Skip to content

Commit

Permalink
Merge pull request #1 from glemieux/SP_next_api-add_tests
Browse files Browse the repository at this point in the history
Adding in test suite definition and pre-merge
  • Loading branch information
rosiealice authored May 19, 2020
2 parents de3f153 + db3bfa6 commit 6e2a996
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Externals_CLM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local_path = src/fates
protocol = git
repo_url = https://github.com/NGEET/fates
tag = sci.1.34.0_api.9.0.0
tag = sci.1.35.0_api.10.0.0
required = True

[PTCLM]
Expand Down
2 changes: 1 addition & 1 deletion bld/namelist_files/namelist_defaults_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- FATES default parameter file -->
<!-- ================================================================== -->

<fates_paramfile>lnd/clm2/paramdata/fates_params_api.8.1.0_12pft_c200103.nc</fates_paramfile>
<fates_paramfile>lnd/clm2/paramdata/fates_params_api.10.0.0_12pft_c200420.nc</fates_paramfile>

<!-- ======================================================================================== -->
<!-- clm 5.0 BGC nitrogen model -->
Expand Down
13 changes: 12 additions & 1 deletion cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@
<option name="wallclock">00:20:00</option>
</options>
</test>
<test name="ERP_Ld3" grid="f09_g16" compset="I2000Clm45Fates" testmods="clm/FatesColdDef">
<test name="ERP_Ld3" grid="f09_g16" compset="I2000Clm50Fates" testmods="clm/FatesColdDef">
<machines>
<machine name="cheyenne" compiler="intel" category="fates"/>
<machine name="lawrencium-lr3" compiler="intel" category="fates"/>
Expand Down Expand Up @@ -1968,6 +1968,16 @@
<options>
<option name="wallclock">00:40:00</option>
</options>
</test>
<test name="ERS_Ld30" grid="f45_f45_mg37" compset="I2000Clm50FatesCruGs" testmods="clm/FatesReducedComplexFixedBiogeo">
<machines>
<machine name="cheyenne" compiler="intel" category="fates"/>
<machine name="izumi" compiler="nag" category="fates"/>
<machine name="lawrencium-lr3" compiler="intel" category="fates"/>
</machines>
<options>
<option name="wallclock">00:40:00</option>
</options>
</test>
<test name="ERS_Ld60" grid="f45_f45_mg37" compset="I2000Clm50FatesCruGs" testmods="clm/FatesPPhys">
<machines>
Expand Down Expand Up @@ -2001,6 +2011,7 @@
<test name="SMS_Lm13" grid="1x1_brazil" compset="I2000Clm50FatesCruGs" testmods="clm/FatesColdDef">
<machines>
<machine name="cheyenne" compiler="intel" category="fates"/>
<machine name="cheyenne" compiler="gnu" category="fates"/>
<machine name="lawrencium-lr3" compiler="intel" category="fates"/>
</machines>
<options>
Expand Down
10 changes: 7 additions & 3 deletions cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
hist_empty_htapes = .true.
use_fates_planthydro= .true.
hist_fincl1 = 'FATES_ERRH2O_SCPF','FATES_TRAN_SCPF','FATES_ROOTUPTAKE_SCPF','FATES_ROOTUPTAKE01_SCPF',
'FATES_SAPFLOW_COL_SCPF','FATES_ITERH1_COL_SCPF','FATES_ATH_COL_SCPF','FATES_TTH_COL_SCPF',
'FATES_STH_COL_SCPF','FATES_LTH_COL_SCPF','FATES_AWP_COL_SCPF','FATES_BTRAN_COL_SCPF'
hist_fincl1 = 'FATES_ERRH2O_SCPF','FATES_TRAN_SCPF',
'FATES_SAPFLOW_SCPF','FATES_ITERH1_SCPF','FATES_ATH_SCPF','FATES_TTH_SCPF',
'FATES_STH_SCPF','FATES_LTH_SCPF','FATES_AWP_SCPF','FATES_BTRAN_SCPF',
'FATES_ROOTWGT_SOILVWC_SI','FATES_ROOTWGT_SOILVWCSAT_SI',
'FATES_ROOTWGT_SOILMATPOT_SI','FATES_SOILMATPOT_SL','FATES_SOILVWC_SL','FATES_SOILVWCSAT_SL',
'FATES_ROOTUPTAKE_SI','FATES_ROOTUPTAKE_SL','FATES_ROOTUPTAKE0_SCPF','FATES_ROOTUPTAKE10_SCPF',
'FATES_ROOTUPTAKE50_SCPF','FATES_ROOTUPTAKE100_SCPF'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../FatesColdDef
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use_fates_fixed_biogeog=.true.
2 changes: 1 addition & 1 deletion src/biogeophys/CanopyFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp,


