-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunVisir.sh
executable file
·250 lines (174 loc) · 7.61 KB
/
runVisir.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
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
#!/bin/bash
##########################################
#
# Help message
#
##########################################
if [[ $1 == "--help" ]]; then
echo "The standard way of invoking GUTTA is:"
echo " $ sh runVisir.sh <YYYYMMDD_HH>"
echo
echo "...but it is possible to execute a single component of the chain:"
echo " $ sh runVisir.sh <YYYYMMDD_HH> <component>"
echo "where component is one of:"
echo "Campi / Tracce / Visualizzazioni / csv2shape.sh / copyN08.sh / runN08.sh"
echo
exit
fi
##########################################
#
# Paths and routes
#
##########################################
# paths
source $HOME/gutta.conf
CAMPI_PATH=${BASE_PATH}/Campi
CAMPI_EXE=${CAMPI_PATH}/MAIN_campi.py
TRACCE_PATH=${BASE_PATH}/Tracce
TRACCE_EXE=${TRACCE_PATH}/MAIN_Tracce.py
VISUAL_PATH=${BASE_PATH}/Visualizzazioni
VISUAL_EXE=${VISUAL_PATH}/netCDF_generator.py
CSV2SHAPE_PATH=${OP_PATH}/
CSV2SHAPE_EXE=${CSV2SHAPE_PATH}/csv2shape.sh
COPYN08_PATH=${OP_PATH}/
COPYN08_EXE=${COPYN08_PATH}/copyN08.sh
RUNN08_PATH=${OP_PATH}/
RUNN08_EXE=${RUNN08_PATH}/runN08.sh
echo "_---------------------"
echo $1
echo $2
echo "_---------------------"
# define the routes
ROUTES=('ALDRZ_ITBDS' 'ALDRZ_ITBRI' 'GRGPA_ITBDS' 'GRIGO_ITBDS' 'HRDBV_ITAOI' 'HRDBV_ITBDS' 'HRDBV_ITBRI' 'HRRJK_ITAOI' 'HRSPU_ITAOI' 'HRSPU_ITBRI' 'HRZAD_ITAOI' 'HRZAD_ITBLT' 'HRZAD_ITRAN' 'ITAOI_HRDBV' 'ITAOI_HRRJK' 'ITAOI_HRSPU' 'ITAOI_HRZAD' 'ITBDS_ALDRZ' 'ITBDS_GRGPA' 'ITBDS_GRIGO' 'ITBDS_HRDBV' 'ITBDS_MEBAR' 'ITBLT_HRZAD' 'ITBRI_ALDRZ' 'ITBRI_HRDBV' 'ITBRI_HRSPU' 'ITBRI_MEBAR' 'ITRAN_HRZAD' 'MEBAR_ITBDS' 'MEBAR_ITBRI')
##########################################
#
# Load utils
#
##########################################
source ${OP_PATH}/utils.sh
##########################################
#
# bsub command re-definition
#
##########################################
# redefining bsub
bsub () {
echo bsub $* >&2
command bsub $* | head -n1 | cut -d'<' -f2 | cut -d'>' -f1
}
##########################################
#
# Initialisation
#
##########################################
# source profile
source ~/.bash_profile
# module load
source ~/.bash_anaconda_3.7
# activate conda environment
conda activate visir
# set the python path
export PYTHONPATH="$BASE_PATH"
# read args
RUNDATE=$1
COMP=$2
##########################################
#
# Campi
#
##########################################
if [[ $COMP == "" ]] || [[ $COMP == "Campi" ]]; then
echo "===== Campi [requested on $(date)] ====="
DATE=$(LANG=en_gb date +"%d%b%y")
# define params
SCRIPT_PAR=AdriaticSea_${DATE}
# invoke the job
cd $CAMPI_PATH
CAMPI_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_medium -P 0338 -J VISIR2_Campi -o ${OP_PATH}/logs/out/campi_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/campi_$(date +%Y%m%d-%H%M)_%J.err "python $CAMPI_EXE $RUNDATE $GUTTA_PATHS")
fi
##########################################
#
# Tracce
#
##########################################
if [[ $COMP == "" ]] || [[ $COMP == "Tracce" ]]; then
echo "===== Tracce [requested on $(date)] ====="
cd $TRACCE_PATH
if [[ $COMP == "Tracce" ]]; then
# Submit Tracce job array, without job dependency
# from Campi, since we only want Tracce. Then exit
TRACCE_JOBID=$(bsub -ptl 720 -q s_long -P 0338 -J "GUTTA_Tracce[1-30]" -o ${OP_PATH}/logs/out/tracce_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/tracce_$(date +%Y%m%d-%H%M)_%J.err "python $TRACCE_EXE $RUNDATE $GUTTA_PATHS ${LSB_JOBINDEX}" &)
else
# Submit Tracce job array
TRACCE_JOBID=$(bsub -ptl 720 -q s_long -P 0338 -w "done(${CAMPI_JOBID})" -J "GUTTA_Tracce[1-30]" -o ${OP_PATH}/logs/out/tracce_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/tracce_$(date +%Y%m%d-%H%M)_%J.err "python $TRACCE_EXE $RUNDATE $GUTTA_PATHS ${LSB_JOBINDEX}" &)
fi
fi
##########################################
#
# Visualizzazioni
#
##########################################
if [[ $COMP == "" ]] || [[ $COMP == "Visualizzazioni" ]]; then
echo "===== Visualizzazioni [requested on $(date)] ====="
cd $VISUAL_PATH
if [[ $COMP == "Visualizzazioni" ]]; then
# Submit Visualizzazzioni job array without dependency
# from Tracce, since we only want Visualizzazioni
VISUAL_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_long -P 0338 -J "GUTTA_Visual[1-30]" -o ${OP_PATH}/logs/out/visual_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/visual_$(date +%Y%m%d-%H%M)_%J.err "python $VISUAL_EXE $RUNDATE $GUTTA_PATHS ${LSB_JOBINDEX}" &)
else
# Submit Visualizzazzioni job array
VISUAL_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_long -P 0338 -w "done(${TRACCE_JOBID})" -J "GUTTA_Visual[1-30]" -o ${OP_PATH}/logs/out/visual_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/visual_$(date +%Y%m%d-%H%M)_%J.err "python $VISUAL_EXE $RUNDATE $GUTTA_PATHS ${LSB_JOBINDEX}" &)
fi
fi
##########################################
#
# Csv 2 shape
#
##########################################
if [[ $COMP == "" ]] || [[ $COMP == "csv2shape.sh" ]]; then
echo "===== csv2shape [requested on $(date)] ====="
cd $CSV2SHAPE_PATH/
if [[ $COMP == "csv2shape.sh" ]]; then
# Submit csv2shape job array without job dependencies
# since we only want csv2shape
CSV_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_long -P 0338 -J 'GUTTA_csv2shape' -o ${OP_PATH}/logs/out/csv2shape_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/csv2shape_$(date +%Y%m%d-%H%M)_%J.err "sh ${CSV2SHAPE_EXE} $RUNDATE" &)
else
# Submit csv2shape job array
CSV_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_long -P 0338 -w "done($VISUAL_JOBID)" -J 'GUTTA_csv2shape' -o ${OP_PATH}/logs/out/csv2shape_$(date +%Y%m%d-%H%M)_%J.log -e ${OP_PATH}/logs/err/csv2shape_$(date +%Y%m%d-%H%M)_%J.err "sh ${CSV2SHAPE_EXE} $RUNDATE" &)
fi
fi
##########################################
#
# Copy to N08
#
##########################################
if [[ $COMP == "" ]] || [[ $COMP == "copyN08.sh" ]]; then
echo "===== copyN08 [requested on $(date)] ====="
cd $COPYN08_PATH/
# Copy files to n08
if [[ $COMP == "copyN08.sh" ]]; then
# submit the job without job dependency since
# we only want to run copyN08.sh
COPYN08_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_medium -P 0338 -o ${OP_PATH}/logs/out/copyToN08_$(date +%Y%m%d-%H%M)_%J.out -e ${OP_PATH}/logs/err/copyToN08_$(date +%Y%m%d-%H%M)_%J.err -J 'GUTTA_copyToN08' "sh ${COPYN08_EXE} ${RUNDATE}" &)
else
# invoke the job
COPYN08_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_medium -P 0338 -w "done($CSV_JOBID)" -o ${OP_PATH}/logs/out/copyToN08_$(date +%Y%m%d-%H%M)_%J.out -e ${OP_PATH}/logs/err/copyToN08_$(date +%Y%m%d-%H%M)_%J.err -J 'GUTTA_copyToN08' "sh ${COPYN08_EXE} ${RUNDATE}" &)
fi
fi
##########################################
#
# Execute a command on N08
#
##########################################
if [[ $COMP == "" ]] || [[ $COMP == "runN08.sh" ]]; then
echo "===== runN08 [requested on $(date)] ====="
cd $RUNN08_PATH/
if [[ $COMP == "runN08.sh" ]]; then
# sumbit the job without job dependency since
# we only want to run this script
N08_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_medium -P 0338 -o ${OP_PATH}/logs/out/GUTTA_n08_$(date +%Y%m%d-%H%M)_%J.out -e ${OP_PATH}/logs/err/GUTTA_n08_$(date +%Y%m%d-%H%M)_%J.err -J 'GUTTA_n08' "sh ${RUNN08_EXE} ${RUNDATE}" &)
else
# invoke the job
N08_JOBID=$(bsub -ptl 720 -R "span[ptile=1]" -q s_medium -P 0338 -w "done($COPYN08_JOBID)" -o ${OP_PATH}/logs/out/GUTTA_n08_$(date +%Y%m%d-%H%M)_%J.out -e ${OP_PATH}/logs/err/GUTTA_n08_$(date +%Y%m%d-%H%M)_%J.err -J 'GUTTA_n08' "sh ${RUNN08_EXE} ${RUNDATE}" &)
fi
fi