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

Last change on this file since 1980 was 1925, checked in by emillour, 7 years ago

A script to automatically download and install the NeCDF 4.0.1 library
(works for either gnu or intel family of compilers).
EM

  • Property svn:executable set to *
File size: 2.4 KB
RevLine 
[1925]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
9#########################################################################
10#  Options
11#########################################################################
12while (($# > 0))
13   do
14   case $1 in
15     "-h") cat <<........fin
16    $0 [ -prefix path ]       where (path) to install
17                              (default: $install_dir)
18       [ -compiler gnu | intel ] compiler suite (Fortran, C, C++) to use
19                              (default: $compiler_suite)
20........fin
21     exit ;;
22     "-prefix") install_dir=$2 ; shift ; shift ;;
23     "-compiler") compiler_suite=$2 ; shift ; shift ;;
24     *) echo "Error, bad argument $1" ; $0 -h ; exit
25   esac
26done
27
28# Install directory (get full path)
29mkdir -p $install_dir
30install_dir=$(cd $install_dir ; pwd -P )
31cd $install_dir
32
33rm -rf netcdf-4.0.1*
34wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
35tar xzf netcdf-4.0.1.tar.gz ; cd netcdf-4.0.1
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
55if [[ ${f_compiler} == "gfortran" ]] ; then
56  export FFLAGS=" -O2 -fPIC"
57  export FCFLAGS="-O2 -ffree-form -fPIC"
58  export CPPFLAGS=""
59  export CFLAGS="-O2 -fPIC"
60  export CXXFLAGS="-O2 -fPIC"
61elif [[ ${f_compiler} == "ifort" ]] ; then
62  export CPP="icc -E"
63  export FFLAGS="-O2 -ip -fpic"
64  export FCFLAGS="-O2 -ip -fpic"
65  export CPPFLAGS=""
66  export CFLAGS="-O2 -ip -fpic"
67  export CXXFLAGS="-O2 -ip -fpic"
68else
69  echo "unknown compiler $f_compiler"
70  echo "might as well stop here"
71  exit
72fi
73
74./configure --prefix=$install_dir > configure.log 2>&1 
75
76make > make.log 2>&1
77
78make test > make_test.log 2>&1
79
80make install > make_install.log 2>&1
81
82if [[ -f $install_dir/bin/nc-config ]] ; then
83  echo "successfully installed the netcdf library in $install_dir"
84fi
Note: See TracBrowser for help on using the repository browser.