This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·253 lines (225 loc) · 7.97 KB
/
build.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
#!/bin/bash
# set -euo pipefail
IFS=$'\n\t'
install_szip() {
git clone https://github.com/erdc/szip $PREFIX/szip
cd $PREFIX/szip
./configure --prefix=$PREFIX
make
make install
}
install_zlib() {
git clone https://github.com/madler/zlib $PREFIX/zlib
cd $PREFIX/zlib
./configure --prefix=$PREFIX
make
make install
}
install_hdf5() {
git clone https://github.com/mortenpi/hdf5 $PREFIX/hdf5
cd $PREFIX/hdf5
./configure \
--prefix=$PREFIX \
--with-zlib=$PREFIX \
--with-szip=$PREFIX \
--enable-fortran \
--enable-cxx
make
make install
}
install_netcdf_c() {
curl -L -S https://github.com/Unidata/netcdf-c/archive/v4.5.tar.gz -o $PREFIX/netcdf-4.5.tar.gz
tar zxvf $PREFIX/netcdf-4.5.tar.gz -C $PREFIX
rm $PREFIX/netcdf-4.5.tar.gz
mv $PREFIX/netcdf-c-4.5 $PREFIX/netcdf-c
cd $PREFIX/netcdf-c
LD_LIBRARY_PATH=$PREFIX/lib CPPFLAGS=-I$PREFIX/include LDFLAGS=-L$PREFIX/lib ./configure --prefix=$PREFIX --disable-dap --disable-netcdf-4 --disable-shared
make
make install
}
install_netcdf_fortran() {
curl -L -S https://github.com/Unidata/netcdf-fortran/archive/v4.4.4.tar.gz -o $PREFIX/netcdf-fortran-4.4.4.tar.gz
tar zxvf $PREFIX/netcdf-fortran-4.4.4.tar.gz -C $PREFIX
rm $PREFIX/netcdf-fortran-4.4.4.tar.gz
mv $PREFIX/netcdf-fortran-4.4.4 $PREFIX/netcdf-fortran
cd $PREFIX/netcdf-fortran
./configure --prefix=$PREFIX
make
make install
}
install_mpich() {
curl --max-time 900 -L -S http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz -o $PREFIX/mpich-3.2.tar.gz
tar zxvf $PREFIX/mpich-3.2.tar.gz -C $PREFIX
rm $PREFIX/mpich-3.2.tar.gz
mv $PREFIX/mpich-3.2 $PREFIX/mpich
cd $PREFIX/mpich
./configure --prefix=$PREFIX
make
make install
}
install_wrf() {
wget http://www2.mmm.ucar.edu/wrf/src/WRFV3.6.1.TAR.gz -P $PREFIX
tar -zxvf $PREFIX/WRFV3.6.1.TAR.gz -C $PREFIX
rm -f $PREFIX/WRFV3.6.1.TAR.gz
cd $PREFIX/WRFV3
echo $WRF_CONFIGURE_OPTION | ./configure
./compile em_real
}
install_libpng() {
curl --max-time 900 -L -S http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/libpng-1.2.50.tar.gz -o $PREFIX/libpng-1.2.50.tar.gz
tar -zxvf $PREFIX/libpng-1.2.50.tar.gz -C $PREFIX
rm $PREFIX/libpng-1.2.50.tar.gz
cd $PREFIX/libpng-1.2.50
CPPFLAGS=-I$PREFIX/include LDFLAGS=-L$PREFIX/lib ./configure --prefix=$PREFIX
make
make install
}
install_jasper() {
curl --max-time 900 -L -S http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/jasper-1.900.1.tar.gz -o $PREFIX/jasper-1.900.1.tar.gz
tar -zxvf $PREFIX/jasper-1.900.1.tar.gz -C $PREFIX
rm $PREFIX/jasper-1.900.1.tar.gz
cd $PREFIX/jasper-1.900.1
./configure --prefix=$PREFIX
make
make install
}
install_wps() {
wget http://www2.mmm.ucar.edu/wrf/src/WPSV3.7.TAR.gz -P $PREFIX
tar zxvf $PREFIX/WPSV3.7.TAR.gz -C $PREFIX
rm $PREFIX/WPSV3.7.TAR.gz
cd $PREFIX/WPS
echo 1 | NCARG_ROOT=$PREFIX PATH=$NCARG_ROOT/bin:$PATH NETCDF=$PREFIX JASPERLIB=$PREFIX/lib JASPERINC=$PREFIX/include ./configure
./compile
}
install_arwpost() {
curl --max-time 900 -L -S http://www2.mmm.ucar.edu/wrf/src/ARWpost_V3.tar.gz -o $PREFIX/ARWpost_V3.tar.gz
tar zxvf $PREFIX/ARWpost_V3.tar.gz -C $PREFIX
rm $PREFIX/ARWpost_V3.tar.gz
cd $PREFIX/ARWpost
echo $ARW_CONFIGURE_OPTION | ./configure --prefix=$PREFIX
sed -i "s/-ffree-form -O/-ffree-form -O -cpp/" configure.arwp
sed -i "s/-ffixed-form -O/-ffixed-form -O -cpp/" configure.arwp
sed -i "s/-lnetcdf/-lnetcdff -lnetcdf/" src/Makefile
./compile
}
install_g2lib() {
curl --max-time 900 -L -S http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2/g2lib-1.4.0.tar -o $PREFIX/g2lib-1.4.0.tar
tar xvf $PREFIX/g2lib-1.4.0.tar -C $PREFIX
rm $PREFIX/g2lib-1.4.0.tar
cd $PREFIX/g2lib-1.4.0
sed -i "s:#.*$::g" makefile
sed -i "s/DEFS=.*/DEFS=-DLINUX/g" makefile
sed -i "s/g95/gfortran/g" makefile
sed -i "s/CC=.*/CC=gcc/g" makefile
sed -i "s|INCDIR=.*|INCDIR=-I"$PREFIX/include" -I"$PREFIX/include/jasper"|g" makefile
sed -i "s/ARFLAGS=.*/ARFLAGS=rUv/" makefile
sed -i "s/-ruv//" makefile
make
cp libg2.a $PREFIX/lib
}
install_w3lib() {
curl --max-time 900 -L -S http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2/w3lib-2.0.2.tar -o $PREFIX/w3lib-2.0.2.tar
tar xvf $PREFIX/w3lib-2.0.2.tar -C $PREFIX
rm $PREFIX/w3lib-2.0.2.tar
cd $PREFIX/w3lib-2.0.2
sed -i "s:#.*$::g" Makefile
sed -i "s/g95/gfortran/g" Makefile
sed -i "s/CC.*= cc/CC = gcc/g" Makefile
sed -i "s/ARFLAGS =.*/ARFLAGS = rUv/" Makefile
sed -i "s/-ruv//" Makefile
make
cp libw3.a $PREFIX/lib
}
install_g95() {
wget http://ftp.g95.org/v0.93/g95-x86_64-64-linux.tgz -P $PREFIX
tar zxvf $PREFIX/g95-x86_64-64-linux.tgz -C $PREFIX
ln -s $PREFIX/g95-install/bin/x86_64-unknown-linux-gnu-g95 $PREFIX/bin/g95
}
install_cnvgrib() {
curl --max-time 900 -L -S http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2/cnvgrib-1.4.1.tar -o $PREFIX/cnvgrib-1.4.1.tar
tar xvf $PREFIX/cnvgrib-1.4.1.tar -C $PREFIX
rm $PREFIX/cnvgrib-1.4.1.tar
cd $PREFIX/cnvgrib-1.4.1
sed -i "s:#.*$::g" makefile
sed -i "s/g95/gfortran/g" makefile
sed -i "s|LIBS =.*|LIBS = -L"$PREFIX/lib" -lg2 -lw3 -ljasper -lpng -lz|" makefile
sed -i "/LIBS =.*/{n;N;N;d}" makefile
sed -i "s|INC =.*|INC = -I"$PREFIX/include" -I"$PREFIX/g2lib-1.4.0" -I"$PREFIX/include/jasper"|" makefile
make
}
install_grads() {
curl --max-time 900 -L -S http://ufpr.dl.sourceforge.net/project/opengrads/grads2/2.0.2.oga.2/Linux/grads-2.0.2.oga.2-bundle-x86_64-unknown-linux-gnu.tar.gz -o $PREFIX/grads-2.0.2.oga.2-bundle-x86_64-unknown-linux-gnu.tar.gz
tar xvf $PREFIX/grads-2.0.2.oga.2-bundle-x86_64-unknown-linux-gnu.tar.gz -C $PREFIX
rm $PREFIX/grads-2.0.2.oga.2-bundle-x86_64-unknown-linux-gnu.tar.gz
}
install_pygrads() {
curl --max-time 900 -L -S https://ufpr.dl.sourceforge.net/project/opengrads/python-grads/1.1.9/pygrads-1.1.9.tar.gz -o $PREFIX/pygrads-1.1.9.tar.gz
tar zxvf $PREFIX/pygrads-1.1.9.tar.gz -C $PREFIX
rm $PREFIX/pygrads-1.1.9.tar.gz
cd $PREFIX/pygrads-1.1.9
python setup.py install --prefix $PREFIX
}
install_libgeos() {
curl -L -S https://github.com/OSGeo/geos/archive/3.6.2.tar.gz -o $PREFIX/geos-3.6.2.tar.gz
tar zxvf $PREFIX/geos-3.6.2.tar.gz -C $PREFIX
rm $PREFIX/geos-3.6.2.tar.gz
mv $PREFIX/geos-3.6.2 $PREFIX/geos
cd $PREFIX/geos
./autogen.sh
./configure --prefix=$PREFIX
make
make install
}
install_anaconda() {
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh -P $PREFIX
bash $PREFIX/Anaconda2-4.2.0-Linux-x86_64.sh -b -p $PREFIX/anaconda
rm $PREFIX/Anaconda2-4.2.0-Linux-x86_64.sh
$PREFIX/anaconda/bin/conda update -f conda
}
install_pyproj() {
git clone https://github.com/jswhit/pyproj $PREFIX/pyproj
cd $PREFIX/pyproj
# https://stackoverflow.com/questions/15608236/eclipse-and-google-app-engine-importerror-no-module-named-sysconfigdata-nd-u
# sudo ln -s /usr/lib/python2.7/plat-*/_sysconfigdata_nd.py /usr/lib/python2.7/
python setup.py build
python setup.py install --prefix $PREFIX
}
install_basemap() {
git clone https://github.com/matplotlib/basemap $PREFIX/basemap \
&& cd $PREFIX/basemap \
&& python setup.py install --prefix $PREFIX
}
install_cartopy() {
git clone https://github.com/SciTools/Cartopy $PREFIX/cartopy
cd $PREFIX/cartopy
python setup.py build_ext -I$PREFIX/include -L$PREFIX/lib
python setup.py install --prefix $PREFIX
}
install_all() {
install_szip
install_zlib
install_hdf5
install_netcdf_c
install_netcdf_fortran
install_mpich
install_wrf
install_libpng
install_jasper
install_wps
install_arwpost
install_g2lib
install_w3lib
install_g95
install_cnvgrib
install_grads
install_pygrads
install_libgeos
install_anaconda
install_pyproj
install_basemap
install_cartopy
}
if [ ! -d /home/wrf/data ]; then
mkdir /home/wrf/data
fi
install_all