Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tile drainage #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 65 additions & 18 deletions HRLDAS/IO_code/module_NoahMP_hrldas_driver.F
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module module_NoahMP_hrldas_driver
#endif

#ifdef WRF_HYDRO
REAL, allocatable, DIMENSION(:,:) :: infxsrt,sfcheadrt, soldrain
REAL, allocatable, DIMENSION(:,:) :: infxsrt,sfcheadrt, soldrain, qtiledrain, ZWATBLE2D
integer :: forc_typ, snow_assim, HRLDAS_ini_typ
REAL, allocatable, DIMENSION(:,:) :: etpnd, greenfrac, prcp0
real :: etpnd1
Expand Down Expand Up @@ -80,6 +80,7 @@ module module_NoahMP_hrldas_driver
INTEGER :: IOPT_SOIL ! soil configuration option
INTEGER :: IOPT_PEDO ! soil pedotransfer function option
INTEGER :: IOPT_CROP ! crop model option (0->none; 1->Liu et al.; 2->Gecros)
INTEGER :: IOPT_TDRN ! drainage option (0->none; 1->on)
REAL, ALLOCATABLE, DIMENSION(:,:,:) :: T_PHY ! 3D atmospheric temperature valid at mid-levels [K]
REAL, ALLOCATABLE, DIMENSION(:,:,:) :: QV_CURR ! 3D water vapor mixing ratio [kg/kg_dry]
REAL, ALLOCATABLE, DIMENSION(:,:,:) :: U_PHY ! 3D U wind component [m/s]
Expand Down Expand Up @@ -115,7 +116,14 @@ module module_NoahMP_hrldas_driver
REAL, ALLOCATABLE, DIMENSION(:,:) :: soilcl2 ! Soil texture class with depth
REAL, ALLOCATABLE, DIMENSION(:,:) :: soilcl3 ! Soil texture class with depth
REAL, ALLOCATABLE, DIMENSION(:,:) :: soilcl4 ! Soil texture class with depth

! tile drainage
REAL, ALLOCATABLE, DIMENSION(:,:) :: KLAT_FAC ! factor multiplier to hydraulic conductivity
REAL, ALLOCATABLE, DIMENSION(:,:) :: TDSMC_FAC ! factor multiplier to field capacity
REAL, ALLOCATABLE, DIMENSION(:,:) :: TD_DC ! drainage coefficient for simple
REAL, ALLOCATABLE, DIMENSION(:,:) :: TD_DCOEF ! drainge coefficient for Hooghoudt
REAL, ALLOCATABLE, DIMENSION(:,:) :: TD_DDRAIN ! depth of drain
REAL, ALLOCATABLE, DIMENSION(:,:) :: TD_RADI ! tile radius
REAL, ALLOCATABLE, DIMENSION(:,:) :: TD_SPAC ! tile spacing
! INOUT (with generic LSM equivalent) (as defined in WRF)

REAL, ALLOCATABLE, DIMENSION(:,:) :: TSK ! surface radiative temperature [K]
Expand Down Expand Up @@ -231,6 +239,7 @@ module module_NoahMP_hrldas_driver
REAL, ALLOCATABLE, DIMENSION(:,:) :: RS ! Total stomatal resistance (s/m)
REAL, ALLOCATABLE, DIMENSION(:,:) :: Z0 ! roughness length output to WRF
REAL, ALLOCATABLE, DIMENSION(:,:) :: ZNT ! roughness length output to WRF
REAL, ALLOCATABLE, DIMENSION(:,:) :: QTDRAIN ! tile drain discharge (mm)
INTEGER :: ids,ide, jds,jde, kds,kde, & ! d -> domain
& ims,ime, jms,jme, kms,kme, & ! m -> memory
& its,ite, jts,jte, kts,kte ! t -> tile
Expand Down Expand Up @@ -277,7 +286,13 @@ module module_NoahMP_hrldas_driver
REAL , ALLOCATABLE, DIMENSION(:,:) :: HARVEST
REAL , ALLOCATABLE, DIMENSION(:,:) :: SEASON_GDD
REAL , ALLOCATABLE, DIMENSION(:,:,:) :: CROPTYPE


!------------------------------------------------------------------------
! Needed for TILE DRAINAGE IF IOPT_TDRN = 1 OR 2
!------------------------------------------------------------------------

REAL, ALLOCATABLE, DIMENSION(:,:) :: TD_FRACTION

