Skip to content

Commit

Permalink
Get test to work with valid scenario, remove the uneeded all and stan…
Browse files Browse the repository at this point in the history
…dard scenarios, and add error checking for resolution and scenario
  • Loading branch information
ekluzek committed Oct 25, 2023
1 parent 9cb21e8 commit d876d78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
3 changes: 1 addition & 2 deletions python/ctsm/test/test_sys_gen_mksurfdata_jobscript_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def createJS(self, nodes, tasks_per_node, scenario, option_list=[]):
scenario,
]
)
print(sys.argv)
main()
self.assertTrue(os.path.exists(self.outfile), "Output jobscript file should exist")

Expand All @@ -70,7 +69,7 @@ def test_simple_jobscript_multi(self):
Test that a standard simple namelist works
"""
# pylint: disable=no-self-use
self.createJS(nodes="4", tasks_per_node="12", scenario="standard")
self.createJS(nodes="4", tasks_per_node="12", scenario="crop-global-present")


if __name__ == "__main__":
Expand Down
38 changes: 10 additions & 28 deletions python/ctsm/toolchain/gen_mksurfdata_jobscript_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

from ctsm.path_utils import path_to_ctsm_root
from ctsm.toolchain.gen_mksurfdata_namelist import main as main_nml
from ctsm.utils import abort

valid_scenarios = [
"all",
"standard",
"global-present",
"global-present-low-res",
"global-present-nldas",
Expand Down Expand Up @@ -146,32 +145,7 @@ def main():
# Determine target list
# --------------------------
target_list = []
if scenario == "all":
target_list = (
[
"global-present",
"crop-global-present",
"crop-global-1850",
"crop-global-hist",
"crop-tropics-present",
"crop-global-SSP1-2.6",
"crop-global-SSP3-7.0",
"crop-global-SSP5-3.4",
"crop-global-SSP2-4.5",
"crop-global-SSP1-1.9",
"crop-global-SSP4-3.4",
"crop-global-SSP4-6.0",
"crop-global-SSP5-8.5",
],
)
elif scenario == "standard":
target_list = (
[
"global-present",
"global-present-nldas",
],
)
elif scenario == "crop":
if scenario == "crop":
target_list = ["crop-global-present", "crop-global-1850", "crop-global-hist"]
elif scenario == "crop-global-future":
target_list = [
Expand All @@ -191,6 +165,12 @@ def main():
target_list = [scenario]

# --------------------------
# Error checking
# --------------------------
for scenario_list in target_list:
if scenario_list not in valid_scenarios:
abort("Input scenario is NOT in valid_scenarios")
# --------------------------
# Determine resolution sets that are referenced in commands
# --------------------------
resolution_dict = {
Expand Down Expand Up @@ -375,6 +355,8 @@ def main():
runfile.write(f"{check} \n")
for target in target_list:
res_set = dataset_dict[target][1]
if res_set not in resolution_dict:
abort(f"Resolution is not in the resolution_dict: {res_set}")
for res in resolution_dict[res_set]:
namelist = f"{scenario}_{res}.namelist"
command = os.path.join(os.getcwd(), "gen_mksurfdata_namelist")
Expand Down

0 comments on commit d876d78

Please sign in to comment.