forked from Geek-007/WRF-sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
librariesWRF.sh
373 lines (292 loc) · 7.3 KB
/
librariesWRF.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#!/bin/bash
################################################################
### THIS SCRIPT INSTALL LIBRARIES NEEDED FOR ###
### WRF MODEL ###
### ###
### AUTHOR: [email protected] ###
################################################################
# EXECUTION OF THIS SCRIPT:
# YOU SHOULD RUN THIS SCRIPT LIKE THE FOLLLOWING
# Ex: ./libraries_wrf_install.sh 3.9 /home/user/WRF
# DIRECTORY NAME where WRF and libraries will be installed
# WHICH IS GIVEN BY USER AS THIS: 3.8 or 3.9
DIR_WRF=$1
WRF="$2/$DIR_WRF"
if [ "$DIR_WRF" == 3.9 ]
then
URL_WRF="http://www2.mmm.ucar.edu/wrf/src/WRFV3.9.TAR.gz"
URL_WPS="http://www2.mmm.ucar.edu/wrf/src/WPSV3.9.TAR.gz"
else
URL_WRF="http://www2.mmm.ucar.edu/wrf/src/WRFV3.8.TAR.gz"
URL_WPS="http://www2.mmm.ucar.edu/wrf/src/WPSV3.8.TAR.gz"
fi
#WRF="$HOME/pavel/WRF/$DIR_WRF"
function loadIntel {
ml Compiler/intel
}
function creaDirs {
mkdir -p $WRF/apps
mkdir -p $WRF/lib
mkdir -p $WRF/src
echo 'STATUS:'
echo $?
}
SRC="$WRF/src"
function downLibs {
cd $SRC
URL_JASPER="http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/jasper-1.900.1.tar.gz"
URL_NETCDF_FORTRAN="ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.4.tar.gz"
URL_NETCDF="ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.1.tar.gz"
URL_HDF5="https://support.hdfgroup.org/ftp/HDF5/current18/src/hdf5-1.8.18.tar.gz"
wget -c $URL_HDF5 && wget -c $URL_NETCDF && wget -c $URL_NETCDF_FORTRAN && wget -c $URL_JASPER && wget -c $URL_WRF && wget -c $URL_WPS
echo 'STATUS:'
echo $?
}
### INSTALL HDF5 LIBRARY
LIB="$WRF/lib"
function installHdf5 {
HDF5_LIB_DIR="$LIB/hdf5-1.8.18"
cd $SRC
tar -xvzf hdf5-1.8.18.tar.gz
cd hdf5-1.8.18/
if [ -d build ]
then
rm -rf build
make distclean
else
mkdir build && cd build
fi
logsave CONFIG-hdf5-$(date +%s) ../configure --enable-fortran2003 --enable-fortran \
CC=icc FC=ifort --prefix=$HDF5_LIB_DIR
make && logsave MAKE-CHECK-LOG-$(date +%s) make check && logsave MAKE-INSTALL-LOG-$(date +%s) make install
##
echo 'STATUS:'
echo $?
}
export LD_LIBRARY_PATH=$LIB/hdf5-1.8.18/lib:$LD_LIBRARY_PATH
function installNetcdf {
HDF5_LIB_DIR="$LIB/hdf5-1.8.18"
NETCDF_LIB_DIR="$LIB/netcdf-4.4.1.1"
cd $SRC
tar -xvzf netcdf-4.4.1.1.tar.gz
cd netcdf-4.4.1.1/
if [ -d build ]
then
rm -rf build
#make distclean
exit
else
mkdir build && cd build
fi
logsave CONFIG-netcdf-$(date +%s) ../configure CC=icc FC=ifort CXX=icpc --prefix=$NETCDF_LIB_DIR LDFLAGS="-L$HDF5_LIB_DIR/lib/" \
CPPFLAGS="-I$HDF5_LIB_DIR/include/"
make && logsave MAKE-CHECK-LOG-$(date +%s) make check && logsave MAKE-INSTALL-LOG-$(date +%s) make install
echo 'STATUS:'
echo $?
}
export LD_LIBRARY_PATH=$LIB/netcdf-4.4.1.1/lib:$LD_LIBRARY_PATH
function installNetcdf_fortran {
HDF5_LIB_DIR="$LIB/hdf5-1.8.18"
NETCDF_LIB_DIR="$LIB/netcdf-4.4.1.1"
cd $SRC
tar -xvzf netcdf-fortran-4.4.4.tar.gz
cd netcdf-fortran-4.4.4
if [ -d build ]
then
rm -rf build
#make distclean
#exit
else
mkdir build && cd build
fi
logsave CONFIG-netcdf-fortran-$(date +%s) ../configure CC=icc FC=ifort CXX=icpc --prefix=$NETCDF_LIB_DIR LDFLAGS="-L$HDF5_LIB_DIR/lib/ -L$NETCDF_LIB_DIR/lib/" CPPFLAGS="-I$HDF5_LIB_DIR/include/ -I$NETCDF_LIB_DIR/include/"
make && logsave MAKE-CHECK-LOG-$(date +%s) make check && logsave MAKE-INSTALL-LOG-$(date +%s) make install
echo 'STATUS:'
echo $?
}
function installJasper {
JASPER_LIB_DIR="$LIB/jasper"
cd $SRC
tar -xvzf jasper-1.900.1.tar.gz
cd jasper-1.900.1
if [ -d build ]
then
rm -rf build
#make distclean
exit
else
mkdir build && cd build
fi
logsave CONFIG-jasper-$(date +%s) ../configure CC=icc CXX=icpc F77=ifort --prefix=$JASPER_LIB_DIR
make && logsave MAKE-CHECK-LOG-$(date +%s) make check && logsave MAKE-INSTALL-LOG-$(date +%s) make install
echo 'STATUS:'
echo $?
export JASPERINC=$JASPER_LIB_DIR/include/
export JASPERLIB=$JASPER_LIB_DIR/lib/
}
JASPER_LIB_DIR="$LIB/jasper"
function prepareWRFWPS {
APPS="$WRF/apps"
cd $SRC
URL_H="${URL_WRF:7}"
URL_WRF=${URL_H##**/}
URL_H="${URL_WPS:7}"
URL_WPS=${URL_H##**/}
tar -xvzf $URL_WRF -C $APPS && tar -xvzf $URL_WPS -C $APPS
export JASPERINC=$JASPER_LIB_DIR/include/
export JASPERLIB=$JASPER_LIB_DIR/lib/
HDF5_LIB_DIR="$LIB/hdf5-1.8.18"
NETCDF_LIB_DIR="$LIB/netcdf-4.4.1.1"
export NETCDF=$NETCDF_LIB_DIR
export HDF5=$HDF5_LIB_DIR/
WRFV3="$APPS/WRFV3"
#
# if [ -d $WRFV3 ]
# then
# cd $WRFV3
# clear
# ./clean -aa
# wait
# else
# #mkdir "$WRFV3"
# echo 'STATUS:'
# echo $?
# fi
#
cd $WRFV3
#
ENVWRF="../envarWRF.sh"
#
exec 6>&1
exec > $ENVWRF
#
cat <<- _EOF_
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export NETCDF="$NETCDF"
export HDF5="$HDF5"
export JASPERLIB="$JASPERLIB"
export JASPERINC="$JASPERINC"
_EOF_
exec 1>&6 6>&-
#
MESSAGE="ARE YOU READY TO COMPILE WRF"
echo $MESSAGE
head --lines=1 README
#
echo "[Y]es"
echo "[N]o"
read ANS
case "$ANS" in
"Y" | "y" )
echo
echo "Choose the best option according to INTEL compilers"
./configure
wait
echo "WE START. TIME TO EDIT configure.wrf. Don't forget to source envarWRF.sh"
;;
"N" | "n" )
echo
echo "BYE!"
exit
;;
esac
}
allofThem ()
{
### CALL PREVIOUS FUNCTIONS
loadIntel #0
if [ $? -eq 0 ]; then
creaDirs #1
else
echo "Not found Intel environment"
exit
fi
if [ $? -eq 0 ]; then
downLibs #2
else
echo "Can not download files. Check links and internet connection"
exit
fi
if [ $? -eq 0 ]; then
installHdf5 #3
else
echo "Couldn't install hdf5"
exit
fi
#&&
if [ $? -eq 0 ]; then
installNetcdf #4
else
echo "Couldn't install netcdf"
exit
fi
#&&
if [ $? -eq 0 ]; then
installNetcdf_fortran #5
else
echo "Couldn't install netcdf-fortran"
exit
fi
#&&
if [ $? -eq 0 ]; then
installJasper #6
else
echo "Couldn't install jasper"
exit
fi
#&&
prepareWRFWPS #7
}
displayMenu ()
{
clear
cat <<-MENU
THIS SCRIPT INSTALL LIBRARIES AND
PREPARES ENVIRONMENT TO INSTALL
WRF/WPS CODE UNDER INTEL COMPILERS
CHOOSE WHAT TO INSTALL
--------------------------------------
0. Load Intel compilers and libraries
1. Create directories
2. Download libraries and WRF/WPS code
3. Install HDF5
4. Install NetCDF
5. Install NetCDF-Fortran
6. Install Jasper
7. Prepare source file for WRF
8. All the previous
9. Quit
--------------------------------------
MENU
read -p "Make a choice: " choice
echo "Your choice: $choice"
}
readsMenu ()
{
case $choice in
0)
loadIntel ;;
1)
creaDirs ;;
2)
downLibs ;;
3)
installHdf5 ;;
4)
installNetcdf ;;
5)
installNetcdf_fortran ;;
6)
installJasper ;;
7)
prepareWRFWPS ;;
8)
allofThem ;;
9)
exit ;;
esac
}
################
displayMenu
readsMenu
################