Skip to content

Commit

Permalink
generate_settings_file sets tracer module logicals
Browse files Browse the repository at this point in the history
Command line arguments for MARBL_generate_settings_file determine value of
base_bio_on and abio_dic_on: by default, base_bio_on=T but running
--exclude-base-bio sets it to F. Similarly, abio_dic_on=F but running
--include-abio-dic sets it to T.
  • Loading branch information
mnlevy1981 committed Mar 1, 2024
1 parent d5862c6 commit 584ca67
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 26 deletions.
16 changes: 15 additions & 1 deletion MARBL_tools/MARBL_generate_settings_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ 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)
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)
parser.add_argument('--enable-abio-dic', action='store_true', dest='abio_dic_on',
help='Turn on abiotic DIC tracer module (default is off)')

# Command line argument to specify resolution (default is None)
parser.add_argument('-g', '--grid', action='store', dest='grid',
help='Some default values are grid-dependent')
Expand Down Expand Up @@ -115,7 +123,13 @@ def _parse_args(marbl_root):
logging.basicConfig(format='%(levelname)s (%(funcName)s): %(message)s', level=logging.DEBUG)

from MARBL_tools import MARBL_settings_class
DefaultSettings = MARBL_settings_class(args.default_settings_file, args.saved_state_vars_source, args.grid, args.settings_file_in, args.unit_system)
DefaultSettings = MARBL_settings_class(args.default_settings_file,
args.saved_state_vars_source,
args.base_bio_on,
args.abio_dic_on,
args.grid,
args.settings_file_in,
args.unit_system)

# Write the settings file
generate_settings_file(DefaultSettings, args.settings_file_out)
8 changes: 7 additions & 1 deletion MARBL_tools/MARBL_settings_file_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class MARBL_settings_class(object):
# CONSTRUCTOR #
###############

