subroutine wxr_gen i (version,igcode,stidd,ylt,yll,years,elev, i jd,itype,clt,tymax,timpkd,usdur,damt,ustpr,uxmav, CC m iyear,numyr,xm,smy,tmpcmx,tmpcmn,ntd1,moveto, m iyear,xm,smy,tmpcmx,tmpcmn,ntd1,moveto, o sumpp,sumptx,sumptm,sumprd,sumpdr) c c ----- Split out from the CLIGEN main module 10/8/99 by C. R. Meyer. c c + + + PURPOSE + + + c The "guts" of the weather generating code. c c + + + ARGUMENT DECLARATIONS + + + real version,ylt,yll,xm,clt,usdur,damt,ustpr,uxmav real smy(12),tymax(4),timpkd(0:12),tmpcmx(12),tmpcmn(12) real sumpp(13),sumptx(12),sumptm(12),sumprd(12),sumpdr(12) C integer igcode,years,elev,iyear,numyr,ntd1,jd,itype,moveto integer igcode,years,elev,iyear,ntd1,jd,itype,moveto character*41 stidd c c + + + ARGUMENT DEFINITIONS + + + c version - CLIGEN version (ie, 5.102) c igcode - wind information/ET equation flag c 0 -- wind information exists: use Penman ET equation c 1 -- no wind information exists: use Priestly-Taylor c ET equation c stidd - 41-character alphanumeric station name. c ylt - Station Latitude. c yll - Station Longitude. c years - Years of Record. c elev - Station Elevation above Sea Level (whole number of meters) c jd - Day of the Storm. c itype - integer value [1..4] to set single storm parameters. c clt - 57.296 180/pi: deg -> radians convert; deg/clt -> radian c tymax(4) - upper limit of r5p (based on itype) c timpkd - The 12 interval time to peak accummulated distribution c usdur - Storm Duration in Hours for Single Storm. c damt - Design Storm Amount in Inches for Single Storm. c ustpr - Time to Peak Intensity (% Duration e.g. .4). c uxmav - Maximum Intensity Inches/Hour for Single Storm. c iyear - Beginning Simulation Year. c numyr - Number of years to simulate. c xm - number of days in the month of interest c smy - Observed Monthly Average Precipitation (mm) c tmpcmx - Observed Monthly Average Max Temperature (C) c tmpcmn - Observed Monthly Average Min Temperature (C) c ntd1 - julian date of jd, mo (iopt = 4, 7) c moveto - A global flag. If set to 'XX' it means "goto XX". c sumpp(13) - "prcp" (average monthly values for numyr years) c (13: average annual precipitation) c sumptx(12) - "tmax" (average monthly values for numyr years) c sumptm(12) - "tmin" (average monthly values for numyr years) c sumprd(12) - "rad" (average monthly values for numyr years) c sumpdr(12) - "dur" (average monthly values for numyr years) c c + + + COMMON BLOCKS + + + include 'f2kcli.inc' !For Fortran 2k commandline parsing code include 'cbk4.inc' c read: nc,mo,iopt c modify: nt c include 'cbk7.inc' c read: rst,prw,obmx,obmn,obsl c include 'ccl1.inc' c write: prcip,tgmx,tgmn,radg,dur c include 'command.inc' c read: numyr, irand c include 'cinterp.inc' c read: interp c c + + + LOCAL VARIABLES + + + c isim - simulation mode c 1 -- continuous storm (iopt = 5, 6) c 2 -- single storm (iopt = 4, 7) c itemp - breakpoint data flag c 0 -- no breakpoint data used c 1 -- breakpoint data used c xr - daily precipitation amount (mm of water) c simulated rainfall amount (mm) [Yu's P] integer jk, ntd, station_code, kkk, ii, itemp integer isim, nbt, i character*60 argv character*256 cmd_str integer cmd_len,status !parms for get_command() subroutine call c c + + + SUBROUTINES CALLED + + + c day_gen c opt_calc c c + + + FUNCTION DECLARATIONS + + + integer jdt integer iargc c c + + + OUTPUT FORMATS + + + 500 format(1x,'Observed monthly ave max temperature (C)',/, 1 1x,12(f5.1,1x),/, 1 1x,'Observed monthly ave min temperature (C)',/, 1 1x,12(f5.1,1x)) 520 format(1x,'Observed monthly ave solar radiation (Langleys/day)',/, 1 12(1x,f5.1)) 555 format(1x,'Observed monthly ave precipitation (mm)',/, 1 12(1x,f5.1)) c642 format(f5.2) 642 format(f6.3) 644 format(' Station: ',a41,6x,' CLIGEN VERSION',f6.3) 645 format(' Latitude Longitude Elevation (m) Obs. Years ', 1 ' Beginning year Years simulated',/ 1 2f9.2,i12,2i12,i16) 648 format(' da mo year prcp dur tp ip tmax', 1 ' tmin rad w-vl w-dir tdew', 2 /,13x,'(mm) (h)',15x,'(C) (C)', 3 ' (l/d) (m/s)(Deg) (C)') 778 format(3i4) c c + + + END SPECIFICATIONS + + + c c c Get Everything Ready to Start Generation by Options Selected c 140 continue do 150 i=1,12 sumpp(i)=0.0 sumptx(i)=0.0 sumptm(i)=0.0 sumprd(i)=0.0 sumpdr(i)=0.0 150 continue sumpp(13)=0.0 c c See What Option was Selected and Set Paths c nbt=1 if(iopt .ge. 4)then isim=1 if(iopt.eq.4.or.iopt.eq.7) isim =2 itemp=0 if(iopt.ge.4) then if (dohedr) then write(7,644)stidd, version !output station name and version C cmd_str = "" C numarg = iargc() C do i=0, numarg C call getarg(i,argv) C cmd_str = trim(cmd_str) // ' ' // trim(argv) C end do call get_command(cmd_str,cmd_len,status) write(7,*) trim(cmd_str) !output command line string write(7,645)ylt,yll,elev,years,iyear,numyr c c ************************************************************** c * P(A,B) = P(A|B) * P(B), so: * c * * c * P(W) = P(W,D)+P(W,W) = P(W|D) / [1 - P(W|W) + P(W|D)] * c * * c * C. R. Meyer -- 7/30/2000 * c ************************************************************** c c CALCULATE MONTHLY RAINFALL AMOUNTS do 111 kkk = 1,12 xm = nc(kkk+1)-nc(kkk) c ---------- calculate number of days of rainfall in month smy(kkk) = xm*prw(2,kkk)/(1.-prw(1,kkk) + prw(2,kkk)) c ---------- monthly rainfall in mm smy(kkk) = smy(kkk) * rst(kkk,1) * 25.4 c ---------- Convert Observed Temps to degrees-C tmpcmx(kkk)=(obmx(kkk)-32.0)*(5.0/9.0) tmpcmn(kkk)=(obmn(kkk)-32.0)*(5.0/9.0) 111 continue write(7,500)tmpcmx,tmpcmn write(7,520)obsl write(7,555)smy write(7,648) endif endif endif if(iopt.eq.4.or.iopt.eq.7) then nt=0 if((iyear-iyear/4*4).eq.0) nt=1 ntd1 = jdt(nc,jd,mo,nt) nbt = ntd1 numyr=1 endif c c Generate Data by Number of Years and Option - MAIN LOOP c ii = 1 160 continue moveto = 0 ntd=365 if((iopt.le.3.or.iopt.eq.5.or.iopt.eq.6) .and. 1 (iyear-iyear/4*4).eq.0) ntd=366 do 170 i=1,12 do 169 jk=1,31 prcip(i,jk)=0.0 tgmx(i,jk)=0.0 tgmn(i,jk)=0.0 radg(i,jk)=0.0 dur(i,jk)=0.0 169 continue 170 continue c call day_gen(nbt,jd,iyear,clt,tymax,timpkd,usdur,damt,ustpr, 1 uxmav,itype,ntd1,ntd,moveto) c if(moveto .ne. 225) then CC call opt_calc(iyear,stidd,numyr,station_code,ii,sumpp,sumptx, call opt_calc(iyear,stidd,station_code,ii,sumpp,sumptx, 1 sumptm,sumprd,sumpdr,moveto) c if(moveto.eq.0) then iyear=iyear+1 ii = ii + 1 endif endif if((moveto.eq.0 .and. ii.le.numyr).or.(moveto.eq.160)) goto 160 c return end