exco_read_pest.f90 Source File


This file depends on

sourcefile~~exco_read_pest.f90~~EfferentGraph sourcefile~exco_read_pest.f90 exco_read_pest.f90 sourcefile~constituent_mass_module.f90 constituent_mass_module.f90 sourcefile~exco_read_pest.f90->sourcefile~constituent_mass_module.f90 sourcefile~exco_module.f90 exco_module.f90 sourcefile~exco_read_pest.f90->sourcefile~exco_module.f90 sourcefile~hydrograph_module.f90 hydrograph_module.f90 sourcefile~exco_read_pest.f90->sourcefile~hydrograph_module.f90 sourcefile~input_file_module.f90 input_file_module.f90 sourcefile~exco_read_pest.f90->sourcefile~input_file_module.f90 sourcefile~maximum_data_module.f90 maximum_data_module.f90 sourcefile~exco_read_pest.f90->sourcefile~maximum_data_module.f90 sourcefile~organic_mineral_mass_module.f90 organic_mineral_mass_module.f90 sourcefile~exco_read_pest.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~basin_module.f90 basin_module.f90 sourcefile~hydrograph_module.f90->sourcefile~basin_module.f90 sourcefile~time_module.f90 time_module.f90 sourcefile~hydrograph_module.f90->sourcefile~time_module.f90 sourcefile~carbon_module.f90 carbon_module.f90 sourcefile~organic_mineral_mass_module.f90->sourcefile~carbon_module.f90

Source Code

      subroutine exco_read_pest
    
      use hydrograph_module
      use input_file_module
      use organic_mineral_mass_module
      use constituent_mass_module
      use exco_module
      use maximum_data_module

      implicit none
 
      character (len=80) :: titldum = ""
      character (len=80) :: header = ""
      integer :: eof = 0
      integer :: imax = 0
      integer :: ob1 = 0
      integer :: ob2 = 0
      logical :: i_exist              !none       |check to determine if file exists
      integer :: iexco_pest = 0
      integer :: ii = 0
      integer :: ipest = 0
      integer :: iexco = 0
      integer :: iob = 0
      eof = 0
      imax = 0
      
      !read all export coefficient data
      inquire (file=in_exco%pest, exist=i_exist)
      if (i_exist .or. in_exco%pest /= "null") then
        do
          open (107,file=in_exco%pest)
          read (107,*,iostat=eof) titldum
          if (eof < 0) exit
          read (107,*,iostat=eof) header
          if (eof < 0) exit
          imax = 0
          do while (eof == 0)
            read (107,*,iostat=eof) titldum
            if (eof < 0) exit
            imax = imax + 1
          end do
          
          db_mx%exco_pest = imax
          
          allocate (exco_pest(imax))
          do iexco_pest = 1, imax
            allocate (exco_pest(iexco_pest)%pest(cs_db%num_pests), source = 0.)
          end do
          allocate (exco_pest_num(imax), source = 0)
          allocate (exco_pest_name(imax))
          rewind (107)
          read (107,*,iostat=eof) titldum
          if (eof < 0) exit
          read (107,*,iostat=eof) header
          if (eof < 0) exit
      
          !read all pesticide export coefficient data
          do ii = 1, db_mx%exco_pest
            read (107,*,iostat=eof) titldum
            if (eof < 0) exit
            backspace (107)
            read (107,*,iostat=eof) exco_pest_name(ii), (exco_pest(ii)%pest(ipest), ipest = 1, cs_db%num_pests)   
            if (eof < 0) exit
          end do
          close (107)
          exit
        end do
      end if
            
      ! xwalk with exco file to get sequential number
      do iexco = 1, db_mx%exco
        do iexco_pest = 1, db_mx%exco_pest
          if (exco_db(iexco)%pest_file == exco_pest_name(iexco_pest)) then
            exco_pest_num(iexco) = iexco_pest
            exit
          end if
        end do
      end do
      
      ! set exco_pest object hydrograph
      ob1 = sp_ob1%exco
      ob2 = sp_ob1%exco + sp_ob%exco - 1
      do iob = ob1, ob2
        iexco = ob(iob)%props
        if (exco_db(iexco)%pest_file == "null") then
          obcs(iob)%hd(1)%pest = 0.
        else
          iexco_pest = exco_pest_num(iexco)
          obcs(iob)%hd(1)%pest = exco_pest(iexco_pest)%pest
        end if
      end do
      
      return
      end subroutine exco_read_pest