Skip to content

Commit

Permalink
Merge pull request #2406 from TeaganKing/plumber
Browse files Browse the repository at this point in the history
b4b-dev: Plumber2 Implementation
  • Loading branch information
ekluzek authored Jan 31, 2025
2 parents 6b49dc2 + 74b665b commit dff976f
Show file tree
Hide file tree
Showing 15 changed files with 542 additions and 254 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,18 @@ unit_test_build
/tools/site_and_regional/listing.csv
/tools/site_and_regional/????/
/tools/site_and_regional/????.ad/
/tools/site_and_regional/????.*.ad/
/tools/site_and_regional/????.postad/
/tools/site_and_regional/????.*.postad/
/tools/site_and_regional/????.transient/
/tools/site_and_regional/????.*.transient/
/tools/site_and_regional/??-???/
/tools/site_and_regional/??-???.ad/
/tools/site_and_regional/??-???.*.ad/
/tools/site_and_regional/??-???.postad/
/tools/site_and_regional/??-???.*.postad/
/tools/site_and_regional/??-???.transient/
/tools/site_and_regional/??-???.*.transient/
/tools/site_and_regional/archive/

# build output
Expand Down
4 changes: 2 additions & 2 deletions python/ctsm/crop_calendars/generate_gdds_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ def import_and_process_1yr(
clm_gdd_var = "GDDACCUM"
my_vars = [clm_gdd_var, "GDDHARV"]
patterns = [f"*h2.{this_year-1}-01*.nc", f"*h2.{this_year-1}-01*.nc.base"]
for p in patterns:
pattern = os.path.join(indir, p)
for pat in patterns:
pattern = os.path.join(indir, pat)
h2_files = glob.glob(pattern)
if h2_files:
break
Expand Down
7 changes: 2 additions & 5 deletions python/ctsm/site_and_regional/neon_site.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
This module contains the NeonSite class and class functions which are used in run_neon.py
This module contains the NeonSite class and class functions which extend the tower_site class for
things that are specific just for NEON sites.
"""

# Import libraries
Expand Down Expand Up @@ -59,7 +60,6 @@ def run_case(
base_case_root,
run_type,
prism,
run_length,
user_version,
tower_type=None,
user_mods_dirs=None,
Expand All @@ -80,8 +80,6 @@ def run_case(
transient, post_ad, or ad case, default transient
prism: bool, opt
if True, use PRISM precipitation, default False
run_length: str, opt
length of run, default '4Y'
user_version: str, opt
default 'latest'
overwrite: bool, opt
Expand All @@ -104,7 +102,6 @@ def run_case(
base_case_root,
run_type,
prism,
run_length,
user_version,
tower_type,
user_mods_dirs,
Expand Down
120 changes: 120 additions & 0 deletions python/ctsm/site_and_regional/plumber_site.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""
This module contains the Plumber2Site class and class functions that extend the tower_site class for
things that are specific just for PLUMBER2 sites.
"""

# Import libraries
import logging
import os
import sys

# Get the ctsm util tools and then the cime tools.
_CTSM_PYTHON = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "python"))
sys.path.insert(1, _CTSM_PYTHON)

# -- import local classes for this script
# pylint: disable=wrong-import-position
from ctsm.site_and_regional.tower_site import TowerSite

# pylint: disable=wrong-import-position, import-error, unused-import, wrong-import-order
from ctsm import add_cime_to_path
from ctsm.path_utils import path_to_ctsm_root

from CIME import build
from CIME.case import Case
from CIME.utils import safe_copy, expect, symlink_force

logger = logging.getLogger(__name__)


# pylint: disable=too-many-instance-attributes
class Plumber2Site(TowerSite):
"""
A class for encapsulating plumber sites.
"""

def build_base_case(
self,
cesmroot,
output_root,
res,
compset,
user_mods_dirs=None,
overwrite=False,
setup_only=False,
):
if user_mods_dirs is None:
user_mods_dirs = [
os.path.join(
self.cesmroot, "cime_config", "usermods_dirs", "clm", "PLUMBER2", self.name
)
]
case_path = super().build_base_case(cesmroot, output_root, res, compset, user_mods_dirs)

return case_path

# pylint: disable=too-many-statements
def run_case(
self,
base_case_root,
run_type,
prism,
user_version,
tower_type=None,
user_mods_dirs=None,
overwrite=False,
setup_only=False,
no_batch=False,
rerun=False,
experiment=False,
):
"""
Run case.
Args:
self
base_case_root: str, opt
file path of base case
run_type: str, opt
transient, post_ad, or ad case, default ad
(ad case is default because PLUMBER requires spinup)
prism: bool, opt
if True, use PRISM precipitation, default False
Note: only supported for NEON sites
user_version: str, opt
default 'latest'; this could be useful later
This is currently only implemented with neon (not plumber) sites
overwrite: bool, opt
default False
setup_only: bool, opt
default False; if True, set up but do not run case
no_batch: bool, opt
default False
rerun: bool, opt
default False
experiment: str, opt
name of experiment, default False
"""
user_mods_dirs = [
os.path.join(
self.cesmroot, "cime_config", "usermods_dirs", "clm", "PLUMBER2", self.name
)
]
tower_type = "PLUMBER"
super().run_case(
base_case_root,
run_type,
prism,
user_version,
tower_type,
user_mods_dirs,
overwrite,
setup_only,
no_batch,
rerun,
experiment,
)

def set_ref_case(self, case):
super().set_ref_case(case)
return True ### Check if super returns false, if this will still return True?
Loading

0 comments on commit dff976f

Please sign in to comment.