call clm_fates%wrap_accumulatefluxes(nc,fn,filterp(1:fn))
call clm_fates%wrap_hydraulics_drive(bounds,nc,soilstate_inst, &
call clm_fates%wrap_hydraulics_drive(bounds,nc,fn,filterp(1:fn),soilstate_inst, &
waterstate_inst,waterflux_inst,solarabs_inst,energyflux_inst)

else
Expand Down
22 changes: 11 additions & 11 deletions src/biogeophys/SoilStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module SoilStateType
use abortutils , only : endrun
use clm_varpar , only : nlevsoi, nlevgrnd, nlevlak, nlayer, nlevsno
use clm_varcon , only : spval
use clm_varctl , only : use_hydrstress, use_cn, use_lch4, use_dynroot
use clm_varctl , only : use_hydrstress, use_cn, use_lch4, use_dynroot, use_fates
use clm_varctl , only : iulog, hist_wrtch4diag
use LandunitType , only : lun
use ColumnType , only : col
Expand Down Expand Up @@ -214,15 +214,15 @@ subroutine InitHistory(this, bounds)
avgflag='A', long_name='soil matric potential (vegetated landunits only)', &
ptr_col=this%smp_l_col, set_spec=spval, l2g_scale_type='veg')

this%root_conductance_patch(begp:endp,:) = spval
call hist_addfld2d (fname='KROOT', units='1/s', type2d='levsoi', &
avgflag='A', long_name='root conductance each soil layer', &
ptr_patch=this%root_conductance_patch, default='inactive')

this%soil_conductance_patch(begp:endp,:) = spval
call hist_addfld2d (fname='KSOIL', units='1/s', type2d='levsoi', &
avgflag='A', long_name='soil conductance in each soil layer', &
ptr_patch=this%soil_conductance_patch, default='inactive')
this%root_conductance_patch(begp:endp,:) = spval
call hist_addfld2d (fname='KROOT', units='1/s', type2d='levsoi', &
avgflag='A', long_name='root conductance each soil layer', &
ptr_patch=this%root_conductance_patch, default='inactive')
this%soil_conductance_patch(begp:endp,:) = spval
call hist_addfld2d (fname='KSOIL', units='1/s', type2d='levsoi', &
avgflag='A', long_name='soil conductance in each soil layer', &
ptr_patch=this%soil_conductance_patch, default='inactive')

if (use_cn) then
this%bsw_col(begc:endc,:) = spval
Expand Down Expand Up @@ -260,7 +260,7 @@ subroutine InitHistory(this, bounds)

end if

