real function ryf2 i (mo,jd,ntd,indpar) c Function 2 of 2 to interpolate preserving the monthly means. c From the values of the month endpoints and the time and value c of the pseudo-midpoint, calculate a daily value for the X-parameter c with index "indpar", for the current day. c c + + + ARGUMENT DECLARATIONS + + + integer mo, jd, ntd integer indpar c c + + + ARGUMENT DEFINITIONS + + + c mo - month input. c jd - day of the month input. c indpar - index of the current parameter. c ntd - days in this year (365 or 366) c include 'cinterp.inc' c read: emv, pmt, pmv, xes c emv - End-of-the-Month Value for the monthly mean of each parameter. c pmt - Pseudo-Midpoint Time for each month, for each parameter. c pmv - Pseudo-Midpoint Value for each month, for each parameter. c c + + + LOCAL VARIABLES + + + integer dim(12) real idim,ipmt,ipmv,emv0,emv1,ratio,mjd c c + + + LOCAL DEFINITIONS + + + c dim - Days in each Month. c idim - Number of days in the current month. c ipmt - Pseudo-Midpoint Time of the current month. c ipmv - Pseudo-Midpoint Value of the current month. c emv0 - End of Month Value at Start of current month. c emv1 - End of Month Value at End of current month. c mjd - (middle of) day of the month input (ie, noon). c c c + + + DATA INITIALIZATIONS + + + data dim/31,28,31,30,31,30,31,31,30,31,30,31/ c c + + + END SPECIFICATIONS + + + c c The intercepts at the end of the months are based on Midnight. c However, the appropriate time to represent a day is Noon (the c middle of the day, or the expected value). Therefore it is c necessary to adjust from Midnight on day-X to Noon on day-X; ie, c to subtract half a day. c c There are two intervals related to each month, before the pseudo- c midpoint, and after it. The appropriate one to use depends upon c the current day of the month (JD). Determine which to use, and c interpolate a daily value for the current parameter. c c-----(not February in a LY) if(mo.ne.2 .or. ntd.ne.366) then idim = dim(mo) ipmt = pmt(mo,indpar) ipmv = pmv(mo,indpar) if(mo.gt.1) then emv0 = emv(mo-1,indpar) else emv0 = emv(12,indpar) endif emv1 = emv(mo,indpar) c-----(it is February in a LY) else idim = 29 ipmt = pmt(13,indpar) ipmv = pmv(13,indpar) emv0 = emv(13,indpar) emv1 = emv(14,indpar) endif c c ---- Compare current date (MJD) to the pseudo-midpoint of month (IPMT). mjd = float(jd) - 0.5 c-----(last half of month) if(mjd .gt. ipmt) then c-------(not a max or min month) if(xes(mo,indpar) .eq. -9999.0) then ratio = (idim - mjd) / (idim - ipmt) ryf2 = ratio*ipmv + (1-ratio)*emv1 c-------(it is a max or min month) else c---------(last quarter of the month) if(mjd .gt. 0.75*idim) then ratio = (idim - mjd) / (0.25*idim) ryf2 = ratio*xes(mo,indpar) + (1-ratio)*emv1 c---------(third quarter) else ratio = (mjd - 0.5*idim) / (0.25*idim) ryf2 = ratio*xes(mo,indpar) + (1-ratio)*ipmv endif endif c ---- Compare to the previous month. else if(xes(mo,indpar) .eq. -9999.0) then ratio = mjd / ipmt ryf2 = ratio*ipmv + (1-ratio)*emv0 else c---------(first quarter of the month) if(mjd .lt. 0.25*idim) then ratio = mjd / (0.25*idim) ryf2 = ratio*xes(mo,indpar) + (1-ratio)*emv0 c---------(second quarter) else ratio = (0.5*idim - mjd) / (0.25*idim) ryf2 = ratio*xes(mo,indpar) + (1-ratio)*ipmv endif endif endif c return end