-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_rasp.sh
executable file
·181 lines (160 loc) · 3.95 KB
/
run_rasp.sh
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
#!/bin/bash
RUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
#
# This scripts runs WRF for a given domain and and time
#
# STDOUT to log
LOG_FILE="${RUN_DIR}/run_rasp.log"
echo > "${LOG_FILE}"
# Close STDOUT file descriptor
exec 1<&-
# Open STDOUT as $LOG_FILE file for read and write.
exec 1<>"${LOG_FILE}"
# STDERR to err
ERR_FILE="${RUN_DIR}/run_rasp.err"
echo > "${ERR_FILE}"
# Close STDERR FD
exec 2<&-
# Redirect STDERR to STDOUT
exec 2<>"${ERR_FILE}"
source $RUN_DIR/rasp_env.sh
FOLDER_tmp=/tmp/METEO
FOLDER_WRF=${FOLDER_tmp}/WRF
FOLDER_WPS=${FOLDER_tmp}/WPS
DOMAIN=`./get_domain.py | head -n 1 | tail -n 1`
GFSdata=`./get_domain.py | head -n 2 | tail -n 1`
OUTdata=`./get_domain.py | head -n 3 | tail -n 1`
Ncores=`./get_domain.py | head -n 4 | tail -n 1`
echo -e "Starting RUN"
echo -e "Domain : ${DOMAIN}"
echo -e "GFS Data Folder: ${GFSdata} "
echo -e "Ncores: ${Ncores}\n"
echo -e "OMP: ${OMP_NUM_THREADS}\n"
(
echo "Cleaning up previous runs"
cd $1
pwd
#### Clean previous runs
rm dataGFS/*
rm RUN/namelist.wps RUN/namelist.input
# rm "${DOMAIN}"/met_em* "${DOMAIN}"/geo_em.*
rm WPS/namelist.wps WPS/namelist.input
rm WPS/FILE* WPS/GRIBFILE.AA* WPS/*.log WPS/log.*
rm WRF/run/namelist.input
rm WRF/run/rsl.* WRF/run/wrfout* WRF/run/met_em*
echo "cleaned"
)
(
cd $1/RUN
echo "Setting up the inputs for RUN"
pwd
#### Prepare namelists
rm namelist.*
python3 inputer.py
ln -s "$1/RUN/namelist.wps" "$1/WPS/"
ln -s "$1/RUN/namelist.input" "$1/WPS/"
ln -s "$1/RUN/namelist.input" "$1/WRF/run/"
echo "WPS/WRF Input files:"
ls $1/WPS/namelist.*
ls $1/WRF/run/namelist.*
#### Download GFS data
echo "Downloading GFS data"
time python3 download_gfs_data.py
if [ $? -eq 0 ]; then
echo "GFS data downloaded to ${GFSdata}:"
ls "${GFSdata}"
else
1>&2 echo "Error downloading GFS data"
$HOME/bin/mybot/sysbot.py "Error downloading GFS data"
exit 1
fi
)
# Check Input and GFS section
if [ $? -eq 0 ]; then
echo 'SUCCESS: Input & GFS'
else
echo "FAIL: Error in Input or GFS data"
exit 1
fi
(
#### WPS
cd $1/WPS
echo "Running geogrid"
time ./geogrid.exe >& log.geogrid
grep "Successful completion of geogrid" log.geogrid
if [ $? -eq 0 ]; then
echo "Geogrid was successful"
echo "Geogrid geo_met* files:"
ls $DOMAIN/geo_em*
./link_grib.csh ../dataGFS/
else
1>&2 echo "Error running Geogrid"
$HOME/bin/mybot/sysbot.py "Error running Geogrid"
exit 1
fi
echo "Running ungrib"
ln -sf ungrib/Variable_Tables/Vtable.GFS Vtable
time ./ungrib.exe
echo "Ungrib 'FILES*' files:"
ls FILE*
# XXX ADD checking point
echo "Running metgrid"
time ./metgrid.exe >& log.metgrid && tail log.metgrid
grep -i "Successful completion of program metgrid.exe" metgrid.log
if [ $? -eq 0 ]; then
echo "Metgrid was successful"
echo 'Metgrid met_em* files:'
ls $1/WPS/met_em*
else
1>&2 echo "Error running Metgrid"
exit 1
fi
)
# Check WPS codes
if [ $? -eq 0 ]; then
echo "SUCCESS: WPS run Ok."
else
echo "FAIL: Error during WPS steps"
exit 1
fi
(
#### WRF
echo "Going for WRF"
cd $1/WRF/run
ln -sf $1/WPS/met_em* .
echo "met* files are present:"
ls met_em*
echo -e "\nStarting real.exe"
time mpirun -np 1 ./real.exe
tail -n 1 rsl.error.0000 | grep -w SUCCESS
if [ $? -eq 0 ]; then
echo "REAL worked!!"
else
1>&2 echo "Error running real.exe"
fi
# WRF
echo -e "\nStarting wrf.exe"
T0=`date`
time mpirun -np $Ncores ./wrf.exe
# time mpirun -np $Ncores --map-by node:PE=$OMP_NUM_THREADS --rank-by core ./wrf.exe
echo "Start" $2 $3 $T0 >> /storage/WRFOUT/TIME.txt
echo "End" $2 $3 `date` >> /storage/WRFOUT/TIME.txt
tail -n 1 rsl.error.0000 | grep -w SUCCESS
if [ $? -eq 0 ]; then
echo "WRF worked!!"
else
1>&2 echo "Error running wrf.exe"
fi
mkdir -p "${OUTdata}"
rm wrfoutReady*
# mv wrfout_* "${OUTdata}"
)
# Check WRF
if [ $? -eq 0 ]; then
echo "SUCCESS: WRF run Ok."
#$HOME/bin/mybot/sysbot.py "SUCCESS: WRF run Ok."
else
echo "FAIL: Error during WRF steps"
$HOME/bin/mybot/sysbot.py "FAIL: Error during WRF steps"
exit 1
fi