!------------------------------------------------------------------------
! Single- and Multi-layer Urban Models
!------------------------------------------------------------------------
Expand Down Expand Up @@ -547,14 +562,16 @@ module module_NoahMP_hrldas_driver
integer :: soil_data_option = 1
integer :: pedotransfer_option = 1
integer :: crop_option = 0

integer :: drainage_option=0

integer :: split_output_count = 1
logical :: skip_first_output = .false.
integer :: khour
integer :: kday
real :: zlvl
character(len=256) :: hrldas_setup_file = " "
character(len=256) :: spatial_filename = " "
character(len=256) :: spatial_filename = " "
character(len=256) :: tdinput_flnm = " "
character(len=256) :: external_veg_filename_template = " "
character(len=256) :: external_lai_filename_template = " "
integer :: xstart = 1
Expand Down Expand Up @@ -582,7 +599,7 @@ module module_NoahMP_hrldas_driver
pcp_partition_option, tbot_option, temp_time_scheme_option, &
glacier_option, surface_resistance_option, &

soil_data_option, pedotransfer_option, crop_option, &
soil_data_option, pedotransfer_option, crop_option,drainage_option, &

sf_urban_physics,num_urban_hi,urban_atmosphere_thickness, &
num_urban_ndm,num_urban_ng,num_urban_nwr ,num_urban_ngb , &
Expand All @@ -591,7 +608,7 @@ module module_NoahMP_hrldas_driver

split_output_count, &
khour, kday, zlvl, hrldas_setup_file, &
spatial_filename, &
spatial_filename, tdinput_flnm,&
external_veg_filename_template, external_lai_filename_template, &
xstart, xend, ystart, yend

Expand Down Expand Up @@ -657,6 +674,7 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
IOPT_SOIL = soil_data_option
IOPT_PEDO = pedotransfer_option
IOPT_CROP = crop_option
IOPT_TDRN = drainage_option
!---------------------------------------------------------------------
! NAMELIST end
!---------------------------------------------------------------------
Expand Down Expand Up @@ -937,7 +955,15 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
ALLOCATE ( soilcl2 (XSTART:XEND,YSTART:YEND) ) ! Soil texture class with depth
ALLOCATE ( soilcl3 (XSTART:XEND,YSTART:YEND) ) ! Soil texture class with depth
ALLOCATE ( soilcl4 (XSTART:XEND,YSTART:YEND) ) ! Soil texture class with depth

! tile drainage
ALLOCATE ( KLAT_FAC (XSTART:XEND,YSTART:YEND) ) ! factor multiplier to hydraulic conductivity
ALLOCATE ( TDSMC_FAC (XSTART:XEND,YSTART:YEND) ) ! factor multiplier to field capacity
ALLOCATE ( TD_DC (XSTART:XEND,YSTART:YEND) ) ! drainage coefficient for simple
ALLOCATE ( TD_DCOEF (XSTART:XEND,YSTART:YEND) ) ! drainge coefficient for Hooghoudt
ALLOCATE ( TD_DDRAIN (XSTART:XEND,YSTART:YEND) ) ! depth of drain
ALLOCATE ( TD_RADI (XSTART:XEND,YSTART:YEND) ) ! tile radius
ALLOCATE ( TD_SPAC (XSTART:XEND,YSTART:YEND) ) ! tile spacing

! INOUT (with generic LSM equivalent) (as defined in WRF)

ALLOCATE ( TSK (XSTART:XEND,YSTART:YEND) ) ! surface radiative temperature [K]
Expand Down Expand Up @@ -1053,6 +1079,8 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
ALLOCATE ( RS (XSTART:XEND,YSTART:YEND) ) ! Total stomatal resistance (s/m)
ALLOCATE ( Z0 (XSTART:XEND,YSTART:YEND) ) ! roughness length output to WRF
ALLOCATE ( ZNT (XSTART:XEND,YSTART:YEND) ) ! roughness length output to WRF
ALLOCATE ( QTDRAIN (XSTART:XEND,YSTART:YEND) ) ! tile drainage (mm)
ALLOCATE ( TD_FRACTION (XSTART:XEND,YSTART:YEND) )! tile drainage fraction

ALLOCATE ( XLONG (XSTART:XEND,YSTART:YEND) ) ! longitude
ALLOCATE ( TERRAIN (XSTART:XEND,YSTART:YEND) ) ! terrain height
Expand Down Expand Up @@ -1400,6 +1428,8 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
HARVEST = undefined_real
SEASON_GDD = undefined_real
CROPTYPE = undefined_real
QTDRAIN = undefined_real
TD_FRACTION= undefined_real

