-
Notifications
You must be signed in to change notification settings - Fork 0
/
HofX.csh
executable file
·142 lines (115 loc) · 3.97 KB
/
HofX.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
#!/bin/csh -f
date
# Process arguments
# =================
## args
# ArgMember: int, ensemble member [>= 1]
set ArgMember = "$1"
# ArgDT: int, valid forecast length beyond CYLC_TASK_CYCLE_POINT in hours
set ArgDT = "$2"
# ArgStateType: str, FC if this is a forecasted state, activates ArgDT in directory naming
set ArgStateType = "$3"
## arg checks
set test = `echo $ArgMember | grep '^[0-9]*$'`
set isNotInt = ($status)
if ( $isNotInt ) then
echo "ERROR in $0 : ArgMember ($ArgMember) must be an integer" > ./FAIL
exit 1
endif
if ( $ArgMember < 1 ) then
echo "ERROR in $0 : ArgMember ($ArgMember) must be > 0" > ./FAIL
exit 1
endif
set test = `echo $ArgDT | grep '^[0-9]*$'`
set isNotInt = ($status)
if ( $isNotInt ) then
echo "ERROR in $0 : ArgDT must be an integer, not $ArgDT"
exit 1
endif
# Setup environment
# =================
source config/experiment.csh
source config/filestructure.csh
source config/tools.csh
source config/modeldata.csh
source config/mpas/variables.csh
source config/builds.csh
source config/environment.csh
set yymmdd = `echo ${CYLC_TASK_CYCLE_POINT} | cut -c 1-8`
set hh = `echo ${CYLC_TASK_CYCLE_POINT} | cut -c 10-11`
set thisCycleDate = ${yymmdd}${hh}
set thisValidDate = `$advanceCYMDH ${thisCycleDate} ${ArgDT}`
source ./getCycleVars.csh
# templated work directory
set self_WorkDir = $WorkDirsTEMPLATE[$ArgMember]
if ($ArgDT > 0 || "$ArgStateType" =~ *"FC") then
set self_WorkDir = $self_WorkDir/${ArgDT}hr
endif
echo "WorkDir = ${self_WorkDir}"
cd ${self_WorkDir}
# build, executable, yaml
set myBuildDir = ${HofXBuildDir}
set myEXE = ${HofXEXE}
set myYAML = ${self_WorkDir}/$appyaml
# other templated variables
set self_StateDir = $inStateDirsTEMPLATE[$ArgMember]
set self_StatePrefix = inStatePrefixTEMPLATE
# Remove old logs
rm jedi.log*
# Remove old netcdf lock files
rm *.nc*.lock
# Remove old static fields in case this directory was used previously
rm ${localStaticFieldsPrefix}*.nc*
# ==================================================================================================
## copy static fields
set localStaticFieldsFile = ${localStaticFieldsFileOuter}
rm ${localStaticFieldsFile}
set StaticMemDir = `${memberDir} ensemble $ArgMember "${staticMemFmt}"`
set memberStaticFieldsFile = ${StaticFieldsDirOuter}${StaticMemDir}/${StaticFieldsFileOuter}
ln -sfv ${memberStaticFieldsFile} ${localStaticFieldsFile}${OrigFileSuffix}
cp -v ${memberStaticFieldsFile} ${localStaticFieldsFile}
# Link/copy bg from other directory + ensure that MPASJEDIDiagVariables are present
# =================================================================================
set bg = ./${bgDir}
mkdir -p ${bg}
set bgFileOther = ${self_StateDir}/${self_StatePrefix}.$fileDate.nc
set bgFile = ${bg}/${BGFilePrefix}.$fileDate.nc
rm ${bgFile}${OrigFileSuffix} ${bgFile}
ln -sfv ${bgFileOther} ${bgFile}${OrigFileSuffix}
ln -sfv ${bgFileOther} ${bgFile}
set copyDiags = 0
foreach var ({$MPASJEDIDiagVariables})
echo "Checking for presence of variable ($var) in ${bgFile}"
ncdump -h ${bgFile} | grep $var
if ( $status != 0 ) then
@ copyDiags++
echo "variable ($var) not present"
endif
end
if ( $copyDiags > 0 ) then
echo "Copy diagnostic variables used in HofX to bg: $MPASJEDIDiagVariables"
rm ${bgFile}
cp -v ${bgFileOther} ${bgFile}
set diagFile = ${self_StateDir}/${DIAGFilePrefix}.$fileDate.nc
ncks -A -v ${MPASJEDIDiagVariables} ${diagFile} ${bgFile}
endif
# use the background as the TemplateFieldsFileOuter
ln -sfv ${bgFile} ${TemplateFieldsFileOuter}
# Run the executable
# ==================
ln -sfv ${myBuildDir}/${myEXE} ./
mpiexec ./${myEXE} $myYAML ./jedi.log >& jedi.log.all
# Check status
# ============
grep 'Run: Finishing oops.* with status = 0' jedi.log
if ( $status != 0 ) then
echo "ERROR in $0 : jedi application failed" > ./FAIL
exit 1
endif
## change static fields to a link, keeping for transparency
rm ${localStaticFieldsFile}
mv ${localStaticFieldsFile}${OrigFileSuffix} ${localStaticFieldsFile}
# Remove netcdf lock files
rm *.nc*.lock
date
exit 0