Skip to content

Commit

Permalink
make prerun delete old output directories, otherwise ensemble.py won'…
Browse files Browse the repository at this point in the history
…t submit new jobs
  • Loading branch information
teopb committed Dec 14, 2023
1 parent 8df590c commit 2b9ad02
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions MPAS_true_failure_testing/pre_run_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import f90nml
import numpy as np
import copy
import shutil

def main(argv):

Expand Down Expand Up @@ -61,6 +62,13 @@ def main(argv):

# create empty directories for outputs
output_folder = test_output_dir + f"/{test_name}"

if os.path.exists(output_folder):
try:
shutil.rmtree(output_folder)
except OSError as e:
print("Error: %s - %s." % (e.filename, e.strerror))

os.mkdir(output_folder)
os.mkdir(output_folder + "/history_files")

Expand Down Expand Up @@ -93,9 +101,15 @@ def main(argv):

# create empty directories for outputs
output_folder = test_output_dir + f"/{var_name}_perturb_neg{order}"
if not os.path.exists(output_folder):
os.mkdir(output_folder)
os.mkdir(output_folder + "/history_files")

if os.path.exists(output_folder):
try:
shutil.rmtree(output_folder)
except OSError as e:
print("Error: %s - %s." % (e.filename, e.strerror))

os.mkdir(output_folder)
os.mkdir(output_folder + "/history_files")

# modify namelist params
mod_nml[namelist_preface][var_name] = default_var_value * (1 - 10.**order)
Expand All @@ -119,9 +133,15 @@ def main(argv):

# create empty directories for outputs
output_folder = test_output_dir + f"/{var_name}_perturb_{order}"
if not os.path.exists(output_folder):
os.mkdir(output_folder)
os.mkdir(output_folder + "/history_files")

if os.path.exists(output_folder):
try:
shutil.rmtree(output_folder)
except OSError as e:
print("Error: %s - %s." % (e.filename, e.strerror))

os.mkdir(output_folder)
os.mkdir(output_folder + "/history_files")

# modify namelist params
mod_nml[namelist_preface][var_name] = default_var_value * (1 + 10.**order)
Expand Down

0 comments on commit 2b9ad02

Please sign in to comment.