!*==calcwu.spg processed by SPAG 6.70Rc at 15:33 on 10 Dec 2012 !*------------------ SPAG Configuration Options -------------------- !*--0323,76 000101,-1 000000102011332010100002000000210211210,136 10 -- !*--1100000011112111000000000000,10,10,10,10,10,10,900,100 200000000 -- !*--000000010000000000000,72,72 73,42,38,33 00011112110000100000000 -- !*---------------------------------------------------------------------- !$Author: joelevin $ !$Date: 2011-03-24 11:33:26 -0500 (Thu, 24 Mar 2011) $ !$Revision: 11724 $ !$HeadURL: https://eweru-dev1.eweru.ksu.edu/svn/code/weps1/branches/WEPS_F90_update/weps.src/src/lib_erosion/calcwu.for $ subroutine calcwu use i_p1unconv use i_p1const use i_p1werm use i_wpath use i_m1sim use i_m1flag use i_w1wind use i_file use i_main use s_caldatw use s_exit use s_julday implicit none !*--CALCWU27 ! !*** Start of declarations rewritten by SPAG ! ! Local variables ! integer :: day,i,jd,month,year logical :: fexist character(80) :: line ! !*** End of declarations rewritten by SPAG ! ! + + + PURPOSE + + + ! This subroutine reads sub-daily wind speeds from a user supplied ! file or simulates the sub-daily wind speeds if the file is not ! supplied. ! programmer: John Tatarko ! version: 07/28/92 ! Edit History ! 07-Mar-99 wjr changed unit 8 to luiwsd ! + + + KEY WORDS + + + ! wind speed, wind direction, sub-daily wind speed ! + + + GLOBAL COMMON BLOCKS + + + ! + + + LOCAL COMMON BLOCKS + + + ! + + + LOCAL VARIABLES + + + ! real large, ! r small ! + + + LOCAL DEFINITIONS + + + ! i - Index on subdaily loop (i=1,ntstep) ! day - The current day in the sub-daily wind file. ! month - The current month in the sub-daily wind file. ! year - The current year in the sub-daily wind file. ! large - Variable initialized with small value so that MAX ! intrinsic function may find the maximum windspeed. ! line - This character variable is used to read the header ! information in the file. ! small - Variable initialized with large value so that MIN ! intrinsic function may find the minimum windspeed. ! subfil - This variable holds the subdaily wind information ! file name. ! subflg - This logical variable is a flag to read header ! information in the sub-daily wind file ! (if .true., read header; if .false., skip). ! + + + FUNCTIONS CALLED + + + ! + + + FUNCTION DEFINITIONS + + + ! julday - Calculates the julian date given the day, month, year ! + + + OUTPUT FORMATS + + + 1000 format (2I2,2x,i4,1x,f6.1,24F6.2) 1100 format (/,' using subdaily wind file: ',a80) 1200 format (/,' error reading subdaily wind file: ',a80) 1300 format (/,' no subdaily wind in file for',2I3,1x,i4, & &' - it will be& & & generated') ! + + + END SPECIFICATIONS + + + ! + + + INITIALIZATION + + + ! small = 1e20 ! large = -1e20 ! if 'real' sub-daily data exixts - read it if (am0efl>0) open (unit=24,file=rootp(1:len_trim(rootp)) & &//'subday.out') inquire (file=subfil,exist=fexist) if (fexist) then write (*,1100) subfil if (.NOT.(subflg.EQV..FALSE.)) then do read (luiwsd,'(a)') line if (line(1:1)/='#') then backspace (unit=luiwsd) subflg = .FALSE. exit end if end do end if read (luiwsd,*,end=10,err=30) day,month,year,awadir, & & &(awu(i),i=1,ntstep) ! test for current date ! write (*,*) 'julday',day, month,year jd = julday(day,month,year) if (jd/=am0jd) then write (*,1300) go to 20 end if ! find max, min, and avg ! do 40 i = 1, ntstep ! large = max(large, awu(i)) ! small = min(small, awu(i)) ! 40 continue ! awudmx = large ! awudmn = small ! awudav = (awudmx + awudmn) / 2. go to 50 10 backspace (unit=luiwsd) end if ! if 'real' data does not exist - generate (for original wind_gen data only) 20 if (wind_gen_fmt_flag==1) then ! original wind_gen file format do i = 1,ntstep awu(i) = awudav + 0.5*(awudmx-awudmn) & & *cos(2.*pi*&((ntstep*24)/ntstep-awhrmx+i)/ntstep) end do !awu(i) array should already be populated else if (ntstep/=24) then write (0,*) 'ntstep not equal to 24 - code changes needed!' go to 40 end if go to 50 ! if error reading sub-daily file 30 write (0,1200) subfil 40 call exit(1) ! 500 stop 50 call caldatw(day,month,year) if (am0efl>0) write (24,1000) day,month,year,awadir, & & (awu(i),i=1,ntstep) end subroutine calcwu