Skip to content

Commit c1f57b1

Browse files
authored
Merge pull request #210 from TeaganKing/cupid_workflow_updates
Updates in template.cupid and config_workflow.xml for cupid workflow
2 parents bcb56e6 + c99f044 commit c1f57b1

File tree

2 files changed

+131
-52
lines changed

2 files changed

+131
-52
lines changed

machines/config_workflow.xml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,20 @@
4343
<dependency>case.run or case.test</dependency>
4444
<prereq>$DOUT_S</prereq>
4545
<runtime_parameters>
46-
<task_count>1</task_count>
47-
<tasks_per_node>1</tasks_per_node>
48-
<walltime>0:20:00</walltime>
46+
<task_count>1</task_count>
47+
<tasks_per_node>1</tasks_per_node>
48+
<walltime>0:20:00</walltime>
49+
</runtime_parameters>
50+
</job>
51+
<job name="case.cupid">
52+
<template>template.cupid</template>
53+
<hidden>false</hidden>
54+
<dependency>case.st_archive</dependency>
55+
<prereq>$RUN_POSTPROCESSING</prereq>
56+
<runtime_parameters MACH="derecho">
57+
<task_count>1</task_count>
58+
<tasks_per_node>1</tasks_per_node>
59+
<walltime>0:20:00</walltime>
4960
</runtime_parameters>
5061
</job>
5162
</workflow_jobs>
@@ -56,28 +67,14 @@
5667
<dependency>case.st_archive</dependency>
5768
<prereq>1</prereq>
5869
<runtime_parameters MACH="aleph">
59-
<task_count>200</task_count>
60-
<tasks_per_node>10</tasks_per_node>
61-
<walltime>12:00:00</walltime>
70+
<task_count>200</task_count>
71+
<tasks_per_node>10</tasks_per_node>
72+
<walltime>12:00:00</walltime>
6273
</runtime_parameters>
6374
<runtime_parameters MACH="cheyenne">
64-
<task_count>72</task_count>
65-
<tasks_per_node>9</tasks_per_node>
66-
<walltime>0:20:00</walltime>
67-
</runtime_parameters>
68-
</job>
69-
</workflow_jobs>
70-
71-
<workflow_jobs id="case.cupid" prepend="default">
72-
<job name="case.cupid">
73-
<template>template.cupid</template>
74-
<hidden>false</hidden>
75-
<dependency>case.st_archive</dependency>
76-
<prereq>1</prereq>
77-
<runtime_parameters MACH="derecho">
78-
<task_count>1</task_count>
79-
<tasks_per_node>1</tasks_per_node>
80-
<walltime>0:20:00</walltime>
75+
<task_count>72</task_count>
76+
<tasks_per_node>9</tasks_per_node>
77+
<walltime>0:20:00</walltime>
8178
</runtime_parameters>
8279
</job>
8380
</workflow_jobs>

machines/template.cupid

Lines changed: 111 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#!/bin/bash -e
22

3+
# Function to add some number of years to a string that
4+
# is formatted as YYYY-MM-DD and print out the updated
5+
# string in the same format
6+
add_years() {
7+
YEAR=`echo $1 | cut -d '-' -f 1`
8+
MM=`echo $1 | cut -d '-' -f 2`
9+
DD=`echo $1 | cut -d '-' -f 3`
10+
NEW_YEAR=`printf '%04d' "$((YEAR + $2))"`-`printf '%02d' "${MM}"`-`printf '%02d' "${DD}"`
11+
echo $NEW_YEAR
12+
}
13+
314
# Batch system directives
415
{{ batchdirectives }}
516

