c file: 'wsum.for' subroutine wsum c + + + PURPOSE + + + c This subroutine summarizes the WINDGEN and CLIGEN weather c simulation output files by month and year. c author: John Tatarko c version: 04/02/92 c + + + KEY WORDS + + + c WERM, CLIGEN, WINDGEN, weather, summary c + + + GLOBAL COMMON BLOCKS + + + *$noereference include 'p1werm.inc' include 'p1unconv.inc' include 'wpath.inc' include 'w1clig.inc' include 'w1wind.inc' c + + + LOCAL COMMON BLACKS + + + include 'main/main.inc' *$reference c + + + LOCAL VARIABLES + + + character header*80 logical l mofl, l yrfl integer bd, bm, i ccd, ccm, ccy, cwd, cwm, cwy, count, i ed, em, i i, j, k, i last, i tucnt, i ucnt, i ycount real avedt, avepir, awuyav, awupav, awdair, r dur, r rad, r sumdpt, sumdt, sumdir, sumdu, r tp, r wdir, wvel, r xmav, r ysumpt, ysumdt, ysumpi, ysumu, yavedt, yavepi c + + + LOCAL DEFINITIONS + + + c avedt - average temperature for the month. c avepir - average global radiation for the month. c awtdav - average of the maximum and minimum temperature for c each day. c awudav - average of the maximum and minimum wind speed for c each day. c awupav - average wind speed for the month. c awuyav - average wind speed for the year. c bd - beginning day of the period. c bm - beginning month of the period. c ccd,ccm,ccy - current day, month, and year of the CLIGEN file. c cwd,cwm,cwy - current day, month, and year of the WINDGEN file. c clifil - CLIGEN input file name. c count - total number of days in the month. c dur - duration pf precipitation produced by CLIGEN c ed - last day of the period. c em - last month of the period. c header - character header information. c i - counter for simulation loops. c irise - time of sunrise (not used). c j,k - iocheck variables which are set to -1 when the end of c file is encountered. c last - last day of the current month as determined by the c function 'lstday'. c mofl - flag set to record the first day of period. c rad - global radiation. c sumdpt - sum of daily precipitation. c sumdt - sum of daily temperature. c sumdir - sum of daily global radiation. c sumdu - sum of daily average wind speed. c tp - produced by CLIGEN (not used here). c tucnt - total number of days wind speed > 8 m/s for year. c ucnt - total number of days wind speed > 8 m/s for month. c wdir - wind direction produced by CLIGEN (not used here). c wvel - wind speed produced by CLIGEN (not used here). c winfil - WINDGEN input file name. c xmav - produced by CLIGEN (not used here). c ycount - total number of days in the year. c ysumpt - sum of yearly precipitation. c ysumdt - sum of yearly temperature. c ysumpi - sum of yearly global radiation. c ysumu - sum of average yearly wind speed. c yavedt - average of yearly temperature. c yavepi - average of yearly global radiation. c yrfl - flag set to record the current year. c + + + FUNCTIONS CALLED + + + c lstday c + + + FUNCTIONS DECLARATIONS + + + integer lstday c + + + DATA INITIALIZATIONS + + + c set initialization flags mofl = .true. yrfl = .true. count = 0 sumdpt = 0.0 sumdt = 0.0 sumdir = 0.0 sumdu = 0.0 tucnt = 0 ucnt = 0 ysumpt = 0.0 ysumdt = 0.0 ysumpi = 0.0 ysumu = 0.0 ycount = 0 ycount = 0 c + + + INPUT FORMATS + + + 1020 format (a80) 1025 format (a60) 1030 format (2x,i2,2x,i2,1x,i4,1x,2f6.2,f5.2,1x,f6.2,3f7.2,f6.2,2f7.2) 1040 format (1x,i2,1x,i2,1x,i4,3f6.1,f6.2,f6.1) c + + + OUTPUT FORMATS + + + 2000 format (' ') 2025 format (' CLIGEN file: ', a60) 2027 format (' WINDGEN file: ', a60) 2026 format (a60) 2030 format (/,' CLIGEN date - ',i4,i4,' ',i4,/ & ,' does not match WINDGEN date -',i4,i4,' ',i4,/ & ,' check files ') 2210 format (/,' warning, the output file - ',a25,/,' already exists - &press enter to overwrite this file or control break to stop') 2220 format (/,25x,' Period Weather Summary Report',/,80('-'),/) 2230 format (/,80('-'),/, &' Period dates Total Ave. Ave. gl. Ave. wind wind &> Total wind',/, &' begin end precip. temp. radiation speed 8 m/s & energy',/, &' dd/mm dd/mm (mm) (c) (MJ/m^2) (m/s) (days &) (MJ)',/, &80('-')) c2300 format (80('-')) 2890 format (6x,i4) 2900 format (1x,i2.2,'/',i2.2,5x,i2.2,'/',i2.2,1x,2f9.2,2f10.2,i9) 2910 format(1x,5('-'),5x,5('-'),1x,2(2x,7('-')),2(3x,7('-')),4x,5('-')) 2920 format (1x,'01/01',5x,'31/12',1x,2f9.2,2f10.2,i9,/) c + + + END SPECIFICATIONS + + + c open CLIGEN file c10 write (*,*) ' Enter the CLIGEN file name ' c read (*,1025) clifil c inquire(file=clifil,exist=fexist) c if(.not. fexist) write(*,*) clifil,' file not found' c if(.not. fexist) goto 10 open (3, file = clifil) c open WINDGEN file c15 write (*,*) ' Enter the WINDGEN file name ' c read (*,1025) winfil c inquire(file=winfil,exist=fexist) c if(.not. fexist) write(*,*) winfil,' file not found' c if(.not. fexist) goto 15 open (4, file = winfil) c open weather summary output file c write (*,*) ' Enter the output file name ' c read (*,1025) wsum c inquire(file=wsum,exist=fexist) c if(fexist) then c write (*,2210) wsum c read (*,1020) c end if c open (8, file = wsum) write (2,2220) c read CLIGEN header - remove at a later date ? read(3,1020) header read(3,1025) header write(2,2025) clifil write(2,1025) header do 20 i=1,2 read(3,1020) header write(2,1020) header 20 continue read(3,1020) header read(3,1020) header read(3,1020) header read(3,1020) header c read WINDGEN header - remove at a later date ? do 30 i = 1,7 read (4,1020) header 30 continue write(2,2000) write(2,2027) winfil write(2,2230) c read CLIGEN and WINDGEN files 50 read(3,1030,err=100,iostat=j) ccd,ccm,ccy,awzdpt,dur,tp, & xmav,awtdmx,awtdmn,rad,wvel,wdir,awtdpt c write(2,*) 'climate',ccd,ccm,ccy,awzdpt,dur,tp, c & xmav,awtdmx,awtdmn,rad,wvel,wdir,awtdpt read(4,1040,err=100,iostat=k) cwd,cwm,cwy,awadir,awudmx,awudmn, & awdair,awhrmx write (*,*) ' wsum ', awudmx c write(*,*) 'wind', cwd,cwm,cwy,awadir,awudmx,awudmn, c & awdair,awhrmx if ((j .ne. 0) .or. (k .ne. 0)) go to 100 ccy = ccy + 1900 awudav = (awudmx+awudmn)/2. if (awudmx .gt. 8.0) ucnt = ucnt+1 awtdav = (awtdmx+awtdmn)/2. rad = rad * 0.04186 c sum and average if (yrfl .eqv. .true.) write (2,2890) cwy yrfl = .false. if (mofl .eqv. .true.) then bd = ccd bm = ccm end if mofl = .false. sumdpt = sumdpt + awzdpt sumdt = sumdt + awtdav sumdir = sumdir + rad sumdu = sumdu + awudav count = count + 1 last = lstday(ccm, ccy) if (ccd .eq. last) then ed = ccd em = ccm avedt = sumdt / count avepir = sumdir / count awupav = sumdu / count write (2,2900) bd,bm,ed,em,sumdpt,avedt,avepir,awupav,ucnt mofl = .true. ysumpt = ysumpt + sumdpt ysumdt = ysumdt + sumdt ysumpi = ysumpi + sumdir ysumu = ysumu + sumdu ycount = ycount + count tucnt = tucnt + ucnt sumdpt = 0.0 sumdt = 0.0 sumdir = 0.0 sumdu = 0.0 count = 0 ucnt = 0 end if if ((ccd .eq. 31) .and. (ccm .eq. 12)) then yavedt = ysumdt / ycount yavepi = ysumpi / ycount awuyav = ysumu / ycount write (2,2910) write (2,2920) ysumpt,yavedt,yavepi,awuyav,tucnt yrfl = .true. ysumpt = 0.0 ysumdt = 0.0 ysumpi = 0.0 ysumu = 0.0 ycount = 0 tucnt = 0 end if go to 50 100 write (2,2000) close (unit = 2) close (unit = 3) close (unit = 4) return end