subroutine sta_dat i (ylt,yll,years,elev,itype,tp6,wgt, m version,moveto, o stidd,timpkd,igcode) c + + + PURPOSE + + + c To determine desired station and load the parameters required to c generate its weather. c c ----- Split out from the CLIGEN main module 9/22-27/99 by C. R. Meyer. c c + + + ARGUMENT DECLARATIONS + + + real ylt,yll,wgt(3),timpkd(0:12),tp6,version integer itype, igcode c--- XXX -- Huh? ELEV is declared to be an *integer*, but in the c data file it is a floating-point!!! --- CRM -- 9/27/99 integer years,elev,moveto character*41 stidd c c c + + + ARGUMENT DEFINITIONS + + + c ylt - Station Degrees Latitude (+ is N, - is S). c yll - Station Degrees Longitude (+ is E, - is W). c years - Years of Record at Station. c elev - Station Elevation above Sea Level (whole number of meters) c itype - integer value [1..4] to set single storm parameters. c tp6 - maximum 6 hour precipitation depth (inches). c wgt(3) - 3 wind station weights used for triangulation -- weighting c factor for wind stations used for interpolation c istate - Numeric Climate Code of Desired State. c index - 4-digit numeric station index. c moveto - A global flag. If set to 'XX' it means "goto XX". c stidd - 41-character alphanumeric station name. c timpkd - The 12 interval time to peak accummulated distribution c parameters for the station. Cumulative distribution of c computed time to peak rainfall intensity values based on c NWS 15-minute rainfall data (section 2.1.4 WEPP tech 1995) 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 c + + + COMMON BLOCKS + + + include 'command.inc' c c + + + LOCAL VARIABLES + + + integer iname,iscnt,nst,station_code,ndflag character*41 stid character*2 dr(55) character*1 yc c c + + + LOCAL DEFINITIONS + + + c Variables Passed to other Modules: c istate - Numeric Climate Code of Desired State. c iscnt - Number of Stations in Selected State. c stid - 41-character ASCII Station Name. c station_code - 4-digit Numeric Station Code. c c nst - Numeric State Code c index - 4-digit numeric station index. c ndflag - "Set" if an "End-of-File" is read. c dr - Array of 2-character state (postal) abbreviations. c yc - 1-character user response (y/n). c dr - Array of 2-character state (postal) abbreviations. c File by that name contains parameters for all the c weather stations in that state for which we can c generate weather. c version - CLIGEN version (ie, 5.103) c c + + + SUBROUTINES CALLED + + + c header c sta_name c sta_parms c c + + + DATA INITIALIZATIONS + + + data dr/'al','az','ar','ca','co','ct','de','fl','ga','id', 1 'il','in','ia','ks','ky','la','me','md','ma','mi', 1 'mn','ms','mo','mt','ne','nv','nh','nj','nm','ny', 1 'nc','nd','oh','ok','or','pa','ri','sc','sd','tn', 1 'tx','ut','vt','va','wa','wv','wi','wy','dc','ak', 1 'hi','pr','pi','if',' '/ c c + + + INPUT FORMATS + + + 1000 format(i4) 1010 format(a41,i2,i4,i2) 1020 format(////////////////////////////////////////////////// 1 ///////////////////////////////) 1030 format(////////////////////////////////////////////////// 1 /////////////////////////////////////////) c c + + + OUTPUT FORMATS + + + 2000 format(/1x,'No stations available - do you want to', 1' continue (y/n)? ') 2010 format(/1x,'Enter the station index: ') c c c + + + END SPECIFICATIONS + + + c if(moveto.ne.10) then timpkd(0)=0.0 c ------ Version number set here for option 5 output header C version=5.103 c if(interactive) then call header(version) !turn of the splash screen header if not interactive endif if(interactive) then write(*,*)' Press Enter to Continue' read(*,'(a1)')yc endif endif c c *************************************************************************** c ---- Determine Desired State, and display Available Stations. c10 continue if(interactive) then ! This routine only allows the user to select the state interactively ! and display the list of available stations for the selected state call sta_name(iscnt,stid,station_code,moveto) endif c *************************************************************************** c -- Move this section (through #50) into STA_NAME? -- CRM 7/13/00. 40 continue if(interactive) then if(moveto.eq.40 .or. (iscnt.le.0 .and. moveto .ne. 50)) then c -------- No Stations Found write(*,2000) read(*,'(a1)')yc if(yc.eq.'y'.or.yc.eq.'Y') then moveto = 10 else moveto = 230 endif endif endif c 50 continue c ****** L1 IF **** ndflag = 0 if(moveto.ne.10 .and. moveto.ne.230) then if(interactive) then write(*,2010) ! Enter station name (number) endif iname = istate if(iname.eq.66) iname=52 if(iname.eq.91) iname=53 if(iname.eq.99) iname=54 if(interactive) then c -------- Choose the Desired Station, from the State Selected. read(*,1000)index endif ndflag = 55 ! Here is where we actually open the cligen database file for reading - LEW if(interactive) then open(10,file=dr(iname),status='old',err=55) ! opens specified cligen db "state" file (interactive mode) else open(10,file=infile,status='old',err=55) ! opens specified cligen db file (commandline arg) endif rewind (10) ndflag = 0 55 continue if(interactive) then if(ndflag .ne. 0) then write(*,*)' Mother Nature does not want to run state ', 1 dr(iname) write(*,*)' Parameters for this state are not loaded on ' write(*,*)' this computer. Check directory for file ', 1 dr(iname) write(*,*)' -- Enter q to quit or c to Continue' read(*,'(a1)')yc if(yc.eq.'q'.or.yc.eq.'Q') then moveto = 230 else moveto = 10 endif endif endif c c ****** L2 IF **** if(moveto.ne.10 .and. moveto.ne.230) then if(interactive) then 60 continue c Gettin Station from State File ndflag = 61 read(10,1010,end=61)stidd,nst,station_code,igcode c ------- Match 2-digit state code & 4-digit station code. c ------- If they don't match, blow past 81 records. ndflag = 0 if((nst.ne.istate).or.(station_code.ne.index)) then if (fs_flag) then !skip # lines based upon db format read(10,1030) !skip to the next record (fs db) else read(10,1020) !skip to the next record (3.1 db) endif ndflag = 60 endif 61 continue c c ---------- Requested Station Not Found -- Try Again? if(ndflag.eq.61) then if(istate.gt.0 .and. index.gt.0) then C stop(" Requested Station Not Found.") stop " Requested Station Not Found." else ndflag = 40 endif endif if(ndflag.eq.60) goto 60 else ! not interactive mode read(10,1010)stidd,nst,station_code,igcode ! read first line in db ! if no state or station code is specified, take first record in cligen db if ((istate .eq. -1) .and. (index .eq. -1)) then C? write(6,*) 'istate and index = 0' C write(6,*) 'should be taking first record in db' continue else ! if a state code and station code is specified, find it 70 continue if((nst.ne.istate).or.(station_code.ne.index)) then if (fs_flag) then read(10,1030) !skip to the next record else read(10,1020) !skip to the next record endif read(10,1010,end=71)stidd,nst,station_code,igcode C write (*,*)'stidd,nst,station_code,igcode,istate,index' C write (*,*)stidd,nst,station_code,igcode,istate,index goto 70 else C write(*,*) 'Should have found state/station' goto 72 ! found state and station, go on endif 71 continue ! if specified state and station code is not here say so and quit stop " Requested State and/or Station Not Found." endif 72 ndflag = 1 endif c CC write(*,*) "NDFLAG", ndflag CC write(*,*)"St_id: ",stidd, "NST: ",nst write(*,*)"Station_ID: ",stidd write(*,*)" State:",istate," Station Number:",index if(ndflag.ne.40) c 1 call sta_parms(stidd,station_code,tp6,wgt,ylt,yll, c 2 years,elev,itype,timpkd) 1 call sta_parms(stidd,index,tp6,wgt,ylt,yll,years,elev,itype, 2 timpkd) c c ****** L2 ENDIF **** endif c **** L1 ENDIF **** endif c c ---- Try Again. if(ndflag.eq.40) goto 40 c c230 continue return end