@@ -3776,6 +3776,8 @@ sub setup_logic_c_isotope {
37763776 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' use_c14' ,
37773777 ' bgc_mode' => $nl_flags -> {' bgc_mode' }, ' phys' => $nl_flags -> {' phys' },
37783778 ' lnd_tuning_mode' => $nl_flags -> {' lnd_tuning_mode' }, ssp_rcp => $nl_flags -> {' ssp_rcp' } );
3779+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13" );
3780+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c14" );
37793781 my $use_c13 = $nl -> get_value(' use_c13' );
37803782 my $use_c14 = $nl -> get_value(' use_c14' );
37813783 if ( $nl_flags -> {' bgc_mode' } ne " sp" && $nl_flags -> {' bgc_mode' } ne " fates" ) {
@@ -3794,14 +3796,14 @@ sub setup_logic_c_isotope {
37943796 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' use_c14_bombspike' , ' use_c14' => $use_c14 );
37953797 $use_c14_bombspike = $nl -> get_value(' use_c14_bombspike' );
37963798 if ( &value_is_true($use_c14_bombspike ) ) {
3797- if ( defined ($stream_fldfilename_atm_c14 ) ) {
3798- setup_logic_c14_streams($opts , $nl_flags , $definition , $defaults , $nl );
3799- } else {
3799+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c14_bombspike" );
3800+ setup_logic_c14_streams($opts , $nl_flags , $definition , $defaults , $nl );
3801+ $stream_fldfilename_atm_c14 = $nl -> get_value(' stream_fldfilename_atm_c14' );
3802+ if ( ! defined ($stream_fldfilename_atm_c14 ) ) {
38003803 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' atm_c14_filename' ,
38013804 ' use_c14' => $use_c14 , ' use_cn' => $nl_flags -> {' use_cn' }, ' use_c14_bombspike' => $nl -> get_value(' use_c14_bombspike' ),
3802- ' ssp_rcp' => $nl_flags -> {' ssp_rcp' } );
3805+ ' ssp_rcp' => $nl_flags -> {' ssp_rcp' }, ' cmip_era ' => $nl_flags -> { ' cmip_era ' } );
38033806 }
3804- $stream_fldfilename_atm_c14 = $nl -> get_value(' stream_fldfilename_atm_c14' );
38053807 $atm_c14_filename = $nl -> get_value(' atm_c14_filename' );
38063808 if ( defined ($stream_fldfilename_atm_c14 ) && defined ($atm_c14_filename ) ) {
38073809 $log -> fatal_error(" Both stream_fldfilename_atm_c14 and atm_c14_filename set, only one should be set" );
@@ -3814,21 +3816,23 @@ sub setup_logic_c_isotope {
38143816 $log -> fatal_error(" use_c14 is FALSE and use_c14_bombspike, stream_fldfilename_atm_c14 or atm_c14_filename set" );
38153817 }
38163818 }
3819+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c14_bombspike" );
3820+
38173821 my $use_c13_timeseries = $nl -> get_value(' use_c13_timeseries' );
38183822 my $stream_fldfilename_atm_c13 = $nl -> get_value(' stream_fldfilename_atm_c13' );
38193823 my $atm_c13_filename = $nl -> get_value(' atm_c13_filename' );
38203824 if ( &value_is_true($use_c13 ) ) {
38213825 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' use_c13_timeseries' , ' use_c13' => $use_c13 );
38223826 $use_c13_timeseries = $nl -> get_value(' use_c13_timeseries' );
38233827 if ( &value_is_true($use_c13_timeseries ) ) {
3824- if ( defined ($stream_fldfilename_atm_c13 ) ) {
3825- setup_logic_c13_streams($opts , $nl_flags , $definition , $defaults , $nl );
3826- } else {
3828+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13_timeseries" );
3829+ setup_logic_c13_streams($opts , $nl_flags , $definition , $defaults , $nl );
3830+ $stream_fldfilename_atm_c13 = $nl -> get_value(' stream_fldfilename_atm_c13' );
3831+ if ( ! defined ($nl -> get_value(' stream_fldfilename_atm_c13' )) ) {
38273832 add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' atm_c13_filename' ,
38283833 ' use_c13' => $use_c13 , ' use_cn' => $nl_flags -> {' use_cn' }, ' use_c13_timeseries' => $nl -> get_value(' use_c13_timeseries' ),
38293834 ' ssp_rcp' => $nl_flags -> {' ssp_rcp' } );
38303835 }
3831- $stream_fldfilename_atm_c13 = $nl -> get_value(' stream_fldfilename_atm_c13' );
38323836 $atm_c13_filename = $nl -> get_value(' atm_c13_filename' );
38333837 if ( defined ($stream_fldfilename_atm_c13 ) && defined ($atm_c13_filename ) ) {
38343838 $log -> fatal_error(" Both stream_fldfilename_atm_c13 and atm_c13_filename set, only one should be set" );
@@ -3853,6 +3857,8 @@ sub setup_logic_c_isotope {
38533857 $log -> fatal_error(" bgc=sp and C isotope namelist variables were set, both can't be used at the same time" );
38543858 }
38553859 }
3860+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13_timeseries" );
3861+ &add_logical_to_nl_flags( $nl_flags , $nl , " use_c13_bombspike" );
38563862}
38573863
38583864# -------------------------------------------------------------------------------
@@ -3862,6 +3868,27 @@ sub setup_logic_c13_streams {
38623868 #
38633869 # C13 stream file settings
38643870 #
3871+ # Just return if use_c13 and use_c13_timeseries aren't both TRUE
3872+ if ( ! &value_is_true($nl_flags -> {' use_c13' }) ) { return ; }
3873+ if ( ! &value_is_true($nl_flags -> {' use_c13_timeseries' }) ) { return ; }
3874+
3875+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_fldfilename_atm_c13' ,
3876+ ' use_c13' => $nl_flags -> {' use_c13' }, ' use_c13_timeseries' => $nl_flags -> {' use_c13_timeseries' },
3877+ ' ssp_rcp' => $nl_flags -> {' ssp_rcp' }, ' cmip_era' => $nl_flags -> {' cmip_era' }, ' nofail' => 1);
3878+ # If stream_fldfilename_atm_c13 is not defined then return and get the cmip6 file format version
3879+ if ( ! defined ( $nl -> get_value( " stream_fldfilename_atm_c13" ) ) ) {
3880+ return ;
3881+ }
3882+
3883+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_first_atm_c13' ,
3884+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3885+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_last_atm_c13' ,
3886+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3887+ # Set align year, if first and last years are different
3888+ if ( $nl -> get_value(' stream_year_first_atm_c13' ) != $nl -> get_value(' stream_year_last_atm_c13' ) ) {
3889+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_model_year_align_atm_c13' ,
3890+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3891+ }
38653892}
38663893
38673894# -------------------------------------------------------------------------------
@@ -3871,6 +3898,33 @@ sub setup_logic_c14_streams {
38713898 #
38723899 # C14 stream file settings
38733900 #
3901+ # Just return if use_c14 and use_c14_bombspike aren't both TRUE
3902+ if ( ! &value_is_true($nl_flags -> {' use_c14' }) ) { return ; }
3903+ if ( ! &value_is_true($nl_flags -> {' use_c14_bombspike' }) ) { return ; }
3904+
3905+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_fldfilename_atm_c14' ,
3906+ ' use_c14' => $nl_flags -> {' use_c14' }, ' use_c14_bombspike' => $nl_flags -> {' use_c14_bombspike' },
3907+ ' ssp_rcp' => $nl_flags -> {' ssp_rcp' }, ' nofail' => 1);
3908+ # If stream_fldfilename_atm_c14 is not defined then return and get the cmip6 file format version
3909+ if ( ! defined ( $nl -> get_value( " stream_fldfilename_atm_c14" ) ) ) {
3910+ return ;
3911+ }
3912+
3913+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_meshfile_atm_c14' ,
3914+ ' use_c14' => $nl_flags -> {' use_c14' }, ' use_c14_bombspike' => $nl_flags -> {' use_c14_bombspike' });
3915+ if ( &remove_leading_and_trailing_quotes( $nl -> get_value( " stream_meshfile_atm_c14" ) ) eq " none" ) {
3916+ $log -> fatal_error( " stream_meshfile_atm_c14 is set to 'none' which will only copy the first latitude to the globe" )
3917+ }
3918+
3919+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_first_atm_c14' ,
3920+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3921+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_year_last_atm_c14' ,
3922+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3923+ # Set align year, if first and last years are different
3924+ if ( $nl -> get_value(' stream_year_first_atm_c14' ) != $nl -> get_value(' stream_year_last_atm_c14' ) ) {
3925+ add_default($opts , $nl_flags -> {' inputdata_rootdir' }, $definition , $defaults , $nl , ' stream_model_year_align_atm_c14' ,
3926+ ' sim_year' => $nl_flags -> {' sim_year' }, ' sim_year_range' => $nl_flags -> {' sim_year_range' });
3927+ }
38743928}
38753929
38763930# -------------------------------------------------------------------------------
@@ -5958,6 +6012,27 @@ sub logical_to_fortran {
59586012
59596013# -------------------------------------------------------------------------------
59606014
6015+ sub add_logical_to_nl_flags {
6016+ # Add a logical setting to the $nl_flsgs hash, so can be used in attribute checking
6017+ # This is important to do to make sure that the attribute is matched exactly as
6018+ # either: .true. or .false.
6019+ # Also sets nl_flags to .false. when the namelist variable is NOT set
6020+ my ($nl_flags , $nl , $var ) = @_ ;
6021+
6022+ my $val = $nl -> get_value($var );
6023+ if ( defined ($val ) ) {
6024+ if ( &value_is_true($val )) {
6025+ $nl_flags -> {$var } = " .true." ;
6026+ } else {
6027+ $nl_flags -> {$var } = " .false." ;
6028+ }
6029+ } else {
6030+ $nl_flags -> {$var } = " .false." ;
6031+ }
6032+ }
6033+
6034+ # -------------------------------------------------------------------------------
6035+
59616036sub string_is_undef_or_empty {
59626037 # Return true if the given string is undefined or only spaces, false otherwise.
59636038 # A quoted empty string (' ' or " ") is treated as being empty.
0 commit comments