From f80b00fca1c54cb1b9d27e5844414961adc467b8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 31 Jan 2020 13:31:03 -0800 Subject: [PATCH 001/152] Removing calls to retired machine edison. Adding a SMS test to the gnu test suite. Changing highest res grid test to clm5. --- cime_config/testdefs/testlist_clm.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index d8e5bf02ff..6e510e731d 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1782,7 +1782,7 @@ - + @@ -1794,6 +1794,7 @@ + @@ -1802,6 +1803,8 @@ + + @@ -1827,6 +1830,7 @@ + @@ -1844,6 +1848,7 @@ + @@ -1860,6 +1865,8 @@ + + From daca97b5c55c119224327c7f1ed0610c7931bfe7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 31 Jan 2020 16:33:29 -0800 Subject: [PATCH 002/152] reinstating edison tests to prebeta --- cime_config/testdefs/testlist_clm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 6e510e731d..e475620633 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1304,6 +1304,7 @@ + From 728d9d79ac753a9a36563552afd32400df431c39 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 20 Sep 2019 10:34:51 -0700 Subject: [PATCH 003/152] Initialize soil moisture to a higher value for cold-starts when fates hydro is active. --- src/biogeophys/WaterStateType.F90 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/biogeophys/WaterStateType.F90 b/src/biogeophys/WaterStateType.F90 index 398f528ebf..668317546a 100644 --- a/src/biogeophys/WaterStateType.F90 +++ b/src/biogeophys/WaterStateType.F90 @@ -14,6 +14,7 @@ module WaterStateType use decompMod , only : bounds_type use decompMod , only : BOUNDS_SUBGRID_PATCH, BOUNDS_SUBGRID_COLUMN, BOUNDS_SUBGRID_GRIDCELL use clm_varctl , only : use_bedrock, iulog + use clm_varctl , only : use_fates_planthydro use clm_varpar , only : nlevgrnd, nlevsoi, nlevurb, nlevsno use clm_varcon , only : spval, namec use LandunitType , only : lun @@ -346,7 +347,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 * ratio + 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 From b7f1b4ce86387367c911f6989430b052d58d4a98 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 10 Jan 2020 16:53:47 -0800 Subject: [PATCH 004/152] Added surface runoff modifier to the fates interface to account for super-saturation during plant hydraulics. --- src/utils/clmfates_interfaceMod.F90 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 76bcb900ea..538b7258b2 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2196,7 +2196,21 @@ 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) waterfluxbulk_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, or from water lost + ! during mortality and litter fall) + ! This array is set in HydrologyNoDrainage()->Infiltration() + ! This subroutine (ComputeRootSoilFlux()) is (conveniently) called right + ! after that in HydrologyNoDrainage() + + waterfluxbulk_inst%qflx_h2osfc_surf_col(c) = waterfluxbulk_inst%qflx_h2osfc_surf_col(c) + & + this%fates(nc)%bc_out(s)%qflx_surf_ro_si + + end do end subroutine ComputeRootSoilFlux From b827ac749db75a76f4b0862e1bb55dd3df104951 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 30 Jan 2020 14:03:36 -0800 Subject: [PATCH 005/152] Condition the zeroing of qflx bc_in upon having hydro on. --- src/utils/clmfates_interfaceMod.F90 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 538b7258b2..747a8beca8 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1421,6 +1421,13 @@ subroutine prep_canopyfluxes(this, nc, fn, filterp, photosyns_inst) do s = 1, this%fates(nc)%nsites ! filter flag == 1 means that this patch has not been called for photosynthesis this%fates(nc)%bc_in(s)%filter_photo_pa(:) = 1 + + ! set transpiration input boundary condition to zero. The exposed + ! vegetation filter may not even call every patch. + if (use_fates_planthydro) then + this%fates(nc)%bc_in(s)%qflx_transp_pa(:) = 0._r8 + end if + end do end subroutine prep_canopyfluxes From 812112a8e5f482f185ef52f9d53ee5bcbd5ff6db Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 5 Feb 2020 10:46:10 -0800 Subject: [PATCH 006/152] Update fates interface to use a call to fatesglobals instead of just prtglobals --- src/utils/clmfates_interfaceMod.F90 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 747a8beca8..01f13bd4e2 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -105,7 +105,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 @@ -119,6 +119,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, & @@ -500,13 +501,11 @@ 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 InitFatesGlobals(masterproc) - call InitPARTEHGlobals() call this%init_history_io(bounds_proc) From 97f2471bf612248c84afbef9e5c4e9540a2f5deb Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 5 Feb 2020 12:46:41 -0800 Subject: [PATCH 007/152] Updating fates tag and default parameter file match api 8.1 --- Externals_CLM.cfg | 2 +- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index f38a229b9f..1307d05c14 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.30.0_api.8.0.0 +tag = sci.1.33.0_api.8.1.0 required = True [PTCLM] diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 2752f17214..0e6458b6d9 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -400,7 +400,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -lnd/clm2/paramdata/fates_params_api.8.0.0_12pft_c191216.nc +lnd/clm2/paramdata/fates_params_api.8.1.0_12pft_c200103.nc From d18d552556dc86750571bff53fb3e03b2b37b20c Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 13 Feb 2020 10:26:35 -0800 Subject: [PATCH 008/152] Provisions for fates-hydro, supersaturating soils. --- src/biogeophys/SoilWaterMovementMod.F90 | 18 ++++++++++-------- src/utils/clmfates_interfaceMod.F90 | 11 +++-------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/biogeophys/SoilWaterMovementMod.F90 b/src/biogeophys/SoilWaterMovementMod.F90 index 8c408c9659..b543f5d1b9 100644 --- a/src/biogeophys/SoilWaterMovementMod.F90 +++ b/src/biogeophys/SoilWaterMovementMod.F90 @@ -572,6 +572,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & qflx_infl => waterfluxbulk_inst%qflx_infl_col , & ! Input: [real(r8) (:) ] infiltration (mm H2O /s) qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col , & ! Output: [real(r8) (:,:) ] vegetation/soil water exchange (mm H2O/s) (+ = to atm) + qflx_drain_vr_col => waterfluxbulk_inst%qflx_drain_vr_col , & ! Input: [real(r8) (:,:) ] drainage from soil layers due to plant induced t_soisno => temperature_inst%t_soisno_col & ! Input: [real(r8) (:,:) ] soil temperature (Kelvin) ) @@ -774,7 +775,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & qout(c,j) = -hk(c,j)*num/den dqodw1(c,j) = -(-hk(c,j)*dsmpdw(c,j) + num*dhkdw(c,j))/den dqodw2(c,j) = -( hk(c,j)*dsmpdw(c,j+1) + num*dhkdw(c,j))/den - rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) + rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j) + qflx_drain_vr_col(c,j)) amx(c,j) = 0._r8 bmx(c,j) = dzmm(c,j)*(sdamp+1._r8/dtime) + dqodw1(c,j) cmx(c,j) = dqodw2(c,j) @@ -798,7 +799,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & qout(c,j) = -hk(c,j)*num/den dqodw1(c,j) = -(-hk(c,j)*dsmpdw(c,j) + num*dhkdw(c,j))/den dqodw2(c,j) = -( hk(c,j)*dsmpdw(c,j+1) + num*dhkdw(c,j))/den - rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) + rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) amx(c,j) = -dqidw0(c,j) bmx(c,j) = dzmm(c,j)/dtime - dqidw1(c,j) + dqodw1(c,j) cmx(c,j) = dqodw2(c,j) @@ -820,7 +821,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & dqidw1(c,j) = -( hk(c,j-1)*dsmpdw(c,j) + num*dhkdw(c,j-1))/den qout(c,j) = 0._r8 dqodw1(c,j) = 0._r8 - rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) + rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) amx(c,j) = -dqidw0(c,j) bmx(c,j) = dzmm(c,j)/dtime - dqidw1(c,j) + dqodw1(c,j) cmx(c,j) = 0._r8 @@ -863,7 +864,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & dqodw1(c,j) = -(-hk(c,j)*dsmpdw(c,j) + num*dhkdw(c,j))/den dqodw2(c,j) = -( hk(c,j)*dsmpdw1 + num*dhkdw(c,j))/den - rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) + rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) amx(c,j) = -dqidw0(c,j) bmx(c,j) = dzmm(c,j)/dtime - dqidw1(c,j) + dqodw1(c,j) cmx(c,j) = dqodw2(c,j) @@ -1153,7 +1154,8 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & hk_l => soilstate_inst%hk_l_col , & ! Input: [real(r8) (:,:) ] hydraulic conductivity (mm/s) h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice water (kg/m2) h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input: [real(r8) (:,:) ] liquid water (kg/m2) - qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col & + qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col , & + qflx_drain_vr_col => waterfluxbulk_inst%qflx_drain_vr_col & ) ! end associate statement ! Get time step @@ -1220,7 +1222,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & ! RHS of system of equations call compute_RHS_moisture_form(c, nlayers, & - qflx_rootsoi_col(c,1:nlayers), & + (qflx_rootsoi_col(c,1:nlayers) + qflx_drain_vr_col(c,1:nlayers)), & vwc_liq(c,1:nlayers), & qin(c,1:nlayers), & qout(c,1:nlayers), & @@ -1313,7 +1315,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & endif ! compute the net flux - fluxNet0(j) = qin_test - qout_test - qflx_rootsoi_col(c,j) + fluxNet0(j) = qin_test - qout_test - (qflx_rootsoi_col(c,j) + qflx_drain_vr_col(c,j)) ! flux calculation is inexpensive else @@ -1324,7 +1326,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & endif ! switch between the expensive and inexpensive fluxcalculations ! compute the net flux at the start of the sub-step - fluxNet1(j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) + fluxNet1(j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) end do ! looping through layers diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 01f13bd4e2..47211cc9d7 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2207,15 +2207,10 @@ subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, & waterfluxbulk_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, or from water lost - ! during mortality and litter fall) - ! This array is set in HydrologyNoDrainage()->Infiltration() - ! This subroutine (ComputeRootSoilFlux()) is (conveniently) called right - ! after that in HydrologyNoDrainage() - - waterfluxbulk_inst%qflx_h2osfc_surf_col(c) = waterfluxbulk_inst%qflx_h2osfc_surf_col(c) + & - this%fates(nc)%bc_out(s)%qflx_surf_ro_si + ! (this is generated potentially from supersaturating soils + waterflux_inst%qflx_drain_vr_col(c,1:nlevsoil) = this%fates(nc)%bc_out(s)%qflx_ro_sisl(1:nlevsoil) + end do From f49862a305137a5b2c95378286205ca0ab33c9a1 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 13 Feb 2020 13:22:22 -0800 Subject: [PATCH 009/152] Allowing soilpsi_col diagnostic with fates --- src/biogeophys/SoilStateType.F90 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/biogeophys/SoilStateType.F90 b/src/biogeophys/SoilStateType.F90 index 8d36a8095d..f7bddbb92b 100644 --- a/src/biogeophys/SoilStateType.F90 +++ b/src/biogeophys/SoilStateType.F90 @@ -214,15 +214,15 @@ subroutine InitHistory(this, bounds) avgflag='A', long_name='soil matric potential (natural vegetated and crop 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 @@ -263,7 +263,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', & From 41a61b2eaefa2405f40048b8d6f1ad72ca3e30e7 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 13 Feb 2020 13:22:58 -0800 Subject: [PATCH 010/152] Allowing soilpsi_col diagnostic with fates --- src/biogeophys/SoilStateType.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeophys/SoilStateType.F90 b/src/biogeophys/SoilStateType.F90 index f7bddbb92b..6500166bd9 100644 --- a/src/biogeophys/SoilStateType.F90 +++ b/src/biogeophys/SoilStateType.F90 @@ -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 From e906294f288385e86ee54e6075418a345a9293ef Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 13 Feb 2020 21:05:24 -0800 Subject: [PATCH 011/152] fates-hydro: changed subroutine arguments --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 47211cc9d7..c457fd8983 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -475,7 +475,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,maxveg_ed) + call InitHydrSites(this%fates(nc)%sites,this%fates(nc)%bc_in) end if From 5f3c439c46ea18d9361eed11995fdcee62da654f Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 18 Feb 2020 21:19:42 -0700 Subject: [PATCH 012/152] Fixed hydro restart bug (needed to initialize bcs prior to initializing wrfs). --- .../testmods_dirs/clm/FatesHydro/user_nl_clm | 2 +- src/biogeophys/CanopyFluxesMod.F90 | 3 +- src/utils/clmfates_interfaceMod.F90 | 38 +++++++++++++++++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm index 2435b5bc7e..c7d24f7ab1 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm @@ -1,5 +1,5 @@ hist_empty_htapes = .true. use_fates_planthydro= .true. -hist_fincl1 = 'FATES_ERRH2O_SCPF','FATES_TRAN_SCPF','FATES_ROOTUPTAKE_SCPF','FATES_ROOTUPTAKE01_SCPF', +hist_fincl1 = 'FATES_ERRH2O_SCPF','FATES_TRAN_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' diff --git a/src/biogeophys/CanopyFluxesMod.F90 b/src/biogeophys/CanopyFluxesMod.F90 index cb68d92aec..9a15c8b7cc 100644 --- a/src/biogeophys/CanopyFluxesMod.F90 +++ b/src/biogeophys/CanopyFluxesMod.F90 @@ -1311,7 +1311,8 @@ 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, & - waterstatebulk_inst,waterdiagnosticbulk_inst,waterfluxbulk_inst,solarabs_inst,energyflux_inst) + waterstatebulk_inst,waterdiagnosticbulk_inst,waterfluxbulk_inst, & + fn, filterp, solarabs_inst,energyflux_inst) else diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index c457fd8983..571df8449e 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1155,8 +1155,24 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_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) = & + waterdiagnosticbulk_inst%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, & @@ -2209,7 +2225,7 @@ subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, & ! This is the total amount of water transferred to surface runoff ! (this is generated potentially from supersaturating soils - waterflux_inst%qflx_drain_vr_col(c,1:nlevsoil) = this%fates(nc)%bc_out(s)%qflx_ro_sisl(1:nlevsoil) + waterfluxbulk_inst%qflx_drain_vr_col(c,1:nlevsoil) = this%fates(nc)%bc_out(s)%qflx_ro_sisl(1:nlevsoil) end do @@ -2249,13 +2265,15 @@ end subroutine ComputeRootSoilFlux subroutine wrap_hydraulics_drive(this, bounds_clump, nc, & soilstate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, & - solarabs_inst, energyflux_inst) + fn, filterp, solarabs_inst, energyflux_inst) implicit none 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(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst @@ -2269,7 +2287,8 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, & integer :: j integer :: ifp integer :: p - integer :: nlevsoil + integer :: f + integer :: nlevsoil real(r8) :: dtime @@ -2306,10 +2325,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) = waterfluxbulk_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) = waterfluxbulk_inst%qflx_tran_veg_patch(p) + end do + ! Call Fates Hydraulics ! ------------------------------------------------------------------------------------ From 5e6fdab3b3fafc7a919304cacf2a2fb7e95f301f Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 18 Feb 2020 21:27:40 -0700 Subject: [PATCH 013/152] fates-hydro: removed dependence on qflx_drain_vr_col --- src/biogeophys/BalanceCheckMod.F90 | 9 +-------- src/biogeophys/SoilWaterMovementMod.F90 | 17 ++++++++--------- src/utils/clmfates_interfaceMod.F90 | 4 ++-- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/biogeophys/BalanceCheckMod.F90 b/src/biogeophys/BalanceCheckMod.F90 index c2d58f711e..d46fd31626 100644 --- a/src/biogeophys/BalanceCheckMod.F90 +++ b/src/biogeophys/BalanceCheckMod.F90 @@ -38,19 +38,11 @@ module BalanceCheckMod ! !PUBLIC TYPES: implicit none save - private ! ! !PUBLIC MEMBER FUNCTIONS: - public :: BalanceCheckInit ! Initialization of Water and energy balance check public :: BeginWaterBalance ! Initialize water balance check public :: BalanceCheck ! Water and energy balance check - public :: GetBalanceCheckSkipSteps ! Get the number of steps to skip for the balance check - public :: BalanceCheckClean ! Clean up for BalanceCheck - - ! !PRIVATE MEMBER DATA: - real(r8), private, parameter :: skip_size = 3600.0_r8 ! Time steps to skip the balance check at startup (sec) - integer, private :: skip_steps = -999 ! Number of time steps to skip the balance check for ! ! !PRIVATE MEMBER FUNCTIONS: @@ -250,6 +242,7 @@ subroutine BalanceCheck( bounds, & use clm_varcon , only : spval use clm_time_manager , only : get_step_size_real, get_nstep use clm_time_manager , only : get_nstep_since_startup_or_lastDA_restart_or_pause + use clm_instMod , only : surfalb_inst use CanopyStateType , only : canopystate_type use subgridAveMod ! diff --git a/src/biogeophys/SoilWaterMovementMod.F90 b/src/biogeophys/SoilWaterMovementMod.F90 index b543f5d1b9..352a93e82d 100644 --- a/src/biogeophys/SoilWaterMovementMod.F90 +++ b/src/biogeophys/SoilWaterMovementMod.F90 @@ -775,7 +775,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & qout(c,j) = -hk(c,j)*num/den dqodw1(c,j) = -(-hk(c,j)*dsmpdw(c,j) + num*dhkdw(c,j))/den dqodw2(c,j) = -( hk(c,j)*dsmpdw(c,j+1) + num*dhkdw(c,j))/den - rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j) + qflx_drain_vr_col(c,j)) + rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) amx(c,j) = 0._r8 bmx(c,j) = dzmm(c,j)*(sdamp+1._r8/dtime) + dqodw1(c,j) cmx(c,j) = dqodw2(c,j) @@ -799,7 +799,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & qout(c,j) = -hk(c,j)*num/den dqodw1(c,j) = -(-hk(c,j)*dsmpdw(c,j) + num*dhkdw(c,j))/den dqodw2(c,j) = -( hk(c,j)*dsmpdw(c,j+1) + num*dhkdw(c,j))/den - rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) + rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) amx(c,j) = -dqidw0(c,j) bmx(c,j) = dzmm(c,j)/dtime - dqidw1(c,j) + dqodw1(c,j) cmx(c,j) = dqodw2(c,j) @@ -821,7 +821,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & dqidw1(c,j) = -( hk(c,j-1)*dsmpdw(c,j) + num*dhkdw(c,j-1))/den qout(c,j) = 0._r8 dqodw1(c,j) = 0._r8 - rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) + rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) amx(c,j) = -dqidw0(c,j) bmx(c,j) = dzmm(c,j)/dtime - dqidw1(c,j) + dqodw1(c,j) cmx(c,j) = 0._r8 @@ -864,7 +864,7 @@ subroutine soilwater_zengdecker2009(bounds, num_hydrologyc, filter_hydrologyc, & dqodw1(c,j) = -(-hk(c,j)*dsmpdw(c,j) + num*dhkdw(c,j))/den dqodw2(c,j) = -( hk(c,j)*dsmpdw1 + num*dhkdw(c,j))/den - rmx(c,j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) + rmx(c,j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) amx(c,j) = -dqidw0(c,j) bmx(c,j) = dzmm(c,j)/dtime - dqidw1(c,j) + dqodw1(c,j) cmx(c,j) = dqodw2(c,j) @@ -1154,8 +1154,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & hk_l => soilstate_inst%hk_l_col , & ! Input: [real(r8) (:,:) ] hydraulic conductivity (mm/s) h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice water (kg/m2) h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input: [real(r8) (:,:) ] liquid water (kg/m2) - qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col , & - qflx_drain_vr_col => waterfluxbulk_inst%qflx_drain_vr_col & + qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col ) ! end associate statement ! Get time step @@ -1222,7 +1221,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & ! RHS of system of equations call compute_RHS_moisture_form(c, nlayers, & - (qflx_rootsoi_col(c,1:nlayers) + qflx_drain_vr_col(c,1:nlayers)), & + qflx_rootsoi_col(c,1:nlayers), & vwc_liq(c,1:nlayers), & qin(c,1:nlayers), & qout(c,1:nlayers), & @@ -1315,7 +1314,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & endif ! compute the net flux - fluxNet0(j) = qin_test - qout_test - (qflx_rootsoi_col(c,j) + qflx_drain_vr_col(c,j)) + fluxNet0(j) = qin_test - qout_test - qflx_rootsoi_col(c,j) ! flux calculation is inexpensive else @@ -1326,7 +1325,7 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & endif ! switch between the expensive and inexpensive fluxcalculations ! compute the net flux at the start of the sub-step - fluxNet1(j) = qin(c,j) - qout(c,j) - (qflx_rootsoi_col(c,j)+qflx_drain_vr_col(c,j)) + fluxNet1(j) = qin(c,j) - qout(c,j) - qflx_rootsoi_col(c,j) end do ! looping through layers diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 571df8449e..7ecf2d317e 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2224,8 +2224,8 @@ subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, & ! This is the total amount of water transferred to surface runoff ! (this is generated potentially from supersaturating soils - - waterfluxbulk_inst%qflx_drain_vr_col(c,1:nlevsoil) = this%fates(nc)%bc_out(s)%qflx_ro_sisl(1:nlevsoil) + ! (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 From f76d039d121472b43f4587b380d22d33fadb1b06 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 18 Feb 2020 21:30:43 -0700 Subject: [PATCH 014/152] fixed reverting files to the wrong version of fates_next_api --- src/biogeophys/BalanceCheckMod.F90 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/biogeophys/BalanceCheckMod.F90 b/src/biogeophys/BalanceCheckMod.F90 index d46fd31626..480eff0298 100644 --- a/src/biogeophys/BalanceCheckMod.F90 +++ b/src/biogeophys/BalanceCheckMod.F90 @@ -38,11 +38,19 @@ module BalanceCheckMod ! !PUBLIC TYPES: implicit none save + private ! ! !PUBLIC MEMBER FUNCTIONS: + public :: BalanceCheckInit ! Initialization of Water and energy balance check public :: BeginWaterBalance ! Initialize water balance check public :: BalanceCheck ! Water and energy balance check + public :: GetBalanceCheckSkipSteps ! Get the number of steps to skip for the balance check + public :: BalanceCheckClean ! Clean up for BalanceCheck + + ! !PRIVATE MEMBER DATA: + real(r8), private, parameter :: skip_size = 3600.0_r8 ! Time steps to skip the balance check at startup (sec) + integer, private :: skip_steps = -999 ! Number of time steps to skip the balance check for ! ! !PRIVATE MEMBER FUNCTIONS: @@ -244,6 +252,7 @@ subroutine BalanceCheck( bounds, & use clm_time_manager , only : get_nstep_since_startup_or_lastDA_restart_or_pause use clm_instMod , only : surfalb_inst use CanopyStateType , only : canopystate_type + use SurfaceAlbedoType , only : surfalb_type use subgridAveMod ! ! !ARGUMENTS: From a5f4e8b3f14cadfb8d9fbb52aa021ecec9cc2040 Mon Sep 17 00:00:00 2001 From: Jessica Needham Date: Thu, 2 Jan 2020 10:00:54 -0800 Subject: [PATCH 015/152] Add a new fates dimension to track cohort age. Add variables that track size and age dependent mortality. Add coage dimension to clmfates_interfaceMod.F90 and histFileMod.F90. This allows cohort age to be tracked. Also add variables that allow size and age dependent mortality to be tracked. These mortality functions have been added to the fates code. --- src/main/histFileMod.F90 | 33 +++++++++++++++++++++++++++-- src/utils/clmfates_interfaceMod.F90 | 21 +++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index f403b1c663..ee6483256b 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -23,7 +23,7 @@ module histFileMod use PatchType , only : patch use EDTypesMod , only : nclmax use EDTypesMod , only : nlevleaf - use FatesInterfaceMod , only : nlevsclass, nlevage + use FatesInterfaceMod , only : nlevsclass, nlevage, nlevcoage use FatesInterfaceMod , only : nlevheight use EDTypesMod , only : nfsc use FatesLitterMod , only : ncwd @@ -914,6 +914,7 @@ subroutine htape_addfld (t, f, avgflag) integer :: numc ! total number of columns across all processors integer :: nump ! total number of pfts across all processors integer :: num2d ! size of second dimension (e.g. .number of vertical levels) + character(len=hist_dim_name_length) :: type2d integer :: beg1d_out,end1d_out ! history output per-proc 1d beginning and ending indices integer :: beg1d,end1d ! beginning and ending indices for this field (assume already set) integer :: num1d_out ! history output 1d size @@ -1048,6 +1049,9 @@ subroutine htape_addfld (t, f, avgflag) tape(t)%hlist(n)%avgflag = avgflag end if + type2d = tape(t)%hlist(n)%field%type2d + + end subroutine htape_addfld !----------------------------------------------------------------------- @@ -1072,6 +1076,7 @@ subroutine hist_update_hbuf(bounds) do t = 1,ntapes !$OMP PARALLEL DO PRIVATE (f, num2d, numdims) do f = 1,tape(t)%nflds + numdims = tape(t)%hlist(f)%field%numdims if ( numdims == 1) then @@ -1393,6 +1398,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d) ! !USES: use subgridAveMod , only : p2g, c2g, l2g, p2l, c2l, p2c use decompMod , only : BOUNDS_LEVEL_PROC + use clm_varctl , only : iulog ! ! !ARGUMENTS: integer, intent(in) :: t ! tape index @@ -1443,6 +1449,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d) no_snow_behavior = tape(t)%hlist(f)%field%no_snow_behavior hpindex = tape(t)%hlist(f)%field%hpindex + if (no_snow_behavior /= no_snow_unset) then ! For multi-layer snow fields, build a special output variable that handles ! missing snow layers appropriately @@ -1462,6 +1469,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d) call hist_set_snow_field_2d(field, clmptr_ra(hpindex)%ptr, no_snow_behavior, type1d, & beg1d, end1d) else + field => clmptr_ra(hpindex)%ptr(:,1:num2d) field_allocated = .false. end if @@ -2067,17 +2075,20 @@ subroutine htape_create (t, histrest) call ncd_defdim(lnfid, 'scale_type_string_length', scale_type_strlen, dimid) call ncd_defdim( lnfid, 'levdcmp', nlevdecomp_full, dimid) + if(use_fates)then call ncd_defdim(lnfid, 'fates_levscag', nlevsclass * nlevage, dimid) call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * maxveg_fates, dimid) call ncd_defdim(lnfid, 'fates_levagepft', nlevage * maxveg_fates, dimid) call ncd_defdim(lnfid, 'fates_levscls', nlevsclass, dimid) + call ncd_defdim(lnfid, 'fates_levcacls', nlevcoage, dimid) call ncd_defdim(lnfid, 'fates_levpft', maxveg_fates, dimid) call ncd_defdim(lnfid, 'fates_levage', nlevage, dimid) call ncd_defdim(lnfid, 'fates_levheight', nlevheight, dimid) call ncd_defdim(lnfid, 'fates_levfuel', nfsc, dimid) call ncd_defdim(lnfid, 'fates_levcwdsc', ncwd, dimid) call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass*maxveg_fates, dimid) + call ncd_defdim(lnfid, 'fates_levcapf', nlevcoage*maxveg_fates, dimid) call ncd_defdim(lnfid, 'fates_levcan', nclmax, dimid) call ncd_defdim(lnfid, 'fates_levcnlf', nlevleaf * nclmax, dimid) call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * maxveg_fates, dimid) @@ -2501,6 +2512,9 @@ subroutine htape_timeconst(t, mode) use FatesInterfaceMod, only : fates_hdim_levsclass use FatesInterfaceMod, only : fates_hdim_pfmap_levscpf use FatesInterfaceMod, only : fates_hdim_scmap_levscpf + use FatesInterfaceMod, only : fates_hdim_levcoage + use FatesInterfaceMod, only : fates_hdim_pfmap_levcapf + use FatesInterfaceMod, only : fates_hdim_camap_levcapf use FatesInterfaceMod, only : fates_hdim_levage use FatesInterfaceMod, only : fates_hdim_levheight use FatesInterfaceMod, only : fates_hdim_levpft @@ -2592,6 +2606,12 @@ subroutine htape_timeconst(t, mode) long_name='FATES pft index of the combined pft-size class dimension', units='-', ncid=nfid(t)) call ncd_defvar(varname='fates_scmap_levscpf',xtype=ncd_int, dim1name='fates_levscpf', & long_name='FATES size index of the combined pft-size class dimension', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_levcacls', xtype=tape(t)%ncprec, dim1name='fates_levcacls', & + long_name='FATES cohort age class lower bound', units='years', ncid=nfid(t)) + call ncd_defvar(varname='fates_pftmap_levcapf',xtype=ncd_int, dim1name='fates_levcapf', & + long_name='FATES pft index of the combined pft-cohort age class dimension', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_camap_levcapf',xtype=ncd_int, dim1name='fates_levcapf', & + long_name='FATES cohort age index of the combined pft-cohort age dimension', units='-', ncid=nfid(t)) call ncd_defvar(varname='fates_levage',xtype=tape(t)%ncprec, dim1name='fates_levage', & long_name='FATES patch age (yr)', ncid=nfid(t)) call ncd_defvar(varname='fates_levheight',xtype=tape(t)%ncprec, dim1name='fates_levheight', & @@ -2656,8 +2676,11 @@ subroutine htape_timeconst(t, mode) call ncd_io(varname='fates_scmap_levscag',data=fates_hdim_scmap_levscag, ncid=nfid(t), flag='write') call ncd_io(varname='fates_agmap_levscag',data=fates_hdim_agmap_levscag, ncid=nfid(t), flag='write') call ncd_io(varname='fates_levscls',data=fates_hdim_levsclass, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levcacls',data=fates_hdim_levcoage, ncid=nfid(t), flag='write') call ncd_io(varname='fates_pftmap_levscpf',data=fates_hdim_pfmap_levscpf, ncid=nfid(t), flag='write') call ncd_io(varname='fates_scmap_levscpf',data=fates_hdim_scmap_levscpf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_pftmap_levcapf',data=fates_hdim_pfmap_levcapf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_camap_levcapf',data=fates_hdim_camap_levcapf, ncid=nfid(t), flag='write') call ncd_io(varname='fates_levage',data=fates_hdim_levage, ncid=nfid(t), flag='write') call ncd_io(varname='fates_levheight',data=fates_hdim_levheight, ncid=nfid(t), flag='write') call ncd_io(varname='fates_levpft',data=fates_hdim_levpft, ncid=nfid(t), flag='write') @@ -4908,6 +4931,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, num2d = nlevdecomp_full case ('fates_levscls') num2d = nlevsclass + case('fates_levcacls') + num2d = nlevcoage case ('fates_levpft') num2d = maxveg_fates case ('fates_levage') @@ -4920,6 +4945,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, num2d = ncwd case ('fates_levscpf') num2d = nlevsclass*maxveg_fates + case ('fates_levcapf') + num2d = nlevcoage*maxveg_fates case ('fates_levscag') num2d = nlevsclass*nlevage case ('fates_levscagpf') @@ -4972,8 +4999,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, end select ! History buffer pointer - hpindex = pointer_index() + if (present(ptr_lnd)) then l_type1d = grlnd @@ -4989,6 +5016,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, l_type1d = namel l_type1d_out = namel clmptr_ra(hpindex)%ptr => ptr_lunit + if (present(set_lake)) then do l = bounds%begl,bounds%endl if (lun%lakpoi(l)) ptr_lunit(l,:) = set_lake @@ -5054,6 +5082,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, l_type1d = namep l_type1d_out = namep clmptr_ra(hpindex)%ptr => ptr_patch + if (present(set_lake)) then do p = bounds%begp,bounds%endp l =patch%landunit(p) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 7ecf2d317e..d9b84c82c6 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1962,6 +1962,7 @@ subroutine init_history_io(this,bounds_proc) use FatesIOVariableKindMod, only : patch_r8, patch_ground_r8, patch_size_pft_r8 use FatesIOVariableKindMod, only : site_r8, site_ground_r8, site_size_pft_r8 use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8 + use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8 use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8 use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8 use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8 @@ -2072,6 +2073,9 @@ subroutine init_history_io(this,bounds_proc) dk_index = this%fates_hist%hvars(ivar)%dim_kinds_index ioname = trim(this%fates_hist%dim_kinds(dk_index)%name) + write(iulog,*) 'attempt ioname: ', ioname + write(iulog,*) 'dk_index: ', dk_index + select case(trim(ioname)) case(patch_r8) call hist_addfld1d(fname=trim(vname),units=trim(vunits), & @@ -2097,12 +2101,15 @@ subroutine init_history_io(this,bounds_proc) ptr_patch=this%fates_hist%hvars(ivar)%r82d, & default=trim(vdefault)) + case(site_ground_r8, site_size_pft_r8, site_size_r8, site_pft_r8, & - site_age_r8, site_height_r8, site_fuel_r8, site_cwdsc_r8, & - site_can_r8,site_cnlf_r8, site_cnlfpft_r8, site_scag_r8, & + site_age_r8, site_height_r8, site_coage_r8,site_coage_pft_r8, & + site_fuel_r8, site_cwdsc_r8, & + site_can_r8,site_cnlf_r8, site_cnlfpft_r8, site_scag_r8, & site_scagpft_r8, site_agepft_r8, site_elem_r8, site_elpft_r8, & site_elcwd_r8, site_elage_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index dim2name = this%fates_hist%dim_bounds(d_index)%name call hist_addfld2d(fname=trim(vname),units=trim(vunits), & @@ -2119,6 +2126,8 @@ subroutine init_history_io(this,bounds_proc) end select end associate + write(iulog,*)'success: ', ioname + end do end subroutine init_history_io @@ -2376,7 +2385,7 @@ end subroutine wrap_hydraulics_drive subroutine hlm_bounds_to_fates_bounds(hlm, fates) use FatesIODimensionsMod, only : fates_bounds_type - use FatesInterfaceMod, only : nlevsclass, nlevage + use FatesInterfaceMod, only : nlevsclass, nlevage, nlevcoage use FatesInterfaceMod, only : nlevheight use EDtypesMod, only : nfsc use FatesLitterMod, only : ncwd @@ -2407,6 +2416,12 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%size_class_begin = 1 fates%size_class_end = nlevsclass + fates%coagepf_class_begin = 1 + fates%coagepf_class_end = nlevcoage * numpft_fates + + fates%coage_class_begin = 1 + fates%coage_class_end = nlevcoage + fates%pft_class_begin = 1 fates%pft_class_end = maxveg_ed From f37d7ba8ad819b0103016efce5ae30c4f39ded9d Mon Sep 17 00:00:00 2001 From: JessicaNeedham Date: Thu, 12 Mar 2020 09:30:20 -0700 Subject: [PATCH 016/152] [ Add a new hlm_use flag for turning on cohort age tracking ] [Cohort age tracking is now a flag like spitfire or hydro that can be turned on with the flag hlm_use_cohort_age_tracking. These changes add this flag to ctsm code. This is for use when FATES is running.] Fixes: [NGT-ED Github issue #] User interface changes?: [No - only on the FATES side of things] Code review: [Names] Test suite: [suite name, machine, compilers] Test baseline: Test namelist changes: Test answer changes: [bit for bit, roundoff, climate changing] Test summary: No testing. --- bld/CLMBuildNamelist.pm | 5 +++-- bld/namelist_files/namelist_defaults_ctsm.xml | 1 + bld/namelist_files/namelist_definition_ctsm.xml | 11 ++++++++--- src/main/clm_varctl.F90 | 1 + src/main/controlMod.F90 | 5 ++++- src/utils/clmfates_interfaceMod.F90 | 9 +++++++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 4ee6a65eda..d435226610 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -768,7 +768,8 @@ sub setup_cmdl_fates_mode { } } else { # dis-allow fates specific namelist items with non-fates runs - my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", + my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", + "use_fates_cohort_age_tracking", "use_fates_inventory_init", "fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" ); foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { @@ -3775,7 +3776,7 @@ sub setup_logic_fates { if (&value_is_true( $nl_flags->{'use_fates'}) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", - "use_fates_inventory_init", "use_fates_logging","fates_parteh_mode" ); + "use_fates_inventory_init", "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'} ); } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 0e6458b6d9..aa8964931c 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2728,6 +2728,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 .false. .false. +.false. .false. .false. .false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 3dafa5591c..a0642c8199 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -646,9 +646,14 @@ Toggle to turn on the logging module (only relevant if FATES is being used). -Toggle to turn on plant hydraulics (only relevant if FATES is on). -(use_fates_planthydro=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!) + group="clm_inparm" valid_values="" value=".false."> + Toggle to turn on plant hydraulics (only relevant if FATES is on). + (use_fates_planthydro=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!) + + + + Toggle to turn on cohort age tracking (only relevant if FATES is on). use spitfire model logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro + logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking logical, public :: use_fates_ed_st3 = .false. ! true => static stand structure logical, public :: use_fates_ed_prescribed_phys = .false. ! true => prescribed physiology logical, public :: use_fates_inventory_init = .false. ! true => initialize fates from inventory diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index e2f75958cd..d24eea2a15 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -223,11 +223,12 @@ subroutine control_init( ) namelist /clm_inparm/ fates_paramfile, use_fates, & use_fates_spitfire, use_fates_logging, & use_fates_planthydro, use_fates_ed_st3, & + use_fates_cohort_age_tracking, & use_fates_ed_prescribed_phys, & use_fates_inventory_init, & fates_inventory_ctrl_filename, & fates_parteh_mode - + ! CLM 5.0 nitrogen flags namelist /clm_inparm/ use_flexibleCN, use_luna @@ -714,6 +715,7 @@ subroutine control_spmd() call mpi_bcast (use_fates_spitfire, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_logging, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_ed_st3, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_ed_prescribed_phys, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_inventory_init, 1, MPI_LOGICAL, 0, mpicom, ier) @@ -1065,6 +1067,7 @@ subroutine control_print () write(iulog, *) ' fates_paramfile = ', fates_paramfile write(iulog, *) ' fates_parteh_mode = ', fates_parteh_mode write(iulog, *) ' use_fates_planthydro = ', use_fates_planthydro + write(iulog, *) ' use_fates_cohort_age_tracking = ', use_fates_cohort_age_tracking write(iulog, *) ' use_fates_ed_st3 = ',use_fates_ed_st3 write(iulog, *) ' use_fates_ed_prescribed_phys = ',use_fates_ed_prescribed_phys write(iulog, *) ' use_fates_inventory_init = ',use_fates_inventory_init diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d9b84c82c6..b86e01f5e4 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -51,6 +51,7 @@ module CLMFatesInterfaceMod use clm_varctl , only : fates_parteh_mode use clm_varctl , only : use_fates_spitfire use clm_varctl , only : use_fates_planthydro + use clm_varctl , only : use_fates_cohort_age_tracking use clm_varctl , only : use_fates_ed_st3 use clm_varctl , only : use_fates_ed_prescribed_phys use clm_varctl , only : use_fates_logging @@ -248,6 +249,7 @@ subroutine init(this, bounds_proc ) integer :: pass_ed_prescribed_phys integer :: pass_logging integer :: pass_planthydro + integer :: pass_cohort_age_tracking integer :: pass_inventory_init integer :: pass_is_restart integer :: nc ! thread index @@ -342,6 +344,13 @@ subroutine init(this, bounds_proc ) end if call set_fates_ctrlparms('use_planthydro',ival=pass_planthydro) + if(use_fates_cohort_age_tracking) then + pass_cohort_age_tracking = 1 + else + pass_cohort_age_tracking = 0 + end if + call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) + if(use_fates_logging) then pass_logging = 1 else From d81ca0e73fd97e904ac211a95a4bc91850c6e4f5 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 12 Mar 2020 15:15:06 -0700 Subject: [PATCH 017/152] Added FATESSizeAge test protocol --- cime_config/testdefs/testlist_clm.xml | 10 ++++++++++ .../clm/FatesSizeAgeMort/include_user_mods | 1 + .../testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index e475620633..321287c716 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1889,6 +1889,16 @@ + + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/include_user_mods new file mode 100644 index 0000000000..1f2c03aebe --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/include_user_mods @@ -0,0 +1 @@ +../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm new file mode 100644 index 0000000000..2cd2755ab3 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm @@ -0,0 +1,3 @@ +hist_empty_htapes = .true. +use_fates_cohort_age_tracking=.true. +hist_fincl1 = 'M9_SCPF','M10_SCPF','M10_CAPF','NPLANT_CACLS','M9_SCLS','M10_SCLS','M10_CACLS' From b5e96371a28c7eca11b85e3bf2a6aaf65f2719bb Mon Sep 17 00:00:00 2001 From: JessicaNeedham Date: Tue, 24 Mar 2020 11:36:18 -0700 Subject: [PATCH 018/152] [Add NPLANT_CAPF to user_nl_clm ] [ Add NPLANT_CAPF to user_nl_clm - number of plants by cohort age class and pft. ] Fixes: [NGT-ED Github issue #] User interface changes?: [No] Code review: [Names] Test suite: [suite name, machine, compilers] Test baseline: Test namelist changes: Test answer changes: [bit for bit, roundoff, climate changing] Test summary:No testing. --- .../testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm index 2cd2755ab3..cb7cc262fe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSizeAgeMort/user_nl_clm @@ -1,3 +1,3 @@ hist_empty_htapes = .true. use_fates_cohort_age_tracking=.true. -hist_fincl1 = 'M9_SCPF','M10_SCPF','M10_CAPF','NPLANT_CACLS','M9_SCLS','M10_SCLS','M10_CACLS' +hist_fincl1 = 'M9_SCPF','M10_SCPF','M10_CAPF','NPLANT_CACLS','NPLANT_CAPF', 'M9_SCLS','M10_SCLS','M10_CACLS' From 4bed4f94fea58a1a203d664c8e282ae97b61933a Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 24 Mar 2020 18:34:36 -0600 Subject: [PATCH 019/152] Fixed fates size-age-mortality test length to be splitable --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 321287c716..52f12543de 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1889,7 +1889,7 @@ - + From f1b579a2d2203309d9f3d681116e30a8b1d41f30 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 26 Mar 2020 14:49:50 -0700 Subject: [PATCH 020/152] update manage externals config file to pull correect fates tag --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 1307d05c14..9f352ca8dd 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.33.0_api.8.1.0 +tag = sci.1.34.0_api.9.0.0 required = True [PTCLM] From 9eda517a949e84f8681dbc3dbe39329971bd6675 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 26 Mar 2020 15:03:35 -0700 Subject: [PATCH 021/152] remove temp writes to iulog in clmfates_interface --- src/utils/clmfates_interfaceMod.F90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b86e01f5e4..c7b62491b0 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2082,9 +2082,6 @@ subroutine init_history_io(this,bounds_proc) dk_index = this%fates_hist%hvars(ivar)%dim_kinds_index ioname = trim(this%fates_hist%dim_kinds(dk_index)%name) - write(iulog,*) 'attempt ioname: ', ioname - write(iulog,*) 'dk_index: ', dk_index - select case(trim(ioname)) case(patch_r8) call hist_addfld1d(fname=trim(vname),units=trim(vunits), & @@ -2135,7 +2132,6 @@ subroutine init_history_io(this,bounds_proc) end select end associate - write(iulog,*)'success: ', ioname end do end subroutine init_history_io From 415f89fefc6c9ac921ea1b4dd98d72ee71f1f1d7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 26 Mar 2020 15:32:13 -0700 Subject: [PATCH 022/152] removing remnant of old code from htape_addfld --- src/main/histFileMod.F90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index ee6483256b..49a6cc940d 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -914,7 +914,6 @@ subroutine htape_addfld (t, f, avgflag) integer :: numc ! total number of columns across all processors integer :: nump ! total number of pfts across all processors integer :: num2d ! size of second dimension (e.g. .number of vertical levels) - character(len=hist_dim_name_length) :: type2d integer :: beg1d_out,end1d_out ! history output per-proc 1d beginning and ending indices integer :: beg1d,end1d ! beginning and ending indices for this field (assume already set) integer :: num1d_out ! history output 1d size @@ -1049,9 +1048,6 @@ subroutine htape_addfld (t, f, avgflag) tape(t)%hlist(n)%avgflag = avgflag end if - type2d = tape(t)%hlist(n)%field%type2d - - end subroutine htape_addfld !----------------------------------------------------------------------- From 683d14e4ecb7a35a3aad906e2c676e3e109c12f1 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 20 Apr 2020 12:02:00 -0700 Subject: [PATCH 023/152] fates-hydro, api update for hydro refactors, bug fix --- src/utils/clmfates_interfaceMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index c7b62491b0..d77cd4ab37 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2379,6 +2379,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) From df9e930ed0760c2b9747a1c51d7cb881e3be7141 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 21 Apr 2020 14:56:41 -0700 Subject: [PATCH 024/152] added time-step argument to fix nep calculations --- src/utils/clmfates_interfaceMod.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d77cd4ab37..900204708f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1911,13 +1911,14 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & 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 From 6a7d5b5a092bbda43961dc44a0724a1d6abe74e3 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 20 Apr 2020 15:01:09 -0600 Subject: [PATCH 025/152] fates-hydro: updated test user_nl_clm --- .../testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm index c7d24f7ab1..9b6cebc7a5 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm @@ -1,5 +1,9 @@ hist_empty_htapes = .true. use_fates_planthydro= .true. hist_fincl1 = 'FATES_ERRH2O_SCPF','FATES_TRAN_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' +'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' From c669928d77f8c0c24658bb8c5184120d1097f3c2 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 20 Apr 2020 13:18:45 -0600 Subject: [PATCH 026/152] updated fates parameter file, backwards compatible --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index aa8964931c..22f078eff1 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -400,7 +400,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -lnd/clm2/paramdata/fates_params_api.8.1.0_12pft_c200103.nc +lnd/clm2/paramdata/fates_params_api.10.0.0_12pft_c200420.nc From 5f71fafe90dbdc3357c7fb6dcbe71910db9755db Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 22 Apr 2020 14:57:51 -0600 Subject: [PATCH 027/152] Updating fates tag in the externals pointer --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 9f352ca8dd..6474d99ce2 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -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] From 31a59ef3abfb391a066f558638a69efeedc609c1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 5 May 2020 15:14:05 -0700 Subject: [PATCH 028/152] no for real this time, fixing merge conflicts --- cime_config/testdefs/testlist_clm.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 52f12543de..93c93569c8 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1786,6 +1786,8 @@ + + @@ -1814,6 +1816,18 @@ +<<<<<<< HEAD +||||||| constructed merge base +<<<<<<< HEAD + +======= + +>>>>>>> fates_next_api + +======= + + +>>>>>>> no for real this time, fixing merge conflicts From 77a21d4983194c7ce3713135fef5d36a83ddd400 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 7 May 2020 16:04:53 -0700 Subject: [PATCH 029/152] fates interface refactor. this interface refactor is intended to consolidate the initialization sequence, and also reduce fates side circular dependencies. This also fixes a bug where some parteh structures were not being passed to this history dimensions properly. --- src/main/clm_initializeMod.F90 | 5 +- src/main/decompInitMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 297 +++++++++++++++------------- 3 files changed, 168 insertions(+), 136 deletions(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index dc5e8f8d40..9a734b2b8d 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -24,8 +24,8 @@ module clm_initializeMod use PatchType , only : patch ! instance use reweightMod , only : reweight_wrapup use filterMod , only : allocFilters, filter, filter_inactive_and_active - use FatesInterfaceMod, only : set_fates_global_elements use dynSubgridControlMod, only: dynSubgridControl_init, get_reset_dynbal_baselines + use CLMFatesInterfaceMod, only : CLMFatesGlobals use clm_instMod use SoilMoistureStreamMod, only : PrescribedSoilMoistureInit @@ -197,9 +197,10 @@ subroutine initialize1(gindex_ocn) ! ! (Note: fates_maxELementsPerSite is the critical variable used by CLM ! to allocate space) + ! This also sets up various global constants in FATES ! ------------------------------------------------------------------------ - call set_fates_global_elements(use_fates) + call CLMFatesGlobals() ! ------------------------------------------------------------------------ ! Determine decomposition of subgrid scale landunits, columns, patches diff --git a/src/main/decompInitMod.F90 b/src/main/decompInitMod.F90 index 540dd3cde9..c114e5968f 100644 --- a/src/main/decompInitMod.F90 +++ b/src/main/decompInitMod.F90 @@ -20,7 +20,7 @@ module decompInitMod use glcBehaviorMod , only : glc_behavior_type use decompMod use mct_mod , only : mct_gsMap_init, mct_gsMap_ngseg, mct_gsMap_nlseg, mct_gsmap_gsize - use FatesInterfaceMod, only : fates_maxElementsPerSite + use FatesInterfaceTypesMod, only : fates_maxElementsPerSite ! ! !PUBLIC TYPES: implicit none diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 900204708f..25b4d31d55 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -49,6 +49,7 @@ module CLMFatesInterfaceMod use clm_varctl , only : iulog use clm_varctl , only : use_vertsoilc use clm_varctl , only : fates_parteh_mode + use clm_varctl , only : use_fates use clm_varctl , only : use_fates_spitfire use clm_varctl , only : use_fates_planthydro use clm_varctl , only : use_fates_cohort_age_tracking @@ -101,9 +102,12 @@ module CLMFatesInterfaceMod ! use SoilWaterPlantSinkMod, only : Compute_EffecRootFrac_And_VertTranSink_Default ! Used FATES Modules - use FatesInterfaceMod , only : fates_interface_type + use FatesInterfaceTypesMod , only : fates_interface_type + use FatesInterfaceMod, only : FatesInterfaceInit, FatesReportParameters + use FatesInterfaceMod, only : SetFatesGlobalElements use FatesInterfaceMod , only : allocate_bcin use FatesInterfaceMod , only : allocate_bcout + use FatesInterfaceMod , only : zero_bcs use FatesInterfaceMod , only : SetFatesTime use FatesInterfaceMod , only : set_fates_ctrlparms @@ -113,14 +117,13 @@ module CLMFatesInterfaceMod use EDTypesMod , only : ed_patch_type use EDTypesMod , only : num_elements - use FatesInterfaceMod , only : hlm_numlevgrnd + use FatesInterfaceTypesMod , only : hlm_numlevgrnd use EDMainMod , only : ed_ecosystem_dynamics use EDMainMod , only : ed_update_site use EDInitMod , only : zero_site 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, & @@ -132,7 +135,6 @@ module CLMFatesInterfaceMod use FatesPlantHydraulicsMod, only : hydraulics_drive use FatesPlantHydraulicsMod, only : HydrSiteColdStart use FatesPlantHydraulicsMod, only : InitHydrSites - use FatesPlantHydraulicsMod, only : UpdateH2OVeg use FatesPlantHydraulicsMod, only : RestartHydrStates implicit none @@ -206,9 +208,151 @@ module CLMFatesInterfaceMod character(len=*), parameter, private :: sourcefile = & __FILE__ - -contains + public :: CLMFatesGlobals + + contains + + + subroutine CLMFatesGlobals() + + ! -------------------------------------------------------------------------------- + ! This is one of the first calls to fates + ! Used for setting dimensions. This MUST + ! be called after NL variables are specified and + ! after the FATES parameter file has been read in + ! Aside from setting global dimension info, which + ! is used in the history file, we also transfer + ! over the NL variables to FATES global settings. + ! -------------------------------------------------------------------------------- + + logical :: verbose_output + integer :: pass_masterproc + integer :: pass_vertsoilc + integer :: pass_spitfire + integer :: pass_ed_st3 + integer :: pass_logging + integer :: pass_ed_prescribed_phys + integer :: pass_planthydro + integer :: pass_inventory_init + integer :: pass_is_restart + integer :: pass_cohort_age_tracking + + if (use_fates) then + + verbose_output = .false. + call FatesInterfaceInit(iulog, verbose_output) + + ! Force FATES parameters that are recieve type, to the unset value + call set_fates_ctrlparms('flush_to_unset') + + ! Send parameters individually + call set_fates_ctrlparms('num_sw_bbands',ival=numrad) + call set_fates_ctrlparms('vis_sw_index',ival=ivis) + call set_fates_ctrlparms('nir_sw_index',ival=inir) + + call set_fates_ctrlparms('num_lev_ground',ival=nlevgrnd) + call set_fates_ctrlparms('hlm_name',cval='CLM') + call set_fates_ctrlparms('hio_ignore_val',rval=spval) + call set_fates_ctrlparms('soilwater_ipedof',ival=get_ipedof(0)) + call set_fates_ctrlparms('max_patch_per_site',ival=(natpft_size-1)) + + call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode) + + if(is_restart()) then + pass_is_restart = 1 + else + pass_is_restart = 0 + end if + call set_fates_ctrlparms('is_restart',ival=pass_is_restart) + + if(use_vertsoilc) then + pass_vertsoilc = 1 + else + pass_vertsoilc = 0 + end if + call set_fates_ctrlparms('use_vertsoilc',ival=pass_vertsoilc) + + if(use_fates_spitfire) then + pass_spitfire = 1 + else + pass_spitfire = 0 + end if + call set_fates_ctrlparms('use_spitfire',ival=pass_spitfire) + + if(use_fates_ed_st3) then + pass_ed_st3 = 1 + else + pass_ed_st3 = 0 + end if + call set_fates_ctrlparms('use_ed_st3',ival=pass_ed_st3) + + if(use_fates_logging) then + pass_logging = 1 + else + pass_logging = 0 + end if + call set_fates_ctrlparms('use_logging',ival=pass_logging) + + if(use_fates_ed_prescribed_phys) then + pass_ed_prescribed_phys = 1 + else + pass_ed_prescribed_phys = 0 + end if + call set_fates_ctrlparms('use_ed_prescribed_phys',ival=pass_ed_prescribed_phys) + + if(use_fates_planthydro) then + pass_planthydro = 1 + else + pass_planthydro = 0 + end if + call set_fates_ctrlparms('use_planthydro',ival=pass_planthydro) + + if(use_fates_cohort_age_tracking) then + pass_cohort_age_tracking = 1 + else + pass_cohort_age_tracking = 0 + end if + call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) + + if(use_fates_inventory_init) then + pass_inventory_init = 1 + else + pass_inventory_init = 0 + end if + call set_fates_ctrlparms('use_inventory_init',ival=pass_inventory_init) + + call set_fates_ctrlparms('inventory_ctrl_file',cval=fates_inventory_ctrl_filename) + + if(masterproc)then + pass_masterproc = 1 + else + pass_masterproc = 0 + end if + call set_fates_ctrlparms('masterproc',ival=pass_masterproc) + + ! Check through FATES parameters to see if all have been set + call set_fates_ctrlparms('check_allset') + + end if + + ! This determines the total amount of space it requires in its largest + ! dimension. We are currently calling that the "cohort" dimension, but + ! it is really a utility dimension that captures the models largest + ! size need. + ! Sets: + ! fates_maxElementsPerPatch + ! num_elements + ! fates_maxElementsPerSite (where a site is roughly equivalent to a column) + ! (Note: this needs to be called when use_fates=.false. as well, becuase + ! it will return some nominal dimension sizes of 1 + + call SetFatesGlobalElements(use_fates) + + return + end subroutine CLMFatesGlobals + + ! ==================================================================================== subroutine init(this, bounds_proc ) @@ -229,8 +373,7 @@ subroutine init(this, bounds_proc ) ! is not turned on ! --------------------------------------------------------------------------------- - use FatesInterfaceMod, only : FatesInterfaceInit, FatesReportParameters - use FatesInterfaceMod, only : maxveg_ed => numpft + use FatesInterfaceTypesMod, only : numpft_fates => numpft use FatesParameterDerivedMod, only : param_derived implicit none @@ -241,7 +384,7 @@ subroutine init(this, bounds_proc ) ! local variables integer :: nclumps ! Number of threads - logical :: verbose_output + integer :: pass_masterproc integer :: pass_vertsoilc integer :: pass_spitfire @@ -270,113 +413,12 @@ subroutine init(this, bounds_proc ) ! Parameter Routines - call param_derived%Init( maxveg_ed ) - - - verbose_output = .false. - call FatesInterfaceInit(iulog, verbose_output) + call param_derived%Init( numpft_fates ) nclumps = get_proc_clumps() allocate(this%fates(nclumps)) allocate(this%f2hmap(nclumps)) - ! --------------------------------------------------------------------------------- - ! Send dimensions and other model controling parameters to FATES. These - ! are obviously only those parameters that are dictated by the host - ! --------------------------------------------------------------------------------- - - ! Force FATES parameters that are recieve type, to the unset value - call set_fates_ctrlparms('flush_to_unset') - - ! Send parameters individually - call set_fates_ctrlparms('num_sw_bbands',ival=numrad) - call set_fates_ctrlparms('vis_sw_index',ival=ivis) - call set_fates_ctrlparms('nir_sw_index',ival=inir) - - call set_fates_ctrlparms('num_lev_ground',ival=nlevgrnd) - call set_fates_ctrlparms('hlm_name',cval='CLM') - call set_fates_ctrlparms('hio_ignore_val',rval=spval) - call set_fates_ctrlparms('soilwater_ipedof',ival=get_ipedof(0)) - call set_fates_ctrlparms('max_patch_per_site',ival=(natpft_size-1)) ! RGK: FATES IGNORES - ! AND DOESNT TOUCH - ! THE BARE SOIL PATCH - call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode) - - if(is_restart()) then - pass_is_restart = 1 - else - pass_is_restart = 0 - end if - call set_fates_ctrlparms('is_restart',ival=pass_is_restart) - - if(use_vertsoilc) then - pass_vertsoilc = 1 - else - pass_vertsoilc = 0 - end if - call set_fates_ctrlparms('use_vertsoilc',ival=pass_vertsoilc) - - if(use_fates_spitfire) then - pass_spitfire = 1 - else - pass_spitfire = 0 - end if - call set_fates_ctrlparms('use_spitfire',ival=pass_spitfire) - - if(use_fates_ed_st3) then - pass_ed_st3 = 1 - else - pass_ed_st3 = 0 - end if - call set_fates_ctrlparms('use_ed_st3',ival=pass_ed_st3) - - if(use_fates_ed_prescribed_phys) then - pass_ed_prescribed_phys = 1 - else - pass_ed_prescribed_phys = 0 - end if - call set_fates_ctrlparms('use_ed_prescribed_phys',ival=pass_ed_prescribed_phys) - - if(use_fates_planthydro) then - pass_planthydro = 1 - else - pass_planthydro = 0 - end if - call set_fates_ctrlparms('use_planthydro',ival=pass_planthydro) - - if(use_fates_cohort_age_tracking) then - pass_cohort_age_tracking = 1 - else - pass_cohort_age_tracking = 0 - end if - call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) - - if(use_fates_logging) then - pass_logging = 1 - else - pass_logging = 0 - end if - call set_fates_ctrlparms('use_logging',ival=pass_logging) - - if(use_fates_inventory_init) then - pass_inventory_init = 1 - else - pass_inventory_init = 0 - end if - call set_fates_ctrlparms('use_inventory_init',ival=pass_inventory_init) - - call set_fates_ctrlparms('inventory_ctrl_file',cval=fates_inventory_ctrl_filename) - - - if(masterproc)then - pass_masterproc = 1 - else - pass_masterproc = 0 - end if - call set_fates_ctrlparms('masterproc',ival=pass_masterproc) - - ! Check through FATES parameters to see if all have been set - call set_fates_ctrlparms('check_allset') if(debug)then write(iulog,*) 'clm_fates%init(): allocating for ',nclumps,' threads' @@ -466,7 +508,7 @@ subroutine init(this, bounds_proc ) call allocate_bcin(this%fates(nc)%bc_in(s),col%nbedrock(c),ndecomp) call allocate_bcout(this%fates(nc)%bc_out(s),col%nbedrock(c),ndecomp) - call this%fates(nc)%zero_bcs(s) + call zero_bcs(this%fates(nc),s) ! Pass any grid-cell derived attributes to the site ! --------------------------------------------------------------------------- @@ -510,13 +552,7 @@ subroutine init(this, bounds_proc ) end do !$OMP END PARALLEL DO - ! This will initialize all FATES globals, - ! particular PARTEH and HYDRO globals - - call InitFatesGlobals(masterproc) - - call this%init_history_io(bounds_proc) ! Report Fates Parameters (debug flag in lower level routines) @@ -822,10 +858,6 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & ! ! This updates the internal value and the bc_out value. ! ! If hydraulics is off, it returns 0 storage if ( use_fates_planthydro ) then - ! call UpdateH2OVeg(this%fates(nc)%nsites, & - ! this%fates(nc)%sites, & - ! this%fates(nc)%bc_out) - ! do s = 1, this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) waterdiagnosticbulk_inst%total_plant_stored_h2o_col(c) = & @@ -942,8 +974,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & use FatesIODimensionsMod, only: fates_bounds_type use FatesIOVariableKindMod, only : site_r8, site_int, cohort_r8, cohort_int use EDMainMod, only : ed_update_site - use FatesInterfaceMod, only: fates_maxElementsPerSite - use FatesPlantHydraulicsMod, only : RestartHydrStates + use FatesInterfaceTypesMod, only: fates_maxElementsPerSite implicit none @@ -2392,12 +2423,12 @@ end subroutine wrap_hydraulics_drive subroutine hlm_bounds_to_fates_bounds(hlm, fates) use FatesIODimensionsMod, only : fates_bounds_type - use FatesInterfaceMod, only : nlevsclass, nlevage, nlevcoage - use FatesInterfaceMod, only : nlevheight + use FatesInterfaceTypesMod, only : nlevsclass, nlevage, nlevcoage + use FatesInterfaceTypesMod, only : nlevheight use EDtypesMod, only : nfsc use FatesLitterMod, only : ncwd use EDtypesMod, only : nlevleaf, nclmax - use FatesInterfaceMod, only : maxveg_ed => numpft + use FatesInterfaceTypesMod, only : numpft_fates => numpft use clm_varpar, only : nlevgrnd implicit none @@ -2418,7 +2449,7 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%ground_end = nlevgrnd fates%sizepft_class_begin = 1 - fates%sizepft_class_end = nlevsclass * maxveg_ed + fates%sizepft_class_end = nlevsclass * numpft_fates fates%size_class_begin = 1 fates%size_class_end = nlevsclass @@ -2430,7 +2461,7 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%coage_class_end = nlevcoage fates%pft_class_begin = 1 - fates%pft_class_end = maxveg_ed + fates%pft_class_end = numpft_fates fates%age_class_begin = 1 fates%age_class_end = nlevage @@ -2442,10 +2473,10 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%sizeage_class_end = nlevsclass * nlevage fates%agepft_class_begin = 1 - fates%agepft_class_end = nlevage * maxveg_ed + fates%agepft_class_end = nlevage * numpft_fates fates%sizeagepft_class_begin = 1 - fates%sizeagepft_class_end = nlevsclass * nlevage * maxveg_ed + fates%sizeagepft_class_end = nlevsclass * nlevage * numpft_fates fates%fuel_begin = 1 fates%fuel_end = nfsc @@ -2460,13 +2491,13 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%cnlf_end = nlevleaf * nclmax fates%cnlfpft_begin = 1 - fates%cnlfpft_end = nlevleaf * nclmax * maxveg_ed + fates%cnlfpft_end = nlevleaf * nclmax * numpft_fates fates%elem_begin = 1 fates%elem_end = num_elements fates%elpft_begin = 1 - fates%elpft_end = num_elements * maxveg_ed + fates%elpft_end = num_elements * numpft_fates fates%elcwd_begin = 1 fates%elcwd_end = num_elements * ncwd From 93b03e1d96f63308c13aee1bb09d4494dad3175a Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 7 May 2020 17:52:32 -0600 Subject: [PATCH 030/152] Removed site level veg24 since it was meaningless --- src/utils/clmfates_interfaceMod.F90 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 25b4d31d55..b1127d21f4 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -681,11 +681,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%h2o_liqvol_sl(1:nlevsoil) = & waterstatebulk_inst%h2osoi_vol_col(c,1:nlevsoil) - ! TO-DO: SHOULD THIS BE LIQVOL OR IS VOL OK? (RGK-02-2017) - - this%fates(nc)%bc_in(s)%t_veg24_si = & - temperature_inst%t_veg24_patch(col%patchi(c)) - this%fates(nc)%bc_in(s)%max_rooting_depth_index_col = & min(nlevsoil, active_layer_inst%altmax_lastyear_indx_col(c)) From 423cbeaebfaace0d6dbc2239d426322dc065959b Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 8 May 2020 11:40:29 -0700 Subject: [PATCH 031/152] fates interface - fixed module use calls --- src/main/histFileMod.F90 | 96 ++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 49a6cc940d..0d46348a38 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -23,12 +23,12 @@ module histFileMod use PatchType , only : patch use EDTypesMod , only : nclmax use EDTypesMod , only : nlevleaf - use FatesInterfaceMod , only : nlevsclass, nlevage, nlevcoage - use FatesInterfaceMod , only : nlevheight + use FatesInterfaceTypesMod , only : nlevsclass, nlevage, nlevcoage + use FatesInterfaceTypesMod , only : nlevheight use EDTypesMod , only : nfsc use FatesLitterMod , only : ncwd use EDTypesMod , only : num_elements_fates => num_elements - use FatesInterfaceMod , only : maxveg_fates => numpft + use FatesInterfaceTypesMod , only : numpft_fates => numpft use ncdio_pio ! @@ -2074,22 +2074,22 @@ subroutine htape_create (t, histrest) if(use_fates)then call ncd_defdim(lnfid, 'fates_levscag', nlevsclass * nlevage, dimid) - call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * maxveg_fates, dimid) - call ncd_defdim(lnfid, 'fates_levagepft', nlevage * maxveg_fates, dimid) + call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * numpft_fates, dimid) + call ncd_defdim(lnfid, 'fates_levagepft', nlevage * numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levscls', nlevsclass, dimid) call ncd_defdim(lnfid, 'fates_levcacls', nlevcoage, dimid) - call ncd_defdim(lnfid, 'fates_levpft', maxveg_fates, dimid) + call ncd_defdim(lnfid, 'fates_levpft', numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levage', nlevage, dimid) call ncd_defdim(lnfid, 'fates_levheight', nlevheight, dimid) call ncd_defdim(lnfid, 'fates_levfuel', nfsc, dimid) call ncd_defdim(lnfid, 'fates_levcwdsc', ncwd, dimid) - call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass*maxveg_fates, dimid) - call ncd_defdim(lnfid, 'fates_levcapf', nlevcoage*maxveg_fates, dimid) + call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass*numpft_fates, dimid) + call ncd_defdim(lnfid, 'fates_levcapf', nlevcoage*numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levcan', nclmax, dimid) call ncd_defdim(lnfid, 'fates_levcnlf', nlevleaf * nclmax, dimid) - call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * maxveg_fates, dimid) + call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levelem', num_elements_fates, dimid) - call ncd_defdim(lnfid, 'fates_levelpft', num_elements_fates * maxveg_fates, dimid) + call ncd_defdim(lnfid, 'fates_levelpft', num_elements_fates * numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levelcwd', num_elements_fates * ncwd, dimid) call ncd_defdim(lnfid, 'fates_levelage', num_elements_fates * nlevage, dimid) end if @@ -2505,37 +2505,37 @@ subroutine htape_timeconst(t, mode) use domainMod , only : ldomain, lon1d, lat1d use clm_time_manager, only : get_nstep, get_curr_date, get_curr_time use clm_time_manager, only : get_ref_date, get_calendar, NO_LEAP_C, GREGORIAN_C - use FatesInterfaceMod, only : fates_hdim_levsclass - use FatesInterfaceMod, only : fates_hdim_pfmap_levscpf - use FatesInterfaceMod, only : fates_hdim_scmap_levscpf - use FatesInterfaceMod, only : fates_hdim_levcoage - use FatesInterfaceMod, only : fates_hdim_pfmap_levcapf - use FatesInterfaceMod, only : fates_hdim_camap_levcapf - use FatesInterfaceMod, only : fates_hdim_levage - use FatesInterfaceMod, only : fates_hdim_levheight - use FatesInterfaceMod, only : fates_hdim_levpft - use FatesInterfaceMod, only : fates_hdim_scmap_levscag - use FatesInterfaceMod, only : fates_hdim_agmap_levscag - use FatesInterfaceMod, only : fates_hdim_scmap_levscagpft - use FatesInterfaceMod, only : fates_hdim_agmap_levscagpft - use FatesInterfaceMod, only : fates_hdim_pftmap_levscagpft - use FatesInterfaceMod, only : fates_hdim_agmap_levagepft - use FatesInterfaceMod, only : fates_hdim_pftmap_levagepft - use FatesInterfaceMod, only : fates_hdim_levfuel - use FatesInterfaceMod, only : fates_hdim_levcwdsc - use FatesInterfaceMod, only : fates_hdim_levcan - use FatesInterfaceMod, only : fates_hdim_canmap_levcnlf - use FatesInterfaceMod, only : fates_hdim_lfmap_levcnlf - use FatesInterfaceMod, only : fates_hdim_canmap_levcnlfpf - use FatesInterfaceMod, only : fates_hdim_lfmap_levcnlfpf - use FatesInterfaceMod, only : fates_hdim_pftmap_levcnlfpf - use FatesInterfaceMod, only : fates_hdim_levelem - use FatesInterfaceMod, only : fates_hdim_elmap_levelpft - use FatesInterfaceMod, only : fates_hdim_pftmap_levelpft - use FatesInterfaceMod, only : fates_hdim_elmap_levelcwd - use FatesInterfaceMod, only : fates_hdim_cwdmap_levelcwd - use FatesInterfaceMod, only : fates_hdim_elmap_levelage - use FatesInterfaceMod, only : fates_hdim_agemap_levelage + use FatesInterfaceTypesMod, only : fates_hdim_levsclass + use FatesInterfaceTypesMod, only : fates_hdim_pfmap_levscpf + use FatesInterfaceTypesMod, only : fates_hdim_scmap_levscpf + use FatesInterfaceTypesMod, only : fates_hdim_levcoage + use FatesInterfaceTypesMod, only : fates_hdim_pfmap_levcapf + use FatesInterfaceTypesMod, only : fates_hdim_camap_levcapf + use FatesInterfaceTypesMod, only : fates_hdim_levage + use FatesInterfaceTypesMod, only : fates_hdim_levheight + use FatesInterfaceTypesMod, only : fates_hdim_levpft + use FatesInterfaceTypesMod, only : fates_hdim_scmap_levscag + use FatesInterfaceTypesMod, only : fates_hdim_agmap_levscag + use FatesInterfaceTypesMod, only : fates_hdim_scmap_levscagpft + use FatesInterfaceTypesMod, only : fates_hdim_agmap_levscagpft + use FatesInterfaceTypesMod, only : fates_hdim_pftmap_levscagpft + use FatesInterfaceTypesMod, only : fates_hdim_agmap_levagepft + use FatesInterfaceTypesMod, only : fates_hdim_pftmap_levagepft + use FatesInterfaceTypesMod, only : fates_hdim_levfuel + use FatesInterfaceTypesMod, only : fates_hdim_levcwdsc + use FatesInterfaceTypesMod, only : fates_hdim_levcan + use FatesInterfaceTypesMod, only : fates_hdim_canmap_levcnlf + use FatesInterfaceTypesMod, only : fates_hdim_lfmap_levcnlf + use FatesInterfaceTypesMod, only : fates_hdim_canmap_levcnlfpf + use FatesInterfaceTypesMod, only : fates_hdim_lfmap_levcnlfpf + use FatesInterfaceTypesMod, only : fates_hdim_pftmap_levcnlfpf + use FatesInterfaceTypesMod, only : fates_hdim_levelem + use FatesInterfaceTypesMod, only : fates_hdim_elmap_levelpft + use FatesInterfaceTypesMod, only : fates_hdim_pftmap_levelpft + use FatesInterfaceTypesMod, only : fates_hdim_elmap_levelcwd + use FatesInterfaceTypesMod, only : fates_hdim_cwdmap_levelcwd + use FatesInterfaceTypesMod, only : fates_hdim_elmap_levelage + use FatesInterfaceTypesMod, only : fates_hdim_agemap_levelage ! @@ -4930,7 +4930,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, case('fates_levcacls') num2d = nlevcoage case ('fates_levpft') - num2d = maxveg_fates + num2d = numpft_fates case ('fates_levage') num2d = nlevage case ('fates_levheight') @@ -4940,21 +4940,21 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, case ('fates_levcwdsc') num2d = ncwd case ('fates_levscpf') - num2d = nlevsclass*maxveg_fates + num2d = nlevsclass*numpft_fates case ('fates_levcapf') - num2d = nlevcoage*maxveg_fates + num2d = nlevcoage*numpft_fates case ('fates_levscag') num2d = nlevsclass*nlevage case ('fates_levscagpf') - num2d = nlevsclass*nlevage*maxveg_fates + num2d = nlevsclass*nlevage*numpft_fates case ('fates_levagepft') - num2d = nlevage*maxveg_fates + num2d = nlevage*numpft_fates case ('fates_levcan') num2d = nclmax case ('fates_levcnlf') num2d = nlevleaf * nclmax case ('fates_levcnlfpf') - num2d = nlevleaf * nclmax * maxveg_fates + num2d = nlevleaf * nclmax * numpft_fates case ('ltype') num2d = max_lunit case ('natpft') @@ -4962,7 +4962,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, case ('fates_levelem') num2d = num_elements_fates case ('fates_levelpft') - num2d = num_elements_fates*maxveg_fates + num2d = num_elements_fates*numpft_fates case ('fates_levelcwd') num2d = num_elements_fates*ncwd case ('fates_levelage') From 38809a7ad2cdc8977568f2d691aa32b801d604b7 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 8 May 2020 16:14:30 -0600 Subject: [PATCH 032/152] updated module use statement in subgridMod for fates globals --- src/main/subgridMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/subgridMod.F90 b/src/main/subgridMod.F90 index 3f34acda69..c0dbbc3dba 100644 --- a/src/main/subgridMod.F90 +++ b/src/main/subgridMod.F90 @@ -17,7 +17,7 @@ module subgridMod use clm_instur , only : wt_lunit, wt_nat_patch, urban_valid, wt_cft use landunit_varcon, only : istcrop, istdlak, istwet, isturb_tbd, isturb_hd, isturb_md use glcBehaviorMod , only : glc_behavior_type - use FatesInterfaceMod, only : fates_maxElementsPerSite + use FatesInterfaceTypesMod, only : fates_maxElementsPerSite implicit none private From 496e48b77f8a2f2d2590792fa76b2c7c2170c9a5 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 12 May 2020 22:42:41 -0600 Subject: [PATCH 033/152] Updating fates tag to api 11 --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 6474d99ce2..903f276ead 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.35.0_api.10.0.0 +tag = sci.1.35.4_api.11.0.0 required = True [PTCLM] From d44323d32c2f62041fc594788c0006670f39cea4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 12 May 2020 11:31:52 -0700 Subject: [PATCH 034/152] changed fire variables to uppercase per PR640 --- cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm | 4 ++-- .../testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm | 4 ++-- .../testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index e7f1e272d1..f39d85411c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -4,8 +4,8 @@ hist_nhtfrq = -24 hist_empty_htapes = .true. use_fates_spitfire= .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN_ELEM','LITTER_OUT_ELEM', - 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', - 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', + 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', + 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', 'TOTSOMC','TOTLITC','T_SCALAR','NEP','HR','NPLANT_SCAG','NPLANT_SCPF', 'BA_SCLS','NPP_BY_AGE','CWD_AG_CWDSC','PARSUN_Z_CNLF','PARSUN_Z_CNLFPFT','PARSHA_Z_CAN', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm index 25c9d2a116..967a48e89c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm @@ -1,6 +1,6 @@ hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', - 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', - 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', + 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', + 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', 'TOTSOMC','TOTLITC','T_SCALAR','NEP','HR','NPLANT_SCAG','NPLANT_SCPF', 'BA_SCLS','NPP_BY_AGE','CWD_AG_CWDSC','PARSUN_Z_CNLF','PARSUN_Z_CNLFPFT','PARSHA_Z_CAN' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm index fc057c0be3..1790bb86c8 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm @@ -1,5 +1,5 @@ hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', - 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', - 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', + 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', + 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', 'TOTSOMC','TOTLITC','T_SCALAR','NEP','HR' From e599635d46711a99da14ee2d6dec4340c4ce94aa Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 29 May 2020 13:53:37 -0600 Subject: [PATCH 035/152] Updating FATES default parameter file to api 11.1 --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 22f078eff1..9027edb115 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -400,7 +400,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -lnd/clm2/paramdata/fates_params_api.10.0.0_12pft_c200420.nc +lnd/clm2/paramdata/fates_params_api.11.1.0_12pft_c200529.nc From d2af2b4aaf303d02f7d9621cfc4fb69dbc02e583 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 3 Jun 2020 13:19:56 -0700 Subject: [PATCH 036/152] updateing externals_clm.cfg to point to the associated fates tag --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 903f276ead..aa937723c3 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.35.4_api.11.0.0 +tag = sci.1.35.5_api.11.1.0 required = True [PTCLM] From 41e5989331bba80585b141461365ca2689a99a56 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Thu, 9 Apr 2020 10:00:47 -0600 Subject: [PATCH 037/152] added BC_IN to call to set_site_properties --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b1127d21f4..43553ec504 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1285,7 +1285,7 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & end do call set_site_properties(this%fates(nc)%nsites, & - this%fates(nc)%sites) + this%fates(nc)%sites,this%fates(nc)%bc_in) ! ---------------------------------------------------------------------------- ! Initialize Hydraulics Code if turned on From ecb65e7a8962a8ca2addb424f8be8621843f357c Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 13 Apr 2020 05:54:45 -0600 Subject: [PATCH 038/152] transmit wt_nat_patch to fates interface --- src/utils/clmfates_interfaceMod.F90 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 43553ec504..118ed8a829 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -64,7 +64,7 @@ module CLMFatesInterfaceMod use clm_varcon , only : denice use clm_varcon , only : ispval - use clm_varpar , only : natpft_size + use clm_varpar , only : natpft_size, natpft_ub, natpft_lb use clm_varpar , only : numrad use clm_varpar , only : ivis use clm_varpar , only : inir @@ -375,7 +375,8 @@ subroutine init(this, bounds_proc ) use FatesInterfaceTypesMod, only : numpft_fates => numpft use FatesParameterDerivedMod, only : param_derived - + use subgridMod, only : natveg_patch_exists + use clm_instur , only : wt_nat_patch implicit none ! Input Arguments @@ -400,6 +401,8 @@ subroutine init(this, bounds_proc ) integer :: c ! HLM column index integer :: l ! HLM LU index integer :: g ! HLM grid index + integer :: m ! HLM PFT index + integer :: ft ! FATES PFT index integer :: pi,pf integer, allocatable :: collist (:) type(bounds_type) :: bounds_clump @@ -517,12 +520,22 @@ subroutine init(this, bounds_proc ) this%fates(nc)%sites(s)%lat = grc%latdeg(g) this%fates(nc)%sites(s)%lon = grc%londeg(g) - end do + ! initialize static layers for reduced complexity FATES versions from HLM + ! maybe make this into a subroutine of it's own later. + do m = natpft_lb,natpft_ub + ft = m-natpft_lb+1 + if (natveg_patch_exists(g, m)) then + this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) + else + this%fates(nc)%bc_in(s)%pft_areafrac(ft)=0._r8 + end if + end do - ! Initialize site-level static quantities dictated by the HLM - ! currently ground layering depth + end do !site + ! Initialize site-level static quantities dictated by the HLM + ! currently ground layering depth call this%init_soil_depths(nc) if (use_fates_planthydro) then From 3e140762f5adce5c153540f615fe7a185e44a14c Mon Sep 17 00:00:00 2001 From: rosiealice Date: Tue, 14 Apr 2020 13:51:53 -0600 Subject: [PATCH 039/152] behold, a new namelist variable! --- bld/CLMBuildNamelist.pm | 4 ++-- bld/namelist_files/namelist_defaults_ctsm.xml | 1 + bld/namelist_files/namelist_definition_ctsm.xml | 5 +++++ src/main/clm_varctl.F90 | 1 + src/main/controlMod.F90 | 3 +++ src/utils/clmfates_interfaceMod.F90 | 2 ++ 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index d435226610..32f2bdd255 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -770,7 +770,7 @@ sub setup_cmdl_fates_mode { # dis-allow fates specific namelist items with non-fates runs my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_cohort_age_tracking", - "use_fates_inventory_init", "fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" ); + "use_fates_inventory_init","use_fates_fixed_biogeog", "fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" ); foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { $log->fatal_error("$var is being set, but can ONLY be set when -bgc fates option is used.\n"); @@ -3776,7 +3776,7 @@ sub setup_logic_fates { if (&value_is_true( $nl_flags->{'use_fates'}) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", - "use_fates_inventory_init", "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" ); + "use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'} ); } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 9027edb115..2474b64dd3 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2733,6 +2733,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 .false. .false. .false. +.false. 1 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index a0642c8199..75734bb3e2 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -640,6 +640,11 @@ Switch deciding which nutrient model to use in FATES. Toggle to turn on spitfire module for modeling fire (only relevant if FATES is being used). + +Toggle to turn on fixed biogeography mode (only relevant if FATES is being used). + + Toggle to turn on the logging module (only relevant if FATES is being used). diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index ac08a93407..68752767f9 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -232,6 +232,7 @@ module clm_varctl logical, public :: use_fates_ed_st3 = .false. ! true => static stand structure logical, public :: use_fates_ed_prescribed_phys = .false. ! true => prescribed physiology logical, public :: use_fates_inventory_init = .false. ! true => initialize fates from inventory + logical, public :: use_fates_fixed_biogeog = .false. ! true => use fixed biogeography mode character(len=256), public :: fates_inventory_ctrl_filename = '' ! filename for inventory control !---------------------------------------------------------- diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index d24eea2a15..1ee2fda0da 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -226,6 +226,7 @@ subroutine control_init( ) use_fates_cohort_age_tracking, & use_fates_ed_prescribed_phys, & use_fates_inventory_init, & + use_fates_fixed_biogeog, & fates_inventory_ctrl_filename, & fates_parteh_mode @@ -719,6 +720,7 @@ subroutine control_spmd() call mpi_bcast (use_fates_ed_st3, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_ed_prescribed_phys, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_inventory_init, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_fixed_biogeog, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_inventory_ctrl_filename, len(fates_inventory_ctrl_filename), MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (fates_paramfile, len(fates_paramfile) , MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (fates_parteh_mode, 1, MPI_INTEGER, 0, mpicom, ier) @@ -1071,6 +1073,7 @@ subroutine control_print () write(iulog, *) ' use_fates_ed_st3 = ',use_fates_ed_st3 write(iulog, *) ' use_fates_ed_prescribed_phys = ',use_fates_ed_prescribed_phys write(iulog, *) ' use_fates_inventory_init = ',use_fates_inventory_init + write(iulog, *) ' use_fates_fixed_biogeog = ', use_fates_fixed_biogeog write(iulog, *) ' fates_inventory_ctrl_filename = ',fates_inventory_ctrl_filename end if end subroutine control_print diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 118ed8a829..411140141e 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -57,6 +57,7 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_fates_ed_prescribed_phys use clm_varctl , only : use_fates_logging use clm_varctl , only : use_fates_inventory_init + use clm_varctl , only : use_fates_fixed_biogeog use clm_varctl , only : fates_inventory_ctrl_filename use clm_varcon , only : tfrz @@ -396,6 +397,7 @@ subroutine init(this, bounds_proc ) integer :: pass_cohort_age_tracking integer :: pass_inventory_init integer :: pass_is_restart + integer :: pass_biogeog integer :: nc ! thread index integer :: s ! FATES site index integer :: c ! HLM column index From f90c8be1764237d89d21e5b97ba554130ce3c7dc Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 11 May 2020 18:35:56 -0700 Subject: [PATCH 040/152] adding files for fates fixed biogeo testing --- cime_config/testdefs/testlist_clm.xml | 32 +++++++++++-------- .../FatesFixedBiogeo/include_user_mods | 1 + .../FatesFixedBiogeo/user_nl_clm | 1 + 3 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 93c93569c8..18710a3a06 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1816,18 +1816,6 @@ -<<<<<<< HEAD -||||||| constructed merge base -<<<<<<< HEAD - -======= - ->>>>>>> fates_next_api - -======= - - ->>>>>>> no for real this time, fixing merge conflicts @@ -1836,6 +1824,7 @@ + @@ -1895,7 +1884,16 @@ - + + + + + + + + + + @@ -1903,6 +1901,14 @@ + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods new file mode 100644 index 0000000000..1f2c03aebe --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods @@ -0,0 +1 @@ +../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm new file mode 100644 index 0000000000..0d9456c4e6 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm @@ -0,0 +1 @@ +use_fates_cohort_age_tracking=.true. \ No newline at end of file From fc04937a66fcc5a4d95bc0ed3a0edad1b6e0be32 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 13 May 2020 14:29:42 -0700 Subject: [PATCH 041/152] update user_nl_clm to use_fates_fixed_biogeog --- cime_config/testdefs/testlist_clm.xml | 2 ++ .../clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 18710a3a06..f957ff6079 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1896,6 +1896,8 @@ + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm index 0d9456c4e6..d3349780e0 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm @@ -1 +1 @@ -use_fates_cohort_age_tracking=.true. \ No newline at end of file +use_fates_fixed_biogeog=.true. \ No newline at end of file From 5e6ab826c5534acaf3184a669460f942bfc0e57c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 13 May 2020 16:40:15 -0700 Subject: [PATCH 042/152] fixing typo in testmod --- cime_config/testdefs/testlist_clm.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index f957ff6079..81afc534f6 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1893,16 +1893,6 @@ - - - - - - - - - - From 25f7417023f1b2f40dea01c8db4e5c15926bb39f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 13 May 2020 16:46:38 -0700 Subject: [PATCH 043/152] moved fixed biogeo directory up on directory to reduce complex directory structure. Also renamed --- cime_config/testdefs/testlist_clm.xml | 2 +- .../clm/FatesReducedCompFixedBiogeo/include_user_mods | 1 + .../user_nl_clm | 0 .../clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/include_user_mods rename cime_config/testdefs/testmods_dirs/clm/{FatesReducedComplex/FatesFixedBiogeo => FatesReducedCompFixedBiogeo}/user_nl_clm (100%) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 81afc534f6..124b6a2930 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1884,7 +1884,7 @@ - + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/include_user_mods new file mode 100644 index 0000000000..7ad63508b8 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/include_user_mods @@ -0,0 +1 @@ +../../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods deleted file mode 100644 index 1f2c03aebe..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplex/FatesFixedBiogeo/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdDef From 485c1fcd843793666150aaf38b0cf40555b11fd0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 13 May 2020 16:50:09 -0700 Subject: [PATCH 044/152] fixing typos again --- cime_config/testdefs/testlist_clm.xml | 2 +- .../include_user_mods | 0 .../user_nl_clm | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename cime_config/testdefs/testmods_dirs/clm/{FatesReducedCompFixedBiogeo => FatesReducedComplexFixedBiogeo}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesReducedCompFixedBiogeo => FatesReducedComplexFixedBiogeo}/user_nl_clm (100%) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 124b6a2930..865e862a11 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1884,7 +1884,7 @@ - + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesReducedCompFixedBiogeo/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/user_nl_clm From cd5be0c94dac8ecdaa0ffe0bc94a038a9570a2a7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 13 May 2020 17:55:05 -0600 Subject: [PATCH 045/152] fixing call to FatesColdDef --- .../clm/FatesReducedComplexFixedBiogeo/include_user_mods | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/include_user_mods index 7ad63508b8..1f2c03aebe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/include_user_mods +++ b/cime_config/testdefs/testmods_dirs/clm/FatesReducedComplexFixedBiogeo/include_user_mods @@ -1 +1 @@ -../../FatesColdDef +../FatesColdDef From c54f625ffe1faac9b2ac873b5145f06753e9049d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 19 May 2020 11:16:08 -0700 Subject: [PATCH 046/152] removing dead code --- src/utils/clmfates_interfaceMod.F90 | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 411140141e..c35bdf9592 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -386,18 +386,6 @@ subroutine init(this, bounds_proc ) ! local variables integer :: nclumps ! Number of threads - - integer :: pass_masterproc - integer :: pass_vertsoilc - integer :: pass_spitfire - integer :: pass_ed_st3 - integer :: pass_ed_prescribed_phys - integer :: pass_logging - integer :: pass_planthydro - integer :: pass_cohort_age_tracking - integer :: pass_inventory_init - integer :: pass_is_restart - integer :: pass_biogeog integer :: nc ! thread index integer :: s ! FATES site index integer :: c ! HLM column index From 8b90363b87316a906db3718564c108917a57623b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 22 May 2020 09:20:25 -0600 Subject: [PATCH 047/152] adding fix for pft indexing bounds --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index c35bdf9592..149b65294d 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -513,7 +513,7 @@ subroutine init(this, bounds_proc ) ! initialize static layers for reduced complexity FATES versions from HLM ! maybe make this into a subroutine of it's own later. - do m = natpft_lb,natpft_ub + do m = natpft_lb,natpft_ub-1 ft = m-natpft_lb+1 if (natveg_patch_exists(g, m)) then this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) From 8de0d356dc224bf72fe42f06c8a20f0510e93628 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 5 Jun 2020 13:09:08 -0700 Subject: [PATCH 048/152] updating pointer to correct fates tag for recently merged biogeog fates_next_api PR --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index aa937723c3..71cbe69a29 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.35.5_api.11.1.0 +tag = sci.1.36.0_api.11.2.0 required = True [PTCLM] From 6bd45143889d962283f4c7a3011bb0a35d991b71 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 29 Jun 2020 16:00:13 -0700 Subject: [PATCH 049/152] cleaning up build errors that came up due to rebase --- src/biogeophys/SoilWaterMovementMod.F90 | 6 +++--- src/main/clm_instMod.F90 | 1 + src/utils/clmfates_interfaceMod.F90 | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/biogeophys/SoilWaterMovementMod.F90 b/src/biogeophys/SoilWaterMovementMod.F90 index 352a93e82d..885aefa004 100644 --- a/src/biogeophys/SoilWaterMovementMod.F90 +++ b/src/biogeophys/SoilWaterMovementMod.F90 @@ -1152,9 +1152,9 @@ subroutine soilwater_moisture_form(bounds, num_hydrologyc, & smp_l => soilstate_inst%smp_l_col , & ! Input: [real(r8) (:,:) ] soil matrix potential [mm] hk_l => soilstate_inst%hk_l_col , & ! Input: [real(r8) (:,:) ] hydraulic conductivity (mm/s) - h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice water (kg/m2) - h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input: [real(r8) (:,:) ] liquid water (kg/m2) - qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col + h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice water (kg/m2) + h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input: [real(r8) (:,:) ] liquid water (kg/m2) + qflx_rootsoi_col => waterfluxbulk_inst%qflx_rootsoi_col & ) ! end associate statement ! Get time step diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index aab218ed62..74bc921b1e 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -575,6 +575,7 @@ subroutine clm_instRest(bounds, ncid, flag, writing_finidat_interp_dest_file) call clm_fates%restart(bounds, ncid, flag=flag, & waterdiagnosticbulk_inst=water_inst%waterdiagnosticbulk_inst, & + waterstatebulk_inst=water_inst%waterstatebulk_inst, & canopystate_inst=canopystate_inst, & soilstate_inst=soilstate_inst) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 149b65294d..112b5424c3 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -950,7 +950,7 @@ end subroutine wrap_update_hlmfates_dyn ! ==================================================================================== subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & - canopystate_inst, soilstate_inst ) + waterstatebulk_inst, canopystate_inst, soilstate_inst ) ! --------------------------------------------------------------------------------- ! The ability to restart the model is handled through three different types of calls @@ -982,7 +982,8 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & type(bounds_type) , intent(in) :: bounds_proc type(file_desc_t) , intent(inout) :: ncid ! netcdf id character(len=*) , intent(in) :: flag - type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst + type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst + type(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst type(canopystate_type) , intent(inout) :: canopystate_inst type(soilstate_type) , intent(inout) :: soilstate_inst @@ -1207,7 +1208,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & soilstate_inst%bsw_col(c,1:nlevsoil) this%fates(nc)%bc_in(s)%h2o_liq_sisl(1:nlevsoil) = & - waterdiagnosticbulk_inst%waterstate_inst%h2osoi_liq_col(c,1:nlevsoil) + waterstatebulk_inst%h2osoi_liq_col(c,1:nlevsoil) end do @@ -1925,7 +1926,8 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & type(soilbiogeochem_carbonstate_type), intent(in) :: soilbiogeochem_carbonstate_inst ! locals - integer :: s,c + real(r8) :: dtime + integer :: s,c associate(& hr => soilbiogeochem_carbonflux_inst%hr_col, & ! (gC/m2/s) total heterotrophic respiration @@ -1940,7 +1942,7 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & this%fates(nc)%bc_in(s)%tot_litc = totlitc(c) end do - dtime = get_step_size() + dtime = get_step_size_real() ! Update history variables that track these variables call this%fates_hist%update_history_cbal(nc, & From 9b2656ee3790e5aeb571816a296efd7adfd79440 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 30 Jun 2020 10:56:45 -0700 Subject: [PATCH 050/152] Fix circular dependency --- src/biogeophys/BalanceCheckMod.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/biogeophys/BalanceCheckMod.F90 b/src/biogeophys/BalanceCheckMod.F90 index 480eff0298..7d839e2242 100644 --- a/src/biogeophys/BalanceCheckMod.F90 +++ b/src/biogeophys/BalanceCheckMod.F90 @@ -250,7 +250,6 @@ subroutine BalanceCheck( bounds, & use clm_varcon , only : spval use clm_time_manager , only : get_step_size_real, get_nstep use clm_time_manager , only : get_nstep_since_startup_or_lastDA_restart_or_pause - use clm_instMod , only : surfalb_inst use CanopyStateType , only : canopystate_type use SurfaceAlbedoType , only : surfalb_type use subgridAveMod From 1dd0850cd92fe4820591858195df87e65a288145 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 30 Jun 2020 10:58:20 -0700 Subject: [PATCH 051/152] fix missing biogeog setting --- src/utils/clmfates_interfaceMod.F90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 112b5424c3..6601d00001 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -238,7 +238,8 @@ subroutine CLMFatesGlobals() integer :: pass_inventory_init integer :: pass_is_restart integer :: pass_cohort_age_tracking - + integer :: pass_biogeog + if (use_fates) then verbose_output = .false. @@ -281,6 +282,13 @@ subroutine CLMFatesGlobals() end if call set_fates_ctrlparms('use_spitfire',ival=pass_spitfire) + if(use_fates_fixed_biogeog)then + pass_biogeog = 1 + else + pass_biogeog = 0 + end if + call set_fates_ctrlparms('use_fixed_biogeog',ival=pass_biogeog) + if(use_fates_ed_st3) then pass_ed_st3 = 1 else From d972d9de2d184cf7c8120ef2ce3401d0ccf09b5b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 3 Jul 2020 16:56:34 -0600 Subject: [PATCH 052/152] fixing missed usage of ratio that cause CompareBulkToTracer runtime error --- src/biogeophys/WaterStateType.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/biogeophys/WaterStateType.F90 b/src/biogeophys/WaterStateType.F90 index 668317546a..4f59b78c63 100644 --- a/src/biogeophys/WaterStateType.F90 +++ b/src/biogeophys/WaterStateType.F90 @@ -348,9 +348,9 @@ subroutine InitCold(this, bounds, & this%h2osoi_vol_col(c,j) = 0.0_r8 else if(use_fates_planthydro) then - this%h2osoi_vol_col(c,j) = 0.75_r8*watsat_col(c,j) + this%h2osoi_vol_col(c,j) = 0.75_r8*watsat_col(c,j)*ratio else - this%h2osoi_vol_col(c,j) = 0.15_r8 + this%h2osoi_vol_col(c,j) = 0.15_r8*ratio end if endif end do From d495c31b8d1a9fa7400c9ea49bdb04ae8db89bc8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 7 Jul 2020 23:42:00 -0700 Subject: [PATCH 053/152] matching Fates testdefs to fates_next_api match FatesColdDef to fates_next_api matching FatesLogging to fates_next_api updating fates testdefs to use FatesColdDef updating ERS_Ld60 fates tests to Clm50 correcting grid and Clm testlist calls correct ERS_D_Ld5 testlists to match fates_next_api correcting ERS_D_Mmpi-serial_Ld5 correcing compset call to ERS_D_Ld5.f19_g16 test update exact restart tests to FatesColdDef adding missing FatesHydro tests correcting SMS compset fixing FatesAllVars history variable setting increasing wallclock time for ERS_D_Ld3 gnu test on cheyenne fixing gnu smoke test called for fates --- cime_config/testdefs/testlist_clm.xml | 63 +++++++++++++------ .../testmods_dirs/clm/Fates/shell_commands | 1 + .../testmods_dirs/clm/Fates/user_nl_clm | 2 +- .../clm/FatesAllVars/include_user_mods | 2 +- .../clm/FatesAllVars/user_nl_clm | 8 +-- .../clm/FatesColdDef/user_nl_clm | 4 ++ .../clm/FatesLogging/include_user_mods | 2 +- .../clm/FatesNoFire/include_user_mods | 2 +- .../clm/FatesPPhys/include_user_mods | 2 +- .../clm/FatesST3/include_user_mods | 2 +- 10 files changed, 59 insertions(+), 29 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 865e862a11..c59b5a985f 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1525,6 +1525,15 @@ + + + + + + + + + @@ -1539,7 +1548,7 @@ - + @@ -1767,7 +1776,7 @@ - + @@ -1775,7 +1784,7 @@ - + @@ -1793,7 +1802,7 @@ - + @@ -1803,52 +1812,64 @@ - + - + - + + - + + - + - + + + + + + + + + + + - + @@ -1858,25 +1879,26 @@ - + + - + - + - + - + @@ -1887,13 +1909,14 @@ + - + @@ -1911,18 +1934,20 @@ - + + - + + diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands index 41a2342a51..fe7182b67f 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands @@ -1,2 +1,3 @@ ./xmlchange CLM_BLDNML_OPTS="-no-megan" --append ./xmlchange BFBFLAG="TRUE" +./xmlchange CLM_FORCE_COLDSTART="on" diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index f39d85411c..7c2892229b 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -1,4 +1,4 @@ -!!finidat = '$DIN_LOC_ROOT/lnd/clm2/initdata_map/iclm45fates-finit-s1.4.0-a3.0.0-1x1br.clm2.r.0111-01-01-00000.nc' +!! USES THE DEFAULT INITIALIZATION FILE SPECIFIED IN bld/namelist_files/namelist_defaults_ctsm.xml hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/include_user_mods index 4c7aa0f2b4..1f2c03aebe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/include_user_mods +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/include_user_mods @@ -1 +1 @@ -../Fates +../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm index d7c9b447a4..a26b638268 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm @@ -7,7 +7,7 @@ hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE',' 'PARSHA_Z_CNLFPFT','PARSUN_Z_CAN','PARSHA_Z_CAN','LAISUN_Z_CNLF','LAISHA_Z_CNLF','LAISUN_Z_CNLFPFT','LAISHA_Z_CNLFPFT', 'LAISUN_TOP_CAN','LAISHA_TOP_CAN','FABD_SUN_CNLFPFT','FABD_SHA_CNLFPFT','FABI_SUN_CNLFPFT','FABI_SHA_CNLFPFT', 'FABD_SUN_CNLF','FABD_SHA_CNLF','FABI_SUN_CNLF','FABI_SHA_CNLF','FABD_SUN_TOPLF_BYCANLAYER','FABD_SHA_TOPLF_BYCANLAYER', - 'FABI_SUN_TOPLF_BYCANLAYER','FABI_SHA_TOPLF_BYCANLAYER','TS_NET_UPTAKE_CNLF','YEAR_NET_UPTAKE_CNLF','CROWNAREA_CNLF', + 'FABI_SUN_TOPLF_BYCANLAYER','FABI_SHA_TOPLF_BYCANLAYER','NET_C_UPTAKE_CNLF','CROWNAREA_CNLF', 'MORTALITY_CARBONFLUX_CANOPY','MORTALITY_CARBONFLUX_UNDERSTORY','NPLANT_SCAG','NPLANT_CANOPY_SCAG','NPLANT_UNDERSTORY_SCAG', 'DDBH_CANOPY_SCAG','DDBH_UNDERSTORY_SCAG','MORTALITY_CANOPY_SCAG','MORTALITY_UNDERSTORY_SCAG','GPP_SCPF','GPP_CANOPY_SCPF', 'AR_CANOPY_SCPF','GPP_UNDERSTORY_SCPF','AR_UNDERSTORY_SCPF','NPP_SCPF','NPP_LEAF_SCPF','NPP_SEED_SCPF','NPP_FNRT_SCPF', @@ -20,12 +20,12 @@ hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE',' 'YESTERDAYCANLEV_UNDERSTORY_SCLS','BA_SCLS','DEMOTION_RATE_SCLS','PROMOTION_RATE_SCLS','NPLANT_CANOPY_SCLS', 'MORTALITY_CANOPY_SCLS','NPLANT_UNDERSTORY_SCLS','MORTALITY_UNDERSTORY_SCLS','TRIMMING_CANOPY_SCLS','TRIMMING_UNDERSTORY_SCLS', 'CROWN_AREA_CANOPY_SCLS','CROWN_AREA_UNDERSTORY_SCLS','LEAF_MD_CANOPY_SCLS','ROOT_MD_CANOPY_SCLS','CARBON_BALANCE_CANOPY_SCLS', - 'SEED_PROD_CANOPY_SCLS','DBALIVEDT_CANOPY_SCLS','DBDEADDT_CANOPY_SCLS','DBSTOREDT_CANOPY_SCLS','STORAGE_FLUX_CANOPY_SCLS', + 'SEED_PROD_CANOPY_SCLS', 'NPP_LEAF_CANOPY_SCLS','NPP_FROOT_CANOPY_SCLS','NPP_BSW_CANOPY_SCLS','NPP_BDEAD_CANOPY_SCLS','NPP_BSEED_CANOPY_SCLS', 'NPP_STORE_CANOPY_SCLS','RDARK_CANOPY_SCLS','LIVESTEM_MR_CANOPY_SCLS','LIVECROOT_MR_CANOPY_SCLS','FROOT_MR_CANOPY_SCLS', 'RESP_G_CANOPY_SCLS','RESP_M_CANOPY_SCLS','LEAF_MD_UNDERSTORY_SCLS','ROOT_MD_UNDERSTORY_SCLS','CARBON_BALANCE_UNDERSTORY_SCLS', - 'SEED_PROD_UNDERSTORY_SCLS','DBALIVEDT_UNDERSTORY_SCLS','DBDEADDT_UNDERSTORY_SCLS','DBSTOREDT_UNDERSTORY_SCLS', - 'STORAGE_FLUX_UNDERSTORY_SCLS','NPP_LEAF_UNDERSTORY_SCLS','NPP_FROOT_UNDERSTORY_SCLS','NPP_BSW_UNDERSTORY_SCLS', + 'SEED_PROD_UNDERSTORY_SCLS', + 'NPP_LEAF_UNDERSTORY_SCLS','NPP_FROOT_UNDERSTORY_SCLS','NPP_BSW_UNDERSTORY_SCLS', 'NPP_BDEAD_UNDERSTORY_SCLS','NPP_BSEED_UNDERSTORY_SCLS','NPP_STORE_UNDERSTORY_SCLS','RDARK_UNDERSTORY_SCLS', 'LIVESTEM_MR_UNDERSTORY_SCLS','LIVECROOT_MR_UNDERSTORY_SCLS','FROOT_MR_UNDERSTORY_SCLS','RESP_G_UNDERSTORY_SCLS', 'RESP_M_UNDERSTORY_SCLS','LITTER_IN_ELEM','LITTER_OUT_ELEM','SEED_BANK_ELEM','SEEDS_IN_LOCAL_ELEM','SEEDS_IN_EXTERN_ELEM', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm index 967a48e89c..02b13dcd1d 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm @@ -1,3 +1,7 @@ +hist_mfilt = 365 +hist_nhtfrq = -24 +hist_empty_htapes = .true. +use_fates_spitfire= .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLogging/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesLogging/include_user_mods index 4c7aa0f2b4..1f2c03aebe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesLogging/include_user_mods +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLogging/include_user_mods @@ -1 +1 @@ -../Fates +../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/include_user_mods index 4c7aa0f2b4..1f2c03aebe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/include_user_mods +++ b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/include_user_mods @@ -1 +1 @@ -../Fates +../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesPPhys/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesPPhys/include_user_mods index 4c7aa0f2b4..1f2c03aebe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesPPhys/include_user_mods +++ b/cime_config/testdefs/testmods_dirs/clm/FatesPPhys/include_user_mods @@ -1 +1 @@ -../Fates +../FatesColdDef diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesST3/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesST3/include_user_mods index 4c7aa0f2b4..1f2c03aebe 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesST3/include_user_mods +++ b/cime_config/testdefs/testmods_dirs/clm/FatesST3/include_user_mods @@ -1 +1 @@ -../Fates +../FatesColdDef From 0b7aa8a0f750bb4651c522db95fdc3951e884e93 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 23 Apr 2020 18:18:09 -0600 Subject: [PATCH 054/152] Extend CNFireMethodMod with a FATESFireData class Following @ekluzek's recommendations in #982. Purpose: Allow FATES access to CTSM's infrastructure that reads lightning and human population data sets for use in SPITFIRE. --- bld/CLMBuildNamelist.pm | 3 + bld/namelist_files/namelist_defaults_ctsm.xml | 7 +- .../namelist_definition_ctsm.xml | 6 +- src/biogeochem/CNFireFactoryMod.F90 | 40 ++++ src/biogeochem/FATESFireDataMod.F90 | 176 +++++++++++++++++ src/biogeochem/FATESFireNoDataMod.F90 | 177 ++++++++++++++++++ src/main/clm_driver.F90 | 18 +- src/main/clm_initializeMod.F90 | 22 ++- src/main/clm_instMod.F90 | 15 +- src/main/controlMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 27 ++- 11 files changed, 482 insertions(+), 11 deletions(-) create mode 100644 src/biogeochem/FATESFireDataMod.F90 create mode 100644 src/biogeochem/FATESFireNoDataMod.F90 diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 32f2bdd255..1f8157c512 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -956,6 +956,9 @@ sub setup_cmdl_fire_light_res { } else { $nl_flags->{$var} = ".false."; } + if ( $nl_flags->{'use_fates_spitfire'} > 1 ) { + $nl_flags->{$var} = ".true."; + } } #------------------------------------------------------------------------------- diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 2474b64dd3..8a09f0ef01 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1173,14 +1173,19 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 none 94x192 94x192 +360x720 0001 0001 +0001 +0001 atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc +atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc bilinear +nn nn nn @@ -2726,7 +2731,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 .false. -.false. +0 .false. .false. .false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 75734bb3e2..1b4df0b22a 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -635,9 +635,9 @@ Toggle to turn on the FATES model Switch deciding which nutrient model to use in FATES. - -Toggle to turn on spitfire module for modeling fire (only relevant if FATES is being used). + +Turn on spitfire module for modeling fire (only relevant if FATES is being used) by setting > 0. Values of 1, 2, and 3 correspond to no external inputs, external lightning data, and external confirmed ignition data, respectively. shr_kind_r8, CL => shr_kind_CL + use shr_log_mod, only: errmsg => shr_log_errMsg + use abortutils, only: endrun + use clm_varctl, only: iulog + use decompMod, only: bounds_type + use CNFireMethodMod, only: cnfire_method_type + use CNFireBaseMod, only: cnfire_base_type + ! + implicit none + private + ! + ! !PUBLIC TYPES: + public :: fates_fire_data_type + ! + type, extends(cnfire_base_type) :: fates_fire_data_type + ! !PRIVATE MEMBER DATA: + real(r8), public, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) + contains + ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: InitAccBuffer ! Initialize accumulation processes + procedure, public :: InitAccVars ! Initialize accumulation variables + procedure, public :: UpdateAccVars ! Update/extract accumulations vars + + end type fates_fire_data_type + + character(len=*), parameter, private :: sourcefile = __FILE__ + ! + ! !PRIVATE MEMBER DATA: + !----------------------------------------------------------------------- + + interface fates_fire_data_type + ! initialize a new cnfire_base object + module procedure constructor + end interface fates_fire_data_type + !----------------------------------------------------------------------- + +contains + + !------------------------------------------------------------------------ + type(fates_fire_data_type) function constructor() + ! + ! !DESCRIPTION: + ! Creates an object of type fates_fire_data_type + ! !ARGUMENTS: + constructor%need_lightning_and_popdens = .true. + end function constructor + + !----------------------------------------------------------------------- + subroutine InitAccBuffer (this, bounds) + ! + ! !DESCRIPTION: + ! Initialize accumulation buffer for all required module accumulated fields + ! This routine set defaults values that are then overwritten by the + ! restart file for restart or branch runs + ! + ! !USES + use clm_varcon, only : spval + use accumulMod, only : init_accum_field + ! + ! !ARGUMENTS: + class(fates_fire_data_type) :: this + type(bounds_type), intent(in) :: bounds + + ! !LOCAL VARIABLES: + integer :: begg, endg + integer :: ier + !--------------------------------------------------------------------- + + begg = bounds%begg; endg = bounds%endg + + allocate(this%lnfm24(begg:endg), stat=ier) + if (ier/=0) then + call endrun(msg="allocation error for lnfm24"//& + errmsg(sourcefile, __LINE__)) + endif + this%lnfm24(:) = spval + call init_accum_field (name='lnfm24', units='strikes/km2/hr', & + desc='24hr average of lightning strikes', accum_type='runmean', & + accum_period=-1, subgrid_type='gridcell', numlev=1, init_value=0._r8) + + end subroutine InitAccBuffer + + !----------------------------------------------------------------------- + subroutine InitAccVars(this, bounds) + ! + ! !DESCRIPTION: + ! Initialize module variables that are associated with + ! time accumulated fields. This routine is called for both an initial run + ! and a restart run (and must therefore must be called after the restart + ! file is read in and the accumulation buffer is obtained) + ! + ! !USES + use accumulMod , only : extract_accum_field + use clm_time_manager , only : get_nstep + ! + ! !ARGUMENTS: + class(fates_fire_data_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + integer :: begg, endg + integer :: nstep + integer :: ier + real(r8), pointer :: rbufslg(:) ! temporary + !--------------------------------------------------------------------- + + begg = bounds%begg; endg = bounds%endg + + ! Allocate needed dynamic memory for single level patch field + allocate(rbufslg(begg:endg), stat=ier) + if (ier/=0) then + call endrun(msg="allocation error for rbufslg"//& + errmsg(sourcefile, __LINE__)) + endif + + ! Determine time step + nstep = get_nstep() + + call extract_accum_field ('lnfm24', rbufslg, nstep) + this%lnfm24(begg:endg) = rbufslg(begg:endg) + + deallocate(rbufslg) + + end subroutine InitAccVars + + !----------------------------------------------------------------------- + subroutine UpdateAccVars (this, bounds) + ! + ! USES + use clm_time_manager, only: get_nstep + use accumulMod, only: update_accum_field, extract_accum_field + use abortutils, only: endrun + ! + ! !ARGUMENTS: + class(fates_fire_data_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + integer :: dtime ! timestep size [seconds] + integer :: nstep ! timestep number + integer :: ier ! error status + integer :: begg, endg + real(r8), pointer :: rbufslg(:) ! temporary single level - gridcell level + !--------------------------------------------------------------------- + + begg = bounds%begg; endg = bounds%endg + + nstep = get_nstep() + + ! Allocate needed dynamic memory for single level gridcell field + + allocate(rbufslg(begg:endg), stat=ier) + if (ier/=0) then + write(iulog,*)'UpdateAccVars allocation error for rbuf1dg' + call endrun(msg=errmsg(sourcefile, __LINE__)) + endif + + ! Accumulate and extract lnfm24 + rbufslg(begg:endg) = this%forc_lnfm(begg:endg) + call update_accum_field ('lnfm24', rbufslg, nstep) + call extract_accum_field ('lnfm24', this%lnfm24, nstep) + + deallocate(rbufslg) + + end subroutine UpdateAccVars + +end module FATESFireDataMod diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 new file mode 100644 index 0000000000..2603a7981d --- /dev/null +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -0,0 +1,177 @@ +module FATESFireNoDataMod + +#include "shr_assert.h" + + !----------------------------------------------------------------------- + ! !DESCRIPTION: + ! module for FATES when not obtaining fire inputs from data + ! + ! !USES: + use shr_kind_mod, only: r8 => shr_kind_r8, CL => shr_kind_CL + use shr_log_mod, only: errmsg => shr_log_errMsg + use abortutils, only: endrun + use clm_varctl, only: iulog + use decompMod, only: bounds_type + use CNFireMethodMod, only: cnfire_method_type + use CNFireBaseMod, only: cnfire_base_type + ! + implicit none + private + ! + ! !PUBLIC TYPES: + public :: fates_fire_no_data_type + ! + type, extends(cnfire_base_type) :: fates_fire_no_data_type + ! !PRIVATE MEMBER DATA: + real(r8), public, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) + contains + ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: InitAccBuffer ! Initialize accumulation processes + procedure, public :: InitAccVars ! Initialize accumulation variables + procedure, public :: UpdateAccVars ! Update/extract accumulations vars + + end type fates_fire_no_data_type + + character(len=*), parameter, private :: sourcefile = __FILE__ + ! + ! !PRIVATE MEMBER DATA: + !----------------------------------------------------------------------- + + interface fates_fire_no_data_type + ! initialize a new cnfire_base object + module procedure constructor + end interface fates_fire_no_data_type + !----------------------------------------------------------------------- + +contains + + !------------------------------------------------------------------------ + type(fates_fire_no_data_type) function constructor() + ! + ! !DESCRIPTION: + ! Creates an object of type fates_fire_no_data_type + ! !ARGUMENTS: + constructor%need_lightning_and_popdens = .true. + end function constructor + + !----------------------------------------------------------------------- + subroutine InitAccBuffer (this, bounds) + ! + ! !DESCRIPTION: + ! Initialize accumulation buffer for all required module accumulated fields + ! This routine set defaults values that are then overwritten by the + ! restart file for restart or branch runs + ! + ! !USES + use clm_varcon, only : spval + use accumulMod, only : init_accum_field + ! + ! !ARGUMENTS: + class(fates_fire_no_data_type) :: this + type(bounds_type), intent(in) :: bounds + + ! !LOCAL VARIABLES: + integer :: begg, endg + integer :: ier + !--------------------------------------------------------------------- + + begg = bounds%begg; endg = bounds%endg + + allocate(this%lnfm24(begg:endg), stat=ier) + if (ier/=0) then + call endrun(msg="allocation error for lnfm24"//& + errMsg(sourcefile, __LINE__)) + endif + this%lnfm24(:) = spval + call init_accum_field (name='lnfm24', units='strikes/km2/hr', & + desc='24hr average of lightning strikes', accum_type='runmean', & + accum_period=-1, subgrid_type='gridcell', numlev=1, init_value=0._r8) + + end subroutine InitAccBuffer + + !----------------------------------------------------------------------- + subroutine InitAccVars(this, bounds) + ! + ! !DESCRIPTION: + ! Initialize module variables that are associated with + ! time accumulated fields. This routine is called for both an initial run + ! and a restart run (and must therefore must be called after the restart + ! file is read in and the accumulation buffer is obtained) + ! + ! !USES + use accumulMod , only : extract_accum_field + use clm_time_manager , only : get_nstep + ! + ! !ARGUMENTS: + class(fates_fire_no_data_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + integer :: begg, endg + integer :: nstep + integer :: ier + real(r8), pointer :: rbufslg(:) ! temporary + !--------------------------------------------------------------------- + + begg = bounds%begg; endg = bounds%endg + + ! Allocate needed dynamic memory for single level patch field + allocate(rbufslg(begg:endg), stat=ier) + if (ier/=0) then + call endrun(msg="allocation error for rbufslg"//& + errMsg(sourcefile, __LINE__)) + endif + + ! Determine time step + nstep = get_nstep() + + call extract_accum_field ('lnfm24', rbufslg, nstep) + this%lnfm24(begg:endg) = rbufslg(begg:endg) + + deallocate(rbufslg) + + end subroutine InitAccVars + + !----------------------------------------------------------------------- + subroutine UpdateAccVars (this, bounds) + ! + ! USES + use clm_time_manager, only: get_nstep + use accumulMod, only: update_accum_field, extract_accum_field + use abortutils, only: endrun + use EDParamsMod, only: ED_val_nignitions + ! + ! !ARGUMENTS: + class(fates_fire_no_data_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + integer :: dtime ! timestep size [seconds] + integer :: nstep ! timestep number + integer :: ier ! error status + integer :: begg, endg + real(r8), pointer :: rbufslg(:) ! temporary single level - gridcell level + !--------------------------------------------------------------------- + + begg = bounds%begg; endg = bounds%endg + + nstep = get_nstep() + + ! Allocate needed dynamic memory for single level gridcell field + + allocate(rbufslg(begg:endg), stat=ier) + if (ier/=0) then + write(iulog,*)'UpdateAccVars allocation error for rbuf1dg' + call endrun(msg=errMsg(sourcefile, __LINE__)) + endif + + ! Accumulate and extract lnfm24 + rbufslg(begg:endg) = ED_val_nignitions + call update_accum_field ('lnfm24', rbufslg, nstep) + call extract_accum_field ('lnfm24', this%lnfm24, nstep) + + deallocate(rbufslg) + + end subroutine UpdateAccVars + +end module FATESFireNoDataMod diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index d57499671d..721cbc1699 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -111,11 +111,15 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ! !USES: use clm_time_manager , only : get_curr_date - use clm_varctl , only : use_lai_streams + use clm_varctl, only: use_lai_streams, use_fates_spitfire use SatellitePhenologyMod, only : lai_advance + use FATESFireNoDataMod, only: fates_fire_no_data_type + use FATESFireDataMod, only: fates_fire_data_type ! ! !ARGUMENTS: implicit none + type(fates_fire_data_type) :: fates_fire_data_inst + type(fates_fire_no_data_type) :: fates_fire_no_data_inst logical , intent(in) :: doalb ! true if time for surface albedo calc real(r8), intent(in) :: nextsw_cday ! calendar day for nstep+1 real(r8), intent(in) :: declinp1 ! declination angle for next time step @@ -398,6 +402,10 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro end if call bgc_vegetation_inst%InterpFileInputs(bounds_proc) call t_stopf('bgc_interp') + ! use_fates_spitfire is assigned an integer value in the namelist + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details + else if (use_fates_spitfire > 1) then + call bgc_vegetation_inst%InterpFileInputs(bounds_proc) end if ! Get time varying urban data @@ -1261,6 +1269,14 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro temperature_inst%t_ref2m_patch, temperature_inst%t_soisno_col) end if + ! use_fates_spitfire is assigned an integer value in the namelist + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details + if (use_fates_spitfire > 1) then + call fates_fire_data_inst%UpdateAccVars(bounds_proc) + else + call fates_fire_no_data_inst%UpdateAccVars(bounds_proc) + end if + call t_stopf('accum') end if diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 9a734b2b8d..35350d0baa 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -280,7 +280,7 @@ subroutine initialize2( ) use clm_varcon , only : spval use clm_varctl , only : finidat, finidat_interp_source, finidat_interp_dest, fsurdat use clm_varctl , only : use_century_decomp, single_column, scmlat, scmlon, use_cn, use_fates - use clm_varctl , only : use_crop, ndep_from_cpl + use clm_varctl , only : use_crop, ndep_from_cpl, use_fates_spitfire use clm_varorb , only : eccen, mvelpp, lambm0, obliqr use clm_time_manager , only : get_step_size_real, get_curr_calday use clm_time_manager , only : get_curr_date, get_nstep, advance_timestep @@ -305,8 +305,12 @@ subroutine initialize2( ) use controlMod , only : NLFilename use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit + use FATESFireNoDataMod, only: fates_fire_no_data_type + use FATESFireDataMod, only: fates_fire_data_type ! - ! !ARGUMENTS + ! !ARGUMENTS + type(fates_fire_data_type) :: fates_fire_data_inst + type(fates_fire_no_data_type) :: fates_fire_no_data_inst ! ! !LOCAL VARIABLES: integer :: c,i,j,k,l,p! indices @@ -507,6 +511,10 @@ subroutine initialize2( ) if ( use_c13 .and. use_c13_timeseries ) then call C13_init_TimeSeries() end if + ! use_fates_spitfire is assigned an integer value in the namelist + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details + else if (use_fates_spitfire > 1) then + call bgc_vegetation_inst%Init2(bounds_proc, NLFilename) else call SatellitePhenologyInit(bounds_proc) end if @@ -674,7 +682,15 @@ subroutine initialize2( ) call crop_inst%initAccVars(bounds_proc) end if - !------------------------------------------------------------ + ! use_fates_spitfire is assigned an integer value in the namelist + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details + if (use_fates_spitfire > 1) then + call fates_fire_data_inst%initAccVars(bounds_proc) + else + call fates_fire_no_data_inst%initAccVars(bounds_proc) + end if + + !------------------------------------------------------------ ! Read monthly vegetation !------------------------------------------------------------ diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 74bc921b1e..80552926c0 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -184,7 +184,8 @@ end subroutine clm_instReadNML subroutine clm_instInit(bounds) ! ! !USES: - use clm_varpar , only : nlevsno + use clm_varpar , only : nlevsno, numpft + use clm_varctl , only : use_fates_spitfire use controlMod , only : nlfilename, fsurdat use domainMod , only : ldomain use SoilBiogeochemDecompCascadeBGCMod , only : init_decompcascade_bgc @@ -197,9 +198,13 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps + use FATESFireNoDataMod, only: fates_fire_no_data_type + use FATESFireDataMod, only: fates_fire_data_type ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds + type(fates_fire_data_type) :: fates_fire_data_inst + type(fates_fire_no_data_type) :: fates_fire_no_data_inst ! ! !LOCAL VARIABLES: integer :: c,l,g @@ -462,6 +467,14 @@ subroutine clm_instInit(bounds) call crop_inst%InitAccBuffer(bounds) end if + ! use_fates_spitfire is assigned an integer value in the namelist + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details + if (use_fates_spitfire > 1) then + call fates_fire_data_inst%InitAccBuffer(bounds) + else + call fates_fire_no_data_inst%InitAccBuffer(bounds) + end if + call print_accum_fields() call ncd_pio_closefile(params_ncid) diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 1ee2fda0da..c912fde132 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -713,7 +713,7 @@ subroutine control_spmd() call mpi_bcast (use_fates, 1, MPI_LOGICAL, 0, mpicom, ier) - call mpi_bcast (use_fates_spitfire, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_spitfire, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (use_fates_logging, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 6601d00001..3cf8eaeda7 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -137,6 +137,7 @@ module CLMFatesInterfaceMod use FatesPlantHydraulicsMod, only : HydrSiteColdStart use FatesPlantHydraulicsMod, only : InitHydrSites use FatesPlantHydraulicsMod, only : RestartHydrStates + use CNFireMethodMod, only: cnfire_method_type implicit none @@ -177,6 +178,9 @@ module CLMFatesInterfaceMod ! fates_restart is the inteface calss for restarting the model type(fates_restart_interface_type) :: fates_restart + ! fates_fire_data_method determines the fire data passed from HLM to FATES + class(cnfire_method_type), allocatable :: fates_fire_data_method + contains procedure, public :: init @@ -385,7 +389,9 @@ subroutine init(this, bounds_proc ) use FatesInterfaceTypesMod, only : numpft_fates => numpft use FatesParameterDerivedMod, only : param_derived use subgridMod, only : natveg_patch_exists - use clm_instur , only : wt_nat_patch + use clm_instur , only : wt_nat_patch + use CNFireFactoryMod, only: create_fates_fire_data_method + implicit none ! Input Arguments @@ -569,6 +575,10 @@ subroutine init(this, bounds_proc ) ! Report Fates Parameters (debug flag in lower level routines) call FatesReportParameters(masterproc) + ! Fire data to send to FATES + allocate(this%fates_fire_data_method, & + source=create_fates_fire_data_method()) + end subroutine init ! =================================================================================== @@ -619,6 +629,10 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! ed_driver is not a hlm_fates_inst_type procedure because we need an extra step ! to process array bounding information + ! !USES + use FATESFireNoDataMod, only: fates_fire_no_data_type + use FATESFireDataMod, only: fates_fire_data_type + implicit none class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type),intent(in) :: bounds_clump @@ -633,8 +647,12 @@ subroutine dynamics_driv(this, nc, bounds_clump, & type(canopystate_type) , intent(inout) :: canopystate_inst type(soilbiogeochem_carbonflux_type), intent(inout) :: soilbiogeochem_carbonflux_inst + type(fates_fire_data_type) :: fates_fire_data_inst + type(fates_fire_no_data_type) :: fates_fire_no_data_inst + ! !LOCAL VARIABLES: integer :: s ! site index + integer :: g ! grid-cell index (HLM) integer :: c ! column index (HLM) integer :: ifp ! patch index integer :: p ! HLM patch index @@ -686,6 +704,13 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) + g = col%gridcell(c) + + if (use_fates_spitfire > 1) then + this%fates(nc)%bc_in(s)%lightning24 = fates_fire_data_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + else + this%fates(nc)%bc_in(s)%lightning24 = fates_fire_no_data_inst%lnfm24(g) / days_per_year ! #/km2/yr to #/km2/day + end if nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil From 2336a24a76bd5a6fd4939facca92985bc7182f06 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sun, 26 Apr 2020 18:30:26 -0600 Subject: [PATCH 055/152] Revisions based on code review by @ekluzek --- bld/namelist_files/namelist_defaults_ctsm.xml | 1 + bld/namelist_files/namelist_definition_ctsm.xml | 5 ++++- src/biogeochem/FATESFireNoDataMod.F90 | 9 +++++++-- src/main/clm_driver.F90 | 12 ++++-------- src/main/clm_initializeMod.F90 | 12 ++++-------- src/main/clm_instMod.F90 | 12 ++++-------- src/utils/clmfates_interfaceMod.F90 | 12 +++++------- 7 files changed, 29 insertions(+), 34 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 8a09f0ef01..fffe43963d 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1173,6 +1173,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 none 94x192 94x192 +360x720 360x720 0001 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 1b4df0b22a..920dbf7f1f 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -637,7 +637,10 @@ Switch deciding which nutrient model to use in FATES. -Turn on spitfire module for modeling fire (only relevant if FATES is being used) by setting > 0. Values of 1, 2, and 3 correspond to no external inputs, external lightning data, and external confirmed ignition data, respectively. +Turn on spitfire module to simulate fire by setting use_fates_spitfire > 0. +Relevant only if use_fates = .true.. Values of 1, 2, and 3 correspond to +no external inputs, external lightning data, and external confirmed ignition +data, respectively. 1) then - call fates_fire_data_inst%UpdateAccVars(bounds_proc) - else - call fates_fire_no_data_inst%UpdateAccVars(bounds_proc) + if (use_fates_spitfire > 0) then + call cnfire_method_inst%UpdateAccVars(bounds_proc) end if call t_stopf('accum') diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 35350d0baa..4a6ea4326a 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -305,12 +305,10 @@ subroutine initialize2( ) use controlMod , only : NLFilename use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit - use FATESFireNoDataMod, only: fates_fire_no_data_type - use FATESFireDataMod, only: fates_fire_data_type + use CNFireMethodMod, only: cnfiremethod_type ! ! !ARGUMENTS - type(fates_fire_data_type) :: fates_fire_data_inst - type(fates_fire_no_data_type) :: fates_fire_no_data_inst + type(cnfire_method_type) :: cnfire_method_inst ! ! !LOCAL VARIABLES: integer :: c,i,j,k,l,p! indices @@ -684,10 +682,8 @@ subroutine initialize2( ) ! use_fates_spitfire is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (use_fates_spitfire > 1) then - call fates_fire_data_inst%initAccVars(bounds_proc) - else - call fates_fire_no_data_inst%initAccVars(bounds_proc) + if (use_fates_spitfire > 0) then + call cnfire_method_inst%initAccVars(bounds_proc) end if !------------------------------------------------------------ diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 80552926c0..3a7063d825 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -198,13 +198,11 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps - use FATESFireNoDataMod, only: fates_fire_no_data_type - use FATESFireDataMod, only: fates_fire_data_type + use CNFireMethodMod, only: cnfire_method_type ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds - type(fates_fire_data_type) :: fates_fire_data_inst - type(fates_fire_no_data_type) :: fates_fire_no_data_inst + type(cnfire_method_type) :: cnfire_method_inst ! ! !LOCAL VARIABLES: integer :: c,l,g @@ -469,10 +467,8 @@ subroutine clm_instInit(bounds) ! use_fates_spitfire is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (use_fates_spitfire > 1) then - call fates_fire_data_inst%InitAccBuffer(bounds) - else - call fates_fire_no_data_inst%InitAccBuffer(bounds) + if (use_fates_spitfire > 0) then + call cnfire_method_inst%InitAccBuffer(bounds) end if call print_accum_fields() diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 3cf8eaeda7..d10707c5c9 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -630,8 +630,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! to process array bounding information ! !USES - use FATESFireNoDataMod, only: fates_fire_no_data_type - use FATESFireDataMod, only: fates_fire_data_type + use CNFireMethodMod, only: cnfire_method_type implicit none class(hlm_fates_interface_type), intent(inout) :: this @@ -647,8 +646,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & type(canopystate_type) , intent(inout) :: canopystate_inst type(soilbiogeochem_carbonflux_type), intent(inout) :: soilbiogeochem_carbonflux_inst - type(fates_fire_data_type) :: fates_fire_data_inst - type(fates_fire_no_data_type) :: fates_fire_no_data_inst + type(cnfire_method_type) :: cnfire_method_inst ! !LOCAL VARIABLES: integer :: s ! site index @@ -706,10 +704,10 @@ subroutine dynamics_driv(this, nc, bounds_clump, & c = this%f2hmap(nc)%fcolumn(s) g = col%gridcell(c) - if (use_fates_spitfire > 1) then - this%fates(nc)%bc_in(s)%lightning24 = fates_fire_data_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + if (use_fates_spitfire > 0) then + this%fates(nc)%bc_in(s)%lightning24 = cnfire_method_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else - this%fates(nc)%bc_in(s)%lightning24 = fates_fire_no_data_inst%lnfm24(g) / days_per_year ! #/km2/yr to #/km2/day + this%fates(nc)%bc_in(s)%lightning24 = 0.0_r8 end if nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil From c53979d9bdf143647ef613b1dada01ef5cfa8c38 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 29 Apr 2020 16:01:56 -0600 Subject: [PATCH 056/152] Revisions part 2 based on comments by @ekluzek @jkshuman @lmkueppers --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- src/biogeochem/FATESFireNoDataMod.F90 | 79 ++----------------- src/main/clm_driver.F90 | 6 +- src/main/clm_initializeMod.F90 | 6 +- src/main/clm_instMod.F90 | 6 +- src/utils/clmfates_interfaceMod.F90 | 5 +- 6 files changed, 15 insertions(+), 89 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index fffe43963d..4de23f46db 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1186,7 +1186,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc bilinear -nn +bilinear nn nn diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 index c863383da4..7fa805cf89 100644 --- a/src/biogeochem/FATESFireNoDataMod.F90 +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -22,8 +22,9 @@ module FATESFireNoDataMod public :: fates_fire_no_data_type ! type, extends(cnfire_base_type) :: fates_fire_no_data_type + ! !PRIVATE MEMBER DATA: - real(r8), public, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) + contains ! !PUBLIC MEMBER FUNCTIONS: procedure, public :: InitAccBuffer ! Initialize accumulation processes @@ -58,34 +59,20 @@ end function constructor subroutine InitAccBuffer (this, bounds) ! ! !DESCRIPTION: + ! EMPTY subroutine for the no_data case. ! Initialize accumulation buffer for all required module accumulated fields ! This routine set defaults values that are then overwritten by the ! restart file for restart or branch runs ! ! !USES - use clm_varcon, only : spval - use accumulMod, only : init_accum_field ! ! !ARGUMENTS: class(fates_fire_no_data_type) :: this type(bounds_type), intent(in) :: bounds ! !LOCAL VARIABLES: - integer :: begg, endg - integer :: ier !--------------------------------------------------------------------- - begg = bounds%begg; endg = bounds%endg - - allocate(this%lnfm24(begg:endg), stat=ier) - if (ier/=0) then - call endrun(msg="allocation error for lnfm24"//& - errMsg(sourcefile, __LINE__)) - endif - this%lnfm24(:) = spval - call init_accum_field (name='lnfm24', units='strikes/km2/hr', & - desc='24hr average of lightning strikes', accum_type='runmean', & - accum_period=-1, subgrid_type='gridcell', numlev=1, init_value=0._r8) end subroutine InitAccBuffer @@ -93,89 +80,39 @@ end subroutine InitAccBuffer subroutine InitAccVars(this, bounds) ! ! !DESCRIPTION: + ! EMPTY subroutine for the no_data case. ! Initialize module variables that are associated with ! time accumulated fields. This routine is called for both an initial run ! and a restart run (and must therefore must be called after the restart ! file is read in and the accumulation buffer is obtained) ! ! !USES - use accumulMod , only : extract_accum_field - use clm_time_manager , only : get_nstep ! ! !ARGUMENTS: class(fates_fire_no_data_type) :: this type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: - integer :: begg, endg - integer :: nstep - integer :: ier - real(r8), pointer :: rbufslg(:) ! temporary !--------------------------------------------------------------------- - begg = bounds%begg; endg = bounds%endg - - ! Allocate needed dynamic memory for single level patch field - allocate(rbufslg(begg:endg), stat=ier) - if (ier/=0) then - call endrun(msg="allocation error for rbufslg"//& - errMsg(sourcefile, __LINE__)) - endif - - ! Determine time step - nstep = get_nstep() - - call extract_accum_field ('lnfm24', rbufslg, nstep) - this%lnfm24(begg:endg) = rbufslg(begg:endg) - - deallocate(rbufslg) end subroutine InitAccVars !----------------------------------------------------------------------- subroutine UpdateAccVars (this, bounds) ! - ! USES - use clm_time_manager, only: get_nstep - use clm_time_manager, only: get_days_per_year - use accumulMod, only: update_accum_field, extract_accum_field - use abortutils, only: endrun - use EDParamsMod, only: ED_val_nignitions + ! !DESCRIPTION: + ! EMPTY subroutine for the no_data case. + ! + ! !USES ! ! !ARGUMENTS: class(fates_fire_no_data_type) :: this type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: - integer :: dtime ! timestep size [seconds] - integer :: nstep ! timestep number - integer :: days_per_year - integer :: ier ! error status - integer :: begg, endg - real(r8), pointer :: rbufslg(:) ! temporary single level - gridcell level !--------------------------------------------------------------------- - begg = bounds%begg; endg = bounds%endg - - nstep = get_nstep() - - ! Allocate needed dynamic memory for single level gridcell field - - allocate(rbufslg(begg:endg), stat=ier) - if (ier/=0) then - write(iulog,*)'UpdateAccVars allocation error for rbuf1dg' - call endrun(msg=errMsg(sourcefile, __LINE__)) - endif - - days_per_year = get_days_per_year() - - ! Accumulate and extract lnfm24 - ! Convert #/km2/yr to #/km2/hr to match lnfm from datasets - rbufslg(begg:endg) = ED_val_nignitions / (days_per_year * 24._r8) - call update_accum_field ('lnfm24', rbufslg, nstep) - call extract_accum_field ('lnfm24', this%lnfm24, nstep) - - deallocate(rbufslg) end subroutine UpdateAccVars diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 627b024ef9..6c353a2539 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -1267,11 +1267,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro temperature_inst%t_ref2m_patch, temperature_inst%t_soisno_col) end if - ! use_fates_spitfire is assigned an integer value in the namelist - ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (use_fates_spitfire > 0) then - call cnfire_method_inst%UpdateAccVars(bounds_proc) - end if + call cnfire_method_inst%UpdateAccVars(bounds_proc) call t_stopf('accum') end if diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 4a6ea4326a..a1b8a436c4 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -680,11 +680,7 @@ subroutine initialize2( ) call crop_inst%initAccVars(bounds_proc) end if - ! use_fates_spitfire is assigned an integer value in the namelist - ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (use_fates_spitfire > 0) then - call cnfire_method_inst%initAccVars(bounds_proc) - end if + call cnfire_method_inst%initAccVars(bounds_proc) !------------------------------------------------------------ ! Read monthly vegetation diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 3a7063d825..81a0ccd6ba 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -465,11 +465,7 @@ subroutine clm_instInit(bounds) call crop_inst%InitAccBuffer(bounds) end if - ! use_fates_spitfire is assigned an integer value in the namelist - ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (use_fates_spitfire > 0) then - call cnfire_method_inst%InitAccBuffer(bounds) - end if + call cnfire_method_inst%InitAccBuffer(bounds) call print_accum_fields() diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d10707c5c9..f924ae3136 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -631,6 +631,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! !USES use CNFireMethodMod, only: cnfire_method_type + use EDParamsMod, only: ED_val_nignitions implicit none class(hlm_fates_interface_type), intent(inout) :: this @@ -704,10 +705,10 @@ subroutine dynamics_driv(this, nc, bounds_clump, & c = this%f2hmap(nc)%fcolumn(s) g = col%gridcell(c) - if (use_fates_spitfire > 0) then + if (use_fates_spitfire > 1) then this%fates(nc)%bc_in(s)%lightning24 = cnfire_method_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else - this%fates(nc)%bc_in(s)%lightning24 = 0.0_r8 + this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day end if nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil From d4d6094cc46f27aa52024abf71cba18c70eed142 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 29 Apr 2020 17:44:32 -0600 Subject: [PATCH 057/152] Revisions part 3 based on @ekluzek's review --- src/biogeochem/FATESFireDataMod.F90 | 61 +++++++++++++++++++++++++++ src/biogeochem/FATESFireNoDataMod.F90 | 61 +++++++++++++++++++++++++++ src/main/clm_driver.F90 | 2 +- src/main/clm_initializeMod.F90 | 2 +- src/main/clm_instMod.F90 | 1 - src/utils/clmfates_interfaceMod.F90 | 2 +- 6 files changed, 125 insertions(+), 4 deletions(-) diff --git a/src/biogeochem/FATESFireDataMod.F90 b/src/biogeochem/FATESFireDataMod.F90 index 12c2b5cabb..96d1bd0ffe 100644 --- a/src/biogeochem/FATESFireDataMod.F90 +++ b/src/biogeochem/FATESFireDataMod.F90 @@ -29,6 +29,8 @@ module FATESFireDataMod procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables procedure, public :: UpdateAccVars ! Update/extract accumulations vars + procedure, public :: InterpFileInputs ! Interpolate inputs from files + procedure, public :: Init2 ! Initialization after determining subgrid weights end type fates_fire_data_type @@ -173,4 +175,63 @@ subroutine UpdateAccVars (this, bounds) end subroutine UpdateAccVars + !----------------------------------------------------------------------- + subroutine InterpFileInputs(this, bounds) + ! + ! !DESCRIPTION: + ! Interpolate inputs from files + ! + ! NOTE(wjs, 2016-02-23) Stuff done here could probably be done at the end of + ! InitEachTimeStep, rather than in this separate routine, except for the + ! fact that + ! (currently) this Interp stuff is done with proc bounds rather thna clump + ! bounds. I + ! think that is needed so that you don't update a given stream multiple + ! times. If we + ! rework the handling of threading / clumps so that there is a separate + ! object for + ! each clump, then I think this problem would disappear - at which point we + ! could + ! remove this Interp routine, moving its body to the end of + ! InitEachTimeStep. + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_method_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'InterpFileInputs' + !----------------------------------------------------------------------- + + call this%cnfire_method%CNFireInterp(bounds) + + end subroutine InterpFileInputs + + !----------------------------------------------------------------------- + subroutine Init2(this, bounds, NLFilename) + ! + ! !DESCRIPTION: + ! Initialization after subgrid weights are determined + ! + ! This copy should only be called if use_fates is .true. + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_method_type) , intent(inout) :: this + type(bounds_type) , intent(in) :: bounds + character(len=*) , intent(in) :: NLFilename ! namelist filename + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'Init2' + !----------------------------------------------------------------------- + + call this%cnfire_method%CNFireInit(bounds, NLFilename) + + end subroutine Init2 + end module FATESFireDataMod diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 index 7fa805cf89..0420b17539 100644 --- a/src/biogeochem/FATESFireNoDataMod.F90 +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -30,6 +30,8 @@ module FATESFireNoDataMod procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables procedure, public :: UpdateAccVars ! Update/extract accumulations vars + procedure, public :: InterpFileInputs ! Interpolate inputs from files + procedure, public :: Init2 ! Initialization after determining subgrid weights end type fates_fire_no_data_type @@ -116,4 +118,63 @@ subroutine UpdateAccVars (this, bounds) end subroutine UpdateAccVars + !----------------------------------------------------------------------- + subroutine InterpFileInputs(this, bounds) + ! + ! !DESCRIPTION: + ! EMPTY subroutine for the no_data case. + ! Interpolate inputs from files + ! + ! NOTE(wjs, 2016-02-23) Stuff done here could probably be done at the end of + ! InitEachTimeStep, rather than in this separate routine, except for the + ! fact that + ! (currently) this Interp stuff is done with proc bounds rather thna clump + ! bounds. I + ! think that is needed so that you don't update a given stream multiple + ! times. If we + ! rework the handling of threading / clumps so that there is a separate + ! object for + ! each clump, then I think this problem would disappear - at which point we + ! could + ! remove this Interp routine, moving its body to the end of + ! InitEachTimeStep. + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_method_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'InterpFileInputs' + !----------------------------------------------------------------------- + + + end subroutine InterpFileInputs + + !----------------------------------------------------------------------- + subroutine Init2(this, bounds, NLFilename) + ! + ! !DESCRIPTION: + ! EMPTY subroutine for the no_data case. + ! Initialization after subgrid weights are determined + ! + ! This copy should only be called if use_fates is .true. + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_method_type) , intent(inout) :: this + type(bounds_type) , intent(in) :: bounds + character(len=*) , intent(in) :: NLFilename ! namelist filename + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'Init2' + !----------------------------------------------------------------------- + + + end subroutine Init2 + end module FATESFireNoDataMod diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 6c353a2539..62d134225f 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -403,7 +403,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! use_fates_spitfire is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details else if (use_fates_spitfire > 1) then - call bgc_vegetation_inst%InterpFileInputs(bounds_proc) + call cnfire_method_inst%InterpFileInputs(bounds_proc) end if ! Get time varying urban data diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index a1b8a436c4..bb12f12ef7 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -512,7 +512,7 @@ subroutine initialize2( ) ! use_fates_spitfire is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details else if (use_fates_spitfire > 1) then - call bgc_vegetation_inst%Init2(bounds_proc, NLFilename) + call cnfire_method_inst%Init2(bounds_proc, NLFilename) else call SatellitePhenologyInit(bounds_proc) end if diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 81a0ccd6ba..0adc522264 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -185,7 +185,6 @@ subroutine clm_instInit(bounds) ! ! !USES: use clm_varpar , only : nlevsno, numpft - use clm_varctl , only : use_fates_spitfire use controlMod , only : nlfilename, fsurdat use domainMod , only : ldomain use SoilBiogeochemDecompCascadeBGCMod , only : init_decompcascade_bgc diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index f924ae3136..b9748e9d49 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -703,9 +703,9 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) - g = col%gridcell(c) if (use_fates_spitfire > 1) then + g = col%gridcell(c) this%fates(nc)%bc_in(s)%lightning24 = cnfire_method_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day From 3653aeefff490a98cab4a73c1c9e0ca08e49150b Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 7 May 2020 16:13:53 -0600 Subject: [PATCH 058/152] Move InterpFileInputs and Init2 to clmfates_interfaceMod Removed from FATESFire[No]DataMod. Added to clmfates_interfaceMod. Updated calls in clm_driver and clm_initialize. --- src/biogeochem/FATESFireDataMod.F90 | 61 --------------------------- src/biogeochem/FATESFireNoDataMod.F90 | 61 --------------------------- src/main/clm_driver.F90 | 2 +- src/main/clm_initializeMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 61 +++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 124 deletions(-) diff --git a/src/biogeochem/FATESFireDataMod.F90 b/src/biogeochem/FATESFireDataMod.F90 index 96d1bd0ffe..12c2b5cabb 100644 --- a/src/biogeochem/FATESFireDataMod.F90 +++ b/src/biogeochem/FATESFireDataMod.F90 @@ -29,8 +29,6 @@ module FATESFireDataMod procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables procedure, public :: UpdateAccVars ! Update/extract accumulations vars - procedure, public :: InterpFileInputs ! Interpolate inputs from files - procedure, public :: Init2 ! Initialization after determining subgrid weights end type fates_fire_data_type @@ -175,63 +173,4 @@ subroutine UpdateAccVars (this, bounds) end subroutine UpdateAccVars - !----------------------------------------------------------------------- - subroutine InterpFileInputs(this, bounds) - ! - ! !DESCRIPTION: - ! Interpolate inputs from files - ! - ! NOTE(wjs, 2016-02-23) Stuff done here could probably be done at the end of - ! InitEachTimeStep, rather than in this separate routine, except for the - ! fact that - ! (currently) this Interp stuff is done with proc bounds rather thna clump - ! bounds. I - ! think that is needed so that you don't update a given stream multiple - ! times. If we - ! rework the handling of threading / clumps so that there is a separate - ! object for - ! each clump, then I think this problem would disappear - at which point we - ! could - ! remove this Interp routine, moving its body to the end of - ! InitEachTimeStep. - ! - ! !USES: - ! - ! !ARGUMENTS: - class(cnfire_method_type), intent(inout) :: this - type(bounds_type), intent(in) :: bounds - ! - ! !LOCAL VARIABLES: - - character(len=*), parameter :: subname = 'InterpFileInputs' - !----------------------------------------------------------------------- - - call this%cnfire_method%CNFireInterp(bounds) - - end subroutine InterpFileInputs - - !----------------------------------------------------------------------- - subroutine Init2(this, bounds, NLFilename) - ! - ! !DESCRIPTION: - ! Initialization after subgrid weights are determined - ! - ! This copy should only be called if use_fates is .true. - ! - ! !USES: - ! - ! !ARGUMENTS: - class(cnfire_method_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds - character(len=*) , intent(in) :: NLFilename ! namelist filename - ! - ! !LOCAL VARIABLES: - - character(len=*), parameter :: subname = 'Init2' - !----------------------------------------------------------------------- - - call this%cnfire_method%CNFireInit(bounds, NLFilename) - - end subroutine Init2 - end module FATESFireDataMod diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 index 0420b17539..7fa805cf89 100644 --- a/src/biogeochem/FATESFireNoDataMod.F90 +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -30,8 +30,6 @@ module FATESFireNoDataMod procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables procedure, public :: UpdateAccVars ! Update/extract accumulations vars - procedure, public :: InterpFileInputs ! Interpolate inputs from files - procedure, public :: Init2 ! Initialization after determining subgrid weights end type fates_fire_no_data_type @@ -118,63 +116,4 @@ subroutine UpdateAccVars (this, bounds) end subroutine UpdateAccVars - !----------------------------------------------------------------------- - subroutine InterpFileInputs(this, bounds) - ! - ! !DESCRIPTION: - ! EMPTY subroutine for the no_data case. - ! Interpolate inputs from files - ! - ! NOTE(wjs, 2016-02-23) Stuff done here could probably be done at the end of - ! InitEachTimeStep, rather than in this separate routine, except for the - ! fact that - ! (currently) this Interp stuff is done with proc bounds rather thna clump - ! bounds. I - ! think that is needed so that you don't update a given stream multiple - ! times. If we - ! rework the handling of threading / clumps so that there is a separate - ! object for - ! each clump, then I think this problem would disappear - at which point we - ! could - ! remove this Interp routine, moving its body to the end of - ! InitEachTimeStep. - ! - ! !USES: - ! - ! !ARGUMENTS: - class(cnfire_method_type), intent(inout) :: this - type(bounds_type), intent(in) :: bounds - ! - ! !LOCAL VARIABLES: - - character(len=*), parameter :: subname = 'InterpFileInputs' - !----------------------------------------------------------------------- - - - end subroutine InterpFileInputs - - !----------------------------------------------------------------------- - subroutine Init2(this, bounds, NLFilename) - ! - ! !DESCRIPTION: - ! EMPTY subroutine for the no_data case. - ! Initialization after subgrid weights are determined - ! - ! This copy should only be called if use_fates is .true. - ! - ! !USES: - ! - ! !ARGUMENTS: - class(cnfire_method_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds - character(len=*) , intent(in) :: NLFilename ! namelist filename - ! - ! !LOCAL VARIABLES: - - character(len=*), parameter :: subname = 'Init2' - !----------------------------------------------------------------------- - - - end subroutine Init2 - end module FATESFireNoDataMod diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 62d134225f..f3d4c76885 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -403,7 +403,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! use_fates_spitfire is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details else if (use_fates_spitfire > 1) then - call cnfire_method_inst%InterpFileInputs(bounds_proc) + call clm_fates%InterpFileInputs(bounds_proc) end if ! Get time varying urban data diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index bb12f12ef7..2451db111d 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -512,7 +512,7 @@ subroutine initialize2( ) ! use_fates_spitfire is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details else if (use_fates_spitfire > 1) then - call cnfire_method_inst%Init2(bounds_proc, NLFilename) + call clm_fates%Init2(bounds_proc, NLFilename) else call SatellitePhenologyInit(bounds_proc) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b9748e9d49..141b190f31 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -196,6 +196,8 @@ module CLMFatesInterfaceMod procedure, public :: wrap_canopy_radiation procedure, public :: wrap_bgc_summary procedure, public :: TransferZ0mDisp + procedure, public :: InterpFileInputs ! Interpolate inputs from files + procedure, public :: Init2 ! Initialization after determining subgrid weights procedure, private :: init_history_io procedure, private :: wrap_update_hlmfates_dyn procedure, private :: init_soil_depths @@ -2025,6 +2027,65 @@ subroutine TransferZ0mDisp(this, bounds_clump, z0m_patch, displa_patch) return end subroutine TransferZ0mDisp + !----------------------------------------------------------------------- + subroutine InterpFileInputs(this, bounds) + ! + ! !DESCRIPTION: + ! Interpolate inputs from files + ! + ! NOTE(wjs, 2016-02-23) Stuff done here could probably be done at the end of + ! InitEachTimeStep, rather than in this separate routine, except for the + ! fact that + ! (currently) this Interp stuff is done with proc bounds rather thna clump + ! bounds. I + ! think that is needed so that you don't update a given stream multiple + ! times. If we + ! rework the handling of threading / clumps so that there is a separate + ! object for + ! each clump, then I think this problem would disappear - at which point we + ! could + ! remove this Interp routine, moving its body to the end of + ! InitEachTimeStep. + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_method_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'InterpFileInputs' + !----------------------------------------------------------------------- + + call this%cnfire_method%CNFireInterp(bounds) + + end subroutine InterpFileInputs + + !----------------------------------------------------------------------- + subroutine Init2(this, bounds, NLFilename) + ! + ! !DESCRIPTION: + ! Initialization after subgrid weights are determined + ! + ! This copy should only be called if use_fates is .true. + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_method_type) , intent(inout) :: this + type(bounds_type) , intent(in) :: bounds + character(len=*) , intent(in) :: NLFilename ! namelist filename + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'Init2' + !----------------------------------------------------------------------- + + call this%cnfire_method%CNFireInit(bounds, NLFilename) + + end subroutine Init2 + ! ====================================================================================== subroutine init_history_io(this,bounds_proc) From 1b3871f9d00824fdf9d7f4488d2d94a65e7e1790 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 7 May 2020 16:27:01 -0600 Subject: [PATCH 059/152] Added if (use_cn) around reading/interpolating population density ...since FATES only needs lightning for now. --- src/biogeochem/CNFireBaseMod.F90 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/CNFireBaseMod.F90 b/src/biogeochem/CNFireBaseMod.F90 index 91a60d5f0c..52fdd35fb0 100644 --- a/src/biogeochem/CNFireBaseMod.F90 +++ b/src/biogeochem/CNFireBaseMod.F90 @@ -116,6 +116,7 @@ subroutine CNFireInit( this, bounds, NLFilename ) ! Initialize CN Fire module ! !USES: use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=) + use clm_varctl , only : use_cn ! ! !ARGUMENTS: class(cnfire_base_type) :: this @@ -131,8 +132,11 @@ subroutine CNFireInit( this, bounds, NLFilename ) allocate( this%forc_hdm(bounds%begg:bounds%endg) ) this%forc_hdm(bounds%begg:) = nan - call this%hdm_init(bounds, NLFilename) - call this%hdm_interp(bounds) + if (use_cn) then + call this%hdm_init(bounds, NLFilename) + call this%hdm_interp(bounds) + end if + call this%lnfm_init(bounds, NLFilename) call this%lnfm_interp(bounds) end if @@ -250,13 +254,18 @@ subroutine CNFireInterp(this,bounds) ! !DESCRIPTION: ! Interpolate CN Fire datasets ! + ! !USES: + use clm_varctl, only: use_cn + ! ! !ARGUMENTS: class(cnfire_base_type) :: this type(bounds_type), intent(in) :: bounds !----------------------------------------------------------------------- if ( this%need_lightning_and_popdens ) then - call this%hdm_interp(bounds) + if (use_cn) then + call this%hdm_interp(bounds) + end if call this%lnfm_interp(bounds) end if From 5cb716dba3050005dd3049889146338b25372af2 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 7 May 2020 18:43:17 -0600 Subject: [PATCH 060/152] Corrections that reduce the number of compilation errors to two --- src/main/clm_driver.F90 | 2 -- src/main/clm_instMod.F90 | 5 +++-- src/utils/clmfates_interfaceMod.F90 | 17 +++++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index f3d4c76885..c38a03517c 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -113,11 +113,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro use clm_time_manager , only : get_curr_date use clm_varctl, only: use_lai_streams, use_fates_spitfire use SatellitePhenologyMod, only : lai_advance - use CNFireMethodMod, only: cnfire_method_type ! ! !ARGUMENTS: implicit none - type(cnfire_method_type) :: cnfire_method_inst logical , intent(in) :: doalb ! true if time for surface albedo calc real(r8), intent(in) :: nextsw_cday ! calendar day for nstep+1 real(r8), intent(in) :: declinp1 ! declination angle for next time step diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 0adc522264..d205de96d6 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -66,6 +66,7 @@ module clm_instMod use HumanIndexMod , only : humanindex_type use VOCEmissionMod , only : vocemis_type use CNFireEmissionsMod , only : fireemis_type + use CNFireMethodMod , only : cnfire_method_type use atm2lndType , only : atm2lnd_type use lnd2atmType , only : lnd2atm_type use lnd2glcMod , only : lnd2glc_type @@ -153,6 +154,8 @@ module clm_instMod type(vocemis_type) , public :: vocemis_inst type(fireemis_type) , public :: fireemis_inst type(drydepvel_type), public :: drydepvel_inst + type(cnfire_method_type), public :: cnfire_method_inst + ! FATES type(hlm_fates_interface_type), public :: clm_fates @@ -197,11 +200,9 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps - use CNFireMethodMod, only: cnfire_method_type ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds - type(cnfire_method_type) :: cnfire_method_inst ! ! !LOCAL VARIABLES: integer :: c,l,g diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 141b190f31..b998dd0764 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -632,7 +632,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! to process array bounding information ! !USES - use CNFireMethodMod, only: cnfire_method_type use EDParamsMod, only: ED_val_nignitions implicit none @@ -649,8 +648,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & type(canopystate_type) , intent(inout) :: canopystate_inst type(soilbiogeochem_carbonflux_type), intent(inout) :: soilbiogeochem_carbonflux_inst - type(cnfire_method_type) :: cnfire_method_inst - ! !LOCAL VARIABLES: integer :: s ! site index integer :: g ! grid-cell index (HLM) @@ -708,7 +705,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & if (use_fates_spitfire > 1) then g = col%gridcell(c) - this%fates(nc)%bc_in(s)%lightning24 = cnfire_method_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + this%fates(nc)%bc_in(s)%lightning24 = this%fates_fire_data_method%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day end if @@ -2050,7 +2047,7 @@ subroutine InterpFileInputs(this, bounds) ! !USES: ! ! !ARGUMENTS: - class(cnfire_method_type), intent(inout) :: this + class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: @@ -2058,7 +2055,7 @@ subroutine InterpFileInputs(this, bounds) character(len=*), parameter :: subname = 'InterpFileInputs' !----------------------------------------------------------------------- - call this%cnfire_method%CNFireInterp(bounds) + call this%fates_fire_data_method%CNFireInterp(bounds) end subroutine InterpFileInputs @@ -2073,16 +2070,16 @@ subroutine Init2(this, bounds, NLFilename) ! !USES: ! ! !ARGUMENTS: - class(cnfire_method_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds - character(len=*) , intent(in) :: NLFilename ! namelist filename + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + character(len=*), intent(in) :: NLFilename ! namelist filename ! ! !LOCAL VARIABLES: character(len=*), parameter :: subname = 'Init2' !----------------------------------------------------------------------- - call this%cnfire_method%CNFireInit(bounds, NLFilename) + call this%fates_fire_data_method%CNFireInit(bounds, NLFilename) end subroutine Init2 From af1641b5fd66c86a2cbc1872d0e16470225aab64 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 8 May 2020 12:16:13 -0600 Subject: [PATCH 061/152] Corrections for the code to compile --- src/main/clm_driver.F90 | 11 ++++++++--- src/main/clm_initializeMod.F90 | 8 +++++--- src/main/clm_instMod.F90 | 9 +++++---- src/utils/clmfates_interfaceMod.F90 | 11 +++++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index c38a03517c..6606fde8e3 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -111,8 +111,10 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ! !USES: use clm_time_manager , only : get_curr_date - use clm_varctl, only: use_lai_streams, use_fates_spitfire + use clm_varctl , only : use_lai_streams, use_fates_spitfire use SatellitePhenologyMod, only : lai_advance + use FATESFireNoDataMod , only : fates_fire_no_data_type + use FATESFireDataMod , only : fates_fire_data_type ! ! !ARGUMENTS: implicit none @@ -123,6 +125,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro logical, intent(in) :: rstwr ! true => write restart file this step logical, intent(in) :: nlend ! true => end of run on this step character(len=*),intent(in) :: rdate ! restart file time stamp for name + type(fates_fire_no_data_type) :: fates_fire_no_data_inst + type(fates_fire_data_type) :: fates_fire_data_inst ! Whether we're running with a prognostic ROF component. This shouldn't change from ! timestep to timestep, but we pass it into the driver loop because it isn't available @@ -1010,7 +1014,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call clm_fates%dynamics_driv( nc, bounds_clump, & atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & - water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst) + water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst & + frictionvel_inst) ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a ! call to reweight_wrapup, if it's needed at all. @@ -1265,7 +1270,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro temperature_inst%t_ref2m_patch, temperature_inst%t_soisno_col) end if - call cnfire_method_inst%UpdateAccVars(bounds_proc) + call fates_fire_data_inst%UpdateAccVars(bounds_proc) call t_stopf('accum') end if diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 2451db111d..b5e2017c23 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -305,10 +305,12 @@ subroutine initialize2( ) use controlMod , only : NLFilename use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit - use CNFireMethodMod, only: cnfiremethod_type + use FATESFireNoDataMod , only : fates_fire_no_data_type + use FATESFireDataMod , only : fates_fire_data_type ! ! !ARGUMENTS - type(cnfire_method_type) :: cnfire_method_inst + type(fates_fire_no_data_type) :: fates_fire_no_data_inst + type(fates_fire_data_type) :: fates_fire_data_inst ! ! !LOCAL VARIABLES: integer :: c,i,j,k,l,p! indices @@ -680,7 +682,7 @@ subroutine initialize2( ) call crop_inst%initAccVars(bounds_proc) end if - call cnfire_method_inst%initAccVars(bounds_proc) + call fates_fire_data_inst%initAccVars(bounds_proc) !------------------------------------------------------------ ! Read monthly vegetation diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index d205de96d6..3262991513 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -66,7 +66,6 @@ module clm_instMod use HumanIndexMod , only : humanindex_type use VOCEmissionMod , only : vocemis_type use CNFireEmissionsMod , only : fireemis_type - use CNFireMethodMod , only : cnfire_method_type use atm2lndType , only : atm2lnd_type use lnd2atmType , only : lnd2atm_type use lnd2glcMod , only : lnd2glc_type @@ -154,8 +153,6 @@ module clm_instMod type(vocemis_type) , public :: vocemis_inst type(fireemis_type) , public :: fireemis_inst type(drydepvel_type), public :: drydepvel_inst - type(cnfire_method_type), public :: cnfire_method_inst - ! FATES type(hlm_fates_interface_type), public :: clm_fates @@ -200,9 +197,13 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps + use FATESFireNoDataMod , only : fates_fire_no_data_type + use FATESFireDataMod , only : fates_fire_data_type ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds + type(fates_fire_no_data_type) :: fates_fire_no_data_inst + type(fates_fire_data_type) :: fates_fire_data_inst ! ! !LOCAL VARIABLES: integer :: c,l,g @@ -465,7 +466,7 @@ subroutine clm_instInit(bounds) call crop_inst%InitAccBuffer(bounds) end if - call cnfire_method_inst%InitAccBuffer(bounds) + call fates_fire_data_inst%InitAccBuffer(bounds) call print_accum_fields() diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b998dd0764..8d651e14d4 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -622,9 +622,9 @@ end subroutine check_hlm_active ! ------------------------------------------------------------------------------------ subroutine dynamics_driv(this, nc, bounds_clump, & - atm2lnd_inst, soilstate_inst, temperature_inst, & - active_layer_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst) + atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & + waterstatebulk_inst, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, & + canopystate_inst, soilbiogeochem_carbonflux_inst, frictionvel_inst) ! This wrapper is called daily from clm_driver ! This wrapper calls ed_driver, which is the daily dynamics component of FATES @@ -633,6 +633,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! !USES use EDParamsMod, only: ED_val_nignitions + use FATESFireDataMod, only: fates_fire_data_type implicit none class(hlm_fates_interface_type), intent(inout) :: this @@ -647,6 +648,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & type(wateratm2lndbulk_type) , intent(inout) :: wateratm2lndbulk_inst type(canopystate_type) , intent(inout) :: canopystate_inst type(soilbiogeochem_carbonflux_type), intent(inout) :: soilbiogeochem_carbonflux_inst + type(frictionvel_type) , intent(inout) :: frictionvel_inst + type(fates_fire_data_type) :: fates_fire_data_inst ! !LOCAL VARIABLES: integer :: s ! site index @@ -705,7 +708,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & if (use_fates_spitfire > 1) then g = col%gridcell(c) - this%fates(nc)%bc_in(s)%lightning24 = this%fates_fire_data_method%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + this%fates(nc)%bc_in(s)%lightning24 = fates_fire_data_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day end if From 737487a6f6ad1f613ebe115b0d525ebfb530feed Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 8 May 2020 14:49:54 -0600 Subject: [PATCH 062/152] Changes needed so that fates_fire_data_method is local to clmfates_interface These are the changes that I see that are needed to keep fates_fire_data_method local to clmfates_interface. Whenever fates_fire_data is accessed it has to be done through clmfates_interface, because that's the object that contains it and has it instantiated. We also will want it to be private to clmfates_interface, so it can't be accessed or changed outside of there. There were some stubs here to pass specific instances of the class types before, but they weren't completed. So those are all removed and the generic method is being accessed so that you don't have to know which specific instance is being used. Testing: I haven't tested it yet. But, will before pushing --- src/main/clm_driver.F90 | 8 ++--- src/main/clm_initializeMod.F90 | 8 ++--- src/main/clm_instMod.F90 | 8 ++--- src/utils/clmfates_interfaceMod.F90 | 48 +++++++++++++++++++++++++++-- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 6606fde8e3..a1fba14146 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -113,8 +113,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro use clm_time_manager , only : get_curr_date use clm_varctl , only : use_lai_streams, use_fates_spitfire use SatellitePhenologyMod, only : lai_advance - use FATESFireNoDataMod , only : fates_fire_no_data_type - use FATESFireDataMod , only : fates_fire_data_type ! ! !ARGUMENTS: implicit none @@ -125,8 +123,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro logical, intent(in) :: rstwr ! true => write restart file this step logical, intent(in) :: nlend ! true => end of run on this step character(len=*),intent(in) :: rdate ! restart file time stamp for name - type(fates_fire_no_data_type) :: fates_fire_no_data_inst - type(fates_fire_data_type) :: fates_fire_data_inst ! Whether we're running with a prognostic ROF component. This shouldn't change from ! timestep to timestep, but we pass it into the driver loop because it isn't available @@ -1270,7 +1266,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro temperature_inst%t_ref2m_patch, temperature_inst%t_soisno_col) end if - call fates_fire_data_inst%UpdateAccVars(bounds_proc) + if(use_fates) then + call clm_fates%UpdateAccVars(bounds_proc) + end if call t_stopf('accum') end if diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index b5e2017c23..c47c64a13c 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -305,12 +305,8 @@ subroutine initialize2( ) use controlMod , only : NLFilename use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit - use FATESFireNoDataMod , only : fates_fire_no_data_type - use FATESFireDataMod , only : fates_fire_data_type ! ! !ARGUMENTS - type(fates_fire_no_data_type) :: fates_fire_no_data_inst - type(fates_fire_data_type) :: fates_fire_data_inst ! ! !LOCAL VARIABLES: integer :: c,i,j,k,l,p! indices @@ -682,7 +678,9 @@ subroutine initialize2( ) call crop_inst%initAccVars(bounds_proc) end if - call fates_fire_data_inst%initAccVars(bounds_proc) + if ( use_fates )then + call clm_fates%initAccVars(bounds_proc) + end if !------------------------------------------------------------ ! Read monthly vegetation diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 3262991513..07fb44d011 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -197,13 +197,9 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps - use FATESFireNoDataMod , only : fates_fire_no_data_type - use FATESFireDataMod , only : fates_fire_data_type ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds - type(fates_fire_no_data_type) :: fates_fire_no_data_inst - type(fates_fire_data_type) :: fates_fire_data_inst ! ! !LOCAL VARIABLES: integer :: c,l,g @@ -466,7 +462,9 @@ subroutine clm_instInit(bounds) call crop_inst%InitAccBuffer(bounds) end if - call fates_fire_data_inst%InitAccBuffer(bounds) + if (use_fates) then + call clm_fates%InitAccBuffer(bounds) + end if call print_accum_fields() diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 8d651e14d4..1cabe33f0f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -198,6 +198,8 @@ module CLMFatesInterfaceMod procedure, public :: TransferZ0mDisp procedure, public :: InterpFileInputs ! Interpolate inputs from files procedure, public :: Init2 ! Initialization after determining subgrid weights + procedure, public :: InitAccBuffer ! Initialize any accumulation variables + procedure, public :: UpdateAccVars ! Update any accumulation variables procedure, private :: init_history_io procedure, private :: wrap_update_hlmfates_dyn procedure, private :: init_soil_depths @@ -633,7 +635,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! !USES use EDParamsMod, only: ED_val_nignitions - use FATESFireDataMod, only: fates_fire_data_type implicit none class(hlm_fates_interface_type), intent(inout) :: this @@ -649,7 +650,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & type(canopystate_type) , intent(inout) :: canopystate_inst type(soilbiogeochem_carbonflux_type), intent(inout) :: soilbiogeochem_carbonflux_inst type(frictionvel_type) , intent(inout) :: frictionvel_inst - type(fates_fire_data_type) :: fates_fire_data_inst ! !LOCAL VARIABLES: integer :: s ! site index @@ -708,7 +708,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & if (use_fates_spitfire > 1) then g = col%gridcell(c) - this%fates(nc)%bc_in(s)%lightning24 = fates_fire_data_inst%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + this%fates(nc)%bc_in(s)%lightning24 = this%fates_fire_data_method%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day end if @@ -2086,6 +2086,48 @@ subroutine Init2(this, bounds, NLFilename) end subroutine Init2 + !----------------------------------------------------------------------- + subroutine InitAccBuffer(this, bounds) + ! + ! !DESCRIPTION: + ! Initialized any accumulation variables needed for FATES + ! + ! !USES: + ! + ! !ARGUMENTS: + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'InitAccBuffer' + !----------------------------------------------------------------------- + + call this%fates_fire_data_method%InitAccBuffer( bounds ) + + end subroutine InitAccBuffer + + !----------------------------------------------------------------------- + subroutine UpdateAccVars(this, bounds) + ! + ! !DESCRIPTION: + ! Update any accumulation variables needed for FATES + ! + ! !USES: + ! + ! !ARGUMENTS: + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'UpdateAccVars' + !----------------------------------------------------------------------- + + call this%fates_fire_data_method%UpdateAccVars( bounds ) + + end subroutine UpdateAccVars + ! ====================================================================================== subroutine init_history_io(this,bounds_proc) From 5eced0c9e2131dc9fd17324131e9be7be031a725 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 8 May 2020 15:32:59 -0600 Subject: [PATCH 063/152] Update to Sam's FATES branch for the lightning reading --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 71cbe69a29..331c344e5a 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -1,8 +1,8 @@ [fates] local_path = src/fates protocol = git -repo_url = https://github.com/NGEET/fates -tag = sci.1.36.0_api.11.2.0 +repo_url = https://github.com/slevisconsulting/fates +branch = lightning_v2_fates required = True [PTCLM] From f959daad137a8a89af295d1da09510d4d2f7d80c Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 8 May 2020 15:56:49 -0600 Subject: [PATCH 064/152] Make lnfm24 data private add an get method for it Make the lnfm24 data private to inside of FATES_FireData object and add an accessor for it. The accessor gets the pointer, so there's no time spent on copying although using a pointer this way also means you can screw up the data outside of the object. But, it seems fairly well constrained so I don't know that's a problem. This is still not compiling because there needs to be a FATES interface to the object that has the FATES specific new methods that have been added. --- src/biogeochem/FATESFireDataMod.F90 | 17 ++++++++++++++++- src/biogeochem/FATESFireNoDataMod.F90 | 15 +++++++++++++++ src/utils/clmfates_interfaceMod.F90 | 7 +++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/FATESFireDataMod.F90 b/src/biogeochem/FATESFireDataMod.F90 index 12c2b5cabb..d1d6b07763 100644 --- a/src/biogeochem/FATESFireDataMod.F90 +++ b/src/biogeochem/FATESFireDataMod.F90 @@ -23,9 +23,10 @@ module FATESFireDataMod ! type, extends(cnfire_base_type) :: fates_fire_data_type ! !PRIVATE MEMBER DATA: - real(r8), public, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) + real(r8), private, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) contains ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: GetLight24 ! Return 24-hour averaged lightning data procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables procedure, public :: UpdateAccVars ! Update/extract accumulations vars @@ -54,6 +55,20 @@ type(fates_fire_data_type) function constructor() constructor%need_lightning_and_popdens = .true. end function constructor + !----------------------------------------------------------------------- + function GetLight24( this ) result(lnfm24) + ! + ! !DESCRIPTION: Get the 24-hour averaged lightning data + ! !USES + ! + ! !ARGUMENTS: + class(fates_fire_data_type) :: this + real(r8), pointer :: lnfm24(:) + !--------------------------------------------------------------------- + lnfm24 => this%lnfm24 + !--------------------------------------------------------------------- + end function + !----------------------------------------------------------------------- subroutine InitAccBuffer (this, bounds) ! diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 index 7fa805cf89..2101ae6a05 100644 --- a/src/biogeochem/FATESFireNoDataMod.F90 +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -27,6 +27,7 @@ module FATESFireNoDataMod contains ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: GetLight24 ! Return the 24-hour averaged lightning data procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables procedure, public :: UpdateAccVars ! Update/extract accumulations vars @@ -55,6 +56,20 @@ type(fates_fire_no_data_type) function constructor() constructor%need_lightning_and_popdens = .false. end function constructor + !----------------------------------------------------------------------- + function GetLight24( this ) result(lnfm24) + ! + ! !DESCRIPTION: Get the 24-hour averaged lightning data + ! !USES + ! + ! !ARGUMENTS: + class(fates_fire_no_data_type) :: this + real(r8), pointer :: lnfm24(:) + !--------------------------------------------------------------------- + call endrun( "GetLight24 should NOT be called for the FATES No-Data case" ) + !--------------------------------------------------------------------- + end function + !----------------------------------------------------------------------- subroutine InitAccBuffer (this, bounds) ! diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 1cabe33f0f..ccfda0c505 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -673,6 +673,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: days_per_year real(r8) :: model_day real(r8) :: day_of_year + real(r8), pointer :: lnfm24(:) !----------------------------------------------------------------------- ! --------------------------------------------------------------------------------- @@ -701,14 +702,16 @@ subroutine dynamics_driv(this, nc, bounds_clump, & current_date, reference_date, & model_day, floor(day_of_year), & days_per_year, 1.0_r8/dble(days_per_year)) - + if (use_fates_spitfire > 1) then + lnfm24 = this%fates_fire_data_method%GetLight24() + end if do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) if (use_fates_spitfire > 1) then g = col%gridcell(c) - this%fates(nc)%bc_in(s)%lightning24 = this%fates_fire_data_method%lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + this%fates(nc)%bc_in(s)%lightning24 = lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day else this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day end if From 34aa9f493ff9ea934eb97a26829d1a410de225bb Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 29 May 2020 13:11:14 -0600 Subject: [PATCH 065/152] Get everything consistent and building --- src/biogeochem/CNFireFactoryMod.F90 | 11 +++++---- src/biogeochem/FATESFireDataMod.F90 | 5 ++-- src/biogeochem/FATESFireNoDataMod.F90 | 6 ++--- src/main/clm_varctl.F90 | 3 +-- src/utils/clmfates_interfaceMod.F90 | 34 ++++++++++++++++++++++----- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index 91f028373e..b172c5b5ed 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -125,7 +125,7 @@ end function create_cnfire_method !----------------------------------------------------------------------- !----------------------------------------------------------------------- - function create_fates_fire_data_method() result(fates_fire_data_method) + subroutine create_fates_fire_data_method( fates_fire_data_method ) ! ! !DESCRIPTION: ! Create and return an object of fates_fire_data_method_type. @@ -134,11 +134,12 @@ function create_fates_fire_data_method() result(fates_fire_data_method) ! !USES: use clm_varctl, only: use_fates_spitfire use CNFireMethodMod, only: cnfire_method_type + use FATESFireBase, only: fates_fire_base_type use FATESFireNoDataMod, only: fates_fire_no_data_type use FATESFireDataMod, only: fates_fire_data_type ! ! !ARGUMENTS: - class(cnfire_method_type), allocatable :: fates_fire_data_method ! function result + class(fates_fire_base_type), allocatable, intent(inout) :: fates_fire_data_method ! function result ! ! !LOCAL VARIABLES: integer :: current_case @@ -150,9 +151,9 @@ function create_fates_fire_data_method() result(fates_fire_data_method) select case (current_case) case (0:1) - allocate(fates_fire_data_method, source=fates_fire_no_data_type()) + allocate(fates_fire_no_data_type :: fates_fire_data_method) case (2:3) - allocate(fates_fire_data_method, source=fates_fire_data_type()) + allocate(fates_fire_data_type :: fates_fire_data_method) case default write(iulog,*) subname//' ERROR: unknown method: ', use_fates_spitfire @@ -160,6 +161,6 @@ function create_fates_fire_data_method() result(fates_fire_data_method) end select - end function create_fates_fire_data_method + end subroutine create_fates_fire_data_method end module CNFireFactoryMod diff --git a/src/biogeochem/FATESFireDataMod.F90 b/src/biogeochem/FATESFireDataMod.F90 index d1d6b07763..f545709376 100644 --- a/src/biogeochem/FATESFireDataMod.F90 +++ b/src/biogeochem/FATESFireDataMod.F90 @@ -12,8 +12,7 @@ module FATESFireDataMod use abortutils, only: endrun use clm_varctl, only: iulog use decompMod, only: bounds_type - use CNFireMethodMod, only: cnfire_method_type - use CNFireBaseMod, only: cnfire_base_type + use FatesFireBase, only: fates_fire_base_type ! implicit none private @@ -21,7 +20,7 @@ module FATESFireDataMod ! !PUBLIC TYPES: public :: fates_fire_data_type ! - type, extends(cnfire_base_type) :: fates_fire_data_type + type, extends(fates_fire_base_type) :: fates_fire_data_type ! !PRIVATE MEMBER DATA: real(r8), private, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) contains diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 index 2101ae6a05..10f7f57a68 100644 --- a/src/biogeochem/FATESFireNoDataMod.F90 +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -12,8 +12,7 @@ module FATESFireNoDataMod use abortutils, only: endrun use clm_varctl, only: iulog use decompMod, only: bounds_type - use CNFireMethodMod, only: cnfire_method_type - use CNFireBaseMod, only: cnfire_base_type + use FatesFireBase, only: fates_fire_base_type ! implicit none private @@ -21,7 +20,8 @@ module FATESFireNoDataMod ! !PUBLIC TYPES: public :: fates_fire_no_data_type ! - type, extends(cnfire_base_type) :: fates_fire_no_data_type + type, extends(fates_fire_base_type) :: fates_fire_no_data_type + private ! !PRIVATE MEMBER DATA: diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 68752767f9..e67ed0d6f4 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -224,8 +224,7 @@ module clm_varctl integer, public :: fates_parteh_mode = -9 ! 1 => carbon only ! 2 => C+N+P (not enabled yet) ! no others enabled - - logical, public :: use_fates_spitfire = .false. ! true => use spitfire model + integer, public :: use_fates_spitfire = 0 ! > 1 => use spitfire model logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index ccfda0c505..daf2377177 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -137,7 +137,7 @@ module CLMFatesInterfaceMod use FatesPlantHydraulicsMod, only : HydrSiteColdStart use FatesPlantHydraulicsMod, only : InitHydrSites use FatesPlantHydraulicsMod, only : RestartHydrStates - use CNFireMethodMod, only: cnfire_method_type + use FATESFireBase , only : fates_fire_base_type implicit none @@ -179,7 +179,7 @@ module CLMFatesInterfaceMod type(fates_restart_interface_type) :: fates_restart ! fates_fire_data_method determines the fire data passed from HLM to FATES - class(cnfire_method_type), allocatable :: fates_fire_data_method + class(fates_fire_base_type), allocatable :: fates_fire_data_method contains @@ -198,7 +198,8 @@ module CLMFatesInterfaceMod procedure, public :: TransferZ0mDisp procedure, public :: InterpFileInputs ! Interpolate inputs from files procedure, public :: Init2 ! Initialization after determining subgrid weights - procedure, public :: InitAccBuffer ! Initialize any accumulation variables + procedure, public :: InitAccBuffer ! Initialize any accumulation buffers + procedure, public :: InitAccVars ! Initialize any accumulation variables procedure, public :: UpdateAccVars ! Update any accumulation variables procedure, private :: init_history_io procedure, private :: wrap_update_hlmfates_dyn @@ -580,8 +581,7 @@ subroutine init(this, bounds_proc ) call FatesReportParameters(masterproc) ! Fire data to send to FATES - allocate(this%fates_fire_data_method, & - source=create_fates_fire_data_method()) + call create_fates_fire_data_method( this%fates_fire_data_method ) end subroutine init @@ -2093,7 +2093,7 @@ end subroutine Init2 subroutine InitAccBuffer(this, bounds) ! ! !DESCRIPTION: - ! Initialized any accumulation variables needed for FATES + ! Initialized any accumulation buffers needed for FATES ! ! !USES: ! @@ -2110,6 +2110,28 @@ subroutine InitAccBuffer(this, bounds) end subroutine InitAccBuffer + + !----------------------------------------------------------------------- + subroutine InitAccVars(this, bounds) + ! + ! !DESCRIPTION: + ! Initialized any accumulation variables needed for FATES + ! + ! !USES: + ! + ! !ARGUMENTS: + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'InitAccVars' + !----------------------------------------------------------------------- + + call this%fates_fire_data_method%InitAccVars( bounds ) + + end subroutine InitAccVars + !----------------------------------------------------------------------- subroutine UpdateAccVars(this, bounds) ! From a8f8fdf015d6e3f40831fcbdda2f7f845222d9fd Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 29 May 2020 13:19:00 -0600 Subject: [PATCH 066/152] Use integer value for use_fates_spitfire now --- cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm | 2 +- cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm | 2 +- cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm | 2 +- cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm | 2 +- cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index 7c2892229b..a2facdeaa6 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -2,7 +2,7 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. -use_fates_spitfire= .true. +use_fates_spitfire= 1 hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN_ELEM','LITTER_OUT_ELEM', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm index a26b638268..7c2969a275 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm @@ -2,7 +2,7 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .false. -use_fates_spitfire= .true. +use_fates_spitfire= 1 hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE','GPP_BY_AGE','PARSUN_Z_CNLF','PARSHA_Z_CNLF','PARSUN_Z_CNLFPFT', 'PARSHA_Z_CNLFPFT','PARSUN_Z_CAN','PARSHA_Z_CAN','LAISUN_Z_CNLF','LAISHA_Z_CNLF','LAISUN_Z_CNLFPFT','LAISHA_Z_CNLFPFT', 'LAISUN_TOP_CAN','LAISHA_TOP_CAN','FABD_SUN_CNLFPFT','FABD_SHA_CNLFPFT','FABI_SUN_CNLFPFT','FABI_SHA_CNLFPFT', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm index 02b13dcd1d..5aea3a43ca 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm @@ -1,7 +1,7 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. -use_fates_spitfire= .true. +use_fates_spitfire= 1 hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm index dfdb775ec5..6cf2c7f70d 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm @@ -1 +1 @@ -use_fates_spitfire= .false. +use_fates_spitfire= 0 diff --git a/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm index e3a3b76d71..810eb19987 100644 --- a/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm @@ -1,2 +1,2 @@ -use_fates_spitfire = .true. +use_fates_spitfire = 1 From 9e227b38a6bbd8e1fbe6d586ec2d3be738935dfb Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 29 May 2020 13:22:27 -0600 Subject: [PATCH 067/152] Add FATES fire base class --- src/biogeochem/FATESFireBase.F90 | 108 +++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/biogeochem/FATESFireBase.F90 diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90 new file mode 100644 index 0000000000..fc3f2bd4c5 --- /dev/null +++ b/src/biogeochem/FATESFireBase.F90 @@ -0,0 +1,108 @@ +module FATESFireBase + + !----------------------------------------------------------------------- + ! !DESCRIPTION: + ! Abstract base class for FATES fire data object + ! + ! !USES: + use CNFireBaseMod , only: cnfire_base_type + ! + implicit none + private + ! + ! !PUBLIC TYPES: + public :: fates_fire_base_type + ! + type, abstract, extends(cnfire_base_type) :: fates_fire_base_type + private + + ! !PRIVATE MEMBER DATA: + + contains + ! !PUBLIC MEMBER FUNCTIONS: + procedure(GetLight24_interface), public, deferred :: GetLight24 ! Return the 24-hour averaged lightning data + procedure(InitAccBuffer_interface), public, deferred :: InitAccBuffer ! Initialize accumulation processes + procedure(InitAccVars_interface), public, deferred :: InitAccVars ! Initialize accumulation variables + procedure(UpdateAccVars_interface), public, deferred :: UpdateAccVars ! Update/extract accumulations vars + + end type fates_fire_base_type + + abstract interface + !----------------------------------------------------------------------- + + !------------------------------------------------------------------------ + function GetLight24_interface( this ) result(lnfm24) + ! + ! !DESCRIPTION: Get the 24-hour averaged lightning data + ! !USES + use shr_kind_mod , only: r8 => shr_kind_r8 + import :: fates_fire_base_type + ! + ! !ARGUMENTS: + class(fates_fire_base_type) :: this + real(r8), pointer :: lnfm24(:) + !--------------------------------------------------------------------- + !--------------------------------------------------------------------- + end function GetLight24_interface + + !----------------------------------------------------------------------- + subroutine InitAccBuffer_interface (this, bounds) + ! + ! !DESCRIPTION: + ! Initialize the accumulation buffers + ! + ! !USES + use decompMod , only: bounds_type + import :: fates_fire_base_type + ! + ! !ARGUMENTS: + class(fates_fire_base_type) :: this + type(bounds_type), intent(in) :: bounds + + ! !LOCAL VARIABLES: + !--------------------------------------------------------------------- + + end subroutine InitAccBuffer_interface + + !----------------------------------------------------------------------- + subroutine InitAccVars_interface(this, bounds) + ! + ! !DESCRIPTION: + ! Initialize the accumulation variables + ! + ! !USES + use decompMod , only: bounds_type + import :: fates_fire_base_type + ! + ! !ARGUMENTS: + class(fates_fire_base_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + !--------------------------------------------------------------------- + + end subroutine InitAccVars_interface + + !----------------------------------------------------------------------- + subroutine UpdateAccVars_interface (this, bounds) + ! + ! !DESCRIPTION: + ! Update accumulation variables + ! + ! !USES + use decompMod , only: bounds_type + import :: fates_fire_base_type + ! + ! !ARGUMENTS: + class(fates_fire_base_type) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + !--------------------------------------------------------------------- + + end subroutine UpdateAccVars_interface + + end interface + !--------------------------------------------------------------------- + +end module FATESFireBase From 9ae963bb99ac730a90837f92f324b65447f5a5d6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 4 Jun 2020 16:46:10 -0600 Subject: [PATCH 068/152] Minor corrections for clm-fates to run with a lightning dataset --- bld/CLMBuildNamelist.pm | 36 +++++++++++++++++-- .../namelist_definition_ctsm.xml | 2 +- src/main/clm_initializeMod.F90 | 10 +++--- src/utils/clmfates_interfaceMod.F90 | 8 +++++ 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 1f8157c512..187927e3af 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -946,7 +946,7 @@ sub setup_cmdl_fire_light_res { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method'); } my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); - if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) ) { + if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) { $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc."); } if ( defined($fire_method) && $fire_method eq "nofire" ) { @@ -3287,7 +3287,8 @@ sub setup_logic_lightning_streams { # lightning streams require CN/BGC my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; - if ( &value_is_true($nl_flags->{'cnfireson'}) ) { +<<<<<<< HEAD + if ( &value_is_true($nl_flags->{'cnfireson'}) || &value_is_true($nl_flags->{'use_fates'}) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); @@ -3300,6 +3301,37 @@ sub setup_logic_lightning_streams { # Set align year, if first and last years are different if ( $nl->get_value('stream_year_first_lightng') != $nl->get_value('stream_year_last_lightng') ) { +||||||| constructed merge base + if ( $physv->as_long() >= $physv->as_long("clm4_5") ) { + if ( &value_is_true($nl_flags->{'cnfireson'}) ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, + 'hgrid'=>$nl_flags->{'res'}, + 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + 'sim_year'=>$nl_flags->{'sim_year'}, + 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + 'sim_year'=>$nl_flags->{'sim_year'}, + 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + # Set align year, if first and last years are different + if ( $nl->get_value('stream_year_first_lightng') != + $nl->get_value('stream_year_last_lightng') ) { +======= + if ( $physv->as_long() >= $physv->as_long("clm4_5") ) { + if ( &value_is_true($nl_flags->{'cnfireson'}) || &value_is_true($nl_flags->{'use_fates'}) ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, + 'hgrid'=>$nl_flags->{'res'}, + 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + 'sim_year'=>$nl_flags->{'sim_year'}, + 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + 'sim_year'=>$nl_flags->{'sim_year'}, + 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + # Set align year, if first and last years are different + if ( $nl->get_value('stream_year_first_lightng') != + $nl->get_value('stream_year_last_lightng') ) { +>>>>>>> Minor corrections for clm-fates to run with a lightning dataset add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_lightng', 'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); } diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 920dbf7f1f..5a4099c33c 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -198,7 +198,7 @@ formulation (1). + group="cnfire_inparm" valid_values="nofire,li2014qianfrc,li2016crufrc,spitfire" > The method type to use for CNFire nofire: Turn fire effects off diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index c47c64a13c..53019100c5 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -507,12 +507,14 @@ subroutine initialize2( ) if ( use_c13 .and. use_c13_timeseries ) then call C13_init_TimeSeries() end if - ! use_fates_spitfire is assigned an integer value in the namelist - ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - else if (use_fates_spitfire > 1) then - call clm_fates%Init2(bounds_proc, NLFilename) else call SatellitePhenologyInit(bounds_proc) + + ! use_fates_spitfire is assigned an integer value in the namelist + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details + if (use_fates_spitfire > 1) then + call clm_fates%Init2(bounds_proc, NLFilename) + end if end if if(use_soil_moisture_streams) then diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index daf2377177..f50949cdb0 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -674,6 +674,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & real(r8) :: model_day real(r8) :: day_of_year real(r8), pointer :: lnfm24(:) + integer :: ier !----------------------------------------------------------------------- ! --------------------------------------------------------------------------------- @@ -702,7 +703,14 @@ subroutine dynamics_driv(this, nc, bounds_clump, & current_date, reference_date, & model_day, floor(day_of_year), & days_per_year, 1.0_r8/dble(days_per_year)) + if (use_fates_spitfire > 1) then + allocate(lnfm24(bounds_clump%begg:bounds_clump%endg), stat=ier) + if (ier /= 0) then + call endrun(msg="allocation error for lnfm24"//& + errmsg(sourcefile, __LINE__)) + endif + lnfm24 = this%fates_fire_data_method%GetLight24() end if From 35996d408d2043481e75664d8ef67c0495305bd6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 5 Jun 2020 17:58:05 -0600 Subject: [PATCH 069/152] Additional conflicts resolved; revisions in response to rgknox's review Had to resolve conflicts that did not get caught by git. Did some cleanup recommended by rgknox in Friday's meeting. --- bld/CLMBuildNamelist.pm | 122 +++++++++++++----- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- .../namelist_definition_ctsm.xml | 4 +- bld/unit_testers/build-namelist_test.pl | 2 +- .../testmods_dirs/clm/Fates/user_nl_clm | 2 +- .../clm/FatesAllVars/user_nl_clm | 2 +- .../clm/FatesColdDef/user_nl_clm | 2 +- .../testmods_dirs/clm/FatesNoFire/user_nl_clm | 2 +- .../testmods_dirs/clm/fatesFire/user_nl_clm | 2 +- src/biogeochem/CNFireFactoryMod.F90 | 6 +- src/main/clm_driver.F90 | 6 +- src/main/clm_initializeMod.F90 | 6 +- src/main/clm_varctl.F90 | 2 +- src/main/controlMod.F90 | 6 +- src/utils/clmfates_interfaceMod.F90 | 20 ++- 15 files changed, 125 insertions(+), 61 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 187927e3af..143dcf93bc 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -768,7 +768,7 @@ sub setup_cmdl_fates_mode { } } else { # dis-allow fates specific namelist items with non-fates runs - my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", + my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_cohort_age_tracking", "use_fates_inventory_init","use_fates_fixed_biogeog", "fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" ); foreach my $var ( @list ) { @@ -917,6 +917,7 @@ sub setup_cmdl_fire_light_res { if ( defined($fire_method) && $val ne "none" ) { if ( $fire_method eq "nofire" ) { $log->fatal_error("-$var option used with fire_method='nofire'. -$var can ONLY be used without the nofire option"); +<<<<<<< HEAD } } my $stream_fldfilename_lightng = remove_leading_and_trailing_quotes( $nl->get_value('stream_fldfilename_lightng') ); @@ -957,6 +958,91 @@ sub setup_cmdl_fire_light_res { $nl_flags->{$var} = ".false."; } if ( $nl_flags->{'use_fates_spitfire'} > 1 ) { +||||||| constructed merge base + } + } + my $stream_fldfilename_lightng = remove_leading_and_trailing_quotes( $nl->get_value('stream_fldfilename_lightng') ); + if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { + $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); + } + if ( ! &value_is_true($nl->get_value('use_cn')) ) { + $log->fatal_error("-$var option used CN is NOT on. -$var can only be used when CN is on (with bgc: cn or bgc)"); + } + if ( &value_is_true($nl->get_value('use_cn')) && $val eq "none" ) { + $log->fatal_error("-$var option is set to none, but CN is on (with bgc: cn or bgc) which is a contradiction"); + } + $nl_flags->{$var} = $val; + } + my $group = $definition->get_group_name($var); + $nl->set_variable_value($group, $var, quote_string($nl_flags->{$var}) ); + if ( ! $definition->is_valid_value( $var, $nl_flags->{$var}, 'noquotes'=>1 ) ) { + my @valid_values = $definition->get_valid_values( $var ); + $log->fatal_error("$var has a value (".$nl_flags->{$var}.") that is NOT valid. Valid values are: @valid_values"); + } + $log->verbose_message("Using $nl_flags->{$var} for $var."); + # + # Set flag if cn-fires are on or not + # + $var = "cnfireson"; + if ( $physv->as_long() >= $physv->as_long("clm4_5") && &value_is_true($nl->get_value('use_cn')) ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method'); + } + my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); + if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) { + $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc."); + } + if ( defined($fire_method) && $fire_method eq "nofire" ) { + $nl_flags->{$var} = ".false."; + } elsif ( &value_is_true($nl->get_value('use_cn')) ) { + $nl_flags->{$var} = ".true."; + } else { + $nl_flags->{$var} = ".false."; + } + if ( $nl_flags->{'use_fates_spitfire'} > 1 ) { +======= + } + } + my $stream_fldfilename_lightng = remove_leading_and_trailing_quotes( $nl->get_value('stream_fldfilename_lightng') ); + if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { + $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); + } + if ( ! &value_is_true($nl->get_value('use_cn')) ) { + $log->fatal_error("-$var option used CN is NOT on. -$var can only be used when CN is on (with bgc: cn or bgc)"); + } + if ( &value_is_true($nl->get_value('use_cn')) && $val eq "none" ) { + $log->fatal_error("-$var option is set to none, but CN is on (with bgc: cn or bgc) which is a contradiction"); + } + $nl_flags->{$var} = $val; + } + my $group = $definition->get_group_name($var); + $nl->set_variable_value($group, $var, quote_string($nl_flags->{$var}) ); + if ( ! $definition->is_valid_value( $var, $nl_flags->{$var}, 'noquotes'=>1 ) ) { + my @valid_values = $definition->get_valid_values( $var ); + $log->fatal_error("$var has a value (".$nl_flags->{$var}.") that is NOT valid. Valid values are: @valid_values"); + } + $log->verbose_message("Using $nl_flags->{$var} for $var."); + # + # Set flag if cn-fires are on or not + # + $var = "cnfireson"; + if ( $physv->as_long() >= $physv->as_long("clm4_5") && &value_is_true($nl->get_value('use_cn')) ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method'); + } + my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); + if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) { + $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc."); + } + if ( defined($fire_method) && $fire_method eq "nofire" ) { + $nl_flags->{$var} = ".false."; + } elsif ( &value_is_true($nl->get_value('use_cn')) ) { + $nl_flags->{$var} = ".true."; + } else { + $nl_flags->{$var} = ".false."; + } + # fates_spitfire_mode = 0 for no_fire, 1 for global const. value from + # fates_params, 2 for lightning dataset, 3 for successful_ignitions dataset + if ( $nl_flags->{'fates_spitfire_mode'} > 1 ) { +>>>>>>> Additional conflicts resolved; revisions in response to rgknox's review $nl_flags->{$var} = ".true."; } } @@ -3287,7 +3373,6 @@ sub setup_logic_lightning_streams { # lightning streams require CN/BGC my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; -<<<<<<< HEAD if ( &value_is_true($nl_flags->{'cnfireson'}) || &value_is_true($nl_flags->{'use_fates'}) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'}, @@ -3301,37 +3386,6 @@ sub setup_logic_lightning_streams { # Set align year, if first and last years are different if ( $nl->get_value('stream_year_first_lightng') != $nl->get_value('stream_year_last_lightng') ) { -||||||| constructed merge base - if ( $physv->as_long() >= $physv->as_long("clm4_5") ) { - if ( &value_is_true($nl_flags->{'cnfireson'}) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, - 'hgrid'=>$nl_flags->{'res'}, - 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'sim_year'=>$nl_flags->{'sim_year'}, - 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'sim_year'=>$nl_flags->{'sim_year'}, - 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - # Set align year, if first and last years are different - if ( $nl->get_value('stream_year_first_lightng') != - $nl->get_value('stream_year_last_lightng') ) { -======= - if ( $physv->as_long() >= $physv->as_long("clm4_5") ) { - if ( &value_is_true($nl_flags->{'cnfireson'}) || &value_is_true($nl_flags->{'use_fates'}) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, - 'hgrid'=>$nl_flags->{'res'}, - 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'sim_year'=>$nl_flags->{'sim_year'}, - 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'sim_year'=>$nl_flags->{'sim_year'}, - 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - # Set align year, if first and last years are different - if ( $nl->get_value('stream_year_first_lightng') != - $nl->get_value('stream_year_last_lightng') ) { ->>>>>>> Minor corrections for clm-fates to run with a lightning dataset add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_lightng', 'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); } @@ -3810,7 +3864,7 @@ sub setup_logic_fates { if (&value_is_true( $nl_flags->{'use_fates'}) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); - my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", + my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'} ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 4de23f46db..028ec58f1e 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2732,7 +2732,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 .false. -0 +0 .false. .false. .false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 5a4099c33c..69e6f492a3 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -635,9 +635,9 @@ Toggle to turn on the FATES model Switch deciding which nutrient model to use in FATES. - -Turn on spitfire module to simulate fire by setting use_fates_spitfire > 0. +Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0. Relevant only if use_fates = .true.. Values of 1, 2, and 3 correspond to no external inputs, external lightning data, and external confirmed ignition data, respectively. diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index faac947342..88229d8cb4 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -823,7 +823,7 @@ sub make_config_cache { phys=>"clm5_0", }, "usespitfireButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"use_fates_spitfire=.true.", + namelst=>"fates_spitfire_mode>1", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index a2facdeaa6..90a188bdb1 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -2,7 +2,7 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. -use_fates_spitfire= 1 +fates_spitfire_mode = 1 hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN_ELEM','LITTER_OUT_ELEM', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm index 7c2969a275..4d488d3c33 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm @@ -2,7 +2,7 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .false. -use_fates_spitfire= 1 +fates_spitfire_mode = 1 hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE','GPP_BY_AGE','PARSUN_Z_CNLF','PARSHA_Z_CNLF','PARSUN_Z_CNLFPFT', 'PARSHA_Z_CNLFPFT','PARSUN_Z_CAN','PARSHA_Z_CAN','LAISUN_Z_CNLF','LAISHA_Z_CNLF','LAISUN_Z_CNLFPFT','LAISHA_Z_CNLFPFT', 'LAISUN_TOP_CAN','LAISHA_TOP_CAN','FABD_SUN_CNLFPFT','FABD_SHA_CNLFPFT','FABI_SUN_CNLFPFT','FABI_SHA_CNLFPFT', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm index 5aea3a43ca..c092059cea 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm @@ -1,7 +1,7 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. -use_fates_spitfire= 1 +fates_spitfire_mode = 1 hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','FIRE_FUEL_MEF', 'FIRE_FUEL_BULKD','FIRE_FUEL_SAV','FIRE_NESTEROV_INDEX','PFTbiomass', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm index 6cf2c7f70d..8fc4951e6a 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesNoFire/user_nl_clm @@ -1 +1 @@ -use_fates_spitfire= 0 +fates_spitfire_mode = 0 diff --git a/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm index 810eb19987..265f4c5406 100644 --- a/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/fatesFire/user_nl_clm @@ -1,2 +1,2 @@ -use_fates_spitfire = 1 +fates_spitfire_mode = 1 diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index b172c5b5ed..a28e0df482 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -132,7 +132,7 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) ! The particular type is determined based on a namelist parameter. ! ! !USES: - use clm_varctl, only: use_fates_spitfire + use clm_varctl, only: fates_spitfire_mode use CNFireMethodMod, only: cnfire_method_type use FATESFireBase, only: fates_fire_base_type use FATESFireNoDataMod, only: fates_fire_no_data_type @@ -146,7 +146,7 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) character(len=*), parameter :: subname = 'create_fates_fire_data_method' !----------------------------------------------------------------------- - current_case = use_fates_spitfire + current_case = fates_spitfire_mode select case (current_case) @@ -156,7 +156,7 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) allocate(fates_fire_data_type :: fates_fire_data_method) case default - write(iulog,*) subname//' ERROR: unknown method: ', use_fates_spitfire + write(iulog,*) subname//' ERROR: unknown method: ', fates_spitfire_mode call endrun(msg=errMsg(sourcefile, __LINE__)) end select diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index a1fba14146..0b3fe04d19 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -111,7 +111,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ! !USES: use clm_time_manager , only : get_curr_date - use clm_varctl , only : use_lai_streams, use_fates_spitfire + use clm_varctl , only : use_lai_streams, fates_spitfire_mode use SatellitePhenologyMod, only : lai_advance ! ! !ARGUMENTS: @@ -398,9 +398,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro end if call bgc_vegetation_inst%InterpFileInputs(bounds_proc) call t_stopf('bgc_interp') - ! use_fates_spitfire is assigned an integer value in the namelist + ! fates_spitfire_mode is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - else if (use_fates_spitfire > 1) then + else if (fates_spitfire_mode > 1) then call clm_fates%InterpFileInputs(bounds_proc) end if diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 53019100c5..9128ceb5ee 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -280,7 +280,7 @@ subroutine initialize2( ) use clm_varcon , only : spval use clm_varctl , only : finidat, finidat_interp_source, finidat_interp_dest, fsurdat use clm_varctl , only : use_century_decomp, single_column, scmlat, scmlon, use_cn, use_fates - use clm_varctl , only : use_crop, ndep_from_cpl, use_fates_spitfire + use clm_varctl , only : use_crop, ndep_from_cpl, fates_spitfire_mode use clm_varorb , only : eccen, mvelpp, lambm0, obliqr use clm_time_manager , only : get_step_size_real, get_curr_calday use clm_time_manager , only : get_curr_date, get_nstep, advance_timestep @@ -510,9 +510,9 @@ subroutine initialize2( ) else call SatellitePhenologyInit(bounds_proc) - ! use_fates_spitfire is assigned an integer value in the namelist + ! fates_spitfire_mode is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (use_fates_spitfire > 1) then + if (fates_spitfire_mode > 1) then call clm_fates%Init2(bounds_proc, NLFilename) end if end if diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index e67ed0d6f4..6f0a45790f 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -224,7 +224,7 @@ module clm_varctl integer, public :: fates_parteh_mode = -9 ! 1 => carbon only ! 2 => C+N+P (not enabled yet) ! no others enabled - integer, public :: use_fates_spitfire = 0 ! > 1 => use spitfire model + integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: 1 with global const. lightning, 2 with lightning dataset, 3 with successful ignition dataset logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index c912fde132..db233c4bd0 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -221,7 +221,7 @@ subroutine control_init( ) ! FATES Flags namelist /clm_inparm/ fates_paramfile, use_fates, & - use_fates_spitfire, use_fates_logging, & + fates_spitfire_mode, use_fates_logging, & use_fates_planthydro, use_fates_ed_st3, & use_fates_cohort_age_tracking, & use_fates_ed_prescribed_phys, & @@ -713,7 +713,7 @@ subroutine control_spmd() call mpi_bcast (use_fates, 1, MPI_LOGICAL, 0, mpicom, ier) - call mpi_bcast (use_fates_spitfire, 1, MPI_INTEGER, 0, mpicom, ier) + call mpi_bcast (fates_spitfire_mode, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (use_fates_logging, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) @@ -1064,7 +1064,7 @@ subroutine control_print () write(iulog, *) ' ED/FATES: ' write(iulog, *) ' use_fates = ', use_fates if (use_fates) then - write(iulog, *) ' use_fates_spitfire = ', use_fates_spitfire + write(iulog, *) ' fates_spitfire_mode = ', fates_spitfire_mode write(iulog, *) ' use_fates_logging = ', use_fates_logging write(iulog, *) ' fates_paramfile = ', fates_paramfile write(iulog, *) ' fates_parteh_mode = ', fates_parteh_mode diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index f50949cdb0..4c618b323c 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -50,7 +50,7 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_vertsoilc use clm_varctl , only : fates_parteh_mode use clm_varctl , only : use_fates - use clm_varctl , only : use_fates_spitfire + use clm_varctl , only : fates_spitfire_mode use clm_varctl , only : use_fates_planthydro use clm_varctl , only : use_fates_cohort_age_tracking use clm_varctl , only : use_fates_ed_st3 @@ -270,6 +270,8 @@ subroutine CLMFatesGlobals() call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode) + call set_fates_ctrlparms('spitfire_mode',ival=fates_spitfire_mode) + if(is_restart()) then pass_is_restart = 1 else @@ -704,7 +706,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & model_day, floor(day_of_year), & days_per_year, 1.0_r8/dble(days_per_year)) - if (use_fates_spitfire > 1) then + if (fates_spitfire_mode > 1) then allocate(lnfm24(bounds_clump%begg:bounds_clump%endg), stat=ier) if (ier /= 0) then call endrun(msg="allocation error for lnfm24"//& @@ -717,11 +719,19 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) - if (use_fates_spitfire > 1) then + if (fates_spitfire_mode > 1) then g = col%gridcell(c) - this%fates(nc)%bc_in(s)%lightning24 = lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + p = ifp + col%patchi(c) + + this%fates(nc)%bc_in(s)%lightning24(ifp) = lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day + end do else - this%fates(nc)%bc_in(s)%lightning24 = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + p = ifp + col%patchi(c) + + this%fates(nc)%bc_in(s)%lightning24(ifp) = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day + end do end if nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil From 7da5ec9beb2e53383eb1b5c92ce101c379441605 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sun, 7 Jun 2020 16:10:16 -0600 Subject: [PATCH 070/152] Added new FATES test that exercises the lightning dataset code New test name: ERS_D_Lm12.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-FatesSuccIgnitions I opted for a longer single-point test to allow several months of lightning or ignition data to be read in. NB. This test has uncovered a preexisting problem that I have documented in ExpectedTestFails.xml and which was missed before due to the short lengths of previous FATES tests. --- cime_config/testdefs/ExpectedTestFails.xml | 21 +++++++++++++++++++ cime_config/testdefs/testlist_clm.xml | 8 +++++++ .../clm/FatesSuccIgnitions/README | 21 +++++++++++++++++++ .../clm/FatesSuccIgnitions/user_nl_clm | 5 +++++ 4 files changed, 55 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 4b9b0ca8b0..dd63a1fcd6 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -130,4 +130,25 @@ + + + FAIL + #667 + + + + + + FAIL + #667 + + + + + + FAIL + NGEET/fates#991 + + + diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index c59b5a985f..a6052f3a31 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1953,6 +1953,14 @@ + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README b/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README new file mode 100644 index 0000000000..4046d99f9d --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README @@ -0,0 +1,21 @@ +Testing the "successful ignitions" code, though reading the lightning +dataset. The lightning and successful ignitions datasets use the same +format and units, so handling is the same until you're in subroutine +area_burnt_intensity where for "successful ignitions" the model selects +currentSite%FDI = 1.0_r8 +cloud_to_ground_strikes = 1.0_r8 +while for lightning the model can use values < 1 for both. + +Lara Kueppers (UC-Berkeley) has access to a "successful ignitions" +dataset for California that has not been placed in the repository of +CTSM datasets as of 2020/6/6. That dataset can be used with the +following settings: + +fire_method = 'spitfire' +fates_spitfire_mode = 3 +stream_fldfilename_lightng = '.../data_UCB/observed/CA_monthly_ignition_number_1980-2016/ignition_1980_to_2016_monthly_20190801.nc' +stream_year_first_lightng = 1980 +stream_year_last_lightng = 2016 +model_year_align_lightng = 1980 + +where {...} = /fs/cgd/data0/slevis on izumi and /glade/work/slevis on cheyenne. diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm new file mode 100644 index 0000000000..f15114e4e1 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm @@ -0,0 +1,5 @@ +fire_method = 'spitfire' +fates_spitfire_mode = 3 +stream_fldfilename_lightng = '/glade/p/cesmdata/cseg/inputdata/atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc' +hist_nhtfrq = 0 +hist_mfilt = 1 From 10915c04ea332bf5f750bbf291b271e1af9c7bae Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 8 Jun 2020 15:54:04 -0600 Subject: [PATCH 071/152] Minor corrections from self-reviewing the PR --- bld/CLMBuildNamelist.pm | 2 +- bld/unit_testers/build-namelist_test.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 143dcf93bc..52873a3589 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1030,7 +1030,7 @@ sub setup_cmdl_fire_light_res { } my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) { - $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc."); + $log->fatal_error("fire_method is being set while use_cn and use_fates are both false."); } if ( defined($fire_method) && $fire_method eq "nofire" ) { $nl_flags->{$var} = ".false."; diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 88229d8cb4..13592ee93c 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -823,7 +823,7 @@ sub make_config_cache { phys=>"clm5_0", }, "usespitfireButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"fates_spitfire_mode>1", + namelst=>"fates_spitfire_mode>0", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, From 2d4d64f40c4c1ac43721683b6f7ad33c1999aa82 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 8 Jun 2020 16:35:01 -0600 Subject: [PATCH 072/152] Reassigned expected test fail to issue #667 --- cime_config/testdefs/ExpectedTestFails.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index dd63a1fcd6..522eb1004b 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -147,7 +147,7 @@ FAIL - NGEET/fates#991 + #667 From 4d276cc07070e8507f2ccbba6f28020cc4cf79dc Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sat, 11 Jul 2020 16:07:49 -0600 Subject: [PATCH 073/152] Updates needed for anthropogenic ignitions in FATES-SPITFIRE Previous commits in this PR made CN's code for reading lightning and population density available to FATES. Here I add the population density to the CTSM-FATES interface so as to calculate anthropogenic fire ignitions in FATES. --- bld/CLMBuildNamelist.pm | 118 +++--------------- bld/namelist_files/namelist_defaults_ctsm.xml | 46 +++++++ .../namelist_definition_ctsm.xml | 11 +- cime_config/testdefs/testlist_clm.xml | 2 +- .../clm/FatesSuccIgnitions/user_nl_clm | 5 - .../README | 14 ++- .../user_nl_clm | 4 + src/biogeochem/CNFireBaseMod.F90 | 12 +- src/utils/clmfates_interfaceMod.F90 | 8 +- 9 files changed, 90 insertions(+), 130 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm rename cime_config/testdefs/testmods_dirs/clm/{FatesSuccIgnitions => Fates_nat_and_anthro_ignitions}/README (58%) create mode 100644 cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 52873a3589..04cd426e68 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -917,89 +917,6 @@ sub setup_cmdl_fire_light_res { if ( defined($fire_method) && $val ne "none" ) { if ( $fire_method eq "nofire" ) { $log->fatal_error("-$var option used with fire_method='nofire'. -$var can ONLY be used without the nofire option"); -<<<<<<< HEAD - } - } - my $stream_fldfilename_lightng = remove_leading_and_trailing_quotes( $nl->get_value('stream_fldfilename_lightng') ); - if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { - $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); - } - if ( ! &value_is_true($nl->get_value('use_cn')) ) { - $log->fatal_error("-$var option used CN is NOT on. -$var can only be used when CN is on (with bgc: cn or bgc)"); - } - if ( &value_is_true($nl->get_value('use_cn')) && $val eq "none" ) { - $log->fatal_error("-$var option is set to none, but CN is on (with bgc: cn or bgc) which is a contradiction"); - } - $nl_flags->{$var} = $val; - } - my $group = $definition->get_group_name($var); - $nl->set_variable_value($group, $var, quote_string($nl_flags->{$var}) ); - if ( ! $definition->is_valid_value( $var, $nl_flags->{$var}, 'noquotes'=>1 ) ) { - my @valid_values = $definition->get_valid_values( $var ); - $log->fatal_error("$var has a value (".$nl_flags->{$var}.") that is NOT valid. Valid values are: @valid_values"); - } - $log->verbose_message("Using $nl_flags->{$var} for $var."); - # - # Set flag if cn-fires are on or not - # - $var = "cnfireson"; - if ( &value_is_true($nl->get_value('use_cn')) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method'); - } - my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); - if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) { - $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc."); - } - if ( defined($fire_method) && $fire_method eq "nofire" ) { - $nl_flags->{$var} = ".false."; - } elsif ( &value_is_true($nl->get_value('use_cn')) ) { - $nl_flags->{$var} = ".true."; - } else { - $nl_flags->{$var} = ".false."; - } - if ( $nl_flags->{'use_fates_spitfire'} > 1 ) { -||||||| constructed merge base - } - } - my $stream_fldfilename_lightng = remove_leading_and_trailing_quotes( $nl->get_value('stream_fldfilename_lightng') ); - if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { - $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); - } - if ( ! &value_is_true($nl->get_value('use_cn')) ) { - $log->fatal_error("-$var option used CN is NOT on. -$var can only be used when CN is on (with bgc: cn or bgc)"); - } - if ( &value_is_true($nl->get_value('use_cn')) && $val eq "none" ) { - $log->fatal_error("-$var option is set to none, but CN is on (with bgc: cn or bgc) which is a contradiction"); - } - $nl_flags->{$var} = $val; - } - my $group = $definition->get_group_name($var); - $nl->set_variable_value($group, $var, quote_string($nl_flags->{$var}) ); - if ( ! $definition->is_valid_value( $var, $nl_flags->{$var}, 'noquotes'=>1 ) ) { - my @valid_values = $definition->get_valid_values( $var ); - $log->fatal_error("$var has a value (".$nl_flags->{$var}.") that is NOT valid. Valid values are: @valid_values"); - } - $log->verbose_message("Using $nl_flags->{$var} for $var."); - # - # Set flag if cn-fires are on or not - # - $var = "cnfireson"; - if ( $physv->as_long() >= $physv->as_long("clm4_5") && &value_is_true($nl->get_value('use_cn')) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method'); - } - my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); - if ( defined($fire_method) && ! &value_is_true($nl_flags->{'use_cn'}) && ! &value_is_true($nl_flags->{'use_fates'}) ) { - $log->fatal_error("fire_method is being set even though bgc is NOT cn or bgc."); - } - if ( defined($fire_method) && $fire_method eq "nofire" ) { - $nl_flags->{$var} = ".false."; - } elsif ( &value_is_true($nl->get_value('use_cn')) ) { - $nl_flags->{$var} = ".true."; - } else { - $nl_flags->{$var} = ".false."; - } - if ( $nl_flags->{'use_fates_spitfire'} > 1 ) { -======= } } my $stream_fldfilename_lightng = remove_leading_and_trailing_quotes( $nl->get_value('stream_fldfilename_lightng') ); @@ -1025,7 +942,7 @@ sub setup_cmdl_fire_light_res { # Set flag if cn-fires are on or not # $var = "cnfireson"; - if ( $physv->as_long() >= $physv->as_long("clm4_5") && &value_is_true($nl->get_value('use_cn')) ) { + if ( &value_is_true($nl->get_value('use_cn')) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_method'); } my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); @@ -1039,10 +956,11 @@ sub setup_cmdl_fire_light_res { } else { $nl_flags->{$var} = ".false."; } - # fates_spitfire_mode = 0 for no_fire, 1 for global const. value from - # fates_params, 2 for lightning dataset, 3 for successful_ignitions dataset + # fates_spitfire_mode = 0 for no_fire + # fates_spitfire_mode = 1 for global const. lightning from fates_params + # fates_spitfire_mode > 1 for ignitions from datasets as explained + # in namelist_definition_clm4_5.xml if ( $nl_flags->{'fates_spitfire_mode'} > 1 ) { ->>>>>>> Additional conflicts resolved; revisions in response to rgknox's review $nl_flags->{$var} = ".true."; } } @@ -3373,19 +3291,19 @@ sub setup_logic_lightning_streams { # lightning streams require CN/BGC my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; - if ( &value_is_true($nl_flags->{'cnfireson'}) || &value_is_true($nl_flags->{'use_fates'}) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, - 'hgrid'=>$nl_flags->{'res'}, - 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'sim_year'=>$nl_flags->{'sim_year'}, - 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'sim_year'=>$nl_flags->{'sim_year'}, - 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - # Set align year, if first and last years are different - if ( $nl->get_value('stream_year_first_lightng') != - $nl->get_value('stream_year_last_lightng') ) { + if ( &value_is_true($nl_flags->{'cnfireson'}) ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, + 'hgrid'=>$nl_flags->{'res'}, + 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + 'sim_year'=>$nl_flags->{'sim_year'}, + 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + 'sim_year'=>$nl_flags->{'sim_year'}, + 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + # Set align year, if first and last years are different + if ( $nl->get_value('stream_year_first_lightng') != + $nl->get_value('stream_year_last_lightng') ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_lightng', 'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 028ec58f1e..aa587a33c4 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1223,6 +1223,24 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 2000 2000 +2010 +2010 + +2000 +2000 + +1850 +1850 + +2000 +2000 + +2000 +2000 + +2000 +2000 + lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202.nc lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc @@ -1241,6 +1259,24 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc +lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202.nc +lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP3_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP4_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP4_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + +lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc + + bilinear nn @@ -1251,6 +1287,16 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 nn nn +bilinear + +nn +nn +nn +nn +nn +nn +nn + 2015 2106 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 69e6f492a3..890c8bbc2e 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -636,11 +636,14 @@ Switch deciding which nutrient model to use in FATES. + group="clm_inparm" valid_values="0,1,2,3,4" value=".false."> Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0. -Relevant only if use_fates = .true.. Values of 1, 2, and 3 correspond to -no external inputs, external lightning data, and external confirmed ignition -data, respectively. +Relevant only if use_fates = .true.. Set to 1 for no external ignition +inputs and use of a global constant lightning rate found in fates_params. +Set to 2 to use an external lightning dataset. Set to 3 to use an +external confirmed ignitions dataset. Set to 4 to use external lightning +and population datasets so as to simulate both natural and anthropogenic +ignitions. 00:40:00 - + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm deleted file mode 100644 index f15114e4e1..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/user_nl_clm +++ /dev/null @@ -1,5 +0,0 @@ -fire_method = 'spitfire' -fates_spitfire_mode = 3 -stream_fldfilename_lightng = '/glade/p/cesmdata/cseg/inputdata/atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc' -hist_nhtfrq = 0 -hist_mfilt = 1 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README similarity index 58% rename from cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README rename to cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README index 4046d99f9d..0e78f61023 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesSuccIgnitions/README +++ b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README @@ -1,7 +1,12 @@ -Testing the "successful ignitions" code, though reading the lightning -dataset. The lightning and successful ignitions datasets use the same -format and units, so handling is the same until you're in subroutine -area_burnt_intensity where for "successful ignitions" the model selects +Testing capability to read/use lightning frequency & population density +datasets. Calculates natural ignitions from lightning using the SPITFIRE +formulation and anthropogenic ignitions using the Li et al. formulation +copied from CTSM-CN's fire model. + +Testing does not include a separate test for reading/using a successful +ignitions dataset which uses the same format and units so handling +is the same until you're in subroutine area_burnt_intensity where for +"successful ignitions" the model selects currentSite%FDI = 1.0_r8 cloud_to_ground_strikes = 1.0_r8 while for lightning the model can use values < 1 for both. @@ -19,3 +24,4 @@ stream_year_last_lightng = 2016 model_year_align_lightng = 1980 where {...} = /fs/cgd/data0/slevis on izumi and /glade/work/slevis on cheyenne. + diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm new file mode 100644 index 0000000000..77d3a7179f --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm @@ -0,0 +1,4 @@ +fire_method = 'spitfire' +fates_spitfire_mode = 4 +hist_nhtfrq = 0 +hist_mfilt = 1 diff --git a/src/biogeochem/CNFireBaseMod.F90 b/src/biogeochem/CNFireBaseMod.F90 index 52fdd35fb0..cf1ed9752d 100644 --- a/src/biogeochem/CNFireBaseMod.F90 +++ b/src/biogeochem/CNFireBaseMod.F90 @@ -116,7 +116,6 @@ subroutine CNFireInit( this, bounds, NLFilename ) ! Initialize CN Fire module ! !USES: use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=) - use clm_varctl , only : use_cn ! ! !ARGUMENTS: class(cnfire_base_type) :: this @@ -132,10 +131,8 @@ subroutine CNFireInit( this, bounds, NLFilename ) allocate( this%forc_hdm(bounds%begg:bounds%endg) ) this%forc_hdm(bounds%begg:) = nan - if (use_cn) then - call this%hdm_init(bounds, NLFilename) - call this%hdm_interp(bounds) - end if + call this%hdm_init(bounds, NLFilename) + call this%hdm_interp(bounds) call this%lnfm_init(bounds, NLFilename) call this%lnfm_interp(bounds) @@ -255,7 +252,6 @@ subroutine CNFireInterp(this,bounds) ! Interpolate CN Fire datasets ! ! !USES: - use clm_varctl, only: use_cn ! ! !ARGUMENTS: class(cnfire_base_type) :: this @@ -263,9 +259,7 @@ subroutine CNFireInterp(this,bounds) !----------------------------------------------------------------------- if ( this%need_lightning_and_popdens ) then - if (use_cn) then - call this%hdm_interp(bounds) - end if + call this%hdm_interp(bounds) call this%lnfm_interp(bounds) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 4c618b323c..5e81204f6d 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -636,7 +636,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! to process array bounding information ! !USES - use EDParamsMod, only: ED_val_nignitions implicit none class(hlm_fates_interface_type), intent(inout) :: this @@ -725,12 +724,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & p = ifp + col%patchi(c) this%fates(nc)%bc_in(s)%lightning24(ifp) = lnfm24(g) * 24._r8 ! #/km2/hr to #/km2/day - end do - else - do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno - p = ifp + col%patchi(c) - - this%fates(nc)%bc_in(s)%lightning24(ifp) = ED_val_nignitions / days_per_year ! #/km2/yr to #/km2/day + this%fates(nc)%bc_in(s)%pop_density(ifp) = this%fates_fire_data_method%forc_hdm(g) end do end if From 8844da9c6f23f35c7adcc78ae163cc8ea76f2d91 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sat, 11 Jul 2020 16:59:51 -0600 Subject: [PATCH 074/152] Minor clean-up Good stopping point: Next I will be testing the population density capability. --- cime_config/testdefs/ExpectedTestFails.xml | 2 +- src/biogeochem/CNFireBaseMod.F90 | 3 --- src/main/clm_varctl.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 6 ++---- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 522eb1004b..5c36197ffa 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -144,7 +144,7 @@ - + FAIL #667 diff --git a/src/biogeochem/CNFireBaseMod.F90 b/src/biogeochem/CNFireBaseMod.F90 index cf1ed9752d..91a60d5f0c 100644 --- a/src/biogeochem/CNFireBaseMod.F90 +++ b/src/biogeochem/CNFireBaseMod.F90 @@ -133,7 +133,6 @@ subroutine CNFireInit( this, bounds, NLFilename ) call this%hdm_init(bounds, NLFilename) call this%hdm_interp(bounds) - call this%lnfm_init(bounds, NLFilename) call this%lnfm_interp(bounds) end if @@ -251,8 +250,6 @@ subroutine CNFireInterp(this,bounds) ! !DESCRIPTION: ! Interpolate CN Fire datasets ! - ! !USES: - ! ! !ARGUMENTS: class(cnfire_base_type) :: this type(bounds_type), intent(in) :: bounds diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 6f0a45790f..cfc7bec1e3 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -224,7 +224,7 @@ module clm_varctl integer, public :: fates_parteh_mode = -9 ! 1 => carbon only ! 2 => C+N+P (not enabled yet) ! no others enabled - integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: 1 with global const. lightning, 2 with lightning dataset, 3 with successful ignition dataset + integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 5e81204f6d..aa82501992 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -396,8 +396,8 @@ subroutine init(this, bounds_proc ) use FatesInterfaceTypesMod, only : numpft_fates => numpft use FatesParameterDerivedMod, only : param_derived use subgridMod, only : natveg_patch_exists - use clm_instur , only : wt_nat_patch - use CNFireFactoryMod, only: create_fates_fire_data_method + use clm_instur , only : wt_nat_patch + use CNFireFactoryMod , only: create_fates_fire_data_method implicit none @@ -635,8 +635,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! ed_driver is not a hlm_fates_inst_type procedure because we need an extra step ! to process array bounding information - ! !USES - implicit none class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type),intent(in) :: bounds_clump From e19350a011db82241e6d52dfcadd45f61b30fd99 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sun, 12 Jul 2020 13:49:43 -0600 Subject: [PATCH 075/152] Small corrections to get test simulation to run Testing with ./create_test ERS_D_Lm36.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-Fates_nat_and_anthro_ignitions --- bld/CLMBuildNamelist.pm | 9 ++------- src/biogeochem/CNFireFactoryMod.F90 | 9 +++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 04cd426e68..0a5636e8c2 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -951,17 +951,12 @@ sub setup_cmdl_fire_light_res { } if ( defined($fire_method) && $fire_method eq "nofire" ) { $nl_flags->{$var} = ".false."; - } elsif ( &value_is_true($nl->get_value('use_cn')) ) { +# } elsif ( &value_is_true($nl->get_value('use_cn')) || $nl_flags->{'fates_spitfire_mode'} > 1 ) { + } elsif ( &value_is_true($nl->get_value('use_cn')) || &value_is_true($nl->get_value('use_fates')) ) { $nl_flags->{$var} = ".true."; } else { $nl_flags->{$var} = ".false."; } - # fates_spitfire_mode = 0 for no_fire - # fates_spitfire_mode = 1 for global const. lightning from fates_params - # fates_spitfire_mode > 1 for ignitions from datasets as explained - # in namelist_definition_clm4_5.xml - if ( $nl_flags->{'fates_spitfire_mode'} > 1 ) { - $nl_flags->{$var} = ".true."; } } diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index a28e0df482..e0b00cb87e 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -143,6 +143,11 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) ! ! !LOCAL VARIABLES: integer :: current_case + integer, parameter :: no_fire = 0 ! value of no_fire mode + integer, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode + integer, parameter :: lightning_data = 2 ! value of lightning_data mode + integer, parameter :: anthro_ignitions = 4 ! value of anthro_ignitions mode + character(len=*), parameter :: subname = 'create_fates_fire_data_method' !----------------------------------------------------------------------- @@ -150,9 +155,9 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) select case (current_case) - case (0:1) + case (no_fire:scalar_lightning) allocate(fates_fire_no_data_type :: fates_fire_data_method) - case (2:3) + case (lightning_data:anthro_ignitions) allocate(fates_fire_data_type :: fates_fire_data_method) case default From bc7a09531cd03387c8de11001bac37ed778ce0af Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sun, 12 Jul 2020 14:20:42 -0600 Subject: [PATCH 076/152] Added some comments to the code --- src/biogeochem/CNFireFactoryMod.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index e0b00cb87e..af950b36bc 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -143,6 +143,8 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) ! ! !LOCAL VARIABLES: integer :: current_case + ! The following parameters set the ranges of the cases below. + ! NB. The same parameters are set in /fates/fire/SFMainMod integer, parameter :: no_fire = 0 ! value of no_fire mode integer, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode integer, parameter :: lightning_data = 2 ! value of lightning_data mode From 5acd34c079ff6f64e49dce9ce220b890aec4a087 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sun, 12 Jul 2020 17:23:13 -0600 Subject: [PATCH 077/152] Changed walltime on new test to avoid timeout --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 3836948e37..d5be518d67 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1958,7 +1958,7 @@ - + From 06dc679e13d001584228dd2b902f2765d9c20c11 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 14 Jul 2020 14:40:49 -0700 Subject: [PATCH 078/152] Update bld/namelist_files/namelist_definition_clm4_5.xml Clearer documentation suggested by @jkshuman. Co-authored-by: jkshuman --- bld/namelist_files/namelist_definition_ctsm.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 890c8bbc2e..77594f7c7a 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -638,11 +638,12 @@ Switch deciding which nutrient model to use in FATES. Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0. -Relevant only if use_fates = .true.. Set to 1 for no external ignition -inputs and use of a global constant lightning rate found in fates_params. -Set to 2 to use an external lightning dataset. Set to 3 to use an -external confirmed ignitions dataset. Set to 4 to use external lightning -and population datasets so as to simulate both natural and anthropogenic +Relevant only if use_fates = .true. +Allowed values are: + 1 : use a global constant lightning rate found in fates_params. + 2 : use an external lightning dataset. + 3 : use an external confirmed ignitions dataset. + 4 : use external lightning and population datasets to simulate both natural and anthropogenic ignitions. From e28c57dd2145d3f11c742dc784cece59c1cc7f67 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 14 Jul 2020 14:42:08 -0700 Subject: [PATCH 079/152] Update cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README Clearer documentation suggestion by @jkshuman. Co-authored-by: jkshuman --- .../clm/Fates_nat_and_anthro_ignitions/README | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README index 0e78f61023..3bd8c7dd62 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README +++ b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/README @@ -1,7 +1,7 @@ Testing capability to read/use lightning frequency & population density -datasets. Calculates natural ignitions from lightning using the SPITFIRE -formulation and anthropogenic ignitions using the Li et al. formulation -copied from CTSM-CN's fire model. +datasets. Calculates lightning ignitions using the SPITFIRE +formulation and anthropogenic ignitions using the Li et al. 2012 formulation +based on human population density implemented in CTSM-CN's fire model. Testing does not include a separate test for reading/using a successful ignitions dataset which uses the same format and units so handling @@ -24,4 +24,3 @@ stream_year_last_lightng = 2016 model_year_align_lightng = 1980 where {...} = /fs/cgd/data0/slevis on izumi and /glade/work/slevis on cheyenne. - From 9b61c0897b9cb0124ee449363200b4c4b57a3110 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 14 Jul 2020 15:39:34 -0700 Subject: [PATCH 080/152] Update src/main/clm_varctl.F90 Clearer comment. Co-authored-by: jkshuman --- src/main/clm_varctl.F90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index cfc7bec1e3..3be001115c 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -224,7 +224,9 @@ module clm_varctl integer, public :: fates_parteh_mode = -9 ! 1 => carbon only ! 2 => C+N+P (not enabled yet) ! no others enabled - integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details + integer, public :: fates_spitfire_mode = 0 + ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details + ! ignitions: 1=constant, >1=external data sources logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking From e20879d06a9e69cefe2160f0bc8ea076a154226f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 14 Jul 2020 17:47:48 -0700 Subject: [PATCH 081/152] Update src/main/clm_varctl.F90 Comment clarification. Co-authored-by: jkshuman --- src/main/clm_varctl.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 3be001115c..d57e85c830 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -226,7 +226,7 @@ module clm_varctl ! no others enabled integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details - ! ignitions: 1=constant, >1=external data sources + ! ignitions: 1=constant, >1=external data sources (lightning and/or anthropogenic) logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking From 79d3c2a11ec6ce150642eb45aefe46dbd3f57487 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sat, 18 Jul 2020 11:24:10 -0600 Subject: [PATCH 082/152] Made spitfire_mode flags public for use throughout CTSM-FATES --- src/biogeochem/CNFireFactoryMod.F90 | 19 ++++++++++++------- src/main/clm_driver.F90 | 3 ++- src/main/clm_initializeMod.F90 | 3 ++- src/main/clm_varctl.F90 | 4 ++-- src/utils/clmfates_interfaceMod.F90 | 8 ++++++-- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index af950b36bc..7b3914534d 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -19,6 +19,17 @@ module CNFireFactoryMod public :: create_cnfire_method ! create an object of class cnfire_method_type public :: create_fates_fire_data_method ! create an object of class cnfire_method_type + ! These parameters set the ranges of the cases in subroutine + ! create_fates_fire_data_method. We declare them public in order to + ! use them as flags elsewhere in the CTSM and FATES-SPITFIRE. + ! They correspond one-to-one to the fates_spitfire_mode options listed + ! in bld/namelist_files/namelist_definition_clm4_5.xml + integer, public, parameter :: no_fire = 0 ! value of no_fire mode + integer, public, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode + integer, public, parameter :: lightning_from_data = 2 ! value of lightning_from_data mode + integer, public, parameter :: successful_ignitions = 3 ! value of successful_ignitions mode + integer, public, parameter :: anthro_ignitions = 4 ! value of anthro_ignitions mode + ! !PRIVATE DATA MEMBERS: character(len=80), private :: fire_method = "li2014qianfrc" @@ -143,12 +154,6 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) ! ! !LOCAL VARIABLES: integer :: current_case - ! The following parameters set the ranges of the cases below. - ! NB. The same parameters are set in /fates/fire/SFMainMod - integer, parameter :: no_fire = 0 ! value of no_fire mode - integer, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode - integer, parameter :: lightning_data = 2 ! value of lightning_data mode - integer, parameter :: anthro_ignitions = 4 ! value of anthro_ignitions mode character(len=*), parameter :: subname = 'create_fates_fire_data_method' !----------------------------------------------------------------------- @@ -159,7 +164,7 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) case (no_fire:scalar_lightning) allocate(fates_fire_no_data_type :: fates_fire_data_method) - case (lightning_data:anthro_ignitions) + case (lightning_from_data:anthro_ignitions) allocate(fates_fire_data_type :: fates_fire_data_method) case default diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 0b3fe04d19..5f40ce39db 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -113,6 +113,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro use clm_time_manager , only : get_curr_date use clm_varctl , only : use_lai_streams, fates_spitfire_mode use SatellitePhenologyMod, only : lai_advance + use CNFireFactoryMod , only : scalar_lightning ! ! !ARGUMENTS: implicit none @@ -400,7 +401,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call t_stopf('bgc_interp') ! fates_spitfire_mode is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - else if (fates_spitfire_mode > 1) then + else if (fates_spitfire_mode > scalar_lightning) then call clm_fates%InterpFileInputs(bounds_proc) end if diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 9128ceb5ee..e946aa6cd8 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -305,6 +305,7 @@ subroutine initialize2( ) use controlMod , only : NLFilename use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit + use CNFireFactoryMod , only : scalar_lightning ! ! !ARGUMENTS ! @@ -512,7 +513,7 @@ subroutine initialize2( ) ! fates_spitfire_mode is assigned an integer value in the namelist ! see bld/namelist_files/namelist_definition_clm4_5.xml for details - if (fates_spitfire_mode > 1) then + if (fates_spitfire_mode > scalar_lightning) then call clm_fates%Init2(bounds_proc, NLFilename) end if end if diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index d57e85c830..ceb3b6ab01 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -225,8 +225,8 @@ module clm_varctl ! 2 => C+N+P (not enabled yet) ! no others enabled integer, public :: fates_spitfire_mode = 0 - ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details - ! ignitions: 1=constant, >1=external data sources (lightning and/or anthropogenic) + ! 0 for no fire; 1 for constant ignitions; > 1 for external data (lightning and/or anthropogenic ignitions) + ! see bld/namelist_files/namelist_definition_clm4_5.xml for details logical, public :: use_fates_logging = .false. ! true => turn on logging module logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index aa82501992..132c4a29a4 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -635,6 +635,10 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! ed_driver is not a hlm_fates_inst_type procedure because we need an extra step ! to process array bounding information + ! !USES + use CNFireFactoryMod, only: scalar_lightning + + ! !ARGUMENTS: implicit none class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type),intent(in) :: bounds_clump @@ -703,7 +707,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & model_day, floor(day_of_year), & days_per_year, 1.0_r8/dble(days_per_year)) - if (fates_spitfire_mode > 1) then + if (fates_spitfire_mode > scalar_lightning) then allocate(lnfm24(bounds_clump%begg:bounds_clump%endg), stat=ier) if (ier /= 0) then call endrun(msg="allocation error for lnfm24"//& @@ -716,7 +720,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) - if (fates_spitfire_mode > 1) then + if (fates_spitfire_mode > scalar_lightning) then g = col%gridcell(c) do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno p = ifp + col%patchi(c) From f5821fc48856a5b8d2b6038e10d767e86231d006 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 22 Jul 2020 16:21:17 -0700 Subject: [PATCH 083/152] updating externals_clm configuration --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 331c344e5a..20c468015e 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -1,8 +1,8 @@ [fates] local_path = src/fates protocol = git -repo_url = https://github.com/slevisconsulting/fates -branch = lightning_v2_fates +repo_url = https://github.com/NGEET/fates +tag = sci.1.39.0_api.12.0.0 required = True [PTCLM] From c384c8eb1e411f68f301a23f08f62452d17f4191 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 29 Jul 2020 13:25:06 -0400 Subject: [PATCH 084/152] fates-interface: added fixes to lightning interface --- src/utils/clmfates_interfaceMod.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 132c4a29a4..2d23472fd7 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -138,6 +138,8 @@ module CLMFatesInterfaceMod use FatesPlantHydraulicsMod, only : InitHydrSites use FatesPlantHydraulicsMod, only : RestartHydrStates use FATESFireBase , only : fates_fire_base_type + use CNFireFactoryMod, only: no_fire, scalar_lightning, & + successful_ignitions, anthro_ignitions implicit none @@ -271,6 +273,10 @@ subroutine CLMFatesGlobals() call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode) call set_fates_ctrlparms('spitfire_mode',ival=fates_spitfire_mode) + call set_fates_ctrlparms('sf_nofire_def',ival=no_fire) + call set_fates_ctrlparms('sf_scalar_lightning_def',ival=scalar_lightning) + call set_fates_ctrlparms('sf_successful_ignitions_def',ival=successful_ignitions) + call set_fates_ctrlparms('sf_anthro_ignitions_def',ival=anthro_ignitions) if(is_restart()) then pass_is_restart = 1 From 184b8bee366f7eb87869b5c3d11b5f14453dd26b Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 6 May 2020 12:13:01 -0600 Subject: [PATCH 085/152] enabling in bld/CLMBuildNamelist.pm the possibility of running with FATES and transient land-use --- bld/CLMBuildNamelist.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 0a5636e8c2..b59946ebf8 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2205,9 +2205,6 @@ sub setup_logic_surface_dataset { if ($flanduse_timeseries ne "null" && &value_is_true($nl_flags->{'use_cndv'}) ) { $log->fatal_error( "dynamic PFT's (setting flanduse_timeseries) are incompatible with dynamic vegetation (use_cndv=.true)." ); } - if ($flanduse_timeseries ne "null" && &value_is_true($nl_flags->{'use_fates'}) ) { - $log->fatal_error( "dynamic PFT's (setting flanduse_timeseries) are incompatible with ecosystem dynamics (use_fates=.true)." ); - } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fsurdat', 'hgrid'=>$nl_flags->{'res'}, 'sim_year'=>$nl_flags->{'sim_year'}, 'irrigate'=>$nl_flags->{'irrigate'}, From 045c894e2ee1b3e5437882748c9f4eb119142730 Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 6 May 2020 13:36:05 -0600 Subject: [PATCH 086/152] adding harvest-type-resolved data structure and reading subroutine --- src/biogeochem/dynHarvestMod.F90 | 70 ++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/biogeochem/dynHarvestMod.F90 index e5dfffc56d..b7dce6a845 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/biogeochem/dynHarvestMod.F90 @@ -23,6 +23,7 @@ module dynHarvestMod use clm_varcon , only : grlnd use ColumnType , only : col use PatchType , only : patch + use clm_varctl , only : use_fates ! ! !PUBLIC MEMBER FUNCTIONS: implicit none @@ -50,6 +51,7 @@ module dynHarvestMod type(dyn_var_time_uninterp_type) :: harvest_inst(num_harvest_inst) ! value of each harvest variable real(r8) , allocatable :: harvest(:) ! harvest rates + real(r8) , allocatable :: harvest_typeresolved(:,:) ! harvest rates, resolved by harvest type logical :: do_harvest ! whether we're in a period when we should do harvest character(len=*), parameter :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set character(len=64) :: harvest_units = string_not_set ! units from harvest variables @@ -85,9 +87,16 @@ subroutine dynHarvest_init(bounds, harvest_filename) SHR_ASSERT(bounds%level == BOUNDS_LEVEL_PROC, subname // ': argument must be PROC-level bounds') - allocate(harvest(bounds%begg:bounds%endg),stat=ier) - if (ier /= 0) then - call endrun(msg=' allocation error for harvest'//errMsg(sourcefile, __LINE__)) + if ( .not. use_fates ) then + allocate(harvest(bounds%begg:bounds%endg),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for harvest'//errMsg(sourcefile, __LINE__)) + end if + else + allocate(harvest_typeresolved(bounds%begg:bounds%endg, num_harvest_inst),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for harvest_typeresolved'//errMsg(sourcefile, __LINE__)) + end if end if ! Get the year from the START of the timestep for consistency with other dyn file @@ -173,6 +182,61 @@ subroutine dynHarvest_interp(bounds) end subroutine dynHarvest_interp + !----------------------------------------------------------------------- + subroutine dynHarvest_interp_resolve_harvesttypes(bounds) + ! + ! !DESCRIPTION: + ! Get harvest data for model time, when needed. + ! + ! Note that harvest data are stored as rates (not weights) and so time interpolation + ! is not necessary - the harvest rate is held constant through the year. This is + ! consistent with the treatment of changing PFT weights, where interpolation of the + ! annual endpoint weights leads to a constant rate of change in PFT weight through the + ! year, with abrupt changes in the rate at annual boundaries. + ! + ! Note the difference between this and dynHarvest_interp is that here, we keep the different + ! forcing sets distinct (e.g., for passing to FATES which has distinct primary and secondary lands) + ! and thus store it in harvest_typeresolved + ! + ! !USES: + use dynTimeInfoMod , only : time_info_type + ! + ! !ARGUMENTS: + type(bounds_type), intent(in) :: bounds ! proc-level bounds + ! + ! !LOCAL VARIABLES: + integer :: varnum ! counter for harvest variables + real(r8), allocatable :: this_data(:) ! data for a single harvest variable + + character(len=*), parameter :: subname = 'dynHarvest_interp' + !----------------------------------------------------------------------- + + SHR_ASSERT_ALL(bounds%level == BOUNDS_LEVEL_PROC, subname // ': argument must be PROC-level bounds') + + call dynHarvest_file%time_info%set_current_year() + + ! Get total harvest for this time step + harvest_typeresolved(bounds%begg:bounds%endg,1:num_harvest_inst) = 0._r8 + + if (dynHarvest_file%time_info%is_before_time_series()) then + ! Turn off harvest before the start of the harvest time series + do_harvest = .false. + else + ! Note that do_harvest stays true even past the end of the time series. This + ! means that harvest rates will be maintained at the rate given in the last + ! year of the file for all years past the end of this specified time series. + do_harvest = .true. + allocate(this_data(bounds%begg:bounds%endg)) + do varnum = 1, num_harvest_inst + call harvest_inst(varnum)%get_current_data(this_data) + harvest_typeresolved(bounds%begg:bounds%endg,varnum) = this_data(bounds%begg:bounds%endg) + end do + deallocate(this_data) + end if + + end subroutine dynHarvest_interp_resolve_harvesttypes + + !----------------------------------------------------------------------- subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & soilbiogeochem_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & From b79422e29b3f23b6b572b3c901a37cf28341a2f7 Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 6 May 2020 20:37:16 -0600 Subject: [PATCH 087/152] some initial updates towards sending land-use drivers to fates --- bld/CLMBuildNamelist.pm | 13 +++++++----- src/biogeochem/EDBGCDynMod.F90 | 1 - src/biogeochem/dynHarvestMod.F90 | 23 +++++++++++----------- src/dyn_subgrid/dynSubgridControlMod.F90 | 8 ++------ src/utils/clmfates_interfaceMod.F90 | 25 ++++++++++++++++++++---- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b59946ebf8..f0b5ee1241 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2561,15 +2561,18 @@ sub setup_logic_do_harvest { # cannot_be_true will be set to a non-empty string in any case where # do_harvest should not be true; if it turns out that do_harvest IS true # in any of these cases, a fatal error will be generated - my $cannot_be_true = ""; + my $cannot_be_true = "" if (string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) { $cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)"; - } elsif (!&value_is_true($nl->get_value('use_cn'))) { - $cannot_be_true = "$var can only be set to true when running with CN (use_cn = true)"; - } elsif (&value_is_true($nl->get_value('use_fates'))) { - $cannot_be_true = "$var currently doesn't work with ED"; } + #cdk disabling this for now, but probably there is a better way to do it. + #cdk elsif (!&value_is_true($nl->get_value('use_cn'))) { + #cdk $cannot_be_true = "$var can only be set to true when running with CN (use_cn = true)"; + #cdk } + #cdk elsif (&value_is_true($nl->get_value('use_fates'))) { + #cdk $cannot_be_true = "$var currently doesn't work with ED"; + #cdk } if ($cannot_be_true) { $default_val = ".false."; diff --git a/src/biogeochem/EDBGCDynMod.F90 b/src/biogeochem/EDBGCDynMod.F90 index 5096cf13fa..802ad4b247 100644 --- a/src/biogeochem/EDBGCDynMod.F90 +++ b/src/biogeochem/EDBGCDynMod.F90 @@ -71,7 +71,6 @@ subroutine EDBGCDyn(bounds, & use CNNStateUpdate1Mod , only: NStateUpdate1 use CNNStateUpdate2Mod , only: NStateUpdate2, NStateUpdate2h use CNGapMortalityMod , only: CNGapMortality - use dynHarvestMod , only: CNHarvest use SoilBiogeochemDecompCascadeBGCMod , only: decomp_rate_constants_bgc use SoilBiogeochemDecompCascadeCNMod , only: decomp_rate_constants_cn use SoilBiogeochemCompetitionMod , only: SoilBiogeochemCompetition diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/biogeochem/dynHarvestMod.F90 index b7dce6a845..065c25283f 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/biogeochem/dynHarvestMod.F90 @@ -31,6 +31,8 @@ module dynHarvestMod ! public :: dynHarvest_init ! initialize data structures for harvest information public :: dynHarvest_interp ! get harvest data for current time step, if needed + public :: dynHarvest_interp_resolve_harvesttypes ! get harvest data for current time step, if needed, harvest-type-resolved + public :: get_harvest_rate public :: CNHarvest ! harvest mortality routine for CN code ! ! !PRIVATE MEMBER FUNCTIONS: @@ -51,7 +53,6 @@ module dynHarvestMod type(dyn_var_time_uninterp_type) :: harvest_inst(num_harvest_inst) ! value of each harvest variable real(r8) , allocatable :: harvest(:) ! harvest rates - real(r8) , allocatable :: harvest_typeresolved(:,:) ! harvest rates, resolved by harvest type logical :: do_harvest ! whether we're in a period when we should do harvest character(len=*), parameter :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set character(len=64) :: harvest_units = string_not_set ! units from harvest variables @@ -87,16 +88,12 @@ subroutine dynHarvest_init(bounds, harvest_filename) SHR_ASSERT(bounds%level == BOUNDS_LEVEL_PROC, subname // ': argument must be PROC-level bounds') - if ( .not. use_fates ) then + ! we only need to keep this summary variable in CN veg type + if ( .not. use_fates ) then allocate(harvest(bounds%begg:bounds%endg),stat=ier) if (ier /= 0) then call endrun(msg=' allocation error for harvest'//errMsg(sourcefile, __LINE__)) end if - else - allocate(harvest_typeresolved(bounds%begg:bounds%endg, num_harvest_inst),stat=ier) - if (ier /= 0) then - call endrun(msg=' allocation error for harvest_typeresolved'//errMsg(sourcefile, __LINE__)) - end if end if ! Get the year from the START of the timestep for consistency with other dyn file @@ -183,7 +180,7 @@ end subroutine dynHarvest_interp !----------------------------------------------------------------------- - subroutine dynHarvest_interp_resolve_harvesttypes(bounds) + subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates) ! ! !DESCRIPTION: ! Get harvest data for model time, when needed. @@ -203,6 +200,7 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds) ! ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds ! proc-level bounds + real(r8) , intent(out):: harvest_rates(bounds%begg: , 1: ) ! output the harvest rates ! ! !LOCAL VARIABLES: integer :: varnum ! counter for harvest variables @@ -215,8 +213,7 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds) call dynHarvest_file%time_info%set_current_year() - ! Get total harvest for this time step - harvest_typeresolved(bounds%begg:bounds%endg,1:num_harvest_inst) = 0._r8 + harvest_rates(bounds%begg:bounds%endg,1:num_harvest_inst) = 0._r8 if (dynHarvest_file%time_info%is_before_time_series()) then ! Turn off harvest before the start of the harvest time series @@ -229,13 +226,17 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds) allocate(this_data(bounds%begg:bounds%endg)) do varnum = 1, num_harvest_inst call harvest_inst(varnum)%get_current_data(this_data) - harvest_typeresolved(bounds%begg:bounds%endg,varnum) = this_data(bounds%begg:bounds%endg) + harvest_rates(bounds%begg:bounds%endg,varnum) = this_data(bounds%begg:bounds%endg) end do deallocate(this_data) end if end subroutine dynHarvest_interp_resolve_harvesttypes + subroutine get_harvest_rate(soilc + + end subroutine get_harvest_rate + !----------------------------------------------------------------------- subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & diff --git a/src/dyn_subgrid/dynSubgridControlMod.F90 b/src/dyn_subgrid/dynSubgridControlMod.F90 index 3820d6392a..3e077a036c 100644 --- a/src/dyn_subgrid/dynSubgridControlMod.F90 +++ b/src/dyn_subgrid/dynSubgridControlMod.F90 @@ -267,12 +267,8 @@ subroutine check_namelist_consistency end if if (dyn_subgrid_control_inst%do_harvest) then - if (.not. use_cn) then - write(iulog,*) 'ERROR: do_harvest can only be true if use_cn is true' - call endrun(msg=errMsg(sourcefile, __LINE__)) - end if - if (use_fates) then - write(iulog,*) 'ERROR: do_harvest currently does not work with use_fates' + if (.not. (use_cn .or. use_fates)) then + write(iulog,*) 'ERROR: do_harvest can only be true if either use_cn or use_fates are true' call endrun(msg=errMsg(sourcefile, __LINE__)) end if end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 2d23472fd7..631673a6ac 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -138,8 +138,11 @@ module CLMFatesInterfaceMod use FatesPlantHydraulicsMod, only : InitHydrSites use FatesPlantHydraulicsMod, only : RestartHydrStates use FATESFireBase , only : fates_fire_base_type - use CNFireFactoryMod, only: no_fire, scalar_lightning, & - successful_ignitions, anthro_ignitions + use CNFireFactoryMod , only : no_fire, scalar_lightning, & + successful_ignitions, anthro_ignitions + use dynSubgridControlMod , only : get_do_harvest + use dynHarvestMod , only : num_harvest_inst, & + dynHarvest_interp_resolve_harvesttypes implicit none @@ -664,6 +667,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: s ! site index integer :: g ! grid-cell index (HLM) integer :: c ! column index (HLM) + integer :: g ! gridcell index (HLM) integer :: ifp ! patch index integer :: p ! HLM patch index integer :: yr ! year (0, ...) @@ -684,6 +688,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & real(r8) :: day_of_year real(r8), pointer :: lnfm24(:) integer :: ier + integer :: begg,endg + real(r8) :: harvest_rates(bounds_clump%begg:bounds_clump%endg,num_harvest_inst) !----------------------------------------------------------------------- ! --------------------------------------------------------------------------------- @@ -695,6 +701,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! and it keeps all the boundaries in one location ! --------------------------------------------------------------------------------- + begg = bounds_clump%begg; endg = bounds_clump%endg + days_per_year = get_days_per_year() call get_curr_date(current_year,current_month,current_day,current_tod) current_date = current_year*10000 + current_month*100 + current_day @@ -713,6 +721,11 @@ subroutine dynamics_driv(this, nc, bounds_clump, & model_day, floor(day_of_year), & days_per_year, 1.0_r8/dble(days_per_year)) + if (get_do_harvest()) then + call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & + harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst)) + endif + if (fates_spitfire_mode > scalar_lightning) then allocate(lnfm24(bounds_clump%begg:bounds_clump%endg), stat=ier) if (ier /= 0) then @@ -725,9 +738,9 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) + g = col%gricell(c) if (fates_spitfire_mode > scalar_lightning) then - g = col%gridcell(c) do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno p = ifp + col%patchi(c) @@ -760,6 +773,11 @@ subroutine dynamics_driv(this, nc, bounds_clump, & end do + if (get_do_harvest()) then + do iharv = 1, num_harvest_inst + this%fates(nc)%bc_in(s)%harvest_rates(iharv) = harvest_rates(g,iharv) + end do + endif if(use_fates_planthydro)then this%fates(nc)%bc_in(s)%hksat_sisl(1:nlevsoil) = soilstate_inst%hksat_col(c,1:nlevsoil) @@ -769,7 +787,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & 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) = waterstatebulk_inst%h2osoi_liq_col(c,1:nlevsoil) end if - end do From dc461526132534b585076155277ecc34efad3d2c Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 20 May 2020 10:50:14 -0600 Subject: [PATCH 088/152] first attempt to link ctsm to fates with harvest --- src/biogeochem/dynHarvestMod.F90 | 32 ++++++++++------------- src/utils/clmfates_interfaceMod.F90 | 40 ++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/biogeochem/dynHarvestMod.F90 index 065c25283f..464808ed4d 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/biogeochem/dynHarvestMod.F90 @@ -32,7 +32,6 @@ module dynHarvestMod public :: dynHarvest_init ! initialize data structures for harvest information public :: dynHarvest_interp ! get harvest data for current time step, if needed public :: dynHarvest_interp_resolve_harvesttypes ! get harvest data for current time step, if needed, harvest-type-resolved - public :: get_harvest_rate public :: CNHarvest ! harvest mortality routine for CN code ! ! !PRIVATE MEMBER FUNCTIONS: @@ -54,8 +53,10 @@ module dynHarvestMod real(r8) , allocatable :: harvest(:) ! harvest rates logical :: do_harvest ! whether we're in a period when we should do harvest - character(len=*), parameter :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set - character(len=64) :: harvest_units = string_not_set ! units from harvest variables + character(len=*), parameter :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set + character(len=64) :: harvest_units = string_not_set ! units from harvest variables + character(len=64), parameter :: mass_units = "gC/m2/yr" + character(len=64), parameter :: unitless_units = "unitless" character(len=*), parameter, private :: sourcefile = & __FILE__ !--------------------------------------------------------------------------- @@ -110,10 +111,10 @@ subroutine dynHarvest_init(bounds, harvest_filename) do_check_sums_equal_1=.false., data_shape=[num_points]) call harvest_inst(varnum)%get_att("units",units) if ( trim(units) == string_not_set ) then - units = "unitless" - else if ( trim(units) == "unitless" ) then + units = unitless_units + else if ( trim(units) == unitless_units ) then - else if ( trim(units) /= "gC/m2/yr" ) then + else if ( trim(units) /= mass_units ) then call endrun(msg=' bad units read in from file='//trim(units)//errMsg(sourcefile, __LINE__)) end if if ( varnum > 1 .and. trim(units) /= trim(harvest_units) )then @@ -123,7 +124,7 @@ subroutine dynHarvest_init(bounds, harvest_filename) harvest_units = units units = string_not_set end do - + end subroutine dynHarvest_init @@ -180,7 +181,7 @@ end subroutine dynHarvest_interp !----------------------------------------------------------------------- - subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates) + subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates, after_start_of_harvest_ts) ! ! !DESCRIPTION: ! Get harvest data for model time, when needed. @@ -201,6 +202,7 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates) ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds ! proc-level bounds real(r8) , intent(out):: harvest_rates(bounds%begg: , 1: ) ! output the harvest rates + logical , intent(out):: after_start_of_harvest_ts ! ! !LOCAL VARIABLES: integer :: varnum ! counter for harvest variables @@ -213,16 +215,15 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates) call dynHarvest_file%time_info%set_current_year() - harvest_rates(bounds%begg:bounds%endg,1:num_harvest_inst) = 0._r8 - if (dynHarvest_file%time_info%is_before_time_series()) then ! Turn off harvest before the start of the harvest time series - do_harvest = .false. + after_start_of_harvest_ts = .false. + harvest_rates(bounds%begg:bounds%endg,1:num_harvest_inst) = 0._r8 else ! Note that do_harvest stays true even past the end of the time series. This ! means that harvest rates will be maintained at the rate given in the last ! year of the file for all years past the end of this specified time series. - do_harvest = .true. + after_start_of_harvest_ts = .true. allocate(this_data(bounds%begg:bounds%endg)) do varnum = 1, num_harvest_inst call harvest_inst(varnum)%get_current_data(this_data) @@ -233,11 +234,6 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates) end subroutine dynHarvest_interp_resolve_harvesttypes - subroutine get_harvest_rate(soilc - - end subroutine get_harvest_rate - - !----------------------------------------------------------------------- subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & soilbiogeochem_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & @@ -374,7 +370,7 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & if (ivt(p) > noveg .and. ivt(p) < nbrdlf_evr_shrub) then if (do_harvest) then - if (harvest_units == "gC/m2/yr") then + if (harvest_units == mass_units) then thistreec = leafc(p) + frootc(p) + livestemc(p) + deadstemc(p) + livecrootc(p) + deadcrootc(p) + xsmrpool(p) cm = harvest(g) if (thistreec > 0.0_r8) then diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 631673a6ac..b67df4df84 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -141,8 +141,9 @@ module CLMFatesInterfaceMod use CNFireFactoryMod , only : no_fire, scalar_lightning, & successful_ignitions, anthro_ignitions use dynSubgridControlMod , only : get_do_harvest - use dynHarvestMod , only : num_harvest_inst, & - dynHarvest_interp_resolve_harvesttypes + use dynHarvestMod , only : num_harvest_inst, harvest_varnames + use dynHarvestMod , only : harvest_units, mass_units, unitless_units + use dynHarvestMod , only : dynHarvest_interp_resolve_harvesttypes implicit none @@ -321,6 +322,24 @@ subroutine CLMFatesGlobals() else pass_logging = 0 end if + if(get_do_harvest()) then + pass_logging = 1 + pass_num_lu_harvest_cats = num_harvest_inst + if (wood_harvest_units .eq. unitless_units) then + pass_lu_harvest = 1 + else if (wood_harvest_units .eq. mass_units) then + pass_lu_harvest = 2 + else + write(iulog,*) 'units field not one of the specified options.' + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + else + pass_lu_harvest = 0 + pass_num_lu_harvest_cats = 0 + end if + + call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) + call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) call set_fates_ctrlparms('use_logging',ival=pass_logging) if(use_fates_ed_prescribed_phys) then @@ -529,7 +548,7 @@ subroutine init(this, bounds_proc ) ndecomp = 1 end if - call allocate_bcin(this%fates(nc)%bc_in(s),col%nbedrock(c),ndecomp) + call allocate_bcin(this%fates(nc)%bc_in(s),col%nbedrock(c),ndecomp, num_harvest_inst) call allocate_bcout(this%fates(nc)%bc_out(s),col%nbedrock(c),ndecomp) call zero_bcs(this%fates(nc),s) @@ -690,6 +709,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: ier integer :: begg,endg real(r8) :: harvest_rates(bounds_clump%begg:bounds_clump%endg,num_harvest_inst) + logical :: after_start_of_harvest_ts !----------------------------------------------------------------------- ! --------------------------------------------------------------------------------- @@ -723,7 +743,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & if (get_do_harvest()) then call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & - harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst)) + harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst), & + after_start_of_harvest_ts) endif if (fates_spitfire_mode > scalar_lightning) then @@ -788,6 +809,17 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%h2o_liq_sisl(1:nlevsoil) = waterstatebulk_inst%h2osoi_liq_col(c,1:nlevsoil) end if + ! get the harvest data, which is by gridcell + ! for now there is one veg column per gridcell, so store all harvest data in each site + ! this will eventually change + ! today's hlm harvest flag needs to be set no matter what + g = col_pp%gridcell(c) + this%fates(nc)%bc_in(s)%hlm_do_harvest_today = do_harvest + if (do_harvest) then + this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = harvest_rates(1:num_harvest_inst,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = harvest_catnames + end if + end do ! --------------------------------------------------------------------------------- From f629d6a8375841419684a95141bef69b6399f85f Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 20 May 2020 21:37:08 -0600 Subject: [PATCH 089/152] bugfixes to get ctsm to compile and run --- src/biogeochem/dynHarvestMod.F90 | 12 ++-- src/dyn_subgrid/dynSubgridDriverMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 76 ++++++++++++++----------- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/biogeochem/dynHarvestMod.F90 index 464808ed4d..afd3fd1152 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/biogeochem/dynHarvestMod.F90 @@ -45,18 +45,18 @@ module dynHarvestMod type(dyn_file_type), target :: dynHarvest_file ! information for the file containing harvest data ! Define the underlying harvest variables - integer, parameter :: num_harvest_inst = 5 - character(len=64), parameter :: harvest_varnames(num_harvest_inst) = & + integer, parameter, public :: num_harvest_inst = 5 + character(len=64), parameter, public :: harvest_varnames(num_harvest_inst) = & [character(len=64) :: 'HARVEST_VH1', 'HARVEST_VH2', 'HARVEST_SH1', 'HARVEST_SH2', 'HARVEST_SH3'] type(dyn_var_time_uninterp_type) :: harvest_inst(num_harvest_inst) ! value of each harvest variable real(r8) , allocatable :: harvest(:) ! harvest rates - logical :: do_harvest ! whether we're in a period when we should do harvest + logical, public, protected :: do_harvest ! whether we're in a period when we should do harvest character(len=*), parameter :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set - character(len=64) :: harvest_units = string_not_set ! units from harvest variables - character(len=64), parameter :: mass_units = "gC/m2/yr" - character(len=64), parameter :: unitless_units = "unitless" + character(len=64), public, protected :: harvest_units = string_not_set ! units from harvest variables + character(len=64), parameter, public :: mass_units = "gC/m2/yr" + character(len=64), parameter, public :: unitless_units = "unitless" character(len=*), parameter, private :: sourcefile = & __FILE__ !--------------------------------------------------------------------------- diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index 73c3f9e4b0..a6d91778fd 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -241,7 +241,7 @@ subroutine dynSubgrid_driver(bounds_proc, call dyncrop_interp(bounds_proc,crop_inst) end if - if (get_do_harvest()) then + if (get_do_harvest() .and. .not. use_fates) then call dynHarvest_interp(bounds_proc) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b67df4df84..9332bf3060 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -247,6 +247,8 @@ subroutine CLMFatesGlobals() integer :: pass_vertsoilc integer :: pass_spitfire integer :: pass_ed_st3 + integer :: pass_num_lu_harvest_cats + integer :: pass_lu_harvest integer :: pass_logging integer :: pass_ed_prescribed_phys integer :: pass_planthydro @@ -322,24 +324,6 @@ subroutine CLMFatesGlobals() else pass_logging = 0 end if - if(get_do_harvest()) then - pass_logging = 1 - pass_num_lu_harvest_cats = num_harvest_inst - if (wood_harvest_units .eq. unitless_units) then - pass_lu_harvest = 1 - else if (wood_harvest_units .eq. mass_units) then - pass_lu_harvest = 2 - else - write(iulog,*) 'units field not one of the specified options.' - call endrun(msg=errMsg(sourcefile, __LINE__)) - end if - else - pass_lu_harvest = 0 - pass_num_lu_harvest_cats = 0 - end if - - call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) - call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) call set_fates_ctrlparms('use_logging',ival=pass_logging) if(use_fates_ed_prescribed_phys) then @@ -362,6 +346,36 @@ subroutine CLMFatesGlobals() pass_cohort_age_tracking = 0 end if call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) + + ! check fates logging namelist value first because hlm harvest overrides it + if(use_fates_logging) then + pass_logging = 1 + else + pass_logging = 0 + end if + + if(get_do_harvest()) then + pass_logging = 1 + pass_num_lu_harvest_cats = num_harvest_inst + ! !!! cdk fo rnow set this inline because harvest_units is being set after this + ! if (trim(harvest_units) .eq. trim(unitless_units)) then + ! pass_lu_harvest = 1 + ! else if (trim(harvest_units) .eq. trim(mass_units)) then + ! pass_lu_harvest = 2 + ! else + ! write(iulog,*) 'units field not one of the specified options.' + ! write(iulog,*) harvest_units + ! call endrun(msg=errMsg(sourcefile, __LINE__)) + ! end if + pass_lu_harvest = 1 + else + pass_lu_harvest = 0 + pass_num_lu_harvest_cats = 0 + end if + + call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) + call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) + call set_fates_ctrlparms('use_logging',ival=pass_logging) if(use_fates_inventory_init) then pass_inventory_init = 1 @@ -710,6 +724,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: begg,endg real(r8) :: harvest_rates(bounds_clump%begg:bounds_clump%endg,num_harvest_inst) logical :: after_start_of_harvest_ts + integer :: iharv !----------------------------------------------------------------------- ! --------------------------------------------------------------------------------- @@ -744,7 +759,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & if (get_do_harvest()) then call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst), & - after_start_of_harvest_ts) + after_start_of_harvest_ts=after_start_of_harvest_ts) endif if (fates_spitfire_mode > scalar_lightning) then @@ -759,7 +774,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s=1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) - g = col%gricell(c) + g = col%gridcell(c) if (fates_spitfire_mode > scalar_lightning) then do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno @@ -793,12 +808,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & atm2lnd_inst%wind24_patch(p) end do - - if (get_do_harvest()) then - do iharv = 1, num_harvest_inst - this%fates(nc)%bc_in(s)%harvest_rates(iharv) = harvest_rates(g,iharv) - end do - endif if(use_fates_planthydro)then this%fates(nc)%bc_in(s)%hksat_sisl(1:nlevsoil) = soilstate_inst%hksat_col(c,1:nlevsoil) @@ -813,12 +822,15 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! for now there is one veg column per gridcell, so store all harvest data in each site ! this will eventually change ! today's hlm harvest flag needs to be set no matter what - g = col_pp%gridcell(c) - this%fates(nc)%bc_in(s)%hlm_do_harvest_today = do_harvest - if (do_harvest) then - this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = harvest_rates(1:num_harvest_inst,g) - this%fates(nc)%bc_in(s)%hlm_harvest_catnames = harvest_catnames - end if + if (get_do_harvest()) then + this%fates(nc)%bc_in(s)%hlm_do_harvest_today = after_start_of_harvest_ts + if (after_start_of_harvest_ts) then + this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = harvest_rates(1:num_harvest_inst,g) + else + this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = 0._r8 + end if + this%fates(nc)%bc_in(s)%hlm_harvest_catnames(1:num_harvest_inst) = harvest_varnames(1:num_harvest_inst) + endif end do From 5dc01b2c7e03e881426609c0531646aca2ec3ff0 Mon Sep 17 00:00:00 2001 From: ckoven Date: Thu, 28 May 2020 11:16:33 -0600 Subject: [PATCH 090/152] fixed runtime bugs --- src/biogeochem/dynHarvestMod.F90 | 3 ++- src/utils/clmfates_interfaceMod.F90 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/biogeochem/dynHarvestMod.F90 index afd3fd1152..a7694d9c84 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/biogeochem/dynHarvestMod.F90 @@ -211,7 +211,8 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates, after_s character(len=*), parameter :: subname = 'dynHarvest_interp' !----------------------------------------------------------------------- - SHR_ASSERT_ALL(bounds%level == BOUNDS_LEVEL_PROC, subname // ': argument must be PROC-level bounds') + !!! NOTE I AM NOT USING THE BOUNDS_LEVEL_PROC ASSERTION HERE BECAUSE OF WHERE IN THE CALLING + !!! SEQUENCE THIS IS CALLED. I THINK THIS IS SAFE BUT NEED TO CONFIRM. --CDK call dynHarvest_file%time_info%set_current_year() diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 9332bf3060..9e2927cfd4 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -825,7 +825,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & if (get_do_harvest()) then this%fates(nc)%bc_in(s)%hlm_do_harvest_today = after_start_of_harvest_ts if (after_start_of_harvest_ts) then - this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = harvest_rates(1:num_harvest_inst,g) + this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = 0._r8 end if From d2e1befc694afecae5bbf735d6857a54b7b59695 Mon Sep 17 00:00:00 2001 From: ckoven Date: Tue, 9 Jun 2020 13:51:28 -0600 Subject: [PATCH 091/152] added pass of bc_in to history dynamics subroutine to allow outputting logging BCs to history --- src/utils/clmfates_interfaceMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 9e2927cfd4..f4f14179e2 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -898,7 +898,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! --------------------------------------------------------------------------------- call this%fates_hist%update_history_dyn( nc, & this%fates(nc)%nsites, & - this%fates(nc)%sites) + this%fates(nc)%sites, this%fates(nc)%bc_in) if (masterproc) then write(iulog, *) 'clm: leaving fates model', bounds_clump%begg, & @@ -1355,7 +1355,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & ! ------------------------------------------------------------------------ call this%fates_hist%update_history_dyn( nc, & this%fates(nc)%nsites, & - this%fates(nc)%sites) + this%fates(nc)%sites, this%fates(nc)%bc_in) end if @@ -1468,7 +1468,7 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & ! ------------------------------------------------------------------------ call this%fates_hist%update_history_dyn( nc, & this%fates(nc)%nsites, & - this%fates(nc)%sites) + this%fates(nc)%sites, this%fates(nc)%bc_in) From 3a55f8346303eef431affb8c7c8be78102663e2e Mon Sep 17 00:00:00 2001 From: ckoven Date: Tue, 9 Jun 2020 13:51:34 -0600 Subject: [PATCH 092/152] Revert "added pass of bc_in to history dynamics subroutine to allow outputting logging BCs to history" This reverts commit c18af043933f0f3aed2920e28b1baa15453f84ab. --- src/utils/clmfates_interfaceMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index f4f14179e2..9e2927cfd4 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -898,7 +898,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! --------------------------------------------------------------------------------- call this%fates_hist%update_history_dyn( nc, & this%fates(nc)%nsites, & - this%fates(nc)%sites, this%fates(nc)%bc_in) + this%fates(nc)%sites) if (masterproc) then write(iulog, *) 'clm: leaving fates model', bounds_clump%begg, & @@ -1355,7 +1355,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & ! ------------------------------------------------------------------------ call this%fates_hist%update_history_dyn( nc, & this%fates(nc)%nsites, & - this%fates(nc)%sites, this%fates(nc)%bc_in) + this%fates(nc)%sites) end if @@ -1468,7 +1468,7 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & ! ------------------------------------------------------------------------ call this%fates_hist%update_history_dyn( nc, & this%fates(nc)%nsites, & - this%fates(nc)%sites, this%fates(nc)%bc_in) + this%fates(nc)%sites) From 07e6e7f9f8f86239f6722b2cbf2d44ab6ce38652 Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 1 Jul 2020 16:38:18 -0600 Subject: [PATCH 093/152] made a bunch of changes based on code review --- bld/CLMBuildNamelist.pm | 23 ++++++++++------------- src/biogeochem/dynHarvestMod.F90 | 5 +---- src/utils/clmfates_interfaceMod.F90 | 5 ++--- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index f0b5ee1241..448c3d9b1f 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2563,20 +2563,17 @@ sub setup_logic_do_harvest { # in any of these cases, a fatal error will be generated my $cannot_be_true = "" - if (string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) { - $cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)"; - } - #cdk disabling this for now, but probably there is a better way to do it. - #cdk elsif (!&value_is_true($nl->get_value('use_cn'))) { - #cdk $cannot_be_true = "$var can only be set to true when running with CN (use_cn = true)"; - #cdk } - #cdk elsif (&value_is_true($nl->get_value('use_fates'))) { - #cdk $cannot_be_true = "$var currently doesn't work with ED"; - #cdk } + if (string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) { + $cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)"; + } - if ($cannot_be_true) { - $default_val = ".false."; - } + elsif (!&value_is_true($nl->get_value('use_cn')) && !&value_is_true($nl->get_value('use_fates'))) { + $cannot_be_true = "$var can only be set to true when running with either CN or FATES"; + } + + if ($cannot_be_true) { + $default_val = ".false."; + } if (!$cannot_be_true) { # Note that, if the variable cannot be true, we don't call add_default diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/biogeochem/dynHarvestMod.F90 index a7694d9c84..4c6ae9b105 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/biogeochem/dynHarvestMod.F90 @@ -200,7 +200,7 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates, after_s use dynTimeInfoMod , only : time_info_type ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds ! proc-level bounds + type(bounds_type), intent(in) :: bounds real(r8) , intent(out):: harvest_rates(bounds%begg: , 1: ) ! output the harvest rates logical , intent(out):: after_start_of_harvest_ts ! @@ -211,9 +211,6 @@ subroutine dynHarvest_interp_resolve_harvesttypes(bounds, harvest_rates, after_s character(len=*), parameter :: subname = 'dynHarvest_interp' !----------------------------------------------------------------------- - !!! NOTE I AM NOT USING THE BOUNDS_LEVEL_PROC ASSERTION HERE BECAUSE OF WHERE IN THE CALLING - !!! SEQUENCE THIS IS CALLED. I THINK THIS IS SAFE BUT NEED TO CONFIRM. --CDK - call dynHarvest_file%time_info%set_current_year() if (dynHarvest_file%time_info%is_before_time_series()) then diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 9e2927cfd4..ec6a2f1a7b 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -823,11 +823,10 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! this will eventually change ! today's hlm harvest flag needs to be set no matter what if (get_do_harvest()) then - this%fates(nc)%bc_in(s)%hlm_do_harvest_today = after_start_of_harvest_ts if (after_start_of_harvest_ts) then - this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) + this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else - this%fates(nc)%bc_in(s)%hlm_harvest(1:num_harvest_inst) = 0._r8 + this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = 0._r8 end if this%fates(nc)%bc_in(s)%hlm_harvest_catnames(1:num_harvest_inst) = harvest_varnames(1:num_harvest_inst) endif From 0ca2231acb0bc84c413ebc369005e9449f5df320 Mon Sep 17 00:00:00 2001 From: ckoven Date: Wed, 1 Jul 2020 20:07:58 -0600 Subject: [PATCH 094/152] moved harvest unit specification to bc_in structure --- src/utils/clmfates_interfaceMod.F90 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index ec6a2f1a7b..d01cf18645 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -144,6 +144,8 @@ module CLMFatesInterfaceMod use dynHarvestMod , only : num_harvest_inst, harvest_varnames use dynHarvestMod , only : harvest_units, mass_units, unitless_units use dynHarvestMod , only : dynHarvest_interp_resolve_harvesttypes + use FatesConstantsMod , only : hlm_harvest_area_fraction + use FatesConstantsMod , only : hlm_harvest_carbon implicit none @@ -357,16 +359,6 @@ subroutine CLMFatesGlobals() if(get_do_harvest()) then pass_logging = 1 pass_num_lu_harvest_cats = num_harvest_inst - ! !!! cdk fo rnow set this inline because harvest_units is being set after this - ! if (trim(harvest_units) .eq. trim(unitless_units)) then - ! pass_lu_harvest = 1 - ! else if (trim(harvest_units) .eq. trim(mass_units)) then - ! pass_lu_harvest = 2 - ! else - ! write(iulog,*) 'units field not one of the specified options.' - ! write(iulog,*) harvest_units - ! call endrun(msg=errMsg(sourcefile, __LINE__)) - ! end if pass_lu_harvest = 1 else pass_lu_harvest = 0 @@ -829,6 +821,19 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = 0._r8 end if this%fates(nc)%bc_in(s)%hlm_harvest_catnames(1:num_harvest_inst) = harvest_varnames(1:num_harvest_inst) + + ! also pass the units that the harvest rates are specified in + if (trim(harvest_units) .eq. trim(unitless_units)) then + this%fates(nc)%bc_in(s)%hlm_harvest_units = hlm_harvest_area_fraction + else if (trim(harvest_units) .eq. trim(mass_units)) then + this%fates(nc)%bc_in(s)%hlm_harvest_units = hlm_harvest_carbon + else + write(iulog,*) 'units field not one of the specified options.' + write(iulog,*) harvest_units + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + + endif end do From 1cfb7a7d988905597723e58b3572c45ad7d876af Mon Sep 17 00:00:00 2001 From: ckoven Date: Tue, 28 Jul 2020 16:04:52 -0600 Subject: [PATCH 095/152] fixing changes requested in code review --- src/{biogeochem => dyn_subgrid}/dynHarvestMod.F90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename src/{biogeochem => dyn_subgrid}/dynHarvestMod.F90 (99%) diff --git a/src/biogeochem/dynHarvestMod.F90 b/src/dyn_subgrid/dynHarvestMod.F90 similarity index 99% rename from src/biogeochem/dynHarvestMod.F90 rename to src/dyn_subgrid/dynHarvestMod.F90 index 4c6ae9b105..a08c71ff1d 100644 --- a/src/biogeochem/dynHarvestMod.F90 +++ b/src/dyn_subgrid/dynHarvestMod.F90 @@ -29,10 +29,10 @@ module dynHarvestMod implicit none private ! - public :: dynHarvest_init ! initialize data structures for harvest information - public :: dynHarvest_interp ! get harvest data for current time step, if needed - public :: dynHarvest_interp_resolve_harvesttypes ! get harvest data for current time step, if needed, harvest-type-resolved - public :: CNHarvest ! harvest mortality routine for CN code + public :: dynHarvest_init ! initialize data structures for harvest information, used by both FATES and no-FATES + public :: dynHarvest_interp ! get harvest data for current time step, if needed, only used by non-FATES + public :: dynHarvest_interp_resolve_harvesttypes ! get harvest data for current time step, if needed, harvest-type-resolved. only used by FATES. + public :: CNHarvest ! harvest mortality routine for CN code, only used by non-FATES ! ! !PRIVATE MEMBER FUNCTIONS: private :: CNHarvestPftToColumn ! gather patch-level harvest fluxes to the column level @@ -52,8 +52,8 @@ module dynHarvestMod type(dyn_var_time_uninterp_type) :: harvest_inst(num_harvest_inst) ! value of each harvest variable real(r8) , allocatable :: harvest(:) ! harvest rates - logical, public, protected :: do_harvest ! whether we're in a period when we should do harvest - character(len=*), parameter :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set + logical, :: do_harvest ! whether we're in a period when we should do harvest + character(len=*), parameter, private :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set character(len=64), public, protected :: harvest_units = string_not_set ! units from harvest variables character(len=64), parameter, public :: mass_units = "gC/m2/yr" character(len=64), parameter, public :: unitless_units = "unitless" From 89e277e627360e8bb15c57f1167d1145e6e315fa Mon Sep 17 00:00:00 2001 From: ckoven Date: Tue, 28 Jul 2020 16:19:57 -0600 Subject: [PATCH 096/152] compile-time bugfixes on prior --- src/dyn_subgrid/dynHarvestMod.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dyn_subgrid/dynHarvestMod.F90 b/src/dyn_subgrid/dynHarvestMod.F90 index a08c71ff1d..db5b0d25e1 100644 --- a/src/dyn_subgrid/dynHarvestMod.F90 +++ b/src/dyn_subgrid/dynHarvestMod.F90 @@ -29,10 +29,10 @@ module dynHarvestMod implicit none private ! - public :: dynHarvest_init ! initialize data structures for harvest information, used by both FATES and no-FATES - public :: dynHarvest_interp ! get harvest data for current time step, if needed, only used by non-FATES + public :: dynHarvest_init ! initialize data structures for harvest information, used by both FATES and non-FATES/CN + public :: dynHarvest_interp ! get harvest data for current time step, if needed, only used by non-FATES/CN public :: dynHarvest_interp_resolve_harvesttypes ! get harvest data for current time step, if needed, harvest-type-resolved. only used by FATES. - public :: CNHarvest ! harvest mortality routine for CN code, only used by non-FATES + public :: CNHarvest ! harvest mortality routine for CN code, only used by non-FATES/CN ! ! !PRIVATE MEMBER FUNCTIONS: private :: CNHarvestPftToColumn ! gather patch-level harvest fluxes to the column level @@ -52,7 +52,7 @@ module dynHarvestMod type(dyn_var_time_uninterp_type) :: harvest_inst(num_harvest_inst) ! value of each harvest variable real(r8) , allocatable :: harvest(:) ! harvest rates - logical, :: do_harvest ! whether we're in a period when we should do harvest + logical, private :: do_harvest ! whether we're in a period when we should do harvest character(len=*), parameter, private :: string_not_set = "not_set" ! string to initialize with to indicate string wasn't set character(len=64), public, protected :: harvest_units = string_not_set ! units from harvest variables character(len=64), parameter, public :: mass_units = "gC/m2/yr" From bf0d97a7d048dddabc881263f9ca3b9c7e7936c2 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 14 Jul 2020 10:44:41 -0700 Subject: [PATCH 097/152] applying GetAndSetTime patch --- src/utils/clmfates_interfaceMod.F90 | 105 +++++++++++++++++++--------- 1 file changed, 72 insertions(+), 33 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d01cf18645..fb19461556 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -222,6 +222,11 @@ module CLMFatesInterfaceMod ! developer will at least question its usage (RGK) private :: hlm_bounds_to_fates_bounds + ! The GetAndSetTime function is used to get the current time from the CLM + ! time procedures and then set to the fates global time variables during restart, + ! init_coldstart, and dynamics_driv function calls + private :: GetAndSetTime + logical :: debug = .false. character(len=*), parameter, private :: sourcefile = & @@ -695,22 +700,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: g ! gridcell index (HLM) integer :: ifp ! patch index integer :: p ! HLM patch index - integer :: yr ! year (0, ...) - integer :: mon ! month (1, ..., 12) - integer :: day ! day of month (1, ..., 31) - integer :: sec ! seconds of the day integer :: nlevsoil ! number of soil layers at the site integer :: nld_si ! site specific number of decomposition layers - integer :: current_year - integer :: current_month - integer :: current_day - integer :: current_tod - integer :: current_date - integer :: jan01_curr_year - integer :: reference_date - integer :: days_per_year - real(r8) :: model_day - real(r8) :: day_of_year real(r8), pointer :: lnfm24(:) integer :: ier integer :: begg,endg @@ -730,23 +721,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & begg = bounds_clump%begg; endg = bounds_clump%endg - days_per_year = get_days_per_year() - call get_curr_date(current_year,current_month,current_day,current_tod) - current_date = current_year*10000 + current_month*100 + current_day - jan01_curr_year = current_year*10000 + 100 + 1 - - call get_ref_date(yr, mon, day, sec) - reference_date = yr*10000 + mon*100 + day - - call timemgr_datediff(reference_date, sec, current_date, current_tod, model_day) - - call timemgr_datediff(jan01_curr_year,0,current_date,sec,day_of_year) - - call SetFatesTime(current_year, current_month, & - current_day, current_tod, & - current_date, reference_date, & - model_day, floor(day_of_year), & - days_per_year, 1.0_r8/dble(days_per_year)) + ! Set the FATES global time and date variables + call GetAndSetTime if (get_do_harvest()) then call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & @@ -1150,6 +1126,9 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & ! I think that is it... ! --------------------------------------------------------------------------------- + ! Set the FATES global time and date variables + call GetAndSetTime + if(.not.initialized) then initialized=.true. @@ -1352,8 +1331,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & call this%fates_restart%update_3dpatch_radiation(this%fates(nc)%nsites, & this%fates(nc)%sites, & this%fates(nc)%bc_out) - - + ! ------------------------------------------------------------------------ ! Update history IO fields that depend on ecosystem dynamics ! ------------------------------------------------------------------------ @@ -1396,6 +1374,10 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & integer :: s integer :: c + + ! Set the FATES global time and date variables + call GetAndSetTime + nclumps = get_proc_clumps() !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,s,c,j,vol_ice,eff_porosity) @@ -2753,4 +2735,61 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) end subroutine hlm_bounds_to_fates_bounds + ! ====================================================================================== + + subroutine GetAndSetTime() + + ! CLM MODULES + use clm_time_manager , only : get_days_per_year, & + get_curr_date, & + get_ref_date, & + timemgr_datediff + + ! FATES MODULES + use FatesInterfaceMod , only : SetFatesTime + + ! LOCAL VARIABLES + integer :: yr ! year (0, ...) + integer :: mon ! month (1, ..., 12) + integer :: day ! day of month (1, ..., 31) + integer :: sec ! seconds of the day + integer :: current_year + integer :: current_month + integer :: current_day + integer :: current_tod + integer :: current_date + integer :: jan01_curr_year + integer :: reference_date + integer :: days_per_year + real(r8) :: model_day + real(r8) :: day_of_year + + + ! Get the current date and determine the set the start of the current year + call get_curr_date(current_year,current_month,current_day,current_tod) + current_date = current_year*10000 + current_month*100 + current_day + jan01_curr_year = current_year*10000 + 100 + 1 + + ! Get the reference date components and compute the date + call get_ref_date(yr, mon, day, sec) + reference_date = yr*10000 + mon*100 + day + + ! Get the defined number of days per year + days_per_year = get_days_per_year() + + ! Determine the model day + call timemgr_datediff(reference_date, sec, current_date, current_tod, model_day) + + ! Determine the current DOY + call timemgr_datediff(jan01_curr_year,0,current_date,sec,day_of_year) + + ! Set the FATES global time variables + call SetFatesTime(current_year, current_month, & + current_day, current_tod, & + current_date, reference_date, & + model_day, floor(day_of_year), & + days_per_year, 1.0_r8/dble(days_per_year)) + + end subroutine GetAndSetTime + end module CLMFatesInterfaceMod From f8d1e8a6b35fd106c9a4853f74171c6318ee4303 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 22 Jul 2020 18:23:27 -0600 Subject: [PATCH 098/152] Updating externals configuration to point to expected fates tag --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 20c468015e..fa6a277979 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.39.0_api.12.0.0 +tag = sci.1.40.0_api.13.0.0 required = True [PTCLM] From b1f7a79825b528db9a3963a0cecdd045fbd1927e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 Jul 2020 16:10:24 -0700 Subject: [PATCH 099/152] fixing duplicate integer definition missed in merge --- src/utils/clmfates_interfaceMod.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index fb19461556..c5872066fc 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -697,7 +697,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: s ! site index integer :: g ! grid-cell index (HLM) integer :: c ! column index (HLM) - integer :: g ! gridcell index (HLM) integer :: ifp ! patch index integer :: p ! HLM patch index integer :: nlevsoil ! number of soil layers at the site From 452be1af70295716670acc826ebb6c3dd7a8e8b0 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 30 Jul 2020 10:40:31 -0600 Subject: [PATCH 100/152] Updated fates in externals --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index fa6a277979..59cfdabc7d 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.40.0_api.13.0.0 +tag = sci.1.40.1_api.13.0.1 required = True [PTCLM] From af8e815691064551b8542e94f6b8ea62c2160c2e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 5 Aug 2020 09:45:19 -0700 Subject: [PATCH 101/152] fixing small typos in CLMBuildNamelist due to rebase --- bld/CLMBuildNamelist.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 448c3d9b1f..519e4d2915 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -958,7 +958,6 @@ sub setup_cmdl_fire_light_res { $nl_flags->{$var} = ".false."; } } -} #------------------------------------------------------------------------------- @@ -2561,7 +2560,7 @@ sub setup_logic_do_harvest { # cannot_be_true will be set to a non-empty string in any case where # do_harvest should not be true; if it turns out that do_harvest IS true # in any of these cases, a fatal error will be generated - my $cannot_be_true = "" + my $cannot_be_true = ""; if (string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) { $cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)"; From d6ef097ccde81c51b355efab87f0489bca845208 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 5 Aug 2020 14:12:47 -0700 Subject: [PATCH 102/152] fixing build errors due to rebase of lu and lightning updates --- src/main/clm_driver.F90 | 2 +- src/main/clm_instMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 5f40ce39db..45e60467ca 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -1011,7 +1011,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call clm_fates%dynamics_driv( nc, bounds_clump, & atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & - water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst & + water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst, & frictionvel_inst) ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 07fb44d011..6338350c10 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -184,7 +184,7 @@ end subroutine clm_instReadNML subroutine clm_instInit(bounds) ! ! !USES: - use clm_varpar , only : nlevsno, numpft + use clm_varpar , only : nlevsno use controlMod , only : nlfilename, fsurdat use domainMod , only : ldomain use SoilBiogeochemDecompCascadeBGCMod , only : init_decompcascade_bgc diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index c5872066fc..0b044f930b 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -78,6 +78,7 @@ module CLMFatesInterfaceMod use SolarAbsorbedType , only : solarabs_type use SoilBiogeochemCarbonFluxType, only : soilbiogeochem_carbonflux_type use SoilBiogeochemCarbonStateType, only : soilbiogeochem_carbonstate_type + use FrictionVelocityMod , only : frictionvel_type use clm_time_manager , only : is_restart use ncdio_pio , only : file_desc_t, ncd_int, ncd_double use restUtilMod, only : restartvar @@ -305,13 +306,6 @@ subroutine CLMFatesGlobals() end if call set_fates_ctrlparms('use_vertsoilc',ival=pass_vertsoilc) - if(use_fates_spitfire) then - pass_spitfire = 1 - else - pass_spitfire = 0 - end if - call set_fates_ctrlparms('use_spitfire',ival=pass_spitfire) - if(use_fates_fixed_biogeog)then pass_biogeog = 1 else From e7f9d5920e70be9ae75d29825c2735631248db14 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 5 Aug 2020 16:25:56 -0700 Subject: [PATCH 103/152] updating cime to 5.6.23 earlier to incorporate a fix to rel_path --- Externals.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals.cfg b/Externals.cfg index 0a0f4d24e9..993d5c505d 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -30,7 +30,7 @@ required = True local_path = cime protocol = git repo_url = https://github.com/ESMCI/cime -tag = cime5.8.19 +tag = cime5.8.23 externals = ../Externals_cime.cfg required = True From aa04fcfa22c52f799ec8b084fc90e228fc05941a Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 7 Aug 2020 12:28:19 -0600 Subject: [PATCH 104/152] revert cime back to 5.8.19 to avoid ctsm issue 1013 --- Externals.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals.cfg b/Externals.cfg index 993d5c505d..0a0f4d24e9 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -30,7 +30,7 @@ required = True local_path = cime protocol = git repo_url = https://github.com/ESMCI/cime -tag = cime5.8.23 +tag = cime5.8.19 externals = ../Externals_cime.cfg required = True From c56788f3091ff36e8933c0ab2936ea33a1019adf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 11 Aug 2020 11:27:55 -0600 Subject: [PATCH 105/152] updating pointer to updated fates tag bug fix for lu --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 59cfdabc7d..a776c6a271 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.40.1_api.13.0.1 +tag = sci.1.40.3_api.13.0.1 required = True [PTCLM] From b1eefc22eb369abe2ab46cde7e3c3bed163e563d Mon Sep 17 00:00:00 2001 From: ckoven Date: Fri, 14 Aug 2020 09:49:06 -0600 Subject: [PATCH 106/152] added timing calls to all subroutines in clmfates_interfaceMod.F90 --- src/utils/clmfates_interfaceMod.F90 | 106 ++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 4 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 0b044f930b..e0215c416b 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -147,7 +147,7 @@ module CLMFatesInterfaceMod use dynHarvestMod , only : dynHarvest_interp_resolve_harvesttypes use FatesConstantsMod , only : hlm_harvest_area_fraction use FatesConstantsMod , only : hlm_harvest_carbon - + use perf_mod , only : t_startf, t_stopf implicit none type, public :: f2hmap_type @@ -265,6 +265,9 @@ subroutine CLMFatesGlobals() integer :: pass_cohort_age_tracking integer :: pass_biogeog + + call t_startf('fates_globals') + if (use_fates) then verbose_output = .false. @@ -401,6 +404,8 @@ subroutine CLMFatesGlobals() ! it will return some nominal dimension sizes of 1 call SetFatesGlobalElements(use_fates) + + call t_stopf('fates_globals') return end subroutine CLMFatesGlobals @@ -458,6 +463,8 @@ subroutine init(this, bounds_proc ) ! 1) allocate the vectors ! 2) add the history variables defined in clm_inst to the history machinery + + call t_startf('fates_init') ! Parameter Routines call param_derived%Init( numpft_fates ) @@ -618,6 +625,8 @@ subroutine init(this, bounds_proc ) ! Fire data to send to FATES call create_fates_fire_data_method( this%fates_fire_data_method ) + call t_stopf('fates_init') + end subroutine init ! =================================================================================== @@ -637,6 +646,8 @@ subroutine check_hlm_active(this, nc, bounds_clump) ! local variables integer :: c + call t_startf('fates_check_hlm_active') + do c = bounds_clump%begc,bounds_clump%endc ! FATES ACTIVE BUT HLM IS NOT @@ -654,6 +665,8 @@ subroutine check_hlm_active(this, nc, bounds_clump) end if end do + call t_stopf('fates_check_hlm_active') + end subroutine check_hlm_active ! ------------------------------------------------------------------------------------ @@ -712,6 +725,9 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! and it keeps all the boundaries in one location ! --------------------------------------------------------------------------------- + + call t_startf('fates_dynamics_daily_driver') + begg = bounds_clump%begg; endg = bounds_clump%endg ! Set the FATES global time and date variables @@ -878,6 +894,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & bounds_clump%endg end if + call t_stopf('fates_dynamics_daily_driver') return end subroutine dynamics_driv @@ -906,6 +923,8 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & integer :: s ! site index integer :: c ! column index + call t_startf('fates_wrap_update_hlmfates_dyn') + associate( & tlai => canopystate_inst%tlai_patch , & elai => canopystate_inst%elai_patch , & @@ -1036,6 +1055,9 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & end do end associate + + call t_stopf('fates_wrap_update_hlmfates_dyn') + end subroutine wrap_update_hlmfates_dyn ! ==================================================================================== @@ -1096,6 +1118,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & logical, save :: initialized = .false. + call t_startf('fates_restart') nclumps = get_proc_clumps() @@ -1338,6 +1361,8 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & !$OMP END PARALLEL DO end if + + call t_stopf('fates_restart') return end subroutine restart @@ -1367,6 +1392,7 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & integer :: s integer :: c + call t_startf('fates_initcoldstart') ! Set the FATES global time and date variables call GetAndSetTime @@ -1455,6 +1481,8 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & end do !$OMP END PARALLEL DO + call t_stopf('fates_initcoldstart') + end subroutine init_coldstart ! ====================================================================================== @@ -1493,6 +1521,8 @@ subroutine wrap_sunfrac(this,nc,atm2lnd_inst,canopystate_inst) type(ed_patch_type), pointer :: cpatch ! c"urrent" patch INTERF-TODO: SHOULD ! BE HIDDEN AS A FATES PRIVATE + call t_startf('fates_wrapsunfrac') + associate( forc_solad => atm2lnd_inst%forc_solad_grc, & forc_solai => atm2lnd_inst%forc_solai_grc, & fsun => canopystate_inst%fsun_patch, & @@ -1546,6 +1576,8 @@ subroutine wrap_sunfrac(this,nc,atm2lnd_inst,canopystate_inst) end associate + call t_stopf('fates_wrapsunfrac') + end subroutine wrap_sunfrac ! =================================================================================== @@ -1569,6 +1601,8 @@ subroutine prep_canopyfluxes(this, nc, fn, filterp, photosyns_inst) ! parameters integer,parameter :: rsmax0 = 2.e4_r8 + call t_startf('fates_prepcanfluxes') + do s = 1, this%fates(nc)%nsites ! filter flag == 1 means that this patch has not been called for photosynthesis this%fates(nc)%bc_in(s)%filter_photo_pa(:) = 1 @@ -1580,6 +1614,9 @@ subroutine prep_canopyfluxes(this, nc, fn, filterp, photosyns_inst) end if end do + + call t_stopf('fates_prepcanfluxes') + end subroutine prep_canopyfluxes ! ==================================================================================== @@ -1622,6 +1659,8 @@ subroutine wrap_btran(this,nc,fn,filterc,soilstate_inst, & integer :: p integer :: nlevsoil + call t_startf('fates_wrapbtran') + associate(& sucsat => soilstate_inst%sucsat_col , & ! Input: [real(r8) (:,:) ] minimum soil suction (mm) watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation (porosity) @@ -1751,6 +1790,8 @@ subroutine wrap_btran(this,nc,fn,filterc,soilstate_inst, & end do end associate + call t_stopf('fates_wrapbtran') + end subroutine wrap_btran ! ==================================================================================== @@ -1765,7 +1806,6 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & use clm_varcon , only : rgas, tfrz, namep use clm_varctl , only : iulog use pftconMod , only : pftcon - use perf_mod , only : t_startf, t_stopf use PatchType , only : patch use quadraticMod , only : quadratic use EDTypesMod , only : dinc_ed @@ -1793,7 +1833,8 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & integer :: s,c,p,ifp,j,icp real(r8) :: dtime - call t_startf('edpsn') + call t_startf('fates_psn') + associate(& t_soisno => temperature_inst%t_soisno_col , & t_veg => temperature_inst%t_veg_patch , & @@ -1878,7 +1919,8 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & end do end associate - call t_stopf('edpsn') + + call t_stopf('fates_psn') end subroutine wrap_photosynthesis @@ -1895,6 +1937,7 @@ subroutine wrap_accumulatefluxes(this, nc, fn, filterp) integer :: s,c,p,ifp,icp real(r8) :: dtime + call t_startf('fates_wrapaccfluxes') ! Run a check on the filter do icp = 1,fn @@ -1921,6 +1964,8 @@ subroutine wrap_accumulatefluxes(this, nc, fn, filterp) this%fates(nc)%sites, & dtime) + call t_stopf('fates_wrapaccfluxes') + end subroutine wrap_accumulatefluxes ! ====================================================================================== @@ -1943,6 +1988,8 @@ subroutine wrap_canopy_radiation(this, bounds_clump, nc, & ! locals integer :: s,c,p,ifp,icp + call t_startf('fates_wrapcanopyradiation') + associate(& albgrd_col => surfalb_inst%albgrd_col , & !in albgri_col => surfalb_inst%albgri_col , & !in @@ -2007,6 +2054,8 @@ subroutine wrap_canopy_radiation(this, bounds_clump, nc, & end associate + call t_stopf('fates_wrapcanopyradiation') + end subroutine wrap_canopy_radiation ! ====================================================================================== @@ -2026,6 +2075,8 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & real(r8) :: dtime integer :: s,c + call t_startf('fates_wrapbgcsummary') + associate(& hr => soilbiogeochem_carbonflux_inst%hr_col, & ! (gC/m2/s) total heterotrophic respiration totsomc => soilbiogeochem_carbonstate_inst%totsomc_col, & ! (gC/m2) total soil organic matter carbon @@ -2049,6 +2100,9 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & dtime) end associate + + call t_stopf('fates_wrapbgcsummary') + end subroutine wrap_bgc_summary ! ====================================================================================== @@ -2069,6 +2123,8 @@ subroutine TransferZ0mDisp(this, bounds_clump, z0m_patch, displa_patch) integer :: ifp ! Fates patch index integer :: p ! CLM patch index + call t_startf('fates_transferz0disp') + SHR_ASSERT_FL((ubound(z0m_patch, 1) == bounds_clump%endp), sourcefile, __LINE__) SHR_ASSERT_FL((ubound(displa_patch, 1) == bounds_clump%endp), sourcefile, __LINE__) @@ -2087,6 +2143,8 @@ subroutine TransferZ0mDisp(this, bounds_clump, z0m_patch, displa_patch) end do end do + call t_stopf('fates_transferz0disp') + return end subroutine TransferZ0mDisp @@ -2121,8 +2179,12 @@ subroutine InterpFileInputs(this, bounds) character(len=*), parameter :: subname = 'InterpFileInputs' !----------------------------------------------------------------------- + call t_startf('fates_interpfileinputs') + call this%fates_fire_data_method%CNFireInterp(bounds) + call t_stopf('fates_interpfileinputs') + end subroutine InterpFileInputs !----------------------------------------------------------------------- @@ -2145,8 +2207,12 @@ subroutine Init2(this, bounds, NLFilename) character(len=*), parameter :: subname = 'Init2' !----------------------------------------------------------------------- + call t_startf('fates_init2') + call this%fates_fire_data_method%CNFireInit(bounds, NLFilename) + call t_stopf('fates_init2') + end subroutine Init2 !----------------------------------------------------------------------- @@ -2166,8 +2232,12 @@ subroutine InitAccBuffer(this, bounds) character(len=*), parameter :: subname = 'InitAccBuffer' !----------------------------------------------------------------------- + call t_startf('fates_initaccbuff') + call this%fates_fire_data_method%InitAccBuffer( bounds ) + call t_stopf('fates_initaccbuff') + end subroutine InitAccBuffer @@ -2188,8 +2258,12 @@ subroutine InitAccVars(this, bounds) character(len=*), parameter :: subname = 'InitAccVars' !----------------------------------------------------------------------- + call t_startf('fates_initaccvars') + call this%fates_fire_data_method%InitAccVars( bounds ) + call t_stopf('fates_initaccvars') + end subroutine InitAccVars !----------------------------------------------------------------------- @@ -2209,8 +2283,12 @@ subroutine UpdateAccVars(this, bounds) character(len=*), parameter :: subname = 'UpdateAccVars' !----------------------------------------------------------------------- + call t_startf('fates_updateaccvars') + call this%fates_fire_data_method%UpdateAccVars( bounds ) + call t_stopf('fates_updateaccvars') + end subroutine UpdateAccVars ! ====================================================================================== @@ -2252,6 +2330,8 @@ subroutine init_history_io(this,bounds_proc) type(fates_bounds_type) :: fates_bounds type(fates_bounds_type) :: fates_clump + call t_startf('fates_inithistoryio') + ! This routine initializes the types of output variables ! not the variables themselves, just the types ! --------------------------------------------------------------------------------- @@ -2386,6 +2466,9 @@ subroutine init_history_io(this,bounds_proc) end associate end do + + call t_stopf('fates_inithistoryio') + end subroutine init_history_io ! ====================================================================================== @@ -2403,6 +2486,7 @@ subroutine init_soil_depths(this, nc) integer :: nlevsoil integer :: nlevdecomp + call t_startf('fates_initsoildepths') do s = 1, this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) @@ -2437,6 +2521,8 @@ subroutine init_soil_depths(this, nc) end do + call t_stopf('fates_initsoildepths') + return end subroutine init_soil_depths @@ -2463,6 +2549,8 @@ subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, & if( .not. use_fates_planthydro ) return + call t_startf('fates_rootsoilflux') + nc = bounds_clump%clump_index ! Perform a check that the number of columns submitted to fates for @@ -2495,6 +2583,8 @@ subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, & end do + + call t_stopf('fates_rootsoilflux') end subroutine ComputeRootSoilFlux @@ -2560,6 +2650,7 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, & if ( .not.use_fates_planthydro ) return + call t_startf('fates_wraphydrodriv') dtime = get_step_size_real() @@ -2634,6 +2725,7 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, & this%fates(nc)%bc_in, & dtime) + call t_stopf('fates_wraphydrodriv') return end subroutine wrap_hydraulics_drive @@ -2656,6 +2748,8 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) type(bounds_type), intent(in) :: hlm type(fates_bounds_type), intent(out) :: fates + call t_startf('fates_hlm2fatesbnds') + fates%cohort_begin = hlm%begcohort fates%cohort_end = hlm%endcohort @@ -2725,6 +2819,7 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%elage_begin = 1 fates%elage_end = num_elements * nlevage + call t_stopf('fates_hlm2fatesbnds') end subroutine hlm_bounds_to_fates_bounds @@ -2757,6 +2852,7 @@ subroutine GetAndSetTime() real(r8) :: model_day real(r8) :: day_of_year + call t_startf('fates_getandsettime') ! Get the current date and determine the set the start of the current year call get_curr_date(current_year,current_month,current_day,current_tod) @@ -2783,6 +2879,8 @@ subroutine GetAndSetTime() model_day, floor(day_of_year), & days_per_year, 1.0_r8/dble(days_per_year)) + call t_stopf('fates_getandsettime') + end subroutine GetAndSetTime end module CLMFatesInterfaceMod From 725f9d60a808d1237863fa3c6e9972669baf0873 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Aug 2020 09:12:20 -0700 Subject: [PATCH 107/152] updating need_lightning_and_popdens in fates fire data types for interface refactor --- src/biogeochem/FATESFireDataMod.F90 | 27 ++++++++++++--------------- src/biogeochem/FATESFireNoDataMod.F90 | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/biogeochem/FATESFireDataMod.F90 b/src/biogeochem/FATESFireDataMod.F90 index f545709376..ce842cbf1c 100644 --- a/src/biogeochem/FATESFireDataMod.F90 +++ b/src/biogeochem/FATESFireDataMod.F90 @@ -25,6 +25,7 @@ module FATESFireDataMod real(r8), private, pointer :: lnfm24(:) ! Daily avg lightning by grid cell (#/km2/hr) contains ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: need_lightning_and_popdens procedure, public :: GetLight24 ! Return 24-hour averaged lightning data procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables @@ -33,26 +34,22 @@ module FATESFireDataMod end type fates_fire_data_type character(len=*), parameter, private :: sourcefile = __FILE__ - ! - ! !PRIVATE MEMBER DATA: - !----------------------------------------------------------------------- - - interface fates_fire_data_type - ! initialize a new cnfire_base object - module procedure constructor - end interface fates_fire_data_type - !----------------------------------------------------------------------- contains !------------------------------------------------------------------------ - type(fates_fire_data_type) function constructor() - ! - ! !DESCRIPTION: - ! Creates an object of type fates_fire_data_type + function need_lightning_and_popdens(this) ! !ARGUMENTS: - constructor%need_lightning_and_popdens = .true. - end function constructor + class(fates_fire_data_type), intent(in) :: this + logical :: need_lightning_and_popdens ! function result + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'need_lightning_and_popdens' + !----------------------------------------------------------------------- + + need_lightning_and_popdens = .true. + end function need_lightning_and_popdens !----------------------------------------------------------------------- function GetLight24( this ) result(lnfm24) diff --git a/src/biogeochem/FATESFireNoDataMod.F90 b/src/biogeochem/FATESFireNoDataMod.F90 index 10f7f57a68..3597bef678 100644 --- a/src/biogeochem/FATESFireNoDataMod.F90 +++ b/src/biogeochem/FATESFireNoDataMod.F90 @@ -27,6 +27,7 @@ module FATESFireNoDataMod contains ! !PUBLIC MEMBER FUNCTIONS: + procedure, public :: need_lightning_and_popdens procedure, public :: GetLight24 ! Return the 24-hour averaged lightning data procedure, public :: InitAccBuffer ! Initialize accumulation processes procedure, public :: InitAccVars ! Initialize accumulation variables @@ -35,26 +36,22 @@ module FATESFireNoDataMod end type fates_fire_no_data_type character(len=*), parameter, private :: sourcefile = __FILE__ - ! - ! !PRIVATE MEMBER DATA: - !----------------------------------------------------------------------- - - interface fates_fire_no_data_type - ! initialize a new cnfire_base object - module procedure constructor - end interface fates_fire_no_data_type - !----------------------------------------------------------------------- contains !------------------------------------------------------------------------ - type(fates_fire_no_data_type) function constructor() - ! - ! !DESCRIPTION: - ! Creates an object of type fates_fire_no_data_type + function need_lightning_and_popdens(this) ! !ARGUMENTS: - constructor%need_lightning_and_popdens = .false. - end function constructor + class(fates_fire_no_data_type), intent(in) :: this + logical :: need_lightning_and_popdens ! function result + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'need_lightning_and_popdens' + !----------------------------------------------------------------------- + + need_lightning_and_popdens = .false. + end function need_lightning_and_popdens !----------------------------------------------------------------------- function GetLight24( this ) result(lnfm24) From 62ff02fade3f714cec8d99e17c93b4cca2f7b0c2 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Aug 2020 11:20:05 -0700 Subject: [PATCH 108/152] correcting error in create_cnfire_method due to merge --- src/biogeochem/CNFireFactoryMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index 30e2812d16..e96c90b4aa 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -132,7 +132,7 @@ subroutine create_cnfire_method( NLFilename, cnfire_method ) end select call cnfire_method%CNFireReadNML( NLFilename ) - end function create_cnfire_method + end subroutine create_cnfire_method !----------------------------------------------------------------------- !----------------------------------------------------------------------- From e0f02da097f466f85ebb196cc6f42fd6032a786c Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 4 Sep 2020 15:23:48 -0400 Subject: [PATCH 109/152] Initial set of changes necessary for updating api to FATES CNP --- src/biogeochem/EDBGCDynMod.F90 | 13 --- src/main/clm_driver.F90 | 42 +++++--- src/main/histFileMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 127 ++++++++++++++++------- src/utils/clmfates_paraminterfaceMod.F90 | 3 + 5 files changed, 123 insertions(+), 64 deletions(-) diff --git a/src/biogeochem/EDBGCDynMod.F90 b/src/biogeochem/EDBGCDynMod.F90 index 802ad4b247..e4150e7789 100644 --- a/src/biogeochem/EDBGCDynMod.F90 +++ b/src/biogeochem/EDBGCDynMod.F90 @@ -336,19 +336,6 @@ subroutine EDBGCDynSummary(bounds, num_soilc, filter_soilc, num_soilp, filter_so ! call soilbiogeochem_nitrogenflux_inst%Summary(bounds, num_soilc, filter_soilc) - ! ----------------------------------------------------------------------------------- - ! fates veg carbon state and flux summary, Nitrogen (TBD) and Balance Checks - ! ----------------------------------------------------------------------------------- - ! ---------------------------------------------- - ! fates veg nitrogen flux summary - ! ---------------------------------------------- - ! ---------------------------------------------- - ! calculate balance checks on entire carbon cycle (FATES + BGC) - ! ---------------------------------------------- - - call clm_fates%wrap_bgc_summary(nc, soilbiogeochem_carbonflux_inst, & - soilbiogeochem_carbonstate_inst) - call t_stopf('BGCsum') end subroutine EDBGCDynSummary diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 45e60467ca..090cf3b988 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -1002,22 +1002,31 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro end if - if ( use_fates .and. is_beg_curr_day() ) then ! run fates at the start of each day - if ( masterproc ) then - write(iulog,*) 'clm: calling FATES model ', get_nstep() - end if - - call clm_fates%dynamics_driv( nc, bounds_clump, & - atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & - water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & - water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst, & - frictionvel_inst) - - ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a - ! call to reweight_wrapup, if it's needed at all. - call setFilters( bounds_clump, glc_behavior ) + + if ( use_fates) then + if( is_beg_curr_day() ) then + + ! -------------------------------------------------------------------------- + ! This is the main call to FATES dynamics + ! -------------------------------------------------------------------------- + + if ( masterproc ) then + write(iulog,*) 'clm: calling FATES model ', get_nstep() + end if + + call clm_fates%dynamics_driv( nc, bounds_clump, & + atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst, & + frictionvel_inst) + + ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a + ! call to reweight_wrapup, if it's needed at all. + call setFilters( bounds_clump, glc_behavior ) + end if + end if ! use_fates branch @@ -1045,6 +1054,11 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, & soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst, & clm_fates, nc) + + call clm_fates%wrap_update_hifrq_hist(bounds_clump, & + soilbiogeochem_carbonflux_inst, & + soilbiogeochem_carbonstate_inst) + end if diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index c8e0257136..1805e50fb8 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -27,7 +27,7 @@ module histFileMod use FatesInterfaceTypesMod , only : nlevheight use EDTypesMod , only : nfsc use FatesLitterMod , only : ncwd - use EDTypesMod , only : num_elements_fates => num_elements + use PRTGenericMod , only : nelements_fates => num_elements use FatesInterfaceTypesMod , only : numpft_fates => numpft use ncdio_pio diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index e0215c416b..70eb37f70b 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -59,7 +59,8 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_fates_inventory_init use clm_varctl , only : use_fates_fixed_biogeog use clm_varctl , only : fates_inventory_ctrl_filename - + use clm_varctl , only : nu_com + use clm_varctl , only : use_nitrif_denitrif use clm_varcon , only : tfrz use clm_varcon , only : spval use clm_varcon , only : denice @@ -109,6 +110,8 @@ module CLMFatesInterfaceMod use FatesInterfaceMod, only : SetFatesGlobalElements use FatesInterfaceMod , only : allocate_bcin use FatesInterfaceMod , only : allocate_bcout + use FatesInterfaceMod , only : allocate_bcpconst + use FatesInterfaceMod , only : set_bcpconst use FatesInterfaceMod , only : zero_bcs use FatesInterfaceMod , only : SetFatesTime use FatesInterfaceMod , only : set_fates_ctrlparms @@ -118,7 +121,7 @@ module CLMFatesInterfaceMod use FatesRestartInterfaceMod, only : fates_restart_interface_type use EDTypesMod , only : ed_patch_type - use EDTypesMod , only : num_elements + use PRTGenericMod , only : num_elements use FatesInterfaceTypesMod , only : hlm_numlevgrnd use EDMainMod , only : ed_ecosystem_dynamics use EDMainMod , only : ed_update_site @@ -133,7 +136,7 @@ module CLMFatesInterfaceMod use EDCanopyStructureMod , only : canopy_summarization, update_hlm_dynamics use FatesPlantRespPhotosynthMod, only : FatesPlantRespPhotosynthDrive use EDAccumulateFluxesMod , only : AccumulateFluxes_ED - use EDPhysiologyMod , only : FluxIntoLitterPools + use FatesSoilBGCFluxMod , only : FluxIntoLitterPools use FatesPlantHydraulicsMod, only : hydraulics_drive use FatesPlantHydraulicsMod, only : HydrSiteColdStart use FatesPlantHydraulicsMod, only : InitHydrSites @@ -203,6 +206,7 @@ module CLMFatesInterfaceMod procedure, public :: wrap_accumulatefluxes procedure, public :: prep_canopyfluxes procedure, public :: wrap_canopy_radiation + procedure, public :: wrap_update_hifrq_hist procedure, public :: wrap_bgc_summary procedure, public :: TransferZ0mDisp procedure, public :: InterpFileInputs ! Interpolate inputs from files @@ -288,6 +292,30 @@ subroutine CLMFatesGlobals() call set_fates_ctrlparms('max_patch_per_site',ival=(natpft_size-1)) call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode) + + if((trim(nu_com).eq.'ECA') .or. (trim(nu_com).eq.'MIC')) then + call set_fates_ctrlparms('nu_com',cval='ECA') + else + call set_fates_ctrlparms('nu_com',cval='RD') + end if + + + ! These may be in a non-limiting status (ie when supplements) + ! are added, but they are always allocated and cycled non-the less + ! FATES may want to interact differently with other models + ! that don't even have these arrays allocated. + ! FATES also checks that if NO3 is cycled in ELM, then + ! any plant affinity parameters are checked. + + if(use_nitrif_denitrif) then + call set_fates_ctrlparms('nitrogen_spec',ival=1) + else + call set_fates_ctrlparms('nitrogen_spec',ival=2) + end if + + ! Phosphorus is not tracked in CLM + call set_fates_ctrlparms('phosphorus_spec',ival=0) + call set_fates_ctrlparms('spitfire_mode',ival=fates_spitfire_mode) call set_fates_ctrlparms('sf_nofire_def',ival=no_fire) @@ -546,9 +574,19 @@ subroutine init(this, bounds_proc ) ! Allocate the FATES boundary arrays (out) allocate(this%fates(nc)%bc_out(this%fates(nc)%nsites)) + + ! Parameter Constants defined by FATES, but used in ELM + ! Note that FATES has its parameters defined, so we can also set the values + call allocate_bcpconst(this%fates(nc)%bc_pconst,nlevdecomp) + + ! This also needs + call set_bcpconst(this%fates(nc)%bc_pconst,nlevdecomp) + + ! Allocate and Initialize the Boundary Condition Arrays ! These are staticaly allocated at maximums, so ! No information about the patch or cohort structure is needed at this step + do s = 1, this%fates(nc)%nsites @@ -823,6 +861,12 @@ subroutine dynamics_driv(this, nc, bounds_clump, & end do + ! Nutrient uptake fluxes have been accumulating with each short + ! timestep, here, we unload them from the boundary condition + ! structures into the cohort structures. + ! call UnPackNutrientAquisitionBCs(this%fates(nc)%sites, this%fates(nc)%bc_in) + + ! --------------------------------------------------------------------------------- ! Part II: Call the FATES model now that input boundary conditions have been ! provided. @@ -831,21 +875,15 @@ subroutine dynamics_driv(this, nc, bounds_clump, & do s = 1,this%fates(nc)%nsites call ed_ecosystem_dynamics(this%fates(nc)%sites(s), & - this%fates(nc)%bc_in(s)) + this%fates(nc)%bc_in(s), & + this%fates(nc)%bc_out(s)) call ed_update_site(this%fates(nc)%sites(s), & - this%fates(nc)%bc_in(s)) + this%fates(nc)%bc_in(s), & + this%fates(nc)%bc_out(s)) enddo - ! call subroutine to aggregate fates litter output fluxes and - ! package them for handing across interface - call FluxIntoLitterPools(this%fates(nc)%nsites, & - this%fates(nc)%sites, & - this%fates(nc)%bc_in, & - this%fates(nc)%bc_out) - - ! --------------------------------------------------------------------------------- ! Part III: Process FATES output into the dimensions and structures that are part ! of the HLMs API. (column, depth, and litter fractions) @@ -874,7 +912,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! --------------------------------------------------------------------------------- ! Part III.2 (continued). - ! Update diagnostics of the FATES ecosystem structure that are used in the HLM. + ! Update UpdateLdiagnostics of the FATES ecosystem structure that are used in the HLM. ! --------------------------------------------------------------------------------- call this%wrap_update_hlmfates_dyn(nc, & bounds_clump, & @@ -1297,9 +1335,20 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & ! update type stuff, should consolidate (rgk 11-2016) do s = 1,this%fates(nc)%nsites call ed_update_site( this%fates(nc)%sites(s), & - this%fates(nc)%bc_in(s) ) - end do + this%fates(nc)%bc_in(s), & + this%fates(nc)%bc_out(s) ) + + ! This call sends internal fates variables into the + ! output boundary condition structures. Note: this is called + ! internally in fates dynamics as well. + call FluxIntoLitterPools(this%fates(nc)%sites(s), & + this%fates(nc)%bc_in(s), & + this%fates(nc)%bc_out(s)) + + end do + + ! ------------------------------------------------------------------------ ! Re-populate all the hydraulics variables that are dependent ! on the key hydro state variables and plant carbon/geometry @@ -1412,7 +1461,8 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & end do call set_site_properties(this%fates(nc)%nsites, & - this%fates(nc)%sites,this%fates(nc)%bc_in) + this%fates(nc)%sites, & + this%fates(nc)%bc_in) ! ---------------------------------------------------------------------------- ! Initialize Hydraulics Code if turned on @@ -1459,7 +1509,16 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & do s = 1,this%fates(nc)%nsites call ed_update_site(this%fates(nc)%sites(s), & - this%fates(nc)%bc_in(s)) + this%fates(nc)%bc_in(s), & + this%fates(nc)%bc_out(s)) + + ! This call sends internal fates variables into the + ! output boundary condition structures. Note: this is called + ! internally in fates dynamics as well. + call FluxIntoLitterPools(this%fates(nc)%sites(s), & + this%fates(nc)%bc_in(s), & + this%fates(nc)%bc_out(s)) + end do ! ------------------------------------------------------------------------ @@ -1958,12 +2017,6 @@ subroutine wrap_accumulatefluxes(this, nc, fn, filterp) this%fates(nc)%bc_out, & dtime) - - call this%fates_hist%update_history_prod(nc, & - this%fates(nc)%nsites, & - this%fates(nc)%sites, & - dtime) - call t_stopf('fates_wrapaccfluxes') end subroutine wrap_accumulatefluxes @@ -2060,28 +2113,29 @@ end subroutine wrap_canopy_radiation ! ====================================================================================== - subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & - soilbiogeochem_carbonstate_inst) - - + subroutine wrap_update_hifrq_hist(this, bounds_clump, & + soilbiogeochem_carbonflux_inst, & + soilbiogeochem_carbonstate_inst) ! Arguments class(hlm_fates_interface_type), intent(inout) :: this - integer , intent(in) :: nc + type(bounds_type), intent(in) :: bounds_clump type(soilbiogeochem_carbonflux_type), intent(in) :: soilbiogeochem_carbonflux_inst type(soilbiogeochem_carbonstate_type), intent(in) :: soilbiogeochem_carbonstate_inst ! locals real(r8) :: dtime - integer :: s,c + integer :: s, c, nc - call t_startf('fates_wrapbgcsummary') + call t_startf('fates_update_hifrq_hist') associate(& - hr => soilbiogeochem_carbonflux_inst%hr_col, & ! (gC/m2/s) total heterotrophic respiration + hr => soilbiogeochem_carbonflux_inst%hr_col, & ! (gC/m2/s) total heterotrophic respiration totsomc => soilbiogeochem_carbonstate_inst%totsomc_col, & ! (gC/m2) total soil organic matter carbon totlitc => soilbiogeochem_carbonstate_inst%totlitc_col) ! (gC/m2) total litter carbon in BGC pools + nc = bounds_clump%clump_index + ! Summarize Net Fluxes do s = 1, this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) @@ -2093,7 +2147,7 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & dtime = get_step_size_real() ! Update history variables that track these variables - call this%fates_hist%update_history_cbal(nc, & + call this%fates_hist%update_history_hifrq(nc, & this%fates(nc)%nsites, & this%fates(nc)%sites, & this%fates(nc)%bc_in, & @@ -2101,9 +2155,9 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & end associate - call t_stopf('fates_wrapbgcsummary') + call t_stopf('fates_wrap_hifrq_hist') - end subroutine wrap_bgc_summary + end subroutine wrap_update_hifrq_hist ! ====================================================================================== @@ -2148,7 +2202,8 @@ subroutine TransferZ0mDisp(this, bounds_clump, z0m_patch, displa_patch) return end subroutine TransferZ0mDisp - !----------------------------------------------------------------------- + !----------------------------------------------------------------------- + subroutine InterpFileInputs(this, bounds) ! ! !DESCRIPTION: diff --git a/src/utils/clmfates_paraminterfaceMod.F90 b/src/utils/clmfates_paraminterfaceMod.F90 index 474ba12394..01a3328747 100644 --- a/src/utils/clmfates_paraminterfaceMod.F90 +++ b/src/utils/clmfates_paraminterfaceMod.F90 @@ -33,6 +33,7 @@ subroutine FatesReadParameters() use EDParamsMod, only : FatesRegisterParams, FatesReceiveParams use SFParamsMod, only : SpitFireRegisterParams, SpitFireReceiveParams + use PRTInitParamsFATESMod, only : PRTRegisterParams, PRTReceiveParams use FatesSynchronizedParamsMod, only : FatesSynchronizedParamsInst implicit none @@ -50,6 +51,7 @@ subroutine FatesReadParameters() call fates_params%Init() call FatesRegisterParams(fates_params) call SpitFireRegisterParams(fates_params) + call PRTRegisterParams(fates_params) call FatesSynchronizedParamsInst%RegisterParams(fates_params) is_host_file = .false. @@ -60,6 +62,7 @@ subroutine FatesReadParameters() call FatesReceiveParams(fates_params) call SpitFireReceiveParams(fates_params) + call PRTReceiveParams(fates_params) call FatesSynchronizedParamsInst%ReceiveParams(fates_params) call fates_params%Destroy() From 3d95dd0de5e0e88acd4c83104ac373b3111de14e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 8 Sep 2020 11:46:20 -0400 Subject: [PATCH 110/152] Fates CNP fixes, expand namelist range for prt 2 --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- src/main/histFileMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 15 +++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 77594f7c7a..33d64d9c32 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -631,7 +631,7 @@ Toggle to turn on the FATES model + group="clm_inparm" valid_values="1,2"> Switch deciding which nutrient model to use in FATES. diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 1805e50fb8..c3c491a7e6 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -27,7 +27,7 @@ module histFileMod use FatesInterfaceTypesMod , only : nlevheight use EDTypesMod , only : nfsc use FatesLitterMod , only : ncwd - use PRTGenericMod , only : nelements_fates => num_elements + use PRTGenericMod , only : num_elements_fates => num_elements use FatesInterfaceTypesMod , only : numpft_fates => numpft use ncdio_pio diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 70eb37f70b..562a6893a7 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -59,7 +59,6 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_fates_inventory_init use clm_varctl , only : use_fates_fixed_biogeog use clm_varctl , only : fates_inventory_ctrl_filename - use clm_varctl , only : nu_com use clm_varctl , only : use_nitrif_denitrif use clm_varcon , only : tfrz use clm_varcon , only : spval @@ -207,7 +206,6 @@ module CLMFatesInterfaceMod procedure, public :: prep_canopyfluxes procedure, public :: wrap_canopy_radiation procedure, public :: wrap_update_hifrq_hist - procedure, public :: wrap_bgc_summary procedure, public :: TransferZ0mDisp procedure, public :: InterpFileInputs ! Interpolate inputs from files procedure, public :: Init2 ! Initialization after determining subgrid weights @@ -293,12 +291,10 @@ subroutine CLMFatesGlobals() call set_fates_ctrlparms('parteh_mode',ival=fates_parteh_mode) - if((trim(nu_com).eq.'ECA') .or. (trim(nu_com).eq.'MIC')) then - call set_fates_ctrlparms('nu_com',cval='ECA') - else - call set_fates_ctrlparms('nu_com',cval='RD') - end if - + ! CTSM-FATES is not fully coupled (yet) + ! So lets tell fates to use the RD competition mechanism + ! which has fewer boundary conditions (simpler) + call set_fates_ctrlparms('nu_com',cval='RD') ! These may be in a non-limiting status (ie when supplements) ! are added, but they are always allocated and cycled non-the less @@ -2144,6 +2140,9 @@ subroutine wrap_update_hifrq_hist(this, bounds_clump, & this%fates(nc)%bc_in(s)%tot_litc = totlitc(c) end do + + print*,"LSM BGC rates: ",hr(c),totsomc(c),totlitc(c) + dtime = get_step_size_real() ! Update history variables that track these variables From bca9d65ef69fc10bef44204d2cc10c6a3f6ce786 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 17 Sep 2020 12:49:58 -0400 Subject: [PATCH 111/152] FATES CNP coupling. Swapped call sequence order between FATES dynamics and FATES specific soil BGC calls. This allows for processing of high frequency history diagnostics before calls to fates dynamics, which will cause havoc on cohorts and their subsequent creation/dissapearance. --- src/main/clm_driver.F90 | 56 +++++++++++++++-------------- src/utils/clmfates_interfaceMod.F90 | 8 ++--- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 090cf3b988..6afb0c0003 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -1005,32 +1005,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro if ( use_fates) then - if( is_beg_curr_day() ) then - - ! -------------------------------------------------------------------------- - ! This is the main call to FATES dynamics - ! -------------------------------------------------------------------------- - - if ( masterproc ) then - write(iulog,*) 'clm: calling FATES model ', get_nstep() - end if - - call clm_fates%dynamics_driv( nc, bounds_clump, & - atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & - water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & - water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst, & - frictionvel_inst) - - ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a - ! call to reweight_wrapup, if it's needed at all. - call setFilters( bounds_clump, glc_behavior ) - - end if - - end if ! use_fates branch - - - if ( use_fates ) then call EDBGCDyn(bounds_clump, & filter(nc)%num_soilc, filter(nc)%soilc, & @@ -1058,6 +1032,36 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call clm_fates%wrap_update_hifrq_hist(bounds_clump, & soilbiogeochem_carbonflux_inst, & soilbiogeochem_carbonstate_inst) + + + if( is_beg_curr_day() ) then + + ! -------------------------------------------------------------------------- + ! This is the main call to FATES dynamics + ! -------------------------------------------------------------------------- + + if ( masterproc ) then + write(iulog,*) 'clm: calling FATES model ', get_nstep() + end if + + call clm_fates%dynamics_driv( nc, bounds_clump, & + atm2lnd_inst, soilstate_inst, temperature_inst, active_layer_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%wateratm2lndbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst, & + frictionvel_inst) + + ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a + ! call to reweight_wrapup, if it's needed at all. + call setFilters( bounds_clump, glc_behavior ) + + end if + + end if ! use_fates branch + + + if ( use_fates ) then + + end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 562a6893a7..d778aa1260 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -136,6 +136,7 @@ module CLMFatesInterfaceMod use FatesPlantRespPhotosynthMod, only : FatesPlantRespPhotosynthDrive use EDAccumulateFluxesMod , only : AccumulateFluxes_ED use FatesSoilBGCFluxMod , only : FluxIntoLitterPools + use FatesSoilBGCFluxMod , only : UnPackNutrientAquisitionBCs use FatesPlantHydraulicsMod, only : hydraulics_drive use FatesPlantHydraulicsMod, only : HydrSiteColdStart use FatesPlantHydraulicsMod, only : InitHydrSites @@ -860,7 +861,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! Nutrient uptake fluxes have been accumulating with each short ! timestep, here, we unload them from the boundary condition ! structures into the cohort structures. - ! call UnPackNutrientAquisitionBCs(this%fates(nc)%sites, this%fates(nc)%bc_in) + call UnPackNutrientAquisitionBCs(this%fates(nc)%sites, this%fates(nc)%bc_in) ! --------------------------------------------------------------------------------- @@ -877,7 +878,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call ed_update_site(this%fates(nc)%sites(s), & this%fates(nc)%bc_in(s), & this%fates(nc)%bc_out(s)) - + enddo ! --------------------------------------------------------------------------------- @@ -2140,9 +2141,6 @@ subroutine wrap_update_hifrq_hist(this, bounds_clump, & this%fates(nc)%bc_in(s)%tot_litc = totlitc(c) end do - - print*,"LSM BGC rates: ",hr(c),totsomc(c),totlitc(c) - dtime = get_step_size_real() ! Update history variables that track these variables From 68b913bd07b2b13f15f3653441de47fae0028cd1 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 18 Sep 2020 11:19:16 -0400 Subject: [PATCH 112/152] FATES CNP, added an ERS test for fates_parteh_mode=2, which includes a testmod dir that activates its namelist entry --- cime_config/testdefs/testlist_clm.xml | 10 ++++++++++ .../testmods_dirs/clm/FatesPRT2/include_user_mods | 1 + .../testdefs/testmods_dirs/clm/FatesPRT2/user_nl_clm | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesPRT2/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesPRT2/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index d5be518d67..a0caf55a29 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1812,6 +1812,16 @@ + + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesPRT2/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesPRT2/include_user_mods new file mode 100644 index 0000000000..4c7aa0f2b4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesPRT2/include_user_mods @@ -0,0 +1 @@ +../Fates diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesPRT2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesPRT2/user_nl_clm new file mode 100644 index 0000000000..400fa7cfd4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesPRT2/user_nl_clm @@ -0,0 +1,5 @@ +hist_mfilt = 365 +hist_nhtfrq = -24 +hist_empty_htapes = .false. +fates_parteh_mode = 2 +fates_spitfire_mode = 1 \ No newline at end of file From 503112aa7b394199a705117aab02320d9c51b81d Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 21 Sep 2020 10:37:49 -0600 Subject: [PATCH 113/152] updating fates default parameter file. --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index aa587a33c4..b84fe61cd8 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -400,7 +400,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -lnd/clm2/paramdata/fates_params_api.11.1.0_12pft_c200529.nc +lnd/clm2/paramdata/fates_params_api.14.0.0_12pft_c200921.nc From 53ee045258a69eb3157e0daab77b5fc018da43fc Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 24 Sep 2020 15:14:07 -0400 Subject: [PATCH 114/152] updated fates allvars list of history variables --- .../clm/FatesAllVars/user_nl_clm | 68 +++++++++++-------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm index 4d488d3c33..cc7d37aab9 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm @@ -3,31 +3,43 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .false. fates_spitfire_mode = 1 -hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE','GPP_BY_AGE','PARSUN_Z_CNLF','PARSHA_Z_CNLF','PARSUN_Z_CNLFPFT', - 'PARSHA_Z_CNLFPFT','PARSUN_Z_CAN','PARSHA_Z_CAN','LAISUN_Z_CNLF','LAISHA_Z_CNLF','LAISUN_Z_CNLFPFT','LAISHA_Z_CNLFPFT', - 'LAISUN_TOP_CAN','LAISHA_TOP_CAN','FABD_SUN_CNLFPFT','FABD_SHA_CNLFPFT','FABI_SUN_CNLFPFT','FABI_SHA_CNLFPFT', - 'FABD_SUN_CNLF','FABD_SHA_CNLF','FABI_SUN_CNLF','FABI_SHA_CNLF','FABD_SUN_TOPLF_BYCANLAYER','FABD_SHA_TOPLF_BYCANLAYER', - 'FABI_SUN_TOPLF_BYCANLAYER','FABI_SHA_TOPLF_BYCANLAYER','NET_C_UPTAKE_CNLF','CROWNAREA_CNLF', - 'MORTALITY_CARBONFLUX_CANOPY','MORTALITY_CARBONFLUX_UNDERSTORY','NPLANT_SCAG','NPLANT_CANOPY_SCAG','NPLANT_UNDERSTORY_SCAG', - 'DDBH_CANOPY_SCAG','DDBH_UNDERSTORY_SCAG','MORTALITY_CANOPY_SCAG','MORTALITY_UNDERSTORY_SCAG','GPP_SCPF','GPP_CANOPY_SCPF', - 'AR_CANOPY_SCPF','GPP_UNDERSTORY_SCPF','AR_UNDERSTORY_SCPF','NPP_SCPF','NPP_LEAF_SCPF','NPP_SEED_SCPF','NPP_FNRT_SCPF', - 'NPP_BGSW_SCPF','NPP_BGDW_SCPF','NPP_AGSW_SCPF','NPP_AGDW_SCPF','NPP_STOR_SCPF','DDBH_SCPF','DDBH_CANOPY_SCPF', - 'DDBH_UNDERSTORY_SCPF','BA_SCPF','NPLANT_SCPF','M1_SCPF','M2_SCPF','M3_SCPF','M4_SCPF','M5_SCPF','M6_SCPF','M7_SCPF', - 'MORTALITY_CANOPY_SCPF','BSTOR_CANOPY_SCPF','BLEAF_CANOPY_SCPF','NPLANT_CANOPY_SCPF','MORTALITY_UNDERSTORY_SCPF', - 'BSTOR_UNDERSTORY_SCPF','BLEAF_UNDERSTORY_SCPF','NPLANT_UNDERSTORY_SCPF','CWD_AG_CWDSC','CWD_BG_CWDSC','CWD_AG_IN_CWDSC', - 'CWD_BG_IN_CWDSC','CWD_AG_OUT_CWDSC','CWD_BG_OUT_CWDSC','AR_SCPF','AR_GROW_SCPF','AR_MAINT_SCPF','AR_DARKM_SCPF','AR_AGSAPM_SCPF', - 'AR_CROOTM_SCPF','AR_FROOTM_SCPF','DDBH_CANOPY_SCLS','DDBH_UNDERSTORY_SCLS','YESTERDAYCANLEV_CANOPY_SCLS', - 'YESTERDAYCANLEV_UNDERSTORY_SCLS','BA_SCLS','DEMOTION_RATE_SCLS','PROMOTION_RATE_SCLS','NPLANT_CANOPY_SCLS', - 'MORTALITY_CANOPY_SCLS','NPLANT_UNDERSTORY_SCLS','MORTALITY_UNDERSTORY_SCLS','TRIMMING_CANOPY_SCLS','TRIMMING_UNDERSTORY_SCLS', - 'CROWN_AREA_CANOPY_SCLS','CROWN_AREA_UNDERSTORY_SCLS','LEAF_MD_CANOPY_SCLS','ROOT_MD_CANOPY_SCLS','CARBON_BALANCE_CANOPY_SCLS', - 'SEED_PROD_CANOPY_SCLS', - 'NPP_LEAF_CANOPY_SCLS','NPP_FROOT_CANOPY_SCLS','NPP_BSW_CANOPY_SCLS','NPP_BDEAD_CANOPY_SCLS','NPP_BSEED_CANOPY_SCLS', - 'NPP_STORE_CANOPY_SCLS','RDARK_CANOPY_SCLS','LIVESTEM_MR_CANOPY_SCLS','LIVECROOT_MR_CANOPY_SCLS','FROOT_MR_CANOPY_SCLS', - 'RESP_G_CANOPY_SCLS','RESP_M_CANOPY_SCLS','LEAF_MD_UNDERSTORY_SCLS','ROOT_MD_UNDERSTORY_SCLS','CARBON_BALANCE_UNDERSTORY_SCLS', - 'SEED_PROD_UNDERSTORY_SCLS', - 'NPP_LEAF_UNDERSTORY_SCLS','NPP_FROOT_UNDERSTORY_SCLS','NPP_BSW_UNDERSTORY_SCLS', - 'NPP_BDEAD_UNDERSTORY_SCLS','NPP_BSEED_UNDERSTORY_SCLS','NPP_STORE_UNDERSTORY_SCLS','RDARK_UNDERSTORY_SCLS', - 'LIVESTEM_MR_UNDERSTORY_SCLS','LIVECROOT_MR_UNDERSTORY_SCLS','FROOT_MR_UNDERSTORY_SCLS','RESP_G_UNDERSTORY_SCLS', - 'RESP_M_UNDERSTORY_SCLS','LITTER_IN_ELEM','LITTER_OUT_ELEM','SEED_BANK_ELEM','SEEDS_IN_LOCAL_ELEM','SEEDS_IN_EXTERN_ELEM', - 'SEED_GERM_ELEM','SEED_DECAY','CBALANCE_ERROR_FATES','ERROR_FATES','LITTER_FINES_AG_ELEM','LITTER_FINES_BG_ELEM','LITTER_CWD_BG_ELEM', - 'LITTER_CWD_AG_ELEM','LITTER_CWD' +hist_fincl1 = 'PFTcrownarea','PFTcanopycrownarea','NCL_BY_AGE','NPATCH_BY_AGE', +'BIOMASS_BY_AGE','SECONDARY_FOREST_FRACTION','WOOD_PRODUCT','SECONDARY_FOREST_BIOMASS', +'SECONDARY_AREA_AGE_ANTHRO_DIST','SECONDARY_AREA_PATCH_AGE_DIST','C_STOMATA_BY_AGE','C_LBLAYER_BY_AGE', +'NPP_BY_AGE','GPP_BY_AGE','PARSUN_Z_CNLF','PARSHA_Z_CNLF', +'PARSUN_Z_CNLFPFT','PARSHA_Z_CNLFPFT','PARSUN_Z_CAN','PARSHA_Z_CAN', +'LAISUN_Z_CNLF','LAISHA_Z_CNLF','LAISUN_Z_CNLFPFT','LAISHA_Z_CNLFPFT', +'LAISUN_TOP_CAN','LAISHA_TOP_CAN','FABD_SUN_CNLFPFT','FABD_SHA_CNLFPFT', +'FABI_SUN_CNLFPFT','FABI_SHA_CNLFPFT','FABD_SUN_CNLF','FABD_SHA_CNLF', +'FABI_SUN_CNLF','FABI_SHA_CNLF','PARPROF_DIR_CNLFPFT','PARPROF_DIF_CNLFPFT', +'PARPROF_DIR_CNLF','PARPROF_DIF_CNLF','FABD_SUN_TOPLF_BYCANLAYER', +'FABD_SHA_TOPLF_BYCANLAYER','FABI_SUN_TOPLF_BYCANLAYER','FABI_SHA_TOPLF_BYCANLAYER', +'NET_C_UPTAKE_CNLF','CROWNAREA_CNLF','NPLANT_CANOPY_SCAG','NPLANT_UNDERSTORY_SCAG', +'DDBH_CANOPY_SCAG','DDBH_UNDERSTORY_SCAG','MORTALITY_CANOPY_SCAG','MORTALITY_UNDERSTORY_SCAG', +'NPLANT_SCAGPFT','NPP_AGEPFT','BIOMASS_AGEPFT','GPP_SCPF','GPP_CANOPY_SCPF', +'AR_CANOPY_SCPF','GPP_UNDERSTORY_SCPF','AR_UNDERSTORY_SCPF','NPP_SCPF', +'NPP_LEAF_SCPF','NPP_SEED_SCPF','NPP_FNRT_SCPF','NPP_BGSW_SCPF','NPP_BGDW_SCPF','NPP_AGSW_SCPF', +'NPP_AGDW_SCPF','NPP_STOR_SCPF','DDBH_SCPF','GROWTHFLUX_SCPF','GROWTHFLUX_FUSION_SCPF', +'DDBH_CANOPY_SCPF','DDBH_UNDERSTORY_SCPF','BA_SCPF','AGB_SCPF','NPLANT_SCPF', +'NPLANT_CAPF','M1_SCPF','M2_SCPF','M3_SCPF','M4_SCPF','M5_SCPF','CROWNFIREMORT_SCPF','CAMBIALFIREMORT_SCPF', +'M6_SCPF','M7_SCPF','M8_SCPF','M9_SCPF','M10_SCPF', +'M10_CAPF','MORTALITY_CANOPY_SCPF','C13disc_SCPF','BSTOR_CANOPY_SCPF','BLEAF_CANOPY_SCPF', +'NPLANT_CANOPY_SCPF','MORTALITY_UNDERSTORY_SCPF','BSTOR_UNDERSTORY_SCPF','BLEAF_UNDERSTORY_SCPF', +'NPLANT_UNDERSTORY_SCPF','CWD_AG_CWDSC','CWD_BG_CWDSC','CWD_AG_IN_CWDSC', +'CWD_BG_IN_CWDSC','CWD_AG_OUT_CWDSC','CWD_BG_OUT_CWDSC','AR_SCPF','AR_GROW_SCPF', +'AR_MAINT_SCPF','AR_DARKM_SCPF','AR_AGSAPM_SCPF','AR_CROOTM_SCPF','AR_FROOTM_SCPF', +'YESTERDAYCANLEV_CANOPY_SCLS','YESTERDAYCANLEV_UNDERSTORY_SCLS', +'BIOMASS_SCLS','DEMOTION_RATE_SCLS','PROMOTION_RATE_SCLS','SAI_CANOPY_SCLS','SAI_UNDERSTORY_SCLS', +'CARBON_BALANCE_CANOPY_SCLS','CARBON_BALANCE_UNDERSTORY_SCLS','TRIMMING_CANOPY_SCLS', +'TRIMMING_UNDERSTORY_SCLS','CROWN_AREA_CANOPY_SCLS','CROWN_AREA_UNDERSTORY_SCLS', +'LEAF_MD_CANOPY_SCLS','ROOT_MD_CANOPY_SCLS','BSTORE_MD_CANOPY_SCLS','BDEAD_MD_CANOPY_SCLS', +'BSW_MD_CANOPY_SCLS','SEED_PROD_CANOPY_SCLS','NPP_LEAF_CANOPY_SCLS','NPP_FROOT_CANOPY_SCLS', +'NPP_BSW_CANOPY_SCLS','NPP_BDEAD_CANOPY_SCLS','NPP_BSEED_CANOPY_SCLS', +'NPP_STORE_CANOPY_SCLS','RDARK_CANOPY_SCLS', +'LIVESTEM_MR_CANOPY_SCLS','LIVECROOT_MR_CANOPY_SCLS','FROOT_MR_CANOPY_SCLS','RESP_G_CANOPY_SCLS', +'RESP_M_CANOPY_SCLS','LEAF_MD_UNDERSTORY_SCLS','ROOT_MD_UNDERSTORY_SCLS','BSTORE_MD_UNDERSTORY_SCLS', +'BDEAD_MD_UNDERSTORY_SCLS','BSW_MD_UNDERSTORY_SCLS','SEED_PROD_UNDERSTORY_SCLS','NPP_LEAF_UNDERSTORY_SCLS', +'NPP_FROOT_UNDERSTORY_SCLS','NPP_BSW_UNDERSTORY_SCLS','NPP_BDEAD_UNDERSTORY_SCLS','NPP_BSEED_UNDERSTORY_SCLS', +'NPP_STORE_UNDERSTORY_SCLS','RDARK_UNDERSTORY_SCLS','LIVESTEM_MR_UNDERSTORY_SCLS','LIVECROOT_MR_UNDERSTORY_SCLS', +'FROOT_MR_UNDERSTORY_SCLS','RESP_G_UNDERSTORY_SCLS','RESP_M_UNDERSTORY_SCLS','TOTVEGC_SCPF', +'LEAFC_SCPF','FNRTC_SCPF','SAPWC_SCPF','STOREC_SCPF','REPROC_SCPF','CEFFLUX_SCPF' From f6893b1a704a0901da4791988885b8ab47b7fdf9 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 24 Sep 2020 13:58:43 -0600 Subject: [PATCH 115/152] Changed the fates parteh 2 test to debug mode, removed an untested variable from fates allvars test list --- cime_config/testdefs/testlist_clm.xml | 2 +- cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index a0caf55a29..82ea2337a4 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1812,7 +1812,7 @@ - + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm index cc7d37aab9..cd1daa4eea 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm @@ -23,7 +23,7 @@ hist_fincl1 = 'PFTcrownarea','PFTcanopycrownarea','NCL_BY_AGE','NPATCH_BY_ 'DDBH_CANOPY_SCPF','DDBH_UNDERSTORY_SCPF','BA_SCPF','AGB_SCPF','NPLANT_SCPF', 'NPLANT_CAPF','M1_SCPF','M2_SCPF','M3_SCPF','M4_SCPF','M5_SCPF','CROWNFIREMORT_SCPF','CAMBIALFIREMORT_SCPF', 'M6_SCPF','M7_SCPF','M8_SCPF','M9_SCPF','M10_SCPF', -'M10_CAPF','MORTALITY_CANOPY_SCPF','C13disc_SCPF','BSTOR_CANOPY_SCPF','BLEAF_CANOPY_SCPF', +'M10_CAPF','MORTALITY_CANOPY_SCPF','BSTOR_CANOPY_SCPF','BLEAF_CANOPY_SCPF', 'NPLANT_CANOPY_SCPF','MORTALITY_UNDERSTORY_SCPF','BSTOR_UNDERSTORY_SCPF','BLEAF_UNDERSTORY_SCPF', 'NPLANT_UNDERSTORY_SCPF','CWD_AG_CWDSC','CWD_BG_CWDSC','CWD_AG_IN_CWDSC', 'CWD_BG_IN_CWDSC','CWD_AG_OUT_CWDSC','CWD_BG_OUT_CWDSC','AR_SCPF','AR_GROW_SCPF', From 75d2118d99bd8579e41e19a4085397149c27b81e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 24 Sep 2020 14:24:08 -0600 Subject: [PATCH 116/152] adding update for daily history output to FatesHydro testmod for ERS_D_Ld5 test --- cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm index 9b6cebc7a5..bd4ddb8b3e 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesHydro/user_nl_clm @@ -1,3 +1,5 @@ +hist_mfilt = 365 +hist_nhtfrq = -24 hist_empty_htapes = .true. use_fates_planthydro= .true. hist_fincl1 = 'FATES_ERRH2O_SCPF','FATES_TRAN_SCPF', From bd9e8ad751564903451533d770ec97e3d4f828ff Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 24 Sep 2020 16:15:07 -0600 Subject: [PATCH 117/152] Updating fates pointer to 1.42 api 14 --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index a776c6a271..448bb39a21 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.40.3_api.13.0.1 +tag = sci.1.42.0_api.14.0.0 required = True [PTCLM] From 332beefec6389f729f13d2b5093eb7ba41ff659d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 24 Sep 2020 22:50:47 -0700 Subject: [PATCH 118/152] cleanup typo and empty logic set --- src/main/clm_driver.F90 | 8 -------- src/utils/clmfates_interfaceMod.F90 | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 6afb0c0003..561bbe0dff 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -1058,14 +1058,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro end if ! use_fates branch - - if ( use_fates ) then - - - - end if - - ! ============================================================================ ! Create summaries of water diagnostic terms ! ============================================================================ diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d778aa1260..1ed29195e9 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -909,7 +909,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! --------------------------------------------------------------------------------- ! Part III.2 (continued). - ! Update UpdateLdiagnostics of the FATES ecosystem structure that are used in the HLM. + ! Update diagnostics of the FATES ecosystem structure that are used in the HLM. ! --------------------------------------------------------------------------------- call this%wrap_update_hlmfates_dyn(nc, & bounds_clump, & From 81fe6ead18ac7df2f1fa4f14342aa76cd67ceb76 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 25 Sep 2020 14:12:02 -0700 Subject: [PATCH 119/152] adding soilbiogeochem scalar outputs pass to fates bc_in --- src/utils/clmfates_interfaceMod.F90 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 1ed29195e9..140c74267c 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -799,6 +799,11 @@ subroutine dynamics_driv(this, nc, bounds_clump, & nlevsoil = this%fates(nc)%bc_in(s)%nlevsoil + ! Decomposition fluxes + this%fates(nc)%bc_in(s)%w_scalar_sisl(1:nlevsoil) = soilbiogeochem_carbonflux_inst%w_scalar_col(c,1:nlevsoil) + this%fates(nc)%bc_in(s)%t_scalar_sisl(1:nlevsoil) = soilbiogeochem_carbonflux_inst%t_scalar_col(c,1:nlevsoil) + + ! Soil water this%fates(nc)%bc_in(s)%h2o_liqvol_sl(1:nlevsoil) = & waterstatebulk_inst%h2osoi_vol_col(c,1:nlevsoil) From 4fec1b1bffe26859236ce95a33f0476560808be4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 8 Oct 2020 10:09:14 -0700 Subject: [PATCH 120/152] updating fates tag to latest --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index a776c6a271..436f5ae996 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.40.3_api.13.0.1 +tag = sci.1.42.4_api.14.0.0 required = True [PTCLM] From 68054ec76f089578b5ff4364872f4b74c01b4960 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 29 Oct 2020 12:10:26 -0700 Subject: [PATCH 121/152] updating externals_CLM.cfg --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 448bb39a21..91a3403f5d 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.42.0_api.14.0.0 +tag = sci.1.43.0_api.14.1.0 required = True [PTCLM] From 7ae28f2b7243d56d2985fcc26dacf1796e338513 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 2 Nov 2020 11:56:42 -0800 Subject: [PATCH 122/152] fixing merge de-conflict error in externals tags --- Externals_CLM.cfg | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 72d7fb1c4e..91a3403f5d 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,13 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -<<<<<<< HEAD tag = sci.1.43.0_api.14.1.0 -||||||| c724747c -tag = sci.1.42.0_api.14.0.0 -======= -tag = sci.1.42.4_api.14.0.0 ->>>>>>> fates_main_api required = True [PTCLM] From d828aa0d7fdd8e0caf5ea7bb5a31a339d17fef45 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 18 Nov 2020 16:56:13 -0800 Subject: [PATCH 123/152] initial attempt at creating new age x fuel size class dimension --- src/main/histFileMod.F90 | 11 +++++++++++ src/utils/clmfates_interfaceMod.F90 | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index ffb034cd6d..32cbefb932 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -2092,6 +2092,7 @@ subroutine htape_create (t, histrest) call ncd_defdim(lnfid, 'fates_levelpft', num_elements_fates * numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levelcwd', num_elements_fates * ncwd, dimid) call ncd_defdim(lnfid, 'fates_levelage', num_elements_fates * nlevage, dimid) + call ncd_defdim(lnfid, 'fates_levagenfsc', nlevage * nfsc, dimid) end if if ( .not. lhistrest )then @@ -2640,6 +2641,12 @@ subroutine htape_timeconst(t, mode) long_name='FATES pft map into patch age x pft', units='-', ncid=nfid(t)) call ncd_defvar(varname='fates_agmap_levagepft', xtype=ncd_int, dim1name='fates_levagepft', & long_name='FATES age-class map into patch age x pft', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_agmap_levagenfsc', xtype=ncd_int, dim1name='fates_levagenfsc', & + long_name='FATES age-class map into patch age x fuel size', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_fscmap_levagenfsc', xtype=ncd_int, dim1name='fates_levagenfsc', & + long_name='FATES fuel size-class map into patch age x fuel size', units='-', ncid=nfid(t)) + + end if @@ -2679,6 +2686,8 @@ subroutine htape_timeconst(t, mode) call ncd_io(varname='fates_pftmap_levscagpft',data=fates_hdim_pftmap_levscagpft, ncid=nfid(t), flag='write') call ncd_io(varname='fates_pftmap_levagepft',data=fates_hdim_pftmap_levagepft, ncid=nfid(t), flag='write') call ncd_io(varname='fates_agmap_levagepft',data=fates_hdim_agmap_levagepft, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_agmap_levagenfsc',data=fates_hdim_agmap_levagenfsc, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_fscmap_levagenfsc',data=fates_hdim_fscmap_levagenfsc, ncid=nfid(t), flag='write') end if endif @@ -4946,6 +4955,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, num2d = num_elements_fates*ncwd case ('fates_levelage') num2d = num_elements_fates*nlevage + case ('fates_levagenfsc') + num2d = nlevage*nfsc case('cft') if (cft_size > 0) then num2d = cft_size diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 140c74267c..d98d5508e8 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2363,7 +2363,7 @@ subroutine init_history_io(this,bounds_proc) use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8 use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8 use FatesIOVariableKindMod, only : site_height_r8, site_elem_r8, site_elpft_r8 - use FatesIOVariableKindMod, only : site_elcwd_r8, site_elage_r8 + use FatesIOVariableKindMod, only : site_elcwd_r8, site_elage_r8, site_agenfsc_r8 use FatesIODimensionsMod, only : fates_bounds_type @@ -2502,7 +2502,7 @@ subroutine init_history_io(this,bounds_proc) site_fuel_r8, site_cwdsc_r8, & site_can_r8,site_cnlf_r8, site_cnlfpft_r8, site_scag_r8, & site_scagpft_r8, site_agepft_r8, site_elem_r8, site_elpft_r8, & - site_elcwd_r8, site_elage_r8) + site_elcwd_r8, site_elage_r8, site_agenfsc_r8) d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index @@ -2876,6 +2876,10 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%elage_begin = 1 fates%elage_end = num_elements * nlevage + fates%agenfsc_begin = 1 + fates%agenfsc_end = nlevage * nfsc + + call t_stopf('fates_hlm2fatesbnds') end subroutine hlm_bounds_to_fates_bounds From aec6dd0a5e1c1fc1446572918fe225f9c4af1d34 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 18 Nov 2020 22:46:33 -0800 Subject: [PATCH 124/152] change naming of age x fuel size class to agefuel --- src/main/histFileMod.F90 | 12 ++++++------ src/utils/clmfates_interfaceMod.F90 | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 32cbefb932..857590464a 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -2092,7 +2092,7 @@ subroutine htape_create (t, histrest) call ncd_defdim(lnfid, 'fates_levelpft', num_elements_fates * numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levelcwd', num_elements_fates * ncwd, dimid) call ncd_defdim(lnfid, 'fates_levelage', num_elements_fates * nlevage, dimid) - call ncd_defdim(lnfid, 'fates_levagenfsc', nlevage * nfsc, dimid) + call ncd_defdim(lnfid, 'fates_levagefuel', nlevage * nfsc, dimid) end if if ( .not. lhistrest )then @@ -2641,9 +2641,9 @@ subroutine htape_timeconst(t, mode) long_name='FATES pft map into patch age x pft', units='-', ncid=nfid(t)) call ncd_defvar(varname='fates_agmap_levagepft', xtype=ncd_int, dim1name='fates_levagepft', & long_name='FATES age-class map into patch age x pft', units='-', ncid=nfid(t)) - call ncd_defvar(varname='fates_agmap_levagenfsc', xtype=ncd_int, dim1name='fates_levagenfsc', & + call ncd_defvar(varname='fates_agmap_levagefuel', xtype=ncd_int, dim1name='fates_levagefuel', & long_name='FATES age-class map into patch age x fuel size', units='-', ncid=nfid(t)) - call ncd_defvar(varname='fates_fscmap_levagenfsc', xtype=ncd_int, dim1name='fates_levagenfsc', & + call ncd_defvar(varname='fates_fscmap_levagefuel', xtype=ncd_int, dim1name='fates_levagefuel', & long_name='FATES fuel size-class map into patch age x fuel size', units='-', ncid=nfid(t)) @@ -2686,8 +2686,8 @@ subroutine htape_timeconst(t, mode) call ncd_io(varname='fates_pftmap_levscagpft',data=fates_hdim_pftmap_levscagpft, ncid=nfid(t), flag='write') call ncd_io(varname='fates_pftmap_levagepft',data=fates_hdim_pftmap_levagepft, ncid=nfid(t), flag='write') call ncd_io(varname='fates_agmap_levagepft',data=fates_hdim_agmap_levagepft, ncid=nfid(t), flag='write') - call ncd_io(varname='fates_agmap_levagenfsc',data=fates_hdim_agmap_levagenfsc, ncid=nfid(t), flag='write') - call ncd_io(varname='fates_fscmap_levagenfsc',data=fates_hdim_fscmap_levagenfsc, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_agmap_levagefuel',data=fates_hdim_agmap_levagefuel, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_fscmap_levagefuel',data=fates_hdim_fscmap_levagefuel, ncid=nfid(t), flag='write') end if endif @@ -4955,7 +4955,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, num2d = num_elements_fates*ncwd case ('fates_levelage') num2d = num_elements_fates*nlevage - case ('fates_levagenfsc') + case ('fates_levagefuel') num2d = nlevage*nfsc case('cft') if (cft_size > 0) then diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d98d5508e8..ab62a6cb6f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2363,7 +2363,7 @@ subroutine init_history_io(this,bounds_proc) use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8 use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8 use FatesIOVariableKindMod, only : site_height_r8, site_elem_r8, site_elpft_r8 - use FatesIOVariableKindMod, only : site_elcwd_r8, site_elage_r8, site_agenfsc_r8 + use FatesIOVariableKindMod, only : site_elcwd_r8, site_elage_r8, site_agefuel_r8 use FatesIODimensionsMod, only : fates_bounds_type @@ -2502,7 +2502,7 @@ subroutine init_history_io(this,bounds_proc) site_fuel_r8, site_cwdsc_r8, & site_can_r8,site_cnlf_r8, site_cnlfpft_r8, site_scag_r8, & site_scagpft_r8, site_agepft_r8, site_elem_r8, site_elpft_r8, & - site_elcwd_r8, site_elage_r8, site_agenfsc_r8) + site_elcwd_r8, site_elage_r8, site_agefuel_r8) d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index @@ -2876,8 +2876,8 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%elage_begin = 1 fates%elage_end = num_elements * nlevage - fates%agenfsc_begin = 1 - fates%agenfsc_end = nlevage * nfsc + fates%agefuel_begin = 1 + fates%agefuel_end = nlevage * nfsc call t_stopf('fates_hlm2fatesbnds') From 0392347e51747abf16039b2d4771cc97785be987 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 18 Nov 2020 23:02:07 -0800 Subject: [PATCH 125/152] fixing error due to missing use of FatesInterfaceTypesMod --- src/main/histFileMod.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 857590464a..d7be796315 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -2537,6 +2537,8 @@ subroutine htape_timeconst(t, mode) use FatesInterfaceTypesMod, only : fates_hdim_cwdmap_levelcwd use FatesInterfaceTypesMod, only : fates_hdim_elmap_levelage use FatesInterfaceTypesMod, only : fates_hdim_agemap_levelage + use FatesInterfaceTypesMod, only : fates_hdim_agmap_levagefuel + use FatesInterfaceTypesMod, only : fates_hdim_fscmap_levagefuel ! From 77790c1d438823e5828673ea2346391b4e07e169 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 7 Dec 2020 14:28:18 -0800 Subject: [PATCH 126/152] updated externals tag for fates --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 91a3403f5d..6412efffe5 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.43.0_api.14.1.0 +tag = sci.1.43.2_api.14.2.0 required = True [PTCLM] From 1e1562777e061d6b70a203c6abb9a2880fd7e5ea Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 18 Dec 2020 00:52:39 -0800 Subject: [PATCH 127/152] fixing calls to refactored CNFireFactoryMod --- src/biogeochem/CNFireFactoryMod.F90 | 3 +-- src/utils/clmfates_interfaceMod.F90 | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index 603521a209..9ec8f8254d 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -17,7 +17,7 @@ module CNFireFactoryMod ! !PUBLIC ROUTINES: public :: CNFireReadNML ! read the fire namelist public :: create_cnfire_method ! create an object of class fire_method_type - public :: create_fates_fire_data_method ! create an object of class cnfire_method_type + public :: create_fates_fire_data_method ! create an object of class fates_fire_base_type ! These parameters set the ranges of the cases in subroutine ! create_fates_fire_data_method. We declare them public in order to @@ -144,7 +144,6 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) ! ! !USES: use clm_varctl, only: fates_spitfire_mode - use CNFireMethodMod, only: cnfire_method_type use FATESFireBase, only: fates_fire_base_type use FATESFireNoDataMod, only: fates_fire_no_data_type use FATESFireDataMod, only: fates_fire_data_type diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index ab62a6cb6f..1d1ee04baf 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2238,7 +2238,7 @@ subroutine InterpFileInputs(this, bounds) call t_startf('fates_interpfileinputs') - call this%fates_fire_data_method%CNFireInterp(bounds) + call this%fates_fire_data_method%FireInterp(bounds) call t_stopf('fates_interpfileinputs') @@ -2266,7 +2266,7 @@ subroutine Init2(this, bounds, NLFilename) call t_startf('fates_init2') - call this%fates_fire_data_method%CNFireInit(bounds, NLFilename) + call this%fates_fire_data_method%FireInit(bounds, NLFilename) call t_stopf('fates_init2') From 3dd33b15e66b50e9b1f31a99c8763206fed2702b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 14 Jan 2021 09:41:08 -0800 Subject: [PATCH 128/152] simple CNFireArea fix attempt --- src/biogeochem/FATESFireBase.F90 | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90 index fc3f2bd4c5..b439adbbc0 100644 --- a/src/biogeochem/FATESFireBase.F90 +++ b/src/biogeochem/FATESFireBase.F90 @@ -24,6 +24,8 @@ module FATESFireBase procedure(InitAccBuffer_interface), public, deferred :: InitAccBuffer ! Initialize accumulation processes procedure(InitAccVars_interface), public, deferred :: InitAccVars ! Initialize accumulation variables procedure(UpdateAccVars_interface), public, deferred :: UpdateAccVars ! Update/extract accumulations vars + + procedure, public :: CNFireArea end type fates_fire_base_type @@ -103,6 +105,39 @@ subroutine UpdateAccVars_interface (this, bounds) end subroutine UpdateAccVars_interface end interface + + subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & + atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, & + waterdiagnosticbulk_inst, wateratm2lndbulk_inst, & + cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) + ! + ! !DESCRIPTION: + ! Computes column-level burned area + ! + ! !USES: + ! + ! !ARGUMENTS: + class(cnfire_base_type) :: this + type(bounds_type) , intent(in) :: bounds + integer , intent(in) :: num_soilc ! number of soil columns in filter + integer , intent(in) :: filter_soilc(:) ! filter for soil columns + integer , intent(in) :: num_soilp ! number of soil patches in filter + integer , intent(in) :: filter_soilp(:) ! filter for soil patches + type(atm2lnd_type) , intent(in) :: atm2lnd_inst + type(energyflux_type) , intent(in) :: energyflux_inst + type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst + type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst + type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst + type(cnveg_state_type) , intent(inout) :: cnveg_state_inst + type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + real(r8) , intent(in) :: totlitc_col(bounds%begc:) + real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) + real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) + ! + + call endrun( 'cnfire_base::CNFireArea: this method MUST be implemented!' ) + +end subroutine CNFireArea !--------------------------------------------------------------------- end module FATESFireBase From fa0a369c038a8ba2fca8b218bcb174c008525756 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 14 Jan 2021 10:25:30 -0800 Subject: [PATCH 129/152] adding missing use calls --- src/biogeochem/FATESFireBase.F90 | 61 +++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90 index b439adbbc0..d8b1df98df 100644 --- a/src/biogeochem/FATESFireBase.F90 +++ b/src/biogeochem/FATESFireBase.F90 @@ -5,8 +5,20 @@ module FATESFireBase ! Abstract base class for FATES fire data object ! ! !USES: - use CNFireBaseMod , only: cnfire_base_type - ! + use CNFireBaseMod , only : cnfire_base_type + use decompMod , only : bounds_type + use atm2lndType , only : atm2lnd_type + use EnergyFluxType , only : energyflux_type + use SaturatedExcessRunoffMod , only : saturated_excess_runoff_type + use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type + use Wateratm2lndBulkType , only : wateratm2lndbulk_type + use WaterStateBulkType , only : waterstatebulk_type + use WaterStateBulkType , only : waterstatebulk_type + use SoilStateType , only : soilstate_type + use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type + use CNVegStateType , only : cnveg_state_type + use CNVegCarbonStateType , only : cnveg_carbonstate_type + implicit none private ! @@ -107,8 +119,9 @@ end subroutine UpdateAccVars_interface end interface subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & - atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, & - waterdiagnosticbulk_inst, wateratm2lndbulk_inst, & + num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, & + atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, & + wateratm2lndbulk_inst, waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, & cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) ! ! !DESCRIPTION: @@ -117,23 +130,29 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_ ! !USES: ! ! !ARGUMENTS: - class(cnfire_base_type) :: this - type(bounds_type) , intent(in) :: bounds - integer , intent(in) :: num_soilc ! number of soil columns in filter - integer , intent(in) :: filter_soilc(:) ! filter for soil columns - integer , intent(in) :: num_soilp ! number of soil patches in filter - integer , intent(in) :: filter_soilp(:) ! filter for soil patches - type(atm2lnd_type) , intent(in) :: atm2lnd_inst - type(energyflux_type) , intent(in) :: energyflux_inst - type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst - type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst - type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst - type(cnveg_state_type) , intent(inout) :: cnveg_state_inst - type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst - real(r8) , intent(in) :: totlitc_col(bounds%begc:) - real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) - real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) - ! + class(fates_fire_base_type) :: this + type(bounds_type) , intent(in) :: bounds + integer , intent(in) :: num_soilc ! number of soil columns in filter + integer , intent(in) :: filter_soilc(:) ! filter for soil columns + integer , intent(in) :: num_soilp ! number of soil patches in filter + integer , intent(in) :: filter_soilp(:) ! filter for soil patches + integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp + integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg + integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp + integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0 + type(atm2lnd_type) , intent(in) :: atm2lnd_inst + type(energyflux_type) , intent(in) :: energyflux_inst + type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst + type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst + type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst + type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst + type(soilstate_type) , intent(in) :: soilstate_inst + class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve + type(cnveg_state_type) , intent(inout) :: cnveg_state_inst + type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + real(r8) , intent(in) :: totlitc_col(bounds%begc:) + real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) + real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) call endrun( 'cnfire_base::CNFireArea: this method MUST be implemented!' ) From 340f5f282aa0e269a0d67c4d54485c60b2d4b360 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 14 Jan 2021 10:36:45 -0800 Subject: [PATCH 130/152] adding missing abortutils and contain statement --- src/biogeochem/FATESFireBase.F90 | 86 +++++++++++++++++--------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90 index d8b1df98df..c213f81e98 100644 --- a/src/biogeochem/FATESFireBase.F90 +++ b/src/biogeochem/FATESFireBase.F90 @@ -18,6 +18,7 @@ module FATESFireBase use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type use CNVegStateType , only : cnveg_state_type use CNVegCarbonStateType , only : cnveg_carbonstate_type + use abortutils , only : endrun implicit none private @@ -41,6 +42,8 @@ module FATESFireBase end type fates_fire_base_type + !----------------------- + abstract interface !----------------------------------------------------------------------- @@ -118,45 +121,48 @@ end subroutine UpdateAccVars_interface end interface - subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & - num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, & - atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, & - wateratm2lndbulk_inst, waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, & - cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) - ! - ! !DESCRIPTION: - ! Computes column-level burned area - ! - ! !USES: - ! - ! !ARGUMENTS: - class(fates_fire_base_type) :: this - type(bounds_type) , intent(in) :: bounds - integer , intent(in) :: num_soilc ! number of soil columns in filter - integer , intent(in) :: filter_soilc(:) ! filter for soil columns - integer , intent(in) :: num_soilp ! number of soil patches in filter - integer , intent(in) :: filter_soilp(:) ! filter for soil patches - integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp - integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg - integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp - integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0 - type(atm2lnd_type) , intent(in) :: atm2lnd_inst - type(energyflux_type) , intent(in) :: energyflux_inst - type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst - type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst - type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst - type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst - type(soilstate_type) , intent(in) :: soilstate_inst - class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve - type(cnveg_state_type) , intent(inout) :: cnveg_state_inst - type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst - real(r8) , intent(in) :: totlitc_col(bounds%begc:) - real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) - real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) - - call endrun( 'cnfire_base::CNFireArea: this method MUST be implemented!' ) - -end subroutine CNFireArea - !--------------------------------------------------------------------- + contains + + subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & + num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, & + atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, & + wateratm2lndbulk_inst, waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, & + cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) + ! + ! !DESCRIPTION: + ! Computes column-level burned area + ! + ! !USES: + ! + ! !ARGUMENTS: + class(fates_fire_base_type) :: this + type(bounds_type) , intent(in) :: bounds + integer , intent(in) :: num_soilc ! number of soil columns in filter + integer , intent(in) :: filter_soilc(:) ! filter for soil columns + integer , intent(in) :: num_soilp ! number of soil patches in filter + integer , intent(in) :: filter_soilp(:) ! filter for soil patches + integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp + integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg + integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp + integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0 + type(atm2lnd_type) , intent(in) :: atm2lnd_inst + type(energyflux_type) , intent(in) :: energyflux_inst + type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst + type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst + type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst + type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst + type(soilstate_type) , intent(in) :: soilstate_inst + class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve + type(cnveg_state_type) , intent(inout) :: cnveg_state_inst + type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + real(r8) , intent(in) :: totlitc_col(bounds%begc:) + real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) + real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) + + call endrun( 'cnfire_base::CNFireArea: this method MUST be implemented!' ) + + end subroutine CNFireArea + +---------------------------------------------- end module FATESFireBase From bc2bc2ff136738dce93fa3e237db6f280b215479 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 14 Jan 2021 10:57:35 -0800 Subject: [PATCH 131/152] adding more missing use cases --- src/biogeochem/FATESFireBase.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90 index c213f81e98..39044377fb 100644 --- a/src/biogeochem/FATESFireBase.F90 +++ b/src/biogeochem/FATESFireBase.F90 @@ -6,6 +6,8 @@ module FATESFireBase ! ! !USES: use CNFireBaseMod , only : cnfire_base_type + use shr_kind_mod , only : r8 => shr_kind_r8 + use abortutils , only : endrun use decompMod , only : bounds_type use atm2lndType , only : atm2lnd_type use EnergyFluxType , only : energyflux_type @@ -18,7 +20,6 @@ module FATESFireBase use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type use CNVegStateType , only : cnveg_state_type use CNVegCarbonStateType , only : cnveg_carbonstate_type - use abortutils , only : endrun implicit none private From e09dc512e2d3335cbf1c15cedadd2f89f64ca6fa Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 15 Jan 2021 12:23:54 -0700 Subject: [PATCH 132/152] Implement CNFire subroutines to the FATES Fire base class, they are required in the base class even though they aren't used in FATES versions, so they are empty and call endrun, if they were invoked wrongly --- src/biogeochem/FATESFireBase.F90 | 153 +++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 46 deletions(-) diff --git a/src/biogeochem/FATESFireBase.F90 b/src/biogeochem/FATESFireBase.F90 index 39044377fb..457e577a7b 100644 --- a/src/biogeochem/FATESFireBase.F90 +++ b/src/biogeochem/FATESFireBase.F90 @@ -9,15 +9,6 @@ module FATESFireBase use shr_kind_mod , only : r8 => shr_kind_r8 use abortutils , only : endrun use decompMod , only : bounds_type - use atm2lndType , only : atm2lnd_type - use EnergyFluxType , only : energyflux_type - use SaturatedExcessRunoffMod , only : saturated_excess_runoff_type - use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type - use Wateratm2lndBulkType , only : wateratm2lndbulk_type - use WaterStateBulkType , only : waterstatebulk_type - use WaterStateBulkType , only : waterstatebulk_type - use SoilStateType , only : soilstate_type - use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type use CNVegStateType , only : cnveg_state_type use CNVegCarbonStateType , only : cnveg_carbonstate_type @@ -38,9 +29,12 @@ module FATESFireBase procedure(InitAccBuffer_interface), public, deferred :: InitAccBuffer ! Initialize accumulation processes procedure(InitAccVars_interface), public, deferred :: InitAccVars ! Initialize accumulation variables procedure(UpdateAccVars_interface), public, deferred :: UpdateAccVars ! Update/extract accumulations vars + ! Interfaces that need to be implemented because they are in the base class + ! They are NOT used when FATES is on + procedure, public :: CNFireReadParams ! Read in parameters (NOT USED FOR FATES) + procedure, public :: CNFireArea ! Calculate fire area (NOT USED FOR FATES) + procedure, public :: CNFireFluxes ! Calculate fire fluxes (NOT USED FOR FATES) - procedure, public :: CNFireArea - end type fates_fire_base_type !----------------------- @@ -124,46 +118,113 @@ end subroutine UpdateAccVars_interface contains - subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & - num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, & - atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, waterdiagnosticbulk_inst, & - wateratm2lndbulk_inst, waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, & - cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) + !----------------------------------------------------------------------- + ! Implement empty subroutines that are required in the FireMethodType base + ! class, but are NOT used in the FATES version + !----------------------------------------------------------------------- + subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & + dgvs_inst, cnveg_state_inst, & + cnveg_carbonstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenstate_inst, cnveg_nitrogenflux_inst, & + leaf_prof_patch, froot_prof_patch, croot_prof_patch, stem_prof_patch, & + totsomc_col, decomp_cpools_vr_col, decomp_npools_vr_col, somc_fire_col) + ! + ! !DESCRIPTION: + ! Fire effects routine for coupled carbon-nitrogen code (CN). (NOT USED FOR FATES) + ! + ! !USES: + use CNDVType , only : dgvs_type + use CNVegCarbonFluxType , only : cnveg_carbonflux_type + use CNVegNitrogenStateType , only : cnveg_nitrogenstate_type + use CNVegNitrogenFluxType , only : cnveg_nitrogenflux_type + ! + ! !ARGUMENTS: + class(fates_fire_base_type) :: this + type(bounds_type) , intent(in) :: bounds + integer , intent(in) :: num_soilc ! number of soil columns in filter + integer , intent(in) :: filter_soilc(:) ! filter for soil columns + integer , intent(in) :: num_soilp ! number of soil patches in filter + integer , intent(in) :: filter_soilp(:) ! filter for soil patches + type(dgvs_type) , intent(inout) :: dgvs_inst + type(cnveg_state_type) , intent(inout) :: cnveg_state_inst + type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst + type(cnveg_nitrogenstate_type) , intent(in) :: cnveg_nitrogenstate_inst + type(cnveg_nitrogenflux_type) , intent(inout) :: cnveg_nitrogenflux_inst + real(r8) , intent(in) :: leaf_prof_patch(bounds%begp:,1:) + real(r8) , intent(in) :: froot_prof_patch(bounds%begp:,1:) + real(r8) , intent(in) :: croot_prof_patch(bounds%begp:,1:) + real(r8) , intent(in) :: stem_prof_patch(bounds%begp:,1:) + real(r8) , intent(in) :: totsomc_col(bounds%begc:) + real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) + real(r8) , intent(in) :: decomp_npools_vr_col(bounds%begc:,1:,1:) + real(r8) , intent(out) :: somc_fire_col(bounds%begc:) + ! + call endrun( "This subroutine should NEVER be called when FATES is active" ) + end subroutine CNFireFluxes + + !----------------------------------------------------------------------- + subroutine CNFireReadParams( this, ncid ) + ! + ! Read in the constant parameters from the input NetCDF parameter file (NOT USED FOR FATES) + ! !USES: + use ncdio_pio , only : file_desc_t + ! + ! !ARGUMENTS: + implicit none + class(fates_fire_base_type) :: this + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + ! + call endrun( "This subroutine should NEVER be called when FATES is active" ) + end subroutine CNFireReadParams + + !----------------------------------------------------------------------- + subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, & + num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, & + atm2lnd_inst, energyflux_inst, saturated_excess_runoff_inst, & + waterdiagnosticbulk_inst, wateratm2lndbulk_inst, & + waterstatebulk_inst, soilstate_inst, soil_water_retention_curve, & + cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) ! ! !DESCRIPTION: - ! Computes column-level burned area + ! Computes column-level burned area (NOT USED FOR FATES) ! ! !USES: + use EnergyFluxType , only : energyflux_type + use SaturatedExcessRunoffMod , only : saturated_excess_runoff_type + use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type + use Wateratm2lndBulkType , only : wateratm2lndbulk_type + use WaterStateBulkType , only : waterstatebulk_type + use SoilStateType , only : soilstate_type + use SoilWaterRetentionCurveMod , only : soil_water_retention_curve_type + use atm2lndType , only : atm2lnd_type ! ! !ARGUMENTS: - class(fates_fire_base_type) :: this - type(bounds_type) , intent(in) :: bounds - integer , intent(in) :: num_soilc ! number of soil columns in filter - integer , intent(in) :: filter_soilc(:) ! filter for soil columns - integer , intent(in) :: num_soilp ! number of soil patches in filter - integer , intent(in) :: filter_soilp(:) ! filter for soil patches - integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp - integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg - integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp - integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0 - type(atm2lnd_type) , intent(in) :: atm2lnd_inst - type(energyflux_type) , intent(in) :: energyflux_inst - type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst - type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst - type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst - type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst - type(soilstate_type) , intent(in) :: soilstate_inst - class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve - type(cnveg_state_type) , intent(inout) :: cnveg_state_inst - type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst - real(r8) , intent(in) :: totlitc_col(bounds%begc:) - real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) - real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) - - call endrun( 'cnfire_base::CNFireArea: this method MUST be implemented!' ) - - end subroutine CNFireArea - ----------------------------------------------- + class(fates_fire_base_type) :: this + type(bounds_type) , intent(in) :: bounds + integer , intent(in) :: num_soilc ! number of soil columns in filter + integer , intent(in) :: filter_soilc(:) ! filter for soil columns + integer , intent(in) :: num_soilp ! number of soil patches in filter + integer , intent(in) :: filter_soilp(:) ! filter for soil patches + integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp + integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg + integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp + integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0 + type(atm2lnd_type) , intent(in) :: atm2lnd_inst + type(energyflux_type) , intent(in) :: energyflux_inst + type(saturated_excess_runoff_type) , intent(in) :: saturated_excess_runoff_inst + type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst + type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst + type(waterstatebulk_type) , intent(in) :: waterstatebulk_inst + type(soilstate_type) , intent(in) :: soilstate_inst + class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve + type(cnveg_state_type) , intent(inout) :: cnveg_state_inst + type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + real(r8) , intent(in) :: totlitc_col(bounds%begc:) + real(r8) , intent(in) :: decomp_cpools_vr_col(bounds%begc:,1:,1:) + real(r8) , intent(in) :: t_soi17cm_col(bounds%begc:) + ! + call endrun( "This subroutine should NEVER be called when FATES is active" ) + end subroutine CNFireArea + !---------------------------------------------- end module FATESFireBase From 377ec154fbae36a563635b0dba9d4e4eb856f55e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 27 Jan 2021 01:01:19 -0800 Subject: [PATCH 133/152] updating Changelog --- doc/ChangeLog | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 130 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2ca737aa91..e84357bdb7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,132 @@ =============================================================== +Tag name: ctsm5.1.dev022 +Originator(s): gregorylemieux (Gregory Lemieux,LBL/NGEET,510-486-5049) +Date: Wed 27 Jan 2021 12:26:44 AM PST +One-line Summary: Merge fates_main_api into ctsm master + +Purpose and description of changes +---------------------------------- + +This brings fates_main_api into and up-to-date with ctsm master. +At the point of merge, fates_main_api was parallel with ctsm5.1.dev020, +only one tag behind ctsm master's head. + +The purpose of this merge is to make all future updates to fates +on the ctsm master branch instead of on the fates_main_api branch. + + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm5_1 + +[X] clm5_0 + +[ ] ctsm5_0-nwp + +[X] clm4_5 + + +Bugs fixed or introduced +------------------------ +[Remove any lines that don't apply. Remove entire section if nothing applies.] + +Issues fixed (include CTSM Issue #): none + +CIME Issues fixed (include issue #): none + +Known bugs introduced in this tag (include issue #): none + +Known bugs found since the previous tag (include issue #): none + + +Notes of particular relevance for users +--------------------------------------- +[Remove any lines that don't apply. Remove entire section if nothing applies.] + +Caveats for users (e.g., need to interpolate initial conditions): none + +Changes to CTSM's user interface (e.g., new/renamed XML or namelist +variables): none + +Changes made to namelist defaults (e.g., changed parameter values): none + +Changes to the datasets (e.g., parameter, surface or initial files): none + +Substantial timing or memory changes: + Only the fates testmod FatesAllVars failed the MEMCOMP test + + +Notes of particular relevance for developers: +--------------------------------------------- +NOTE: Be sure to review the steps in README.CHECKLIST.master_tags as well as the coding style in the Developers Guide + +Caveats for developers (e.g., code that is duplicated that requires double +maintenance): none + +Changes to tests or testing: none + + +Testing summary: +---------------- + + [PASS means all tests PASS; OK means tests PASS other than expected fails.] + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + cheyenne ---- PASS (except for fates DIFFs) + izumi ------- N/A + + ok: All non-fates testmods PASS. Fates testmods have DIFF as expected due + to update of fates tag. + + any other testing (give details below): + + fates suite: + cheyenne ---- OK + + ok: expected failures on COMPARE_base_rest for FatesHydro + and Fates_nat_and_anthro_ignitions. All else B4B. + + fates baseline: fates-sci.1.43.2_api.14.2.0-ctsm5.1.dev020-C5f348cac-F5534a940 + +If the tag used for baseline comparisons was NOT the previous tag, note that here: + +Answer changes +-------------- + +Changes answers relative to baseline: Yes, only for fates + + Summarize any changes to answers, i.e., + - what code configurations: all fates + - what platforms/compilers: all + - nature of change (roundoff; larger than roundoff/same climate; new + climate): larger than roundoff + + Comparison made using fates suite between fates_main_api (at ctsm5.1.dev020) + and ctsm5.1.dev022. All tests PASS, except for two expected failures and + expected NLCOMP failure due to ctsm5.1.dev021 update to paramfile. + + +Other details +------------- + +List any externals directories updated (cime, rtm, mosart, cism, fates, etc.): +fates + + fates: sci.1.30.0_api.8.0.0 -> sci.1.43.2_api.14.2.0 + +Pull Requests that document the changes (include PR ids): +(https://github.com/ESCOMP/ctsm/pull) + #1264 -- Merge fates_main_api into master + +=============================================================== +=============================================================== Tag name: ctsm5.1.dev021 Originator(s): erik (Erik Kluzek,UCAR/TSS,303-497-1326) Date: Tue Jan 12 20:21:52 MST 2021 @@ -122,6 +250,7 @@ Changes answers relative to baseline: Yes! Detailed list of changes ------------------------ + Pull Requests that document the changes (include PR ids): (https://github.com/ESCOMP/ctsm/pull) #1016 -- Heat Storage biomass diff --git a/doc/ChangeSum b/doc/ChangeSum index 0ca1854990..501dbbb210 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.1.dev022 glemieux 01/27/2021 Merge fates_main_api into ctsm master ctsm5.1.dev021 erik 01/12/2021 Add option for biomass heat storage (BHS) to clm5_1 physics ctsm5.1.dev020 erik 12/30/2020 Potential roundoff changes in preparation for bio-mass heat storage option ctsm5.1.dev019 sacks 12/19/2020 Fix ndep from coupler From 292c8b63ff8528f73348a129374a23312fe3887c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 27 Jan 2021 16:11:36 -0800 Subject: [PATCH 134/152] removing unnecessary spitfire addition to cnfire_inparm group --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index b65a93c12c..ecc8fdef36 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -207,7 +207,7 @@ formulation (1). + group="cnfire_inparm" valid_values="nofire,li2014qianfrc,li2016crufrc,li2021gswpfrc" > The method type to use for CNFire nofire: Turn fire effects off From 677f422c98de1d4b5548df020a86ee13828d3e45 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 28 Jan 2021 16:47:30 -0800 Subject: [PATCH 135/152] add hgrid setting to lightning stream filename setting --- bld/namelist_files/namelist_defaults_ctsm.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 6d6704d8cc..e60930ba6e 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1580,9 +1580,9 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts 0001 0001 -atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc -atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc -atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc +atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc +atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc +atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc bilinear bilinear From 0fe37c06659cad163417b20a9391f586bbd01c98 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 29 Jan 2021 09:33:06 -0800 Subject: [PATCH 136/152] adding clarifying comments --- bld/namelist_files/namelist_definition_ctsm.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index ecc8fdef36..78c712e969 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -654,9 +654,10 @@ Switch deciding which nutrient model to use in FATES. Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0. Relevant only if use_fates = .true. Allowed values are: + 0 : Simulations of fire are off 1 : use a global constant lightning rate found in fates_params. 2 : use an external lightning dataset. - 3 : use an external confirmed ignitions dataset. + 3 : use an external confirmed ignitions dataset (not available through standard CSEM dataset collection). 4 : use external lightning and population datasets to simulate both natural and anthropogenic ignitions. @@ -679,7 +680,7 @@ Toggle to turn on the logging module (only relevant if FATES is being used). - Toggle to turn on cohort age tracking (only relevant if FATES is on). + Toggle to turn on cohort age tracking (only relevant if FATES is on, which only tracks patches by default). Date: Fri, 29 Jan 2021 09:41:54 -0800 Subject: [PATCH 137/152] strike out dated edison test --- cime_config/testdefs/testlist_clm.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index e2211d7b4a..dced442457 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1656,7 +1656,6 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this - From b1a6080a90fa50cc5d9f78efcf2fccc221744cb3 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 29 Jan 2021 14:50:35 -0800 Subject: [PATCH 138/152] updating changelog notes --- doc/ChangeLog | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index e84357bdb7..0affa035d0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -32,34 +32,25 @@ Does this tag change answers significantly for any of the following physics conf [X] clm4_5 -Bugs fixed or introduced ------------------------- -[Remove any lines that don't apply. Remove entire section if nothing applies.] - -Issues fixed (include CTSM Issue #): none - -CIME Issues fixed (include issue #): none - -Known bugs introduced in this tag (include issue #): none - -Known bugs found since the previous tag (include issue #): none - - Notes of particular relevance for users --------------------------------------- -[Remove any lines that don't apply. Remove entire section if nothing applies.] Caveats for users (e.g., need to interpolate initial conditions): none Changes to CTSM's user interface (e.g., new/renamed XML or namelist -variables): none +variables): + -Changes made to namelist defaults (e.g., changed parameter values): none +Changes made to namelist defaults (e.g., changed parameter values): + - fates_spitfire_mode updated with multiple modes that use external datasets + - use_fates_cohort_age_tracking added to enable size and age dependent mortality + - fates_parteh_mode option 2 added for fates CNP mode -Changes to the datasets (e.g., parameter, surface or initial files): none +Changes to the datasets (e.g., parameter, surface or initial files): + fates_paramfile updated to fates_params_api.14.0.0_12pft_c200921.nc Substantial timing or memory changes: - Only the fates testmod FatesAllVars failed the MEMCOMP test + Only the fates testmod FatesAllVars failed the MEMCOMP test due to the increase in the number of variables included Notes of particular relevance for developers: @@ -69,7 +60,11 @@ NOTE: Be sure to review the steps in README.CHECKLIST.master_tags as well as the Caveats for developers (e.g., code that is duplicated that requires double maintenance): none -Changes to tests or testing: none +Changes to tests or testing: + - Added FatesPRT2 testmod test which activates fates CNP mode + - Added FatesReducedComplexFixedBiogeo testmod which activates fates fixed biogeography mode + - Added FatesSizeAgeMort testmod which activates tracking of size and age dependent mortality in fates + - Added Fates_nat_and_anthro_ignitions testmod to activate use of external lightning and population datasets Testing summary: From 62439ab2505377a72bccb4bd7e7b15c75ec619ed Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 29 Jan 2021 15:58:47 -0800 Subject: [PATCH 139/152] adding comments to all fates testmods --- cime_config/testdefs/testlist_clm.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index dced442457..62e78bac29 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2135,6 +2135,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2143,6 +2144,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2153,6 +2155,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2163,6 +2166,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2173,6 +2177,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2183,6 +2188,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2192,6 +2198,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2202,6 +2209,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2211,6 +2219,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2221,6 +2230,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2230,6 +2240,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2240,6 +2251,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2249,6 +2261,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2259,6 +2272,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2267,6 +2281,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2277,6 +2292,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2285,6 +2301,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2295,6 +2312,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2314,6 +2332,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + @@ -2322,6 +2341,7 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this + From 0a563fbc5d456139fe3ab92093003300e3eb85d8 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Sun, 31 Jan 2021 00:00:23 -0700 Subject: [PATCH 140/152] Remove most of the notes about FATES being experimental, make the note about fates options only being relevant for FATES be consistent between options --- .../namelist_definition_ctsm.xml | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index b65a93c12c..2c2bcdc5a4 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -641,68 +641,74 @@ baseline proportion of nitrogen allocated for electron transport (J) Toggle to turn on the FATES model -(use_fates= '.true.' is EXPERIMENTAL NOT SUPPORTED!) +Functionally Assembled Terrestrial Ecosystem Simulator (FATES) Switch deciding which nutrient model to use in FATES. +(Only relevant if FATES is on) Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0. -Relevant only if use_fates = .true. Allowed values are: 1 : use a global constant lightning rate found in fates_params. 2 : use an external lightning dataset. 3 : use an external confirmed ignitions dataset. 4 : use external lightning and population datasets to simulate both natural and anthropogenic ignitions. +(Only relevant if FATES is on) -Toggle to turn on fixed biogeography mode (only relevant if FATES is being used). +Toggle to turn on fixed biogeography mode +(Only relevant if FATES is on) -Toggle to turn on the logging module (only relevant if FATES is being used). +Toggle to turn on the logging module +(Only relevant if FATES is on) - Toggle to turn on plant hydraulics (only relevant if FATES is on). - (use_fates_planthydro=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!) +Toggle to turn on plant hydraulics +(Only relevant if FATES is on) - Toggle to turn on cohort age tracking (only relevant if FATES is on). +Toggle to turn on cohort age tracking +(Only relevant if FATES is on). Toggle to turn on Static Stand Structure Mode (only relevant if FATES is being used). -(use_fates_ed_st3=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!) +(Only relevant if FATES is on). -Toggle to turn on prescribed physiology (only relevant if FATES is being used). +Toggle to turn on prescribed physiology +(Only relevant if FATES is on). -Toggle to turn on inventory initialization to startup FATES (only relevant if FATES is being used). -(use_fates_inventory_init=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!) +Toggle to turn on inventory initialization to startup FATES +(Only relevant if FATES is on). Full pathname to the inventory initialization control file. (Required, if use_fates_inventory_init=T) +(Only relevant if FATES is on). Full pathname datafile with fates parameters +(Only relevant if FATES is on). Date: Mon, 1 Feb 2021 00:05:28 -0700 Subject: [PATCH 141/152] Set light_res default according to some a few attributes rather than nothing which allows fates namelist tests to work, also add clm5_1 physics default for fates light_res, and remote the fail test for fates and transient --- bld/CLMBuildNamelist.pm | 6 +++++- bld/namelist_files/namelist_defaults_ctsm.xml | 1 + bld/unit_testers/build-namelist_test.pl | 7 +------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 198ea749f3..5d91212bf1 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -908,7 +908,11 @@ sub setup_cmdl_fire_light_res { my $var = "light_res"; my $val = $opts->{$var}; if ( $val eq "default" ) { - $nl_flags->{$var} = remove_leading_and_trailing_quotes($defaults->get_value($var)); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, + 'use_fates'=>$nl_flags->{'use_fates'}, fire_method=>$nl->get_value('fire_method') ); + $val = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + $nl_flags->{$var} = $val; } else { my $fire_method = remove_leading_and_trailing_quotes( $nl->get_value('fire_method') ); if ( defined($fire_method) && $val ne "none" ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index e60930ba6e..2fce00a22a 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1574,6 +1574,7 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts 360x720 360x720 360x720 +360x720 0001 0001 diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 5c7a775d72..49b9b9a591 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -138,7 +138,7 @@ sub make_config_cache { # # Figure out number of tests that will run # -my $ntests = 1550; +my $ntests = 1549; if ( defined($opts{'compare'}) ) { $ntests += 1044; } @@ -847,11 +847,6 @@ sub make_config_cache { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, - "useFATESWTransient" =>{ options=>"-bgc fates -use_case 20thC_transient -envxml_dir . -no-megan -res 10x15", - namelst=>"", - GLC_TWO_WAY_COUPLING=>"FALSE", - phys=>"clm5_0", - }, "usespitfireButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", namelst=>"fates_spitfire_mode>0", GLC_TWO_WAY_COUPLING=>"FALSE", From 08b1f8781a3dd3442e52e4719b840ae2559498b9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 1 Feb 2021 10:39:09 -0800 Subject: [PATCH 142/152] create FATES version of fire factory --- src/biogeochem/CNFireFactoryMod.F90 | 51 ----------------------------- src/main/clm_driver.F90 | 2 +- src/main/clm_initializeMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 6 ++-- 4 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/biogeochem/CNFireFactoryMod.F90 b/src/biogeochem/CNFireFactoryMod.F90 index 87616d5280..dbd9b70d15 100644 --- a/src/biogeochem/CNFireFactoryMod.F90 +++ b/src/biogeochem/CNFireFactoryMod.F90 @@ -17,18 +17,6 @@ module CNFireFactoryMod ! !PUBLIC ROUTINES: public :: CNFireReadNML ! read the fire namelist public :: create_cnfire_method ! create an object of class fire_method_type - public :: create_fates_fire_data_method ! create an object of class fates_fire_base_type - - ! These parameters set the ranges of the cases in subroutine - ! create_fates_fire_data_method. We declare them public in order to - ! use them as flags elsewhere in the CTSM and FATES-SPITFIRE. - ! They correspond one-to-one to the fates_spitfire_mode options listed - ! in bld/namelist_files/namelist_definition_clm4_5.xml - integer, public, parameter :: no_fire = 0 ! value of no_fire mode - integer, public, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode - integer, public, parameter :: lightning_from_data = 2 ! value of lightning_from_data mode - integer, public, parameter :: successful_ignitions = 3 ! value of successful_ignitions mode - integer, public, parameter :: anthro_ignitions = 4 ! value of anthro_ignitions mode ! !PRIVATE DATA MEMBERS: character(len=80), private :: fire_method = "li2014qianfrc" @@ -138,43 +126,4 @@ subroutine create_cnfire_method( NLFilename, cnfire_method ) end subroutine create_cnfire_method !----------------------------------------------------------------------- - !----------------------------------------------------------------------- - subroutine create_fates_fire_data_method( fates_fire_data_method ) - ! - ! !DESCRIPTION: - ! Create and return an object of fates_fire_data_method_type. - ! The particular type is determined based on a namelist parameter. - ! - ! !USES: - use clm_varctl, only: fates_spitfire_mode - use FATESFireBase, only: fates_fire_base_type - use FATESFireNoDataMod, only: fates_fire_no_data_type - use FATESFireDataMod, only: fates_fire_data_type - ! - ! !ARGUMENTS: - class(fates_fire_base_type), allocatable, intent(inout) :: fates_fire_data_method ! function result - ! - ! !LOCAL VARIABLES: - integer :: current_case - - character(len=*), parameter :: subname = 'create_fates_fire_data_method' - !----------------------------------------------------------------------- - - current_case = fates_spitfire_mode - - select case (current_case) - - case (no_fire:scalar_lightning) - allocate(fates_fire_no_data_type :: fates_fire_data_method) - case (lightning_from_data:anthro_ignitions) - allocate(fates_fire_data_type :: fates_fire_data_method) - - case default - write(iulog,*) subname//' ERROR: unknown method: ', fates_spitfire_mode - call endrun(msg=errMsg(sourcefile, __LINE__)) - - end select - - end subroutine create_fates_fire_data_method - end module CNFireFactoryMod diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index b65a260bc2..400aa65f56 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -113,7 +113,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro use clm_time_manager , only : get_curr_date use clm_varctl , only : use_lai_streams, fates_spitfire_mode use SatellitePhenologyMod, only : lai_advance - use CNFireFactoryMod , only : scalar_lightning + use FATESFireFactoryMod , only : scalar_lightning ! ! !ARGUMENTS: implicit none diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index fb54ee2ffc..648e252f5c 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -317,7 +317,7 @@ subroutine initialize2( ) use controlMod , only : NLFilename use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit - use CNFireFactoryMod , only : scalar_lightning + use FATESFireFactoryMod , only : scalar_lightning ! ! !ARGUMENTS ! diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d0609b85e2..836668511f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -142,7 +142,7 @@ module CLMFatesInterfaceMod use FatesPlantHydraulicsMod, only : InitHydrSites use FatesPlantHydraulicsMod, only : RestartHydrStates use FATESFireBase , only : fates_fire_base_type - use CNFireFactoryMod , only : no_fire, scalar_lightning, & + use FATESFireFactoryMod , only : no_fire, scalar_lightning, & successful_ignitions, anthro_ignitions use dynSubgridControlMod , only : get_do_harvest use dynHarvestMod , only : num_harvest_inst, harvest_varnames @@ -460,7 +460,7 @@ subroutine init(this, bounds_proc ) use FatesParameterDerivedMod, only : param_derived use subgridMod, only : natveg_patch_exists use clm_instur , only : wt_nat_patch - use CNFireFactoryMod , only: create_fates_fire_data_method + use FATESFireFactoryMod , only: create_fates_fire_data_method implicit none @@ -717,7 +717,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! to process array bounding information ! !USES - use CNFireFactoryMod, only: scalar_lightning + use FATESFireFactoryMod, only: scalar_lightning ! !ARGUMENTS: implicit none From deb57e02b75fc491c31346c60503ade1988f41f2 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 1 Feb 2021 11:33:01 -0800 Subject: [PATCH 143/152] adding FATESFireFactoryMod --- src/biogeochem/FATESFireFactoryMod.F90 | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/biogeochem/FATESFireFactoryMod.F90 diff --git a/src/biogeochem/FATESFireFactoryMod.F90 b/src/biogeochem/FATESFireFactoryMod.F90 new file mode 100644 index 0000000000..2bbc300e7d --- /dev/null +++ b/src/biogeochem/FATESFireFactoryMod.F90 @@ -0,0 +1,75 @@ +module FATESFireFactoryMod + + !--------------------------------------------------------------------------- + ! !DESCRIPTION: + ! Factory to create an instance of fire_method_type. This module figures + ! out the particular type to return. + ! + ! !USES: + use abortutils , only : endrun + use shr_log_mod , only : errMsg => shr_log_errMsg + use clm_varctl , only : iulog + + implicit none + save + private + ! + ! !PUBLIC ROUTINES: + public :: create_fates_fire_data_method ! create an object of class fates_fire_base_type + + ! These parameters set the ranges of the cases in subroutine + ! create_fates_fire_data_method. We declare them public in order to + ! use them as flags elsewhere in the CTSM and FATES-SPITFIRE. + ! They correspond one-to-one to the fates_spitfire_mode options listed + ! in bld/namelist_files/namelist_definition_clm4_5.xml + integer, public, parameter :: no_fire = 0 ! value of no_fire mode + integer, public, parameter :: scalar_lightning = 1 ! value of scalar_lightning mode + integer, public, parameter :: lightning_from_data = 2 ! value of lightning_from_data mode + integer, public, parameter :: successful_ignitions = 3 ! value of successful_ignitions mode + integer, public, parameter :: anthro_ignitions = 4 ! value of anthro_ignitions mode + + character(len=*), parameter, private :: sourcefile = & + __FILE__ + +contains + + !----------------------------------------------------------------------- + subroutine create_fates_fire_data_method( fates_fire_data_method ) + ! + ! !DESCRIPTION: + ! Create and return an object of fates_fire_data_method_type. + ! The particular type is determined based on a namelist parameter. + ! + ! !USES: + use clm_varctl, only: fates_spitfire_mode + use FATESFireBase, only: fates_fire_base_type + use FATESFireNoDataMod, only: fates_fire_no_data_type + use FATESFireDataMod, only: fates_fire_data_type + ! + ! !ARGUMENTS: + class(fates_fire_base_type), allocatable, intent(inout) :: fates_fire_data_method ! function result + ! + ! !LOCAL VARIABLES: + integer :: current_case + + character(len=*), parameter :: subname = 'create_fates_fire_data_method' + !----------------------------------------------------------------------- + + current_case = fates_spitfire_mode + + select case (current_case) + + case (no_fire:scalar_lightning) + allocate(fates_fire_no_data_type :: fates_fire_data_method) + case (lightning_from_data:anthro_ignitions) + allocate(fates_fire_data_type :: fates_fire_data_method) + + case default + write(iulog,*) subname//' ERROR: unknown method: ', fates_spitfire_mode + call endrun(msg=errMsg(sourcefile, __LINE__)) + + end select + + end subroutine create_fates_fire_data_method + +end module CNFireFactoryMod From b8abb886416dab11f314201727462aa93ef06e8b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 1 Feb 2021 11:46:58 -0800 Subject: [PATCH 144/152] fixing missing end module name --- src/biogeochem/FATESFireFactoryMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeochem/FATESFireFactoryMod.F90 b/src/biogeochem/FATESFireFactoryMod.F90 index 2bbc300e7d..4e8ea8681f 100644 --- a/src/biogeochem/FATESFireFactoryMod.F90 +++ b/src/biogeochem/FATESFireFactoryMod.F90 @@ -72,4 +72,4 @@ subroutine create_fates_fire_data_method( fates_fire_data_method ) end subroutine create_fates_fire_data_method -end module CNFireFactoryMod +end module FATESFireFactoryMod From c8b2339533f41385e678ecabe021d899dd21ab24 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 1 Feb 2021 16:55:30 -0700 Subject: [PATCH 145/152] removing old call to fire_method = spitfire in ignitions testmod --- .../testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm | 1 - 1 file changed, 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm index 77d3a7179f..7915bb63eb 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates_nat_and_anthro_ignitions/user_nl_clm @@ -1,4 +1,3 @@ -fire_method = 'spitfire' fates_spitfire_mode = 4 hist_nhtfrq = 0 hist_mfilt = 1 From 9f0916bbb6798ad41b515c9aab7726f6e26d1f4d Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 2 Feb 2021 23:07:21 -0700 Subject: [PATCH 146/152] Set T62 lightning dataset for fates as well, set light_res for fates spitfire settings that don't need it to 'none' when light_res is none do not set any of the lighting settings, remove use_cn setting for lightning as not needed --- bld/CLMBuildNamelist.pm | 13 +++++++------ bld/namelist_files/namelist_defaults_ctsm.xml | 10 +++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 5d91212bf1..83128f7357 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -910,6 +910,7 @@ sub setup_cmdl_fire_light_res { if ( $val eq "default" ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, + 'fates_spitfire_mode'=>$nl->get_value('fates_spitfire_mode'), 'use_fates'=>$nl_flags->{'use_fates'}, fire_method=>$nl->get_value('fire_method') ); $val = remove_leading_and_trailing_quotes( $nl->get_value($var) ); $nl_flags->{$var} = $val; @@ -3373,14 +3374,14 @@ sub setup_logic_lightning_streams { # lightning streams require CN/BGC my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; - if ( &value_is_true($nl_flags->{'cnfireson'}) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, + if ( $nl_flags->{'light_res'} ne "none" ) { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'hgrid'=>$nl_flags->{'res'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_lightng', 'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); # Set align year, if first and last years are different @@ -3389,7 +3390,7 @@ sub setup_logic_lightning_streams { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_lightng', 'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); } - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_lightng', 'hgrid'=>$nl_flags->{'light_res'} ); } else { # If bgc is NOT CN/CNDV then make sure none of the Lightng settings are set @@ -3398,7 +3399,7 @@ sub setup_logic_lightning_streams { defined($nl->get_value('model_year_align_lightng')) || defined($nl->get_value('lightng_tintalgo' )) || defined($nl->get_value('stream_fldfilename_lightng')) ) { - $log->fatal_error("When bgc is SP (NOT CN or BGC) or fire_method==nofire none of: stream_year_first_lightng,\n" . + $log->fatal_error("When bgc is SP (NOT CN or BGC or FATES) or fire is turned off none of: stream_year_first_lightng,\n" . "stream_year_last_lightng, model_year_align_lightng, lightng_tintalgo nor\n" . "stream_fldfilename_lightng can be set!"); } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 2fce00a22a..b0367fab04 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1572,9 +1572,12 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts 94x192 94x192 360x720 -360x720 -360x720 -360x720 +none +none +none +360x720 +360x720 +360x720 0001 0001 @@ -1583,6 +1586,7 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc +atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc bilinear From 2f27c6852e22a53a98450f49db3cd328d001543f Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 3 Feb 2021 11:51:59 -0700 Subject: [PATCH 147/152] Remove the use_cn and use_fates settings for lightning variables so don't have to have a different copy for each --- bld/namelist_files/namelist_defaults_ctsm.xml | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index b0367fab04..aea9c07e75 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1579,26 +1579,21 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts 360x720 360x720 -0001 -0001 -0001 -0001 - -atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc -atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc -atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc -atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc - -bilinear -bilinear - -nn -nn -nn -nn -nn -nn -nn +0001 +0001 + +atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc +atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc + +bilinear + +nn +nn +nn +nn +nn +nn +nn 2015 From 089eb798dd8d65e3d89e75cf8bacbf7b49ef763c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 4 Feb 2021 09:40:00 -0800 Subject: [PATCH 148/152] updating changelog template --- doc/.ChangeLog_template | 5 +++++ doc/ChangeLog | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/.ChangeLog_template b/doc/.ChangeLog_template index 1150edaa03..11c30a596d 100644 --- a/doc/.ChangeLog_template +++ b/doc/.ChangeLog_template @@ -26,6 +26,8 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm4_5 +[ ] fates + Bugs fixed or introduced ------------------------ @@ -119,6 +121,9 @@ infrastructure should be run when appropriate, as described below. cheyenne ---- izumi ------- + + fates tests: + cheyenne ---- any other testing (give details below): diff --git a/doc/ChangeLog b/doc/ChangeLog index 0affa035d0..fe40c4c3cb 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -25,12 +25,13 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm5_1 -[X] clm5_0 +[ ] clm5_0 [ ] ctsm5_0-nwp -[X] clm4_5 +[ ] clm4_5 +[X] fates Notes of particular relevance for users --------------------------------------- @@ -40,7 +41,6 @@ Caveats for users (e.g., need to interpolate initial conditions): none Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): - Changes made to namelist defaults (e.g., changed parameter values): - fates_spitfire_mode updated with multiple modes that use external datasets - use_fates_cohort_age_tracking added to enable size and age dependent mortality @@ -75,20 +75,20 @@ Testing summary: regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): cheyenne ---- PASS (except for fates DIFFs) - izumi ------- N/A + izumi ------- OK ok: All non-fates testmods PASS. Fates testmods have DIFF as expected due to update of fates tag. - any other testing (give details below): - - fates suite: + fates tests: cheyenne ---- OK ok: expected failures on COMPARE_base_rest for FatesHydro and Fates_nat_and_anthro_ignitions. All else B4B. fates baseline: fates-sci.1.43.2_api.14.2.0-ctsm5.1.dev020-C5f348cac-F5534a940 + + any other testing (give details below): If the tag used for baseline comparisons was NOT the previous tag, note that here: From 0643ad45f8f46879c632f67c326ec75a1fecb0a4 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 4 Feb 2021 13:59:55 -0700 Subject: [PATCH 149/152] Remove all non-debug nag tests There is a compiler error with nag when building in non-debug mode with the latest FATES code. The non-debug nag tests don't seem to have much value, so I'm removing them - either changing them to debug tests or removing them entirely, depending on whether a given configuration seems to have sufficient test coverage. --- cime_config/testdefs/testlist_clm.xml | 33 ++++----------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 62e78bac29..95db622a9c 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -659,7 +659,7 @@ - + @@ -695,7 +695,7 @@ - + @@ -703,7 +703,7 @@ - + @@ -711,23 +711,7 @@ - - - - - - - - - - - - - - - - - + @@ -1236,14 +1220,6 @@ - - - - - - - - @@ -1680,7 +1656,6 @@ for ERS test as otherwise it won't work for a sub-day test (no need to run this - From 0d52de5efdc64d05c7d11c4668f364bc2d4e68be Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 4 Feb 2021 15:14:51 -0800 Subject: [PATCH 150/152] updating changelog notes for dev022 and removing fates checkbox from template --- doc/.ChangeLog_template | 2 -- doc/ChangeLog | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/.ChangeLog_template b/doc/.ChangeLog_template index 11c30a596d..f72764d0f4 100644 --- a/doc/.ChangeLog_template +++ b/doc/.ChangeLog_template @@ -26,8 +26,6 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm4_5 -[ ] fates - Bugs fixed or introduced ------------------------ diff --git a/doc/ChangeLog b/doc/ChangeLog index fe40c4c3cb..be84eaeaa1 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -31,7 +31,6 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm4_5 -[X] fates Notes of particular relevance for users --------------------------------------- @@ -65,6 +64,7 @@ Changes to tests or testing: - Added FatesReducedComplexFixedBiogeo testmod which activates fates fixed biogeography mode - Added FatesSizeAgeMort testmod which activates tracking of size and age dependent mortality in fates - Added Fates_nat_and_anthro_ignitions testmod to activate use of external lightning and population datasets + - Non-debug mode nag tests replaced in izumi test list with debug versions due to internal compiler error. Testing summary: @@ -74,11 +74,11 @@ Testing summary: regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): - cheyenne ---- PASS (except for fates DIFFs) + cheyenne ---- PASS (fates testmods DIFFs are expected) izumi ------- OK - ok: All non-fates testmods PASS. Fates testmods have DIFF as expected due - to update of fates tag. + ok: All non-fates testmods PASS. Fates testmods have DIFF as expected due to update of fates tag. + BFAILs expected due to changing non-debug nag test to debug. See #1264 comments for discussion. fates tests: cheyenne ---- OK From 5ee6ce2517c16c3b4ffc828c5bde0188324472f5 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 4 Feb 2021 17:01:46 -0700 Subject: [PATCH 151/152] Add two fail tests for light-res set to none, but fire required to be on --- bld/unit_testers/build-namelist_test.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 49b9b9a591..56bf61a387 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -138,7 +138,7 @@ sub make_config_cache { # # Figure out number of tests that will run # -my $ntests = 1549; +my $ntests = 1551; if ( defined($opts{'compare'}) ) { $ntests += 1044; } @@ -842,6 +842,16 @@ sub make_config_cache { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_1", }, + "FireNoneButFATESfireon" =>{ options=>"-bgc fates -envxml_dir . -no-megan -light_res none", + namelst=>"fates_spitfire_mode=4", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_1", + }, + "FireNoneButBGCfireon" =>{ options=>"-bgc bgc -envxml_dir . -light_res none", + namelst=>"fire_method='li2021gswpfrc'", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_1", + }, "createcropFalse" =>{ options=>"-bgc bgc -envxml_dir . -no-megan", namelst=>"create_crop_landunit=.false.", GLC_TWO_WAY_COUPLING=>"FALSE", From c49dcbc497eef12b1ffe2fa448292f634b2b41ad Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 5 Feb 2021 00:03:41 -0700 Subject: [PATCH 152/152] Some more work with the Change files --- doc/ChangeLog | 33 ++++++++++++++++++++++++--------- doc/ChangeSum | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index be84eaeaa1..bc681f955a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,7 +1,7 @@ =============================================================== Tag name: ctsm5.1.dev022 Originator(s): gregorylemieux (Gregory Lemieux,LBL/NGEET,510-486-5049) -Date: Wed 27 Jan 2021 12:26:44 AM PST +Date: Fri Feb 5 00:03:28 MST 2021 One-line Summary: Merge fates_main_api into ctsm master Purpose and description of changes @@ -31,15 +31,24 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm4_5 +Bugs fixed or introduced +------------------------ + +Issues fixed (include CTSM Issue #): + Fixes #1128 -- missing compset for FATES tests + Fixes #1002 -- allow transient land-use files when FATES is on? + Some work was done on #1272 -- namelist refactor for FATES + +Known bugs introduced in this tag (include issue #): + #1265 -- Diversifying fates testmods included in `aux_clm` test suite + #1266 - Add test for successful_ignitions mode for FATES-SPITFIRE + +Known bugs found since the previous tag (include issue #): + #1269 -- GSWP3V1 atmospheric forcing for 2011-2014 is "bad" over Antarctica Notes of particular relevance for users --------------------------------------- -Caveats for users (e.g., need to interpolate initial conditions): none - -Changes to CTSM's user interface (e.g., new/renamed XML or namelist -variables): - Changes made to namelist defaults (e.g., changed parameter values): - fates_spitfire_mode updated with multiple modes that use external datasets - use_fates_cohort_age_tracking added to enable size and age dependent mortality @@ -56,8 +65,11 @@ Notes of particular relevance for developers: --------------------------------------------- NOTE: Be sure to review the steps in README.CHECKLIST.master_tags as well as the coding style in the Developers Guide -Caveats for developers (e.g., code that is duplicated that requires double -maintenance): none +Caveats for developers (e.g., code that is duplicated that requires double maintenance): + There are a couple of issues we plan to address later (#1265, and #1272) + Note also that NAG compiler production tests started failing because of a compiler error + Since, we only care about NAG for DEBUG testing we removed those tests. Hopefully, a compiler + update will allow that to work in the future. Changes to tests or testing: - Added FatesPRT2 testmod test which activates fates CNP mode @@ -67,10 +79,13 @@ Changes to tests or testing: - Non-debug mode nag tests replaced in izumi test list with debug versions due to internal compiler error. -Testing summary: +Testing summary: regular ---------------- [PASS means all tests PASS; OK means tests PASS other than expected fails.] + build-namelist tests (if CLMBuildNamelist.pm has changed): + + cheyenne - PASS (61 namelists are different because of fates changes) regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): diff --git a/doc/ChangeSum b/doc/ChangeSum index 501dbbb210..ffd5a805a4 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,6 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.1.dev022 glemieux 01/27/2021 Merge fates_main_api into ctsm master + ctsm5.1.dev022 glemieux 02/05/2021 Merge fates_main_api into ctsm master ctsm5.1.dev021 erik 01/12/2021 Add option for biomass heat storage (BHS) to clm5_1 physics ctsm5.1.dev020 erik 12/30/2020 Potential roundoff changes in preparation for bio-mass heat storage option ctsm5.1.dev019 sacks 12/19/2020 Fix ndep from coupler