forked from NCAR/MPAS-Workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drive.csh
executable file
·269 lines (220 loc) · 9.73 KB
/
drive.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/csh
####################################################################################################
# This script runs a pre-configure cylc suite scenario described in config/scenario.csh. If the user
# has previously executed this script with the same effecitve "SuiteName" the scenario is
# already running, then executing this script will automatically kill those running suites.
####################################################################################################
echo "$0 (INFO): generating a new cylc suite"
date
echo "$0 (INFO): Initializing the MPAS-Workflow experiment directory"
# Create the experiment directory and cylc task scripts
source SetupWorkflow.csh
## Change to the cylc suite directory
cd ${mainScriptDir}
echo "$0 (INFO): loading the workflow-relevant parts of the configuration"
# cross-application settings
source config/experiment.csh
source config/job.csh
source config/model.csh
source config/observations.csh
source config/workflow.csh
# application-specific settings, including resource requests
source config/applications/ensvariational.csh
source config/applications/forecast.csh
source config/applications/hofx.csh
source config/applications/initic.csh
source config/applications/rtpp.csh
source config/applications/variational.csh
source config/applications/verifyobs.csh
source config/applications/verifymodel.csh
echo "$0 (INFO): ExperimentName = ${ExperimentName}"
echo "$0 (INFO): setting up the environment"
module purge
module load cylc
module load graphviz
date
## SuiteName: name of the cylc suite, can be used to differentiate between two
# suites running simultaneously in the same ${ExperimentName} directory
#
# default: ${ExperimentName}
# example: ${ExperimentName}_verify for a simultaneous suite running only Verification
set SuiteName = ${ExperimentName}
# Differentiate between creating the workflow suite for the first time
# and restarting (i.e., when initialCyclePoint > firstCyclePoint)
if ($initialCyclePoint == $firstCyclePoint) then
# The analysis will run every CyclingWindowHR hours, starting CyclingWindowHR hours after the
# initialCyclePoint
set AnalysisTimes = +PT${CyclingWindowHR}H/PT${CyclingWindowHR}H
# The forecast will run every CyclingWindowHR hours, starting CyclingWindowHR+DA2FCOffsetHR hours
# after the initialCyclePoint
@ ColdFCOffset = ${CyclingWindowHR} + ${DA2FCOffsetHR}
set ForecastTimes = +PT${ColdFCOffset}H/PT${CyclingWindowHR}H
else
# The analysis will run every CyclingWindowHR hours, starting at the initialCyclePoint
set AnalysisTimes = PT${CyclingWindowHR}H
# The forecast will run every CyclingWindowHR hours, starting DA2FCOffsetHR hours after the
# initialCyclePoint
set ForecastTimes = +PT${DA2FCOffsetHR}H/PT${CyclingWindowHR}H
endif
set cylcWorkDir = /glade/scratch/${USER}/cylc-run
mkdir -p ${cylcWorkDir}
echo "$0 (INFO): Generating the suite.rc file"
cat >! suite.rc << EOF
#!Jinja2
## Import relevant environment variables as Jinja2 variables
# main suite directory
{% set mainScriptDir = "${mainScriptDir}" %}
# cycling dates-time information
{% set firstCyclePoint = "${firstCyclePoint}" %}
{% set initialCyclePoint = "${initialCyclePoint}" %}
{% set finalCyclePoint = "${finalCyclePoint}" %}
{% set AnalysisTimes = "${AnalysisTimes}" %}
{% set ForecastTimes = "${ForecastTimes}" %}
{% set DA2FCOffsetHR = "${DA2FCOffsetHR}" %}
{% set FC2DAOffsetHR = "${FC2DAOffsetHR}" %}
{% set ExtendedMeanFCTimes = "${ExtendedMeanFCTimes}" %}
{% set ExtendedEnsFCTimes = "${ExtendedEnsFCTimes}" %}
{% set ExtendedFCWindowHR = ${ExtendedFCWindowHR} %} #integer
{% set ExtendedFC_DT_HR = ${ExtendedFC_DT_HR} %} #integer
# initialization type
{% set InitializationType = "${InitializationType}" %}
{% set observationsResource = "${observations__resource}" %}
{% set modelAnalysisSource = "${model__AnalysisSource}" %}
# members
{% set nMembers = ${nMembers} %} #integer
{% set allMembers = range(1, nMembers+1, 1) %}
# variational
{% set EDASize = ${EDASize} %} #integer
{% set nDAInstances = ${nDAInstances} %} #integer
{% set DAInstances = range(1, nDAInstances+1, 1) %}
# inflation
{% set RTPPRelaxationFactor = ${rtpp__relaxationFactor} %}
{% set ABEInflation = ${ABEInflation} %}
# common job controls
{% set CPQueueName = "${CPQueueName}" %}
{% set CPAccountNumber = "${CPAccountNumber}" %}
{% set NCPQueueName = "${NCPQueueName}" %}
{% set NCPAccountNumber = "${NCPAccountNumber}" %}
{% set SingleProcQueueName = "${SingleProcQueueName}" %}
{% set SingleProcAccountNumber = "${SingleProcAccountNumber}" %}
{% set EnsMeanBGQueueName = "${EnsMeanBGQueueName}" %}
{% set EnsMeanBGAccountNumber = "${EnsMeanBGAccountNumber}" %}
{% set InitializationRetry = "${InitializationRetry}" %}
{% set GFSAnalysisRetry = "${GFSAnalysisRetry}" %}
{% set GetObsRetry = "${GetObsRetry}" %}
{% set VariationalRetry = "${VariationalRetry}" %}
{% set EnsOfVariationalRetry = "${EnsOfVariationalRetry}" %}
{% set CyclingFCRetry = "${CyclingFCRetry}" %}
{% set RTPPRetry = "${RTPPRetry}" %}
{% set HofXRetry = "${HofXRetry}" %}
{% set CleanRetry = "${CleanRetry}" %}
{% set VerifyObsRetry = "${VerifyObsRetry}" %}
{% set VerifyModelRetry = "${VerifyModelRetry}" %}
# mesh-specific job controls
{% set CyclingFCSeconds = "${forecast__seconds}" %}
{% set CyclingFCNodes = "${forecast__nodes}" %}
{% set CyclingFCPEPerNode = "${forecast__PEPerNode}" %}
{% set RTPPSeconds = "${rtpp__seconds}" %}
{% set RTPPNodes = "${rtpp__nodes}" %}
{% set RTPPPEPerNode = "${rtpp__PEPerNode}" %}
{% set RTPPMemory = "${rtpp__memory}" %}
{% set EnsOfVariationalSeconds = "${ensvariational__seconds}" %}
{% set EnsOfVariationalNodes = "${ensvariational__nodes}" %}
{% set EnsOfVariationalPEPerNode = "${ensvariational__PEPerNode}" %}
{% set EnsOfVariationalMemory = "${ensvariational__memory}" %}
{% set ExtendedFCSeconds = "${extendedforecast__seconds}" %}
{% set ExtendedFCNodes = "${forecast__nodes}" %}
{% set ExtendedFCPEPerNode = "${forecast__PEPerNode}" %}
{% set HofXSeconds = "${hofx__seconds}" %}
{% set HofXNodes = "${hofx__nodes}" %}
{% set HofXPEPerNode = "${hofx__PEPerNode}" %}
{% set HofXMemory = "${hofx__memory}" %}
{% set InitICSeconds = "${initic__seconds}" %}
{% set InitICNodes = "${initic__nodes}" %}
{% set InitICPEPerNode = "${initic__PEPerNode}" %}
{% set VariationalSeconds = "${variational__seconds}" %}
{% set VariationalNodes = "${variational__nodes}" %}
{% set VariationalPEPerNode = "${variational__PEPerNode}" %}
{% set VariationalMemory = "${variational__memory}" %}
{% set VerifyModelSeconds = "${verifymodel__seconds}" %}
{% set VerifyModelEnsMeanSeconds = "${verifymodelens__seconds}" %}
{% set VerifyObsSeconds = "${verifyobs__seconds}" %}
{% set VerifyObsEnsMeanSeconds = "${verifyobsens__seconds}" %}
# task selection controls
{% set CriticalPathType = "${CriticalPathType}" %}
{% set VerifyDeterministicDA = ${VerifyDeterministicDA} %} #bool
{% set CompareDA2Benchmark = ${CompareDA2Benchmark} %} #bool
{% set VerifyExtendedMeanFC = ${VerifyExtendedMeanFC} %} #bool
{% set VerifyBGMembers = ${VerifyBGMembers} %} #bool
{% set CompareBG2Benchmark = ${CompareBG2Benchmark} %} #bool
{% set VerifyEnsMeanBG = ${VerifyEnsMeanBG} %} #bool
{% set DiagnoseEnsSpreadBG = ${DiagnoseEnsSpreadBG} %} #bool
{% set VerifyANMembers = ${VerifyANMembers} %} #bool
{% set VerifyExtendedEnsFC = ${VerifyExtendedEnsFC} %} #bool
# Active cycle points
{% set maxActiveCyclePoints = ${maxActiveCyclePoints} %}
## Mini-workflow that prepares observations for IODA ingest
{% if observationsResource == "PANDACArchive" %}
# assume that IODA observation files are already available for PANDACArchive case
{% set PrepareObservations = "ObsReady" %}
{% else %}
{% set PrepareObservations = "GetObs => ObsToIODA => ObsReady" %}
{% endif %}
## Mini-workflow that prepares a cold-start initial condition file from a GFS analysis
{% if "Archive" in modelAnalysisSource %}
# assume that external analysis files are already available for "*Archive*" sources
{% set PrepareExternalAnalysis = "ExternalAnalysisReady" %}
{% elif "GFS" in modelAnalysisSource %}
# non-archived GFS analysis sources are generated online
{% set PrepareExternalAnalysis = "GetGFSanalysis => UngribColdStartIC => GenerateColdStartIC => ExternalAnalysisReady" %}
{% else %}
{{ raise('modelAnalysisSource is not valid') }}
{% endif %}
# Use GFS analysis for sea surface updating
{% set PrepareSeaSurfaceUpdate = PrepareExternalAnalysis %}
[meta]
title = "${PackageBaseName}--${SuiteName}"
[cylc]
UTC mode = False
[[environment]]
[scheduling]
initial cycle point = {{initialCyclePoint}}
final cycle point = {{finalCyclePoint}}
# Maximum number of simultaneous active dates;
# useful for constraining non-blocking flows
# and to avoid over-utilization of login nodes
# hint: execute 'ps aux | grep $USER' to check your login node overhead
# default: 3
{% if CriticalPathType != "Normal" %}
max active cycle points = 20
{% else %}
max active cycle points = {{maxActiveCyclePoints}}
{% endif %}
[[dependencies]]
## (1) Critical Path
%include include/criticalpath.rc
## (2) Verification
%include include/verification.rc
[runtime]
%include include/tasks.rc
[visualization]
initial cycle point = {{initialCyclePoint}}
final cycle point = {{finalCyclePoint}}
number of cycle points = 200
default node attributes = "style=filled", "fillcolor=grey"
EOF
cylc poll $SuiteName >& /dev/null
if ( $status == 0 ) then
echo "$0 (INFO): a cylc suite named $SuiteName is already running!"
echo "$0 (INFO): stopping the suite (30 sec.), then starting a new one..."
cylc stop --kill $SuiteName
sleep 30
else
echo "$0 (INFO): confirmed that a cylc suite named $SuiteName is not running"
echo "$0 (INFO): starting a new suite..."
endif
rm -rf ${cylcWorkDir}/${SuiteName}
cylc register ${SuiteName} ${mainScriptDir}
cylc validate --strict ${SuiteName}
cylc run ${SuiteName}
exit 0