Skip to content
22 changes: 18 additions & 4 deletions src/RunModule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ SUBROUTINE initialize_from_file(model, config_filename)

type (noahowpgrid_type), intent (out) :: model
character(len=*), intent (in) :: config_filename ! config file from command line argument
integer :: forcing_timestep ! integer time step (set to dt) for some subroutine calls
integer :: ii, ix, iy
integer :: forcing_timestep ! integer time step (set to dt) for some subroutine calls
integer :: ii, ix, iy ! indices
integer, allocatable, dimension(:,:) :: err_grid ! to catch land use vs. soil inconsistencies

associate(namelist => model%namelist, &
attributes => model%attributes, &
Expand Down Expand Up @@ -245,15 +246,28 @@ SUBROUTINE initialize_from_file(model, config_filename)
do ii = 1, namelist%nsoil
domaingrid%zsnso(:,:,ii) = namelist%zsoil(ii)
end do
domaingrid%IST(:,:) = 1 ! 1 = soil
where (domaingrid%vegtyp == parametersgrid%ISWATER) domaingrid%IST = 2 ! 2 = lake
domaingrid%IST(:,:) = 1 ! 1 = soil
where (domaingrid%vegtyp.eq.parametersgrid%ISWATER) domaingrid%IST = 2 ! 2 = lake

! time variables
domaingrid%nowdate = domaingrid%startdate ! start the model with nowdate = startdate
forcing_timestep = domaingrid%dt ! integer timestep for some subroutine calls
domaingrid%itime = 1 ! initialize the time loop counter at 1
domaingrid%time_dbl = 0.d0 ! start model run at t = 0

!---------------------------------------------------------------------
!--- check consistency of domain land use and soil attributes ---
!---------------------------------------------------------------------
allocate(err_grid(domaingrid%n_x,domaingrid%n_y)); err_grid(:,:) = 0
where (domaingrid%mask.eq.1.and.domaingrid%vegtyp.ne.parametersgrid%ISWATER.and.domaingrid%isltyp.eq.14) err_grid = 1
if(any(err_grid.eq.1)) then; write(*,'(A,i2,A)') 'ERROR: one or more grid cells have a non-water land cover (vegtyp != ',parametersgrid%ISWATER,') and a water soil type (isltyp = 14)'; stop; end if
where (domaingrid%mask.eq.1.and.domaingrid%vegtyp.eq.parametersgrid%ISWATER.and.domaingrid%isltyp.ne.14) err_grid = 1
if(any(err_grid.eq.1)) then; write(*,'(A,i2,A)') 'ERROR: one or more grid cells have a water land cover (vegtyp = ',parametersgrid%ISWATER,') and a non-water soil type (isltyp != 14)'; stop; end if
where (domaingrid%mask.eq.1.and.domaingrid%vegtyp.ne.parametersgrid%ISICE.and.domaingrid%isltyp.eq.16) err_grid = 1
if(any(err_grid.eq.1)) then; write(*,'(A,i2,A)') 'ERROR: one or more grid cells have a non-ice land cover (vegtyp != ',parametersgrid%ISICE,') and an ice soil type (isltyp = 16)'; stop; end if
where (domaingrid%mask.eq.1.and.domaingrid%vegtyp.eq.parametersgrid%ISICE.and.domaingrid%isltyp.ne.16) err_grid = 1
if(any(err_grid.eq.1)) then; write(*,'(A,i2,A)') 'ERROR: one or more grid cells have an ice land cover (vegtyp = ',parametersgrid%ISICE,') and a non-ice soil type (isltyp != 16)'; stop; end if
Comment thread
PhilMiller marked this conversation as resolved.
Outdated

!---------------------------------------------------------------------
!--- set a time vector for simulation ---
!---------------------------------------------------------------------
Expand Down