From cf5d00dcd534fa6bce784eb46abb7aa9bae5a7a7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 14 Jan 2025 10:51:25 -0800 Subject: [PATCH 1/8] add graceful failure if for Meier2022 and use_fates combo --- bld/CLMBuildNamelist.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index ab0aab0cc5..f72959f55f 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2125,10 +2125,13 @@ sub setup_logic_roughness_methods { $log->fatal_error("$var is incorrect entry for the namelist variable z0param_method; expected Meier2022 or ZengWang2007"); } my $phys = $physv->as_string(); - if ( $phys eq "clm4_5" || $phys eq "clm5_0" ) { - if ( $var eq "Meier2022" ) { + if ( $var eq "Meier2022" ) { + if ( $phys eq "clm4_5" || $phys eq "clm5_0" ) { $log->fatal_error("z0param_method = $var and phys = $phys, but this method has been tested only with clm6_0 and later versions; to use with earlier versions, disable this error, and add Meier2022 parameters to the corresponding params file"); } + if ( &value_is_true($nl_flags->{'use_fates'}) ) { + $log->fatal_error("z0param_method = $var and use_fates currently are not compatible. Please update the z0param_method to ZengWang2007") + } } } #------------------------------------------------------------------------------- From dbb619273b73e642b2c2eaefe452dcc95e45bca1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 14 Jan 2025 11:35:01 -0800 Subject: [PATCH 2/8] add default option to z0param_method If fates is on, default to ZengWang2007, otherwise use Meier2022 --- bld/namelist_files/namelist_defaults_ctsm.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index cee72ca5cf..838c28da84 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -540,7 +540,9 @@ attributes from the config_cache.xml file (with keys converted to upper-case). ZengWang2007 -Meier2022 + +ZengWang2007 +Meier2022 .true. .false. From 43407e152c887017fa2d7ccbded868c3e7eabef4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 14 Jan 2025 15:58:09 -0800 Subject: [PATCH 3/8] add endrun call during initialization if Meier2022 is run with fates --- src/main/clm_initializeMod.F90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 46353539ce..ec0fbeb024 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -57,7 +57,7 @@ subroutine initialize1(dtime) use clm_varpar , only: clm_varpar_init use clm_varcon , only: clm_varcon_init use landunit_varcon , only: landunit_varcon_init - use clm_varctl , only: fsurdat, version + use clm_varctl , only: fsurdat, version, z0param_method use surfrdMod , only: surfrd_get_num_patches, surfrd_get_nlevurb, surfrd_compat_check use controlMod , only: control_init, control_print, NLFilename use ncdio_pio , only: ncd_pio_init @@ -108,6 +108,10 @@ subroutine initialize1(dtime) ! number of patches per column. We still use numcft from the surface ! file though... if(use_fates) then + if (z0param_method == 'Meier2022') then + call endrun(msg='ERROR clm_initializeMod: '//& + 'FATES is not compatible with Meier2022') + end if call CLMFatesGlobals1(actual_numpft, actual_numcft, actual_maxsoil_patches) end if From cb361ebe234fdd79cca28832da9fb404f9973e16 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 14 Jan 2025 22:39:10 -0800 Subject: [PATCH 4/8] update comment and error message with issue number --- bld/CLMBuildNamelist.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index f72959f55f..791e5a4af2 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2129,8 +2129,9 @@ sub setup_logic_roughness_methods { if ( $phys eq "clm4_5" || $phys eq "clm5_0" ) { $log->fatal_error("z0param_method = $var and phys = $phys, but this method has been tested only with clm6_0 and later versions; to use with earlier versions, disable this error, and add Meier2022 parameters to the corresponding params file"); } + # Make sure that fates and meier2022 are not both active due to issue #2932 if ( &value_is_true($nl_flags->{'use_fates'}) ) { - $log->fatal_error("z0param_method = $var and use_fates currently are not compatible. Please update the z0param_method to ZengWang2007") + $log->fatal_error("z0param_method = $var and use_fates currently are not compatible. Please update the z0param_method to ZengWang2007. See issue #2932 for more information.") } } } From 57f3d217b22acf5a08e85ecab4b0ab60b4207799 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 15 Jan 2025 00:13:42 -0700 Subject: [PATCH 5/8] add failure unit test for Meier2022 and fates --- bld/unit_testers/build-namelist_test.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index d42487cfdb..a3630f3286 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 = 3263; +my $ntests = 3264; if ( defined($opts{'compare'}) ) { - $ntests += 1979; + $ntests += 1980; } plan( tests=>$ntests ); @@ -1185,6 +1185,10 @@ sub cat_and_create_namelistinfile { namelst=>"use_hydrstress=.true.", phys=>"clm5_0", }, + "useMeierwithFATES" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"z0param_method=Meier2022", + phys=>"clm5_0", + }, "noanthro_w_crop" =>{ options=>"-envxml_dir . -res 0.9x1.25 -bgc bgc -crop -use_case 1850_noanthro_control", namelst=>"", phys=>"clm5_0", From 97ac82306c231c79c393449687c704bcb0b64033 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 15 Jan 2025 09:33:04 -0800 Subject: [PATCH 6/8] add use_fates to add_default call in roughness bld logic this avoids the need to set a `.true.` condition for z0param_method in the defaults --- bld/CLMBuildNamelist.pm | 2 +- bld/namelist_files/namelist_defaults_ctsm.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 791e5a4af2..93004ad1c4 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2118,7 +2118,7 @@ sub setup_logic_roughness_methods { my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_; add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'z0param_method', - 'phys'=>$nl_flags->{'phys'} ); + 'phys'=>$nl_flags->{'phys'} , 'use_fates'=>$nl_flags->{'use_fates'}); my $var = remove_leading_and_trailing_quotes( $nl->get_value("z0param_method") ); if ( $var ne "Meier2022" && $var ne "ZengWang2007" ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 838c28da84..64e00527fe 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -540,8 +540,6 @@ attributes from the config_cache.xml file (with keys converted to upper-case). ZengWang2007 - -ZengWang2007 Meier2022 .true. From 23b30aed8a9154e760407af3a73f24bf6f115e6f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 15 Jan 2025 15:19:15 -0800 Subject: [PATCH 7/8] Revert "add endrun call during initialization if Meier2022 is run with fates" This reverts commit 43407e152c887017fa2d7ccbded868c3e7eabef4. --- src/main/clm_initializeMod.F90 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index ec0fbeb024..46353539ce 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -57,7 +57,7 @@ subroutine initialize1(dtime) use clm_varpar , only: clm_varpar_init use clm_varcon , only: clm_varcon_init use landunit_varcon , only: landunit_varcon_init - use clm_varctl , only: fsurdat, version, z0param_method + use clm_varctl , only: fsurdat, version use surfrdMod , only: surfrd_get_num_patches, surfrd_get_nlevurb, surfrd_compat_check use controlMod , only: control_init, control_print, NLFilename use ncdio_pio , only: ncd_pio_init @@ -108,10 +108,6 @@ subroutine initialize1(dtime) ! number of patches per column. We still use numcft from the surface ! file though... if(use_fates) then - if (z0param_method == 'Meier2022') then - call endrun(msg='ERROR clm_initializeMod: '//& - 'FATES is not compatible with Meier2022') - end if call CLMFatesGlobals1(actual_numpft, actual_numcft, actual_maxsoil_patches) end if From ccb55dab6f582a9ca7ac72677e2d768b522859c2 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 15 Jan 2025 15:19:30 -0800 Subject: [PATCH 8/8] add Meier2022 check in control_init fates section --- src/main/controlMod.F90 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index e8121519aa..c07909c67e 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -518,6 +518,11 @@ subroutine control_init(dtime) errMsg(sourcefile, __LINE__)) end if + if (z0param_method == 'Meier2022') then + call endrun(msg=' ERROR: Surface roughness parameterization Meier2022 is not compatible with FATES.'//& + errMsg(sourcefile, __LINE__)) + end if + else ! These do default to false anyway, but this emphasizes they