Skip to content

Commit

Permalink
When LND_SETS_DUST_EMIS_DRV_FLDS is FALSE read in CAM drv_flds_in nam…
Browse files Browse the repository at this point in the history
…elist to use to determine dust_emis settings, still check that they aren't set in the user_nl_clm file
  • Loading branch information
ekluzek committed Aug 15, 2024
1 parent 7d8d0f6 commit a590ca7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
51 changes: 30 additions & 21 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 );
}
}
}
Expand Down Expand Up @@ -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 );
}
}

Expand Down
4 changes: 2 additions & 2 deletions bld/unit_testers/build-namelist_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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 " ); };
Expand Down
1 change: 1 addition & 0 deletions bld/unit_testers/empty_user_nl_clm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
! empty user_nl_clm file

0 comments on commit a590ca7

Please sign in to comment.