Skip to content
Merged
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
43 changes: 20 additions & 23 deletions machines/config_workflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@
<dependency>case.run or case.test</dependency>
<prereq>$DOUT_S</prereq>
<runtime_parameters>
<task_count>1</task_count>
<tasks_per_node>1</tasks_per_node>
<walltime>0:20:00</walltime>
<task_count>1</task_count>
<tasks_per_node>1</tasks_per_node>
<walltime>0:20:00</walltime>
</runtime_parameters>
</job>
<job name="case.cupid">
<template>template.cupid</template>
<hidden>false</hidden>
<dependency>case.st_archive</dependency>
<prereq>$RUN_POSTPROCESSING</prereq>
<runtime_parameters MACH="derecho">
<task_count>1</task_count>
<tasks_per_node>1</tasks_per_node>
<walltime>0:20:00</walltime>
</runtime_parameters>
</job>
</workflow_jobs>
Expand All @@ -56,28 +67,14 @@
<dependency>case.st_archive</dependency>
<prereq>1</prereq>
<runtime_parameters MACH="aleph">
<task_count>200</task_count>
<tasks_per_node>10</tasks_per_node>
<walltime>12:00:00</walltime>
<task_count>200</task_count>
<tasks_per_node>10</tasks_per_node>
<walltime>12:00:00</walltime>
</runtime_parameters>
<runtime_parameters MACH="cheyenne">
<task_count>72</task_count>
<tasks_per_node>9</tasks_per_node>
<walltime>0:20:00</walltime>
</runtime_parameters>
</job>
</workflow_jobs>

<workflow_jobs id="case.cupid" prepend="default">
<job name="case.cupid">
<template>template.cupid</template>
<hidden>false</hidden>
<dependency>case.st_archive</dependency>
<prereq>1</prereq>
<runtime_parameters MACH="derecho">
<task_count>1</task_count>
<tasks_per_node>1</tasks_per_node>
<walltime>0:20:00</walltime>
<task_count>72</task_count>
<tasks_per_node>9</tasks_per_node>
<walltime>0:20:00</walltime>
</runtime_parameters>
</job>
</workflow_jobs>
Expand Down
140 changes: 111 additions & 29 deletions machines/template.cupid
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/bin/bash -e

# Function to add some number of years to a string that
# is formatted as YYYY-MM-DD and print out the updated
# string in the same format
add_years() {
YEAR=`echo $1 | cut -d '-' -f 1`
MM=`echo $1 | cut -d '-' -f 2`
DD=`echo $1 | cut -d '-' -f 3`
NEW_YEAR=`printf '%04d' "$((YEAR + $2))"`-`printf '%02d' "${MM}"`-`printf '%02d' "${DD}"`
echo $NEW_YEAR
}

# Batch system directives
{{ batchdirectives }}

Expand All @@ -11,37 +22,108 @@ source .env_mach_specific.sh
# by setting $PYTHONPATH; since this is conda-based we
# want an empty PYTHONPATH environment variable
MACH=`./xmlquery --value MACH`
unset PYTHONPATH
conda activate cupid-infrastructure

# Set variables that should eventually come from environment file
CUPID_EXAMPLE=key_metrics
RUN_CUPID_ANALYSIS=TRUE
RUN_CUPID_TIMESERIES=TRUE

if [ "${RUN_CUPID_ANALYSIS}" == "TRUE" ]; then
# 1. Generate CUPiD config file
{{ srcroot }}/tools/CUPiD/helper_scripts/generate_cupid_config_for_cesm_case.py \
--cesm-root {{ SRCROOT }}

# 2. Generate ADF config file
{{ srcroot }}/tools/CUPiD/helper_scripts/generate_adf_config_file.py \
--cesm-root {{ SRCROOT }} \
--cupid-config-loc ${PWD} \
--adf-template {{ SRCROOT }}/tools/CUPiD/externals/ADF/config_amwg_default_plots.yaml \
--out-file adf_config.yml

# 3. Generate timeseries files and run ADF
if [ "${RUN_CUPID_TIMESERIES}" == "TRUE" ]; then
{{ srcroot }}/tools/CUPiD/cupid/run_timeseries.py

# Set variables that come from environment file
CUPID_EXAMPLE=`./xmlquery --value CUPID_EXAMPLE`
CUPID_GEN_TIMESERIES=`./xmlquery --value CUPID_GEN_TIMESERIES`
CUPID_GEN_DIAGNOSTICS=`./xmlquery --value CUPID_GEN_DIAGNOSTICS`
CUPID_GEN_HTML=`./xmlquery --value CUPID_GEN_HTML`
CUPID_BASELINE_CASE=`./xmlquery --value CUPID_BASELINE_CASE`
CUPID_BASELINE_ROOT=`./xmlquery --value CUPID_BASELINE_ROOT`
CUPID_START_YEAR=`./xmlquery --value CUPID_START_YEAR`
CUPID_NYEARS=`./xmlquery --value CUPID_NYEARS`
CUPID_END_YEAR=`add_years $CUPID_START_YEAR $CUPID_NYEARS`
CUPID_BASE_START_YEAR=`./xmlquery --value CUPID_BASE_START_YEAR`
CUPID_BASE_NYEARS=`./xmlquery --value CUPID_BASE_NYEARS`
CUPID_BASE_END_YEAR=`add_years $CUPID_BASE_START_YEAR $CUPID_BASE_NYEARS`
CUPID_RUN_ALL=`./xmlquery --value CUPID_RUN_ALL`
CUPID_RUN_ATM=`./xmlquery --value CUPID_RUN_ATM`
CUPID_RUN_OCN=`./xmlquery --value CUPID_RUN_OCN`
CUPID_RUN_LND=`./xmlquery --value CUPID_RUN_LND`
CUPID_RUN_ICE=`./xmlquery --value CUPID_RUN_ICE`
CUPID_RUN_ROF=`./xmlquery --value CUPID_RUN_ROF`
CUPID_RUN_GLC=`./xmlquery --value CUPID_RUN_GLC`
CUPID_RUN_ADF=`./xmlquery --value CUPID_RUN_ADF`
CUPID_INFRASTRUCTURE_ENV=`./xmlquery --value CUPID_INFRASTRUCTURE_ENV`
CUPID_ANALYSIS_ENV=`./xmlquery --value CUPID_ANALYSIS_ENV`

