Skip to content

Commit 221502a

Browse files
committed
Move subset_data call to build phase and only run new shell_commands.
1 parent eaf6bb1 commit 221502a

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

cime_config/SystemTests/subsetdatapoint.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ def __init__(self, case):
3434
if "serial" not in self._case.get_value("MPILIB"):
3535
raise RuntimeError("SUBSETDATAPOINT tests require a serial MPILIB")
3636

37+
def build_phase(self, sharedlib_only=False, model_only=False):
38+
3739
# Where the output files will be saved
38-
self.out_dir = os.path.join(self._get_caseroot(), "subset_data_output")
39-
self.usermods_dir = os.path.join(self.out_dir, "user_mods")
40+
out_dir = os.path.join(self._get_caseroot(), "subset_data_output")
41+
usermods_dir = os.path.join(out_dir, "user_mods")
4042

4143
# Run the tool
42-
self.lat = 45.402252
43-
self.lon = -92.798085
44+
lat = 45.402252
45+
lon = -92.798085
4446
sys.argv = [
4547
"tools/site_and_regional/subset_data",
4648
"point",
4749
"--lat",
48-
str(self.lat),
50+
str(lat),
4951
"--lon",
50-
str(self.lon),
52+
str(lon),
5153
"--create-surface",
5254
"--create-datm",
5355
"--datm-syr",
@@ -56,16 +58,17 @@ def __init__(self, case):
5658
"2000",
5759
"--create-user-mods",
5860
"--outdir",
59-
self.out_dir,
61+
out_dir,
6062
"--user-mods-dir",
61-
self.usermods_dir,
63+
usermods_dir,
64+
"--overwrite",
6265
]
6366
subset_data()
6467

6568
# Append files in usermods_dir to equivalents in top level of case
66-
for file in os.listdir(self.usermods_dir):
69+
for file in os.listdir(usermods_dir):
6770
# Get the full path to source and destination files
68-
source_file_path = os.path.join(self.usermods_dir, file)
71+
source_file_path = os.path.join(usermods_dir, file)
6972
dest_file_path = os.path.join(self._get_caseroot(), file)
7073

7174
# Read the content of the source file
@@ -76,10 +79,9 @@ def __init__(self, case):
7679
with open(dest_file_path, "a", encoding="utf-8") as dest_file:
7780
dest_file.write("\n\n\n" + content_to_append)
7881

79-
80-
def build_phase(self, sharedlib_only=False, model_only=False):
81-
82-
# Run shell_commands
83-
subprocess.check_call("./shell_commands", shell=True)
82+
# Run the generated shell_commands
83+
if file == "shell_commands":
84+
cmd = f"chmod +x {source_file_path}; {source_file_path}"
85+
subprocess.check_call(cmd, shell=True)
8486

8587
super().build_phase(sharedlib_only, model_only)

0 commit comments

Comments
 (0)