⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readfile.f

📁 水文模型的原始代码
💻 F
📖 第 1 页 / 共 2 页
字号:
      subroutine readfile

!!    ~ ~ ~ PURPOSE ~ ~ ~
!!   this subroutine opens the main input and output files and reads watershed
!!   information from the file.cio

!!    ~ ~ ~ INCOMING VARIABLES ~ ~ ~
!!    name        |units         |definition
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!!    mhruo       |none          |maximum number of variables in output.hru file
!!    mrcho       |none          |maximum number of variables in output.rch file
!!    msubo       |none          |maximum number of variables in output.sub file
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

!!    ~ ~ ~ OUTGOING VARIABLES ~ ~ ~
!!    name        |units       |definition
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!!    calfile     |NA          |name of file containing calibration parameters
!!    fcstcycles  |none        |number of times forecast period is simulated
!!                             |(using different weather generator seeds each
!!                             |time)
!!    fcstday     |julian date |beginning date of forecast period
!!    fcstyr      |year        |beginning year of forecast period
!!    iclb        |none        |auto-calibration flag
!!    idaf        |julian date |beginning day of simulation
!!    idal        |julian date |ending day of simulation
!!    idg(:)      |none        |array location of random number seed
!!                             |used for a given process
!!    idist       |none        |rainfall distribution code
!!                             |  0 for skewed normal dist
!!                             |  1 for mixed exponential distribution
!!    idt         |minutes     |length of time step used to report
!!                             |precipitation data for sub-daily modeling
!!    igen        |none        |random number generator seed code
!!    ilog        |none        |streamflow print code
!!    iprint      |none        |print code:0=monthly,1=daily,2=annual
!!    ipdhru(:)   |none        |HRUs whose output information will be
!!                             |printed to the output.hru and output.wtr
!!                             |files
!!    ipdvab(:)   |none        |output variable codes for output.sub file
!!    ipdvar(:)   |none        |output variable codes for output.rch file
!!    ipdvas(:)   |none        |output varaible codes for output.hru file
!!    iprp        |none        |print code for output.pst file
!!                             |0 do not print pesticide output
!!                             |1 print pesticide output
!!    isproj      |none        |special project code:
!!                             |1 test rewind (run simulation twice)
!!    itotb       |none        |number of output variables printed 
!!                             |(output.sub)
!!    itoth       |none        |number of HRUs printed (output.hru/output.wtr)
!!    itotr       |none        |number of output variables printed (output.rch)
!!    itots       |none        |number of output variables printed (output.hru)
!!    iyr         |year        |beginning year of simulation
!!    nbyr        |none        |number of calendar years simulated
!!    nhtot       |none        |number of relative humidity records in file
!!    nrgage      |none        |number of raingage files
!!    nrgfil      |none        |number of rain gages per file
!!    nrtot       |none        |total number of rain gages
!!    nstep       |none        |number of lines of rainfall data for each
!!                             |day
!!    nstot       |none        |number of solar radiation records in file
!!    ntgage      |none        |number of temperature gage files
!!    ntgfil      |none        |number of temperature gages per file
!!    nttot       |none        |total number of temperature gages
!!    nwtot       |none        |number of wind speed records in file
!!    nyskip      |none        |number of years to not print output
!!    pcpsim      |none        |rainfall input code
!!                             |1 measured data read for each subbasin
!!                             |2 data simulated for each subbasin
!!    rcor        |none        |correction coefficient for generated rainfall
!!                             |to ensure that the annual means for generated
!!                             |and observed values are comparable. (needed
!!                             |only if IDIST=1)
!!    rexp        |none        |value of exponent for mixed exponential
!!                             |rainfall distribution (needed only if
!!                             |IDIST=1)
!!    rfile(:)    |NA          |rainfall file names (.pcp)
!!    rhfile      |NA          |relative humidity file name (.hmd)
!!    rhsim       |none        |relative humidity input code
!!                             |1 measured data read for each subbasin
!!                             |2 data simulated for each subbasin
!!    rndseed(:,:)|none        |random number generator seed
!!    slrfile     |NA          |solar radiation file name (.slr)
!!    slrsim      |none        |solar radiation input code
!!                             |1 measured data read for each subbasin
!!                             |2 data simulated for each subbasin
!!    tfile(:)    |NA          |temperature file names (.tmp)
!!    title       |NA          |description lines in file.cio(1st 3 lines)
!!    tmpsim      |none        |temperature input code
!!                             |1 measured data read for each subbasin
!!                             |2 data simulated for each subbasin
!!    wndfile     |NA          |wind speed file name (.wnd)
!!    wndsim      |none        |wind speed input code
!!                             |1 measured data read for each subbasin
!!                             |2 data simulated for each subbasin
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

