-
Notifications
You must be signed in to change notification settings - Fork 344
Changes to enable easily turning on CUPiD diagnostics from your CTSM case #3689
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
base: master
Are you sure you want to change the base?
Changes from 28 commits
499c13f
a0f4094
22bcd8c
133475d
99ecd8e
9493442
3d368b6
b21026d
0ef3c92
675ce37
e870c10
5630cbd
e463fe7
baa6088
d8d1d4b
256a8d4
e6c38c2
76bb364
203a391
91e8267
8c5904d
714de30
c2b8893
04c3b25
d4e5826
d333a31
28fbcb8
a33dfea
b91b731
a06eb03
95acbfc
dc7043d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # QuickStart to Running Diagnostics of your Case with CUPiD (CESM Unified Postprocessing and Diagnostics) | ||
|
|
||
| [!NOTE] | ||
| Land Diagnostics Cheat Sheet is here: | ||
|
|
||
| This document has more details on more options and such | ||
|
|
||
| https://docs.google.com/document/d/1ziZWGgaj9FxgR6WRHyCAZnzIc6-4ezqfUDDpQv4MzUI/edit?tab=t.0 | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Point to this: |
||
|
|
||
| ## Initial setup steps to do first time | ||
|
|
||
| This step is something you need to do the first time you want to run CUPiD for a case. | ||
| And you only need to do it again if the CUPiD environment changes. | ||
|
|
||
| ``` shell | ||
| # Setup the conda environments | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, point to the CUPiD documentation |
||
| # TODO: Make this use py_env_create? | ||
| mamba env create --yes -f tools/cupid/environments/cupid-infrastructure.yml | ||
| mamba env create --yes -f tools/cupid/environments/cupid-analysis.yml | ||
| # Check that the environment is valid | ||
| conda activate cupid-infrastructure | ||
| which cupid-diagnostics | ||
| # Should return something like: | ||
| # $HOME/conda-envs/cupid-infrastructure/bin/cupid-diagnostics | ||
| # If it returns "Command not found." something is wrong with the environment | ||
|
|
||
|
|
||
| # Now make sure the conda environments can be used by Jupyter notebooks | ||
| conda activate cupid-analysis | ||
| python -m ipykernel install --user --name=cupid-analysis | ||
| conda activate cupid-infrastructure | ||
| python -m ipykernel install --user --name=cupid-infrastructure | ||
| ``` | ||
|
|
||
| ## Create your case using the CUPiD user-mod | ||
|
|
||
| This is similar to setting up any case, such as documented in the README and Quickstart guides. | ||
|
|
||
| ``` shell | ||
| ./create_newcase --case testIwCUPiD --res f09_t232 --compset I2000Clm60BgcCrop --user-mods-dirs clm-CUPiD | ||
| ``` | ||
|
|
||
| ## Run CUPID in your case | ||
|
|
||
| After st_archive has run do the following. With RUN_POSTPROCESSING set to TRUE this will happen | ||
| with each case submission automatically. But, if you want to run it separately... | ||
|
|
||
|
|
||
| ``` shell | ||
| ./case.submit --only-job case.cupid | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
| from CIME.test_status import * | ||
|
|
||
| CUPID_PHASE = "CUPID" | ||
|
|
||
| ALL_PHASES = [ | ||
| CREATE_NEWCASE_PHASE, | ||
| XML_PHASE, | ||
| SETUP_PHASE, | ||
| NAMELIST_PHASE, | ||
| SHAREDLIB_BUILD_PHASE, | ||
| MODEL_BUILD_PHASE, | ||
| SUBMIT_PHASE, | ||
| RUN_PHASE, | ||
| COMPARE_PHASE, | ||
| BASELINE_PHASE, | ||
| THROUGHPUT_PHASE, | ||
| MEMCOMP_PHASE, | ||
| MEMLEAK_PHASE, | ||
| STARCHIVE_PHASE, | ||
| CUPID_PHASE, | ||
| GENERATE_PHASE, | ||
| ] | ||
|
|
||
| # Extend the TestStatus class to include the CUPID phase and have CUPID phase within ALL_PHASES | ||
| class CTSMTestStatus(TestStatus): | ||
|
|
||
| def __init__(self, case): | ||
| super().__init__(case, ALL_PHASES) | ||
| self._test_status = CTSMTestStatus(test_dir=case.get_value("CASEROOT"), test_name=self.case.get_value("CASEBASEID") ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from CIME.SystemTests.sms import SMS | ||
| from ctsm_test_status import * | ||
|
|
||
|
|
||
| class SMSAR(SMS): | ||
| def setup_indv( | ||
| self, clean=False, test_mode=False, reset=False, keep=False, disable_git=False | ||
| ): | ||
| """ | ||
| Perform an individual setup | ||
| """ | ||
| super().setup_indv( | ||
| clean=clean, | ||
| test_mode=test_mode, | ||
| reset=reset, | ||
| keep=keep, | ||
| disable_git=disable_git, | ||
| ) | ||
| # Make sure the st_archiver is turned on, as CUPiD only runs after it runs | ||
| self._case.set_value("DOUT_S", True) | ||
|
|
||
| def run_indv( | ||
| self, | ||
| suffix="base", | ||
| st_archive=True, | ||
| cupid=True, | ||
| submit_resubmits=None, | ||
| keep_init_generated_files=False, | ||
| ): | ||
| """ | ||
| Perform an individual run. Raises an EXCEPTION on fail. | ||
|
|
||
| Just add the CUPiD phase after the standard run. | ||
| """ | ||
| super().run_indv( | ||
| suffix=suffix, | ||
| st_archive=st_archive, | ||
| submit_resubmits=submit_resubmits, | ||
| keep_init_generated_files=keep_init_generated_files, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| from CIME.SystemTests.sms import SMS | ||
| from ctsm_test_status import * | ||
|
|
||
|
|
||
| class SMSCUPID(SMS): | ||
| def __init__(self, case): | ||
| super().__init__(case) | ||
| self._test_status = CTSMTestStatus( | ||
| test_dir=self._case.get_value("CASEROOT"), | ||
| test_name=self._case.get_value("CASEBASEID"), | ||
| ) | ||
|
|
||
| def setup_indv( | ||
| self, clean=False, test_mode=False, reset=False, keep=False, disable_git=False | ||
| ): | ||
| """ | ||
| Perform an individual setup | ||
| """ | ||
| super().setup_indv( | ||
| clean=clean, | ||
| test_mode=test_mode, | ||
| reset=reset, | ||
| keep=keep, | ||
| disable_git=disable_git, | ||
| ) | ||
| # Make sure the st_archiver is turned on, as CUPiD only runs after it runs | ||
| self._case.set_value("DOUT_S", True) | ||
|
|
||
| def run_indv( | ||
| self, | ||
| suffix="base", | ||
| st_archive=True, | ||
| cupid=True, | ||
| submit_resubmits=None, | ||
| keep_init_generated_files=False, | ||
| ): | ||
| """ | ||
| Perform an individual run. Raises an EXCEPTION on fail. | ||
|
|
||
| Just add the CUPiD phase after the standard run. | ||
| """ | ||
| super().run_indv( | ||
| suffix=suffix, | ||
| st_archive=st_archive, | ||
| submit_resubmits=submit_resubmits, | ||
| keep_init_generated_files=keep_init_generated_files, | ||
| ) | ||
| self._phase_modifying_call(CUPID_PHASE, self._cupid_case_test) | ||
|
|
||
| def case_test_cupid(self, testdir="cupid_test"): | ||
| # create the run directory testdir | ||
| if os.path.exists(testdir): | ||
| logger.info("Removing existing test directory {}".format(testdir)) | ||
| shutil.rmtree(testdir) | ||
| # Check that the CUPid postprocessing directories and config file exist | ||
| cupid_dir = os.path.join(self._case.get_value("CASEROOT"), "cupid-postprocessing" ) | ||
| notebooks_dir = os.path.join(cupid_dir, "compute_notebooks") | ||
| data_dir = os.path.join(cupid_dir, "temp_data") | ||
| for dir in [cupid_dir, notebooks_dir, data_dir]: | ||
| expect( os.isdir(dir), | ||
| "CUPiD postprocessing directory {} does not exist".format(dir) ) | ||
| cupid_config = os.path.join(cupid_dir, "config.yml") | ||
| expect( os.isfile(cupid_config), | ||
| "CUPiD config file {} does not exist".format(cupid_config) ) | ||
| # TODO: Add more checks about more files that should exist | ||
|
|
||
|
|
||
| # TODO: Populate the testdir with data files, config files and notebooks from the cupid-postprocessing directory | ||
|
|
||
| # TODO: Save various files to the baseline directory to use for BASELINE comparison | ||
|
|
||
| return True | ||
|
|
||
| def _cupid_case_test(self): | ||
| # For the st_archiver this test is under the case object | ||
| # Here we create it in this object, but probably should be moved to under the case object in CIME | ||
| result = self.test_cupid() | ||
| with self._test_status: | ||
| if result: | ||
| self._test_status.set_status(CUPID_PHASE, TEST_PASS_STATUS) | ||
| else: | ||
| self._test_status.set_status(CUPID_PHASE, TEST_FAIL_STATUS) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../usermods_dirs/clm/CUPiD |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/bin/bash | ||
| ./xmlchange CUPID_ILAMB=TRUE | ||
| ./xmlchange CUPID_LND=FALSE | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../usermods_dirs/clm/CUPiD |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/bin/bash | ||
| ./xmlchange CUPID_LDF=TRUE | ||
| ./xmlchange CUPID_LND=FALSE | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../usermods_dirs/clm/CUPiD |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/bin/bash | ||
| ./xmlchange CUPID_ROF=TRUE | ||
| ./xmlchange CUPID_LND=FALSE | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| This usermod turns on running CUPiD to get plots and diagnostics as part of a case. It sets the most common settings | ||
| for a CTSM case. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../_includes/hist_2000-2005 |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's go through this and figure out which of these should be default settings for ALL CTSM standalone cases—i.e., not just in this usermod. (And also—which of these are already set correctly by default without us in CTSM needing to do anything.)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been looking at other repositories for other things, but I see this sort of thing in config_compsets.xml for several components. <entries>
<entry id="RUN_STARTDATE">
<values>
<value compset="1850_">0001-01-01</value>
</values>
</entry>So it looks like that's the sort of thing that can be done. The entry is defined elsewhere, but you can set the value according to the compset as above. I think in our case we want it to be in config_component.xml, so I'll check if it can be added there. If not we could add %CUPID as part of the CLM compset options. I don't think I like that, but it's probably something to discuss. We do have compsets that set a particular user-mod directory as part of their definition. And this would be doing that same thing here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/bin/bash | ||
| # Make sure DOUT_S is turned on, as CUPiD only runs after st_archive | ||
| ./xmlchange DOUT_S=TRUE | ||
|
|
||
| # Enable postprocessing which is what turns on running CUPiD for a case | ||
| ./xmlchange RUN_POSTPROCESSING=TRUE | ||
|
|
||
|
|
||
| LND_ROOT=`./xmlquery --value COMP_ROOT_DIR_LND` | ||
|
|
||
| CUPID_ROOT=`./xmlquery --value CUPID_ROOT` | ||
| # When I first tried this I thought I needed the following... | ||
| if [ -z "$CUPID_ROOT" ]; then | ||
| echo "CUPID settings aren't done yet" | ||
| exit 5 | ||
| fi | ||
|
|
||
| # For a test case, make sure DOUT_S is TRUE | ||
| # TODO: Add a proper SystemTest so this is handled correctly in the test | ||
| TEST=`./xmlquery --value TEST` | ||
| if [ "$TEST" == "TRUE" ]; then | ||
| ./xmlchange DOUT_S=TRUE --file env_test.xml | ||
| fi | ||
|
|
||
| # | ||
| # Set CUPiD parameters for what a CTSM case needs to do | ||
| # | ||
|
|
||
| # Set the standard CUPiD baseline case to compare to | ||
| ./xmlchange --force CUPID_BASELINE_CASE='$CASE' | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the base case I need to point to @wwieder base case. /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing/ctsm5.4.002_clm6_BGCcrop_crujra_4x5_HIST/lnd/hist make the clm6_0 physics in the ctsm5.,4.002 tag 4x5 case the base case
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the start and extent for the base case.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the case as a I2000 starting 2000-2004 |
||
| ./xmlchange --force CUPID_BASE_STARTDATE='$RUN_STARTDATE' | ||
| ./xmlchange --force CUPID_BASE_STOP_N='$STOP_N' | ||
| # TODO: Make sure STOP_OPTION is nyears | ||
ekluzek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ./xmlchange --force CUPID_BASE_STOP_OPTION='$STOP_OPTION' | ||
| # TODO: Have this set based on what CLM_BLDNML_OPTS has | ||
| ./xmlchange CUPID_RUN_TYPE=SP | ||
| ./xmlchange --force CUPID_STARTDATE='$RUN_STARTDATE' | ||
| ./xmlchange --force CUPID_STOP_N='$STOP_N' | ||
| ./xmlchange --force CUPID_STOP_OPTION='$STOP_OPTION' | ||
| # TODO: This should maybe be turned on as a smoke test, and to check for the appropriate files in testing | ||
| ./xmlchange CUPID_GEN_HTML=TRUE | ||
| # TODO: Test with running more tasks | ||
| ./xmlchange CUPID_NTASKS=1 | ||
| ./xmlchange CUPID_RUN_ADF=FALSE | ||
| ./xmlchange CUPID_RUN_ALL=FALSE | ||
| # Use the land_only example | ||
| ./xmlchange CUPID_EXAMPLE=land_only | ||
| # TODO: Get CUPiD working with LDF under CESM | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LND without either LDF or ILAMB won't work except with a ne30 case |
||
| ./xmlchange CUPID_RUN_LDF=FALSE | ||
| ./xmlchange CUPID_RUN_LND=TRUE | ||
| # TODO: Test if ROF can be run | ||
| ./xmlchange CUPID_RUN_ROF=TRUE | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
| # Setup for a IHist case to start in 2000 and run for 5 years | ||
| ./xmlchange RUN_STARTDATE=2000-01-01 | ||
| ./xmlchange STOP_OPTION=nyears | ||
| ./xmlchange STOP_N=5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we point to the documentation for running CUPiD via the CESM workflow rather than duplicating and ending up with outdated information?
I'm thinking it would also be good for me to put the land-specific 'cheat sheet' as a docs page for component-specific example of running a STANDALONE version