def __init__(self, default_settings_file, saved_state_vars_source="settings_file", grid=None, input_file=None, unit_system='cgs'):
def __init__(self, default_settings_file, saved_state_vars_source="settings_file",
base_bio_on=True, abio_dic_on=False, grid=None, input_file=None,
unit_system='cgs'):
""" Class constructor: set up a dictionary of config keywords for when multiple
default values are provided, read the JSON file, and then populate
self.settings_dict and self.tracers_dict.
Expand All @@ -23,6 +25,10 @@ def __init__(self, default_settings_file, saved_state_vars_source="settings_file

# 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')
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
10 changes: 8 additions & 2 deletions defaults/json/settings_cesm2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1519,15 +1519,21 @@
"abio_dic_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".false.",
"default_value": {
"INCLUDE_ABIO_DIC": ".true.",
"default": ".false."
},
"longname": "Control whether abiotic carbon tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
},
"base_bio_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".true.",
"default_value": {
"EXCLUDE_BASE_BIO": ".false.",
"default": ".true."
},
"longname": "Control whether the base ecosystem tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
Expand Down
10 changes: 8 additions & 2 deletions defaults/json/settings_cesm2.1+cocco.json
Original file line number Diff line number Diff line change
Expand Up @@ -1564,15 +1564,21 @@
"abio_dic_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".false.",
"default_value": {
"INCLUDE_ABIO_DIC": ".true.",
"default": ".false."
},
"longname": "Control whether abiotic carbon tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
},
"base_bio_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".true.",
"default_value": {
"EXCLUDE_BASE_BIO": ".false.",
"default": ".true."
},
"longname": "Control whether the base ecosystem tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
Expand Down
10 changes: 8 additions & 2 deletions defaults/json/settings_cesm2.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1522,15 +1522,21 @@
"abio_dic_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".false.",
"default_value": {
"INCLUDE_ABIO_DIC": ".true.",
"default": ".false."
},
"longname": "Control whether abiotic carbon tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
},
"base_bio_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".true.",
"default_value": {
"EXCLUDE_BASE_BIO": ".false.",
"default": ".true."
},
"longname": "Control whether the base ecosystem tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
Expand Down
10 changes: 8 additions & 2 deletions defaults/json/settings_latest+4p2z.json
Original file line number Diff line number Diff line change
Expand Up @@ -1617,15 +1617,21 @@
"abio_dic_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".false.",
"default_value": {
"INCLUDE_ABIO_DIC": ".true.",
"default": ".false."
},
"longname": "Control whether abiotic carbon tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
},
"base_bio_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".true.",
"default_value": {
"EXCLUDE_BASE_BIO": ".false.",
"default": ".true."
},
"longname": "Control whether the base ecosystem tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
Expand Down
10 changes: 8 additions & 2 deletions defaults/json/settings_latest+cocco.json
Original file line number Diff line number Diff line change
Expand Up @@ -1564,15 +1564,21 @@
"abio_dic_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".false.",
"default_value": {
"INCLUDE_ABIO_DIC": ".true.",
"default": ".false."
},
"longname": "Control whether abiotic carbon tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
},
"base_bio_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".true.",
"default_value": {
"EXCLUDE_BASE_BIO": ".false.",
"default": ".true."
},
"longname": "Control whether the base ecosystem tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
Expand Down
10 changes: 8 additions & 2 deletions defaults/json/settings_latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,15 +1528,21 @@
"abio_dic_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".false.",
"default_value": {
"INCLUDE_ABIO_DIC": ".true.",
"default": ".false."
},
"longname": "Control whether abiotic carbon tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
},
"base_bio_on": {
"_append_to_config_keywords": true,
"datatype": "logical",
"default_value": ".true.",
"default_value": {
"EXCLUDE_BASE_BIO": ".false.",
"default": ".true."
},
"longname": "Control whether the base ecosystem tracer module is active",
"subcategory": "1. tracer modules",
"units": "unitless"
Expand Down
8 changes: 6 additions & 2 deletions defaults/settings_cesm2.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ tracer_modules :
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .true.
default_value :
default : .true.
EXCLUDE_BASE_BIO : .false.
_append_to_config_keywords : true
abio_dic_on :
longname : Control whether abiotic carbon tracer module is active
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .false.
default_value :
default : .false.
INCLUDE_ABIO_DIC : .true.
_append_to_config_keywords : true
ciso_on :
longname : Control whether CISO tracer module is active
Expand Down
8 changes: 6 additions & 2 deletions defaults/settings_cesm2.1+cocco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ tracer_modules :
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .true.
default_value :
default : .true.
EXCLUDE_BASE_BIO : .false.
_append_to_config_keywords : true
abio_dic_on :
longname : Control whether abiotic carbon tracer module is active
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .false.
default_value :
default : .false.
INCLUDE_ABIO_DIC : .true.
_append_to_config_keywords : true
ciso_on :
longname : Control whether CISO tracer module is active
Expand Down
8 changes: 6 additions & 2 deletions defaults/settings_cesm2.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ tracer_modules :
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .true.
default_value :
default : .true.
EXCLUDE_BASE_BIO : .false.
_append_to_config_keywords : true
abio_dic_on :
longname : Control whether abiotic carbon tracer module is active
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .false.
default_value :
default : .false.
INCLUDE_ABIO_DIC : .true.
_append_to_config_keywords : true
ciso_on :
longname : Control whether CISO tracer module is active
Expand Down
8 changes: 6 additions & 2 deletions defaults/settings_latest+4p2z.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,18 @@ tracer_modules :
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .true.
default_value :
default : .true.
EXCLUDE_BASE_BIO : .false.
_append_to_config_keywords : true
abio_dic_on :
longname : Control whether abiotic carbon tracer module is active
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .false.
default_value :
default : .false.
INCLUDE_ABIO_DIC : .true.
_append_to_config_keywords : true
ciso_on :
longname : Control whether CISO tracer module is active
Expand Down
8 changes: 6 additions & 2 deletions defaults/settings_latest+cocco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ tracer_modules :
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .true.
default_value :
default : .true.
EXCLUDE_BASE_BIO : .false.
_append_to_config_keywords : true
abio_dic_on :
longname : Control whether abiotic carbon tracer module is active
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .false.
default_value :
default : .false.
INCLUDE_ABIO_DIC : .true.
_append_to_config_keywords : true
ciso_on :
longname : Control whether CISO tracer module is active
Expand Down
8 changes: 6 additions & 2 deletions defaults/settings_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ tracer_modules :
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .true.
default_value :
default : .true.
EXCLUDE_BASE_BIO : .false.
_append_to_config_keywords : true
abio_dic_on :
longname : Control whether abiotic carbon tracer module is active
subcategory : 1. tracer modules
units : unitless
datatype : logical
default_value : .false.
default_value :
default : .false.
INCLUDE_ABIO_DIC : .true.
_append_to_config_keywords : true
ciso_on :
longname : Control whether CISO tracer module is active
Expand Down

0 comments on commit 584ca67

Please sign in to comment.