if (use_cn) then
if (use_cn .or. use_fates) then
this%soilpsi_col(begc:endc,:) = spval
call hist_addfld2d (fname='SOILPSI', units='MPa', type2d='levgrnd', &
avgflag='A', long_name='soil water potential in each soil layer', &
Expand Down
7 changes: 6 additions & 1 deletion src/biogeophys/WaterStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module WaterstateType
use shr_log_mod , only : errMsg => shr_log_errMsg
use decompMod , only : bounds_type
use clm_varctl , only : use_vancouver, use_mexicocity, use_cn, iulog, use_luna
use clm_varctl , only : use_fates_planthydro
use clm_varpar , only : nlevgrnd, nlevurb, nlevsno
use clm_varcon , only : spval
use LandunitType , only : lun
Expand Down Expand Up @@ -766,7 +767,11 @@ subroutine InitCold(this, bounds, &
if (j > nbedrock) then
this%h2osoi_vol_col(c,j) = 0.0_r8
else
this%h2osoi_vol_col(c,j) = 0.15_r8
if(use_fates_planthydro) then
this%h2osoi_vol_col(c,j) = 0.75_r8*watsat_col(c,j)
else
this%h2osoi_vol_col(c,j) = 0.15_r8
end if
endif
end do
else if (lun%urbpoi(l)) then
Expand Down
63 changes: 52 additions & 11 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module CLMFatesInterfaceMod
use FatesInterfaceMod , only : allocate_bcout
use FatesInterfaceMod , only : SetFatesTime
use FatesInterfaceMod , only : set_fates_ctrlparms
use FatesInterfaceMod , only : InitPARTEHGlobals


use FatesHistoryInterfaceMod, only : fates_history_interface_type
use FatesRestartInterfaceMod, only : fates_restart_interface_type
Expand All @@ -118,6 +118,7 @@ module CLMFatesInterfaceMod
use EDInitMod , only : init_site_vars
use EDInitMod , only : init_patches
use EDInitMod , only : set_site_properties
use EDInitMod , only : InitFatesGlobals
use EDPftVarcon , only : EDpftvarcon_inst
use EDSurfaceRadiationMod , only : ED_SunShadeFracs, ED_Norman_Radiation
use EDBtranMod , only : btran_ed, &
Expand Down Expand Up @@ -503,7 +504,7 @@ subroutine init(this, bounds_proc )
call this%init_soil_depths(nc)

if (use_fates_planthydro) then
call InitHydrSites(this%fates(nc)%sites,this%fates(nc)%bc_in,numpft_fates)
call InitHydrSites(this%fates(nc)%sites,this%fates(nc)%bc_in)
end if

if( this%fates(nc)%nsites == 0 ) then
Expand All @@ -528,13 +529,10 @@ subroutine init(this, bounds_proc )
end do
!$OMP END PARALLEL DO

! This will initialize all globals associated with the chosen
! Plant Allocation and Reactive Transport hypothesis. This includes
! mapping tables and global variables. These will be read-only
! and only required once per machine instance (thus no requirements
! to have it instanced on each thread
! This will initialize all FATES globals,
! particular PARTEH and HYDRO globals

call InitPARTEHGlobals()
call InitFatesGlobals(masterproc)



Expand Down Expand Up @@ -1186,8 +1184,24 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, &
nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil
this%fates(nc)%bc_in(s)%hksat_sisl(1:nlevsoil) = &
soilstate_inst%hksat_col(c,1:nlevsoil)

this%fates(nc)%bc_in(s)%watsat_sisl(1:nlevsoil) = &
soilstate_inst%watsat_col(c,1:nlevsoil)

this%fates(nc)%bc_in(s)%watres_sisl(1:nlevsoil) = &
soilstate_inst%watres_col(c,1:nlevsoil)

this%fates(nc)%bc_in(s)%sucsat_sisl(1:nlevsoil) = &
soilstate_inst%sucsat_col(c,1:nlevsoil)

this%fates(nc)%bc_in(s)%bsw_sisl(1:nlevsoil) = &
soilstate_inst%bsw_col(c,1:nlevsoil)

this%fates(nc)%bc_in(s)%h2o_liq_sisl(1:nlevsoil) = &
waterstate_inst%h2osoi_liq_col(c,1:nlevsoil)
end do


call RestartHydrStates(this%fates(nc)%sites, &
this%fates(nc)%nsites, &
this%fates(nc)%bc_in, &
Expand Down Expand Up @@ -1920,13 +1934,15 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, &
this%fates(nc)%bc_in(s)%tot_somc = totsomc(c)
this%fates(nc)%bc_in(s)%tot_litc = totlitc(c)
end do


dtime = get_step_size()

! Update history variables that track these variables
call this%fates_hist%update_history_cbal(nc, &
this%fates(nc)%nsites, &
this%fates(nc)%sites, &
this%fates(nc)%bc_in)
this%fates(nc)%bc_in, &
dtime)

end associate
end subroutine wrap_bgc_summary
Expand Down Expand Up @@ -2237,7 +2253,16 @@ subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, &
do s = 1, this%fates(nc)%nsites
c = this%f2hmap(nc)%fcolumn(s)
nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil

! This is the water removed from the soil layers by roots (or added)
waterflux_inst%qflx_rootsoi_col(c,1:nlevsoil) = this%fates(nc)%bc_out(s)%qflx_soil2root_sisl(1:nlevsoil)

! This is the total amount of water transferred to surface runoff
! (this is generated potentially from supersaturating soils
! (currently this is unnecessary)
! waterflux_inst%qflx_drain_vr_col(c,1:nlevsoil) = this%fates(nc)%bc_out(s)%qflx_ro_sisl(1:nlevsoil)


end do

end subroutine ComputeRootSoilFlux
Expand Down Expand Up @@ -2274,6 +2299,7 @@ end subroutine ComputeRootSoilFlux
! ======================================================================================

subroutine wrap_hydraulics_drive(this, bounds_clump, nc, &
fn, filterp, &
soilstate_inst, waterstate_inst, waterflux_inst, &
solarabs_inst, energyflux_inst)

Expand All @@ -2282,6 +2308,8 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, &
class(hlm_fates_interface_type), intent(inout) :: this
type(bounds_type),intent(in) :: bounds_clump
integer,intent(in) :: nc
integer, intent(in) :: fn
integer, intent(in) :: filterp(fn)
type(soilstate_type) , intent(inout) :: soilstate_inst
type(waterstate_type) , intent(inout) :: waterstate_inst
type(waterflux_type) , intent(inout) :: waterflux_inst
Expand All @@ -2294,6 +2322,7 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, &
integer :: j
integer :: ifp
integer :: p
integer :: f
integer :: nlevsoil
real(r8) :: dtime

Expand Down Expand Up @@ -2331,10 +2360,21 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, &
p = ifp+col%patchi(c)
this%fates(nc)%bc_in(s)%swrad_net_pa(ifp) = solarabs_inst%fsa_patch(p)
this%fates(nc)%bc_in(s)%lwrad_net_pa(ifp) = energyflux_inst%eflx_lwrad_net_patch(p)
this%fates(nc)%bc_in(s)%qflx_transp_pa(ifp) = waterflux_inst%qflx_tran_veg_patch(p)
end do
end do

! The exposed vegetation filter "filterp" dictates which patches
! had their transpiration updated during canopy_fluxes(). Patches
! not in the filter had been zero'd during prep_canopyfluxes().

do f = 1,fn
p = filterp(f)
c = patch%column(p)
s = this%f2hmap(nc)%hsites(c)
ifp = p - col%patchi(c)
this%fates(nc)%bc_in(s)%qflx_transp_pa(ifp) = waterflux_inst%qflx_tran_veg_patch(p)
end do

! Call Fates Hydraulics
! ------------------------------------------------------------------------------------

Expand All @@ -2360,6 +2400,7 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, &
call this%fates_hist%update_history_hydraulics(nc, &
this%fates(nc)%nsites, &
this%fates(nc)%sites, &
this%fates(nc)%bc_in, &
dtime)


Expand Down

0 comments on commit 6e2a996

Please sign in to comment.