From 644cadc929825c9a33624f885b7d9602bcf29933 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Thu, 7 Mar 2024 11:35:55 -0700 Subject: [PATCH] Clean up config_keywords Use "BASE_BIO_ON == FALSE" instead of "EXCLUDE_BASE_BIO" and "ABIO_DIC_ON == TRUE" instead of "INCLUDE_ABIO_DIC". Note that, when appropriate, "BASE_BIO_ON == TRUE" and "ABIO_DIC_ON == FALSE" are available in _config_keywords so it will be easy to do things like change the default value of abio_dic_on to .true. Also cleaned up comments in _parse_args() for generating the settings file. --- MARBL_tools/MARBL_generate_settings_file.py | 4 ++-- MARBL_tools/MARBL_settings_file_class.py | 10 ++++++---- defaults/json/settings_cesm2.0.json | 4 ++-- defaults/json/settings_cesm2.1+cocco.json | 4 ++-- defaults/json/settings_cesm2.1.json | 4 ++-- defaults/json/settings_latest+4p2z.json | 4 ++-- defaults/json/settings_latest+cocco.json | 4 ++-- defaults/json/settings_latest.json | 4 ++-- defaults/settings_cesm2.0.yaml | 4 ++-- defaults/settings_cesm2.1+cocco.yaml | 4 ++-- defaults/settings_cesm2.1.yaml | 4 ++-- defaults/settings_latest+4p2z.yaml | 4 ++-- defaults/settings_latest+cocco.yaml | 4 ++-- defaults/settings_latest.yaml | 4 ++-- 14 files changed, 32 insertions(+), 30 deletions(-) diff --git a/MARBL_tools/MARBL_generate_settings_file.py b/MARBL_tools/MARBL_generate_settings_file.py index 3f3c75a1..bd07c747 100755 --- a/MARBL_tools/MARBL_generate_settings_file.py +++ b/MARBL_tools/MARBL_generate_settings_file.py @@ -81,11 +81,11 @@ def _parse_args(marbl_root): default='settings_file', choices = set(('settings_file', 'GCM')), help="Source of initial value for saved state vars that can come from GCM or settings file") - # Command line argument to specify resolution (default is None) + # Command line flag to turn off the base biotic tracers parser.add_argument('--disable-base-bio', action='store_false', dest='base_bio_on', help='Turn off base biotic tracer module (default is on)') - # Command line argument to specify resolution (default is None) + # Command line flag to turn on the abiotic DIC tracers parser.add_argument('--enable-abio-dic', action='store_true', dest='abio_dic_on', help='Turn on abiotic DIC tracer module (default is off)') diff --git a/MARBL_tools/MARBL_settings_file_class.py b/MARBL_tools/MARBL_settings_file_class.py index a094d77e..7a86e1b5 100644 --- a/MARBL_tools/MARBL_settings_file_class.py +++ b/MARBL_tools/MARBL_settings_file_class.py @@ -23,12 +23,14 @@ def __init__(self, default_settings_file, saved_state_vars_source="settings_file logger = logging.getLogger(__name__) + # Check argument types + if not (type(base_bio_on) == bool and type(abio_dic_on == bool)): + raise ValueError("base_bio_on and abio_dic_on must be type bool") + # 1. List of configuration keywords to match in JSON if default_default is a dictionary self._config_keyword = [] - if not base_bio_on: - self._config_keyword.append('EXCLUDE_BASE_BIO') - if abio_dic_on: - self._config_keyword.append('INCLUDE_ABIO_DIC') + self._config_keyword.append(f'BASE_BIO_ON == {str(base_bio_on).upper()}') + self._config_keyword.append(f'ABIO_DIC_ON == {str(abio_dic_on).upper()}') if grid != None: self._config_keyword.append('GRID == "%s"' % grid) self._config_keyword.append('SAVED_STATE_VARS_SOURCE == "%s"' % saved_state_vars_source) diff --git a/defaults/json/settings_cesm2.0.json b/defaults/json/settings_cesm2.0.json index 9d39e3cd..e2a51bf9 100644 --- a/defaults/json/settings_cesm2.0.json +++ b/defaults/json/settings_cesm2.0.json @@ -1520,7 +1520,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "INCLUDE_ABIO_DIC": ".true.", + "ABIO_DIC_ON == TRUE": ".true.", "default": ".false." }, "longname": "Control whether abiotic carbon tracer module is active", @@ -1531,7 +1531,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "EXCLUDE_BASE_BIO": ".false.", + "BASE_BIO_ON == FALSE": ".false.", "default": ".true." }, "longname": "Control whether the base ecosystem tracer module is active", diff --git a/defaults/json/settings_cesm2.1+cocco.json b/defaults/json/settings_cesm2.1+cocco.json index df897857..d1f627e7 100644 --- a/defaults/json/settings_cesm2.1+cocco.json +++ b/defaults/json/settings_cesm2.1+cocco.json @@ -1565,7 +1565,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "INCLUDE_ABIO_DIC": ".true.", + "ABIO_DIC_ON == TRUE": ".true.", "default": ".false." }, "longname": "Control whether abiotic carbon tracer module is active", @@ -1576,7 +1576,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "EXCLUDE_BASE_BIO": ".false.", + "BASE_BIO_ON == FALSE": ".false.", "default": ".true." }, "longname": "Control whether the base ecosystem tracer module is active", diff --git a/defaults/json/settings_cesm2.1.json b/defaults/json/settings_cesm2.1.json index fbafda63..4c8cbb93 100644 --- a/defaults/json/settings_cesm2.1.json +++ b/defaults/json/settings_cesm2.1.json @@ -1523,7 +1523,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "INCLUDE_ABIO_DIC": ".true.", + "ABIO_DIC_ON == TRUE": ".true.", "default": ".false." }, "longname": "Control whether abiotic carbon tracer module is active", @@ -1534,7 +1534,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "EXCLUDE_BASE_BIO": ".false.", + "BASE_BIO_ON == FALSE": ".false.", "default": ".true." }, "longname": "Control whether the base ecosystem tracer module is active", diff --git a/defaults/json/settings_latest+4p2z.json b/defaults/json/settings_latest+4p2z.json index f3b3b8fb..5ff2b46f 100644 --- a/defaults/json/settings_latest+4p2z.json +++ b/defaults/json/settings_latest+4p2z.json @@ -1618,7 +1618,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "INCLUDE_ABIO_DIC": ".true.", + "ABIO_DIC_ON == TRUE": ".true.", "default": ".false." }, "longname": "Control whether abiotic carbon tracer module is active", @@ -1629,7 +1629,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "EXCLUDE_BASE_BIO": ".false.", + "BASE_BIO_ON == FALSE": ".false.", "default": ".true." }, "longname": "Control whether the base ecosystem tracer module is active", diff --git a/defaults/json/settings_latest+cocco.json b/defaults/json/settings_latest+cocco.json index f13d58f1..67de0b33 100644 --- a/defaults/json/settings_latest+cocco.json +++ b/defaults/json/settings_latest+cocco.json @@ -1565,7 +1565,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "INCLUDE_ABIO_DIC": ".true.", + "ABIO_DIC_ON == TRUE": ".true.", "default": ".false." }, "longname": "Control whether abiotic carbon tracer module is active", @@ -1576,7 +1576,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "EXCLUDE_BASE_BIO": ".false.", + "BASE_BIO_ON == FALSE": ".false.", "default": ".true." }, "longname": "Control whether the base ecosystem tracer module is active", diff --git a/defaults/json/settings_latest.json b/defaults/json/settings_latest.json index 6f5fd1c2..36d5a57d 100644 --- a/defaults/json/settings_latest.json +++ b/defaults/json/settings_latest.json @@ -1529,7 +1529,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "INCLUDE_ABIO_DIC": ".true.", + "ABIO_DIC_ON == TRUE": ".true.", "default": ".false." }, "longname": "Control whether abiotic carbon tracer module is active", @@ -1540,7 +1540,7 @@ "_append_to_config_keywords": true, "datatype": "logical", "default_value": { - "EXCLUDE_BASE_BIO": ".false.", + "BASE_BIO_ON == FALSE": ".false.", "default": ".true." }, "longname": "Control whether the base ecosystem tracer module is active", diff --git a/defaults/settings_cesm2.0.yaml b/defaults/settings_cesm2.0.yaml index 7b610033..d33ac0b7 100644 --- a/defaults/settings_cesm2.0.yaml +++ b/defaults/settings_cesm2.0.yaml @@ -257,7 +257,7 @@ tracer_modules : datatype : logical default_value : default : .true. - EXCLUDE_BASE_BIO : .false. + BASE_BIO_ON == FALSE : .false. _append_to_config_keywords : true abio_dic_on : longname : Control whether abiotic carbon tracer module is active @@ -266,7 +266,7 @@ tracer_modules : datatype : logical default_value : default : .false. - INCLUDE_ABIO_DIC : .true. + ABIO_DIC_ON == TRUE : .true. _append_to_config_keywords : true ciso_on : longname : Control whether CISO tracer module is active diff --git a/defaults/settings_cesm2.1+cocco.yaml b/defaults/settings_cesm2.1+cocco.yaml index df8c1fe2..4d34a419 100644 --- a/defaults/settings_cesm2.1+cocco.yaml +++ b/defaults/settings_cesm2.1+cocco.yaml @@ -257,7 +257,7 @@ tracer_modules : datatype : logical default_value : default : .true. - EXCLUDE_BASE_BIO : .false. + BASE_BIO_ON == FALSE : .false. _append_to_config_keywords : true abio_dic_on : longname : Control whether abiotic carbon tracer module is active @@ -266,7 +266,7 @@ tracer_modules : datatype : logical default_value : default : .false. - INCLUDE_ABIO_DIC : .true. + ABIO_DIC_ON == TRUE : .true. _append_to_config_keywords : true ciso_on : longname : Control whether CISO tracer module is active diff --git a/defaults/settings_cesm2.1.yaml b/defaults/settings_cesm2.1.yaml index 4997bf08..1cc48809 100644 --- a/defaults/settings_cesm2.1.yaml +++ b/defaults/settings_cesm2.1.yaml @@ -257,7 +257,7 @@ tracer_modules : datatype : logical default_value : default : .true. - EXCLUDE_BASE_BIO : .false. + BASE_BIO_ON == FALSE : .false. _append_to_config_keywords : true abio_dic_on : longname : Control whether abiotic carbon tracer module is active @@ -266,7 +266,7 @@ tracer_modules : datatype : logical default_value : default : .false. - INCLUDE_ABIO_DIC : .true. + ABIO_DIC_ON == TRUE : .true. _append_to_config_keywords : true ciso_on : longname : Control whether CISO tracer module is active diff --git a/defaults/settings_latest+4p2z.yaml b/defaults/settings_latest+4p2z.yaml index 6ac8eb9a..dbe103fb 100644 --- a/defaults/settings_latest+4p2z.yaml +++ b/defaults/settings_latest+4p2z.yaml @@ -268,7 +268,7 @@ tracer_modules : datatype : logical default_value : default : .true. - EXCLUDE_BASE_BIO : .false. + BASE_BIO_ON == FALSE : .false. _append_to_config_keywords : true abio_dic_on : longname : Control whether abiotic carbon tracer module is active @@ -277,7 +277,7 @@ tracer_modules : datatype : logical default_value : default : .false. - INCLUDE_ABIO_DIC : .true. + ABIO_DIC_ON == TRUE : .true. _append_to_config_keywords : true ciso_on : longname : Control whether CISO tracer module is active diff --git a/defaults/settings_latest+cocco.yaml b/defaults/settings_latest+cocco.yaml index f43b3c9b..f1f61569 100644 --- a/defaults/settings_latest+cocco.yaml +++ b/defaults/settings_latest+cocco.yaml @@ -257,7 +257,7 @@ tracer_modules : datatype : logical default_value : default : .true. - EXCLUDE_BASE_BIO : .false. + BASE_BIO_ON == FALSE : .false. _append_to_config_keywords : true abio_dic_on : longname : Control whether abiotic carbon tracer module is active @@ -266,7 +266,7 @@ tracer_modules : datatype : logical default_value : default : .false. - INCLUDE_ABIO_DIC : .true. + ABIO_DIC_ON == TRUE : .true. _append_to_config_keywords : true ciso_on : longname : Control whether CISO tracer module is active diff --git a/defaults/settings_latest.yaml b/defaults/settings_latest.yaml index d9155443..e30b714f 100644 --- a/defaults/settings_latest.yaml +++ b/defaults/settings_latest.yaml @@ -257,7 +257,7 @@ tracer_modules : datatype : logical default_value : default : .true. - EXCLUDE_BASE_BIO : .false. + BASE_BIO_ON == FALSE : .false. _append_to_config_keywords : true abio_dic_on : longname : Control whether abiotic carbon tracer module is active @@ -266,7 +266,7 @@ tracer_modules : datatype : logical default_value : default : .false. - INCLUDE_ABIO_DIC : .true. + ABIO_DIC_ON == TRUE : .true. _append_to_config_keywords : true ciso_on : longname : Control whether CISO tracer module is active