Skip to content

Commit dff976f

Browse files
authored
Merge pull request #2406 from TeaganKing/plumber
b4b-dev: Plumber2 Implementation
2 parents 6b49dc2 + 74b665b commit dff976f

15 files changed

+542
-254
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,18 @@ unit_test_build
8989
/tools/site_and_regional/listing.csv
9090
/tools/site_and_regional/????/
9191
/tools/site_and_regional/????.ad/
92+
/tools/site_and_regional/????.*.ad/
9293
/tools/site_and_regional/????.postad/
94+
/tools/site_and_regional/????.*.postad/
9395
/tools/site_and_regional/????.transient/
96+
/tools/site_and_regional/????.*.transient/
97+
/tools/site_and_regional/??-???/
98+
/tools/site_and_regional/??-???.ad/
99+
/tools/site_and_regional/??-???.*.ad/
100+
/tools/site_and_regional/??-???.postad/
101+
/tools/site_and_regional/??-???.*.postad/
102+
/tools/site_and_regional/??-???.transient/
103+
/tools/site_and_regional/??-???.*.transient/
94104
/tools/site_and_regional/archive/
95105

96106
# build output

python/ctsm/crop_calendars/generate_gdds_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ def import_and_process_1yr(
553553
clm_gdd_var = "GDDACCUM"
554554
my_vars = [clm_gdd_var, "GDDHARV"]
555555
patterns = [f"*h2.{this_year-1}-01*.nc", f"*h2.{this_year-1}-01*.nc.base"]
556-
for p in patterns:
557-
pattern = os.path.join(indir, p)
556+
for pat in patterns:
557+
pattern = os.path.join(indir, pat)
558558
h2_files = glob.glob(pattern)
559559
if h2_files:
560560
break

python/ctsm/site_and_regional/neon_site.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
This module contains the NeonSite class and class functions which are used in run_neon.py
2+
This module contains the NeonSite class and class functions which extend the tower_site class for
3+
things that are specific just for NEON sites.
34
"""
45

56
# Import libraries
@@ -59,7 +60,6 @@ def run_case(
5960
base_case_root,
6061
run_type,
6162
prism,
62-
run_length,
6363
user_version,
6464
tower_type=None,
6565
user_mods_dirs=None,
@@ -80,8 +80,6 @@ def run_case(
8080
transient, post_ad, or ad case, default transient
8181
prism: bool, opt
8282
if True, use PRISM precipitation, default False
83-
run_length: str, opt
84-
length of run, default '4Y'
8583
user_version: str, opt
8684
default 'latest'
8785
overwrite: bool, opt
@@ -104,7 +102,6 @@ def run_case(
104102
base_case_root,
105103
run_type,
106104
prism,
107-
run_length,
108105
user_version,
109106
tower_type,
110107
user_mods_dirs,
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
"""
2+
This module contains the Plumber2Site class and class functions that extend the tower_site class for
3+
things that are specific just for PLUMBER2 sites.
4+
"""
5+
6+
# Import libraries
7+
import logging
8+
import os
9+
import sys
10+
11+
# Get the ctsm util tools and then the cime tools.
12+
_CTSM_PYTHON = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "python"))
13+
sys.path.insert(1, _CTSM_PYTHON)
14+
15+
# -- import local classes for this script
16+
# pylint: disable=wrong-import-position
17+
from ctsm.site_and_regional.tower_site import TowerSite
18+
19+
# pylint: disable=wrong-import-position, import-error, unused-import, wrong-import-order
20+
from ctsm import add_cime_to_path
21+
from ctsm.path_utils import path_to_ctsm_root
22+
23+
from CIME import build
24+
from CIME.case import Case
25+
from CIME.utils import safe_copy, expect, symlink_force
26+
27+
logger = logging.getLogger(__name__)
28+
29+
30+
# pylint: disable=too-many-instance-attributes
31+
class Plumber2Site(TowerSite):
32+
"""
33+
A class for encapsulating plumber sites.
34+
"""
35+
36+
def build_base_case(
37+
self,
38+
cesmroot,
39+
output_root,
40+
res,
41+
compset,
42+
user_mods_dirs=None,
43+
overwrite=False,
44+
setup_only=False,
45+
):
46+
if user_mods_dirs is None:
47+
user_mods_dirs = [
48+
os.path.join(
49+
self.cesmroot, "cime_config", "usermods_dirs", "clm", "PLUMBER2", self.name
50+
)
51+
]
52+
case_path = super().build_base_case(cesmroot, output_root, res, compset, user_mods_dirs)
53+
54+
return case_path
55+
56+
# pylint: disable=too-many-statements
57+
def run_case(
58+
self,
59+
base_case_root,
60+
run_type,
61+
prism,
62+
user_version,
63+
tower_type=None,
64+
user_mods_dirs=None,
65+
overwrite=False,
66+
setup_only=False,
67+
no_batch=False,
68+
rerun=False,
69+
experiment=False,
70+
):
71+
"""
72+
Run case.
73+
74+
Args:
75+
self
76+
base_case_root: str, opt
77+
file path of base case
78+
run_type: str, opt
79+
transient, post_ad, or ad case, default ad
80+
(ad case is default because PLUMBER requires spinup)
81+
prism: bool, opt
82+
if True, use PRISM precipitation, default False
83+
Note: only supported for NEON sites
84+
user_version: str, opt
85+
default 'latest'; this could be useful later
86+
This is currently only implemented with neon (not plumber) sites
87+
overwrite: bool, opt
88+
default False
89+
setup_only: bool, opt
90+
default False; if True, set up but do not run case
91+
no_batch: bool, opt
92+
default False
93+
rerun: bool, opt
94+
default False
95+
experiment: str, opt
96+
name of experiment, default False
97+
"""
98+
user_mods_dirs = [
99+
os.path.join(
100+
self.cesmroot, "cime_config", "usermods_dirs", "clm", "PLUMBER2", self.name
101+
)
102+
]
103+
tower_type = "PLUMBER"
104+
super().run_case(
105+
base_case_root,
106+
run_type,
107+
prism,
108+
user_version,
109+
tower_type,
110+
user_mods_dirs,
111+
overwrite,
112+
setup_only,
113+
no_batch,
114+
rerun,
115+
experiment,
116+
)
117+
118+
def set_ref_case(self, case):
119+
super().set_ref_case(case)
120+
return True ### Check if super returns false, if this will still return True?

0 commit comments

Comments
 (0)