source: trunk/UTIL/install_netcdf4.0.1.bash @ 3026

Last change on this file since 3026 was 2057, checked in by emillour, 6 years ago

Add the possibility to specify extra options to the NetCDF configure script
(e.g. use script with -option "-enabled-shared" to build shared libraries).
EM

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/bash
2#########################################################################
3# Script to automatically install the NetCDF 4.0.1 Library
4#########################################################################
5# Defaults
6#########################################################################
7install_dir=$(pwd)/netcdf-4.0.1
8compiler_suite=gnu
9configure_options=""
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       [ -options opt ]       additional options string
22                              for the NetCDF configure script
23                              (default: $configure_options)
24........fin
25     exit ;;
26     "-prefix") install_dir=$2 ; shift ; shift ;;
27     "-compiler") compiler_suite=$2 ; shift ; shift ;;
28     "-options") configure_options=$2 ; shift ; shift ;;
29     *) echo "Error, bad argument $1" ; $0 -h ; exit
30   esac
31done
32
33# Install directory (get full path)
34mkdir -p $install_dir
35install_dir=$(cd $install_dir ; pwd -P )
36cd $install_dir
37
38rm -rf netcdf-4.0.1*
39wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
40tar xzf netcdf-4.0.1.tar.gz ; cd netcdf-4.0.1
41
42if [[ ${compiler_suite} == "gnu" ]] ; then
43  f_compiler="gfortran"
44  c_compiler="gcc"
45  cxx_compiler="g++"
46elif [[ ${compiler_suite} == "intel" ]] ; then
47  f_compiler="ifort"
48  c_compiler="icc"
49  cxx_compiler="icpc"
50else
51  echo "unknown compiler family $compiler_suite"
52  echo "might as well stop here"
53  exit
54fi
55
56export FC=$f_compiler
57export F90=$f_compiler
58export CC=$c_compiler
59export CXX=$cxx_compiler
60if [[ ${f_compiler} == "gfortran" ]] ; then
61  export FFLAGS=" -O2 -fPIC"
62  export FCFLAGS="-O2 -ffree-form -fPIC"
63  export CPPFLAGS=""
64  export CFLAGS="-O2 -fPIC"
65  export CXXFLAGS="-O2 -fPIC"
66elif [[ ${f_compiler} == "ifort" ]] ; then
67  export CPP="icc -E"
68  export FFLAGS="-O2 -ip -fpic"
69  export FCFLAGS="-O2 -ip -fpic"
70  export CPPFLAGS=""
71  export CFLAGS="-O2 -ip -fpic"
72  export CXXFLAGS="-O2 -ip -fpic"
73else
74  echo "unknown compiler $f_compiler"
75  echo "might as well stop here"
76  exit
77fi
78
79./configure $configure_options --prefix=$install_dir > configure.log 2>&1 
80
81make > make.log 2>&1
82
83make test > make_test.log 2>&1
84
85make install > make_install.log 2>&1
86
87if [[ -f $install_dir/bin/nc-config ]] ; then
88  echo "successfully installed the netcdf library in $install_dir"
89fi
Note: See TracBrowser for help on using the repository browser.