-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #397 from hollyhan/add_ismip6_run_testgroup
Add ismip6 run testgroup This PR adds a test group on running Antarctic simulations for the ISMIP6 2300 experimental protocol https://www.climate-cryosphere.org/wiki/index.php?title=ISMIP6-Projections2300-Antarctica. Each experiment is a step that is meant to be run manually. A user must specify input files and experiments to set up in the config file.
- Loading branch information
Showing
21 changed files
with
1,366 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,6 @@ | |
{%- endif %} | ||
|
||
source load_compass_env.sh | ||
{{ pre_run_commands }} | ||
compass run {{suite}} | ||
|
||
{{ post_run_commands }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from compass.landice.tests.ismip6_run.ismip6_ais_proj2300 import ( | ||
Ismip6AisProj2300, | ||
) | ||
from compass.testgroup import TestGroup | ||
|
||
|
||
class Ismip6Run(TestGroup): | ||
""" | ||
A test group for automated setup of a suite of standardized | ||
ISMIP6 simulations | ||
Attributes | ||
---------- | ||
""" | ||
def __init__(self, mpas_core): | ||
""" | ||
mpas_core : compass.landice.Landice | ||
the MPAS core that this test group belongs to | ||
""" | ||
super().__init__(mpas_core=mpas_core, name='ismip6_run') | ||
|
||
self.add_test_case(Ismip6AisProj2300(test_group=self)) |
82 changes: 82 additions & 0 deletions
82
compass/landice/tests/ismip6_run/ismip6_ais_proj2300/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
|
||
from compass.landice.tests.ismip6_run.ismip6_ais_proj2300.set_up_experiment import ( # noqa | ||
SetUpExperiment, | ||
) | ||
from compass.testcase import TestCase | ||
|
||
|
||
class Ismip6AisProj2300(TestCase): | ||
""" | ||
A test case for automated setup of a suite of standardized | ||
simulations for ISMIP6-Projections2300-Antarctica | ||
See: https://www.climate-cryosphere.org/wiki/index.php?title=ISMIP6-Projections2300-Antarctica) # noqa | ||
""" | ||
|
||
def __init__(self, test_group): | ||
""" | ||
Create the test case | ||
Parameters | ||
---------- | ||
test_group : compass.landice.tests.ismip6_run.Ismip6Run | ||
The test group that this test case belongs to | ||
""" | ||
name = 'ismip6_ais_proj2300' | ||
|
||
super().__init__(test_group=test_group, name=name, | ||
subdir=name) | ||
|
||
def configure(self): | ||
""" | ||
Set up the desired ISMIP6 AIS 2300 experiments. | ||
Read the list from the config of which experiments the | ||
user wants to set up. Call thee add_step method and add the | ||
experiment to steps_to_run. Those operations are typically done | ||
in the constructor, but they are done here so that the list to set up | ||
can be adjusted in the config, and the config is not available until | ||
this point. | ||
""" | ||
|
||
# user can specify any of: 'all', 'tier1', 'tier2', or a | ||
# comma-delimited list (or a single experiment) | ||
exp_list = self.config.get('ismip6_run_ais_2300', 'exp_list') | ||
if exp_list == "tier1": | ||
exp_list = ['hist', 'ctrlAE'] + \ | ||
[f'expAE{i:02}' for i in range(1, 7)] | ||
elif exp_list == "tier2": | ||
exp_list = [f'expAE{i:02}' for i in range(7, 15)] | ||
elif exp_list == "all": | ||
exp_list = ['hist', 'ctrlAE'] + \ | ||
[f'expAE{i:02}' for i in range(1, 15)] | ||
else: | ||
exp_list = exp_list.split(",") | ||
mesh_res = self.config.getint('ismip6_run_ais_2300', 'mesh_res') | ||
|
||
for exp in exp_list: | ||
if os.path.exists(os.path.join(self.work_dir, exp)): | ||
print(f"WARNING: {exp} path already exists; skipping. " | ||
"Please remove the directory " | ||
f"{os.path.join(self.work_dir, exp)} and execute " | ||
"'compass setup' again to set this experiment up.") | ||
else: | ||
exp_name = f'{exp}_{mesh_res:02}' | ||
self.add_step( | ||
SetUpExperiment(test_case=self, name=exp_name, | ||
subdir=exp_name, exp=exp)) | ||
# Do not add experiments to step to steps_to_run; | ||
# each experiment (step) should be run manually | ||
self.steps_to_run = [] | ||
|
||
def run(self): | ||
""" | ||
A dummy run method | ||
""" | ||
raise ValueError("ERROR: 'compass run' has no functionality at the " | ||
"test case level for this test. " | ||
"Please submit the job script in " | ||
"each experiment's subdirectory manually instead.") | ||
|
||
# no validate() method is needed |
Oops, something went wrong.