From bb37cab5373f9f150673e7de3bfdd0512b51097c Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Fri, 15 Mar 2024 16:04:02 +0100 Subject: [PATCH 1/2] updates for error check --- bld/CLMBuildNamelist.pm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b4550f99c4..01e9395529 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -97,7 +97,7 @@ OPTIONS CENTURY or MIMICS decomposition This toggles on the namelist variables: use_fates. use_lch4 and use_nitrif_denitrif are optional - + (Only for CLM4.5/CLM5.0) -[no-]chk_res Also check [do NOT check] to make sure the resolution and land-mask is valid. @@ -984,6 +984,13 @@ sub setup_cmdl_fire_light_res { if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); } + if ( &value_is_true($nl_flags->{'use_fates'}) ) { + if ( $nl->get_value('fates_spitfire_mode') == 0) { + if (! $opts->{'fire_emis'} ) { + $log->fatal_error("cannot have fire_emis and use_fates set if fates does not have spitfire mode") + } + } + } if ( ! &value_is_true($nl->get_value('use_cn')) ) { if ( &value_is_true($nl_flags->{'use_fates'}) ) { if ( $nl->get_value('fates_spitfire_mode') < 2) { @@ -1010,7 +1017,7 @@ sub setup_cmdl_fire_light_res { if ( ! &value_is_true($nl_flags->{'neon'}) ) { if ( defined($opts->{'clm_usr_name'}) ) { $log->warning("The NEON lightning dataset does NOT cover the entire globe, make sure it covers the region for your grid"); - } else { + } else { $log->fatal_error("The NEON lightning dataset can NOT be used for global grids or regions or points outside of its area as it does NOT cover the entire globe."); } } @@ -2260,7 +2267,7 @@ sub setup_logic_crop_inparm { } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, "initial_seed_at_planting", 'use_crop'=>$nl->get_value('use_crop') ); - + my $crop_residue_removal_frac = $nl->get_value('crop_residue_removal_frac'); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'crop_residue_removal_frac' ); if ( $crop_residue_removal_frac < 0.0 or $crop_residue_removal_frac > 1.0 ) { @@ -2454,7 +2461,7 @@ sub setup_logic_surface_dataset { } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'hgrid'=>$nl_flags->{'res'}, 'ssp_rcp'=>$nl_flags->{'ssp_rcp'}, 'use_vichydro'=>$nl_flags->{'use_vichydro'}, - 'sim_year'=>$nl_flags->{'sim_year'}, 'irrigate'=>".true.", 'use_fates'=>$nl_flags->{'use_fates'}, + 'sim_year'=>$nl_flags->{'sim_year'}, 'irrigate'=>".true.", 'use_fates'=>$nl_flags->{'use_fates'}, 'neon'=>$nl_flags->{'neon'}, 'neonsite'=>$nl_flags->{'neonsite'}, 'use_crop'=>$nl_flags->{'use_crop'}, 'glc_nec'=>$nl_flags->{'glc_nec'} ); } @@ -3119,7 +3126,7 @@ sub setup_logic_supplemental_nitrogen { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'suplnitro', 'use_fates'=>$nl_flags->{'use_fates'}); } - + # # Error checking for suplnitro # @@ -3629,10 +3636,10 @@ sub setup_logic_nitrogen_deposition { 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndep_taxmode', 'phys'=>$nl_flags->{'phys'}, - 'use_cn'=>$nl_flags->{'use_cn'}, + 'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'} ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndep_varlist', 'phys'=>$nl_flags->{'phys'}, - 'use_cn'=>$nl_flags->{'use_cn'}, + 'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'} ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_ndep', 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, 'sim_year'=>$nl_flags->{'sim_year'}, @@ -4423,8 +4430,8 @@ sub setup_logic_fates { 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'}) ) { - $log->fatal_error("supplemental Nitrogen (suplnitro) is NOT set to ALL, FATES is on, " . - "but and FATES-SP is not active, but fates_parteh_mode is 1, so Nitrogen is not active" . + $log->fatal_error("supplemental Nitrogen (suplnitro) is NOT set to ALL, FATES is on, " . + "but and FATES-SP is not active, but fates_parteh_mode is 1, so Nitrogen is not active" . "Change suplnitro back to ALL"); } # From c6405cd8fdabd172d77b6b2e0d67090a853b5ae2 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Fri, 15 Mar 2024 16:13:59 +0100 Subject: [PATCH 2/2] error check for spitfire mode and fire_emis --- bld/CLMBuildNamelist.pm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 01e9395529..fde53a8f8e 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -984,13 +984,6 @@ sub setup_cmdl_fire_light_res { if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); } - if ( &value_is_true($nl_flags->{'use_fates'}) ) { - if ( $nl->get_value('fates_spitfire_mode') == 0) { - if (! $opts->{'fire_emis'} ) { - $log->fatal_error("cannot have fire_emis and use_fates set if fates does not have spitfire mode") - } - } - } if ( ! &value_is_true($nl->get_value('use_cn')) ) { if ( &value_is_true($nl_flags->{'use_fates'}) ) { if ( $nl->get_value('fates_spitfire_mode') < 2) { @@ -3925,7 +3918,10 @@ sub setup_logic_fire_emis { if ($opts->{'fire_emis'} ) { if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning( "Fire emission factor file will NOT be used when FATES is on.\n" ); + $log->message( "Fire emission factor file will NOT be used when FATES is on.\n" ); + if ( $nl->get_value('fates_spitfire_mode') == 0) { + $log->fatal_error("cannot have fire_emis and use_fates set if fates does not have spitfire mode on") + } } else { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_factors_file'); }