Skip to content

Commit

Permalink
Improve dependencies for some diagnostics
Browse files Browse the repository at this point in the history
1. ECOSYS_IFRAC, ECOSYS_XKW, and ECOSYS_ATMPRESS are only available if either
   lflux_gas_co2 or lflux_gas_o2 are true
2. PV_CO2 and SCHMIDT_CO2 are only available if lflux_gas_co2 is true

Adding [1] required adding a mechanism for specifying that only one of a set of
dependencies need to evaluate to true (the default behavior is that all
dependencies must evaluate to true).

I tested this by running with

base_bio_on = .false.
abio_dic_on = .true.
lflux_gas_co2 = .false.

And needed to add an if (lflux_gas_co2) block to
abio_dic_surface_flux_compute() to avoid seg faults.
  • Loading branch information
mnlevy1981 committed Oct 13, 2023
1 parent da59455 commit 70318b8
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 181 deletions.
20 changes: 14 additions & 6 deletions MARBL_tools/MARBL_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,19 @@ def meet_dependencies(input_dict, MARBL_settings):
import logging
logger = logging.getLogger(__name__)

dependencies_or = input_dict.get('dependencies_or', False)
if "dependencies" in input_dict.keys():
for dependency in input_dict["dependencies"].keys():
if dependency not in MARBL_settings.settings_dict.keys():
logger.error("'%s' is not a valid dependency" % dependency)
abort(1)
if input_dict["dependencies"][dependency] != MARBL_settings.settings_dict[dependency]['value']:
return False
if dependencies_or:
for dependency in input_dict["dependencies"].keys():
if dependency in MARBL_settings.settings_dict.keys():
if input_dict["dependencies"][dependency] == MARBL_settings.settings_dict[dependency]['value']:
return True
return False
else:
for dependency in input_dict["dependencies"].keys():
if dependency not in MARBL_settings.settings_dict.keys():
logger.error("'%s' is not a valid dependency" % dependency)
abort(1)
if input_dict["dependencies"][dependency] != MARBL_settings.settings_dict[dependency]['value']:
return False
return True
16 changes: 16 additions & 0 deletions defaults/diagnostics_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
####################

