From d876d78cce5828ec5bba776476d91153ecb245b3 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 24 Oct 2023 23:45:39 -0600 Subject: [PATCH] Get test to work with valid scenario, remove the uneeded all and standard scenarios, and add error checking for resolution and scenario --- ...test_sys_gen_mksurfdata_jobscript_multi.py | 3 +- .../gen_mksurfdata_jobscript_multi.py | 38 +++++-------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/python/ctsm/test/test_sys_gen_mksurfdata_jobscript_multi.py b/python/ctsm/test/test_sys_gen_mksurfdata_jobscript_multi.py index 751ca23dd9..6245e2de86 100755 --- a/python/ctsm/test/test_sys_gen_mksurfdata_jobscript_multi.py +++ b/python/ctsm/test/test_sys_gen_mksurfdata_jobscript_multi.py @@ -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") @@ -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__": diff --git a/python/ctsm/toolchain/gen_mksurfdata_jobscript_multi.py b/python/ctsm/toolchain/gen_mksurfdata_jobscript_multi.py index 4226e73a04..59a07107a9 100755 --- a/python/ctsm/toolchain/gen_mksurfdata_jobscript_multi.py +++ b/python/ctsm/toolchain/gen_mksurfdata_jobscript_multi.py @@ -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", @@ -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 = [ @@ -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 = { @@ -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")