Skip to content

Commit

Permalink
Clean up config_keywords
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mnlevy1981 committed Mar 7, 2024
1 parent 13d30c6 commit 644cadc
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions MARBL_tools/MARBL_generate_settings_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')

Expand Down
10 changes: 6 additions & 4 deletions MARBL_tools/MARBL_settings_file_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions defaults/json/settings_cesm2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions defaults/json/settings_cesm2.1+cocco.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions defaults/json/settings_cesm2.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions defaults/json/settings_latest+4p2z.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions defaults/json/settings_latest+cocco.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions defaults/json/settings_latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions defaults/settings_cesm2.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions defaults/settings_cesm2.1+cocco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions defaults/settings_cesm2.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions defaults/settings_latest+4p2z.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions defaults/settings_latest+cocco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions defaults/settings_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 644cadc

Please sign in to comment.