@@ -3746,6 +3746,8 @@ sub setup_logic_c_isotope {
37463746 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' use_c14' ,
37473747 ' bgc_mode' => $nl_flags -> {' bgc_mode' }, ' phys' => $nl_flags -> {' phys' },
37483748 ' lnd_tuning_mode' => $nl_flags -> {' lnd_tuning_mode' }, ssp_rcp => $nl_flags -> {' ssp_rcp' } );
3749+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13" );
3750+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c14" );
37493751 my $use_c13 = $nl -> get_value(' use_c13' );
37503752 my $use_c14 = $nl -> get_value(' use_c14' );
37513753 if ( $nl_flags -> {' bgc_mode' } ne " sp" && $nl_flags -> {' bgc_mode' } ne " fates" ) {
@@ -3765,6 +3767,7 @@ sub setup_logic_c_isotope {
37653767 $use_c14_bombspike = $nl -> get_value(' use_c14_bombspike' );
37663768 if ( &value_is_true($use_c14_bombspike ) ) {
37673769 if ( defined ($stream_fldfilename_atm_c14 ) ) {
3770+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c14_bombspike" );
37683771 setup_logic_c14_streams($opts , $nl_flags , $definition , $defaults , $nl );
37693772 } else {
37703773 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' atm_c14_filename' ,
@@ -3784,6 +3787,8 @@ sub setup_logic_c_isotope {
37843787 $log -> fatal_error(" use_c14 is FALSE and use_c14_bombspike, stream_fldfilename_atm_c14 or atm_c14_filename set" );
37853788 }
37863789 }
3790+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c14_bombspike" );
3791+
37873792 my $use_c13_timeseries = $nl -> get_value(' use_c13_timeseries' );
37883793 my $stream_fldfilename_atm_c13 = $nl -> get_value(' stream_fldfilename_atm_c13' );
37893794 my $atm_c13_filename = $nl -> get_value(' atm_c13_filename' );
@@ -3792,6 +3797,7 @@ sub setup_logic_c_isotope {
37923797 $use_c13_timeseries = $nl -> get_value(' use_c13_timeseries' );
37933798 if ( &value_is_true($use_c13_timeseries ) ) {
37943799 if ( defined ($stream_fldfilename_atm_c13 ) ) {
3800+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13_timeseries" );
37953801 setup_logic_c13_streams($opts , $nl_flags , $definition , $defaults , $nl );
37963802 } else {
37973803 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' atm_c13_filename' ,
@@ -3823,6 +3829,8 @@ sub setup_logic_c_isotope {
38233829 $log -> fatal_error(" bgc=sp and C isotope namelist variables were set, both can't be used at the same time" );
38243830 }
38253831 }
3832+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13_timeseries" );
3833+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13_bombspike" );
38263834}
38273835
38283836# -------------------------------------------------------------------------------
@@ -3832,6 +3840,23 @@ sub setup_logic_c13_streams {
38323840 #
38333841 # C13 stream file settings
38343842 #
3843+ # Just return if use_c13 and use_c13_timeseries aren't both TRUE
3844+ if ( ! &value_is_true($nl_flags -> {' use_c13' }) ) { return ; }
3845+ if ( ! &value_is_true($nl_flags -> {' use_c13_timeseries' }) ) { return ; }
3846+
3847+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_fldfilename_atm_c13' ,
3848+ ' use_c13' => $nl_flags -> {' use_c13' }, ' use_c13_timeseries' => $nl_flags -> {' use_c13_timeseries' },
3849+ ' ssp_rcp' => $nl_flags -> {' ssp_rcp' });
3850+
3851+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_first_atm_c13' ,
3852+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3853+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_last_atm_c13' ,
3854+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3855+ # Set align year, if first and last years are different
3856+ if ( $nl -> get_value(' stream_year_first_atm_c13' ) != $nl -> get_value(' stream_year_last_atm_c13' ) ) {
3857+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_model_year_align_atm_c13' ,
3858+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3859+ }
38353860}
38363861
38373862# -------------------------------------------------------------------------------
@@ -3841,6 +3866,30 @@ sub setup_logic_c14_streams {
38413866 #
38423867 # C14 stream file settings
38433868 #
3869+ # Just return if use_c14 and use_c14_bombspike aren't both TRUE
3870+ if ( ! &value_is_true($nl_flags -> {' use_c14' }) ) { return ; }
3871+ if ( ! &value_is_true($nl_flags -> {' use_c14_bombspike' }) ) { return ; }
3872+
3873+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_fldfilename_atm_c14' ,
3874+ ' use_c14' => $nl_flags -> {' use_c14' }, ' use_c14_bombspike' => $nl_flags -> {' use_c14_bombspike' },
3875+ ' ssp_rcp' => $nl_flags -> {' ssp_rcp' });
3876+
3877+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_meshfile_atm_c14' ,
3878+ ' use_c14' => $nl_flags -> {' use_c14' }, ' use_c14_bombspike' => $nl_flags -> {' use_c14_bombspike' });
3879+ if ( &remove_leading_and_trailing_quotes( $nl -> get_value( " stream_meshfile_atm_c14" ) ) eq " none" ) {
3880+ # TODP: Change this to a fatal when we start using this
3881+ $log -> warning( " stream_meshfile_atm_c14 is set to 'none' which will only copy the first latitude to the globe" )
3882+ }
3883+
3884+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_first_atm_c14' ,
3885+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3886+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_last_atm_c14' ,
3887+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3888+ # Set align year, if first and last years are different
3889+ if ( $nl -> get_value(' stream_year_first_atm_c14' ) != $nl -> get_value(' stream_year_last_atm_c14' ) ) {
3890+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_model_year_align_atm_c14' ,
3891+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3892+ }
38443893}
38453894
38463895# -------------------------------------------------------------------------------
@@ -5937,6 +5986,27 @@ sub logical_to_fortran {
59375986
59385987# -------------------------------------------------------------------------------
59395988
5989+ sub add_logical_to_nl_flags {
5990+ # Add a logical setting to the $nl_flsgs hash, so can be used in attribute checking
5991+ # This is important to do to make sure that the attribute is matched exactly as
5992+ # either: .true. or .false.
5993+ # Also sets nl_flags to .false. when the namelist variable is NOT set
5994+ my ($nl_flags , $nl , $var ) = @_ ;
5995+
5996+ my $val = $nl -> get_value($var );
5997+ if ( defined ($val ) ) {
5998+ if ( &value_is_true($val )) {
5999+ $nl_flags -> {$var } = " .true." ;
6000+ } else {
6001+ $nl_flags -> {$var } = " .false." ;
6002+ }
6003+ } else {
6004+ $nl_flags -> {$var } = " .false." ;
6005+ }
6006+ }
6007+
6008+ # -------------------------------------------------------------------------------
6009+
59406010sub string_is_undef_or_empty {
59416011 # Return true if the given string is undefined or only spaces, false otherwise.
59426012 # A quoted empty string (' ' or " ") is treated as being empty.
0 commit comments