source: BOL/script_install/install_netcdf4_hdf5.bash @ 4925

Last change on this file since 4925 was 4925, checked in by Laurent Fairhead, 7 weeks ago

-fallow-argument-mismatch added

  • Property svn:executable set to *
File size: 6.3 KB
Line 
1#!/bin/bash
2#########################################################################
3# Defaults
4#########################################################################
5install_dir=$(pwd)
6c_compiler=gcc
7f_compiler=gfortran
8cxx_compiler=g++
9mpi_home="/usr/lib64/openmpi"
10#########################################################################
11#  Options
12#########################################################################
13while (($# > 0))
14   do
15   case $1 in
16     "-h") cat <<........fin
17    $0 [ -prefix path ]       where (path) to install
18                              (default: $install_dir)
19       [ -
20CC compiler ]       C compiler to use
21                              (default: $c_compiler)
22       [ -FC compiler ]       Fortran compiler to use
23                              (default: $f_compiler)
24       [ -CXX compiler ]      C++ compiler to use
25                              (default: $cxx_compiler)
26       [ -MPI path ]          top directory of the MPI library
27                              (default: $mpi_home)
28........fin
29     exit ;;
30     "-prefix") install_dir=$2 ; shift ; shift ;;
31     "-CC") c_compiler=$2 ; shift ; shift ;;
32     "-FC") f_compiler=$2 ; shift ; shift ;;
33     "-CXX") cxx_compiler=$2 ; shift ; shift ;;
34     "-MPI") mpi_home=$2 ; shift ; shift ;;
35     *) echo "Error, bad argument $1" ; $0 -h ; exit
36   esac
37done
38
39# Install directory (get full path)
40mkdir -p $install_dir
41install_dir=$(cd $install_dir ; pwd -P )
42
43# Install location for packages
44mkdir -p $install_dir/src
45
46allow_arg_mismatch=""
47if [[ ${f_compiler} == "gfortran" ]] ; then
48  if [ `gfortran -dumpversion | cut -d. -f1` -ge 10 ] ; then 
49    allow_arg_mismatch="-fallow-argument-mismatch" 
50  fi
51  export FFLAGS=" -O2 -fPIC $allow_arg_mismatch"
52  export FCFLAGS="-O2 -ffree-form -fPIC $allow_arg_mismatch"
53  export CPPFLAGS="-I${install_dir}/include"
54  export CFLAGS="-O2 -fPIC"
55  export CXXFLAGS="-O2 -fPIC"
56elif [[ ${f_compiler} == "ifort" ]] ; then
57  export CPP="icc -E"
58  export FFLAGS="-O2 -ip -fpic"
59  export FCFLAGS="-O2 -ip -fpic"
60  export CPPFLAGS="-I${install_dir}/include"
61  export CFLAGS="-O2 -ip -fpic"
62  export CXXFLAGS="-O2 -ip -fpic"
63else
64  echo "unknown compiler $f_compiler"
65  echo "might as well stop here"
66  exit
67fi
68
69# CURL
70APP=curl-7.26.0
71CURL_PATH=$install_dir/$APP
72rm -rf $CURL_PATH 
73cd $install_dir/src
74rm -rf curl-7.26.0*
75wget -nv --no-check-certificate http://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/curl-7.26.0.tar.gz
76tar xvf curl-7.26.0.tar.gz ; cd curl-7.26.0
77export CC=$c_compiler
78./configure \
79--prefix=$install_dir | tee $APP.config.log
80make 2>&1 | tee $APP.make.log
81make install 2>&1 | tee $APP.install.log
82
83# ZLIB
84APP=zlib-1.2.8
85ZLIB_PATH=$install_dir/$APP 
86rm -rf $ZLIB_PATH 
87cd $install_dir/src
88rm -rf zlib-1.2.8*
89wget -nv --no-check-certificate http://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/zlib-1.2.8.tar.gz
90tar zxf zlib-1.2.8.tar.gz ; cd zlib-1.2.8
91export CC=$c_compiler
92export FC=$f_compiler
93export CXX=$cxx_compiler 
94./configure \
95--prefix=$install_dir | tee $APP.config.log
96make 2>&1 | tee $APP.make.log
97make check 2>&1 | tee $APP.make_check.log
98make install 2>&1 | tee $APP.install.log
99
100# HDF5
101APP=hdf5-1.10.7
102HDF5_PATH=$install_dir/$APP 
103rm -rf $HDF5_PATH 
104cd $install_dir/src
105rm -rf ${APP}*
106wget -nv --no-check-certificate http://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/$APP.tar.gz
107tar xzf $APP.tar.gz ; cd $APP
108export PATH=$mpi_home/bin:$PATH
109if [[ ${LD_LIBRARY_PATH} == '' ]]
110then
111  export LD_LIBRARY_PATH=$mpi_home/lib
112else
113  export LD_LIBRARY_PATH=$mpi_home/lib:${LD_LIBRARY_PATH}
114fi
115export CFLAGS="-I$mpi_home/include -m64"
116export LDFLAGS="-L$mpi_home/lib -lmpi"
117export MPI_BIN=$mpi_home/bin
118export MPI_SYSCONFIG=$mpi_home/etc
119export MPI_FORTRAN_MOD_DIR=$mpi_home/lib
120export MPI_INCLUDE=$mpi_home/include
121export MPI_LIB=$mpi_home/lib
122export MPI_HOME=$mpi_home
123export CC=mpicc
124export FC=mpif90
125export CXX=mpiCC
126./configure \
127--prefix=$install_dir \
128--enable-fortran \
129--enable-parallel \
130--with-zlib=$install_dir  \
131--with-pic 2>&1 | tee $APP.config.log
132make 2>&1 | tee $APP.make.log
133#make check 2>&1 | tee $APP.make_check.log
134make install 2>&1 | tee $APP.install.log
135
136# NetCDF4
137APP=netcdf-4.3.3.1
138NETCDF4_PATH=$install_dir/$APP
139rm -rf $NETCDF4_PATH 
140cd $install_dir/src
141rm -rf netcdf-4.3.3.1*
142wget -nv --no-check-certificate http://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/netcdf-4.3.3.1.tar.gz
143tar xzf netcdf-4.3.3.1.tar.gz ; cd netcdf-4.3.3.1
144export LDFLAGS="-L${install_dir}/lib -L${mpi_home}/lib -lmpi"
145export CFLAGS="-I${install_dir}/include/curl -I${install_dir}/include"
146export LD_LIBRARY_PATH="${install_dir}/lib:${LD_LIBRARY_PATH}"
147CC=mpicc ./configure \
148--prefix=${install_dir} \
149--enable-static \
150--enable-shared \
151--enable-netcdf4 \
152--enable-dap \
153--with-pic 2>&1 | tee $APP.config.log
154make 2>&1 | tee $APP.make.log
155make check 2>&1 | tee $APP.make_check.log
156make install 2>&1 | tee $APP.install.log
157
158# NetCDF4-Fortran
159APP=netcdf-fortran-4.4.2
160NETCDF4_FORTRAN_PATH=${install_dir}/$APP
161rm -rf $NETCDF4_FORTRAN_PATH
162cd ${install_dir}/src
163rm -rf netcdf-fortran-4.4.2*
164wget -nv --no-check-certificate http://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/netcdf-fortran-4.4.2.tar.gz
165tar xzf netcdf-fortran-4.4.2.tar.gz ; cd netcdf-fortran-4.4.2
166#export LD_LIBRARY_PATH=${install_dir}/lib:${LD_LIBRARY_PATH}
167export LDFLAGS="-L${install_dir}/lib -L${install_dir}/lib -L${mpi_home}/lib -lmpi"
168export CPPFLAGS="-I${install_dir}/include/curl -I${install_dir}/include"
169export CC=mpicc
170export FC=mpif90
171export F77=mpif77
172export LDFLAGS=-L${install_dir}/lib
173./configure \
174--prefix=${install_dir} 2>&1 | tee $APP.config.log
175make 2>&1 | tee $APP.make.log
176make check 2>&1 | tee $APP.make_check.log
177make install 2>&1 | tee $APP.install.log
178
179# NetCDF4-C++
180APP=netcdf-cxx4-4.2.1
181NETCDF4_CXX_PATH=${install_dir}/$APP
182rm -rf $NETCDF4_CXX_PATH
183cd ${install_dir}/src
184rm -rf netcdf-cxx4-4.2.1*
185wget -nv --no-check-certificate http://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/netcdf-cxx4-4.2.1.tar.gz
186tar xzf netcdf-cxx4-4.2.1.tar.gz ; cd netcdf-cxx4-4.2.1
187#export LD_LIBRARY_PATH=${install_dir}/lib:${LD_LIBRARY_PATH}
188export LDFLAGS="-L${install_dir}/lib -L${mpi_home}/lib -lmpi"
189export CPPFLAGS="-I${install_dir}/include/curl -I${install_dir}/include"
190export CC=mpicc
191export CXX=mpiCC
192export LDFLAGS=-L${install_dir}/lib
193./configure \
194--prefix=${install_dir} 2>&1 | tee $APP.config.log
195make 2>&1 | tee $APP.make.log
196make check 2>&1 | tee $APP.make_check.log
197make install 2>&1 | tee $APP.install.log
Note: See TracBrowser for help on using the repository browser.