Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ran black in cime_config/MARBL_scripts/
Browse files Browse the repository at this point in the history
mnlevy1981 committed Jul 17, 2024
1 parent dbe3d4e commit c0c8d88
Showing 4 changed files with 688 additions and 376 deletions.
43 changes: 31 additions & 12 deletions cime_config/MARBL_scripts/MARBL_diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Interface to the marbl_diagnostics_class object
"""


class MARBL_diagnostics_for_MOM(object):
def __init__(self, MARBL_dir, caseroot, MARBL_settings):

@@ -15,9 +16,13 @@ def __init__(self, MARBL_dir, caseroot, MARBL_settings):
MARBL_args = dict()

# User can put default_values.json in SourceMods, otherwise use file provided by MARBL
MARBL_args["default_diagnostics_file"] = os.path.join(caseroot,"SourceMods","src.mom","diagnostics_latest.json")
MARBL_args["default_diagnostics_file"] = os.path.join(
caseroot, "SourceMods", "src.mom", "diagnostics_latest.json"
)
if not os.path.isfile(MARBL_args["default_diagnostics_file"]):
MARBL_args["default_diagnostics_file"] = os.path.join(MARBL_dir, "defaults", "json", "diagnostics_latest.json")
MARBL_args["default_diagnostics_file"] = os.path.join(
MARBL_dir, "defaults", "json", "diagnostics_latest.json"
)

MARBL_args["MARBL_settings"] = MARBL_settings._MARBL_settings

@@ -30,32 +35,46 @@ def __init__(self, MARBL_dir, caseroot, MARBL_settings):
sys.path.append(MARBL_dir)
# (ii) Here's where we import from either MARBL_tools or SourceMods
diagnostics_class_dir = os.path.join(caseroot, "SourceMods", "src.mom")
if not os.path.isfile(os.path.join(diagnostics_class_dir, "MARBL_diagnostics_file_class.py")):
if not os.path.isfile(
os.path.join(diagnostics_class_dir, "MARBL_diagnostics_file_class.py")
):
from MARBL_tools import MARBL_diagnostics_file_class
else:
import imp
import logging

logger = logging.getLogger(__name__)
logging.info('Importing MARBL_diagnostics_file_class.py from %s' % diagnostics_class_dir)
diagnostics_class_module = diagnostics_class_dir+'/MARBL_diagnostics_file_class.py'
logging.info(
"Importing MARBL_diagnostics_file_class.py from %s"
% diagnostics_class_dir
)
diagnostics_class_module = (
diagnostics_class_dir + "/MARBL_diagnostics_file_class.py"
)
if os.path.isfile(diagnostics_class_module):
MARBL_diagnostics_file_class = imp.load_source('MARBL_diagnostics_file_class', diagnostics_class_module)
MARBL_diagnostics_file_class = imp.load_source(
"MARBL_diagnostics_file_class", diagnostics_class_module
)
else:
logger.error('Can not find %s' % diagnostics_class_module)
logger.error("Can not find %s" % diagnostics_class_module)
sys.exit(1)

# Generate diagnostics object
self.MARBL_diagnostic_dict = MARBL_diagnostics_file_class.MARBL_diagnostics_class(**MARBL_args)
self.MARBL_diagnostic_dict = (
MARBL_diagnostics_file_class.MARBL_diagnostics_class(**MARBL_args)
)

################################################################################
# PUBLIC CLASS METHODS #
################################################################################

def write_diagnostics_file(self, diagnostics_file_out, diag_mode, append):
""" Add all MARBL diagnostics to file containing MOM diagnostics
Also create a list of diagnostics generated by MOM
"""Add all MARBL diagnostics to file containing MOM diagnostics
Also create a list of diagnostics generated by MOM
"""
diag_mode_loc = 'full' if diag_mode == 'test_suite' else diag_mode
diag_mode_loc = "full" if diag_mode == "test_suite" else diag_mode
from MARBL_tools import generate_diagnostics_file
generate_diagnostics_file(self.MARBL_diagnostic_dict, diagnostics_file_out, diag_mode_loc, append)

generate_diagnostics_file(
self.MARBL_diagnostic_dict, diagnostics_file_out, diag_mode_loc, append
)
Loading

0 comments on commit c0c8d88

Please sign in to comment.