subroutine lintrp i (mo,jd,ntd) c c + + + PURPOSE + + + c Used for smoothing between average monthly values (like max & min c temp), from which daily values are stochastically generated (using c random numbers) by CLIGEN. Provides factors "lf" & "rf" to perform c a linear interpolation for the input date, between the middle of c the current month, and the middle of an adjacent month. Depending c on the day of the month, values will be needed for either the c previous month, or the following month. The value "o_mo" is the c number of the other month involved in the interpolation. The c interpolated value (Vi) is simply computed as follows: c Vi = V(mo)*lf + V(o_mo)*rf . c c Uses linear interpolation. Outputs "weighting factors" for the c average monthly parameters associated with the midpoints of the c months on either side of the date that is input. c c Written by Charles R. Meyer 12/02/99 in consultation with Roel Vining. c c Note that for a linear interpolation "lf" is simply the fraction c of the distance from the _upper_ time midpoint, and "rf" is the c converse at the other end of the interval. Also lf + rf = 1.0 . c c + + + ARGUMENT DECLARATIONS + + + integer mo, jd, ntd c c + + + ARGUMENT DEFINITIONS + + + c mo - month input. c jd - day of the month input. c ntd - days in this year (365 or 366) c c + + + COMMON BLOCKS + + + include 'cinterp.inc' c write: lf, rf, o_mo c lf - weighting factor for the midpoint value on this month's end c of the time interval. c rf - weighting factor for the midpoint value on the "other" end. c o_mo - month (on the "other" end) whose average value should be used. c c + + + LOCAL VARIABLES + + + real mp(12),ni(12) c c + + + LOCAL DEFINITIONS + + + c mp - Number of days from beginning to midpoint of each month c (non-leap year). c ni - Number of days from midpoint of previous month to midpoint c of current month; ie, number of days in the interval. c c + + + DATA INITIALIZATIONS + + + data mp/15.5,14.0,15.5,15.0,15.5,15.0,15.5,15.5,15.0,15.5,15.0, 1 15.5/ data ni/31.0,29.5,30.0,30.5,30.5,30.5,30.5,31.0,30.5,30.5,30.5, 1 30.5/ c c + + + END SPECIFICATIONS + + + c c ---- Adjust February's midpoint (ni) for Leap Year. if(ntd .eq. 366) then ni(2) = 30.0 else ni(2) = 29.5 endif c c There are two intervals related to each month. The appropriate c one to use depends upon the day of the month. Determine whether c it is the previous month, or the following month that is of interest. c ---- Compare to the next month. if(float(jd) .gt. mp(mo)) then o_mo = mod(mo+1,12) if(o_mo .eq. 0) o_mo = 12 rf = (jd - mp(mo)) / ni(o_mo) c ---- Compare to the previous month. else o_mo = mod(mo-1,12) if(o_mo .eq. 0) o_mo = 12 rf = (mp(mo) - jd) / ni(mo) endif c lf = 1.0 - rf c return end