IF(SF_URBAN_PHYSICS > 0 ) THEN ! any urban model
HRANG = undefined_real
Expand Down Expand Up @@ -1440,7 +1470,8 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
if (soil_data_option == 4) then
CALL READ_3D_SOIL(SPATIAL_FILENAME, XSTART, XEND, YSTART, YEND, &
NSOIL,BEXP_3D,SMCDRY_3D,SMCWLT_3D,SMCREF_3D,SMCMAX_3D, &
DKSAT_3D,DWSAT_3D,PSISAT_3D,QUARTZ_3D,REFDK_2D,REFKDT_2D)
DKSAT_3D,DWSAT_3D,PSISAT_3D,QUARTZ_3D,REFDK_2D,REFKDT_2D, &
KLAT_FAC,TDSMC_FAC,TD_DC,TD_DCOEF,TD_DDRAIN,TD_RADI,TD_SPAC)
end if

!------------------------------------------------------------------------
Expand All @@ -1466,6 +1497,14 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
CROPTYPE,PLANTING,HARVEST,SEASON_GDD)
end if

!------------------------------------------------------------------------
! For IOPT_TDRN = 1 or 2 READ TILE DRAIN MAP
!------------------------------------------------------------------------
TD_FRACTION = 0.
IF (IOPT_TDRN .GT. 0) THEN
CALL READ_TILE_DRAIN_MAP(TDINPUT_FLNM,XSTART,XEND,YSTART,YEND,TD_FRACTION)
ENDIF

!----------------------------------------------------------------------
! Initialize Model State
!----------------------------------------------------------------------
Expand Down Expand Up @@ -1531,6 +1570,7 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSFC" , QSFC )
call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFCRUNOFF",SFCRUNOFF )
call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "UDRUNOFF" ,UDRUNOFF )
call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QTDRAIN" ,QTDRAIN )
! below for opt_run = 5
call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SMOISEQ" , SMOISEQ )
call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "AREAXY" , AREAXY )
Expand Down Expand Up @@ -1646,7 +1686,7 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
ids,ide+1, jds,jde+1, kds,kde, & ! domain
ims,ime, jms,jme, kms,kme, & ! memory
its,ite, jts,jte, kts,kte & ! tile
,smoiseq ,smcwtdxy ,rechxy ,deeprechxy, areaxy ,dx, dy, msftx, msfty,&
,smoiseq ,smcwtdxy ,rechxy ,deeprechxy,qtdrain, areaxy ,dx, dy, msftx, msfty,&
wtddt ,stepwtd ,dtbl ,qrfsxy ,qspringsxy ,qslatxy, &
fdepthxy ,terrain ,riverbedxy ,eqzwt ,rivercondxy ,pexpxy, &
rechclim ,gecros_state &
Expand Down Expand Up @@ -1780,7 +1820,7 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
ids,ide+1, jds,jde+1, kds,kde, & ! domain
ims,ime, jms,jme, kms,kme, & ! memory
its,ite, jts,jte, kts,kte & ! tile
,smoiseq ,smcwtdxy ,rechxy ,deeprechxy, areaxy ,dx, dy, msftx, msfty,&
,smoiseq ,smcwtdxy ,rechxy ,deeprechxy,qtdrain, areaxy ,dx, dy, msftx, msfty,&
wtddt ,stepwtd ,dtbl ,qrfsxy ,qspringsxy ,qslatxy, &
fdepthxy ,terrain ,riverbedxy ,eqzwt ,rivercondxy ,pexpxy, &
rechclim ,gecros_state &
Expand Down Expand Up @@ -1868,13 +1908,17 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
allocate( soldrain (ix,jx) )
allocate( etpnd (ix,jx) )
allocate( prcp0 (ix,jx) )

allocate( qtiledrain(ix,jx) )
allocate( ZWATBLE2D (ix,jx) )

prcp0 = 0
sfcheadrt = 0.0
infxsrt = 0.0
etpnd = 0.0
soldrain = 0.0

qtiledrain= 0.0
ZWATBLE2D = 0.0

allocate(zsoil (NSOIL))
zsoil = 0

Expand All @@ -1886,7 +1930,7 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte)
print*, "zsoil/soil_thick_input = ", soil_thick_input(1:NSOIL)

