-
Notifications
You must be signed in to change notification settings - Fork 18
/
install_netCDF.sh
executable file
·89 lines (73 loc) · 2.29 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
#!/bin/bash
# ==================
# Install netCDF-C library
# Tested successfully on Amazon-Linux AMI
#
# Jiawei Zhuang 2017/4
# ==================
# ==================
# Note:
# Use the zlib,HDF5,NetCDF4 versions specified in
# https://github.com/amznlabs/amazon-dsstne/blob/master/docs/getting_started/setup.md#openmpi-setup
# but added more --prefix and include options according to
# http://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html#build_default
#
# The older version(netcdf 4.1.3) seems much easier to install than the lastest version (netcdf 4.4.1)
# ==================
# ==================
# for C compiler if not installed yet
# ==================
#sudo yum install gcc
#sudo yum install gcc-c++
#CC=gcc
#CXX=g++
# ==================
# make a new directory if not exist
# ==================
mkdir -p $HOME/lib
cd $HOME/lib
# ==================
# for zlib
# ==================
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
tar xvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
# Build and install zlib
ZDIR=/usr/local
./configure --prefix=${ZDIR}
make check
sudo make install
cd ..
# ==================
# for HDF5
# The "make check" step takes 10~20 minutes
# Some of the tests might fail, but doesn't affect netCDF functionality
# ==================
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-1.8.12.tar.gz
tar xvfz hdf5-1.8.12.tar.gz
cd hdf5-1.8.12
# Build and install HDF5
H5DIR=/usr/local
./configure --with-zlib=${ZDIR} --prefix=${H5DIR}
make check
sudo make install
cd ..
# ==================
# for m4 if necessary
# (https://geeksww.com/tutorials/libraries/m4/installation/installing_m4_macro_processor_ubuntu_linux.php)
# ==================
# ==================
# for netCDF4
# The "make check" step takes 5~10 minutes
# ==================
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.1.3.tar.gz
tar xvf netcdf-4.1.3.tar.gz
cd netcdf-4.1.3
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${H5DIR}/lib
# Build and install netCDF-4. We don't need Fortran support (no gfortran installed)
NCDIR=/usr/local
CPPFLAGS=-I${H5DIR}/include LDFLAGS=-L${H5DIR}/lib ./configure --prefix=${NCDIR} --disable-fortran
make check # will fail fortran check without "--disable-fortran" in the configure step
sudo make install
# show the configure details
nc-config --all