Skip to content

Commit

Permalink
Read in PCT_URBAN_MAX and initialize urban accordingly.
Browse files Browse the repository at this point in the history
Also updated variable name from HASURBAN to PCT_URBAN_MAX (ESCOMP#1572 (comment)).
  • Loading branch information
fang-bowen committed Feb 18, 2022
1 parent dd74f20 commit c179615
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/main/surfrdMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ subroutine surfrd_get_data (begg, endg, ldomain, lfsurdat, actual_numcft)
use landunit_varcon , only : max_lunit, istsoil, isturb_MIN, isturb_MAX
use dynSubgridControlMod, only : get_flanduse_timeseries
use dynSubgridControlMod, only : get_do_transient_lakes
use dynSubgridControlMod, only : get_do_transient_urban

!
! !ARGUMENTS:
Expand Down Expand Up @@ -237,6 +238,11 @@ subroutine surfrd_get_data (begg, endg, ldomain, lfsurdat, actual_numcft)
call surfrd_lakemask(begg, endg)
end if

! read the lakemask (necessary for initialization of dynamical urban)
if (get_do_transient_urban()) then
call surfrd_urbanmask(begg, endg)
end if

end subroutine surfrd_get_data

!-----------------------------------------------------------------------
Expand Down Expand Up @@ -792,5 +798,59 @@ subroutine surfrd_lakemask(begg, endg)

end subroutine surfrd_lakemask

!-----------------------------------------------------------------------
subroutine surfrd_urbanmask(begg, endg)
!
! !DESCRIPTION:
! Reads the urban mask, indicating where urban areas are and will grow
! of the landuse.timeseries file.
! Necessary for the initialization of the urban land units.
! All urban density types will intialize if any type exists or will grow.
!
! !USES:
use clm_instur , only : hasurban
use dynSubgridControlMod , only : get_flanduse_timeseries
use clm_varctl , only : fname_len
use fileutils , only : getfil
!
! !ARGUMENTS:
integer, intent(in) :: begg, endg
!
!
! !LOCAL VARIABLES:
type(file_desc_t) :: ncid_dynuse ! netcdf id for landuse timeseries file
character(len=256) :: locfn ! local file name
character(len=fname_len) :: fdynuse ! landuse.timeseries filename
logical :: readvar
!
character(len=*), parameter :: subname = 'surfrd_urbanmask'
!
!-----------------------------------------------------------------------

! get filename of landuse_timeseries file
fdynuse = get_flanduse_timeseries()

if (masterproc) then
write(iulog,*) 'Attempting to read landuse.timeseries data .....'
if (fdynuse == ' ') then
write(iulog,*)'fdynuse must be specified'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if

call getfil(fdynuse, locfn, 0 )

! open landuse_timeseries file
call ncd_pio_openfile (ncid_dynuse, trim(locfn), 0)

! read the lakemask
call ncd_io(ncid=ncid_dynuse, varname='PCT_URBAN_MAX', flag='read', data=hasurban, &
dim1name=grlnd, readvar=readvar)
if (.not. readvar) call endrun( msg=' ERROR: PCT_URBAN_MAX is not on landuse.timeseries file'//errMsg(sourcefile, __LINE__))

! close landuse_timeseries file again
call ncd_pio_closefile(ncid_dynuse)

end subroutine surfrd_urbanmask

end module surfrdMod

0 comments on commit c179615

Please sign in to comment.