source: BOL/script_install/install_netcdf4_hdf5_seq.bash @ 5304

Last change on this file since 5304 was 4779, checked in by Laurent Fairhead, 11 months ago

Argument -fallow-argument-mismatch applies to gfortran version 10 as well
LF

  • Property svn:executable set to *
File size: 4.9 KB
RevLine 
[4382]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
[4779]57  if [ `gfortran -dumpversion | cut -d. -f1` -ge 10 ] ; then 
[4382]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}*
[4417]81wget -nv --no-check-certificate https://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/$1.tar.gz
[4382]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
92myget curl-7.26.0
93cd    curl-7.26.0
94export CC=$c_compiler
95./configure \
96--prefix=$install_dir | tee $APP.config.log
97make 2>&1 | tee $APP.make.log
98make install 2>&1 | tee $APP.install.log
99
100# ZLIB
101APP=zlib-1.2.8
102ZLIB_PATH=$install_dir/$APP 
103rm -rf $ZLIB_PATH 
104cd $install_dir/src
105myget zlib-1.2.8
106cd    zlib-1.2.8
107export CC=$c_compiler
108export FC=$f_compiler
109export CXX=$cxx_compiler 
110./configure \
111--prefix=$install_dir | tee $APP.config.log
112make 2>&1 | tee $APP.make.log
113make check 2>&1 | tee $APP.make_check.log
114make install 2>&1 | tee $APP.install.log
115
116
117# HDF5
118APP=hdf5-1.10.5
119HDF5_PATH=$install_dir/$APP 
120rm -rf $HDF5_PATH 
121cd $install_dir/src
122rm -rf hdf5-1.10.5*
123wget -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
124tar xzf hdf5-1.10.5.tar.gz ; cd hdf5-1.10.5
125export CC=$c_compiler
126export FC=$f_compiler
127export CXX=$cxx_compiler 
128./configure \
129--prefix=$install_dir \
130--enable-fortran \
131--with-zlib=$install_dir  \
132--with-pic 2>&1 | tee $APP.config.log
133make 2>&1 | tee $APP.make.log
134#make check 2>&1 | tee $APP.make_check.log
135make install 2>&1 | tee $APP.install.log
136
137# NetCDF4
138APP=netcdf-4.3.3.1
139NETCDF4_PATH=$install_dir/$APP
140rm -rf $NETCDF4_PATH 
141cd $install_dir/src
142myget netcdf-4.3.3.1
143cd    netcdf-4.3.3.1
144export LDFLAGS="-L${install_dir}/lib"
145export CFLAGS="-I${install_dir}/include/curl -I${install_dir}/include"
146export LD_LIBRARY_PATH="${install_dir}/lib:${LD_LIBRARY_PATH}"
147./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
163myget netcdf-fortran-4.4.2
164cd    netcdf-fortran-4.4.2
165export LDFLAGS=-L${install_dir}/lib
166./configure \
167--prefix=${install_dir} 2>&1 | tee $APP.config.log
168make 2>&1 | tee $APP.make.log
169make check 2>&1 | tee $APP.make_check.log
170make install 2>&1 | tee $APP.install.log
171
172
173if [[ -f $install_dir/bin/nf-config ]] ; then
174  echo "successfully installed the netcdf library in $install_dir"
175fi
Note: See TracBrowser for help on using the repository browser.