!!    ~ ~ ~ LOCAL VARIABLES ~ ~ ~
!!    name        |units       |definition
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!!    bsnfile     |NA          |name of basin input file (.bsn)
!!    fcstfile    |NA          |name of weather forecast data file (.cst
!!    fertdb      |NA          |name of fertilizer database file (fert.dat)
!!    figfile     |NA          |name of watershed configuration file (.fig)
!!    ii          |none        |counter
!!    j           |none        |counter
!!    pestdb      |NA          |name of pesticide database input file(pest.dat)
!!    plantdb     |NA          |name of LU/LC database input file (crop.dat)
!!    rn          |none        |random number generator seed
!!    sumv        |none        |variable to hold intermediate calculation
!!    tilldb      |NA          |name of tillage database input file(till.dat)
!!    urbandb     |NA          |name of urban database file (urban.dat)
!!    xx          |none        |random number between 0.0 and 1.0
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

!!    ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!!    SWAT: gcycl, caps, Aunif
!!    ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~


      use parm

      character (len=13) :: figfile, bsnfile, plantdb, tilldb, urbandb, &
     &    pestdb, fertdb, fcstfile
      character (len=80) :: titldum
      real :: sumv, xx
      integer :: rn, j, ii, eof
      eof = 0

      bsnfile = ""
      fcstfile = ""
      plantdb = ""
      fertdb = ""
      pestdb = ""
      figfile = ""
      tilldb = ""
      urbandb = ""

      open (101,file="file.cio")

!! Read project description
      read (101,5101) titldum
      read (101,5101) titldum
      read (101,5100) title

!! Read general information/watershed configuration
      read (101,5101) titldum
      read (101,5000) figfile
      read (101,*) nbyr
      read (101,*) iyr
      read (101,*) idaf
      read (101,*) idal

      call caps(figfile)
      open (102,file=figfile)

!! Read climate information
      read (101,5101) titldum
      read (101,*) igen
      read (101,*) pcpsim
      read (101,*) idt
      read (101,*) idist
      read (101,*) rexp
      read (101,*) nrgage
      read (101,*) nrtot
      read (101,*) nrgfil
      read (101,*) tmpsim
      read (101,*) ntgage
      read (101,*) nttot
      read (101,*) ntgfil
      read (101,*) slrsim
      read (101,*) nstot
      read (101,*) rhsim
      read (101,*) nhtot
      read (101,*) wndsim
      read (101,*) nwtot
      read (101,*) fcstyr
      read (101,*) fcstday
      read (101,*) fcstcycles
      read (101,5101) titldum
      read (101,5000) (rfile(j),j = 1,18)
      read (101,5101) titldum
      read (101,5000) (tfile(j),j = 1,18)
      read (101,5000) slrfile
      read (101,5000) rhfile
      read (101,5000) wndfile
      read (101,5000) fcstfile
 
      !! calculate precipitation data lines per day
      if (idt > 0) nstep = 1440 / idt

      call gcycl

      !! calculate values related to exponential rainfall distribution
      if (idist == 1) then
        if (rexp <= 0.) rexp = 1.3
        sumv = 0.
        rn = 0
        rn = rndseed(idg(3),1)
        do j = 1, 10000
          xx = 0.
          xx = Aunif(rn)
          sumv = sumv + (-Log(xx))**rexp
        end do
        if (sumv > 0.) then
          rcor = 10100. / sumv
        else
          rcor = 1.
        endif
      endif

      if (nrgfil <= 0) nrgfil = 10
      if (nrtot <= 0) nrtot = nrgage * nrgfil
      if (ntgfil <= 0) ntgfil = 10
      if (nttot <= 0) nttot = nrgage * ntgfil

      !! check for values on forecast variables
      if (fcstyr > 0 .and. fcstday > 0) then
        if (fcstcycles <= 0) fcstcycles = 1
      else
        fcstcycles = 1
      end if

      do j = 1, nrgage
        call caps(rfile(j))
      end do
      do j = 1, ntgage
        call caps(tfile(j))
      end do
      call caps(slrfile)
      call caps(rhfile)
      call caps(wndfile)

      call caps(fcstfile)
      if (fcstfile /= '             ') then 
        open (109,file=fcstfile)
      else
        fcstyr = 0
        fcstday = 0
      end if

!!Open watershed modeling option file
      read (101,5101) titldum
      read (101,5000) bsnfile

      call caps(bsnfile)
      open (103,file=bsnfile)

!!Open database files
      read (101,5101) titldum
      read (101,5000) plantdb
      read (101,5000) tilldb
      read (101,5000) pestdb
      read (101,5000) fertdb
      read (101,5000) urbandb

      call caps(plantdb)
      call caps(tilldb)
      call caps(pestdb)
      call caps(fertdb)
      call caps(urbandb)
      open (104,file=plantdb)
      open (105,file=tilldb)
      open (106,file=pestdb)
      open (107,file=fertdb)
      open (108,file=urbandb)

!!Special Projects input
      read (101,5101) titldum
      read (101,*) isproj
      read (101,*) iclb
      read (101,5000) calfile

!!Output Information input
      read (101,5101) titldum
      read (101,*) iprint
      read (101,*) nyskip
      read (101,*) ilog
      read (101,*) iprp
      read (101,*) iprs

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -