From fffb79409b29ed741c119d9fb37496898a689cd9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 1 May 2024 15:46:26 -0700 Subject: [PATCH 01/15] 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 02/15] 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 03/15] 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 04/15] 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 05/15] 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 06/15] 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 07/15] 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 08/15] 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 09/15] 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 10/15] 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 11/15] 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 12/15] 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 13/15] 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 14/15] 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 15/15] 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