Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add run_neon SystemTest #2345

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions cime_config/SystemTests/runneon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""
CTSM-specific test that uses the run_neon.py methods for setting up, building, and running a NEON
site
"""

import os
import sys
from CIME.SystemTests.system_tests_common import SystemTestsCommon

_CTSM_PYTHON = os.path.join(
os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, "python"
)
sys.path.insert(1, _CTSM_PYTHON)
import ctsm.site_and_regional.run_neon as rn # python: disable=wrong-import-position


class RUNNEON(SystemTestsCommon):
# pylint: disable=too-many-instance-attributes
"""
CTSM-specific test that uses the run_neon.py methods for setting up, building, and running a
NEON site
"""

def __init__(self, case):
# initialize an object interface to the SMS system test
SystemTestsCommon.__init__(self, case)

caseroot = self._case.get_value("CASEROOT")
argv = [
"run_neon",
"--neon-sites",
"ABBY",
"--output-root",
caseroot,
]

(
self._cesmroot,
site_list,
self._output_root,
self._run_type,
self._experiment,
self._prism,
self._overwrite,
self._run_length,
self._base_case_root,
run_from_postad,
self._setup_only,
self._no_batch,
self._rerun,
self._user_version,
available_list,
self._res,
self._compset,
) = rn.setup(description="", argv=argv)

if not available_list:
raise RuntimeError("available_list not defined")
self._neon_site = None
for neon_site in available_list:
if neon_site.name in site_list:
self._neon_site = neon_site
break
if self._neon_site is None:
raise RuntimeError(
f"available_list does not contain any member of site_list: {site_list}"
)

if run_from_postad:
self._neon_site.finidat = None

def build_phase(self, sharedlib_only=False, model_only=False):
"""
Builds the case
"""
if not model_only:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried with if sharedlib_only, if model_only, etc., as well as with no conditional here. I get the same build error no matter what.

self._base_case_root = self._neon_site.build_base_case(
self._cesmroot,
self._output_root,
self._res,
self._compset,
self._overwrite,
self._setup_only,
)

def run_phase(self):
"""
Runs the case
"""
self._neon_site.run_case(
self._base_case_root,
self._run_type,
self._prism,
self._run_length,
self._user_version,
self._overwrite,
self._setup_only,
self._no_batch,
self._rerun,
self._experiment,
)
10 changes: 10 additions & 0 deletions cime_config/config_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ This defines various CTSM-specific system tests
<HIST_N>$STOP_N</HIST_N>
</test>

<test NAME="RUNNEON">
<DESC>Test run_neon setup. Test options are (mostly?) ignored.</DESC>
<INFO_DBUG>1</INFO_DBUG>
<DOUT_S>FALSE</DOUT_S>
<CONTINUE_RUN>FALSE</CONTINUE_RUN>
<REST_OPTION>never</REST_OPTION>
<HIST_OPTION>$STOP_OPTION</HIST_OPTION>
<HIST_N>$STOP_N</HIST_N>
</test>

<test NAME="RXCROPMATURITY">
<DESC>Generate prescribed maturity requirements, then test with them</DESC>
<INFO_DBUG>1</INFO_DBUG>
Expand Down
2 changes: 1 addition & 1 deletion python/ctsm/run_sys_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def _check_py_env(test_attributes):
# pylint: disable=import-error disable

# Check requirements for FSURDATMODIFYCTSM, if needed
if any("FSURDATMODIFYCTSM" in t for t in test_attributes):
if any("FSURDATMODIFYCTSM" in t or "RUNNEON" in t for t in test_attributes):
try:
import ctsm.modify_input_files.modify_fsurdat
except ModuleNotFoundError as err:
Expand Down
54 changes: 51 additions & 3 deletions python/ctsm/site_and_regional/run_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,19 @@ def parse_neon_listing(listing_file, valid_neon_sites):
return available_list


def main(description):
def setup(description, argv=None):
"""
Determine valid neon sites. Make an output directory if it does not exist.
Loop through requested sites and run CTSM at that site.
"""
cesmroot = path_to_ctsm_root()
# Get the list of supported neon sites from usermods
valid_neon_sites = glob.glob(
os.path.join(cesmroot, "cime_config", "usermods_dirs", "NEON", "[!d]*")
)
valid_neon_sites = sorted([v.split("/")[-1] for v in valid_neon_sites])

if argv is None:
argv = sys.argv

(
site_list,
Expand All @@ -193,7 +195,7 @@ def main(description):
no_batch,
rerun,
user_version,
) = get_parser(sys.argv, description, valid_neon_sites)
) = get_parser(argv, description, valid_neon_sites)

if output_root:
logger.debug("output_root : %s", output_root)
Expand All @@ -212,6 +214,52 @@ def main(description):
compset = "IHist1PtClm51Bgc"
else:
compset = "I1PtClm51Bgc"
return (
cesmroot,
site_list,
output_root,
run_type,
experiment,
prism,
overwrite,
run_length,
base_case_root,
run_from_postad,
setup_only,
no_batch,
rerun,
user_version,
available_list,
res,
compset,
)


def main(description):
"""
After setting up, loop through requested sites and run CTSM there.
"""

# Set up
(
cesmroot,
site_list,
output_root,
run_type,
experiment,
prism,
overwrite,
run_length,
base_case_root,
run_from_postad,
setup_only,
no_batch,
rerun,
user_version,
available_list,
res,
compset,
) = setup(description)

# -- Looping over neon sites

Expand Down
Loading