c file: 'clacwu.for' subroutine calcwu c + + + PURPOSE + + + c This subroutine reads sub-daily wind speeds from a user supplied c file or simulates the sub-daily wind speeds if the file is not c supplied. c programmer: John Tatarko c version: 07/28/92 C Edit History C 07-Mar-99 wjr changed unit 8 to luiwsd c + + + KEY WORDS + + + c wind speed, wind direction, sub-daily wind speed c + + + GLOBAL COMMON BLOCKS + + + *$noereference include 'p1unconv.inc' include 'p1const.inc' include 'p1werm.inc' include 'wpath.inc' include 'm1sim.inc' include 'w1wind.inc' include 'file.fi' c + + + LOCAL COMMON BLOCKS + + + include 'main/main.inc' *$reference c + + + LOCAL VARIABLES + + + character line*80 logical fexist integer i day, i i, i jd, i month, i year c real large, c r small c + + + LOCAL DEFINITIONS + + + c i - Index on subdaily loop (i=1,ntstep) c day - The current day in the sub-daily wind file. c month - The current month in the sub-daily wind file. c year - The current year in the sub-daily wind file. c large - Variable initialized with small value so that MAX c intrinsic function may find the maximum windspeed. c line - This character variable is used to read the header c information in the file. c small - Variable initialized with large value so that MIN c intrinsic function may find the minimum windspeed. c subfil - This variable holds the subdaily wind information c file name. c subflg - This logical variable is a flag to read header c information in the sub-daily wind file c (if .true., read header; if .false., skip). c + + + FUNCTIONS CALLED + + + integer julday integer lentrm c + + + FUNCTION DEFINITIONS + + + c julday - Calculates the julian date given the day, month, year c + + + OUTPUT FORMATS + + + 2000 format (2i2,2x,i4,1x,f6.1,24f6.2) 2005 format (/,' using subdaily wind file: ',a80) 2010 format (/,' error reading subdaily wind file: ',a80) 2020 format (/,' no subdaily wind in file for',2i3,1x,i4,' - it will be & generated') c + + + END SPECIFICATIONS + + + c + + + INITIALIZATION + + + c small = 1e20 c large = -1e20 c if 'real' sub-daily data exixts - read it open(unit = 24, file = rootp(1:lentrm(rootp)) // 'subday.out') inquire (file = subfil, exist = fexist) if (fexist) then write(*,2005) subfil if (subflg .eqv. .false.) go to 30 20 read (luiwsd,'(a)') line if (line(1:1) .eq. '#') go to 20 backspace (unit = luiwsd) subflg = .false. 30 read (luiwsd, *, end = 80, err = 90) day, month, year, awadir, & (awu(i), i = 1,ntstep) c test for current date c write (*,*) 'julday',day, month,year jd = julday (day, month, year) if (jd .ne. am0jd) then write(*,2020) go to 50 end if c find max, min, and avg c do 40 i = 1, ntstep c large = max(large, awu(i)) c small = min(small, awu(i)) c 40 continue c awudmx = large c awudmn = small c awudav = (awudmx + awudmn) / 2. go to 600 80 backspace (unit= luiwsd) end if c if 'real' data does not exist - generate 50 do 60 i = 1, ntstep awu(i) = awudav + 0.5 * (awudmx - awudmn) * cos( 2. * pi * & ((ntstep * 24) / ntstep - awhrmx + i) / ntstep) 60 continue go to 600 c if error reading sub-daily file 90 write (*,2010) subfil 500 stop 600 call caldat (-1,day,month,year) write(24,2000) day,month,year,awadir,(awu(i),i=1,ntstep) return end