From 6bef41f1d01f455b3986b4f39f1e9bb453446de9 Mon Sep 17 00:00:00 2001 From: "Michael Kavulich, Jr" Date: Thu, 16 Nov 2023 16:27:26 -0700 Subject: [PATCH] Add default value for SCM_ROOT. Had to move call to setup_logging() because for some reason calling logging prior to setup was messing up all the subsequent logging. --- scm/src/run_scm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scm/src/run_scm.py b/scm/src/run_scm.py index 0d04edd25..20cfbce6a 100755 --- a/scm/src/run_scm.py +++ b/scm/src/run_scm.py @@ -758,13 +758,16 @@ def main(): verbose, levels, npz_type, vert_coord_file, case_data_dir, n_itt_out, \ n_itt_diag, run_dir, bin_dir, timestep) = parse_arguments() + setup_logging(verbose) + global SCM_ROOT SCM_ROOT = os.getenv('SCM_ROOT') if SCM_ROOT is None: - message = 'The SCM_ROOT environment variable is not set. Please set the SCM_ROOT environment variable to the top-level path where the model was cloned.' - logging.critical(message) - raise Exception(message) - + # Note: os.path.dirname() is the platform-agnostic way to get a parent directory + SCM_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + message = f"The SCM_ROOT environment variable is not set. Using default value:\n{SCM_ROOT}" + logging.warning(message) + global SCM_BIN if bin_dir: SCM_BIN = bin_dir @@ -782,14 +785,11 @@ def main(): global EXECUTABLE EXECUTABLE = os.path.join(SCM_RUN, EXECUTABLE_NAME) - setup_logging(verbose) - # Debugger if use_gdb: gdb = find_gdb() else: gdb = None - if (file != None): logging.info('SCM-run: Using {} to loop through defined runs'.format(file)) try: