|
| 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