forked from easybest/install-wrf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
289 lines (252 loc) · 6.86 KB
/
install.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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo "+------------------------------------------------------------------------+"
echo "| One Click Of WRF Installation |"
echo "+------------------------------------------------------------------------+"
echo "| A tool to auto-compile & install WRF on Linux |"
echo "+------------------------------------------------------------------------+"
echo "| Author: Jarvis Email: jarvis.daisy@gmail.com |"
echo "+------------------------------------------------------------------------+"
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to execute install.sh"
exit 1
fi
# Install GCC & GC++ etc.
apt-get -y install build-essential gfortran
apt-get -y install csh
apt-get -y install perl
apt-get -y install m4 gzip curl wget
cur_dir=$(pwd)
Build_WRF=$cur_dir/Build_WRF
mkdir -p $Build_WRF
echo "WRF will be compiled in $Build_WRF"
# TODO Check GCC version
mkdir -p $Build_WRF/test
cd $Build_WRF/test
# Test fortran compiler
if [ ! -f "Fortran_C_tests.tar" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_tests.tar
tar -xf Fortran_C_tests.tar
fi
gfortran TEST_1_fortran_only_fixed.f
./a.out > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_1_fortran_only_fixed.f test SUCCESS"
else
echo "Error: test TEST_1_fortran_only_fixed.f!"
exit 1
fi
rm -f a.out a.out.log
gfortran TEST_2_fortran_only_free.f90
./a.out > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_2_fortran_only_free.f90 test SUCCESS"
else
echo "Error: test TEST_2_fortran_only_free.f90!"
exit 1
fi
rm -f a.out a.out.log
gcc TEST_3_c_only.c
./a.out > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_3_c_only.c test SUCCESS"
else
echo "Error: test TEST_3_c_only.c!"
exit 1
fi
rm -f a.out a.out.log
gcc -c -m64 TEST_4_fortran+c_c.c
gfortran -c -m64 TEST_4_fortran+c_f.f90
gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o
./a.out > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_4_fortran+c_c.o test SUCCESS"
else
echo "Error: TEST_4_fortran+c_c.o!"
exit 1
fi
rm -f a.out a.out.log
./TEST_csh.csh > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_csh.csh test SUCCESS"
else
echo "Error: TEST_csh.csh!"
exit 1
fi
rm -f a.out.log
./TEST_perl.pl > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_perl.pl test SUCCESS"
else
echo "Error: TEST_perl.pl!"
exit 1
fi
rm -f a.out.log
./TEST_sh.sh > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "TEST_sh.sh test SUCCESS"
else
echo "Error: TEST_sh.sh!"
exit 1
fi
rm -f a.out.log
echo "All Compile Tests Passwd!!!"
# Building Libraries
cd $Build_WRF
mkdir -p LIBRARIES
LIBRARIES_DIR=$Build_WRF/LIBRARIES
cd $LIBRARIES_DIR
## Downloads libraries
if [ ! -f "mpich-3.0.4.tar.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/mpich-3.0.4.tar.gz
fi
if [ ! -f "netcdf-4.1.3.tar.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/netcdf-4.1.3.tar.gz
fi
if [ ! -f "jasper-1.900.1.tar.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/jasper-1.900.1.tar.gz
fi
if [ ! -f "libpng-1.2.50.tar.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/libpng-1.2.50.tar.gz
fi
if [ ! -f "zlib-1.2.7.tar.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/zlib-1.2.7.tar.gz
fi
## install NetCDF
export DIR=$LIBRARIES_DIR
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
tar zxvf netcdf-4.1.3.tar.gz
cd netcdf-4.1.3
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
make
make install
export PATH=$DIR/netcdf/bin:$PATH
export NETCDF=$DIR/netcdf
cd ..
## install MPICH
tar xzvf mpich-3.0.4.tar.gz
cd mpich-3.0.4
./configure --prefix=$DIR/mpich
make
make install
export PATH=$DIR/mpich/bin:$PATH
cd ..
## install zlib
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include
tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure --prefix=$DIR/grib2
make
make install
cd ..
## install libpng
tar xzvf libpng-1.2.50.tar.gz
cd libpng-1.2.50
./configure --prefix=$DIR/grib2
make
make install
cd ..
## install JasPer
tar xzvf jasper-1.900.1.tar.gz
cd jasper-1.900.1
./configure --prefix=$DIR/grib2
make
make install
cd ..
# Library Compatibility Tests
cd $Build_WRF/test
if [ ! -f "Fortran_C_NETCDF_MPI_tests.tar" ]; then
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_NETCDF_MPI_tests.tar
fi
tar -xf Fortran_C_NETCDF_MPI_tests.tar
## Test Fortran + C + NetCDF
cp ${NETCDF}/include/netcdf.inc .
gfortran -c 01_fortran+c+netcdf_f.f
gcc -c 01_fortran+c+netcdf_c.c
gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf
./a.out > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "Fortran + C + NetCDF test SUCCESS"
else
echo "Error: test Fortran + C + NetCDF!"
exit 1
fi
rm -f a.out a.out.log
## Test Fortran + C + NetCDF + MPI
cp ${NETCDF}/include/netcdf.inc .
mpif90 -c 02_fortran+c+netcdf+mpi_f.f
mpicc -c 02_fortran+c+netcdf+mpi_c.c
mpif90 02_fortran+c+netcdf+mpi_f.o 02_fortran+c+netcdf+mpi_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf
mpirun ./a.out > a.out.log
if grep -q "SUCCESS" a.out.log
then
echo "Fortran + C + NetCDF + MPI test SUCCESS"
else
echo "Error: test Fortran + C + NetCDF + MPI!"
exit 1
fi
rm -f a.out a.out.log
# Building WRFV3
cd $Build_WRF
if [ ! -f "WRFV3.7.TAR.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/src/WRFV3.7.TAR.gz
fi
tar zxvf WRFV3.7.TAR.gz
cd WRFV3
echo 34 | ./configure
./compile em_real > log.compile
ls -ls main/*.exe
if [ ! -f "main/wrf.exe" ]; then
echo "WRF INSTALLED FAILURE."
exit 1
else
echo "WRF INSTALLED SUCCESS!"
fi
# Building WPS
cd $Build_WRF
if [ ! -f "WPSV3.7.TAR.gz" ]; then
wget http://www2.mmm.ucar.edu/wrf/src/WPSV3.7.TAR.gz
fi
tar zxvf WPSV3.7.TAR.gz
cd WPS
./clean
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
echo 1 | ./configure
./compile > log.compile
ls -ls *.exe
if [ ! -f "geogrid.exe" ]; then
echo "WPS INSTALLED FAILURE."
exit 1
else
echo "WPS INSTALLED SUCCESS!"
fi
# Static Geography Data
cd $Build_WRF
mkdir -p $Build_WRF/WPS_GEOG
if [ ! -f "geog_minimum.tar.bz2" ]; then
wget http://www2.mmm.ucar.edu/wrf/src/wps_files/geog_minimum.tar.bz2
mv geog_minimum.tar.bz2 WPS_GEOG
cd WPS_GEOG
tar -jxvf geog_minimum.tar.bz2
mv geog_minimum.tar.bz2 ..
fi
cd $Build_WRF/WPS
cp namelist.wps namelist.wps.bak
sed -i "s#/glade/p/work/wrfhelp#$Build_WRF#g" namelist.wps