source: BOL/script_install/install_netcdf4_hdf5_seq.bash @ 4382

Last change on this file since 4382 was 4382, checked in by fhourdin, 17 months ago

Introduction de l'install netcdf dans la svn

  • Property svn:executable set to *
File size: 5.2 KB
Line 
1#!/bin/bash
2#########################################################################
3# Script to automatically install the HDF5 1.10.5, NetCDF 4.3.3.1 C library
4#  and the NetCDF 4.4.2 Fortran library
5#########################################################################
6# Defaults
7#########################################################################
8install_dir=$(pwd)
9compiler_suite=gnu
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       [ -compiler gnu | intel ] compiler suite (Fortran, C, C++) to use
20                              (default: $compiler_suite)
21........fin
22     exit ;;
23     "-prefix") install_dir=$2 ; shift ; shift ;;
24     "-compiler") compiler_suite=$2 ; shift ; shift ;;
25     *) echo "Error, bad argument $1" ; $0 -h ; exit
26   esac
27done
28
29# Install directory (get full path)
30mkdir -p $install_dir
31install_dir=$(cd $install_dir ; pwd -P )
32
33# Install location for packages
34mkdir -p $install_dir/src
35
36
37if [[ ${compiler_suite} == "gnu" ]] ; then
38  f_compiler="gfortran"
39  c_compiler="gcc"
40  cxx_compiler="g++"
41elif [[ ${compiler_suite} == "intel" ]] ; then
42  f_compiler="ifort"
43  c_compiler="icc"
44  cxx_compiler="icpc"
45else
46  echo "unknown compiler family $compiler_suite"
47  echo "might as well stop here"
48  exit
49fi
50
51export FC=$f_compiler
52export F90=$f_compiler
53export CC=$c_compiler
54export CXX=$cxx_compiler
55allow_arg_mismatch=""
56if [[ ${f_compiler} == "gfortran" ]] ; then
57  if [ `gfortran -dumpversion | cut -d. -f1` -ge 11 ] ; then 
58    allow_arg_mismatch="-fallow-argument-mismatch" 
59  fi
60  export FFLAGS=" -O2 -fPIC $allow_arg_mismatch"
61  export FCFLAGS="-O2 -ffree-form -fPIC $allow_arg_mismatch"
62  export CPPFLAGS="-I${install_dir}/include"
63  export CFLAGS="-O2 -fPIC"
64  export CXXFLAGS="-O2 -fPIC"
65elif [[ ${f_compiler} == "ifort" ]] ; then
66  export CPP="icc -E"
67  export FFLAGS="-O2 -ip -fpic"
68  export FCFLAGS="-O2 -ip -fpic"
69  export CPPFLAGS="-I${install_dir}/include"
70  export CFLAGS="-O2 -ip -fpic"
71  export CXXFLAGS="-O2 -ip -fpic"
72else
73  echo "unknown compiler $f_compiler"
74  echo "might as well stop here"
75  exit
76fi
77
78#---------------------------------------------------------------------------
79function myget() {
80\rm -f ${1}*
81wget -nv --no-check-certificate https://lmdz.lmd.jussieu.fr/Distrib/$1.tar.gz
82tar xvf $1.tar.gz
83}
84#---------------------------------------------------------------------------
85
86
87# CURL
88APP=curl-7.26.0
89CURL_PATH=$install_dir/$APP
90rm -rf $CURL_PATH 
91cd $install_dir/src
92#wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/curl-7.26.0.tar.gz
93myget curl-7.26.0
94cd    curl-7.26.0
95export CC=$c_compiler
96./configure \
97--prefix=$install_dir | tee $APP.config.log
98make 2>&1 | tee $APP.make.log
99make install 2>&1 | tee $APP.install.log
100
101# ZLIB
102APP=zlib-1.2.8
103ZLIB_PATH=$install_dir/$APP 
104rm -rf $ZLIB_PATH 
105cd $install_dir/src
106#wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
107myget zlib-1.2.8
108cd    zlib-1.2.8
109export CC=$c_compiler
110export FC=$f_compiler
111export CXX=$cxx_compiler 
112./configure \
113--prefix=$install_dir | tee $APP.config.log
114make 2>&1 | tee $APP.make.log
115make check 2>&1 | tee $APP.make_check.log
116make install 2>&1 | tee $APP.install.log
117
118
119# HDF5
120APP=hdf5-1.10.5
121HDF5_PATH=$install_dir/$APP 
122rm -rf $HDF5_PATH 
123cd $install_dir/src
124rm -rf hdf5-1.10.5*
125#wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-1.8.13.tar.gz
126#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/hdf5-1.8.13.tar.gz
127wget -nv --no-check-certificate https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.5/src/hdf5-1.10.5.tar.gz
128tar xzf hdf5-1.10.5.tar.gz ; cd hdf5-1.10.5
129export CC=$c_compiler
130export FC=$f_compiler
131export CXX=$cxx_compiler 
132./configure \
133--prefix=$install_dir \
134--enable-fortran \
135--with-zlib=$install_dir  \
136--with-pic 2>&1 | tee $APP.config.log
137make 2>&1 | tee $APP.make.log
138#make check 2>&1 | tee $APP.make_check.log
139make install 2>&1 | tee $APP.install.log
140
141# NetCDF4
142APP=netcdf-4.3.3.1
143NETCDF4_PATH=$install_dir/$APP
144rm -rf $NETCDF4_PATH 
145cd $install_dir/src
146myget netcdf-4.3.3.1
147cd    netcdf-4.3.3.1
148export LDFLAGS="-L${install_dir}/lib"
149export CFLAGS="-I${install_dir}/include/curl -I${install_dir}/include"
150export LD_LIBRARY_PATH="${install_dir}/lib:${LD_LIBRARY_PATH}"
151./configure \
152--prefix=${install_dir} \
153--enable-static \
154--enable-shared \
155--enable-netcdf4 \
156--enable-dap \
157--with-pic 2>&1 | tee $APP.config.log
158make 2>&1 | tee $APP.make.log
159make check 2>&1 | tee $APP.make_check.log
160make install 2>&1 | tee $APP.install.log
161
162# NetCDF4-Fortran
163APP=netcdf-fortran-4.4.2
164NETCDF4_FORTRAN_PATH=${install_dir}/$APP
165rm -rf $NETCDF4_FORTRAN_PATH
166cd ${install_dir}/src
167#wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.2.tar.gz
168myget netcdf-fortran-4.4.2
169cd    netcdf-fortran-4.4.2
170export LDFLAGS=-L${install_dir}/lib
171./configure \
172--prefix=${install_dir} 2>&1 | tee $APP.config.log
173make 2>&1 | tee $APP.make.log
174make check 2>&1 | tee $APP.make_check.log
175make install 2>&1 | tee $APP.install.log
176
177
178if [[ -f $install_dir/bin/nf-config ]] ; then
179  echo "successfully installed the netcdf library in $install_dir"
180fi
Note: See TracBrowser for help on using the repository browser.