From 7d8d0f6e2b47de2c0cb7a989942c995481a9c775 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 14 Aug 2024 17:35:00 -0600 Subject: [PATCH 01/22] Add failing tests for running with dust set by CAM so LND_SETS_DUST_EMIS_DRV_FLDS is FALSE --- bld/unit_testers/build-namelist_test.pl | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index c51b0b0cb3..28e6084f0e 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -447,7 +447,32 @@ sub cat_and_create_namelistinfile { &cleanup(); } } - +print "\n===============================================================================\n"; +print "Test setting drv_flds_in fields in CAM"; +print "=================================================================================\n"; +foreach my $phys ( "clm5_0", "clm6_0" ) { + $mode = "-phys $phys CAM_SETS_DRV_FLDS"; + &make_config_cache($phys); + foreach my $options ( + "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam6.0", + "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam7.0", + ) { + &make_env_run( 'LND_SETS_DUST_EMIS_DRV_FLDS'=>"FALSE" ); + eval{ system( "$bldnml --envxml_dir . $options > $tempfile 2>&1 " ); }; + is( $@, '', "options: $options" ); + $cfiles->checkfilesexist( "$options", $mode ); + $cfiles->shownmldiff( "default", $mode ); + if ( defined($opts{'compare'}) ) { + $cfiles->doNOTdodiffonfile( "$tempfile", "$options", $mode ); + $cfiles->dodiffonfile( "lnd_in", "$options", $mode ); + $cfiles->comparefiles( "$options", $mode, $opts{'compare'} ); + } + if ( defined($opts{'generate'}) ) { + $cfiles->copyfiles( "$options", $mode ); + } + &cleanup(); + } +} print "\n==============================================================\n"; print "Test several use_cases and specific configurations for clm5_0\n"; print "==============================================================\n"; @@ -518,7 +543,7 @@ sub cat_and_create_namelistinfile { phys=>"clm4_5", }, "LeungDust_WO_Prigent" =>{ options=>" -envxml_dir . -bgc sp", - namelst=>"use_prigent_roughness=.false.", + namelst=>"use_prigent_roughness=.true.", phys=>"clm5_1", }, "soilm_stream off w file" =>{ options=>"-res 0.9x1.25 -envxml_dir .", From a590ca7e57c965e1cfc46779cb5c6f1dc34bfb27 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 15 Aug 2024 01:59:10 -0600 Subject: [PATCH 02/22] When LND_SETS_DUST_EMIS_DRV_FLDS is FALSE read in CAM drv_flds_in namelist to use to determine dust_emis settings, still check that they aren't set in the user_nl_clm file --- bld/CLMBuildNamelist.pm | 51 +++++++++++++++---------- bld/unit_testers/build-namelist_test.pl | 4 +- bld/unit_testers/empty_user_nl_clm | 1 + 3 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 bld/unit_testers/empty_user_nl_clm diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b99be288e7..daf4320c18 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1470,6 +1470,32 @@ sub process_namelist_commandline_namelist { } } +sub process_namelist_infile { + my ($definition, $nl, $envxml_ref, $infile) = @_; + + # Make sure a valid file was found + if ( -f "$infile" ) { + # Otherwise abort as a valid file doesn't exist + } else { + $log->fatal_error("input namelist file does NOT exist $infile.\n $@"); + } + # Parse namelist input from the next file + my $nl_infile = Build::Namelist->new($infile); + + # Validate input namelist -- trap exceptions + my $nl_infile_valid; + eval { $nl_infile_valid = $definition->validate($nl_infile); }; + if ($@) { + $log->fatal_error("Invalid namelist variable in '-infile' $infile.\n $@"); + } + # Go through all variables and expand any XML env settings in them + expand_xml_variables_in_namelist( $nl_infile_valid, $envxml_ref ); + + # Merge input values into namelist. Previously specified values have higher precedence + # and are not overwritten. + $nl->merge_nl($nl_infile_valid); +} + #------------------------------------------------------------------------------- sub process_namelist_commandline_infile { @@ -1479,27 +1505,7 @@ sub process_namelist_commandline_infile { if (defined $opts->{'infile'}) { my @infiles = split( /,/, $opts->{'infile'} ); foreach my $infile ( @infiles ) { - # Make sure a valid file was found - if ( -f "$infile" ) { - # Otherwise abort as a valid file doesn't exist - } else { - $log->fatal_error("input namelist file does NOT exist $infile.\n $@"); - } - # Parse namelist input from the next file - my $nl_infile = Build::Namelist->new($infile); - - # Validate input namelist -- trap exceptions - my $nl_infile_valid; - eval { $nl_infile_valid = $definition->validate($nl_infile); }; - if ($@) { - $log->fatal_error("Invalid namelist variable in '-infile' $infile.\n $@"); - } - # Go through all variables and expand any XML env settings in them - expand_xml_variables_in_namelist( $nl_infile_valid, $envxml_ref ); - - # Merge input values into namelist. Previously specified values have higher precedence - # and are not overwritten. - $nl->merge_nl($nl_infile_valid); + process_namelist_infile( $definition, $nl, $envxml_ref, $infile ); } } } @@ -4086,6 +4092,9 @@ sub setup_logic_dust_emis { " connected to CAM as CAM should set them"); } } + # Now process the CAM drv_flds_in to get the dust settings + my $infile = $opts->{'envxml_dir'} . "/Buildconf/camconf/drv_flds_in"; + process_namelist_infile( $definition, $nl, $envxml_ref, $infile ); } } diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 28e6084f0e..1b54f29d92 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -454,8 +454,8 @@ sub cat_and_create_namelistinfile { $mode = "-phys $phys CAM_SETS_DRV_FLDS"; &make_config_cache($phys); foreach my $options ( - "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam6.0", - "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam7.0", + "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam6.0 --infile empty_user_nl_clm", + "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam7.0 --infile empty_user_nl_clm", ) { &make_env_run( 'LND_SETS_DUST_EMIS_DRV_FLDS'=>"FALSE" ); eval{ system( "$bldnml --envxml_dir . $options > $tempfile 2>&1 " ); }; diff --git a/bld/unit_testers/empty_user_nl_clm b/bld/unit_testers/empty_user_nl_clm new file mode 100644 index 0000000000..45fda13d2c --- /dev/null +++ b/bld/unit_testers/empty_user_nl_clm @@ -0,0 +1 @@ +! empty user_nl_clm file From 733cf9918178fc89a1c6ee2c34447160e5e944fb Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 15 Aug 2024 15:20:33 -0600 Subject: [PATCH 03/22] Add missing cmeps drv_flds_in variables fixing #2170 --- .../namelist_definition_drv_flds.xml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bld/namelist_files/namelist_definition_drv_flds.xml b/bld/namelist_files/namelist_definition_drv_flds.xml index 89bab07f4f..9bb1a3e3b0 100644 --- a/bld/namelist_files/namelist_definition_drv_flds.xml +++ b/bld/namelist_files/namelist_definition_drv_flds.xml @@ -123,6 +123,10 @@ List of fluxes needed by the CARMA model, from CLM to CAM. + + + + Which dust emission method is going to be used. Either the Zender 2003 scheme or the Leung 2023 scheme. @@ -136,4 +140,27 @@ (only used when dust_emis_method is Zender_2003) + + + + + + Frequency of surface ozone field passed from CAM to surface components. + Surface ozone is passed every coupling interval, but this namelist flag + indicates whether the timestep-level values are interpolated from a + coarser temporal resolution. + Default: set by CAM + + + + + + + + If TRUE atmosphere model will provide prognosed lightning flash frequency. + (NOTE: NOT CONNECTED INTO CTSM YET) + + From 3f3541b37b7ff9abe37050c98575b61b3702e688 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 15 Aug 2024 15:41:00 -0600 Subject: [PATCH 04/22] Current drv_flds_in file from CAM for a FHIST case, including some fields that weren't being set in CLM --- bld/unit_testers/Buildconf/camconf/drv_flds_in | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bld/unit_testers/Buildconf/camconf/drv_flds_in diff --git a/bld/unit_testers/Buildconf/camconf/drv_flds_in b/bld/unit_testers/Buildconf/camconf/drv_flds_in new file mode 100644 index 0000000000..e8e95ad369 --- /dev/null +++ b/bld/unit_testers/Buildconf/camconf/drv_flds_in @@ -0,0 +1,13 @@ +&drydep_inparm + dep_data_file = '/glade/campaign/cesm/cesmdata/inputdata/atm/cam/chem/trop_mozart/dvel/dep_data_c20221208.nc' +/ +&dust_emis_inparm + dust_emis_method = 'Zender_2003' + zender_soil_erod_source = 'atm' +/ +&lightning_coupling_nl + atm_provides_lightning = .true. +/ +&ozone_coupling_nl + atm_ozone_frequency = 'multiday_average' +/ From 6268e5907d7563d350fba6f7bb79b0bae3e6344d Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 16 Aug 2024 09:55:02 -0600 Subject: [PATCH 05/22] Add megan and drydep settings as per a cam6_4_015 SMS_Ln9.f19_f19_mg17.FHIST.derecho_intel.cam-outfrq9s test --- bld/unit_testers/Buildconf/camconf/drv_flds_in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bld/unit_testers/Buildconf/camconf/drv_flds_in b/bld/unit_testers/Buildconf/camconf/drv_flds_in index e8e95ad369..c551ccacf5 100644 --- a/bld/unit_testers/Buildconf/camconf/drv_flds_in +++ b/bld/unit_testers/Buildconf/camconf/drv_flds_in @@ -1,5 +1,16 @@ &drydep_inparm - dep_data_file = '/glade/campaign/cesm/cesmdata/inputdata/atm/cam/chem/trop_mozart/dvel/dep_data_c20221208.nc' + dep_data_file = '/glade/campaign/cesm/cesmdata/inputdata/atm/cam/chem/trop_mozart/dvel/dep_data_c20221208.nc' + drydep_list = 'DMS','H2O2','H2SO4','SO2','SOAG' +/ +&megan_emis_nl + megan_factors_file = '/glade/campaign/cesm/cesmdata/inputdata/atm/cam/chem/trop_mozart/emis/megan21_emis_factors_78pft_c20161108.nc' + megan_mapped_emisfctrs = .false. + megan_specifier = 'SOAE = 0.5954*isoprene + 5.1004*(carene_3 + pinene_a + thujene_a + bornene +', ' terpineol_4 + terpineol_a + terpinyl_ACT_a + myrtenal + sabinene + pinene_b + camphene +', + ' fenchene_a + limonene + phellandrene_a + terpinene_a + terpinene_g + terpinolene +', ' phellandrene_b + linalool + ionone_b + geranyl_acetone + neryl_acetone + jasmone +', + ' verbenene + ipsenol + myrcene + ocimene_t_b + ocimene_al + ocimene_c_b + 2met_nonatriene) + ', ' 12.3942*(farnescene_a + caryophyllene_b + acoradiene + aromadendrene + bergamotene_a +', + ' bergamotene_b + bisabolene_a + bisabolene_b + bourbonene_b + cadinene_d + cadinene_g +', ' cedrene_a + copaene_a + cubebene_a + cubebene_b + elemene_b + farnescene_b +', + ' germacrene_B + germacrene_D + gurjunene_b + humulene_a + humulene_g + isolongifolene +', ' longifolene + longipinene + muurolene_a + muurolene_g + selinene_b + selinene_d +', + ' nerolidol_c + nerolidol_t)' / &dust_emis_inparm dust_emis_method = 'Zender_2003' From e9b629db2cc57ac52e4ff691b4762968d364e80d Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 16 Aug 2024 16:22:53 -0600 Subject: [PATCH 06/22] Simplify the validation checking for megan specifier as the expressions allowed are much more complex now, this resolves #2709 --- bld/CLMBuildNamelist.pm | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index daf4320c18..e4cc50614c 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -5652,26 +5652,10 @@ sub check_megan_spec { my $megan_spec = $nl->get_value('megan_specifier'); my @megan_spec_list = split( /\s*,\s*/, $megan_spec ); - foreach $megan_spec ( @megan_spec_list ) { - if ( $megan_spec =~ /^['"]+[A-Za-z0-9]+\s*\=\s*([\sA-Za-z0-9+_-]+)["']+$/ ) { - my $megan_list = $1; - my @megan_cmpds = split( /\s*\+\s*/, $megan_list ); - my $var = "megan_cmpds"; - my $warn = 0; - foreach my $megan_cmpd ( @megan_cmpds ) { - if ( ! $definition->is_valid_value( $var, $megan_cmpd, 'noquotes'=>1 ) ) { - $log->warning("megan_compound $megan_cmpd NOT found in list" ); - $warn++; - } - } - if ( $warn > 0 ) { - my @valid_values = $definition->get_valid_values( $var, 'noquotes'=>1 ); - $log->warning("list of megan compounds includes:\n" . - "@valid_values\n" . - "Does your megan_factors_file include more compounds?\n" . - "If NOT your simulation will fail." ); - } - } else { + foreach my $spec ( @megan_spec_list ) { + $megan_spec = remove_leading_and_trailing_quotes($spec); + # Do simple validation of the expressions to just check for valid characters + if ( ! $megan_spec =~ /[\s=A-Za-z0-9_\+\.\*\(\)-]+/ ) { $log->fatal_error("Bad format for megan_specifier = $megan_spec"); } } From 53a1874b48c82591f45212ba7df5c29254e61a4c Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 21 Aug 2024 12:01:57 -0600 Subject: [PATCH 07/22] CAM_SETS_DRV_FLDS tests don't need to have drv_flds_in settings to be explicit --- 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 1b54f29d92..de5a9b0e13 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -454,8 +454,8 @@ sub cat_and_create_namelistinfile { $mode = "-phys $phys CAM_SETS_DRV_FLDS"; &make_config_cache($phys); foreach my $options ( - "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam6.0 --infile empty_user_nl_clm", - "--res 1.9x2.5 --mask gx1v7 --bgc sp --no-megan --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam7.0 --infile empty_user_nl_clm", + "--res 1.9x2.5 --mask gx1v7 --bgc sp --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam6.0 --infile empty_user_nl_clm", + "--res 1.9x2.5 --mask gx1v7 --bgc sp --use_case 20thC_transient --namelist '&a start_ymd=19790101/' --lnd_tuning_mode ${phys}_cam7.0 --infile empty_user_nl_clm", ) { &make_env_run( 'LND_SETS_DUST_EMIS_DRV_FLDS'=>"FALSE" ); eval{ system( "$bldnml --envxml_dir . $options > $tempfile 2>&1 " ); }; @@ -1286,7 +1286,7 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "bad_megan_spec" =>{ options=>"-envxml_dir . -bgc bgc -megan", - namelst=>"megan_specifier='ZZTOP=zztop'", + namelst=>"megan_specifier='ZZTOP=zztop%'", phys=>"clm4_5", }, "FUN_wo_flexCN" =>{ options=>"-envxml_dir . -bgc bgc", From 717f957123f1b10dd2676438f7dcb7b95aa31c59 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 21 Aug 2024 12:10:19 -0600 Subject: [PATCH 08/22] Get working with bringing in CAM drv_flds_in Get it working with bringing in the CAM drv_flds_in file. And make it not matter on the --megan --drydep --fire_emis options. Also do dust_emis before the other drv_flds_in namelists, so the CAM namelist is loaded. --- bld/CLMBuildNamelist.pm | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index e4cc50614c..1fad577c51 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1449,7 +1449,7 @@ sub setup_cmdl_vichydro { sub process_namelist_commandline_namelist { # Process the commandline '-namelist' arg. - my ($opts, $definition, $nl, $envxml_ref) = @_; + my ($opts, $definition, $nl, $envxml_ref, %settings) = @_; if (defined $opts->{'namelist'}) { # Parse commandline namelist @@ -1471,7 +1471,7 @@ sub process_namelist_commandline_namelist { } sub process_namelist_infile { - my ($definition, $nl, $envxml_ref, $infile) = @_; + my ($definition, $nl, $envxml_ref, $infile, %settings) = @_; # Make sure a valid file was found if ( -f "$infile" ) { @@ -1493,7 +1493,7 @@ sub process_namelist_infile { # Merge input values into namelist. Previously specified values have higher precedence # and are not overwritten. - $nl->merge_nl($nl_infile_valid); + $nl->merge_nl($nl_infile_valid, %settings); } #------------------------------------------------------------------------------- @@ -1756,6 +1756,12 @@ sub process_namelist_inline_logic { ################################## setup_logic_lightning_streams($opts, $nl_flags, $definition, $defaults, $nl); + ###################################### + # namelist options for dust emissions + ###################################### + setup_logic_dust_emis($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref); + setup_logic_prigent_roughness($opts, $nl_flags, $definition, $defaults, $nl); + ################################# # namelist group: drydep_inparm # ################################# @@ -1766,12 +1772,6 @@ sub process_namelist_inline_logic { ################################# setup_logic_fire_emis($opts, $nl_flags, $definition, $defaults, $nl); - ###################################### - # namelist options for dust emissions - ###################################### - setup_logic_dust_emis($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref); - setup_logic_prigent_roughness($opts, $nl_flags, $definition, $defaults, $nl); - ################################# # namelist group: megan_emis_nl # ################################# @@ -3998,17 +3998,18 @@ sub setup_logic_lightning_streams { sub setup_logic_dry_deposition { my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; + my @list = ( "drydep_list", "dep_data_file"); if ($opts->{'drydep'} ) { - if ( &value_is_true( $nl_flags->{'use_fates'}) && not &value_is_true( $nl_flags->{'use_fates_sp'}) ) { - $log->warning("DryDeposition can NOT be on when FATES is also on unless FATES-SP mode is on.\n" . - " Use the '--no-drydep' option when '-bgc fates' is activated"); - } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'drydep_list'); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'dep_data_file'); - } else { - if ( defined($nl->get_value('drydep_list')) ) { - $log->fatal_error("drydep_list defined, but drydep option NOT set"); - } + } + if ( &value_is_true( $nl_flags->{'use_fates'}) && not &value_is_true( $nl_flags->{'use_fates_sp'}) ) { + foreach my $var ( @list ) { + if ( defined($nl->get_value($var)) ) { + $log->warning("DryDeposition $var is being set and can NOT be on when FATES is also on unless FATES-SP mode is on.\n" . + " Use the '--no-drydep' option when '-bgc fates' is activated"); + } + } } } @@ -4017,20 +4018,20 @@ sub setup_logic_dry_deposition { sub setup_logic_fire_emis { my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; + my @list = ( "fire_emis_eleveated", "fire_emis_factors_file", "fire_emis_specifier"); + if ($opts->{'fire_emis'} ) { - if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning("Fire emission can NOT be on when FATES is also on.\n" . - " DON'T use the '-fire_emis' option when '-bgc fates' is activated"); - } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_factors_file'); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_specifier'); - } else { - if ( defined($nl->get_value('fire_emis_elevated')) || - defined($nl->get_value('fire_emis_factors_file')) || - defined($nl->get_value('fire_emis_specifier')) ) { - $log->fatal_error("fire_emission setting defined: fire_emis_elevated, fire_emis_factors_file, or fire_emis_specifier, but fire_emis option NOT set"); - } } + foreach my $var ( @list ) { + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { + $log->warning("Fire emission option $var can NOT be on when FATES is also on.\n" . + " DON'T use the '--fire_emis' option when '--bgc fates' is activated"); + } + } + } } #------------------------------------------------------------------------------- @@ -4094,7 +4095,8 @@ sub setup_logic_dust_emis { } # Now process the CAM drv_flds_in to get the dust settings my $infile = $opts->{'envxml_dir'} . "/Buildconf/camconf/drv_flds_in"; - process_namelist_infile( $definition, $nl, $envxml_ref, $infile ); + $log->verbose_message("Read in the drv_flds_in file generated by CAM's build-namelist"); + process_namelist_infile( $definition, $nl, $envxml_ref, $infile, 'die_on_conflict'=>1 ); } } @@ -4115,17 +4117,15 @@ sub setup_logic_megan { } if ($nl_flags->{'megan'} ) { - if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning("MEGAN can NOT be on when FATES is also on.\n" . - " Use the '-no-megan' option when '-bgc fates' is activated"); - } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'megan_specifier'); - check_megan_spec( $opts, $nl, $definition ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'megan_factors_file'); - } else { - if ( defined($nl->get_value('megan_specifier')) || + } + if ( defined($nl->get_value('megan_specifier')) || defined($nl->get_value('megan_factors_file')) ) { - $log->fatal_error("megan_specifier or megan_factors_file defined, but megan option NOT set"); + check_megan_spec( $opts, $nl, $definition ); + if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { + $log->warning("MEGAN can NOT be on when FATES is also on.\n" . + " Use the '-no-megan' option when '-bgc fates' is activated"); } } } From 406edd4596fe6bba3d3d5095996fe729d0bccbd3 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 22 Aug 2024 14:39:14 -0600 Subject: [PATCH 09/22] Add some comments about some of this being temporary and point to the issue regarding it --- bld/CLMBuildNamelist.pm | 32 +++++++++++++++++++++----------- cime_config/config_component.xml | 1 + 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 1fad577c51..52ac4c1d6f 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1756,25 +1756,29 @@ sub process_namelist_inline_logic { ################################## setup_logic_lightning_streams($opts, $nl_flags, $definition, $defaults, $nl); - ###################################### + ############################################################################################ # namelist options for dust emissions - ###################################### + # NOTE: This MUST be done before other drv_flds_in settings (megan, drydep, fire_emis etc.) + ############################################################################################ setup_logic_dust_emis($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref); setup_logic_prigent_roughness($opts, $nl_flags, $definition, $defaults, $nl); - ################################# - # namelist group: drydep_inparm # - ################################# + ##################################### + # namelist group: drydep_inparm # + # NOTE: After setup_logic_dust_emis # + ##################################### setup_logic_dry_deposition($opts, $nl_flags, $definition, $defaults, $nl); - ################################# - # namelist group: fire_emis_nl # - ################################# + ##################################### + # namelist group: fire_emis_nl # + # NOTE: After setup_logic_dust_emis # + ##################################### setup_logic_fire_emis($opts, $nl_flags, $definition, $defaults, $nl); - ################################# - # namelist group: megan_emis_nl # - ################################# + ##################################### + # namelist group: megan_emis_nl # + # NOTE: After setup_logic_dust_emis # + ##################################### setup_logic_megan($opts, $nl_flags, $definition, $defaults, $nl); ################################## @@ -4041,6 +4045,8 @@ sub setup_logic_dust_emis { my ($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref) = @_; # Only set dust emission settings -- if not connected to CAM + # Longer term plan is to remove this logic and have CTSM just set it and for CAM to use what CLM decides + # See: https://github.com/ESCOMP/CTSM/issues/2713 my $lnd_sets_dust = logical_to_fortran($envxml_ref->{'LND_SETS_DUST_EMIS_DRV_FLDS'}); if ( &value_is_true( $lnd_sets_dust)) { @@ -4094,8 +4100,12 @@ sub setup_logic_dust_emis { } } # Now process the CAM drv_flds_in to get the dust settings + # This requires that the CAM drv_flds_in namelist be created BEFORE CLM + # and that the path below NOT be changed. Hence, there's some fragility here + # to future changes. my $infile = $opts->{'envxml_dir'} . "/Buildconf/camconf/drv_flds_in"; $log->verbose_message("Read in the drv_flds_in file generated by CAM's build-namelist"); + # When merging the CAM namelist in -- die with an error if there's a conflict between CAM and CLM process_namelist_infile( $definition, $nl, $envxml_ref, $infile, 'die_on_conflict'=>1 ); } } diff --git a/cime_config/config_component.xml b/cime_config/config_component.xml index 3c48e16651..e3f559b08a 100644 --- a/cime_config/config_component.xml +++ b/cime_config/config_component.xml @@ -167,6 +167,7 @@ + logical TRUE,FALSE TRUE From fa7f8f5928609f67cd710149802db30bf886428b Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 22 Aug 2024 15:22:19 -0600 Subject: [PATCH 10/22] Fix bug in setting of init_interp_attributes that should have been for clm6_0_cam6.0, that came about due to XML code duplication --- bld/namelist_files/namelist_defaults_ctsm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 167ded8c62..668ea1e05f 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1193,12 +1193,12 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -hgrid=0.9x1.25 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. -hgrid=1.9x2.5 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. From 796bd834fb575153d681992cc3641ee0636333bd Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 22 Aug 2024 15:35:14 -0600 Subject: [PATCH 11/22] Get the megan_spec checker working for identifying bad characters in a string --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 52ac4c1d6f..37eedff6e5 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -5665,7 +5665,7 @@ sub check_megan_spec { foreach my $spec ( @megan_spec_list ) { $megan_spec = remove_leading_and_trailing_quotes($spec); # Do simple validation of the expressions to just check for valid characters - if ( ! $megan_spec =~ /[\s=A-Za-z0-9_\+\.\*\(\)-]+/ ) { + if ( $megan_spec !~ /^([\s=A-Za-z0-9_\+\.\*\(\)-]+)$/ ) { $log->fatal_error("Bad format for megan_specifier = $megan_spec"); } } From b2d7edf8f629406b01ec0044ea8655de9d670da5 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 22 Aug 2024 17:14:44 -0600 Subject: [PATCH 12/22] Duplicate a bunch of XML so that the namelist unit tester works for all the tests --- bld/namelist_files/namelist_defaults_ctsm.xml | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 668ea1e05f..394f72a62e 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1059,12 +1059,12 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >hgrid=1.9x2.5 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. -hgrid=ne0np4.ARCTIC.ne30x4 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. -hgrid=ne0np4.ARCTICGRIS.ne30x8 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. @@ -1144,6 +1144,26 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. +hgrid=0.9x1.25 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=1.9x2.5 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=ne0np4.ARCTIC.ne30x4 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=ne0np4.ARCTICGRIS.ne30x8 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + hgrid=0.9x1.25 maxpft=79 mask=gx1v7 use_cn=.true. use_crop=.true. irrigate=.true. glc_nec=10 do_transient_pfts=.false. @@ -1213,6 +1233,26 @@ attributes from the config_cache.xml file (with keys converted to upper-case). >hgrid=ne0np4.ARCTICGRIS.ne30x8 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. +hgrid=0.9x1.25 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=1.9x2.5 maxpft=17 mask=gx1v7 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=ne0np4.ARCTIC.ne30x4 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + +hgrid=ne0np4.ARCTICGRIS.ne30x8 maxpft=17 mask=tx0.1v2 use_cn=.false. use_crop=.false. irrigate=.true. glc_nec=10 do_transient_pfts=.false. + + Date: Thu, 22 Aug 2024 17:15:17 -0600 Subject: [PATCH 13/22] Change fatal error to warning for megan_specifier --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 37eedff6e5..94f6bf7e38 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -5666,7 +5666,7 @@ sub check_megan_spec { $megan_spec = remove_leading_and_trailing_quotes($spec); # Do simple validation of the expressions to just check for valid characters if ( $megan_spec !~ /^([\s=A-Za-z0-9_\+\.\*\(\)-]+)$/ ) { - $log->fatal_error("Bad format for megan_specifier = $megan_spec"); + $log->warning("Bad format for megan_specifier = $megan_spec"); } } } From a5a15ed19bd7517e3abfd9994353c3f42bd49e8d Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 22 Aug 2024 17:17:11 -0600 Subject: [PATCH 14/22] Correct test number and remove fail tests that are now allowed to happen because you can set drv_flds_in settings without using the CLM_BLDNML_OPTS options for it --- bld/unit_testers/build-namelist_test.pl | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index de5a9b0e13..8b2827b069 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 = 3339; +my $ntests = 3349; if ( defined($opts{'compare'}) ) { - $ntests += 1999; + $ntests += 2007; } plan( tests=>$ntests ); @@ -1093,14 +1093,6 @@ sub cat_and_create_namelistinfile { namelst=>"use_hydrstress=.true.", phys=>"clm5_0", }, - "specWOfireemis" =>{ options=>"-envxml_dir . -no-fire_emis", - namelst=>"fire_emis_specifier='bc_a1 = BC'", - phys=>"clm5_0", - }, - "elevWOfireemis" =>{ options=>"-envxml_dir . -no-fire_emis", - namelst=>"fire_emis_elevated=.false.", - 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 b35320a2c452dcb99e82a183bffda126c1206eb1 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 8 Dec 2021 13:54:28 -0700 Subject: [PATCH 15/22] Also include the mizuRoute expected fails list --- parse_cime.cs.status | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/parse_cime.cs.status b/parse_cime.cs.status index 08bb1bfc86..269878d0bd 100755 --- a/parse_cime.cs.status +++ b/parse_cime.cs.status @@ -302,6 +302,7 @@ sub print_categories { if ( ! -f $expectedfailfile ) { $expectedfailfile = "$scrdir/cime_config/testdefs/ExpectedTestFails.xml"; } + my @failfiles = ( $expectedfailfile, "$scrdir/components/mizuRoute/cime_config/testdefs/ExpectedTestFails.xml" ); my @passes; my @fails; my @pendings; @@ -341,8 +342,10 @@ sub print_categories { print( "================================================================================\n" ); foreach my $key ( @passes ) { my $expect = ""; - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = "FAILED PREVIOUSLY"; } + foreach my $expectedfailfile ( @failfiles ) { + `grep $key $expectedfailfile > /dev/null`; + if ( $? == 0 ) { $expect = "FAILED PREVIOUSLY"; } + } print( "$key\t\t\t$expect\n" ); } } @@ -368,8 +371,10 @@ sub print_categories { print( "================================================================================\n" ); foreach my $key ( @pendings ) { my $expect = ""; - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = "EXPECTED"; } + foreach my $expectedfailfile ( @failfiles ) { + `grep $key $expectedfailfile > /dev/null`; + if ( $? == 0 ) { $expect = "EXPECTED"; } + } print( "$key\t\t$expect\n" ); } } @@ -379,8 +384,10 @@ sub print_categories { print( "================================================================================\n" ); foreach my $key ( @fails ) { my $expect = ""; - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = "EXPECTED"; } + foreach my $expectedfailfile ( @failfiles ) { + `grep $key $expectedfailfile > /dev/null`; + if ( $? == 0 ) { $expect = "EXPECTED"; } + } print( "$key\t\t$expect\n" ); } } From 463e85d8f624fb8f8b64592f4a6824b80683bdd9 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 19 Jan 2022 22:45:47 -0700 Subject: [PATCH 16/22] Add bit from SLIM that includes what parts FAIL when reporting summary of fails --- parse_cime.cs.status | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parse_cime.cs.status b/parse_cime.cs.status index 269878d0bd..8ef8ef2bf6 100755 --- a/parse_cime.cs.status +++ b/parse_cime.cs.status @@ -384,11 +384,12 @@ sub print_categories { print( "================================================================================\n" ); foreach my $key ( @fails ) { my $expect = ""; + my $fails = $csstatus{$key}{'FAIL'}; foreach my $expectedfailfile ( @failfiles ) { `grep $key $expectedfailfile > /dev/null`; if ( $? == 0 ) { $expect = "EXPECTED"; } } - print( "$key\t\t$expect\n" ); + print( "$key\t$fails\t$expect\n" ); } } } From 8fbfcc009c26459e5c76c03309d1d58c678583c8 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 25 Jan 2022 14:32:09 -0700 Subject: [PATCH 17/22] Add an extra tab --- parse_cime.cs.status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse_cime.cs.status b/parse_cime.cs.status index 8ef8ef2bf6..fb2d8e4283 100755 --- a/parse_cime.cs.status +++ b/parse_cime.cs.status @@ -389,7 +389,7 @@ sub print_categories { `grep $key $expectedfailfile > /dev/null`; if ( $? == 0 ) { $expect = "EXPECTED"; } } - print( "$key\t$fails\t$expect\n" ); + print( "$key\t$fails\t\t$expect\n" ); } } } From 0d1a867beb91d1e8a1aacd57a3165dd297c33a1b Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Aug 2024 16:06:00 -0600 Subject: [PATCH 18/22] Make a little subroutine to check the expected fails --- parse_cime.cs.status | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/parse_cime.cs.status b/parse_cime.cs.status index fb2d8e4283..885b53c6c4 100755 --- a/parse_cime.cs.status +++ b/parse_cime.cs.status @@ -290,7 +290,15 @@ sub print_sumperline { } } - +sub expectedFails { + my ($key, $message, @failfiles) = @_; + my $expect = ""; + foreach my $expectedfailfile ( @failfiles ) { + `grep $key $expectedfailfile > /dev/null`; + if ( $? == 0 ) { $expect = $message; } + } + return( $expect ); +} sub print_categories { # Seperate tests into categories @@ -341,11 +349,7 @@ sub print_categories { print( "These tests passed\n" ); print( "================================================================================\n" ); foreach my $key ( @passes ) { - my $expect = ""; - foreach my $expectedfailfile ( @failfiles ) { - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = "FAILED PREVIOUSLY"; } - } + my $expect = &expectedFails( $key, "FAILED PREVIOUSLY", @failfiles ); print( "$key\t\t\t$expect\n" ); } } @@ -370,26 +374,19 @@ sub print_categories { print( "These tests are pending (some tests may fail in the pending state)\n" ); print( "================================================================================\n" ); foreach my $key ( @pendings ) { - my $expect = ""; - foreach my $expectedfailfile ( @failfiles ) { - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = "EXPECTED"; } - } + my $expect = &expectedFails( $key, "EXPECTED", @failfiles ); print( "$key\t\t$expect\n" ); } } if ( $#fails >= 0 ) { print( "================================================================================\n" ); print( "These tests failed\n" ); + print( "Test (what Failed) If expected\n" ); print( "================================================================================\n" ); foreach my $key ( @fails ) { - my $expect = ""; + my $expect = &expectedFails( $key, "EXPECTED", @failfiles ); my $fails = $csstatus{$key}{'FAIL'}; - foreach my $expectedfailfile ( @failfiles ) { - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = "EXPECTED"; } - } - print( "$key\t$fails\t\t$expect\n" ); + print( "$key\t($fails)\t\t$expect\n" ); } } } From cd6a94b3512bf9d4def7b7db1af85e77fb3e1690 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Aug 2024 17:03:09 -0600 Subject: [PATCH 19/22] Report on the expected fails for tests --- parse_cime.cs.status | 46 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/parse_cime.cs.status b/parse_cime.cs.status index 885b53c6c4..264ba0708f 100755 --- a/parse_cime.cs.status +++ b/parse_cime.cs.status @@ -204,7 +204,11 @@ sub run_csstatus { do { $newline = shift(@lines); if ( $newline =~ /FAIL[ ]+$test ([^ ]+)/ ) { - $fails .= " $1"; + if ( $fails eq "" ) { + $fails = $1; + } else { + $fails .= " $1"; + } chomp( $fails ); if ( $1 eq "BASELINE" ) { if ( $newline =~ /ERROR BFAIL baseline directory/ ) { @@ -291,13 +295,31 @@ sub print_sumperline { } sub expectedFails { + # Query expected fail file for the input testname key my ($key, $message, @failfiles) = @_; my $expect = ""; + my $expectedfails = ""; foreach my $expectedfailfile ( @failfiles ) { - `grep $key $expectedfailfile > /dev/null`; - if ( $? == 0 ) { $expect = $message; } + my $fh = IO::File->new($expectedfailfile, '<') or die "ERROR:: failure opening $expectedfailfile\n"; + while( my $line = <$fh> ) { + if ( $line =~ /$key/ ) { + $expect = $message; + # Read past the testname until the test end is found... + # Keep track of all of the expected fails and return it at the end + while( my $testline = <$fh> ) { + if ( $testline =~ /phase\s+name\s*=\s*\"([a-zA-Z0-9_]+)/ ) { + if ( $expectedfails eq "" ) { + $expectedfails = $1; + } else { + $expectedfails = "$expectedfails $1"; + } + } + if ( $testline =~ /\<\/test\>/ ) { last; } + } + } + } } - return( $expect ); + return( $expect, $expectedfails ); } sub print_categories { @@ -349,7 +371,9 @@ sub print_categories { print( "These tests passed\n" ); print( "================================================================================\n" ); foreach my $key ( @passes ) { - my $expect = &expectedFails( $key, "FAILED PREVIOUSLY", @failfiles ); + my ($expect, $expectFails) = &expectedFails( $key, "FAILED PREVIOUSLY", @failfiles ); + if ( $expect ne "" ) { $expect = "$expect ($expectFails)"; } + if ($expectFails =~ /BASELINE/ ) { $expect = ""; } print( "$key\t\t\t$expect\n" ); } } @@ -358,7 +382,9 @@ sub print_categories { print( "These tests compare different to the baseline\n" ); print( "================================================================================\n" ); foreach my $key ( @compares_diff ) { - print( "$key\n" ); + my ($expect, $expectFails) = &expectedFails( $key, "EXPECTED POSSIBILITY", @failfiles ); + if ($expectFails !~ /BASELINE/ ) { $expect = ""; } + print( "$key\t\t$expect\n" ); } } if ( $#compares_diff_nobase >= 0 ) { @@ -374,17 +400,19 @@ sub print_categories { print( "These tests are pending (some tests may fail in the pending state)\n" ); print( "================================================================================\n" ); foreach my $key ( @pendings ) { - my $expect = &expectedFails( $key, "EXPECTED", @failfiles ); + my ($expect, $expectFails) = &expectedFails( $key, "EXPECTED", @failfiles ); + if ( $expect ne "" ) { $expect = "$expect ($expectFails)"; } print( "$key\t\t$expect\n" ); } } if ( $#fails >= 0 ) { print( "================================================================================\n" ); print( "These tests failed\n" ); - print( "Test (what Failed) If expected\n" ); + print( "Test (what Failed) EXPECTED (what expected to fail)\n" ); print( "================================================================================\n" ); foreach my $key ( @fails ) { - my $expect = &expectedFails( $key, "EXPECTED", @failfiles ); + my ($expect, $expectFails) = &expectedFails( $key, "EXPECTED", @failfiles ); + if ( $expect ne "" ) { $expect = "$expect ($expectFails)"; } my $fails = $csstatus{$key}{'FAIL'}; print( "$key\t($fails)\t\t$expect\n" ); } From c5aeec66333b37050bd426c678ac36f9ec3f0c62 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Aug 2024 21:43:31 -0600 Subject: [PATCH 20/22] Add some more notes about -drydep, -fire_emis, -no-megan options options that they add testing namelists, but you can always add the fields to user_nl_clm even when they are turned off --- bld/CLMBuildNamelist.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 94f6bf7e38..15d51ccfcb 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -159,16 +159,20 @@ OPTIONS This turns on the namelist variable: use_crop -csmdata "dir" Root directory of CESM input data. Can also be set by using the CSMDATA environment variable. - -drydep Produce a drydep_inparm namelist that will go into the + -drydep Produce a drydep_inparm namelist for testing that will go into the "drv_flds_in" file for the driver to pass dry-deposition to the atm. + This populates the namelist with valid drydep settings for testing. Default: -no-drydep + Note: Can always add drydep fields to user_nl_clm even with --no-drydep (Note: buildnml copies the file for use by the driver) -dynamic_vegetation Toggle for dynamic vegetation model. (default is off) (can ONLY be turned on when BGC type is 'bgc') This turns on the namelist variable: use_cndv (Deprecated, this will be removed) - -fire_emis Produce a fire_emis_nl namelist that will go into the + -fire_emis Produce a fire_emis_nl namelist for testing that will go into the "drv_flds_in" file for the driver to pass fire emissions to the atm. + This populates the namelist with valid fire-emiss settings for testing. + Note: Can always add fire_emis fields to user_nl_clm even with --no-fire_emis (Note: buildnml copies the file for use by the driver) -glc_nec Glacier number of elevation classes [0 | 3 | 5 | 10 | 36] (default is 0) (standard option with land-ice model is 10) @@ -204,9 +208,11 @@ OPTIONS -namelist "namelist" Specify namelist settings directly on the commandline by supplying a string containing FORTRAN namelist syntax, e.g., -namelist "&clm_inparm dt=1800 /" - -no-megan DO NOT PRODUCE a megan_emis_nl namelist that will go into the + -no-megan DO NOT PRODUCE a megan_emis_nl namelist for testing that will go into the "drv_flds_in" file for the driver to pass VOCs to the atm. MEGAN (Model of Emissions of Gases and Aerosols from Nature) + This removes setting default values for testing MEGAN fields + Note: Can always add megan fields to user_nl_clm even with --no-megan (Note: buildnml copies the file for use by the driver) -[no-]note Add note to output namelist [do NOT add note] about the arguments to build-namelist. From 46a09d91c08cf39a5352f9b2e78e7622f3376503 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 26 Aug 2024 22:10:27 -0600 Subject: [PATCH 21/22] Update some of the documentation around the -drydep, -fire_emis and --no-megan build-namelist options --- bld/namelist_files/namelist_defaults_drydep.xml | 6 +++--- bld/namelist_files/namelist_defaults_fire_emis.xml | 4 ++-- bld/namelist_files/namelist_definition_drv_flds.xml | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_drydep.xml b/bld/namelist_files/namelist_defaults_drydep.xml index 08bb5adaef..fb73ab6646 100644 --- a/bld/namelist_files/namelist_defaults_drydep.xml +++ b/bld/namelist_files/namelist_defaults_drydep.xml @@ -5,7 +5,7 @@ - + 'O3','NO2','HNO3','NO','HO2NO2','CH3OOH','CH2O','CO','H2O2','CH3COOOH','PAN','MPAN','C2H5OOH','ONIT','POOH','C3H7OOH','ROOH','CH3COCHO','CH3COCH3','Pb','ONITR','MACROOH','XOOH','ISOPOOH','CH3OH','C2H5OH','CH3CHO','GLYALD','HYAC','HYDRALD','ALKOOH','MEKOOH','TOLOOH','TERPOOH','CH3COOH','CB1','CB2','OC1','OC2','SOA','SO2','SO4','NH3','NH4NO3' @@ -21,7 +21,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). atm/cam/chem/trop_mozart/dvel/dep_data_c201019.nc - + 'ISOP = isoprene', 'C10H16 = pinene_a + carene_3 + thujene_a', 'CH3OH = methanol', 'C2H5OH = ethanol', 'CH2O = formaldehyde', 'CH3CHO = acetaldehyde', 'CH3COOH = acetic_acid', 'CH3COCH3 = acetone' diff --git a/bld/namelist_files/namelist_defaults_fire_emis.xml b/bld/namelist_files/namelist_defaults_fire_emis.xml index b7536ba66b..54e67424d5 100644 --- a/bld/namelist_files/namelist_defaults_fire_emis.xml +++ b/bld/namelist_files/namelist_defaults_fire_emis.xml @@ -5,7 +5,7 @@ - + 'bc_a1 = BC','pom_a1 = 1.4*OC','SO2 = SO2' diff --git a/bld/namelist_files/namelist_definition_drv_flds.xml b/bld/namelist_files/namelist_definition_drv_flds.xml index 9bb1a3e3b0..f440a9a678 100644 --- a/bld/namelist_files/namelist_definition_drv_flds.xml +++ b/bld/namelist_files/namelist_definition_drv_flds.xml @@ -35,10 +35,14 @@ group="megan_emis_nl" valid_values="" > MEGAN specifier. This is in the form of: Chem-compound = megan_compound(s) - where megan_compound(s) can be the sum of megan compounds with a "+" between them. + where megan_compound(s) can be an equation with megan compounds added or subtracted together with multiplication In each equation, the item to the left of the equal sign is a CAM chemistry compound, the items to the right are compounds known to the MEGAN model (single or combinations). + Long lines for equations can be split into multiple specifiers For example: megan_specifier = 'ISOP = isoprene', 'C10H16 = pinene_a + carene_3 + thujene_a' + or... megan_specifier = 'SOAE = 0.5954*isoprene + 5.1004*(carene_3 + pinene_a + thujene_a + bornene +', + ' terpineol_4 + terpineol_a + terpinyl_ACT_a + myrtenal + sabinene + pinene_b + camphene +', + and etcetera... Date: Mon, 26 Aug 2024 23:11:11 -0600 Subject: [PATCH 22/22] Update documentation around the drv_flds_in testing namelists and command line options to build-namelist -drydep, -fire_emis and -no-megan --- .../customizing-the-clm-configuration.rst | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/doc/source/users_guide/setting-up-and-running-a-case/customizing-the-clm-configuration.rst b/doc/source/users_guide/setting-up-and-running-a-case/customizing-the-clm-configuration.rst index e76a9cc6f0..a1efac897e 100644 --- a/doc/source/users_guide/setting-up-and-running-a-case/customizing-the-clm-configuration.rst +++ b/doc/source/users_guide/setting-up-and-running-a-case/customizing-the-clm-configuration.rst @@ -140,10 +140,17 @@ CLM_BLDNML_OPTS Can also be set by using the CSMDATA environment variable. -d "directory" Directory where output namelist file will be written Default: current working directory. - -drydep Produce a drydep_inparm namelist that will go into the + -drydep Produce a drydep_inparm namelist for testing that will go into the "drv_flds_in" file for the driver to pass dry-deposition to the atm. + This populates the namelist with valid drydep settings for testing. Default: -no-drydep - (Note: buildnml.csh copies the file for use by the driver) + Note: Can always add drydep fields to user_nl_clm even with --no-drydep + (Note: buildnml copies the file for use by the driver) + -fire_emis Produce a fire_emis_nl namelist for testing that will go into the + "drv_flds_in" file for the driver to pass fire emissions to the atm. + This populates the namelist with valid fire-emiss settings for testing. + Note: Can always add fire_emis fields to user_nl_clm even with --no-fire_emis + (Note: buildnml copies the file for use by the driver) -glc_grid "grid" Glacier model grid and resolution when glacier model, Only used if glc_nec > 0 for determining fglcmask Default: gland5UM @@ -185,10 +192,12 @@ CLM_BLDNML_OPTS -namelist "namelist" Specify namelist settings directly on the commandline by supplying a string containing FORTRAN namelist syntax, e.g., -namelist "&clm_inparm dt=1800 /" - -no-megan DO NOT PRODUCE a megan_emis_nl namelist that will go into the + -no-megan DO NOT PRODUCE a megan_emis_nl namelist for testing that will go into the "drv_flds_in" file for the driver to pass VOCs to the atm. MEGAN (Model of Emissions of Gases and Aerosols from Nature) - (Note: buildnml.csh copies the file for use by the driver) + This removes setting default values for testing MEGAN fields + Note: Can always add megan fields to user_nl_clm even with --no-megan + (Note: buildnml copies the file for use by the driver) -[no-]note Add note to output namelist [do NOT add note] about the arguments to build-namelist. -rcp "value" Representative concentration pathway (rcp) to use for @@ -258,6 +267,8 @@ The **$CTSMROOT/cime_config/buildnml** script already sets the resolution and ma #. -drydep +#. -fire_emis + #. -ignore_ic_date #. -ignore_ic_year @@ -291,7 +302,7 @@ To see a list of valid variables that you could set do this: .. note:: Using a 20th-Century transient compset or the ``20thC_transient`` use-case using ``CLM_NML_USE_CASE`` would set this as well, but would also use dynamic nitrogen and aerosol deposition files, so using ``-clm_demand`` would be a way to get *just* dynamic vegetation types and NOT the other files as well. -"-drydep" adds the dry-deposition namelist to the driver. This is a driver namelist, but adding the option here has CLM **build-namelist** create the ``drv_flds_in`` file that the driver will copy over and use. Invoking this option does have an impact on performance even for I compsets and will slow the model down. It's also only useful when running with an active atmosphere model that makes use of this information. +"-drydep" adds a dry-deposition namelist for testing to the driver. This is a driver namelist, but adding the option here has CLM **build-namelist** create the ``drv_flds_in`` file that the driver will copy over and use. Invoking this option does have an impact on performance even for I compsets and will slow the model down. It's also only useful when running with an active atmosphere model that makes use of this information. "-ignore_ic_date" ignores the Initial Conditions (IC) date completely for finding initial condition files to startup from. Without this option or the "-ignore_ic_year" option below, the date of the file comes into play. @@ -299,7 +310,7 @@ To see a list of valid variables that you could set do this: When "-irrig on" is used **build-namelist** will try to find surface datasets that have the irrigation model enabled (when running with Sattellitte Phenology). When running with the prognostic crop model on, "-irrig on" will turn irrigate crops on, while "-irrig off" will manage all crop areas as rain-fed without irrigation. -"no-megan" means do NOT add the MEGAN model Biogenic Volatile Organic Compounds (BVOC) namelist to the driver. This namelist is created by default, so normally this WILL be done. This is a driver namelist, so unless "no-megan" is specified the CLM **build-namelist** will create the ``drv_flds_in`` file that the driver will copy over and use (if you are running with CAM and CAM produces this file as well, it's file will have precedence). +"no-megan" means do NOT add a MEGAN model Biogenic Volatile Organic Compounds (BVOC) testing namelist to the driver. This namelist is created by default, so normally this WILL be done. This is a driver namelist, so unless "no-megan" is specified the CLM **build-namelist** will create the ``drv_flds_in`` file that the driver will copy over and use (if you are running with CAM and CAM produces this file as well, it's file will have precedence). "-note" adds a note to the bottom of the namelist file, that gives the details of how **build-namelist** was called, giving the specific command-line options given to it. @@ -363,18 +374,20 @@ Example: user_nl_clm namelist file ! Users should add all user specific namelist changes below in the form of ! namelist_var = new_namelist_value ! - ! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options - ! are set in the CLM_NAMELIST_OPTS env variable. - ! ! EXCEPTIONS: + ! Set use_cndv by the compset you use and the CLM_BLDNML_OPTS -dynamic_vegetation setting + ! Set use_vichydro by the compset you use and the CLM_BLDNML_OPTS -vichydro setting + ! Set use_cn by the compset you use and CLM_BLDNML_OPTS -bgc setting + ! Set use_crop by the compset you use and CLM_BLDNML_OPTS -crop setting + ! Set spinup_state by the CLM_BLDNML_OPTS -bgc_spinup setting ! Set co2_ppmv with CCSM_CO2_PPMV option - ! Set dtime with L_NCPL option ! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options ! Set finidat with RUN_REFCASE/RUN_REFDATE/RUN_REFTOD options for hybrid or branch cases ! (includes $inst_string for multi-ensemble cases) - ! Set glc_grid with GLC_GRID option - ! Set glc_smb with GLC_SMB option - ! Set maxpatch_glc with GLC_NEC option + ! or with CLM_FORCE_COLDSTART to do a cold start + ! or set it with an explicit filename here. + ! Set maxpatch_glc with GLC_NEC option + ! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable !---------------------------------------------------------------------------------- hist_fincl2 = 'TG','TBOT','FIRE','FIRA','FLDS','FSDS', 'FSR','FSA','FGEV','FSH','FGR','TSOI',