forked from NCAR/MPAS-Workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.csh
executable file
·101 lines (84 loc) · 3.79 KB
/
run.csh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/csh -f
####################################################################################################
# This script runs a pre-configured set of cylc suites via MPAS-Workflow. If the user has
# previously executed this script with the same "ArgRunConfig", and one or more of the scenarios is
# already running, then executing this script again will cause drive.csh to kill those running
# suites.
####################################################################################################
## Usage:
# source env/cheyenne.${YourShell}
# ./run.csh {{runConfig}}
## ArgRunConfig
# A YAML file describing the set of scenarios to run
# OPTIONS:
set ValidRunConfigs = ( \
test \
120km3dvar \
120km3denvar \
120kmEDA \
60kmEDA \
30km-60km3denvar \
RealTime \
IASI120km3denvar \
)
set ArgRunConfig = $1
if ("$ValidRunConfigs" =~ *"$ArgRunConfig"* && $ArgRunConfig != '') then
echo "$0 (INFO): Running the $ArgRunConfig set of scenarios"
else
echo "$0 (ERROR): invalid ArgRunConfig, $ArgRunConfig"
exit 1
endif
## stage
# Choose which stage of the workflow to run for all scenarios. It can be useful to run only the
# SetupWorkflow stage in order to check that all scripts run correctly or to re-initialize
# the MPAS-Worlfow config directories of all of the scenarios. The latter is useful when a simple
# update to the config directory will enable a workflow task to run, and avoids re-starting
# the one or more cylc suites. drive.csh automatically stops active scenario suites when the user
# executes this script script.
# OPTIONS: drive, SetupWorkflow
set stage = drive
###################################################################################################
# get the configuration (only developers should modify this)
###################################################################################################
# config tools
source config/config.csh
# defaults config
set baseConfig = runs/base.yaml
# this config
set runConfig = runs/${ArgRunConfig}.yaml
# setRun and setRestore are helper functions that pick out a configuration node
# under the "run" and "restore" keys of runConfig
setenv setRun "source $setConfig $baseConfig $runConfig run"
setenv setRestore "source $setConfig $baseConfig $runConfig restore"
# these values will be used during the run phase
# see runs/baseConfig.yaml for configuration documentation
$setRun scenarios
$setRun scenarioDirectory
###################################################################################################
# run the scenarios (only developers should modify this)
###################################################################################################
sed -i 's@^set\ scenarioDirectory\ =\ .*@set\ scenarioDirectory\ =\ '$scenarioDirectory'@' config/scenario.csh
foreach thisScenario ($scenarios)
if ($thisScenario == None) then
continue
endif
echo ""
echo ""
echo "##################################################################"
echo "${0}: Executing ${stage}.csh for the $thisScenario scenario"
sed -i 's@^set\ scenario\ =\ .*@set\ scenario\ =\ '$thisScenario'@' config/scenario.csh
./${stage}.csh
if ( $status != 0 ) then
echo "$0 (ERROR): error when setting up $thisScenario"
exit 1
endif
end
###################################################################################################
# restore settings (only developers should modify this)
###################################################################################################
## restore* settings
# these values are restored now that all suites are initialized
$setRestore scenarioDirectory
sed -i 's@^set\ scenarioDirectory\ =\ .*@set\ scenarioDirectory\ =\ '$scenarioDirectory'@' config/scenario.csh
$setRestore scenario
sed -i 's@^set\ scenario\ =\ .*@set\ scenario\ =\ '$scenario'@' config/scenario.csh