# Create directory for running CUPiD
mkdir -p cupid-postprocessing
cd cupid-postprocessing

# If CUPID_RUN_ALL is TRUE, we don't add any component flags.
# The lack of any component flags tells CUPiD to run all components.
CUPID_FLAG_STRING=""
if [ "${CUPID_RUN_ALL}" == "FALSE" ]; then
if [ "${CUPID_RUN_ATM}" == "TRUE" ]; then
CUPID_FLAG_STRING+=" --atm"
fi
if [ "${CUPID_RUN_OCN}" == "TRUE" ]; then
CUPID_FLAG_STRING+=" --ocn"
fi
if [ "${CUPID_RUN_LND}" == "TRUE" ]; then
CUPID_FLAG_STRING+=" --lnd"
fi
if [ "${CUPID_RUN_ICE}" == "TRUE" ]; then
CUPID_FLAG_STRING+=" --ice"
fi
if [ "${CUPID_RUN_ROF}" == "TRUE" ]; then
CUPID_FLAG_STRING+=" --rof"
fi
if [ "${CUPID_RUN_GLC}" == "TRUE" ]; then
CUPID_FLAG_STRING+=" --glc"
fi
if [ "${CUPID_FLAG_STRING}" == "" ]; then
echo "If CUPID_RUN_ALL is False, user must set at least one component"
exit 1
fi
fi
if [ "${CUPID_RUN_ALL}" == "TRUE" ]; then
echo "CUPID_RUN_ALL is True, running diagnostics for all components"
fi

unset PYTHONPATH
conda activate $CUPID_INFRASTRUCTURE_ENV

# 1. Generate CUPiD config file
{{ SRCROOT }}/tools/CUPiD/helper_scripts/generate_cupid_config_for_cesm_case.py \
--cesm-root {{ SRCROOT }} \
--case-root {{ CASEROOT }} \
--cupid-example $CUPID_EXAMPLE \
--cupid-baseline-case $CUPID_BASELINE_CASE \
--cupid-baseline-root $CUPID_BASELINE_ROOT \
--cupid-start-year $CUPID_START_YEAR \
--cupid-end-year $CUPID_END_YEAR \
--cupid-base-start-year $CUPID_BASE_START_YEAR \
--cupid-base-end-year $CUPID_BASE_END_YEAR \

# 2. Generate ADF config file
if [ "${CUPID_RUN_ADF}" == "TRUE" ]; then
{{ SRCROOT }}/tools/CUPiD/helper_scripts/generate_adf_config_file.py \
--cesm-root {{ SRCROOT }} \
--cupid-config-loc {{ SRCROOT }}/tools/CUPiD/examples/${CUPID_EXAMPLE} \
--adf-template {{ SRCROOT }}/tools/CUPiD/externals/ADF/config_amwg_default_plots.yaml \
--out-file adf_config.yml
fi

# 3. Generate timeseries files
if [ "${CUPID_GEN_TIMESERIES}" == "TRUE" ]; then
{{ SRCROOT }}/tools/CUPiD/cupid/run_timeseries.py $CUPID_FLAG_STRING
fi

#4. Run ADF
if [ "${CUPID_RUN_ADF}" == "TRUE" ]; then
conda deactivate
conda activate cupid-analysis
conda activate $CUPID_ANALYSIS_ENV
{{ SRCROOT }}/tools/CUPiD/externals/ADF/run_adf_diag adf_config.yml
fi

# 4. Run CUPiD and build webpage
conda deactivate
conda activate cupid-infrastructure
{{ srcroot }}/tools/CUPiD/cupid/run_diagnostics.py
{{ srcroot }}/tools/CUPiD/cupid/cupid_webpage.py
# 5. Run CUPiD and build webpage
conda deactivate
conda activate $CUPID_INFRASTRUCTURE_ENV
if [ "${CUPID_GEN_DIAGNOSTICS}" == "TRUE" ]; then
{{ SRCROOT }}/tools/CUPiD/cupid/run_diagnostics.py $CUPID_FLAG_STRING
fi
if [ "${CUPID_GEN_HTML}" == "TRUE" ]; then
{{ SRCROOT }}/tools/CUPiD/cupid/cupid_webpage.py
fi