ECOSYS_IFRAC :
dependencies :
lflux_gas_o2 : .true.
lflux_gas_co2 : .true.
dependencies_or : true
longname : Ice Fraction
units : fraction
vertical_grid : none
Expand All @@ -32,6 +36,10 @@ ECOSYS_IFRAC :
- average
- average
ECOSYS_XKW :
dependencies :
lflux_gas_o2 : .true.
lflux_gas_co2 : .true.
dependencies_or : true
longname : XKW
units : cm/s
vertical_grid : none
Expand All @@ -42,18 +50,26 @@ ECOSYS_XKW :
- average
- average
ECOSYS_ATM_PRESS :
dependencies :
lflux_gas_o2 : .true.
lflux_gas_co2 : .true.
dependencies_or : true
longname : Atmospheric Pressure
units : atmospheres
vertical_grid : none
frequency : medium
operator : average
PV_CO2 :
dependencies :
lflux_gas_co2 : .true.
longname : CO2 Piston Velocity
units : cm/s
vertical_grid : none
frequency : never
operator : average
SCHMIDT_CO2 :
dependencies :
lflux_gas_co2 : .true.
longname : CO2 Schmidt Number for base biotic tracers fluxes
units : 1
vertical_grid : none
Expand Down
21 changes: 21 additions & 0 deletions defaults/json/diagnostics_latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1529,13 +1529,23 @@
"vertical_grid": "none"
},
"ECOSYS_ATM_PRESS": {
"dependencies": {
"lflux_gas_co2": ".true.",
"lflux_gas_o2": ".true."
},
"dependencies_or": true,
"frequency": "medium",
"longname": "Atmospheric Pressure",
"operator": "average",
"units": "atmospheres",
"vertical_grid": "none"
},
"ECOSYS_IFRAC": {
"dependencies": {
"lflux_gas_co2": ".true.",
"lflux_gas_o2": ".true."
},
"dependencies_or": true,
"frequency": [
"medium",
"high"
Expand All @@ -1549,6 +1559,11 @@
"vertical_grid": "none"
},
"ECOSYS_XKW": {
"dependencies": {
"lflux_gas_co2": ".true.",
"lflux_gas_o2": ".true."
},
"dependencies_or": true,
"frequency": [
"medium",
"high"
Expand Down Expand Up @@ -2137,6 +2152,9 @@
"vertical_grid": "layer_avg"
},
"PV_CO2": {
"dependencies": {
"lflux_gas_co2": ".true."
},
"frequency": "never",
"longname": "CO2 Piston Velocity",
"operator": "average",
Expand Down Expand Up @@ -2205,6 +2223,9 @@
"vertical_grid": "layer_avg"
},
"SCHMIDT_CO2": {
"dependencies": {
"lflux_gas_co2": ".true."
},
"frequency": "medium",
"longname": "CO2 Schmidt Number for base biotic tracers fluxes",
"operator": "average",
Expand Down
1 change: 0 additions & 1 deletion defaults/json/settings_cesm2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@
"lflux_gas_co2": {
"datatype": "logical",
"default_value": ".true.",
"dependencies": "base_bio_on",
"longname": "Control which portions of code are executed (useful for debugging)",
"subcategory": "3. config flags",
"units": "unitless"
Expand Down
1 change: 0 additions & 1 deletion defaults/json/settings_cesm2.1+cocco.json
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,6 @@
"lflux_gas_co2": {
"datatype": "logical",
"default_value": ".true.",
"dependencies": "base_bio_on",
"longname": "Control which portions of code are executed (useful for debugging)",
"subcategory": "3. config flags",
"units": "unitless"
Expand Down
1 change: 0 additions & 1 deletion defaults/json/settings_cesm2.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@
"lflux_gas_co2": {
"datatype": "logical",
"default_value": ".true.",
"dependencies": "base_bio_on",
"longname": "Control which portions of code are executed (useful for debugging)",
"subcategory": "3. config flags",
"units": "unitless"
Expand Down
1 change: 0 additions & 1 deletion defaults/json/settings_latest+4p2z.json
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,6 @@
"lflux_gas_co2": {
"datatype": "logical",
"default_value": ".true.",
"dependencies": "base_bio_on",
"longname": "Control which portions of code are executed (useful for debugging)",
"subcategory": "3. config flags",
"units": "unitless"
Expand Down
1 change: 0 additions & 1 deletion defaults/json/settings_latest+cocco.json
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,6 @@
"lflux_gas_co2": {
"datatype": "logical",
"default_value": ".true.",
"dependencies": "base_bio_on",
"longname": "Control which portions of code are executed (useful for debugging)",
"subcategory": "3. config flags",
"units": "unitless"
Expand Down
1 change: 0 additions & 1 deletion defaults/json/settings_latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,6 @@
"lflux_gas_co2": {
"datatype": "logical",
"default_value": ".true.",
"dependencies": "base_bio_on",
"longname": "Control which portions of code are executed (useful for debugging)",
"subcategory": "3. config flags",
"units": "unitless"
Expand Down
1 change: 0 additions & 1 deletion defaults/settings_cesm2.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ general_parms :
datatype : logical
default_value : .true.
lflux_gas_co2 :
dependencies : base_bio_on
longname : Control which portions of code are executed (useful for debugging)
subcategory : 3. config flags
units : unitless
Expand Down
1 change: 0 additions & 1 deletion defaults/settings_cesm2.1+cocco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ general_parms :
datatype : logical
default_value : .true.
lflux_gas_co2 :
dependencies : base_bio_on
longname : Control which portions of code are executed (useful for debugging)
subcategory : 3. config flags
units : unitless
Expand Down
1 change: 0 additions & 1 deletion defaults/settings_cesm2.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ general_parms :
datatype : logical
default_value : .true.
lflux_gas_co2 :
dependencies : base_bio_on
longname : Control which portions of code are executed (useful for debugging)
subcategory : 3. config flags
units : unitless
Expand Down
1 change: 0 additions & 1 deletion defaults/settings_latest+4p2z.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ general_parms :
datatype : logical
default_value : .true.
lflux_gas_co2 :
dependencies : base_bio_on
longname : Control which portions of code are executed (useful for debugging)
subcategory : 3. config flags
units : unitless
Expand Down
1 change: 0 additions & 1 deletion defaults/settings_latest+cocco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ general_parms :
datatype : logical
default_value : .true.
lflux_gas_co2 :
dependencies : base_bio_on
longname : Control which portions of code are executed (useful for debugging)
subcategory : 3. config flags
units : unitless
Expand Down
1 change: 0 additions & 1 deletion defaults/settings_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ general_parms :
datatype : logical
default_value : .true.
lflux_gas_co2 :
dependencies : base_bio_on
longname : Control which portions of code are executed (useful for debugging)
subcategory : 3. config flags
units : unitless
Expand Down
Loading

0 comments on commit 70318b8

Please sign in to comment.