forked from NCAR/MPAS-Workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetupWorkflow.csh
More file actions
executable file
·196 lines (170 loc) · 6.82 KB
/
SetupWorkflow.csh
File metadata and controls
executable file
·196 lines (170 loc) · 6.82 KB
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
#!/bin/csh -f
source config/filestructure.csh
set AppAndVerify = AppAndVerify
echo ""
echo "======================================================================"
echo "Setting up a new workflow"
echo " ExperimentName: ${ExperimentName}"
echo " mainScriptDir: ${mainScriptDir}"
echo "======================================================================"
echo ""
rm -rf ${mainScriptDir}
mkdir -p ${mainScriptDir}
echo `pwd`
set workflowParts = ( \
getCycleVars.csh \
tools \
config \
MeanAnalysis.csh \
MeanBackground.csh \
RTPPInflation.csh \
GenerateABEInflation.csh \
PrepVariational.csh \
EnsembleOfVariational.csh \
)
foreach part ($workflowParts)
cp -rP $part ${mainScriptDir}/
end
source config/tools.csh
source config/modeldata.csh
source config/obsdata.csh
source config/mpas/variables.csh
source config/experiment.csh
source config/mpas/${MPASGridDescriptor}/mesh.csh
## First cycle "forecast" established offline
# TODO: Setup FirstCycleDate using a new fcinit job type and put in R1 cylc position
set thisCycleDate = $FirstCycleDate
set thisValidDate = $thisCycleDate
source getCycleVars.csh
set prevCyclingFCDirs = $prevCyclingFCDirs
set member = 1
while ( $member <= ${nEnsDAMembers} )
echo ""
echo ""
if ($prevCycleDate == $prevFirstCycleDate) then
## First FC
echo "Making First FC job script"
set JobScript=${mainScriptDir}/InitFC.csh
sed -e 's@fcLengthHRTEMPLATE@'${CyclingWindowHR}'@' \
-e 's@fcIntervalHRTEMPLATE@'${CyclingWindowHR}'@' \
-e 's@deleteZerothForecastTEMPLATE@True@' \
forecast_Init.csh > ${JobScript}
chmod 744 ${JobScript}
else
find $prevCyclingFCDirs[$member] -mindepth 0 -maxdepth 0 > /dev/null
if ($? == 0) then
rm -r $prevCyclingFCDirs[$member]
endif
mkdir -p $prevCyclingFCDirs[$member]
# Outer loop mesh
set fcFile = $prevCyclingFCDirs[$member]/${FCFilePrefix}.${fileDate}.nc
set InitialMemberFC = "$firstFCDirOuter"`${memberDir} ens $member "${firstFCMemFmt}"`
ln -sfv ${InitialMemberFC}/${firstFCFilePrefix}.${fileDate}.nc ${fcFile}${OrigFileSuffix}
# rm ${fcFile}
cp ${fcFile}${OrigFileSuffix} ${fcFile}
# Inner loop mesh
if ($MPASnCellsOuter != $MPASnCellsInner) then
echo ""
set innerFCDir = $prevCyclingFCDirs[$member]/Inner
mkdir -p ${innerFCDir}
set fcFile = $innerFCDir/${FCFilePrefix}.${fileDate}.nc
set InitialMemberFC = "$firstFCDirInner"`${memberDir} ens $member "${firstFCMemFmt}"`
ln -sfv ${InitialMemberFC}/${firstFCFilePrefix}.${fileDate}.nc ${fcFile}${OrigFileSuffix}
# rm ${fcFile}
cp ${fcFile}${OrigFileSuffix} ${fcFile}
endif
endif
@ member++
end
setenv VARBC_TABLE ${INITIAL_VARBC_TABLE}
#TODO: enable VARBC updating between cycles
# setenv VARBC_TABLE ${prevCyclingDADir}/${VarBCAnalysis}
## PrepJEDICyclingDA, CyclingDA, VerifyObsDA, VerifyModelDA*, CleanCyclingDA
# *VerifyModelDA is non-functional and unused
#TODO: enable VerifyObsDA for ensemble DA; only works for deterministic DA
set WorkDir = $CyclingDADirs[1]
set taskBaseScript = Variational
set WrapperScript=${mainScriptDir}/${AppAndVerify}DA.csh
sed -e 's@wrapWorkDirsTEMPLATE@CyclingDADirs@' \
-e 's@wrapWorkDirsBenchmarkTEMPLATE@BenchmarkCyclingDADirs@' \
-e 's@AppScriptNameTEMPLATE@Variational@' \
-e 's@taskBaseScriptTEMPLATE@'${taskBaseScript}'@' \
-e 's@wrapStateDirsTEMPLATE@prevCyclingFCDirs@' \
-e 's@wrapStatePrefixTEMPLATE@'${FCFilePrefix}'@' \
-e 's@wrapStateTypeTEMPLATE@DA@' \
-e 's@wrapVARBCTableTEMPLATE@'${VARBC_TABLE}'@' \
-e 's@wrapWindowHRTEMPLATE@'${CyclingWindowHR}'@' \
-e 's@wrapAppNameTEMPLATE@'${DAType}'@g' \
-e 's@wrapjediAppNameTEMPLATE@variational@g' \
-e 's@wrapnOuterTEMPLATE@'${nOuterIterations}'@g' \
-e 's@wrapAppTypeTEMPLATE@variational@g' \
${AppAndVerify}.csh > ${WrapperScript}
chmod 744 ${WrapperScript}
${WrapperScript}
rm ${WrapperScript}
## CyclingFC
echo "Making CyclingFC job script"
set JobScript=${mainScriptDir}/CyclingFC.csh
sed -e 's@WorkDirsTEMPLATE@CyclingFCDirs@' \
-e 's@StateDirsTEMPLATE@CyclingDAOutDirs@' \
-e 's@fcLengthHRTEMPLATE@'${CyclingWindowHR}'@' \
-e 's@fcIntervalHRTEMPLATE@'${CyclingWindowHR}'@' \
-e 's@deleteZerothForecastTEMPLATE@True@' \
forecast.csh > ${JobScript}
chmod 744 ${JobScript}
## ExtendedMeanFC
echo "Making ExtendedMeanFC job script"
set JobScript=${mainScriptDir}/ExtendedMeanFC.csh
sed -e 's@WorkDirsTEMPLATE@ExtendedMeanFCDirs@' \
-e 's@StateDirsTEMPLATE@MeanAnalysisDirs@' \
-e 's@fcLengthHRTEMPLATE@'${ExtendedFCWindowHR}'@' \
-e 's@fcIntervalHRTEMPLATE@'${ExtendedFC_DT_HR}'@' \
-e 's@deleteZerothForecastTEMPLATE@False@' \
forecast.csh > ${JobScript}
chmod 744 ${JobScript}
## ExtendedEnsFC
echo "Making ExtendedEnsFC job script"
set JobScript=${mainScriptDir}/ExtendedEnsFC.csh
sed -e 's@WorkDirsTEMPLATE@ExtendedEnsFCDirs@' \
-e 's@StateDirsTEMPLATE@CyclingDAOutDirs@' \
-e 's@fcLengthHRTEMPLATE@'${ExtendedFCWindowHR}'@' \
-e 's@fcIntervalHRTEMPLATE@'${ExtendedFC_DT_HR}'@' \
-e 's@deleteZerothForecastTEMPLATE@False@' \
forecast.csh > ${JobScript}
chmod 744 ${JobScript}
## PrepJEDIHofX{{state}}, HofX{{state}}, CleanHofX{{state}}
## VerifyObs{{state}}, CompareObs{{state}},
## VerifyModel{{state}}, CompareModel{{state}}
foreach state (AN BG EnsMeanBG MeanFC EnsFC)
if (${state} == AN) then
set TemplateVariables = (CyclingDAOutDirs ${ANFilePrefix} ${DAVFWindowHR})
else if (${state} == BG) then
set TemplateVariables = (prevCyclingFCDirs ${FCFilePrefix} ${DAVFWindowHR})
else if (${state} == EnsMeanBG) then
set TemplateVariables = (MeanBackgroundDirs ${FCFilePrefix} ${DAVFWindowHR})
else if (${state} == MeanFC) then
set TemplateVariables = (ExtendedMeanFCDirs ${FCFilePrefix} ${FCVFWindowHR})
else if (${state} == EnsFC) then
set TemplateVariables = (ExtendedEnsFCDirs ${FCFilePrefix} ${FCVFWindowHR})
endif
set taskBaseScript = HofX${state}
set WrapperScript=${mainScriptDir}/${AppAndVerify}${state}.csh
sed -e 's@wrapWorkDirsTEMPLATE@Verify'${state}'Dirs@' \
-e 's@wrapWorkDirsBenchmarkTEMPLATE@BenchmarkVerify'${state}'Dirs@' \
-e 's@AppScriptNameTEMPLATE@HofX@' \
-e 's@taskBaseScriptTEMPLATE@'${taskBaseScript}'@' \
-e 's@wrapStateDirsTEMPLATE@'$TemplateVariables[1]'@' \
-e 's@wrapStatePrefixTEMPLATE@'$TemplateVariables[2]'@' \
-e 's@wrapStateTypeTEMPLATE@'${state}'@' \
-e 's@wrapVARBCTableTEMPLATE@'${VARBC_TABLE}'@' \
-e 's@wrapWindowHRTEMPLATE@'$TemplateVariables[3]'@' \
-e 's@wrapAppNameTEMPLATE@hofx@g' \
-e 's@wrapjediAppNameTEMPLATE@hofx@g' \
-e 's@wrapnOuterTEMPLATE@0@g' \
-e 's@wrapAppTypeTEMPLATE@hofx@g' \
${AppAndVerify}.csh > ${WrapperScript}
chmod 744 ${WrapperScript}
${WrapperScript}
rm ${WrapperScript}
end
exit 0