From 48b52dc5179a4ba3388a911a8aea7f1c682ce62c Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 17 Apr 2024 17:08:50 -0600 Subject: [PATCH 001/114] Point FATES external at Charlie's LUH2 branch. --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index dc1bc3f0e7..1494217277 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.70.0_api.32.0.0 +repo_url = https://github.com/ckoven/fates +hash = d37d9733b5970dfe67a required = True [externals_description] From 526bc19b068546e4d92828cf44c86596010e9482 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 17 Apr 2024 15:39:56 -0600 Subject: [PATCH 002/114] Update CTSM to work with FATES LUH2. Some issues remain. --- bld/CLMBuildNamelist.pm | 26 +- bld/namelist_files/namelist_defaults_ctsm.xml | 10 +- .../namelist_definition_ctsm.xml | 26 +- bld/unit_testers/build-namelist_test.pl | 1 + .../testmods_dirs/clm/Fates/user_nl_clm | 2 +- .../clm/FatesColdLogging/user_nl_clm | 1 + .../usermods_dirs/fates_sp/user_nl_clm | 2 +- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 80 +++++- src/main/clm_instMod.F90 | 3 +- src/main/clm_varctl.F90 | 4 +- src/main/controlMod.F90 | 14 +- src/utils/clmfates_interfaceMod.F90 | 227 ++++++++++++++++-- 12 files changed, 351 insertions(+), 45 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 4df42d5e74..bcf68a8d61 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -783,7 +783,7 @@ sub setup_cmdl_fates_mode { # dis-allow fates specific namelist items with non-fates runs 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", - "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","use_fates_logging", + "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries" ); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { @@ -4370,7 +4370,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'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_nocomp","fates_seeddisp_cadence", - "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage","use_fates_luh" ); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage","use_fates_luh" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); @@ -4426,6 +4426,28 @@ sub setup_logic_fates { } } } + + # Check fates_harvest_mode compatibility + my $var = "fates_harvest_mode"; + if ( defined($nl->get_value($var)) ) { + # using fates_harvest_mode with CLM landuse driver data - for user convienence + # if ( $nl->get_value($var) == 2) { + # # Make sure that do_harvest is set to true + # if ( ! &value_is_true($nl->get_value('do_harvest')) ) { + # fatal_error("do_harvest must be true when $var is equal to 2" ); + # } + # using fates_harvest mode with raw luh2 harvest data + if ( $nl->get_value($var) > 2) { + # Make sure that use_fates_luh is true when using raw fates luh2 harvest data + if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { + fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); + } + # do_harvest can not be on if we are using the raw fates luh2 harvest data + if ( &value_is_true($nl->get_value('do_harvest')) ) { + fatal_error("do_harvest can not be true when $var is greater than 2" ); + } + } + } } } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 7891361238..bc962d1b0f 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1572,11 +1572,14 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 lnd/clm2/surfdata_map/release-clm5.0.18/landuse.timeseries_10x15_SSP5-3.4_16pfts_Irrig_CMIP6_simyr1850-2100_c190228.nc - + lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc + +lnd/clm2/surfdata_map/fates-sci.1.73.0_api.33.0.0/fates_landuse_pft_map_4x5_240206.nc + lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc @@ -2756,14 +2759,17 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 0 +0 .false. .false. .false. .false. .false. -.false. .false. .false. +.false. +.true. +.true. .false. 1 0 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index b672b43125..fa2d83a3c9 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -734,10 +734,15 @@ Toggle to turn on no competition mode (only relevant if FATES is being used). Toggle to turn on FATES satellite phenology mode (only relevant if FATES is being used). - -Toggle to turn on the logging module -(Only relevant if FATES is on) + +Set FATES harvesting mode by setting fates_harvest_mode > 0. +Allowed values are: + 0 : no fates harvesting of any kind + 1 : fates logging via fates logging event codes (see fates parameter file) only + 2 : fates harvest driven by CLM landuse timeseries data (dynHarvestMod) + 3 : fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) + 4 : fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) If TRUE, enable use of land use harmonization (LUH) state and transition data from luh_timeseries file. +This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harvest +data (fates_harvest_mode >= 3) (Also, only valid for use_fates = true and is incompatible with transient runs currently.) + +If TRUE, ignore the land-use state vector and transitions, and assert that all lands +are primary, and that there is no harvest. + + @@ -793,6 +806,11 @@ types to vary over time. (Only relevant if FATES is on). + +Full pathname of fates landuse x pft data map. + + Toggle to turn on the LUNA model, to effect Photosynthesis by leaf Nitrogen diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 9b579dd9ce..899bd10b9c 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1046,6 +1046,7 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, + # TODO SSR: Replace this with fates_harvest_mode "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", namelst=>"use_fates_logging=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", 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 406fb598f6..91df3e2e61 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -16,7 +16,7 @@ hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_SAPWOODC', 'FATES_LEAFC', 'FATES_FROOTC', 'FATES_REPROC', 'FATES_STRUCTC', 'FATES_NONSTRUCTC', 'FATES_VEGC_ABOVEGROUND', 'FATES_CANOPY_VEGC', 'FATES_USTORY_VEGC', 'FATES_PRIMARY_PATCHFUSION_ERR', -'FATES_HARVEST_CARBON_FLUX', 'FATES_DISTURBANCE_RATE_FIRE', +'FATES_HARVEST_WOODPROD_C_FLUX', 'FATES_DISTURBANCE_RATE_FIRE', 'FATES_DISTURBANCE_RATE_LOGGING', 'FATES_DISTURBANCE_RATE_TREEFALL', 'FATES_STOMATAL_COND', 'FATES_LBLAYER_COND', 'FATES_NPP', 'FATES_GPP', 'FATES_AUTORESP', 'FATES_GROWTH_RESP', 'FATES_MAINT_RESP', 'FATES_GPP_CANOPY', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm index 3b74a4fd37..5f457f3f1c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm @@ -1 +1,2 @@ +! TODO SSR: Replace this with fates_harvest_mode use_fates_logging= .true. diff --git a/cime_config/usermods_dirs/fates_sp/user_nl_clm b/cime_config/usermods_dirs/fates_sp/user_nl_clm index 093ecd7eda..37da8d1c67 100644 --- a/cime_config/usermods_dirs/fates_sp/user_nl_clm +++ b/cime_config/usermods_dirs/fates_sp/user_nl_clm @@ -22,7 +22,7 @@ hist_fexcl1 = 'FATES_TRIMMING', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLD 'FATES_SAPWOODC', 'FATES_FROOTC', 'FATES_REPROC', 'FATES_STRUCTC', 'FATES_NONSTRUCTC', 'FATES_VEGC_ABOVEGROUND', 'FATES_CANOPY_VEGC', 'FATES_USTORY_VEGC', 'FATES_PRIMARY_PATCHFUSION_ERR', 'FATES_DISTURBANCE_RATE_FIRE', 'FATES_DISTURBANCE_RATE_LOGGING', 'FATES_DISTURBANCE_RATE_TREEFALL', - 'FATES_HARVEST_CARBON_FLUX', 'FATES_GPP_CANOPY', 'FATES_AUTORESP_CANOPY', + 'FATES_HARVEST_WOODPROD_C_FLUX', 'FATES_GPP_CANOPY', 'FATES_AUTORESP_CANOPY', 'FATES_GPP_USTORY', 'FATES_AUTORESP_USTORY', 'FATES_CROWNAREA_CL', 'FATES_DEMOTION_CARBONFLUX', 'FATES_PROMOTION_CARBONFLUX', 'FATES_MORTALITY_CFLUX_CANOPY', 'FATES_MORTALITY_CFLUX_USTORY', 'FATES_DDBH_CANOPY_SZ', 'FATES_DDBH_USTORY_SZ', 'FATES_BASALAREA_SZ', diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index 45f4340d6a..4f326d82a5 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -26,13 +26,39 @@ module dynFATESLandUseChangeMod ! Landuse state at beginning of year (fraction of gridcell), landuse state name x gridcell real(r8), allocatable, public :: landuse_states(:,:) + ! TODO SSR: Ask Charlie for description to go here + real(r8), allocatable, public :: landuse_harvest(:,:) + ! Number of landuse transition and state names integer, public, parameter :: num_landuse_transition_vars = 108 integer, public, parameter :: num_landuse_state_vars = 12 + integer, public, parameter :: num_landuse_harvest_vars = 5 + + ! Define the fates landuse namelist mode switch values + integer, public, parameter :: fates_harvest_no_logging = 0 + integer, public, parameter :: fates_harvest_logging_only = 1 + integer, public, parameter :: fates_harvest_clmlanduse = 2 + integer, public, parameter :: fates_harvest_luh_area = 3 + integer, public, parameter :: fates_harvest_luh_mass = 4 + + ! Define landuse harvest unit integer representation + integer, public, parameter :: landuse_harvest_area_units = 1 + integer, public, parameter :: landuse_harvest_mass_units = 2 + integer, public :: landuse_harvest_units ! landuse filename type(dyn_file_type), target :: dynFatesLandUse_file + ! LUH2 raw wood harvest area fraction + character(len=10), target :: landuse_harvest_area_varnames(num_landuse_harvest_vars) = & + [character(len=10) :: 'primf_harv', 'primn_harv', 'secmf_harv', 'secyf_harv', 'secnf_harv'] + + ! LUH2 raw wood harvest biomass carbon + character(len=10), target :: landuse_harvest_mass_varnames(num_landuse_harvest_vars) = & + [character(len=10) :: 'primf_bioh', 'primn_bioh', 'secmf_bioh', 'secyf_bioh', 'secnf_bioh'] + + character(len=10), public, pointer :: landuse_harvest_varnames(:) => null() + ! Land use name arrays character(len=5), public, parameter :: landuse_state_varnames(num_landuse_state_vars) = & [character(len=5) :: 'primf','primn','secdf','secdn','pastr','range', & @@ -64,8 +90,9 @@ module dynFATESLandUseChangeMod 'c3nfx_to_c3ann','c3nfx_to_c4ann','c3nfx_to_c3per','c3nfx_to_c4per', & 'c3nfx_to_secdf','c3nfx_to_secdn','c3nfx_to_pastr','c3nfx_to_range','c3nfx_to_urban'] - type(dyn_var_time_uninterp_type) :: landuse_transition_vars(num_landuse_transition_vars) ! value of each landuse variable - type(dyn_var_time_uninterp_type) :: landuse_state_vars(num_landuse_state_vars) ! value of each landuse variable + type(dyn_var_time_uninterp_type) :: landuse_transition_vars(num_landuse_transition_vars) ! value of each transitions variable + type(dyn_var_time_uninterp_type) :: landuse_state_vars(num_landuse_state_vars) ! value of each state variable + type(dyn_var_time_uninterp_type) :: landuse_harvest_vars(num_landuse_harvest_vars) ! value of each harvest variable public :: dynFatesLandUseInit public :: dynFatesLandUseInterp @@ -79,14 +106,14 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) ! Initialize data structures for land use information. ! !USES: - use clm_varctl , only : use_cn, use_fates_luh + use clm_varctl , only : use_cn, use_fates_luh, fates_harvest_mode use dynVarTimeUninterpMod , only : dyn_var_time_uninterp_type use dynTimeInfoMod , only : YEAR_POSITION_START_OF_TIMESTEP use dynTimeInfoMod , only : YEAR_POSITION_END_OF_TIMESTEP ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds ! proc-level bounds - character(len=*) , intent(in) :: landuse_filename ! name of file containing land use information + character(len=*) , intent(in) :: landuse_filename ! name of file containing landuse timeseries information (fates luh2) ! !LOCAL VARIABLES integer :: varnum, i ! counter for harvest variables @@ -111,17 +138,23 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) if (ier /= 0) then call endrun(msg=' allocation error for landuse_transitions'//errMsg(__FILE__, __LINE__)) end if + allocate(landuse_harvest(num_landuse_harvest_vars,bounds%begg:bounds%endg),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for landuse_harvest'//errMsg(__FILE__, __LINE__)) + end if + ! Initialize the states, transitions and harvest mapping percentages as zero by default landuse_states = 0._r8 landuse_transitions = 0._r8 + landuse_harvest = 0._r8 if (use_fates_luh) then - ! Generate the dyn_file_type object. Note that the land use data being read in is for the - ! transitions occuring within the current year + ! Generate the dyn_file_type object. + ! Start calls get_prev_date, whereas end calls get_curr_date dynFatesLandUse_file = dyn_file_type(landuse_filename, YEAR_POSITION_END_OF_TIMESTEP) - ! Get initial land use data + ! Get initial land use data from the fates luh2 timeseries dataset num_points = (bounds%endg - bounds%begg + 1) landuse_shape(1) = num_points ! Does this need an explicit array shape to be passed to the constructor? do varnum = 1, num_landuse_transition_vars @@ -136,6 +169,28 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) dim1name=grlnd, conversion_factor=1.0_r8, & do_check_sums_equal_1=.false., data_shape=landuse_shape) end do + + ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled + if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + + ! change the harvest varnames being used depending on the mode selected + if (fates_harvest_mode .eq. fates_harvest_luh_area ) then + landuse_harvest_varnames => landuse_harvest_area_varnames + landuse_harvest_units = landuse_harvest_area_units + elseif (fates_harvest_mode .eq. fates_harvest_luh_mass ) then + landuse_harvest_varnames => landuse_harvest_mass_varnames + landuse_harvest_units = landuse_harvest_mass_units + else + call endrun(msg=' undefined fates harvest mode selected'//errMsg(__FILE__, __LINE__)) + end if + + do varnum = 1, num_landuse_harvest_vars + landuse_harvest_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_harvest_varnames(varnum), & + dim1name=grlnd, conversion_factor=1.0_r8, & + do_check_sums_equal_1=.false., data_shape=landuse_shape) + end do + end if end if ! Since fates needs state data during initialization, make sure to call @@ -159,7 +214,7 @@ subroutine dynFatesLandUseInterp(bounds, init_state) ! !USES: use dynTimeInfoMod , only : time_info_type - use clm_varctl , only : use_cn + use clm_varctl , only : use_cn, fates_harvest_mode ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds ! proc-level bounds @@ -181,13 +236,14 @@ subroutine dynFatesLandUseInterp(bounds, init_state) init_flag = init_state end if - ! Get the current year + ! Get the data for the current year call dynFatesLandUse_file%time_info%set_current_year() if (dynFatesLandUse_file%time_info%is_before_time_series() .and. .not.(init_flag)) then ! Reset the land use transitions to zero for safety landuse_transitions(1:num_landuse_transition_vars,bounds%begg:bounds%endg) = 0._r8 landuse_states(1:num_landuse_state_vars,bounds%begg:bounds%endg) = 0._r8 + landuse_harvest(1:num_landuse_harvest_vars,bounds%begg:bounds%endg) = 0._r8 else ! Loop through all variables on the data file and put data into the temporary array ! then update the global state and transitions array. @@ -200,6 +256,12 @@ subroutine dynFatesLandUseInterp(bounds, init_state) call landuse_state_vars(varnum)%get_current_data(this_data) landuse_states(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) end do + if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + do varnum = 1, num_landuse_harvest_vars + call landuse_harvest_vars(varnum)%get_current_data(this_data) + landuse_harvest(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) + end do + end if deallocate(this_data) end if diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 1ca450b48d..830dcfcca7 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -200,6 +200,7 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps + use clm_varctl , only : flandusepftdat ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds @@ -436,7 +437,7 @@ subroutine clm_instInit(bounds) ! Initialize the Functionaly Assembled Terrestrial Ecosystem Simulator (FATES) ! if (use_fates) then - call clm_fates%Init(bounds) + call clm_fates%Init(bounds, flandusepftdat) end if deallocate (h2osno_col) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index e0d142bffd..9ab6c631c7 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -302,7 +302,7 @@ module clm_varctl ! > 1 for external data (lightning and/or anthropogenic ignitions) ! see bld/namelist_files/namelist_definition_clm4_5.xml for details logical, public :: use_fates_tree_damage = .false. ! true => turn on tree damage module - logical, public :: use_fates_logging = .false. ! true => turn on logging module + integer, public :: fates_harvest_mode = 0 ! 0 for no harvest/logging; 1-4 for harvest mode options 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 @@ -311,7 +311,9 @@ module clm_varctl logical, public :: use_fates_fixed_biogeog = .false. ! true => use fixed biogeography mode logical, public :: use_fates_nocomp = .false. ! true => use no comopetition mode logical, public :: use_fates_luh = .false. ! true => use FATES landuse data mode + logical, public :: use_fates_potentialveg = .false. ! true => FATES potential veg only character(len=256), public :: fluh_timeseries = '' ! filename for fates landuse timeseries data + character(len=256), public :: flandusepftdat = '' ! filename for fates landuse x pft data character(len=256), public :: fates_inventory_ctrl_filename = '' ! filename for inventory control ! FATES SP AND FATES BGC are MUTUTALLY EXCLUSIVE, THEY CAN'T BOTH BE ON diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 44efec4eeb..196bc141ff 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -222,7 +222,7 @@ subroutine control_init(dtime) ! FATES Flags namelist /clm_inparm/ fates_paramfile, use_fates, & - fates_spitfire_mode, use_fates_logging, & + fates_spitfire_mode, fates_harvest_mode, & use_fates_planthydro, use_fates_ed_st3, & use_fates_cohort_age_tracking, & use_fates_ed_prescribed_phys, & @@ -231,7 +231,9 @@ subroutine control_init(dtime) use_fates_nocomp, & use_fates_sp, & use_fates_luh, & + use_fates_potentialveg, & fluh_timeseries, & + flandusepftdat, & fates_inventory_ctrl_filename, & fates_parteh_mode, & fates_seeddisp_cadence, & @@ -772,7 +774,7 @@ subroutine control_spmd() call mpi_bcast (for_testing_allow_interp_non_ciso_to_ciso, 1, MPI_LOGICAL, 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 (fates_harvest_mode, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_tree_damage, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) @@ -783,10 +785,12 @@ subroutine control_spmd() call mpi_bcast (use_fates_nocomp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_sp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_luh, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_potentialveg, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_bgc, 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 (fluh_timeseries, len(fates_paramfile) , MPI_CHARACTER, 0, mpicom, ier) + call mpi_bcast (fluh_timeseries, len(fluh_timeseries) , MPI_CHARACTER, 0, mpicom, ier) + call mpi_bcast (flandusepftdat, len(flandusepftdat) , MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (fates_parteh_mode, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (fates_seeddisp_cadence, 1, MPI_INTEGER, 0, mpicom, ier) @@ -1144,7 +1148,7 @@ subroutine control_print () write(iulog, *) ' use_fates = ', use_fates if (use_fates) then write(iulog, *) ' fates_spitfire_mode = ', fates_spitfire_mode - write(iulog, *) ' use_fates_logging = ', use_fates_logging + write(iulog, *) ' fates_harvest_mode = ', fates_harvest_mode write(iulog, *) ' fates_paramfile = ', fates_paramfile write(iulog, *) ' fates_parteh_mode = ', fates_parteh_mode write(iulog, *) ' use_fates_planthydro = ', use_fates_planthydro @@ -1157,7 +1161,9 @@ subroutine control_print () write(iulog, *) ' use_fates_nocomp = ', use_fates_nocomp write(iulog, *) ' use_fates_sp = ', use_fates_sp write(iulog, *) ' use_fates_luh= ', use_fates_luh + write(iulog, *) ' use_fates_potentialveg = ', use_fates_potentialveg write(iulog, *) ' fluh_timeseries = ', trim(fluh_timeseries) + write(iulog, *) ' flandusepftdat = ', trim(flandusepftdat) write(iulog, *) ' fates_seeddisp_cadence = ', fates_seeddisp_cadence write(iulog, *) ' fates_seeddisp_cadence: 0, 1, 2, 3 => off, daily, monthly, or yearly dispersal' write(iulog, *) ' fates_inventory_ctrl_filename = ', trim(fates_inventory_ctrl_filename) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 83d7186021..3f84a28508 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -54,12 +54,14 @@ module CLMFatesInterfaceMod 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 + use clm_varctl , only : fates_harvest_mode use clm_varctl , only : use_fates_inventory_init use clm_varctl , only : use_fates_fixed_biogeog use clm_varctl , only : use_fates_nocomp use clm_varctl , only : use_fates_sp use clm_varctl , only : use_fates_luh + use clm_varctl , only : use_fates_potentialveg + use clm_varctl , only : flandusepftdat use clm_varctl , only : fates_seeddisp_cadence use clm_varctl , only : fates_inventory_ctrl_filename use clm_varctl , only : use_nitrif_denitrif @@ -180,6 +182,12 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : landuse_transitions, landuse_states use dynFATESLandUseChangeMod, only : landuse_transition_varnames, landuse_state_varnames use dynFATESLandUseChangeMod, only : dynFatesLandUseInterp + use dynFATESLandUseChangeMod, only : num_landuse_harvest_vars + use dynFATESLandUseChangeMod, only : fates_harvest_no_logging + use dynFATESLandUseChangeMod, only : fates_harvest_luh_area + use dynFATESLandUseChangeMod, only : landuse_harvest + use dynFATESLandUseChangeMod, only : landuse_harvest_units + use dynFATESLandUseChangeMod, only : landuse_harvest_varnames implicit none @@ -272,6 +280,8 @@ module CLMFatesInterfaceMod character(len=*), parameter, private :: sourcefile = & __FILE__ + integer, parameter :: num_landuse_pft_vars = 4 + public :: CLMFatesGlobals1 public :: CLMFatesGlobals2 @@ -384,8 +394,10 @@ subroutine CLMFatesGlobals2() integer :: pass_cohort_age_tracking integer :: pass_tree_damage integer :: pass_use_luh + integer :: pass_use_potentialveg integer :: pass_num_luh_states integer :: pass_num_luh_transitions + integer :: pass_lupftdat call t_startf('fates_globals2') @@ -477,7 +489,7 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_ed_st3',ival=pass_ed_st3) - if(use_fates_logging) then + if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 else pass_logging = 0 @@ -505,8 +517,8 @@ subroutine CLMFatesGlobals2() 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 + ! check fates logging namelist value first because hlm harvest can override it + if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 else pass_logging = 0 @@ -521,23 +533,53 @@ subroutine CLMFatesGlobals2() 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_luh) then pass_use_luh = 1 pass_num_luh_states = num_landuse_state_vars pass_num_luh_transitions = num_landuse_transition_vars + + ! Do not set harvest passing variables to zero not in luh harvest modes + ! as the user may want to use the CLM landuse harvest with luh2 transitions + if(fates_harvest_mode >= fates_harvest_luh_area) then + ! End the run if do_harvest is true with this run mode. + ! This should be caught be the build namelist. + if(get_do_harvest()) then + call endrun(msg="do_harvest and fates_harvest_mode using luh2 harvest data are incompatible"//& + errmsg(sourcefile, __LINE__)) + else + pass_lu_harvest = 1 + end if + end if else pass_use_luh = 0 pass_num_luh_states = 0 pass_num_luh_transitions = 0 end if + call set_fates_ctrlparms('use_luh2',ival=pass_use_luh) call set_fates_ctrlparms('num_luh2_states',ival=pass_num_luh_states) call set_fates_ctrlparms('num_luh2_transitions',ival=pass_num_luh_transitions) + if ( use_fates_potentialveg ) then + pass_use_potentialveg = 1 + else + pass_use_potentialveg = 0 + end if + call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) + + if(flandusepftdat /= '') then + pass_lupftdat = 1 + else + pass_lupftdat = 0 + end if + call set_fates_ctrlparms('use_landusepft_data',ival=pass_lupftdat) + + ! Wait to set the harvest and logging variables after checking get_do_harvest + ! and fates_harvest_modes + 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 else @@ -585,7 +627,7 @@ end subroutine CLMFatesTimesteps ! ==================================================================================== - subroutine init(this, bounds_proc ) + subroutine init(this, bounds_proc, flandusepftdat) ! --------------------------------------------------------------------------------- ! This initializes the hlm_fates_interface_type @@ -614,6 +656,7 @@ subroutine init(this, bounds_proc ) ! Input Arguments class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type),intent(in) :: bounds_proc + character(len=*), intent(in) :: flandusepftdat ! local variables integer :: nclumps ! Number of threads @@ -631,6 +674,9 @@ subroutine init(this, bounds_proc ) integer :: ndecomp integer :: numg + real(r8), allocatable :: landuse_pft_map(:,:,:) + real(r8), allocatable :: landuse_bareground(:) + ! Initialize the FATES communicators with the HLM ! This involves to stages ! 1) allocate the vectors @@ -663,6 +709,13 @@ subroutine init(this, bounds_proc ) write(iulog,*) 'clm_fates%init(): allocating for ',nclumps,' threads' end if + ! Retrieve the landuse x pft static data if the file is present + if (flandusepftdat /= '') then + call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground) + end if + + nclumps = get_proc_clumps() + allocate(copy_fates_var(bounds_proc%begc:bounds_proc%endc)) copy_fates_var(:) = .false. @@ -767,18 +820,26 @@ subroutine init(this, bounds_proc ) this%fates(nc)%sites(s)%lat = grc%latdeg(g) this%fates(nc)%sites(s)%lon = grc%londeg(g) - this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 - ! initialize static layers for reduced complexity FATES versions from HLM - ! maybe make this into a subroutine of it's own later. - do m = surfpft_lb,surfpft_ub - ft = m - surfpft_lb - this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) - end do + ! Transfer the landuse x pft data to fates via bc_in if file is given + if (flandusepftdat /= '') then + this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) + this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) + end if - if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then - write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s)%pft_areafrac(:)) - 1.0_r8 - call endrun(msg=errMsg(sourcefile, __LINE__)) - end if + if (flandusepftdat == '') then + ! initialize static layers for reduced complexity FATES versions from HLM + ! maybe make this into a subroutine of it's own later. + this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 + do m = surfpft_lb,surfpft_ub + ft = m - surfpft_lb + this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) + end do + + if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then + write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8 + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + end if end do !site ! Initialize site-level static quantities dictated by the HLM @@ -820,6 +881,12 @@ subroutine init(this, bounds_proc ) ! Fire data to send to FATES call create_fates_fire_data_method( this%fates_fire_data_method ) + ! deallocate the local landuse x pft array + if (flandusepftdat /= '') then + deallocate(landuse_pft_map) + deallocate(landuse_bareground) + end if + call t_stopf('fates_init') end subroutine init @@ -1087,6 +1154,12 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%hlm_luh_state_names = landuse_state_varnames this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames + + if (fates_harvest_mode >= fates_harvest_luh_area) then + this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames + this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units + end if end if end do @@ -2033,6 +2106,12 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & this%fates(nc)%bc_in(s)%hlm_luh_state_names = landuse_state_varnames this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames + + if (fates_harvest_mode >= fates_harvest_luh_area ) then + this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames + this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units + end if end if end do @@ -3646,6 +3725,114 @@ subroutine GetAndSetTime() end subroutine GetAndSetTime + ! ====================================================================================== + + subroutine GetLandusePFTData(bounds, landuse_pft_file, landuse_pft_map, landuse_bareground) + + ! !DESCRIPTION: + ! Read in static landuse x pft file + + ! !USES: + use fileutils , only : getfil + use ncdio_pio , only : file_desc_t, ncd_io, ncd_inqdlen + use ncdio_pio , only : ncd_pio_openfile, ncd_pio_closefile + use decompMod , only : BOUNDS_LEVEL_PROC + use clm_varcon, only : grlnd + use FatesConstantsMod, only : fates_unset_r8 + + + ! !ARGUMENTS: + type(bounds_type), intent(in) :: bounds ! proc-level bounds + character(len=*) , intent(in) :: landuse_pft_file ! name of file containing static landuse x pft information + real(r8), allocatable, intent(inout) :: landuse_pft_map(:,:,:) + real(r8), allocatable, intent(inout) :: landuse_bareground(:) + + ! !LOCAL VARIABLES + integer :: varnum ! variable number + integer :: dimid, dimlen ! dimension id number and length + integer :: ier ! error id + character(len=256) :: locfn ! local file name + type(file_desc_t) :: ncid ! netcdf id + real(r8), pointer :: arraylocal(:,:) ! local array for reading fraction data + real(r8), pointer :: arraylocal_bareground(:) ! local array for reading bareground data + logical :: readvar ! true => variable is on dataset + !character(len=16), parameter :: grlnd = 'lndgrid' ! name of lndgrid + + integer, parameter :: dim_landuse_pft = 14 + + ! Land use name arrays + character(len=10), parameter :: landuse_pft_map_varnames(num_landuse_pft_vars) = & + [character(len=10) :: 'frac_primr','frac_secnd','frac_pastr','frac_range'] !need to move 'frac_surf' to a different variable + + character(len=*), parameter :: subname = 'GetLandusePFTData' + + !----------------------------------------------------------------------- + + ! Check to see if the landuse file name has been provided + ! Note: getfile checks this as well + if (masterproc) then + write(iulog,*) 'Attempting to read landuse x pft data .....' + if (landuse_pft_file == ' ') then + write(iulog,*)'landuse_pft_file must be specified' + call endrun(msg=errMsg(__FILE__, __LINE__)) + endif + endif + + ! Initialize the landuse x pft arrays and initialize to unset + allocate(landuse_pft_map(bounds%begg:bounds%endg,dim_landuse_pft,num_landuse_pft_vars),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for landuse_pft_map'//errMsg(__FILE__, __LINE__)) + end if + landuse_pft_map = fates_unset_r8 + + allocate(landuse_bareground(bounds%begg:bounds%endg),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for landuse_bareground'//errMsg(__FILE__, __LINE__)) + end if + landuse_bareground = fates_unset_r8 + + + ! Get the local filename and open the file + call getfil(landuse_pft_file, locfn, 0) + call ncd_pio_openfile (ncid, trim(locfn), 0) + + ! Check that natpft dimension on the file matches the target array dimensions + call ncd_inqdlen(ncid, dimid, dimlen, 'natpft') + if (dimlen /= dim_landuse_pft) then + write(iulog,*) 'natpft dimensions on the landuse x pft file do not match target array size' + call endrun(msg=errMsg(__FILE__, __LINE__)) + end if + + ! Allocate a temporary array since ncdio expects a pointer + allocate(arraylocal(bounds%begg:bounds%endg,dim_landuse_pft)) + allocate(arraylocal_bareground(bounds%begg:bounds%endg)) + + ! Read the landuse x pft data from file + do varnum = 1, num_landuse_pft_vars + call ncd_io(ncid=ncid, varname=landuse_pft_map_varnames(varnum), flag='read', & + data=arraylocal, dim1name=grlnd, readvar=readvar) + if (.not. readvar) & + call endrun(msg='ERROR: '//trim(landuse_pft_map_varnames(varnum))// & + ' NOT on landuse x pft file'//errMsg(__FILE__, __LINE__)) + landuse_pft_map(bounds%begg:bounds%endg,:,varnum) = arraylocal(bounds%begg:bounds%endg,:) + end do + + ! Read the bareground data from file. This is per gridcell only. + call ncd_io(ncid=ncid, varname='frac_brgnd', flag='read', & + data=arraylocal_bareground, dim1name=grlnd, readvar=readvar) + if (.not. readvar) call endrun(msg='ERROR: frac_brgnd NOT on landuse x pft file'//errMsg(__FILE__, __LINE__)) + landuse_bareground(bounds%begg:bounds%endg) = arraylocal_bareground(bounds%begg:bounds%endg) + + ! Deallocate the temporary local array point and close the file + deallocate(arraylocal) + deallocate(arraylocal_bareground) + call ncd_pio_closefile(ncid) + + ! Check that sums equal to unity + + end subroutine GetLandusePFTData + + !----------------------------------------------------------------------- end module CLMFatesInterfaceMod From 46420cfb64f4ebb2b092daef9071a3f070b403bf Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 18 Apr 2024 09:40:21 -0600 Subject: [PATCH 003/114] Add fates_landuse_v2 test suite. --- cime_config/testdefs/testlist_clm.xml | 36 +++++++++++++++++++ .../clm/FatesColdLUH2Mode1/include_user_mods | 1 + .../clm/FatesColdLUH2Mode1/user_nl_clm | 1 + .../clm/FatesColdLUH2Mode2/include_user_mods | 1 + .../clm/FatesColdLUH2Mode2/user_nl_clm | 1 + .../clm/FatesColdLUH2Mode3/include_user_mods | 1 + .../clm/FatesColdLUH2Mode3/user_nl_clm | 1 + .../clm/FatesColdLUH2Mode4/include_user_mods | 1 + .../clm/FatesColdLUH2Mode4/user_nl_clm | 1 + 9 files changed, 44 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index dec8cf49d8..4184cc7e1f 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2910,6 +2910,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm new file mode 100644 index 0000000000..dea75b71e7 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 1 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm new file mode 100644 index 0000000000..fd4c74fe57 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm new file mode 100644 index 0000000000..3332e9e526 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 3 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm new file mode 100644 index 0000000000..13dae9efee --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 4 From e4c8b6a0f1dfd0392fc956cf5d3f41e197508ba5 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 18 Apr 2024 11:32:05 -0600 Subject: [PATCH 004/114] Point FATES external to my repo: Nag array index fix. --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 1494217277..ef4406545e 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/ckoven/fates -hash = d37d9733b5970dfe67a +repo_url = https://github.com/samsrabin/fates +hash = c03a4ba64a7e59817658f1c3357ffff681d8b958 required = True [externals_description] From 7216006b1c2400d1ca2932899671f9bcec85b6af Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 18 Apr 2024 16:48:41 -0600 Subject: [PATCH 005/114] Apply relevant changes from rgknox/fates-auto-params. --- .../testdefs/testmods_dirs/clm/Fates/shell_commands | 5 +++++ .../testdefs/testmods_dirs/clm/Fates/user_nl_clm | 1 + .../testdefs/testmods_dirs/clm/_scripts/README | 2 ++ .../clm/_scripts/get_fates_shell_commands_vars.sh | 11 +++++++++++ 4 files changed, 19 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/_scripts/README create mode 100755 cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands index 41a2342a51..3443bacef0 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands @@ -1,2 +1,7 @@ ./xmlchange CLM_BLDNML_OPTS="-no-megan" --append ./xmlchange BFBFLAG="TRUE" + +SRCROOT=`./xmlquery SRCROOT --value` +. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh + +ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl 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 91df3e2e61..57adea1ff6 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -4,6 +4,7 @@ hist_nhtfrq = -24 hist_empty_htapes = .true. hist_ndens = 1 fates_spitfire_mode = 1 +fates_paramfile='${SRCROOT}/src/fates/parameter_files/binaries/${CASE}-params.nc' hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF','FATES_DAYSINCE_COLDLEAFON', diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/README b/cime_config/testdefs/testmods_dirs/clm/_scripts/README new file mode 100644 index 0000000000..66eb22a375 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/_scripts/README @@ -0,0 +1,2 @@ +This directory contains scripts that can be called in +shell_commands of multiple testmods. diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh b/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh new file mode 100755 index 0000000000..382fb4e53e --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh @@ -0,0 +1,11 @@ +# This script should be called in shell_commands with +# . "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh +# where the leading period ensures it's run in the same shell. + +CASE=`./xmlquery CASE --value` +FATESDIR="${SRCROOT}/src/fates" +FATESPARAMDIR="${SRCROOT}/src/fates/parameter_files/binaries" +mkdir -p "${FATESPARAMDIR}" +FATESPARAMFILE="${FATESPARAMDIR}/${CASE}-params.nc" + +# No exit status because it should be called in the same shell. From a7c21a752224c09361b4280a730e5c61273244fa Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 23 Apr 2024 12:26:35 -0600 Subject: [PATCH 006/114] Don't allow flandusepftdat to be set in non-FATES runs. --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index bcf68a8d61..e3ceedeccc 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -784,7 +784,7 @@ sub setup_cmdl_fates_mode { 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", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", - "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries" ); + "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat"); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { From 90a40281134953f3d371a6454642773035efe137 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 23 Apr 2024 12:27:16 -0600 Subject: [PATCH 007/114] Actually set flandusepftdat in CLMBuildNamelist.pm. --- bld/CLMBuildNamelist.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index e3ceedeccc..0f7f6891c5 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4424,6 +4424,9 @@ sub setup_logic_fates { } elsif ( ! -f "$fname" ) { $log->fatal_error("$fname does NOT point to a valid filename" ); } + + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); } } From d88fda01ba5904e80cf432f609cc10d4392f2767 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 23 Apr 2024 12:27:43 -0600 Subject: [PATCH 008/114] Update path for default flandusepftdat. --- 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 bc962d1b0f..66c0f837e0 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1578,7 +1578,7 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc -lnd/clm2/surfdata_map/fates-sci.1.73.0_api.33.0.0/fates_landuse_pft_map_4x5_240206.nc +lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc Date: Sun, 28 Apr 2024 13:45:50 -0600 Subject: [PATCH 009/114] Point FATES external back at Charlie's branch. --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index ef4406545e..b689141aaf 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/samsrabin/fates -hash = c03a4ba64a7e59817658f1c3357ffff681d8b958 +repo_url = https://github.com/ckoven/fates +hash = c1a7453c8331277a156a0ee158a870c1b8598a9f required = True [externals_description] From 0191278f95a35f90c76b7922fb51d8e42d68b24e Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Sun, 28 Apr 2024 13:48:21 -0600 Subject: [PATCH 010/114] Add missing potential veg to build list. Manually cherry-picked from Greg Lemieux's b33a722. --- bld/CLMBuildNamelist.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 0f7f6891c5..7e2e4294af 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -784,7 +784,8 @@ sub setup_cmdl_fates_mode { 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", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", - "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat"); + "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat", + "use_fates_potentialveg"); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { From fffb79409b29ed741c119d9fb37496898a689cd9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 1 May 2024 15:46:26 -0700 Subject: [PATCH 011/114] add use_fates_lupft switch --- bld/CLMBuildNamelist.pm | 25 +++++++++++++++++++ bld/namelist_files/namelist_defaults_ctsm.xml | 18 +++++++------ .../namelist_definition_ctsm.xml | 6 +++++ src/main/clm_varctl.F90 | 1 + src/main/controlMod.F90 | 3 +++ src/utils/clmfates_interfaceMod.F90 | 16 ++++-------- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7e2e4294af..021381a18e 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4414,6 +4414,31 @@ sub setup_logic_fates { } } } + # make sure that fates landuse x pft mode has the necessary run mode configurations + # and add the necessary landuse x pft static mapping data default if not defined + my $var = "use_fates_lupft"; + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true($nl->get_value($var)) ) { + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + fatal_error("$var is required when use_fates_lupft is set" ); + } elsif ( ! -f "$fname" ) { + fatal_error("$fname does NOT point to a valid filename" ); + } + } + # make sure that nocomp and fbg mode are enabled as well as use_fates_luh + my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); + foreach my $var ( @list ) { + if ( ! &value_is_true($nl->get_value($var)) ) { + fatal_error("$var is required when use_fates_lupft is true" ); + } + } + } + # check that fates landuse change mode has the necessary luh2 landuse timeseries data + # and add the default if not defined my $var = "use_fates_luh"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 66c0f837e0..49109c6591 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2767,17 +2767,21 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. +.false. .false. -.true. -.true. -.false. +.true. +.true. +.true. +.false. 1 0 -.true. -.false. -.true. -.false. +.true. +.true. +.false. +.true. +.true. +.false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fa2d83a3c9..a2df9b1d1e 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -791,6 +791,12 @@ data (fates_harvest_mode >= 3) (Also, only valid for use_fates = true and is incompatible with transient runs currently.) + +If TRUE, enable use of fates land use x pft mapping data file. +(Only valid for use_fates = true and is incompatible with transient runs currently.) + + If TRUE, ignore the land-use state vector and transitions, and assert that all lands diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 9ab6c631c7..64d6e15747 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -311,6 +311,7 @@ module clm_varctl logical, public :: use_fates_fixed_biogeog = .false. ! true => use fixed biogeography mode logical, public :: use_fates_nocomp = .false. ! true => use no comopetition mode logical, public :: use_fates_luh = .false. ! true => use FATES landuse data mode + logical, public :: use_fates_lupft = .false. ! true => use FATES landuse x pft static mapping mode logical, public :: use_fates_potentialveg = .false. ! true => FATES potential veg only character(len=256), public :: fluh_timeseries = '' ! filename for fates landuse timeseries data character(len=256), public :: flandusepftdat = '' ! filename for fates landuse x pft data diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 196bc141ff..55dd92305d 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -231,6 +231,7 @@ subroutine control_init(dtime) use_fates_nocomp, & use_fates_sp, & use_fates_luh, & + use_fates_lupft, & use_fates_potentialveg, & fluh_timeseries, & flandusepftdat, & @@ -785,6 +786,7 @@ subroutine control_spmd() call mpi_bcast (use_fates_nocomp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_sp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_luh, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_lupft, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_potentialveg, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_bgc, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_inventory_ctrl_filename, len(fates_inventory_ctrl_filename), MPI_CHARACTER, 0, mpicom, ier) @@ -1161,6 +1163,7 @@ subroutine control_print () write(iulog, *) ' use_fates_nocomp = ', use_fates_nocomp write(iulog, *) ' use_fates_sp = ', use_fates_sp write(iulog, *) ' use_fates_luh= ', use_fates_luh + write(iulog, *) ' use_fates_lupft= ', use_fates_lupft write(iulog, *) ' use_fates_potentialveg = ', use_fates_potentialveg write(iulog, *) ' fluh_timeseries = ', trim(fluh_timeseries) write(iulog, *) ' flandusepftdat = ', trim(flandusepftdat) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 3f84a28508..b0ae0044f3 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -60,6 +60,7 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_fates_nocomp use clm_varctl , only : use_fates_sp use clm_varctl , only : use_fates_luh + use clm_varctl , only : use_fates_lupft use clm_varctl , only : use_fates_potentialveg use clm_varctl , only : flandusepftdat use clm_varctl , only : fates_seeddisp_cadence @@ -567,13 +568,6 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) - if(flandusepftdat /= '') then - pass_lupftdat = 1 - else - pass_lupftdat = 0 - end if - call set_fates_ctrlparms('use_landusepft_data',ival=pass_lupftdat) - ! Wait to set the harvest and logging variables after checking get_do_harvest ! and fates_harvest_modes call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) @@ -710,7 +704,7 @@ subroutine init(this, bounds_proc, flandusepftdat) end if ! Retrieve the landuse x pft static data if the file is present - if (flandusepftdat /= '') then + if (use_fates_lupft) then call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground) end if @@ -821,12 +815,12 @@ subroutine init(this, bounds_proc, flandusepftdat) this%fates(nc)%sites(s)%lon = grc%londeg(g) ! Transfer the landuse x pft data to fates via bc_in if file is given - if (flandusepftdat /= '') then + if (use_fates_lupft) then this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) end if - if (flandusepftdat == '') then + if (.not. use_fates_lupft) then ! initialize static layers for reduced complexity FATES versions from HLM ! maybe make this into a subroutine of it's own later. this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 @@ -882,7 +876,7 @@ subroutine init(this, bounds_proc, flandusepftdat) call create_fates_fire_data_method( this%fates_fire_data_method ) ! deallocate the local landuse x pft array - if (flandusepftdat /= '') then + if (use_fates_lupft) then deallocate(landuse_pft_map) deallocate(landuse_bareground) end if From 5d11bcf5c1ad64bb8898e54f15852315439c5d57 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 1 May 2024 15:52:27 -0700 Subject: [PATCH 012/114] add fates use_potentialveg namelist defaults settings and checks --- bld/CLMBuildNamelist.pm | 13 ++++++++++++- bld/namelist_files/namelist_defaults_ctsm.xml | 9 +++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 021381a18e..7999e9a31d 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4455,7 +4455,18 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); } } - + # check that fates landuse is on and harvest mode is off when potential veg switch is true + my $var = "use_potentialveg"; + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true($nl->get_value($var)) ) { + if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { + fatal_error("use_fates_luh must be true when $var is true" ); + } + if ( $nl->get_value('fates_harvest_mode') > 0) { + fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + } + } + } # Check fates_harvest_mode compatibility my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 49109c6591..68a122e9bc 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,10 +2769,11 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. -.true. -.false. +.true. +.true. +.true. +.true. +.false. 1 0 From 6bd7d37a956edb0fc2bb20f7d593c64e4fa6eb0c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 2 May 2024 11:49:28 -0700 Subject: [PATCH 013/114] add use_fates_lupft to default namelist --- bld/CLMBuildNamelist.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7999e9a31d..23505492bd 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -785,7 +785,7 @@ sub setup_cmdl_fates_mode { "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat", - "use_fates_potentialveg"); + "use_fates_potentialveg","use_fates_lupft"); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { @@ -4371,7 +4371,8 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'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_nocomp","fates_seeddisp_cadence", - "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage","use_fates_luh" ); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage", + "use_fates_luh","use_fates_lupft" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); From edae95a1013439e234e7d56d57c01efc74ce063f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 13:08:16 -0600 Subject: [PATCH 014/114] manually revert defaults for use_fates_lupft and fix calls to fatal_error --- bld/CLMBuildNamelist.pm | 25 +++++++++++-------- bld/namelist_files/namelist_defaults_ctsm.xml | 7 ++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 23505492bd..01d583eb16 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4371,12 +4371,16 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'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_nocomp","fates_seeddisp_cadence", - "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage", - "use_fates_luh","use_fates_lupft" ); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage"); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); } + + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl_flags->{'use_fates_lupft'} ); + my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); if ( ($parteh_mode == 1) && ($suplnitro !~ /ALL/) && not &value_is_true( $nl_flags->{'use_fates_sp'}) ) { @@ -4384,6 +4388,7 @@ sub setup_logic_fates { "but and FATES-SP is not active, but fates_parteh_mode is 1, so Nitrogen is not active" . "Change suplnitro back to ALL"); } + # # For FATES SP mode make sure no-competetiion, and fixed-biogeography are also set # And also check for other settings that can't be trigged on as well @@ -4425,16 +4430,16 @@ sub setup_logic_fates { 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { - fatal_error("$var is required when use_fates_lupft is set" ); + $log->fatal_error("$var is required when use_fates_lupft is set" ); } elsif ( ! -f "$fname" ) { - fatal_error("$fname does NOT point to a valid filename" ); + $log->fatal_error("$fname does NOT point to a valid filename" ); } } # make sure that nocomp and fbg mode are enabled as well as use_fates_luh my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); foreach my $var ( @list ) { if ( ! &value_is_true($nl->get_value($var)) ) { - fatal_error("$var is required when use_fates_lupft is true" ); + $log->fatal_error("$var is required when use_fates_lupft is true" ); } } } @@ -4461,10 +4466,10 @@ sub setup_logic_fates { if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - fatal_error("use_fates_luh must be true when $var is true" ); + $log->fatal_error("use_fates_luh must be true when $var is true" ); } if ( $nl->get_value('fates_harvest_mode') > 0) { - fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); } } } @@ -4475,17 +4480,17 @@ sub setup_logic_fates { # if ( $nl->get_value($var) == 2) { # # Make sure that do_harvest is set to true # if ( ! &value_is_true($nl->get_value('do_harvest')) ) { - # fatal_error("do_harvest must be true when $var is equal to 2" ); + # $log->fatal_error("do_harvest must be true when $var is equal to 2" ); # } # using fates_harvest mode with raw luh2 harvest data if ( $nl->get_value($var) > 2) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); + $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); } # do_harvest can not be on if we are using the raw fates luh2 harvest data if ( &value_is_true($nl->get_value('do_harvest')) ) { - fatal_error("do_harvest can not be true when $var is greater than 2" ); + $log->fatal_error("do_harvest can not be true when $var is greater than 2" ); } } } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 68a122e9bc..1195ba5329 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,19 +2769,16 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. + .true. -.true. .false. + 1 0 .true. -.true. .false. .true. -.true. .false. From af6a1c0e87a4f3d03e3fe6976b00af3ac94398f1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 13:37:22 -0600 Subject: [PATCH 015/114] remove old flandusepftdat add_default and fix use_fates_lupft check this also temporarily removes the use_fates_lupft check for the use_fates_luh namelist defaults --- bld/CLMBuildNamelist.pm | 17 +++++++---------- bld/namelist_files/namelist_defaults_ctsm.xml | 6 +----- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 01d583eb16..1cb14878e7 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4389,7 +4389,6 @@ sub setup_logic_fates { "Change suplnitro back to ALL"); } - # # For FATES SP mode make sure no-competetiion, and fixed-biogeography are also set # And also check for other settings that can't be trigged on as well # @@ -4434,12 +4433,13 @@ sub setup_logic_fates { } elsif ( ! -f "$fname" ) { $log->fatal_error("$fname does NOT point to a valid filename" ); } - } - # make sure that nocomp and fbg mode are enabled as well as use_fates_luh - my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); - foreach my $var ( @list ) { - if ( ! &value_is_true($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_lupft is true" ); + + # make sure that nocomp and fbg mode are enabled as well as use_fates_luh + my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); + foreach my $var ( @list ) { + if ( ! &value_is_true($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_lupft is true" ); + } } } } @@ -4456,9 +4456,6 @@ sub setup_logic_fates { } elsif ( ! -f "$fname" ) { $log->fatal_error("$fname does NOT point to a valid filename" ); } - - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); } } # check that fates landuse is on and harvest mode is off when potential veg switch is true diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 1195ba5329..e6f6b736a6 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,13 +2769,9 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. - -.true. -.false. - +.false. 1 0 - .true. .false. .true. From d5575d5c31e0013b8e303b3bc6966f6c8e405f55 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 14:42:15 -0600 Subject: [PATCH 016/114] correct call to add_default for use_fates_lupft dependency with use_fates_luh --- bld/CLMBuildNamelist.pm | 2 +- bld/namelist_files/namelist_defaults_ctsm.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 1cb14878e7..7ad35584aa 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4379,7 +4379,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl_flags->{'use_fates_lupft'} ); + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft') ); my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index e6f6b736a6..38a0fe6493 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,7 +2769,8 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.false. +.true. +.false. 1 0 .true. From ea773e451b78b3b7011a534a73352693600be95e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 14:53:16 -0600 Subject: [PATCH 017/114] add use_fates_lupft dependencies for nocomp and fbg --- bld/CLMBuildNamelist.pm | 10 ++++++++-- bld/namelist_files/namelist_defaults_ctsm.xml | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7ad35584aa..261c775fbd 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4370,7 +4370,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 = ( "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_nocomp","fates_seeddisp_cadence", + "use_fates_inventory_init","fates_seeddisp_cadence", "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage"); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, @@ -4380,6 +4380,12 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft') ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_fixed_biogeog', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); @@ -4435,7 +4441,7 @@ sub setup_logic_fates { } # make sure that nocomp and fbg mode are enabled as well as use_fates_luh - my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); + my @list = ( "use_fates_luh", "use_fates_nocomp", "use_fates_fixed_biogeog" ); foreach my $var ( @list ) { if ( ! &value_is_true($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_lupft is true" ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 38a0fe6493..216ad74ca1 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2774,8 +2774,10 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 1 0 .true. +.true. .false. .true. +.true. .false. From a21181f1b3e4a89f426e4b9bdce52e76b06ffc39 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 5 May 2024 12:24:05 -0600 Subject: [PATCH 018/114] add fates_harvest_mode to use_fates_luh check --- bld/CLMBuildNamelist.pm | 3 ++- bld/namelist_files/namelist_defaults_ctsm.xml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 261c775fbd..8af5f035e9 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4379,7 +4379,8 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft') ); + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 216ad74ca1..206ab7cd1b 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,6 +2769,8 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. +.true. +.true. .true. .false. 1 From d8178e415a399f2f0fd61b15f92b4c43f9dd4484 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 5 May 2024 12:54:52 -0600 Subject: [PATCH 019/114] add use_fates_potentialveg to use_fates_luh check --- bld/CLMBuildNamelist.pm | 4 +++- bld/namelist_files/namelist_defaults_ctsm.xml | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 8af5f035e9..b450060736 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4377,9 +4377,11 @@ sub setup_logic_fates { 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); } + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_potentialveg', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), @@ -4466,7 +4468,7 @@ sub setup_logic_fates { } } # check that fates landuse is on and harvest mode is off when potential veg switch is true - my $var = "use_potentialveg"; + my $var = "use_fates_potentialveg"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 206ab7cd1b..9d2a34b7bf 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,10 +2769,11 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. +.true. +.true. .true. -.false. +.true. +.false. 1 0 .true. From 9751fb68174903134e301472087edc263bc4822e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 5 May 2024 13:01:20 -0600 Subject: [PATCH 020/114] add check to fates sp mode to make sure landuse isn't enabled --- bld/CLMBuildNamelist.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b450060736..54f0c0c997 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4414,6 +4414,10 @@ sub setup_logic_fates { if ( $nl->get_value('fates_spitfire_mode') > 0 ) { $log->fatal_error('fates_spitfire_mode can NOT be set to greater than 0 when use_fates_sp is true'); } + # fates landuse can't be on with FATES SP mode is active + if ( &value_is_true($nl->get_value('use_fates_luh')) ) { + $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + } } } my $var = "use_fates_inventory_init"; From 75f9cc54227f39f7baabc430de7a12506b892192 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 15:35:56 -0700 Subject: [PATCH 021/114] rename luh unit test that matched old test --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 899bd10b9c..0bf0ea5390 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1062,7 +1062,7 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, - "useinventorybutnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", + "useLUH2butnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", namelst=>"use_fates_luh=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", From ff3af55931b98e9cb7b9553717d10f2388954197 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 16:24:30 -0700 Subject: [PATCH 022/114] add build namelist unit tests for fates landuse v2 --- bld/unit_testers/build-namelist_test.pl | 41 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 0bf0ea5390..70243c5843 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,10 +163,10 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 1999; +my $ntests = 2006; if ( defined($opts{'compare'}) ) { - $ntests += 1353; + $ntests += 1360; } plan( tests=>$ntests ); @@ -1062,11 +1062,16 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, - "useLUH2butnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", + "useFATESLUH2butnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", namelst=>"use_fates_luh=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, + "useFATESLUPFTbutnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", + namelst=>"use_fates_lupft=.true.", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm4_5", + }, "inventoryfileDNE" =>{ options=>"-bgc fates -envxml_dir . -no-megan", namelst=>"use_fates_luh=.true., fluh_timeseries='zztop'", GLC_TWO_WAY_COUPLING=>"FALSE", @@ -1092,6 +1097,36 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, + "useFATESSPwithLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_sp=T,use_fates_luh=T", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode=1", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESHARVEST3WOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_luh=F,fates_harvest_mode=3", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESLUPFTWOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_lupft=T,use_fates_luh=F", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESLUPFTWONOCOMP" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_lupft=T,use_fates_nocomp=F", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESLUPFTWOFBG" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_lupft=T,use_fates_fixedbiogeog=F", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, "useFATESTRANSWdynPFT" =>{ options=>"-bgc fates -envxml_dir . -use_case 20thC_transient -no-megan", namelst=>"do_transient_pfts=T", GLC_TWO_WAY_COUPLING=>"FALSE", From 69154dab7b33706491bdabc634d9a80142bf0b35 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 16:37:07 -0700 Subject: [PATCH 023/114] update fates logging unit test to use new fates harvest mode --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- bld/unit_testers/build-namelist_test.pl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index a2df9b1d1e..edcfa36d27 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -814,7 +814,7 @@ types to vary over time. -Full pathname of fates landuse x pft data map. +Full pathname of fates landuse x pft static data map. "FALSE", phys=>"clm4_5", }, - # TODO SSR: Replace this with fates_harvest_mode "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"use_fates_logging=.true.", + namelst=>"fates_harvest_mode=1", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, From 5c5ca6f8e40cc6fe69d9b9a7edf32ce5242a7629 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 17:49:34 -0600 Subject: [PATCH 024/114] minor update --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 3b2dabd057..f674849b6f 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 2006; +my $ntests = 2007; if ( defined($opts{'compare'}) ) { $ntests += 1360; From 2a88002ea1a916d21da69b05c6621774cca74b39 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 7 May 2024 10:26:16 -0700 Subject: [PATCH 025/114] change lupft check to fbg + luh check to mirror fates-side logic --- src/utils/clmfates_interfaceMod.F90 | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b0ae0044f3..048824a83a 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -398,7 +398,6 @@ subroutine CLMFatesGlobals2() integer :: pass_use_potentialveg integer :: pass_num_luh_states integer :: pass_num_luh_transitions - integer :: pass_lupftdat call t_startf('fates_globals2') @@ -704,7 +703,7 @@ subroutine init(this, bounds_proc, flandusepftdat) end if ! Retrieve the landuse x pft static data if the file is present - if (use_fates_lupft) then + if (use_fates_fixed_biogeog .and. use_fates_luh) then call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground) end if @@ -815,23 +814,23 @@ subroutine init(this, bounds_proc, flandusepftdat) this%fates(nc)%sites(s)%lon = grc%londeg(g) ! Transfer the landuse x pft data to fates via bc_in if file is given - if (use_fates_lupft) then - this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) - this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) - end if - - if (.not. use_fates_lupft) then - ! initialize static layers for reduced complexity FATES versions from HLM - ! maybe make this into a subroutine of it's own later. - this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 - do m = surfpft_lb,surfpft_ub - ft = m - surfpft_lb - this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) - end do + if (use_fates_fixed_biogeog) then + if (use_fates_luh) then + this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) + this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) + else + ! initialize static layers for reduced complexity FATES versions from HLM + ! maybe make this into a subroutine of it's own later. + this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 + do m = surfpft_lb,surfpft_ub + ft = m - surfpft_lb + this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) + end do - if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then - write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8 - call endrun(msg=errMsg(sourcefile, __LINE__)) + if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then + write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8 + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if end if end if end do !site @@ -876,7 +875,7 @@ subroutine init(this, bounds_proc, flandusepftdat) call create_fates_fire_data_method( this%fates_fire_data_method ) ! deallocate the local landuse x pft array - if (use_fates_lupft) then + if (use_fates_fixed_biogeog .and. use_fates_luh) then deallocate(landuse_pft_map) deallocate(landuse_bareground) end if From 0bcf80acea865f2df37d13911aa6b9d167622a66 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 1 May 2024 16:37:32 -0600 Subject: [PATCH 026/114] FatesColdLUH2 tests now use use_fates_nocomp false. --- cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm | 1 + 1 file changed, 1 insertion(+) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm index 854c21407f..917ba314b3 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm @@ -1 +1,2 @@ use_fates_luh = .true. +use_fates_nocomp = .false. From 0edcb1b5b118c7029807a05e1ce3773396c6ec7f Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 10:22:47 -0600 Subject: [PATCH 027/114] Update FATES external to latest ckoven/luh2_nocomp_merge. --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index b689141aaf..e1bc1696af 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/ckoven/fates -hash = c1a7453c8331277a156a0ee158a870c1b8598a9f +hash = 153b0bda9c96f18e8d2a93887a082bc7a31b574b required = True [externals_description] From 92fb80687f707c1799cacea85bc64bc9c1cd9f89 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 13:25:19 -0600 Subject: [PATCH 028/114] Update FatesColdLUH2 testdef. --- .../testmods_dirs/clm/FatesColdLUH2/user_nl_clm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm index 917ba314b3..970e7df7cd 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm @@ -1,2 +1,11 @@ + +! Run a transient case, with vegetation starting from bare ground, but land use starting from LUH state vector on starting date, in a nocomp configuration. +! From Charlie's list of valid FATES configurations: +! https://docs.google.com/spreadsheets/d/1eE3sRMYxfocZKbT8uIQhXpjjtfM2feXPRSWXJNoo4jM/edit#gid=0 +flandusepftdat = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc' use_fates_luh = .true. -use_fates_nocomp = .false. +use_fates_nocomp = .true. +use_fates_fixed_biogeog = .true. +use_fates_sp = .false. +use_fates_potentialveg = .false. +fluh_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc' From f6728017c7726f947492179f88031cccfa81181f Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 13:26:56 -0600 Subject: [PATCH 029/114] Add FatesColdLUH2Mode0 testdef. --- cime_config/testdefs/testlist_clm.xml | 9 +++++++++ .../clm/FatesColdLUH2Mode0/include_user_mods | 1 + .../testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm | 1 + 3 files changed, 11 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 4184cc7e1f..022bb9ad73 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2910,6 +2910,15 @@ + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm new file mode 100644 index 0000000000..929a8e6e14 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 0 From 05332fb117e7ed94abcc09c5c66f5db8d8885638 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 10:53:59 -0700 Subject: [PATCH 030/114] Remove get_do_harvest dependency for fates harvest modes --- src/dyn_subgrid/dynSubgridDriverMod.F90 | 7 ++- src/utils/clmfates_interfaceMod.F90 | 71 +++++++++---------------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index e5ca3f002e..b12b135b59 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -89,6 +89,11 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! Note that dynpft_init needs to be called from outside any loops over clumps - so ! this routine needs to be called from outside any loops over clumps. ! + ! + ! !USES: + use clm_varctl , only : fates_harvest_mode + use dynFATESLandUseChangeMod , only : fates_harvest_clmlanduse + ! ! !ARGUMENTS: type(bounds_type) , intent(in) :: bounds_proc ! processor-level bounds type(glc_behavior_type) , intent(in) :: glc_behavior @@ -123,7 +128,7 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! flanduse_timeseries file. However, this could theoretically be changed so that the ! harvest data were separated from the pftdyn data, allowing them to differ in the ! years over which they apply. - if (get_do_harvest()) then + if (get_do_harvest() .or. fates_harvest_mode >= fates_harvest_clmlanduse) then call dynHarvest_init(bounds_proc, harvest_filename=get_flanduse_timeseries()) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 048824a83a..308d5cee8e 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -169,7 +169,6 @@ module CLMFatesInterfaceMod use FATESFireBase , only : fates_fire_base_type use FATESFireFactoryMod , only : no_fire, scalar_lightning, successful_ignitions,& anthro_ignitions, anthro_suppression - use dynSubgridControlMod , only : get_do_harvest use dynHarvestMod , only : num_harvest_inst, harvest_varnames use dynHarvestMod , only : harvest_units, mass_units, unitless_units use dynHarvestMod , only : dynHarvest_interp_resolve_harvesttypes @@ -185,6 +184,7 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : dynFatesLandUseInterp use dynFATESLandUseChangeMod, only : num_landuse_harvest_vars use dynFATESLandUseChangeMod, only : fates_harvest_no_logging + use dynFATESLandUseChangeMod, only : fates_harvest_clmlanduse use dynFATESLandUseChangeMod, only : fates_harvest_luh_area use dynFATESLandUseChangeMod, only : landuse_harvest use dynFATESLandUseChangeMod, only : landuse_harvest_units @@ -489,13 +489,6 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_ed_st3',ival=pass_ed_st3) - if (fates_harvest_mode > fates_harvest_no_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 @@ -517,39 +510,28 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) - ! check fates logging namelist value first because hlm harvest can override it + ! FATES logging and harvest modes if (fates_harvest_mode > fates_harvest_no_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 - pass_lu_harvest = 1 - else - pass_lu_harvest = 0 - pass_num_lu_harvest_cats = 0 - end if + pass_logging = 1 ! Time driven logging, without landuse harvest + ! CLM landuse timeseries driven harvest rates + if (fates_harvest_mode == fates_harvest_clmlanduse) + pass_num_lu_harvest_cats = num_harvest_inst + pass_lu_harvest = 1 + + ! LUH2 landuse timeseries driven harvest rates + else if (fates_harvest_mode >= fates_harvest_luh_area) then + pass_lu_harvest = 1 + pass_num_lu_harvest_types = num_landuse_harvest_vars + else + pass_lu_harvest = 0 + pass_num_lu_harvest_cats = 0 + end if + ! FATES landuse modes if(use_fates_luh) then pass_use_luh = 1 pass_num_luh_states = num_landuse_state_vars pass_num_luh_transitions = num_landuse_transition_vars - - ! Do not set harvest passing variables to zero not in luh harvest modes - ! as the user may want to use the CLM landuse harvest with luh2 transitions - if(fates_harvest_mode >= fates_harvest_luh_area) then - ! End the run if do_harvest is true with this run mode. - ! This should be caught be the build namelist. - if(get_do_harvest()) then - call endrun(msg="do_harvest and fates_harvest_mode using luh2 harvest data are incompatible"//& - errmsg(sourcefile, __LINE__)) - else - pass_lu_harvest = 1 - end if - end if else pass_use_luh = 0 pass_num_luh_states = 0 @@ -567,8 +549,7 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) - ! Wait to set the harvest and logging variables after checking get_do_harvest - ! and fates_harvest_modes + ! Wait to set the harvest and logging variables after checking fates_harvest_modes 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) @@ -996,7 +977,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! Set the FATES global time and date variables call GetAndSetTime - if (get_do_harvest()) then + ! Get harvest rates for CLM landuse timeseries driven rates + if (fates_harvest_mode == fates_harvest_clmlanduse) 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) @@ -1122,7 +1104,7 @@ 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 - if (get_do_harvest()) then + if (fates_harvest_mode == fates_harvest_clmlanduse) if (after_start_of_harvest_ts) then this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else @@ -1140,6 +1122,11 @@ subroutine dynamics_driv(this, nc, bounds_clump, & write(iulog,*) harvest_units call endrun(msg=errMsg(sourcefile, __LINE__)) end if + + else if (fates_harvest_mode >= fates_harvest_luh_area) then + this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames + this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units endif if (use_fates_luh) then @@ -1147,12 +1134,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%hlm_luh_state_names = landuse_state_varnames this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames - - if (fates_harvest_mode >= fates_harvest_luh_area) then - this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) - this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames - this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units - end if end if end do From a35f91d53444c2ac7af2ee1434ae0f85431208b4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 11:15:18 -0700 Subject: [PATCH 031/114] fix check to be only during use of clm landuse timeseries for fates --- src/dyn_subgrid/dynSubgridDriverMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index b12b135b59..162247a0ff 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -128,7 +128,7 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! flanduse_timeseries file. However, this could theoretically be changed so that the ! harvest data were separated from the pftdyn data, allowing them to differ in the ! years over which they apply. - if (get_do_harvest() .or. fates_harvest_mode >= fates_harvest_clmlanduse) then + if (get_do_harvest() .or. fates_harvest_mode == fates_harvest_clmlanduse) then call dynHarvest_init(bounds_proc, harvest_filename=get_flanduse_timeseries()) end if From 74e86669d21c18043a057d955f55e17bd5e7913e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 11:48:57 -0700 Subject: [PATCH 032/114] fix passing num landuse harvest vars to the fates landuse harvest categories --- 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 308d5cee8e..cd94b6a15c 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -521,7 +521,7 @@ subroutine CLMFatesGlobals2() ! LUH2 landuse timeseries driven harvest rates else if (fates_harvest_mode >= fates_harvest_luh_area) then pass_lu_harvest = 1 - pass_num_lu_harvest_types = num_landuse_harvest_vars + pass_num_lu_harvest_cats = num_landuse_harvest_vars else pass_lu_harvest = 0 pass_num_lu_harvest_cats = 0 From fd07890223b3e92d91caa1a034055d1184bcff2e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 11:51:20 -0700 Subject: [PATCH 033/114] fix missing end if --- 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 cd94b6a15c..b9e9bf3031 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -526,6 +526,7 @@ subroutine CLMFatesGlobals2() pass_lu_harvest = 0 pass_num_lu_harvest_cats = 0 end if + end if ! FATES landuse modes if(use_fates_luh) then From 72ed62381b8312b0f0355b938d30c8b1a852cb31 Mon Sep 17 00:00:00 2001 From: loaner Date: Thu, 9 May 2024 16:25:53 -0700 Subject: [PATCH 034/114] update do_harvest to not be compatible with fates --- bld/CLMBuildNamelist.pm | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 54f0c0c997..e422109078 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2932,7 +2932,7 @@ sub setup_logic_do_harvest { $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')) && !&value_is_true($nl->get_value('use_fates'))) { + 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"; } @@ -4486,22 +4486,12 @@ sub setup_logic_fates { # Check fates_harvest_mode compatibility my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { - # using fates_harvest_mode with CLM landuse driver data - for user convienence - # if ( $nl->get_value($var) == 2) { - # # Make sure that do_harvest is set to true - # if ( ! &value_is_true($nl->get_value('do_harvest')) ) { - # $log->fatal_error("do_harvest must be true when $var is equal to 2" ); - # } # using fates_harvest mode with raw luh2 harvest data if ( $nl->get_value($var) > 2) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); } - # do_harvest can not be on if we are using the raw fates luh2 harvest data - if ( &value_is_true($nl->get_value('do_harvest')) ) { - $log->fatal_error("do_harvest can not be true when $var is greater than 2" ); - } } } } From f00ba49d552a3dc3578012f1cf32e6925ac224f9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 17:58:07 -0600 Subject: [PATCH 035/114] remove fates from the do_harvest section altogether --- bld/CLMBuildNamelist.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index e422109078..aafc7739a3 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2932,8 +2932,8 @@ sub setup_logic_do_harvest { $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')) && &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"; + elsif (!&value_is_true($nl->get_value('use_cn'))) { + $cannot_be_true = "$var can only be set to true when running with CN. Please set use_cn to true."; } if ($cannot_be_true) { From 278a901fc4821e0c6abef4e0c5ed9bbf41f64516 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 10 May 2024 10:43:41 -0700 Subject: [PATCH 036/114] fix if statements --- 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 b9e9bf3031..5c23f1c1dc 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -514,7 +514,7 @@ subroutine CLMFatesGlobals2() if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 ! Time driven logging, without landuse harvest ! CLM landuse timeseries driven harvest rates - if (fates_harvest_mode == fates_harvest_clmlanduse) + if (fates_harvest_mode == fates_harvest_clmlanduse) then pass_num_lu_harvest_cats = num_harvest_inst pass_lu_harvest = 1 @@ -979,7 +979,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call GetAndSetTime ! Get harvest rates for CLM landuse timeseries driven rates - if (fates_harvest_mode == fates_harvest_clmlanduse) + if (fates_harvest_mode == fates_harvest_clmlanduse) 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) @@ -1105,7 +1105,7 @@ 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 - if (fates_harvest_mode == fates_harvest_clmlanduse) + if (fates_harvest_mode == fates_harvest_clmlanduse) then if (after_start_of_harvest_ts) then this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else From d66ddff54439bd192b9ed8b07419a17cd3282656 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 13 May 2024 11:21:08 -0700 Subject: [PATCH 037/114] update fates_harvest_mode to use chars to set namelist options initial commit --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 10 ++++++---- src/main/clm_varctl.F90 | 2 +- src/main/controlMod.F90 | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index 4f326d82a5..d9bd0352ca 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -171,13 +171,14 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) end do ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled - if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & + trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then ! change the harvest varnames being used depending on the mode selected - if (fates_harvest_mode .eq. fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area ) then landuse_harvest_varnames => landuse_harvest_area_varnames landuse_harvest_units = landuse_harvest_area_units - elseif (fates_harvest_mode .eq. fates_harvest_luh_mass ) then + elseif (trim(fates_harvest_mode) .eq. fates_harvest_luh_mass ) then landuse_harvest_varnames => landuse_harvest_mass_varnames landuse_harvest_units = landuse_harvest_mass_units else @@ -256,7 +257,8 @@ subroutine dynFatesLandUseInterp(bounds, init_state) call landuse_state_vars(varnum)%get_current_data(this_data) landuse_states(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) end do - if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & + trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then do varnum = 1, num_landuse_harvest_vars call landuse_harvest_vars(varnum)%get_current_data(this_data) landuse_harvest(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 64d6e15747..59b72c8e74 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -302,7 +302,7 @@ module clm_varctl ! > 1 for external data (lightning and/or anthropogenic ignitions) ! see bld/namelist_files/namelist_definition_clm4_5.xml for details logical, public :: use_fates_tree_damage = .false. ! true => turn on tree damage module - integer, public :: fates_harvest_mode = 0 ! 0 for no harvest/logging; 1-4 for harvest mode options + character(len=256), public :: fates_harvest_mode = '' ! five different harvest modes; see namelist definition 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 diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 55dd92305d..1dd432bb7e 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -775,7 +775,7 @@ subroutine control_spmd() call mpi_bcast (for_testing_allow_interp_non_ciso_to_ciso, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_spitfire_mode, 1, MPI_INTEGER, 0, mpicom, ier) - call mpi_bcast (fates_harvest_mode, 1, MPI_INTEGER, 0, mpicom, ier) + call mpi_bcast (fates_harvest_mode, len(fates_harvest_mode) , MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_tree_damage, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) From 458c788eb6b7ca8b6351a5c3e4ebfae7d8364e21 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 13 May 2024 15:07:05 -0700 Subject: [PATCH 038/114] add default pass values for logging and harvest --- 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 5c23f1c1dc..ba6c59143f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -511,6 +511,9 @@ subroutine CLMFatesGlobals2() call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) ! FATES logging and harvest modes + pass_logging = 0 + pass_lu_harvest = 0 + pass_num_lu_harvest_cats = 0 if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 ! Time driven logging, without landuse harvest ! CLM landuse timeseries driven harvest rates @@ -522,9 +525,6 @@ subroutine CLMFatesGlobals2() else if (fates_harvest_mode >= fates_harvest_luh_area) then pass_lu_harvest = 1 pass_num_lu_harvest_cats = num_landuse_harvest_vars - else - pass_lu_harvest = 0 - pass_num_lu_harvest_cats = 0 end if end if From 28f5bc36108af5281f3fdfd286b43bac5a849786 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 13 May 2024 15:25:00 -0700 Subject: [PATCH 039/114] update fates_harvest_mode to accept strings --- bld/CLMBuildNamelist.pm | 4 +-- bld/namelist_files/namelist_defaults_ctsm.xml | 6 ++--- .../namelist_definition_ctsm.xml | 17 ++++++------ bld/unit_testers/build-namelist_test.pl | 6 ++--- .../clm/FatesColdLUH2Mode0/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode1/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode2/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode3/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode4/user_nl_clm | 2 +- src/dyn_subgrid/dynSubgridDriverMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 27 ++++++++++--------- 11 files changed, 37 insertions(+), 35 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index aafc7739a3..456447925c 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4478,7 +4478,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh must be true when $var is true" ); } - if ( $nl->get_value('fates_harvest_mode') > 0) { + if ( $nl->get_value('fates_harvest_mode') ne 'no_harvest') { $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); } } @@ -4487,7 +4487,7 @@ sub setup_logic_fates { my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { # using fates_harvest mode with raw luh2 harvest data - if ( $nl->get_value($var) > 2) { + if ( $nl->get_value($var) eq 'luhdata_area' || $nl->get_value($var) eq 'luhdata_mass' ) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 9d2a34b7bf..5da9cb22bf 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2759,7 +2759,7 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 0 -0 +no_harvest .false. .false. .false. @@ -2769,8 +2769,8 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. +.true. +.true. .true. .true. .false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index edcfa36d27..03b1e9e64d 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -735,14 +735,14 @@ Toggle to turn on FATES satellite phenology mode (only relevant if FATES is bein -Set FATES harvesting mode by setting fates_harvest_mode > 0. + group="clm_inparm" valid_values="no_harvest_event_code,surfdata_file,luhdata_area,luhdata_mass"> +Set FATES harvesting mode by setting fates_harvest_mode to a valid string option. Allowed values are: - 0 : no fates harvesting of any kind - 1 : fates logging via fates logging event codes (see fates parameter file) only - 2 : fates harvest driven by CLM landuse timeseries data (dynHarvestMod) - 3 : fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) - 4 : fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) + no_harvest: no fates harvesting of any kind + event_code: fates logging via fates logging event codes (see fates parameter file) only + surfdata_file: fates harvest driven by CLM landuse timeseries data (dynHarvestMod) + luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) + luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) If TRUE, enable use of land use harmonization (LUH) state and transition data from luh_timeseries file. -This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harvest -data (fates_harvest_mode >= 3) +This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harvest data (Also, only valid for use_fates = true and is incompatible with transient runs currently.) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index f674849b6f..973fdffd16 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1047,7 +1047,7 @@ sub cat_and_create_namelistinfile { phys=>"clm4_5", }, "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"fates_harvest_mode=1", + namelst=>"fates_harvest_mode=event_code", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, @@ -1102,12 +1102,12 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_potentialveg=T,fates_harvest_mode=1", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode=event_code", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, "useFATESHARVEST3WOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_luh=F,fates_harvest_mode=3", + namelst=>"use_fates_luh=F,fates_harvest_mode=luhdata_area", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm index 929a8e6e14..b3b338e232 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 0 +fates_harvest_mode = no_harvest diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm index dea75b71e7..c0e1c476be 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 1 +fates_harvest_mode = event_code diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm index fd4c74fe57..61e1daaa93 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 2 +fates_harvest_mode = surfdata_file diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm index 3332e9e526..d760105e68 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 3 +fates_harvest_mode = luhdata_area diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm index 13dae9efee..bb5f30f75d 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 4 +fates_harvest_mode = luhdata_mass diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index 162247a0ff..faef029b40 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -128,7 +128,7 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! flanduse_timeseries file. However, this could theoretically be changed so that the ! harvest data were separated from the pftdyn data, allowing them to differ in the ! years over which they apply. - if (get_do_harvest() .or. fates_harvest_mode == fates_harvest_clmlanduse) then + if (get_do_harvest() .or. trim(fates_harvest_mode) == fates_harvest_clmlanduse) then call dynHarvest_init(bounds_proc, harvest_filename=get_flanduse_timeseries()) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index ba6c59143f..4205802088 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -186,6 +186,7 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : fates_harvest_no_logging use dynFATESLandUseChangeMod, only : fates_harvest_clmlanduse use dynFATESLandUseChangeMod, only : fates_harvest_luh_area + use dynFATESLandUseChangeMod, only : fates_harvest_luh_mass use dynFATESLandUseChangeMod, only : landuse_harvest use dynFATESLandUseChangeMod, only : landuse_harvest_units use dynFATESLandUseChangeMod, only : landuse_harvest_varnames @@ -514,20 +515,25 @@ subroutine CLMFatesGlobals2() pass_logging = 0 pass_lu_harvest = 0 pass_num_lu_harvest_cats = 0 - if (fates_harvest_mode > fates_harvest_no_logging) then + if (trim(fates_harvest_mode) /= fates_harvest_no_logging) then pass_logging = 1 ! Time driven logging, without landuse harvest ! CLM landuse timeseries driven harvest rates - if (fates_harvest_mode == fates_harvest_clmlanduse) then + if (trim(fates_harvest_mode) == fates_harvest_clmlanduse) then pass_num_lu_harvest_cats = num_harvest_inst pass_lu_harvest = 1 ! LUH2 landuse timeseries driven harvest rates - else if (fates_harvest_mode >= fates_harvest_luh_area) then + else if (trim(fates_harvest_mode)== fates_harvest_luh_area .or. & + trim(fates_harvest_mode)== fates_harvest_luh_mass) then pass_lu_harvest = 1 pass_num_lu_harvest_cats = num_landuse_harvest_vars end if 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) + ! FATES landuse modes if(use_fates_luh) then pass_use_luh = 1 @@ -550,11 +556,6 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) - ! Wait to set the harvest and logging variables after checking fates_harvest_modes - 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 else @@ -979,7 +980,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call GetAndSetTime ! Get harvest rates for CLM landuse timeseries driven rates - if (fates_harvest_mode == fates_harvest_clmlanduse) then + if (trim(fates_harvest_mode) == fates_harvest_clmlanduse) 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) @@ -1105,7 +1106,7 @@ 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 - if (fates_harvest_mode == fates_harvest_clmlanduse) then + if (trim(fates_harvest_mode) == fates_harvest_clmlanduse) then if (after_start_of_harvest_ts) then this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else @@ -1124,7 +1125,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call endrun(msg=errMsg(sourcefile, __LINE__)) end if - else if (fates_harvest_mode >= fates_harvest_luh_area) then + else if (trim(fates_harvest_mode) == fates_harvest_luh_area .or. & + trim(fates_harvest_mode) == fates_harvest_luh_mass) then this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units @@ -2082,7 +2084,8 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames - if (fates_harvest_mode >= fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) == fates_harvest_luh_area .or. & + trim(fates_harvest_mode) == fates_harvest_luh_mass) then this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units From f19a080721f5fffa96b580da51a170cbe80d4244 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 15 May 2024 17:59:34 -0600 Subject: [PATCH 040/114] add more landuse graceful failures If luh + fbg are present fail if flandusepftdat isn't valid. Don't allow fluh_timeseries to be defined if in potential veg mode to avoid confusing users that it is needed. --- bld/CLMBuildNamelist.pm | 71 ++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index aafc7739a3..0d8ca732b4 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4433,21 +4433,9 @@ sub setup_logic_fates { } } # make sure that fates landuse x pft mode has the necessary run mode configurations - # and add the necessary landuse x pft static mapping data default if not defined my $var = "use_fates_lupft"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_lupft is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$fname does NOT point to a valid filename" ); - } - - # make sure that nocomp and fbg mode are enabled as well as use_fates_luh my @list = ( "use_fates_luh", "use_fates_nocomp", "use_fates_fixed_biogeog" ); foreach my $var ( @list ) { if ( ! &value_is_true($nl->get_value($var)) ) { @@ -4457,31 +4445,56 @@ sub setup_logic_fates { } } # check that fates landuse change mode has the necessary luh2 landuse timeseries data - # and add the default if not defined + # and add the default if not defined. Do not add default if use_fates_potentialveg is true. + # If fixed biogeography is on, make sure that flandusepftdat is avilable. my $var = "use_fates_luh"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "fluh_timeseries"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$fname does NOT point to a valid filename" ); - } + $var = "use_fates_potentialveg"; + if ( defined($nl->get_value($var)) ) { + if ( ! &value_is_true($nl->get_value($var)) ) { + $var = "fluh_timeseries"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } + $var = "use_fates_fixed_biogeog"; + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true($nl->get_value($var)) ) { + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true my $var = "use_fates_potentialveg"; if ( defined($nl->get_value($var)) ) { - if ( &value_is_true($nl->get_value($var)) ) { - if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error("use_fates_luh must be true when $var is true" ); - } - if ( $nl->get_value('fates_harvest_mode') > 0) { - $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); - } - } + if ( &value_is_true($nl->get_value($var)) ) { + if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { + $log->fatal_error("use_fates_luh must be true when $var is true" ); + } + if ( $nl->get_value('fates_harvest_mode') > 0) { + $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + } + my $var = "fluh_timeseries"; + if ( defined($nl->get_value($var)) ) { + $log->fatal_error("fluh_timeseries can not be defined when use_fates_potentialveg is true" ); + } + } } # Check fates_harvest_mode compatibility my $var = "fates_harvest_mode"; From 7c5c632f02b54f2285bdfb3902834d78715077f7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 16 May 2024 15:03:31 -0600 Subject: [PATCH 041/114] fix namelist definition --- bld/namelist_files/namelist_definition_ctsm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 03b1e9e64d..58e0aca3a6 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -734,8 +734,8 @@ Toggle to turn on no competition mode (only relevant if FATES is being used). Toggle to turn on FATES satellite phenology mode (only relevant if FATES is being used). - + Set FATES harvesting mode by setting fates_harvest_mode to a valid string option. Allowed values are: no_harvest: no fates harvesting of any kind From 0266a70e98142750e6c34494740a8dd3e600a93c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 16 May 2024 15:22:10 -0600 Subject: [PATCH 042/114] update landuse parameters from ints to chars --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index d9bd0352ca..f330ee2b78 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -35,11 +35,11 @@ module dynFATESLandUseChangeMod integer, public, parameter :: num_landuse_harvest_vars = 5 ! Define the fates landuse namelist mode switch values - integer, public, parameter :: fates_harvest_no_logging = 0 - integer, public, parameter :: fates_harvest_logging_only = 1 - integer, public, parameter :: fates_harvest_clmlanduse = 2 - integer, public, parameter :: fates_harvest_luh_area = 3 - integer, public, parameter :: fates_harvest_luh_mass = 4 + character(len=13), public, parameter :: fates_harvest_no_logging = 'no_harvest' + character(len=13), public, parameter :: fates_harvest_logging_only = 'event_code' + character(len=13), public, parameter :: fates_harvest_clmlanduse = 'surfdata_file' + character(len=13), public, parameter :: fates_harvest_luh_area = 'luhdata_area' + character(len=13), public, parameter :: fates_harvest_luh_mass = 'luhdata_mass' ! Define landuse harvest unit integer representation integer, public, parameter :: landuse_harvest_area_units = 1 From 438d85a58b120a1329db4c47520ff473a40bcc5b Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 17 May 2024 09:27:55 -0600 Subject: [PATCH 043/114] Added a missing bracket --- bld/CLMBuildNamelist.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index ad378ffc6d..3658f681af 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -785,7 +785,7 @@ sub setup_cmdl_fates_mode { "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries", - "flandusepftdat","use_fates_potentialveg","use_fates_lupft","fates_history_dimlevel"); + "flandusepftdat","use_fates_potentialveg","use_fates_lupft","fates_history_dimlevel" ); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { @@ -4517,7 +4517,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_inventory_init","fates_seeddisp_cadence","fates_history_dimlevel", - "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage"); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, @@ -4564,12 +4564,12 @@ sub setup_logic_fates { # fates landuse can't be on with FATES SP mode is active if ( &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + } # hydro isn't currently supported to work when FATES SP mode is active if (&value_is_true( $nl->get_value('use_fates_planthydro') )) { $log->fatal_error('fates sp mode is currently not supported to work with fates hydro'); - } } } From e6f62c431b05460f62c6549e464797df7a7ebf58 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 17 May 2024 15:56:00 -0600 Subject: [PATCH 044/114] fix reading of fates_harvest_modes during namelist build checks --- bld/CLMBuildNamelist.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 01f7918d62..c1ec60fb33 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4487,8 +4487,9 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh must be true when $var is true" ); } - if ( $nl->get_value('fates_harvest_mode') ne 'no_harvest') { - $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + my $var = remove_leading_and_trailing_quotes($nl->get_value('fates_harvest_mode')); + if ( $var ne 'no_harvest') { + $log->fatal_error("fates_harvest_mode set to $var. It must set to no_harvest when use_potential_veg is true." ); } my $var = "fluh_timeseries"; if ( defined($nl->get_value($var)) ) { @@ -4500,10 +4501,22 @@ sub setup_logic_fates { my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { # using fates_harvest mode with raw luh2 harvest data - if ( $nl->get_value($var) eq 'luhdata_area' || $nl->get_value($var) eq 'luhdata_mass' ) { + my $mode = remove_leading_and_trailing_quotes($nl->get_value($var)); + if ( $mode eq 'luhdata_area' || $mode eq 'luhdata_mass' ) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); + $log->fatal_error("use_fates_luh is required to be true when $var is luhdata_mass or luhdata_area" ); + } + } elsif ( $mode eq 'surfdata_file' ) { + # Check to make sure that the user set the flanduse_timeseries file + # Since the flanduse_timeseries logic checking is upstream of the fates logic, + # don't try and add the default here + my $var = "flanduse_timeseries"; + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when fates_harvest_mode is surfdata_file" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); } } } From 093f0666b9b1d78701240a2036e1efca8e073133 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 17 May 2024 16:18:20 -0600 Subject: [PATCH 045/114] minor comment update --- bld/CLMBuildNamelist.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index c1ec60fb33..e563bdffa8 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4510,7 +4510,8 @@ sub setup_logic_fates { } elsif ( $mode eq 'surfdata_file' ) { # Check to make sure that the user set the flanduse_timeseries file # Since the flanduse_timeseries logic checking is upstream of the fates logic, - # don't try and add the default here + # don't add the default here. The onus is on the user to match the correct timeseries + # data to the correct surface dataset resolution my $var = "flanduse_timeseries"; my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { From 3967d77a17e4e6a02362aec42aa3feb187ba6c72 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 22 May 2024 10:28:47 -0600 Subject: [PATCH 046/114] new fates api 36 paramfile default --- 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 6ef91bb4a0..fdfeba7719 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -481,7 +481,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -lnd/clm2/paramdata/fates_params_api.35.0.0_12pft_c240326.nc +lnd/clm2/paramdata/fates_params_api.36.0.0_12pft_c240517.nc From 5b30740bd91e421639bb46239f4d921b8e767b54 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 22 May 2024 13:37:16 -0600 Subject: [PATCH 047/114] Pin FATES external to commit a997af5. --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index cfb7beb40f..a8d53e4fdb 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/ckoven/fates -branch = luh2_nocomp_merge +hash = a997af58f38db8ffda259e11f3abcc65478a4903 required = True [externals_description] From 2a7ca01b2177b480e8897fd2921bf00a7ac9c48f Mon Sep 17 00:00:00 2001 From: loaner Date: Wed, 22 May 2024 17:43:48 -0700 Subject: [PATCH 048/114] add systemtest for potential vegetation spin up --- cime_config/SystemTests/pvt.py | 120 ++++++++++++++++++++ cime_config/SystemTests/systemtest_utils.py | 20 +++- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 cime_config/SystemTests/pvt.py diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py new file mode 100644 index 0000000000..e18022220d --- /dev/null +++ b/cime_config/SystemTests/pvt.py @@ -0,0 +1,120 @@ +""" +FATES land use potential vegetation spin up + transient test + +This is a FATES specific test: + +1) conduct a spinup with use_fates_potentialveg on + - write restart file + - use CLM_ACCELERATED_SPINUP? +2) run a transient landuse case with use_fates_lupft + - start from the restart file generated in (1) + +""" +from CIME.XML.standard_module_setup import * +from CIME.SystemTests.system_tests_common import SystemTestsCommon +from systemtest_utils import read_user_nl_clm +import shutil, glob, os + +logger = logging.getLogger(__name__) + +class PVT(SystemTestsCommon): + def __init_(self,case): + SystemTestsCommon.__init__(self,case) + + # Do not allow PVT to be run with certain testmods + # Should this be targeted to a specific testmod for simplicity for now? + # Technically this could be run with the luh fates_harvest_modes + casebaseid = self._case.get_value("CASEBASEID") + casebasid = casebaseid.split("-")[-1] + if casebaseid[0:10] != "FatesLUPFT": + error_message = ( + "Only call PVT with test FatesLUPFT" + ) + logger.error(error_message) + raise RuntimeError(error_message) + + # Only allow to run if resolution is 4x5 for now + # Eventually we could set this up to generate the necessary land use x pft mapping + # on the fly, although this would also require generating the land use timeseries + # regridding on the fly which is a more time consuming endevour currently + lnd_grid = self._case.get_value("LND_GRID") + if lnd_grid != "4x5": + error_message = ( + "PVT can currently only be run with 4x5 resolution" + ) + logger.error(error_message) + raise RuntimeError(error_message) + + def run_phase(self): + # ------------------------------------------------------------------- + # (1) Run FATES spin-up case in potential vegetation mode + # ------------------------------------------------------------------- + orig_case = self._case + orig_casevar = self._case.get_value("CASE") + caseroot = self._case.get_value("CASEROOT") + + # clone the main case to create spinup case + logger.info("PVT log: cloning setup") + clone_path = "{}.potveg".format(caseroot) + if os.path.exists(clone_path): + shutil.rmtree(clone_path) + logger.info("PVT log: cloning") + clone = self._case.create_clone(clone_path, keepexe=True) + logger.info("PVT log: cloning complete") + + # setup the clone case + os.chdir(clone_path) + self._set_active_case(clone) + self._setup_all() + + # Modify the spin up case to use the potential vegetation mode. + # Checks for incompatible cases and necessary mapping files are + # handled in the build case. + # use_fates_lupft should be set to true in the testmod + # save off the harvest mode for reinstating later + found, hmode = self.read_user_nl_clm('fates_harvest_mode') + logger.info("PVT log: modify user_nl_clm file for spin up run") + # TODO: remove fates_harvest_mode if found + self._append_to_user_nl_clm( + [ + "use_fates_potentialveg = .true.", + ] + ) + + stop_n_pveg = 1 + with clone: + # clone.set_value("CLM_ACCELERATED_SPINUP", "on") + clone.set_value("STOP_N", stop_n_pveg) + + # Run the spin up case + # As per SSP test: + # "No history files expected, set suffix=None to avoid compare error" + logger.info("PVT log: starting spin-up run") + dout_sr = clone.get_value("DOUT_S_ROOT") + self._skip_pnl = False + self.run_indv(suffix=None, st_archive=True) + + # ------------------------------------------------------------------- + # (2) Run FATES transient case using restart file from spin-up + # ------------------------------------------------------------------- + os.chdir(caseroot) + self._set_active_case(orig_case) + + # logger.info("PVT log: modify user_nl_clm file for transient run") + # self._append_to_user_nl_clm( + # [ + # "use_fates_potentialveg = .true.", + # ] + # ) + + + self._case.set_value("CLM_ACCELERATED_SPINUP", "off") + self._case.set_value("RUN_TYPE", "hybrid") + self._case.set_value("GET_REFCASE", False) + self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) + self._case.set_value("RUN_REFDATE", "1700-01-01") + self._case.set_value("DOUT_S", False) + self._case.flush() + + # do the restart run (short term archiving is off) + self.run_indv() diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index c5ac986abd..8447934797 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -2,7 +2,7 @@ Reduce code duplication by putting reused functions here. """ -import os, subprocess +import os, subprocess, re def cmds_to_setup_conda(caseroot): @@ -84,3 +84,21 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): except: print(f"ERROR trying to run {tool_name}.") raise + +def read_user_nl_clm(self,namelist_option): + user_nl_clm_path = os.path.join(self._get_caseroot(), "user_nl_clm") + with open(user_nl_clm_path) as f: + user_nl_clm_text = f.read() + reg = fr'{namelist_option}\s*=\s*([^\n]+)' + find_out = re.findall(reg, user_nl_clm_text) + # This could be more robust + if len(find_out) == 0: + return 0, False + elif len(find_out) > 1: + error_message = ( + "ERROR: read_user_nl_clm: namelist option is set more than once" + ) + # logger.error(error_message) + raise RuntimeError(error_message) + else: + return find_out[0], True From b7cf13f6dcfd6c975de294ef90122bb4e2fc0d3e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 13:47:07 -0700 Subject: [PATCH 049/114] add PVT system test to the config_test xml file --- cime_config/config_tests.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cime_config/config_tests.xml b/cime_config/config_tests.xml index c0b6afed9d..8a4388c664 100644 --- a/cime_config/config_tests.xml +++ b/cime_config/config_tests.xml @@ -123,6 +123,18 @@ This defines various CTSM-specific system tests $STOP_N + + FATES potential vegetarion spin-up + land use transient run test + 1 + ndays + startup + 4 + FALSE + FALSE + $STOP_OPTION + $STOP_N + + Generate prescribed maturity requirements, then test with them 1 From 8e35d80baf507185ef0dac47a4adee4bf975d47e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 14:29:02 -0600 Subject: [PATCH 050/114] add test mode for use_fates_lupft --- .../testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods | 1 + cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm | 1 + 2 files changed, 2 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods new file mode 100644 index 0000000000..4c7aa0f2b4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods @@ -0,0 +1 @@ +../Fates diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm new file mode 100644 index 0000000000..10044848a0 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm @@ -0,0 +1 @@ +use_fates_lupft = .true. From af5451b7e37d53d1192fb87315d01fb16b527ba1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 14:39:45 -0700 Subject: [PATCH 051/114] remove tabs and correct whitespace --- bld/CLMBuildNamelist.pm | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index acdad5c5cc..b17a245715 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4520,22 +4520,22 @@ sub setup_logic_fates { "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage" ); foreach my $var ( @list ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); } - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_potentialveg', 'use_fates'=>$nl_flags->{'use_fates'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), - 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), - 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), - 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_fixed_biogeog', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), - 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_potentialveg', 'use_fates'=>$nl_flags->{'use_fates'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), + 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_fixed_biogeog', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); @@ -4564,8 +4564,8 @@ sub setup_logic_fates { # fates landuse can't be on with FATES SP mode is active if ( &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); - } + $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + } # hydro isn't currently supported to work when FATES SP mode is active if (&value_is_true( $nl->get_value('use_fates_planthydro') )) { @@ -4608,7 +4608,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value($var)) ) { $var = "fluh_timeseries"; add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, - 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); @@ -4616,21 +4616,21 @@ sub setup_logic_fates { $log->fatal_error("$var does NOT point to a valid filename" ); } } - } + } $var = "use_fates_fixed_biogeog"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$var does NOT point to a valid filename" ); - } - } - } + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true From 00d23e9adb4139847dc5f855ff4ce43bc845b41e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 16:48:55 -0600 Subject: [PATCH 052/114] correct add default for fluh and flandusepftdat --- bld/CLMBuildNamelist.pm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b17a245715..d952e7fe89 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4607,8 +4607,8 @@ sub setup_logic_fates { if ( defined($nl->get_value($var)) ) { if ( ! &value_is_true($nl->get_value($var)) ) { $var = "fluh_timeseries"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, - 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); @@ -4620,17 +4620,17 @@ sub setup_logic_fates { $var = "use_fates_fixed_biogeog"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$var does NOT point to a valid filename" ); - } - } - } + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true From 2ac13bcb7aeec5a1772635edfe7c0f99be9c532d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 17:39:57 -0600 Subject: [PATCH 053/114] correct typos causing RunTimeError to be missed --- cime_config/SystemTests/pvt.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index e18022220d..c45c514f39 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -18,20 +18,17 @@ logger = logging.getLogger(__name__) class PVT(SystemTestsCommon): - def __init_(self,case): + def __init__(self,case): SystemTestsCommon.__init__(self,case) # Do not allow PVT to be run with certain testmods # Should this be targeted to a specific testmod for simplicity for now? # Technically this could be run with the luh fates_harvest_modes + error_message = None casebaseid = self._case.get_value("CASEBASEID") - casebasid = casebaseid.split("-")[-1] + casebaseid = casebaseid.split("-")[-1] if casebaseid[0:10] != "FatesLUPFT": - error_message = ( - "Only call PVT with test FatesLUPFT" - ) - logger.error(error_message) - raise RuntimeError(error_message) + error_message = (f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected.") # Only allow to run if resolution is 4x5 for now # Eventually we could set this up to generate the necessary land use x pft mapping @@ -39,12 +36,11 @@ def __init_(self,case): # regridding on the fly which is a more time consuming endevour currently lnd_grid = self._case.get_value("LND_GRID") if lnd_grid != "4x5": - error_message = ( - "PVT can currently only be run with 4x5 resolution" - ) + error_message = (f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected.") + + if error_message is not None: logger.error(error_message) raise RuntimeError(error_message) - def run_phase(self): # ------------------------------------------------------------------- # (1) Run FATES spin-up case in potential vegetation mode From f4ff559c831533ab9c901d1f44e5744740a8f302 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 16:45:42 -0700 Subject: [PATCH 054/114] remove tabs again --- bld/CLMBuildNamelist.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index d952e7fe89..0fb7ba9692 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4608,7 +4608,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value($var)) ) { $var = "fluh_timeseries"; add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, - 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); @@ -4620,17 +4620,17 @@ sub setup_logic_fates { $var = "use_fates_fixed_biogeog"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$var does NOT point to a valid filename" ); - } - } - } + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true From de8c0a33315693c9dc66b267bd255e703f9010c0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 13:53:13 -0600 Subject: [PATCH 055/114] update what new utility function returns as output --- cime_config/SystemTests/systemtest_utils.py | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index 8447934797..9470799a27 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -2,7 +2,7 @@ Reduce code duplication by putting reused functions here. """ -import os, subprocess, re +import os, subprocess, re, glob def cmds_to_setup_conda(caseroot): @@ -84,21 +84,26 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): except: print(f"ERROR trying to run {tool_name}.") raise +""" +Read a user_nl file and return the namelist option if found +""" +def find_user_nl_option(caseroot, component, namelist_option): + + # This is a copy of the CIME _get_list_of_user_nl_files + # which could be used if this moved into the CIME project + file_pattern = "user_nl_" + component + "*" + file_list = glob.glob(os.path.join(caseroot, file_pattern)) + + # Check that there is at least one file + if len(file_list) == 0: + raise RuntimeError("No user_nl files found for component " + component) -def read_user_nl_clm(self,namelist_option): - user_nl_clm_path = os.path.join(self._get_caseroot(), "user_nl_clm") - with open(user_nl_clm_path) as f: - user_nl_clm_text = f.read() - reg = fr'{namelist_option}\s*=\s*([^\n]+)' - find_out = re.findall(reg, user_nl_clm_text) - # This could be more robust - if len(find_out) == 0: - return 0, False - elif len(find_out) > 1: - error_message = ( - "ERROR: read_user_nl_clm: namelist option is set more than once" - ) - # logger.error(error_message) - raise RuntimeError(error_message) - else: - return find_out[0], True + # Read through the file list and look for a match and return the whole entry + output = {} + for one_file in file_list: + with open(one_file, "r") as user_nl_file: + user_nl_text = user_nl_file.read() + reg = fr'{namelist_option}.*?(?=,|\n)' + find_out = re.findall(reg, user_nl_text) + output[one_file] = find_out + return output From cd04c06c06e1399c262c970180f291d583eaf72b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 14:06:36 -0600 Subject: [PATCH 056/114] change dictionary to ordered dict --- cime_config/SystemTests/systemtest_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index 9470799a27..2591ac4223 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -3,6 +3,7 @@ """ import os, subprocess, re, glob +from collections import OrderedDict def cmds_to_setup_conda(caseroot): @@ -99,7 +100,7 @@ def find_user_nl_option(caseroot, component, namelist_option): raise RuntimeError("No user_nl files found for component " + component) # Read through the file list and look for a match and return the whole entry - output = {} + output = OrderedDict() for one_file in file_list: with open(one_file, "r") as user_nl_file: user_nl_text = user_nl_file.read() From dab63611a6088551ff2959f1c04bcfbc4b61c2db Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 16:13:59 -0600 Subject: [PATCH 057/114] pvt system init step update --- cime_config/SystemTests/pvt.py | 149 ++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 67 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index c45c514f39..184c5de289 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -12,7 +12,8 @@ """ from CIME.XML.standard_module_setup import * from CIME.SystemTests.system_tests_common import SystemTestsCommon -from systemtest_utils import read_user_nl_clm +from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files +from systemtest_utils import find_user_nl_option import shutil, glob, os logger = logging.getLogger(__name__) @@ -41,76 +42,90 @@ def __init__(self,case): if error_message is not None: logger.error(error_message) raise RuntimeError(error_message) - def run_phase(self): - # ------------------------------------------------------------------- - # (1) Run FATES spin-up case in potential vegetation mode - # ------------------------------------------------------------------- - orig_case = self._case - orig_casevar = self._case.get_value("CASE") - caseroot = self._case.get_value("CASEROOT") - - # clone the main case to create spinup case - logger.info("PVT log: cloning setup") - clone_path = "{}.potveg".format(caseroot) - if os.path.exists(clone_path): - shutil.rmtree(clone_path) - logger.info("PVT log: cloning") - clone = self._case.create_clone(clone_path, keepexe=True) - logger.info("PVT log: cloning complete") - # setup the clone case - os.chdir(clone_path) - self._set_active_case(clone) - self._setup_all() + # Look to see if a harvest mode has been set in the namelist and save off for the transient run + # If there are more than one entries in the dict, i.e. multiple user_nl_clm's found, abort. + # If there are multiple enteries the user_nl_clm, use the last one as the dict is ordered + caseroot = self._case.get_value("CASEROOT") + harvest_mode_dict = find_user_nl_option(caseroot, 'clm', 'fates_harvest_mode') + harvest_mode = None + if len(harvest_mode_dict) == 1: + hmod = harvest_mode_dict[next(reversed(harvest_mode_dict))] + if len(hmod) != 0: + harvest_mode = hmod[-1] + elif (len(harvest_mode_dict)) > 1: + raise RuntimeError('Multiple user_nl_clm files found. PVT assumes only a single user_nl_clm case') # Modify the spin up case to use the potential vegetation mode. # Checks for incompatible cases and necessary mapping files are # handled in the build case. # use_fates_lupft should be set to true in the testmod - # save off the harvest mode for reinstating later - found, hmode = self.read_user_nl_clm('fates_harvest_mode') - logger.info("PVT log: modify user_nl_clm file for spin up run") - # TODO: remove fates_harvest_mode if found - self._append_to_user_nl_clm( - [ - "use_fates_potentialveg = .true.", - ] - ) - - stop_n_pveg = 1 - with clone: - # clone.set_value("CLM_ACCELERATED_SPINUP", "on") - clone.set_value("STOP_N", stop_n_pveg) - - # Run the spin up case - # As per SSP test: - # "No history files expected, set suffix=None to avoid compare error" - logger.info("PVT log: starting spin-up run") - dout_sr = clone.get_value("DOUT_S_ROOT") - self._skip_pnl = False - self.run_indv(suffix=None, st_archive=True) + # If the testmod has a fates harvest mode, make sure to append 'no_harvest' + # to the spin up case - # ------------------------------------------------------------------- - # (2) Run FATES transient case using restart file from spin-up - # ------------------------------------------------------------------- - os.chdir(caseroot) - self._set_active_case(orig_case) - - # logger.info("PVT log: modify user_nl_clm file for transient run") - # self._append_to_user_nl_clm( - # [ - # "use_fates_potentialveg = .true.", - # ] - # ) - - - self._case.set_value("CLM_ACCELERATED_SPINUP", "off") - self._case.set_value("RUN_TYPE", "hybrid") - self._case.set_value("GET_REFCASE", False) - self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) - self._case.set_value("RUN_REFDATE", "1700-01-01") - self._case.set_value("DOUT_S", False) - self._case.flush() - - # do the restart run (short term archiving is off) - self.run_indv() + logger.info("PVT log: modify user_nl_clm file for spin up run") + added_content = ["use_fates_potentialveg = .true."] + if harvest_mode is not None: + added_content.append("fates_harvest_mode = 'no_harvest'") + append_to_user_nl_files(caseroot, "clm", added_content) + +# def run_phase(self): +# # ------------------------------------------------------------------- +# # (1) Run FATES spin-up case in potential vegetation mode +# # ------------------------------------------------------------------- +# orig_case = self._case +# orig_casevar = self._case.get_value("CASE") +# caseroot = self._case.get_value("CASEROOT") +# +# # clone the main case to create spinup case +# logger.info("PVT log: cloning setup") +# clone_path = "{}.potveg".format(caseroot) +# if os.path.exists(clone_path): +# shutil.rmtree(clone_path) +# logger.info("PVT log: cloning") +# clone = self._case.create_clone(clone_path, keepexe=True) +# logger.info("PVT log: cloning complete") +# +# # setup the clone case +# os.chdir(clone_path) +# self._set_active_case(clone) +# self._setup_all() +# +# +# stop_n_pveg = 1 +# with clone: +# # clone.set_value("CLM_ACCELERATED_SPINUP", "on") +# clone.set_value("STOP_N", stop_n_pveg) +# +# # Run the spin up case +# # As per SSP test: +# # "No history files expected, set suffix=None to avoid compare error" +# logger.info("PVT log: starting spin-up run") +# dout_sr = clone.get_value("DOUT_S_ROOT") +# self._skip_pnl = False +# self.run_indv(suffix=None, st_archive=True) +# +# # ------------------------------------------------------------------- +# # (2) Run FATES transient case using restart file from spin-up +# # ------------------------------------------------------------------- +# os.chdir(caseroot) +# self._set_active_case(orig_case) +# +# # logger.info("PVT log: modify user_nl_clm file for transient run") +# # self._append_to_user_nl_clm( +# # [ +# # "use_fates_potentialveg = .true.", +# # ] +# # ) +# +# +# self._case.set_value("CLM_ACCELERATED_SPINUP", "off") +# self._case.set_value("RUN_TYPE", "hybrid") +# self._case.set_value("GET_REFCASE", False) +# self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) +# self._case.set_value("RUN_REFDATE", "1700-01-01") +# self._case.set_value("DOUT_S", False) +# self._case.flush() +# +# # do the restart run (short term archiving is off) +# self.run_indv() From 175a3d01082437945f15660f75aca860c626d0a4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 18:14:18 -0600 Subject: [PATCH 058/114] pvt system test setup looks correct --- cime_config/SystemTests/pvt.py | 132 +++++++++++++-------------------- 1 file changed, 53 insertions(+), 79 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 184c5de289..6b2a958eaa 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -43,89 +43,63 @@ def __init__(self,case): logger.error(error_message) raise RuntimeError(error_message) - # Look to see if a harvest mode has been set in the namelist and save off for the transient run - # If there are more than one entries in the dict, i.e. multiple user_nl_clm's found, abort. - # If there are multiple enteries the user_nl_clm, use the last one as the dict is ordered + def run_phase(self): + # ------------------------------------------------------------------- + # (1) Run FATES spin-up case in potential vegetation mode + # ------------------------------------------------------------------- + orig_case = self._case + orig_casevar = self._case.get_value("CASE") caseroot = self._case.get_value("CASEROOT") - harvest_mode_dict = find_user_nl_option(caseroot, 'clm', 'fates_harvest_mode') - harvest_mode = None - if len(harvest_mode_dict) == 1: - hmod = harvest_mode_dict[next(reversed(harvest_mode_dict))] - if len(hmod) != 0: - harvest_mode = hmod[-1] - elif (len(harvest_mode_dict)) > 1: - raise RuntimeError('Multiple user_nl_clm files found. PVT assumes only a single user_nl_clm case') + + # clone the main case to create spinup case + logger.info("PVT log: cloning setup") + clone_path = "{}.potveg".format(caseroot) + if os.path.exists(clone_path): + shutil.rmtree(clone_path) + logger.info("PVT log: cloning") + clone = self._case.create_clone(clone_path, keepexe=True) + logger.info("PVT log: cloning complete") + + # setup the clone case + os.chdir(clone_path) + self._set_active_case(clone) + + # set the clone case values + stop_n_pveg = 1 + with clone: + # clone.set_value("CLM_ACCELERATED_SPINUP", "on") + clone.set_value("STOP_N", stop_n_pveg) # Modify the spin up case to use the potential vegetation mode. # Checks for incompatible cases and necessary mapping files are # handled in the build case. - # use_fates_lupft should be set to true in the testmod - # If the testmod has a fates harvest mode, make sure to append 'no_harvest' - # to the spin up case + # Turn off fates_harvest_mode for the spin up. logger.info("PVT log: modify user_nl_clm file for spin up run") - added_content = ["use_fates_potentialveg = .true."] - if harvest_mode is not None: - added_content.append("fates_harvest_mode = 'no_harvest'") - append_to_user_nl_files(caseroot, "clm", added_content) - -# def run_phase(self): -# # ------------------------------------------------------------------- -# # (1) Run FATES spin-up case in potential vegetation mode -# # ------------------------------------------------------------------- -# orig_case = self._case -# orig_casevar = self._case.get_value("CASE") -# caseroot = self._case.get_value("CASEROOT") -# -# # clone the main case to create spinup case -# logger.info("PVT log: cloning setup") -# clone_path = "{}.potveg".format(caseroot) -# if os.path.exists(clone_path): -# shutil.rmtree(clone_path) -# logger.info("PVT log: cloning") -# clone = self._case.create_clone(clone_path, keepexe=True) -# logger.info("PVT log: cloning complete") -# -# # setup the clone case -# os.chdir(clone_path) -# self._set_active_case(clone) -# self._setup_all() -# -# -# stop_n_pveg = 1 -# with clone: -# # clone.set_value("CLM_ACCELERATED_SPINUP", "on") -# clone.set_value("STOP_N", stop_n_pveg) -# -# # Run the spin up case -# # As per SSP test: -# # "No history files expected, set suffix=None to avoid compare error" -# logger.info("PVT log: starting spin-up run") -# dout_sr = clone.get_value("DOUT_S_ROOT") -# self._skip_pnl = False -# self.run_indv(suffix=None, st_archive=True) -# -# # ------------------------------------------------------------------- -# # (2) Run FATES transient case using restart file from spin-up -# # ------------------------------------------------------------------- -# os.chdir(caseroot) -# self._set_active_case(orig_case) -# -# # logger.info("PVT log: modify user_nl_clm file for transient run") -# # self._append_to_user_nl_clm( -# # [ -# # "use_fates_potentialveg = .true.", -# # ] -# # ) -# -# -# self._case.set_value("CLM_ACCELERATED_SPINUP", "off") -# self._case.set_value("RUN_TYPE", "hybrid") -# self._case.set_value("GET_REFCASE", False) -# self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) -# self._case.set_value("RUN_REFDATE", "1700-01-01") -# self._case.set_value("DOUT_S", False) -# self._case.flush() -# -# # do the restart run (short term archiving is off) -# self.run_indv() + added_content = ["use_fates_potentialveg = .true.","fates_harvest_mode = 'no_harvest'"] + append_to_user_nl_files(clone_path, "clm", added_content) + + # Run the spin up case + # As per SSP test: + # "No history files expected, set suffix=None to avoid compare error" + logger.info("PVT log: starting spin-up run") + dout_sr = clone.get_value("DOUT_S_ROOT") + self._skip_pnl = False + self.run_indv(suffix=None, st_archive=True) + + # ------------------------------------------------------------------- + # (2) Run FATES transient case using restart file from spin-up + # ------------------------------------------------------------------- + os.chdir(caseroot) + self._set_active_case(orig_case) + + self._case.set_value("CLM_ACCELERATED_SPINUP", "off") + self._case.set_value("RUN_TYPE", "hybrid") + self._case.set_value("GET_REFCASE", False) + self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) + self._case.set_value("RUN_REFDATE", "1700-01-01") + self._case.set_value("DOUT_S", False) + self._case.flush() + + # do the restart run (short term archiving is off) + self.run_indv() From 10728d91c8dcaeeb0719429ba11cf857fec50f68 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 18:15:04 -0600 Subject: [PATCH 059/114] add non-Cold based testmod for spinup + transient --- .../testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods | 1 + .../testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm | 1 + 2 files changed, 2 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods new file mode 100644 index 0000000000..1ceba4c200 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods @@ -0,0 +1 @@ +../FatesLUPFT diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm new file mode 100644 index 0000000000..426b41b49e --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 'luhdata_area' From 0537a6a32d586e62c237b6e2a6d645b7895bf76a Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 11:23:15 -0600 Subject: [PATCH 060/114] add potential veg check to avoid accessing timeseries file --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 88 ++++++++++---------- src/dyn_subgrid/dynSubgridDriverMod.F90 | 4 +- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index f330ee2b78..d7c1063494 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -107,6 +107,7 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) ! !USES: use clm_varctl , only : use_cn, use_fates_luh, fates_harvest_mode + use clm_varctl , only : use_fates_potentialveg use dynVarTimeUninterpMod , only : dyn_var_time_uninterp_type use dynTimeInfoMod , only : YEAR_POSITION_START_OF_TIMESTEP use dynTimeInfoMod , only : YEAR_POSITION_END_OF_TIMESTEP @@ -148,55 +149,58 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) landuse_transitions = 0._r8 landuse_harvest = 0._r8 - if (use_fates_luh) then + ! Avoid initializing the landuse timeseries file if in fates potential vegetation mode + if (.not. use_fates_potentialveg) then + if (use_fates_luh) then - ! Generate the dyn_file_type object. - ! Start calls get_prev_date, whereas end calls get_curr_date - dynFatesLandUse_file = dyn_file_type(landuse_filename, YEAR_POSITION_END_OF_TIMESTEP) + ! Generate the dyn_file_type object. + ! Start calls get_prev_date, whereas end calls get_curr_date + dynFatesLandUse_file = dyn_file_type(landuse_filename, YEAR_POSITION_END_OF_TIMESTEP) - ! Get initial land use data from the fates luh2 timeseries dataset - num_points = (bounds%endg - bounds%begg + 1) - landuse_shape(1) = num_points ! Does this need an explicit array shape to be passed to the constructor? - do varnum = 1, num_landuse_transition_vars - landuse_transition_vars(varnum) = dyn_var_time_uninterp_type( & - dyn_file=dynFatesLandUse_file, varname=landuse_transition_varnames(varnum), & - dim1name=grlnd, conversion_factor=1.0_r8, & - do_check_sums_equal_1=.false., data_shape=landuse_shape) - end do - do varnum = 1, num_landuse_state_vars - landuse_state_vars(varnum) = dyn_var_time_uninterp_type( & - dyn_file=dynFatesLandUse_file, varname=landuse_state_varnames(varnum), & - dim1name=grlnd, conversion_factor=1.0_r8, & - do_check_sums_equal_1=.false., data_shape=landuse_shape) - end do - - ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled - if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & - trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then - - ! change the harvest varnames being used depending on the mode selected - if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area ) then - landuse_harvest_varnames => landuse_harvest_area_varnames - landuse_harvest_units = landuse_harvest_area_units - elseif (trim(fates_harvest_mode) .eq. fates_harvest_luh_mass ) then - landuse_harvest_varnames => landuse_harvest_mass_varnames - landuse_harvest_units = landuse_harvest_mass_units - else - call endrun(msg=' undefined fates harvest mode selected'//errMsg(__FILE__, __LINE__)) - end if - - do varnum = 1, num_landuse_harvest_vars - landuse_harvest_vars(varnum) = dyn_var_time_uninterp_type( & - dyn_file=dynFatesLandUse_file, varname=landuse_harvest_varnames(varnum), & + ! Get initial land use data from the fates luh2 timeseries dataset + num_points = (bounds%endg - bounds%begg + 1) + landuse_shape(1) = num_points ! Does this need an explicit array shape to be passed to the constructor? + do varnum = 1, num_landuse_transition_vars + landuse_transition_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_transition_varnames(varnum), & + dim1name=grlnd, conversion_factor=1.0_r8, & + do_check_sums_equal_1=.false., data_shape=landuse_shape) + end do + do varnum = 1, num_landuse_state_vars + landuse_state_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_state_varnames(varnum), & dim1name=grlnd, conversion_factor=1.0_r8, & do_check_sums_equal_1=.false., data_shape=landuse_shape) end do + + ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & + trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then + + ! change the harvest varnames being used depending on the mode selected + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area ) then + landuse_harvest_varnames => landuse_harvest_area_varnames + landuse_harvest_units = landuse_harvest_area_units + elseif (trim(fates_harvest_mode) .eq. fates_harvest_luh_mass ) then + landuse_harvest_varnames => landuse_harvest_mass_varnames + landuse_harvest_units = landuse_harvest_mass_units + else + call endrun(msg=' undefined fates harvest mode selected'//errMsg(__FILE__, __LINE__)) + end if + + do varnum = 1, num_landuse_harvest_vars + landuse_harvest_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_harvest_varnames(varnum), & + dim1name=grlnd, conversion_factor=1.0_r8, & + do_check_sums_equal_1=.false., data_shape=landuse_shape) + end do + end if end if - end if - ! Since fates needs state data during initialization, make sure to call - ! the interpolation routine at the start - call dynFatesLandUseInterp(bounds,init_state=.true.) + ! Since fates needs state data during initialization, make sure to call + ! the interpolation routine at the start + call dynFatesLandUseInterp(bounds,init_state=.true.) + end if end subroutine dynFatesLandUseInit diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index faef029b40..ea1210521d 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -206,7 +206,7 @@ subroutine dynSubgrid_driver(bounds_proc, ! OUTSIDE any loops over clumps in the driver. ! ! !USES: - use clm_varctl , only : use_cn, use_fates, use_fates_luh + use clm_varctl , only : use_cn, use_fates, use_fates_luh, use_fates_potentialveg use dynInitColumnsMod , only : initialize_new_columns use dynConsBiogeophysMod , only : dyn_hwcontent_init, dyn_hwcontent_final use dynEDMod , only : dyn_ED @@ -295,7 +295,7 @@ subroutine dynSubgrid_driver(bounds_proc, call dynurban_interp(bounds_proc) end if - if (use_fates_luh) then + if (use_fates_luh .and. .not. use_fates_potentialveg) then call dynFatesLandUseInterp(bounds_proc) end if From dbbd7954a9b5e9a38d0afe45648b19dd5597c4fe Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 12:17:31 -0600 Subject: [PATCH 061/114] change fluh_timeseries to use an file with wider time range --- 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 fe34e9f4b8..37aff979f9 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1557,7 +1557,7 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc + >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1650-2015_c240216.nc .false. From 2848873409be7eddecb0f62326116afaf9a2e319 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 12:18:24 -0600 Subject: [PATCH 062/114] fix pvt system test --- cime_config/SystemTests/pvt.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 6b2a958eaa..05da935a0e 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -51,6 +51,11 @@ def run_phase(self): orig_casevar = self._case.get_value("CASE") caseroot = self._case.get_value("CASEROOT") + # Set the run start date based on the desired starting reference case year + refcase_year = 1700 + stop_n_pveg = 5 + startyear_pveg = refcase_year - stop_n_pveg + # clone the main case to create spinup case logger.info("PVT log: cloning setup") clone_path = "{}.potveg".format(caseroot) @@ -65,10 +70,11 @@ def run_phase(self): self._set_active_case(clone) # set the clone case values - stop_n_pveg = 1 with clone: - # clone.set_value("CLM_ACCELERATED_SPINUP", "on") + clone.set_value("CLM_ACCELERATED_SPINUP", "off") clone.set_value("STOP_N", stop_n_pveg) + clone.set_value("STOP_OPTION", "nyears") + clone.set_value("RUN_STARTDATE", "{}-01-01".format(startyear_pveg)) # Modify the spin up case to use the potential vegetation mode. # Checks for incompatible cases and necessary mapping files are @@ -93,11 +99,33 @@ def run_phase(self): os.chdir(caseroot) self._set_active_case(orig_case) + # Copy restart files from spin up to the transient case run directory + # obtain rpointer files and necessary restart files from short term archiving directory + rundir = self._case.get_value("RUNDIR") + + refdate = str(refcase_year) + '-01-01-00000' + rest_path = os.path.join(dout_sr, "rest", "{}".format(refdate)) + + for item in glob.glob("{}/*{}*".format(rest_path, refdate)): + link_name = os.path.join(rundir, os.path.basename(item)) + if os.path.islink(link_name) and os.readlink(link_name) == item: + # Link is already set up correctly: do nothing + # (os.symlink raises an exception if you try to replace an + # existing file) + pass + else: + os.symlink(item, link_name) + + for item in glob.glob("{}/*rpointer*".format(rest_path)): + shutil.copy(item, rundir) + + # Update run case settings self._case.set_value("CLM_ACCELERATED_SPINUP", "off") self._case.set_value("RUN_TYPE", "hybrid") self._case.set_value("GET_REFCASE", False) self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) - self._case.set_value("RUN_REFDATE", "1700-01-01") + self._case.set_value("RUN_REFDATE", "{}-01-01".format(refcase_year)) + self._case.set_value("RUN_STARTDATE", "{}-01-01".format(refcase_year)) self._case.set_value("DOUT_S", False) self._case.flush() From 709c3da94d1816b42268bf98a4b3d947bdc29a9d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 16:30:06 -0600 Subject: [PATCH 063/114] remove unnecessary import call --- cime_config/SystemTests/pvt.py | 2 -- cime_config/SystemTests/systemtest_utils.py | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 05da935a0e..feef6cb04c 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -8,12 +8,10 @@ - use CLM_ACCELERATED_SPINUP? 2) run a transient landuse case with use_fates_lupft - start from the restart file generated in (1) - """ from CIME.XML.standard_module_setup import * from CIME.SystemTests.system_tests_common import SystemTestsCommon from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files -from systemtest_utils import find_user_nl_option import shutil, glob, os logger = logging.getLogger(__name__) diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index 2591ac4223..c39f5171ba 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -85,9 +85,8 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): except: print(f"ERROR trying to run {tool_name}.") raise -""" -Read a user_nl file and return the namelist option if found -""" + +# Read a user_nl file and return the namelist option if found def find_user_nl_option(caseroot, component, namelist_option): # This is a copy of the CIME _get_list_of_user_nl_files From aed9d31c060ce247a3c7dd29ccf138552e56a1f4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 4 Jun 2024 10:40:46 -0700 Subject: [PATCH 064/114] remove hydro tests that are now passing per NGEET/FATES#1164 --- cime_config/testdefs/ExpectedTestFails.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 23e481222b..2d59568602 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -190,20 +190,6 @@ - - - FAIL - #2373 - - - - - - FAIL - FATES#701 - - - FAIL From 628be7bd39fb48acab7a456504be05c424f4510f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 11 Jun 2024 12:20:30 -0700 Subject: [PATCH 065/114] temporarily update fates to point to latest pull request commit hash --- .gitmodules | 4 ++-- src/fates | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 699ad22969..5b679e62bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "fates"] path = src/fates -url = https://github.com/NGEET/fates -fxtag = sci.1.73.0_api.35.0.0 +url = https://github.com/ckoven/fates +fxtag = 4b018eade498d063b21dddf26f77c9658ff80261 fxrequired = AlwaysRequired fxDONOTUSEurl = https://github.com/NCAR/fates-release diff --git a/src/fates b/src/fates index adfa664806..4b018eade4 160000 --- a/src/fates +++ b/src/fates @@ -1 +1 @@ -Subproject commit adfa6648063408d443f5cae671bd37f713d3e3e8 +Subproject commit 4b018eade498d063b21dddf26f77c9658ff80261 From 422f06f7389094b32baa763628865a53467d0830 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 25 Jun 2024 13:33:42 -0700 Subject: [PATCH 066/114] add fates potential vegetation spin up to transient test mod --- cime_config/testdefs/testlist_clm.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 85824a4404..0706a1ef53 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2615,6 +2615,15 @@ + + + + + + + + + From f9d8349021458c56912edf626a0c8e229e4f58da Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 25 Jun 2024 13:53:01 -0700 Subject: [PATCH 067/114] rename fates luh2 harvest modes --- .../include_user_mods | 0 .../{FatesColdLUH2Mode3 => FatesColdLUH2HarvestArea}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode1 => FatesColdLUH2HarvestEvent}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode4 => FatesColdLUH2HarvestMass}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode2 => FatesColdLUH2HarvestSurf}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode0 => FatesColdLUH2NoHarvest}/user_nl_clm | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode0 => FatesColdLUH2HarvestArea}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode3 => FatesColdLUH2HarvestArea}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode1 => FatesColdLUH2HarvestEvent}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode1 => FatesColdLUH2HarvestEvent}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode2 => FatesColdLUH2HarvestMass}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode4 => FatesColdLUH2HarvestMass}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode3 => FatesColdLUH2HarvestSurf}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode2 => FatesColdLUH2HarvestSurf}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode4 => FatesColdLUH2NoHarvest}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode0 => FatesColdLUH2NoHarvest}/user_nl_clm (100%) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm From 5a46b9382ee15fea803cb5e7091ed6915c2169a1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Jun 2024 10:53:02 -0700 Subject: [PATCH 068/114] remove fates land use no harvest due to overlap --- .../testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods | 1 - .../testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm | 1 - 2 files changed, 2 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods deleted file mode 100644 index 7eb8bb1579..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm deleted file mode 100644 index b3b338e232..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm +++ /dev/null @@ -1 +0,0 @@ -fates_harvest_mode = no_harvest From 3318d3b46df34013afcb5fadc4ad9f4184779f28 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Jun 2024 11:03:10 -0700 Subject: [PATCH 069/114] update fates landuse harvest test mod names --- cime_config/testdefs/testlist_clm.xml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 0706a1ef53..ed0627f242 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2570,7 +2570,7 @@ - + @@ -2579,7 +2579,7 @@ - + @@ -2588,7 +2588,7 @@ - + @@ -2597,16 +2597,7 @@ - - - - - - - - - - + @@ -2621,7 +2612,7 @@ - + From 34c4db0b185b4cb62fc6fa22de96b23c949c0dfd Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Jun 2024 23:47:14 -0700 Subject: [PATCH 070/114] Revert "Apply relevant changes from rgknox/fates-auto-params." This reverts commit 7216006b1c2400d1ca2932899671f9bcec85b6af. --- .../testdefs/testmods_dirs/clm/Fates/shell_commands | 5 ----- .../testdefs/testmods_dirs/clm/Fates/user_nl_clm | 1 - .../testdefs/testmods_dirs/clm/_scripts/README | 2 -- .../clm/_scripts/get_fates_shell_commands_vars.sh | 11 ----------- 4 files changed, 19 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/_scripts/README delete mode 100755 cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands index 3443bacef0..41a2342a51 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands @@ -1,7 +1,2 @@ ./xmlchange CLM_BLDNML_OPTS="-no-megan" --append ./xmlchange BFBFLAG="TRUE" - -SRCROOT=`./xmlquery SRCROOT --value` -. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh - -ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl 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 57adea1ff6..91df3e2e61 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -4,7 +4,6 @@ hist_nhtfrq = -24 hist_empty_htapes = .true. hist_ndens = 1 fates_spitfire_mode = 1 -fates_paramfile='${SRCROOT}/src/fates/parameter_files/binaries/${CASE}-params.nc' hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF','FATES_DAYSINCE_COLDLEAFON', diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/README b/cime_config/testdefs/testmods_dirs/clm/_scripts/README deleted file mode 100644 index 66eb22a375..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/_scripts/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains scripts that can be called in -shell_commands of multiple testmods. diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh b/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh deleted file mode 100755 index 382fb4e53e..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh +++ /dev/null @@ -1,11 +0,0 @@ -# This script should be called in shell_commands with -# . "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh -# where the leading period ensures it's run in the same shell. - -CASE=`./xmlquery CASE --value` -FATESDIR="${SRCROOT}/src/fates" -FATESPARAMDIR="${SRCROOT}/src/fates/parameter_files/binaries" -mkdir -p "${FATESPARAMDIR}" -FATESPARAMFILE="${FATESPARAMDIR}/${CASE}-params.nc" - -# No exit status because it should be called in the same shell. From 99d0f2bb4c93c739e5875781070a3d66c6bb8cbd Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 16:56:21 -0700 Subject: [PATCH 071/114] move fates landuse test mods to fates suite --- cime_config/testdefs/testlist_clm.xml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index ef4358f763..347fd33e8e 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2573,8 +2573,7 @@ - - + @@ -2582,8 +2581,7 @@ - - + @@ -2591,8 +2589,7 @@ - - + @@ -2600,8 +2597,7 @@ - - + @@ -2609,8 +2605,7 @@ - - + From 535033b959f6eab9c5d39d7edff410c47dfacb80 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 17:11:47 -0700 Subject: [PATCH 072/114] remove flandusepft and fluh_times pointers for testmod Use default currently. --- .../testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm | 2 -- 1 file changed, 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm index 970e7df7cd..e25490ffbb 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm @@ -2,10 +2,8 @@ ! Run a transient case, with vegetation starting from bare ground, but land use starting from LUH state vector on starting date, in a nocomp configuration. ! From Charlie's list of valid FATES configurations: ! https://docs.google.com/spreadsheets/d/1eE3sRMYxfocZKbT8uIQhXpjjtfM2feXPRSWXJNoo4jM/edit#gid=0 -flandusepftdat = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc' use_fates_luh = .true. use_fates_nocomp = .true. use_fates_fixed_biogeog = .true. use_fates_sp = .false. use_fates_potentialveg = .false. -fluh_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc' From 8793f477483bf0332bf423e3c7b3bb66b31f88aa Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 17:15:29 -0700 Subject: [PATCH 073/114] add readme noting grid resolution limitation --- cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README new file mode 100644 index 0000000000..79d6511d17 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README @@ -0,0 +1,2 @@ +Currently the FATES LUH2 category of test mods currently only supports +4x5 grid resolutions. From 95bf3f82fb09d4022ac1af285569e9c1fd1aefa0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 13:52:40 -0700 Subject: [PATCH 074/114] add fates harvest event expected failure --- cime_config/testdefs/ExpectedTestFails.xml | 7 +++++++ cime_config/testdefs/testlist_clm.xml | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 65419a5903..de864aeee6 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -165,6 +165,13 @@ + + + FAIL + FATES#1216 + + + FAIL diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 347fd33e8e..16359b88be 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2579,7 +2579,7 @@ - + @@ -2609,6 +2609,7 @@ + From 889cc97d4172e85edc7f6c53f4a71ec89048a4d5 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 17:51:13 -0600 Subject: [PATCH 075/114] update seed dispersal test mod to put on-the-fly generated paramfile in the case directory --- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands | 2 +- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands index 94a832af25..db5a1f8672 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands @@ -1,7 +1,7 @@ SRCDIR=`./xmlquery SRCROOT --value` CASEDIR=`./xmlquery CASEROOT --value` FATESDIR=$SRCDIR/src/fates/ -FATESPARAMFILE=$SRCDIR/fates_params_seeddisp_4x5.nc +FATESPARAMFILE=$CASEDIR/fates_params_seeddisp_4x5.nc ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm index e8d24253c1..ecd1dc8b57 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm @@ -1,3 +1,3 @@ -fates_paramfile = '$SRCROOT/fates_params_seeddisp_4x5.nc' +fates_paramfile = '$CASEROOT/fates_params_seeddisp_4x5.nc' fates_seeddisp_cadence = 1 hist_fincl1 = 'FATES_SEEDS_IN_GRIDCELL_PF', 'FATES_SEEDS_OUT_GRIDCELL_PF' From f58cd7ee463f5ad7d8838a618f6e51bc7c37fb07 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 23:43:20 -0600 Subject: [PATCH 076/114] reinstate fates-landuse as a second, shorter test list --- cime_config/testdefs/testlist_clm.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 16359b88be..68862c0dce 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2565,6 +2565,7 @@ + @@ -2574,6 +2575,7 @@ + @@ -2582,6 +2584,7 @@ + @@ -2590,6 +2593,7 @@ + @@ -2598,6 +2602,7 @@ + @@ -2606,6 +2611,7 @@ + From 9465da6202b0fd2ca8cbd9d39b6ffb5cc2e9f1e0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 23:44:49 -0600 Subject: [PATCH 077/114] fix luh2 harvest testmod --- .../testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm | 2 +- .../testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm index d760105e68..426b41b49e 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = luhdata_area +fates_harvest_mode = 'luhdata_area' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm index bb5f30f75d..7b6bc24f5a 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = luhdata_mass +fates_harvest_mode = 'luhdata_mass' From c2deb25a278e7b177c47b5ae189f1c8697cd8d58 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 23:48:18 -0600 Subject: [PATCH 078/114] rename fates landuse to luh2harvestevent --- .../testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm | 3 ++- .../testmods_dirs/clm/FatesColdLandUse/include_user_mods | 1 - .../testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm index 61e1daaa93..a23336f36c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm @@ -1 +1,2 @@ -fates_harvest_mode = surfdata_file +flanduse_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/ctsm5.2.0/landuse.timeseries_4x5_hist_16_CMIP6_1850-2015_c230620.nc' +fates_harvest_mode = 'surfdata_file' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods deleted file mode 100644 index 14f7591b72..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesCold diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm deleted file mode 100644 index 668f9c861d..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm +++ /dev/null @@ -1,2 +0,0 @@ -flanduse_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/ctsm5.2.0/landuse.timeseries_4x5_hist_16_CMIP6_1850-2015_c230620.nc' -do_harvest = .true. From 4d0b49a81fa68653ba92ca59cfdd791cc053378a Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 12:32:36 -0600 Subject: [PATCH 079/114] fix fates harvest event code testmod --- .../testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm index c0e1c476be..d2079d9e43 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = event_code +fates_harvest_mode = 'event_code' From 387ac5ed9163f77bd037ff8f935e56e73a832702 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:49:55 -0600 Subject: [PATCH 080/114] add description to flandusepftdat definition --- bld/namelist_files/namelist_definition_ctsm.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index c12cb75ab6..fd3020f320 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -826,7 +826,13 @@ types to vary over time. -Full pathname of fates landuse x pft static data map. +Full pathname of fates landuse x pft association static data map. +The file associates land use types with pfts across a static global map. +This file is necessary for running FATES with use_fates_luh, +use_fates_nocomp, and use_fates_fixedbiogeo engaged. The file is output +by the FATES land use data tool (https://github.com/NGEET/tools-fates-landusedata) +which processes the raw land use data from the THEMIS tool data sets +(https://doi.org/10.5065/29s7-7b41) Date: Fri, 28 Jun 2024 14:04:09 -0700 Subject: [PATCH 081/114] update flandusepftdat description with note about use_fates_lupft --- bld/namelist_files/namelist_definition_ctsm.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fd3020f320..fb4f5d07a9 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -829,7 +829,8 @@ types to vary over time. Full pathname of fates landuse x pft association static data map. The file associates land use types with pfts across a static global map. This file is necessary for running FATES with use_fates_luh, -use_fates_nocomp, and use_fates_fixedbiogeo engaged. The file is output +use_fates_nocomp, and use_fates_fixedbiogeo engaged (note that use_fates_lupft +is provided as a namelist option to engage all necessary options). The file is output by the FATES land use data tool (https://github.com/NGEET/tools-fates-landusedata) which processes the raw land use data from the THEMIS tool data sets (https://doi.org/10.5065/29s7-7b41) From f985fbafafd5710e944d7715522966e042743361 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:23:29 -0700 Subject: [PATCH 082/114] rename misleading surfdata_file option name to the landuse_timeseries --- bld/CLMBuildNamelist.pm | 4 ++-- bld/namelist_files/namelist_definition_ctsm.xml | 7 ++++--- .../testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm | 2 +- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index c336d41ca9..0fb7963c67 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4652,7 +4652,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh is required to be true when $var is luhdata_mass or luhdata_area" ); } - } elsif ( $mode eq 'surfdata_file' ) { + } elsif ( $mode eq 'landuse_timeseries' ) { # Check to make sure that the user set the flanduse_timeseries file # Since the flanduse_timeseries logic checking is upstream of the fates logic, # don't add the default here. The onus is on the user to match the correct timeseries @@ -4660,7 +4660,7 @@ sub setup_logic_fates { my $var = "flanduse_timeseries"; my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when fates_harvest_mode is surfdata_file" ); + $log->fatal_error("$var is required when fates_harvest_mode is landuse_timeseries" ); } elsif ( ! -f "$fname" ) { $log->fatal_error("$var does NOT point to a valid filename" ); } diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fb4f5d07a9..046de32c11 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -734,15 +734,16 @@ Toggle to turn on no competition mode (only relevant if FATES is being used). Toggle to turn on FATES satellite phenology mode (only relevant if FATES is being used). - + Set FATES harvesting mode by setting fates_harvest_mode to a valid string option. Allowed values are: no_harvest: no fates harvesting of any kind event_code: fates logging via fates logging event codes (see fates parameter file) only - surfdata_file: fates harvest driven by CLM landuse timeseries data (dynHarvestMod) + landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod) luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) +Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. Date: Fri, 28 Jun 2024 14:25:37 -0700 Subject: [PATCH 083/114] add language about age and possible future deprication of landuse_timeseries option --- bld/namelist_files/namelist_definition_ctsm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 046de32c11..9b495ccda4 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -744,6 +744,7 @@ Allowed values are: luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. +This option is older than the luhdata options and may be depricated at some point in the future. Date: Fri, 28 Jun 2024 14:29:38 -0700 Subject: [PATCH 084/114] fix copy/paste typo --- 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 9b495ccda4..b80bbda2d6 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -806,7 +806,7 @@ This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harv + group="clm_inparm" valid_values="" value=".false."> If TRUE, enable use of fates land use x pft mapping data file. (Only valid for use_fates = true and is incompatible with transient runs currently.) From 32b2554189d6cbdb11361ed376eb53c4bb8d2857 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:32:39 -0700 Subject: [PATCH 085/114] add clarifying language for use_fates_potentialveg --- bld/namelist_files/namelist_definition_ctsm.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index b80bbda2d6..bbc860df6c 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -814,7 +814,9 @@ If TRUE, enable use of fates land use x pft mapping data file. If TRUE, ignore the land-use state vector and transitions, and assert that all lands -are primary, and that there is no harvest. +are primary, and that there is no harvest. This mode is only relevant for FATES +spin-up workflows that are intending to use the spin-up restart output to start a +FATES land use transient case using the use_fates_lupft namelist option. From aaaff224b18585a4f93c4b83595b2017ee96f607 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:40:32 -0700 Subject: [PATCH 086/114] add clearer instructions about when to use_fates_potentialveg --- bld/namelist_files/namelist_definition_ctsm.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index bbc860df6c..252d83aa21 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -816,7 +816,8 @@ If TRUE, enable use of fates land use x pft mapping data file. If TRUE, ignore the land-use state vector and transitions, and assert that all lands are primary, and that there is no harvest. This mode is only relevant for FATES spin-up workflows that are intending to use the spin-up restart output to start a -FATES land use transient case using the use_fates_lupft namelist option. +FATES land use transient case using the use_fates_lupft namelist option. The option +should be set to true for the spin-up case and false for the transient case. From f6f7b2d135253f5a13dbd6e5ae66328a01c97d76 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:45:13 -0700 Subject: [PATCH 087/114] add language explaining what use_fates_lupft does --- bld/namelist_files/namelist_definition_ctsm.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 252d83aa21..5a478f0bfa 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -807,7 +807,9 @@ This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harv -If TRUE, enable use of fates land use x pft mapping data file. +If TRUE, enable use of FATES land use with no competition and fixed biogeography. This mode +requires the use of the land use x pft association static data map file. See the +flandusepftdat definition entry in this file for more information. (Only valid for use_fates = true and is incompatible with transient runs currently.) From 2539cea91b481f4680e2696c6c517df3d952befa Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 16:31:36 -0700 Subject: [PATCH 088/114] add readme to FatesLUPFT test mod --- cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README new file mode 100644 index 0000000000..88f5c2c8fb --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README @@ -0,0 +1,9 @@ +This test mod does not use cold start and is intended to +be used in conjunction with a test workflow that provides +an initialization file. Currently this is accomplished +by using the test mod in conjunction with the PVT +system test. The PVT system test runs a FATES spin-up +case using the use_fates_potentialveg mode and then +references the restart output to run a use_fates_lupft +transient mode case. + From bf46d33d289f85077082dc01ec79c1945c42c3f4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 30 Jun 2024 23:04:07 -0700 Subject: [PATCH 089/114] update fates logging test with new harvest event code Remove duplicate and misnamed FatesColdLUH2HarvestEvent --- .../clm/FatesColdLUH2HarvestEvent/include_user_mods | 1 - .../testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm | 1 - .../testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods deleted file mode 100644 index 7eb8bb1579..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm deleted file mode 100644 index d2079d9e43..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm +++ /dev/null @@ -1 +0,0 @@ -fates_harvest_mode = 'event_code' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm index 5f457f3f1c..d2079d9e43 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm @@ -1,2 +1 @@ -! TODO SSR: Replace this with fates_harvest_mode -use_fates_logging= .true. +fates_harvest_mode = 'event_code' From 96d1a78b3c28c9f1bc8185e646f6a4f975236a42 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 30 Jun 2024 23:07:59 -0700 Subject: [PATCH 090/114] reinstate FatesColdLandUse This will provide continuity to the previous test and fixes the incorrect use of FatesColdLUH2 as the test to inherit from --- .../testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods | 1 - .../testmods_dirs/clm/FatesColdLandUse/include_user_mods | 1 + .../{FatesColdLUH2HarvestSurf => FatesColdLandUse}/user_nl_clm | 0 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2HarvestSurf => FatesColdLandUse}/user_nl_clm (100%) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods deleted file mode 100644 index 7eb8bb1579..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods new file mode 100644 index 0000000000..14f7591b72 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods @@ -0,0 +1 @@ +../FatesCold diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm From f47e2bfe035571268743f5bed11b2b97169d31e0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 30 Jun 2024 23:10:43 -0700 Subject: [PATCH 091/114] remove duplicate tests --- cime_config/testdefs/testlist_clm.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 68862c0dce..272d4093d8 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2581,15 +2581,6 @@ - - - - - - - - - @@ -2599,15 +2590,6 @@ - - - - - - - - - From 0e6eed5f399eb85744410ecf1962c0416c7846ba Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 5 Jul 2024 10:57:34 -0700 Subject: [PATCH 092/114] Revert "update seed dispersal test mod to put on-the-fly generated paramfile in the case directory" This reverts commit 889cc97d4172e85edc7f6c53f4a71ec89048a4d5. I forgot that #2322 prevents this from working. --- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands | 2 +- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands index db5a1f8672..94a832af25 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands @@ -1,7 +1,7 @@ SRCDIR=`./xmlquery SRCROOT --value` CASEDIR=`./xmlquery CASEROOT --value` FATESDIR=$SRCDIR/src/fates/ -FATESPARAMFILE=$CASEDIR/fates_params_seeddisp_4x5.nc +FATESPARAMFILE=$SRCDIR/fates_params_seeddisp_4x5.nc ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm index ecd1dc8b57..e8d24253c1 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm @@ -1,3 +1,3 @@ -fates_paramfile = '$CASEROOT/fates_params_seeddisp_4x5.nc' +fates_paramfile = '$SRCROOT/fates_params_seeddisp_4x5.nc' fates_seeddisp_cadence = 1 hist_fincl1 = 'FATES_SEEDS_IN_GRIDCELL_PF', 'FATES_SEEDS_OUT_GRIDCELL_PF' From a486e86065223a882790a6078647a82c592ffdaf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 5 Jul 2024 17:15:08 -0700 Subject: [PATCH 093/114] update harvest parameter variables lengths Updating all lengths to account for the update to the clmlanduse name option change --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index b440b55dc9..681d39f38c 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -35,11 +35,11 @@ module dynFATESLandUseChangeMod integer, public, parameter :: num_landuse_harvest_vars = 5 ! Define the fates landuse namelist mode switch values - character(len=13), public, parameter :: fates_harvest_no_logging = 'no_harvest' - character(len=13), public, parameter :: fates_harvest_logging_only = 'event_code' - character(len=13), public, parameter :: fates_harvest_clmlanduse = 'landuse_timeseries' - character(len=13), public, parameter :: fates_harvest_luh_area = 'luhdata_area' - character(len=13), public, parameter :: fates_harvest_luh_mass = 'luhdata_mass' + character(len=18), public, parameter :: fates_harvest_no_logging = 'no_harvest' + character(len=18), public, parameter :: fates_harvest_logging_only = 'event_code' + character(len=18), public, parameter :: fates_harvest_clmlanduse = 'landuse_timeseries' + character(len=18), public, parameter :: fates_harvest_luh_area = 'luhdata_area' + character(len=18), public, parameter :: fates_harvest_luh_mass = 'luhdata_mass' ! Define landuse harvest unit integer representation integer, public, parameter :: landuse_harvest_area_units = 1 From fafc8137baeb39c07c65e697def4488b86aab612 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 8 Jul 2024 14:53:52 -0700 Subject: [PATCH 094/114] update fates submodule to api 36 --- .gitmodules | 4 ++-- src/fates | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 049c62ade8..9ed4402c7e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,8 +27,8 @@ # [submodule "fates"] path = src/fates -url = https://github.com/ckoven/fates -fxtag = 4b018eade498d063b21dddf26f77c9658ff80261 +url = https://github.com/NGEET/fates +fxtag = sci.1.77.0_api.36.0.0 fxrequired = AlwaysRequired # Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed fxDONOTUSEurl = https://github.com/NCAR/fates-release diff --git a/src/fates b/src/fates index 4b018eade4..fd7f3438c2 160000 --- a/src/fates +++ b/src/fates @@ -1 +1 @@ -Subproject commit 4b018eade498d063b21dddf26f77c9658ff80261 +Subproject commit fd7f3438c2ff821672b703050e7011f293649ee9 From e49c11dafe49ec306848a31cabfbf6b87d0d62da Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:25:04 -0700 Subject: [PATCH 095/114] update ChangeLog and ChangeSum --- doc/ChangeLog | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 118 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2ab7676ddc..26deed83db 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,121 @@ =============================================================== +Tag name: ctsm5.2.009 +Originator(s): glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) +Date: Tue 9 Jul 2024 10:50:00 AM MDT +One-line Summary: FATES Land Use V2 + +Purpose and description of changes +---------------------------------- + +This tag enables FATES to utilize its land use mode with fixed +biogeography and no competition mode engaged. To facilitate +this update, the host land model reads in a new static map data +set that associates land use with FATES plant functional types. +This tag also updates the pre-existing FATES dynamic land use +module to provide access to the raw LUH2 harvest data from the +FATES LUH2 timeseries data set (added in ctsm5.1.dev160). + +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.] + +[ ] clm6_0 + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Notes of particular relevance for users +--------------------------------------- + +Caveats for users (e.g., need to interpolate initial conditions): + FATES satellite phenology mode and land use mode are currently incompatible + and trying to engage both will result in a graceful build failure message + +Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): + New FATES namelist option: fates_harvest_mode + - This new option provides five harvest modes + - The 'event_code' mode takes over the now defunct use_fates_logging option + + New FATES namelist option: use_fates_lupft + - This option enables the necessary namelist options and data sets to run + FATES with land use, no competition, and fixed biogeography modes. + + New FATES namelist option: flandusepftdat + - This data set is necessary for running with use_fates_lupft. + + New FATES namelist option: use_potential_veg + - This option is only necessary for use with FATES spin-up to transient + workflows that will engage the use_fates_lupft mode for the transient case + +Changes made to namelist defaults (e.g., changed parameter values): + The default FATES parameter file has been updated to account for the new + parameters necessary for land use v2. + + A new default data set has been provided for flandusepftdat. Only a 4x5 grid + resolution is currently provided. + +Changes to the datasets (e.g., parameter, surface or initial files): + The FATES land use timeseries data set, fluh_timeseries, has been updated to + provide a wider timeseries range, from 0850-2015. + + +Notes of particular relevance for developers: +--------------------------------------------- +Changes to tests or testing: + New FATES testmods have been added to account for the additional harvest mode + and use_fates_lupft namelist options. Additoinally a new system text prefix, + PVT, has been added to test the use_fates_potentialveg spin-up to use_fates_lupft + transient workflow. These have been added to the fates test suite. + + +Testing summary: +---------------- + + build-namelist tests (if CLMBuildNamelist.pm has changed): + + derecho - PASS + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + derecho ----- TBD + izumi ------- TBD + + fates tests: (give name of baseline if different from CTSM tagname, normally fates baselines are fates--) + derecho ----- OK + +If the tag used for baseline comparisons was NOT the previous tag, note that here: + fates tested against fates-sci.1.76.4_api.35.1.0-ctsm5.2.008 + + +Answer changes +-------------- + +Changes answers relative to baseline: Only for FATES test mods, otherwise B4B + + +Other details +------------- +List any git submodules updated (cime, rtm, mosart, cism, fates, etc.): + FATES: sci.1.73.0_api.35.0.0 -> sci.1.77.0_api.36.0.0 + +Pull Requests that document the changes (include PR ids): +(https://github.com/ESCOMP/ctsm/pull) + +#2507 -- FATES land use v2 API update (CTSM-side) +NGEET#1116 -- V2 Land Use Change + +=============================================================== +=============================================================== Tag name: ctsm5.2.008 Originator(s): erik (Erik Kluzek,UCAR/TSS,303-497-1326) Date: Fri 28 Jun 2024 12:22:46 PM MDT diff --git a/doc/ChangeSum b/doc/ChangeSum index ea9417fe41..209c7e9a51 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.2.009 glemieux 07/09/2024 FATES Land Use V2 ctsm5.2.008 erik 06/28/2024 Bring changes on temp-branch to master: b4b-dev, git-fleximod, hillslope fsat tmp-240620.n03.ctsm5.2.007 06/27/2024 Set upland hillslope column fsat values to zero (samrabin) tmp-240620.n02.ctsm5.2.007 06/21/2024 Another update of git-fleximod (erik) From da50efd1477e53db42abc11db90b97648daabadf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:27:48 -0700 Subject: [PATCH 096/114] add clarifying language for user about FATES and do_harvest --- doc/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 26deed83db..7b40fe908a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -45,6 +45,8 @@ Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): New FATES namelist option: fates_harvest_mode - This new option provides five harvest modes - The 'event_code' mode takes over the now defunct use_fates_logging option + - The 'landuse_timeseries' option supersedes the use of do_harvest option + with FATES. Using do_harvest is no longer compatible with FATES. New FATES namelist option: use_fates_lupft - This option enables the necessary namelist options and data sets to run From 2b50ebb8dfcfaa609a13b50d04270ed3169fcce8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:29:14 -0700 Subject: [PATCH 097/114] correct fluh_timeseries file name --- 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 754510289f..97424eb13a 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1558,7 +1558,7 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1650-2015_c240216.nc + >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr0850-2015_c240216.nc .false. From 03ab3bdefa98b776263c057b50cf4b803f6c4fd7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:41:40 -0700 Subject: [PATCH 098/114] remove out-dated-comment Checking the landuse x pft data is handled on the fates-side --- src/utils/clmfates_interfaceMod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 43a574d6e3..d15288d3a3 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -3915,8 +3915,6 @@ subroutine GetLandusePFTData(bounds, landuse_pft_file, landuse_pft_map, landuse_ deallocate(arraylocal_bareground) call ncd_pio_closefile(ncid) - ! Check that sums equal to unity - end subroutine GetLandusePFTData From 272f99f405e95adec9774519323a34c0f2f9c874 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 13:41:55 -0700 Subject: [PATCH 099/114] remove unused land use mod subroutine --- 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 d15288d3a3..e3e7644b90 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -182,7 +182,6 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : num_landuse_transition_vars, num_landuse_state_vars use dynFATESLandUseChangeMod, only : landuse_transitions, landuse_states use dynFATESLandUseChangeMod, only : landuse_transition_varnames, landuse_state_varnames - use dynFATESLandUseChangeMod, only : dynFatesLandUseInterp use dynFATESLandUseChangeMod, only : num_landuse_harvest_vars use dynFATESLandUseChangeMod, only : fates_harvest_no_logging use dynFATESLandUseChangeMod, only : fates_harvest_clmlanduse From 093f5fb615988c4ec3cf9e41997178ca45e4808c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:55:43 -0700 Subject: [PATCH 100/114] Update bld/namelist_files/namelist_definition_ctsm.xml with note asterisks --- 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 c8118031cc..ce2c1b3c5a 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -740,7 +740,7 @@ Set FATES harvesting mode by setting fates_harvest_mode to a valid string option Allowed values are: no_harvest: no fates harvesting of any kind event_code: fates logging via fates logging event codes (see fates parameter file) only - landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod) + landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod)** luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. From 63c458254274edf650aac6bb0da359630446bfca Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:57:09 -0700 Subject: [PATCH 101/114] Update bld/namelist_files/namelist_definition_ctsm.xml with astericks Link to note --- 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 ce2c1b3c5a..208c42038e 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -743,7 +743,7 @@ Allowed values are: landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod)** luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) -Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. +**Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. This option is older than the luhdata options and may be depricated at some point in the future. From 1e9df4973fdfcb9e685026ecaed2b56745b24663 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:27:07 -0700 Subject: [PATCH 102/114] update comment regarding landuse x pft data set Pre-generating files is a more likely next step relative to auto-gen --- cime_config/SystemTests/pvt.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index feef6cb04c..2a3dbafdc3 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -30,9 +30,8 @@ def __init__(self,case): error_message = (f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected.") # Only allow to run if resolution is 4x5 for now - # Eventually we could set this up to generate the necessary land use x pft mapping - # on the fly, although this would also require generating the land use timeseries - # regridding on the fly which is a more time consuming endevour currently + # Other grid resolutions will be pre-processed and included in the namelist defaults at a future date. + # Potentially we could generate these on the fly although doing so would result in increased build time lnd_grid = self._case.get_value("LND_GRID") if lnd_grid != "4x5": error_message = (f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected.") From 48aeb43c9575c80a1547a85c1b02b529b690ac05 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:40:15 -0700 Subject: [PATCH 103/114] Update README with suggested clarification --- cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README index 79d6511d17..9b782cb2a7 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README @@ -1,2 +1,4 @@ Currently the FATES LUH2 category of test mods currently only supports -4x5 grid resolutions. +4x5 grid resolutions. This is because we only have one LUH2 time series +dataset for the 4x5 resolution. In the future we will provide more resolutions +which will be added to the namelist defaults. From 9ee75610973c32376f6dc407c99a0bc8d55cad83 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 14:09:26 -0700 Subject: [PATCH 104/114] fix how harvest mode is passed to add_default for use_fates_luh --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 47e0fff402..ac87d6f4ca 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4522,7 +4522,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), - 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); + 'fates_harvest_mode'=>remove_leading_and_trailing_quotes($nl->get_value('fates_harvest_mode')) ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); From 48368ac9a5fd2c36fb57cd21c3be76f773e3744d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 15:11:48 -0700 Subject: [PATCH 105/114] add comment pointing to luh2 data set readme --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index 681d39f38c..1bc6ab929e 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -50,6 +50,7 @@ module dynFATESLandUseChangeMod type(dyn_file_type), target :: dynFatesLandUse_file ! LUH2 raw wood harvest area fraction + ! LUH2 data set variable names can be found at https://luh.umd.edu/LUH2/LUH2_v2h_README.pdf character(len=10), target :: landuse_harvest_area_varnames(num_landuse_harvest_vars) = & [character(len=10) :: 'primf_harv', 'primn_harv', 'secmf_harv', 'secyf_harv', 'secnf_harv'] From b0e6565a8d802db3c1a4a2ad3322726ed680b09f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 15:18:54 -0700 Subject: [PATCH 106/114] add single quotes around fates_harvest_mode in unit tests --- bld/unit_testers/build-namelist_test.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index b343e3d194..e60a411ccb 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1009,7 +1009,7 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"fates_harvest_mode=event_code", + namelst=>"fates_harvest_mode='event_code'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, @@ -1064,12 +1064,12 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_potentialveg=T,fates_harvest_mode=event_code", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode='event_code'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, "useFATESHARVEST3WOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_luh=F,fates_harvest_mode=luhdata_area", + namelst=>"use_fates_luh=F,fates_harvest_mode='luhdata_area'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, From 12c60f3de477bbdaa2cf7a8afe0d089886d2c960 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 16:01:12 -0700 Subject: [PATCH 107/114] correct POTVEG fail unit test This needs to have use_fates_luh to avoid the false negative of failing due to not having this mode with use_fates_potentialveg --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index fc1e83f162..741964d8a1 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1063,7 +1063,7 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_potentialveg=T,fates_harvest_mode='event_code'", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode='event_code',use_fates_luh=T", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, From 322097f0a2b5cf0c3b6bdd5a3eccb70845cb6990 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 15 Jul 2024 13:05:59 -0700 Subject: [PATCH 108/114] change folder name for fates land use x pft files This matches the corresponding fates tag that also impliments using this 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 6f29513e6b..d4167228b9 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2019,7 +2019,7 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc -lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc +lnd/clm2/surfdata_map/fates-sci.1.77.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc Date: Tue, 16 Jul 2024 15:38:28 -0700 Subject: [PATCH 109/114] add izumi luh2 failure to expected list --- cime_config/testdefs/ExpectedTestFails.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index a4033aa6cd..ee1f188f15 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -150,6 +150,13 @@ + + + FAIL + #2653 + + + FAIL From 1de58fbb04d862245f69239835a00c15e062dc54 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 12:37:45 -0700 Subject: [PATCH 110/114] update fates to sci.1.77.1_api.36.0.0 --- .gitmodules | 2 +- src/fates | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9ed4402c7e..8127cac482 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,7 +28,7 @@ [submodule "fates"] path = src/fates url = https://github.com/NGEET/fates -fxtag = sci.1.77.0_api.36.0.0 +fxtag = sci.1.77.1_api.36.0.0 fxrequired = AlwaysRequired # Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed fxDONOTUSEurl = https://github.com/NCAR/fates-release diff --git a/src/fates b/src/fates index fd7f3438c2..1982b0032c 160000 --- a/src/fates +++ b/src/fates @@ -1 +1 @@ -Subproject commit fd7f3438c2ff821672b703050e7011f293649ee9 +Subproject commit 1982b0032c3cab6278892eccb85f643114ffb1af From 47571d844674d836a7501c3cd98f65ac545f4e39 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 13:23:11 -0700 Subject: [PATCH 111/114] formatting fixed for changelog --- doc/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 71b07aa2f2..54e3b4cc4b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,5 @@ +=============================================================== +Tag name: ctsm5.2.013 Originator(s): samrabin (Sam Rabin, UCAR/TSS, samrabin@ucar.edu) glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) Date: Wed 17 Jul 2024 01:20:00 PM MDT From e4142b96425712afa44cb6ab440d297a56aeaae1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 13:26:45 -0700 Subject: [PATCH 112/114] fixing bad merge with changelog --- doc/ChangeLog | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 54e3b4cc4b..3c6a104725 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -79,7 +79,6 @@ Changes to tests or testing: and use_fates_lupft namelist options. Additoinally a new system text prefix, PVT, has been added to test the use_fates_potentialveg spin-up to use_fates_lupft transient workflow. These have been added to the fates test suite. -======= Bugs fixed ---------- @@ -154,6 +153,19 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm4_5 + +Bugs fixed +---------- +List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: +Fixes #2444 Failing water isotope test on the ctsm5.2 branch + +Notes of particular relevance for users +--------------------------------------- +Changes to documentation: 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): From 75cd2f4c866bd8148dff0e310e1ba0711bef13f3 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 14:07:23 -0700 Subject: [PATCH 113/114] reformat new and updated systests with black --- cime_config/SystemTests/pvt.py | 15 +++++++++------ cime_config/SystemTests/systemtest_utils.py | 7 ++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 2a3dbafdc3..cf923dd334 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -16,9 +16,10 @@ logger = logging.getLogger(__name__) + class PVT(SystemTestsCommon): - def __init__(self,case): - SystemTestsCommon.__init__(self,case) + def __init__(self, case): + SystemTestsCommon.__init__(self, case) # Do not allow PVT to be run with certain testmods # Should this be targeted to a specific testmod for simplicity for now? @@ -27,14 +28,16 @@ def __init__(self,case): casebaseid = self._case.get_value("CASEBASEID") casebaseid = casebaseid.split("-")[-1] if casebaseid[0:10] != "FatesLUPFT": - error_message = (f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected.") + error_message = f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected." # Only allow to run if resolution is 4x5 for now # Other grid resolutions will be pre-processed and included in the namelist defaults at a future date. # Potentially we could generate these on the fly although doing so would result in increased build time lnd_grid = self._case.get_value("LND_GRID") if lnd_grid != "4x5": - error_message = (f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected.") + error_message = ( + f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected." + ) if error_message is not None: logger.error(error_message) @@ -79,7 +82,7 @@ def run_phase(self): # Turn off fates_harvest_mode for the spin up. logger.info("PVT log: modify user_nl_clm file for spin up run") - added_content = ["use_fates_potentialveg = .true.","fates_harvest_mode = 'no_harvest'"] + added_content = ["use_fates_potentialveg = .true.", "fates_harvest_mode = 'no_harvest'"] append_to_user_nl_files(clone_path, "clm", added_content) # Run the spin up case @@ -100,7 +103,7 @@ def run_phase(self): # obtain rpointer files and necessary restart files from short term archiving directory rundir = self._case.get_value("RUNDIR") - refdate = str(refcase_year) + '-01-01-00000' + refdate = str(refcase_year) + "-01-01-00000" rest_path = os.path.join(dout_sr, "rest", "{}".format(refdate)) for item in glob.glob("{}/*{}*".format(rest_path, refdate)): diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index c39f5171ba..c252f73251 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -86,14 +86,15 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): print(f"ERROR trying to run {tool_name}.") raise + # Read a user_nl file and return the namelist option if found def find_user_nl_option(caseroot, component, namelist_option): - + # This is a copy of the CIME _get_list_of_user_nl_files # which could be used if this moved into the CIME project file_pattern = "user_nl_" + component + "*" file_list = glob.glob(os.path.join(caseroot, file_pattern)) - + # Check that there is at least one file if len(file_list) == 0: raise RuntimeError("No user_nl files found for component " + component) @@ -103,7 +104,7 @@ def find_user_nl_option(caseroot, component, namelist_option): for one_file in file_list: with open(one_file, "r") as user_nl_file: user_nl_text = user_nl_file.read() - reg = fr'{namelist_option}.*?(?=,|\n)' + reg = rf"{namelist_option}.*?(?=,|\n)" find_out = re.findall(reg, user_nl_text) output[one_file] = find_out return output From 3416574a862e2f1df62d29abb82efe76686084dd Mon Sep 17 00:00:00 2001 From: adrifoster Date: Thu, 18 Jul 2024 10:51:28 -0600 Subject: [PATCH 114/114] update date --- doc/ChangeLog | 2 +- doc/ChangeSum | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 3c6a104725..8cc3198fae 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,7 +2,7 @@ Tag name: ctsm5.2.013 Originator(s): samrabin (Sam Rabin, UCAR/TSS, samrabin@ucar.edu) glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) -Date: Wed 17 Jul 2024 01:20:00 PM MDT +Date: Thu Jul 18 10:51:11 MDT 2024 One-line Summary: FATES Land Use V2 Purpose and description of changes diff --git a/doc/ChangeSum b/doc/ChangeSum index 92ca8281cf..df8e6dcf6a 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,6 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.2.013 glemieux 07/17/2024 FATES Land Use V2 + ctsm5.2.013 glemieux 07/18/2024 FATES Land Use V2 ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.011 slevis 07/12/2024 Merge b4b-dev ctsm5.2.010 multiple 07/11/2024 Explicit A/C adoption