call hrldas_drv_HYDRO_ini(TSLB(:,1:NSOIL,:),SMOIS(:,1:NSOIL,:),SH2O(:,1:NSOIL,:), &
infxsrt,sfcheadrt,soldrain,ix,jx,NSOIL, SMOIS,real(noah_timestep), &
infxsrt,sfcheadrt,soldrain,qtiledrain,ZWATBLE2D,ix,jx,NSOIL, SMOIS,real(noah_timestep), &
olddate,zsoil(1:NSOIL))

if(finemesh .ne. 0 ) then
Expand Down Expand Up @@ -2070,7 +2114,7 @@ subroutine land_driver_exe(itime)
PLANTING, HARVEST,SEASON_GDD, &
IDVEG, IOPT_CRS, IOPT_BTR, IOPT_RUN, IOPT_SFC, IOPT_FRZ, &
IOPT_INF, IOPT_RAD, IOPT_ALB, IOPT_SNF, IOPT_TBOT, IOPT_STC, &
IOPT_GLA, IOPT_RSF,IOPT_SOIL,IOPT_PEDO,IOPT_CROP, &
IOPT_GLA, IOPT_RSF,IOPT_SOIL,IOPT_PEDO,IOPT_CROP,IOPT_TDRN, &
IZ0TLND, sf_urban_physics, &
SOILCOMP, SOILCL1, SOILCL2, SOILCL3, SOILCL4, &
T_PHY, QV_CURR, U_PHY, V_PHY, SWDOWN, GLW, &
Expand All @@ -2079,7 +2123,7 @@ subroutine land_driver_exe(itime)
SMSTOT,SFCRUNOFF, UDRUNOFF, ALBEDO, SNOWC, SMOIS, &
SH2O, TSLB, SNOW, SNOWH, CANWAT, ACSNOM, &
ACSNOW, EMISS, QSFC, &
Z0, ZNT, & ! IN/OUT LSM eqv
Z0, ZNT, QTDRAIN,ZWATBLE2D, & ! IN/OUT LSM eqv
ISNOWXY, TVXY, TGXY, CANICEXY, CANLIQXY, EAHXY, &
TAHXY, CMXY, CHXY, FWETXY, SNEQVOXY, ALBOLDXY, &
QSNOWXY, WSLAKEXY, ZWTXY, WAXY, WTXY, TSNOXY, &
Expand All @@ -2098,8 +2142,9 @@ subroutine land_driver_exe(itime)
! BEXP_3D,SMCDRY_3D,SMCWLT_3D,SMCREF_3D,SMCMAX_3D, &
! DKSAT_3D,DWSAT_3D,PSISAT_3D,QUARTZ_3D, &
! REFDK_2D,REFKDT_2D, &
! KLAT_FAC,TDSMC_FAC,TD_DC,TD_DCOEF,TD_DDRAIN,TD_RADI,TD_SPAC, &
#ifdef WRF_HYDRO
sfcheadrt,INFXSRT,soldrain, & !O
sfcheadrt,INFXSRT,soldrain,qtiledrain,TD_FRACTION, & !O
#endif
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
Expand Down Expand Up @@ -2347,7 +2392,8 @@ subroutine land_driver_exe(itime)
call add_to_output(NPPXY , "NPP" , "Net primary productivity" , "g m{-2} s{-1} C" )
call add_to_output(PSNXY , "PSN" , "Total photosynthesis" , "umol CO@ m{-2} s{-1}")
call add_to_output(APARXY , "APAR" , "Photosynthesis active energy by canopy" , "W m{-2}" )

! Tile drainage output
call add_to_output(QTDRAIN , "QTDRAIN" , "Tile drainage discharge" , "mm" )
! Carbon allocation model
IF(RUNOFF_OPTION == 5) THEN
call add_to_output(SMCWTDXY , "SMCWTD" , "Leaf mass" , "g m{-2}" )
Expand Down Expand Up @@ -2472,6 +2518,7 @@ subroutine lsm_restart()
call add_to_restart(QSFC , "QSFC" )
call add_to_restart(SFCRUNOFF , "SFCRUNOFF")
call add_to_restart(UDRUNOFF , "UDRUNOFF" )
call add_to_restart(QTDRAIN , "QTDRAIN")
! below for opt_run = 5
call add_to_restart(SMOISEQ , "SMOISEQ" , layers="SOIL" )
call add_to_restart(AREAXY , "AREAXY" )
Expand Down
Loading