-
Notifications
You must be signed in to change notification settings - Fork 12
/
install_netcdf.sh
executable file
·121 lines (106 loc) · 3.32 KB
/
install_netcdf.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
#!/bin/sh
#
# install_netcdf.sh
# Copyright (C) 2018 Daniel Peláez-Zapata <[email protected]>
#
# Distributed under terms of the GNU/GPL license.
#
set -e
# ============================================================================
# Installation of NetCDF4 Fortran libraries
# ----------------------------------------------------------------------------
#
# Purpose:
# This script get the given versions of the NetCD4 libreries and its
# dependencies and install them in the MAINDIR=/usr/local/netcdf/ directory
#
# Usage:
# [sudo] CC=gcc FC=gfortran MAINDIR=/usr/local/netcdf ./install_netcdf.sh
#
# Autor:
# Daniel Peláez-Zapata
# github/dspelaez
#
# ============================================================================
## define compilers
CC=${CC:-gcc}
FC=${FC:-gfortran}
F90=${FC}
F77=${FC}
# main directory
MAINDIR=${MAINDIR:-./netcdf}
MAINDIR=$(realpath $MAINDIR)
mkdir -p $MAINDIR
echo " --->> Creating directory $MAINDIR"
# version of libs
CLTAG="8.10.0"
ZLTAG="1.3.1"
H5TAG="1.13.0"
NCTAG="4.9.2"
NFTAG="4.6.1"
## donwload source code of depencies
wget -nc -nv "https://curl.haxx.se/download/curl-$CLTAG.tar.gz"
wget -nc -nv "https://zlib.net/fossils/zlib-$ZLTAG.tar.gz"
wget -nc -nv "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${H5TAG%.*}/hdf5-$H5TAG/src/hdf5-$H5TAG.tar"
wget -nc -nv "https://downloads.unidata.ucar.edu/netcdf-c/$NCTAG/netcdf-c-$NCTAG.tar.gz"
wget -nc -nv "https://downloads.unidata.ucar.edu/netcdf-fortran/$NFTAG/netcdf-fortran-$NFTAG.tar.gz"
## create config.log
touch config.log
## curl
tar -xf curl-$CLTAG.tar.gz
cd curl-$CLTAG/
CLDIR=$MAINDIR
echo " --->> Compiling curl-$CLTAG"
./configure --prefix=${CLDIR} > config.log 2>&1
make -j4 > config.log 2>&1
make install > config.log 2>&1
cd ..
rm -rf curl-$CLTAG
## zlib
tar -xf zlib-$ZLTAG.tar.gz
cd zlib-$ZLTAG/
ZDIR=$MAINDIR
echo " --->> Compiling zlib-$ZLTAG"
./configure --prefix=${ZDIR} > config.log 2>&1
make -j4 > config.log 2>&1
make install > config.log 2>&1
cd ..
rm -rf zlib-$ZLTAG
## hdf5
tar -xf hdf5-$H5TAG.tar
cd hdf5-$H5TAG/
H5DIR=$MAINDIR
echo " --->> Compiling hdf5-$H5TAG"
./configure --with-zlib=${ZDIR} --prefix=${H5DIR} > config.log 2>&1
make -j4 > config.log 2>&1
make install > config.log 2>&1
cd ..
rm -rf hdf5-$H5TAG
## netcdf4-c
tar -xf netcdf-c-$NCTAG.tar.gz
cd netcdf-c-$NCTAG/
NCDIR=$MAINDIR
echo " --->> Compiling netcdf-c-$NCTAG"
CPPFLAGS=-I${H5DIR}/include LDFLAGS=-L${H5DIR}/lib ./configure --prefix=${NCDIR} > config.log 2>&1
make -j4 > config.log 2>&1
make install > config.log 2>&1
cd ..
rm -rf netcdf-c-$NCTAG
## netcdf4-fortran
tar -xf netcdf-fortran-$NFTAG.tar.gz
cd netcdf-fortran-$NFTAG/
echo " --->> Compiling netcdf-fortran-$NFTAG"
CPPFLAGS=-I${NCDIR}/include LDFLAGS=-L${NCDIR}/lib ./configure --prefix=${NCDIR} > config.log 2>&1
make -j4 > config.log 2>&1
make install > config.log 2>&1
cd ..
rm -rf netcdf-fortran-$NFTAG
## show compilation options
$NCDIR/bin/nf-config --all
echo ""
echo ===============================================================================
echo "Finally, you must add this to the .profile (or .bashrc or .zshrc) file"
echo " Linux --\>" export LD_LIBRARY_PATH=$NCDIR/lib:'$LD_LIBRARY_PATH'
echo " OSX --\>" export DYLD_LIBRARY_PATH=$NCDIR/lib:'$DYLD_LIBRARY_PATH'
echo ===============================================================================
echo ""