-
Notifications
You must be signed in to change notification settings - Fork 7
/
main_restart.bash
executable file
·133 lines (98 loc) · 3.99 KB
/
main_restart.bash
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
#!/bin/bash
# ------------------------------------------------------------------------------
# WRFOTRON
# ------------------------------------------------------------------------------
#$ -cwd -V
#$ -l h_rt=48:00:00
#$ -pe ib 128
#$ -l h_vmem=2G
. config.bash
# fix hyper-threading issue with Yellowstone after upgrade
unset MP_PE_AFFINITY
export MP_TASK_AFFINITY=cpu
# -----------------------------------------------------------------------------
# 2) Chemistry simulation
# -----------------------------------------------------------------------------
# update restart files with previous results for chemistry, or do cold start
# restart check logic assumes that once we have restart file for domain 1
# we continue, even though further domains might be missing a restart file.
# Logic does not account for the case that restart file for domain 1 is missing,
# but is available for another domain (--> would attempt restart run...)
restartFound=false
for domain in $(seq -f "0%g" 1 ${max_dom})
do
newRunRstFile=wrfrst_d${domain}_YYYY-MM-DD_HH:00:00
prevRunRstFile=${restartDir}/${newRunRstFile}
if [ -f ${prevRunRstFile} ]
then
msg "substituting initial data with ${prevRunRstFile}"
# Check nco Version
ncks --version &> ncover.txt
ncksvno=$(grep -E '[0-9]' ncover.txt | cut -d" " -f5 | tr -d -c 0-9)
msg "nco version is ${ncksvno}"
if (( ${ncksvno} > 460 )); then
ncks -m ${prevRunRstFile} | grep -E ':FieldType' | cut -f1 -d ':' | tr -d ' ' | sort > chemVarList
ncks -m ${newRunRstFile} | grep -E ':FieldType' | cut -f1 -d ':' | tr -d ' ' | sort > metVarList
else
# listing variables in old (chemistry) and new (met-only) restart files
ncks -m ${prevRunRstFile} | grep -E ': type' | cut -f 1 -d ' ' | sed 's/://' | sort > chemVarList
ncks -m ${newRunRstFile} | grep -E ': type' | cut -f 1 -d ' ' | sed 's/://' | sort > metVarList
fi
chemvarsno=$(wc -l chemVarList | awk '{ print $1 }')
metvarsno=$(wc -l metVarList | awk '{ print $1 }')
if [ $chemvarsno == 0 ]; then
if [ $chemvarsno == $metvarsno ]; then
msg "WARNING chemistry restart file and meteorology restart file have same variables"
else
msg "WARNING chemistry variable list nor created"
fi
fi
# determining arrays only in old (chemistry) restart file
chemvarsno=$(wc -l chemVarList | awk '{ print $1 }')
metvarsno=$(wc -l metVarList | awk '{ print $1 }')
if (( $chemvarsno == 0 )); then
msg "WARNING chemistry variable list nor created"
fi
if (( $chemvarsno == $metvarsno )); then
msg "WARNING chemistry restart file and meteorology restart file have same variables"
fi
# determining arrays only in old (chemistry) restart file
chemVarsArr=( $(awk 'FNR==NR{a[$0]++;next}!a[$0]' metVarList chemVarList) )
# converting to comma-separated string
chemVarsLst=${chemVarsArr[@]}
chemVarsTxt=${chemVarsLst// /,}
# adding chemistry variables to new restart file
ncks -A -v ${chemVarsTxt} ${prevRunRstFile} ${newRunRstFile}
restartFound=true
fi
done
msg "chem"
# do the chem run
# adding `-bind-to none` to stop the mpi jobs trying to self-allocate binding to processors, which significantly slowed down jobs
${mpiCommandMain} -bind-to none wrf.exe
mkdir chem_out
mv rsl* chem_out
# -----------------------------------------------------------------------------
# 3) house keeping
# -----------------------------------------------------------------------------
msg "save restart files"
# save restart files in restart directory
for domain in $(seq -f "0%g" 1 ${max_dom})
do
lastRstFile=wrfrst_d${domain}_YYYY-MM-DD_HH:00:00
cp ${lastRstFile} ${restartDir}/${lastRstFile}
done
# that stuff was for runs with chemistry only...
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
msg "save output to archive staging area"
# move all new output to archive directory
for domain in $(seq -f "0%g" 1 ${max_dom})
do
for hour in $(seq -w 1 __fcstTime__)
do
curDate=$(date -u --date="YYYY-MM-DD HH:00:00 ${hour} hours" "+%Y-%m-%d_%H")
outFile=wrfout_d${domain}_${curDate}:00:00
cp ${outFile} ${stagingDir}/
done
done
msg "finished WRF/chem"