@@ -11,37 +22,108 @@ source .env_mach_specific.sh
1122
# by setting $PYTHONPATH; since this is conda-based we
1223
# want an empty PYTHONPATH environment variable
1324
MACH=`./xmlquery --value MACH`
14-
unset PYTHONPATH
15-
conda activate cupid-infrastructure
16-
17-
# Set variables that should eventually come from environment file
18-
CUPID_EXAMPLE=key_metrics
19-
RUN_CUPID_ANALYSIS=TRUE
20-
RUN_CUPID_TIMESERIES=TRUE
21-
22-
if [ "${RUN_CUPID_ANALYSIS}" == "TRUE" ]; then
23-
# 1. Generate CUPiD config file
24-
{{ srcroot }}/tools/CUPiD/helper_scripts/generate_cupid_config_for_cesm_case.py \
25-
--cesm-root {{ SRCROOT }}
26-
27-
# 2. Generate ADF config file
28-
{{ srcroot }}/tools/CUPiD/helper_scripts/generate_adf_config_file.py \
29-
--cesm-root {{ SRCROOT }} \
30-
--cupid-config-loc ${PWD} \
31-
--adf-template {{ SRCROOT }}/tools/CUPiD/externals/ADF/config_amwg_default_plots.yaml \
32-
--out-file adf_config.yml
33-
34-
# 3. Generate timeseries files and run ADF
35-
if [ "${RUN_CUPID_TIMESERIES}" == "TRUE" ]; then
36-
{{ srcroot }}/tools/CUPiD/cupid/run_timeseries.py
25+
26+
# Set variables that come from environment file
27+
CUPID_EXAMPLE=`./xmlquery --value CUPID_EXAMPLE`
28+
CUPID_GEN_TIMESERIES=`./xmlquery --value CUPID_GEN_TIMESERIES`
29+
CUPID_GEN_DIAGNOSTICS=`./xmlquery --value CUPID_GEN_DIAGNOSTICS`
30+
CUPID_GEN_HTML=`./xmlquery --value CUPID_GEN_HTML`
31+
CUPID_BASELINE_CASE=`./xmlquery --value CUPID_BASELINE_CASE`
32+
CUPID_BASELINE_ROOT=`./xmlquery --value CUPID_BASELINE_ROOT`
33+
CUPID_START_YEAR=`./xmlquery --value CUPID_START_YEAR`
34+
CUPID_NYEARS=`./xmlquery --value CUPID_NYEARS`
35+
CUPID_END_YEAR=`add_years $CUPID_START_YEAR $CUPID_NYEARS`
36+
CUPID_BASE_START_YEAR=`./xmlquery --value CUPID_BASE_START_YEAR`
37+
CUPID_BASE_NYEARS=`./xmlquery --value CUPID_BASE_NYEARS`
38+
CUPID_BASE_END_YEAR=`add_years $CUPID_BASE_START_YEAR $CUPID_BASE_NYEARS`
39+
CUPID_RUN_ALL=`./xmlquery --value CUPID_RUN_ALL`
40+
CUPID_RUN_ATM=`./xmlquery --value CUPID_RUN_ATM`
41+
CUPID_RUN_OCN=`./xmlquery --value CUPID_RUN_OCN`
42+
CUPID_RUN_LND=`./xmlquery --value CUPID_RUN_LND`
43+
CUPID_RUN_ICE=`./xmlquery --value CUPID_RUN_ICE`
44+
CUPID_RUN_ROF=`./xmlquery --value CUPID_RUN_ROF`
45+
CUPID_RUN_GLC=`./xmlquery --value CUPID_RUN_GLC`
46+
CUPID_RUN_ADF=`./xmlquery --value CUPID_RUN_ADF`
47+
CUPID_INFRASTRUCTURE_ENV=`./xmlquery --value CUPID_INFRASTRUCTURE_ENV`
48+
CUPID_ANALYSIS_ENV=`./xmlquery --value CUPID_ANALYSIS_ENV`
49+
50+
# Create directory for running CUPiD
51+
mkdir -p cupid-postprocessing
52+
cd cupid-postprocessing
53+
54+
# If CUPID_RUN_ALL is TRUE, we don't add any component flags.
55+
# The lack of any component flags tells CUPiD to run all components.
56+
CUPID_FLAG_STRING=""
57+
if [ "${CUPID_RUN_ALL}" == "FALSE" ]; then
58+
if [ "${CUPID_RUN_ATM}" == "TRUE" ]; then
59+
CUPID_FLAG_STRING+=" --atm"
60+
fi
61+
if [ "${CUPID_RUN_OCN}" == "TRUE" ]; then
62+
CUPID_FLAG_STRING+=" --ocn"
3763
fi
64+
if [ "${CUPID_RUN_LND}" == "TRUE" ]; then
65+
CUPID_FLAG_STRING+=" --lnd"
66+
fi
67+
if [ "${CUPID_RUN_ICE}" == "TRUE" ]; then
68+
CUPID_FLAG_STRING+=" --ice"
69+
fi
70+
if [ "${CUPID_RUN_ROF}" == "TRUE" ]; then
71+
CUPID_FLAG_STRING+=" --rof"
72+
fi
73+
if [ "${CUPID_RUN_GLC}" == "TRUE" ]; then
74+
CUPID_FLAG_STRING+=" --glc"
75+
fi
76+
if [ "${CUPID_FLAG_STRING}" == "" ]; then
77+
echo "If CUPID_RUN_ALL is False, user must set at least one component"
78+
exit 1
79+
fi
80+
fi
81+
if [ "${CUPID_RUN_ALL}" == "TRUE" ]; then
82+
echo "CUPID_RUN_ALL is True, running diagnostics for all components"
83+
fi
84+
85+
unset PYTHONPATH
86+
conda activate $CUPID_INFRASTRUCTURE_ENV
87+
88+
# 1. Generate CUPiD config file
89+
{{ SRCROOT }}/tools/CUPiD/helper_scripts/generate_cupid_config_for_cesm_case.py \
90+
--cesm-root {{ SRCROOT }} \
91+
--case-root {{ CASEROOT }} \
92+
--cupid-example $CUPID_EXAMPLE \
93+
--cupid-baseline-case $CUPID_BASELINE_CASE \
94+
--cupid-baseline-root $CUPID_BASELINE_ROOT \
95+
--cupid-start-year $CUPID_START_YEAR \
96+
--cupid-end-year $CUPID_END_YEAR \
97+
--cupid-base-start-year $CUPID_BASE_START_YEAR \
98+
--cupid-base-end-year $CUPID_BASE_END_YEAR \
99+
100+
# 2. Generate ADF config file
101+
if [ "${CUPID_RUN_ADF}" == "TRUE" ]; then
102+
{{ SRCROOT }}/tools/CUPiD/helper_scripts/generate_adf_config_file.py \
103+
--cesm-root {{ SRCROOT }} \
104+
--cupid-config-loc {{ SRCROOT }}/tools/CUPiD/examples/${CUPID_EXAMPLE} \
105+
--adf-template {{ SRCROOT }}/tools/CUPiD/externals/ADF/config_amwg_default_plots.yaml \
106+
--out-file adf_config.yml
107+
fi
108+
109+
# 3. Generate timeseries files
110+
if [ "${CUPID_GEN_TIMESERIES}" == "TRUE" ]; then
111+
{{ SRCROOT }}/tools/CUPiD/cupid/run_timeseries.py $CUPID_FLAG_STRING
112+
fi
113+
114+
#4. Run ADF
115+
if [ "${CUPID_RUN_ADF}" == "TRUE" ]; then
38116
conda deactivate
39-
conda activate cupid-analysis
117+
conda activate $CUPID_ANALYSIS_ENV
40118
{{ SRCROOT }}/tools/CUPiD/externals/ADF/run_adf_diag adf_config.yml
119+
fi
41120

42-
# 4. Run CUPiD and build webpage
43-
conda deactivate
44-
conda activate cupid-infrastructure
45-
{{ srcroot }}/tools/CUPiD/cupid/run_diagnostics.py
46-
{{ srcroot }}/tools/CUPiD/cupid/cupid_webpage.py
121+
# 5. Run CUPiD and build webpage
122+
conda deactivate
123+
conda activate $CUPID_INFRASTRUCTURE_ENV
124+
if [ "${CUPID_GEN_DIAGNOSTICS}" == "TRUE" ]; then
125+
{{ SRCROOT }}/tools/CUPiD/cupid/run_diagnostics.py $CUPID_FLAG_STRING
126+
fi
127+
if [ "${CUPID_GEN_HTML}" == "TRUE" ]; then
128+
{{ SRCROOT }}/tools/CUPiD/cupid/cupid_webpage.py
47129
fi

0 commit comments

Comments
 (0)