[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 | ######################################################################### |
---|
| 8 | install_dir=$(pwd) |
---|
| 9 | compiler_suite=gnu |
---|
| 10 | ######################################################################### |
---|
| 11 | # Options |
---|
| 12 | ######################################################################### |
---|
| 13 | while (($# > 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 |
---|
| 27 | done |
---|
| 28 | |
---|
| 29 | # Install directory (get full path) |
---|
| 30 | mkdir -p $install_dir |
---|
| 31 | install_dir=$(cd $install_dir ; pwd -P ) |
---|
| 32 | |
---|
| 33 | # Install location for packages |
---|
| 34 | mkdir -p $install_dir/src |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | if [[ ${compiler_suite} == "gnu" ]] ; then |
---|
| 38 | f_compiler="gfortran" |
---|
| 39 | c_compiler="gcc" |
---|
| 40 | cxx_compiler="g++" |
---|
| 41 | elif [[ ${compiler_suite} == "intel" ]] ; then |
---|
| 42 | f_compiler="ifort" |
---|
| 43 | c_compiler="icc" |
---|
| 44 | cxx_compiler="icpc" |
---|
| 45 | else |
---|
| 46 | echo "unknown compiler family $compiler_suite" |
---|
| 47 | echo "might as well stop here" |
---|
| 48 | exit |
---|
| 49 | fi |
---|
| 50 | |
---|
| 51 | export FC=$f_compiler |
---|
| 52 | export F90=$f_compiler |
---|
| 53 | export CC=$c_compiler |
---|
| 54 | export CXX=$cxx_compiler |
---|
| 55 | allow_arg_mismatch="" |
---|
| 56 | if [[ ${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" |
---|
| 65 | elif [[ ${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" |
---|
| 72 | else |
---|
| 73 | echo "unknown compiler $f_compiler" |
---|
| 74 | echo "might as well stop here" |
---|
| 75 | exit |
---|
| 76 | fi |
---|
| 77 | |
---|
| 78 | #--------------------------------------------------------------------------- |
---|
| 79 | function myget() { |
---|
| 80 | \rm -f ${1}* |
---|
[4417] | 81 | wget -nv --no-check-certificate https://lmdz.lmd.jussieu.fr/pub/src_archives/netcdf/$1.tar.gz |
---|
[4382] | 82 | tar xvf $1.tar.gz |
---|
| 83 | } |
---|
| 84 | #--------------------------------------------------------------------------- |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | # CURL |
---|
| 88 | APP=curl-7.26.0 |
---|
| 89 | CURL_PATH=$install_dir/$APP |
---|
| 90 | rm -rf $CURL_PATH |
---|
| 91 | cd $install_dir/src |
---|
| 92 | myget curl-7.26.0 |
---|
| 93 | cd curl-7.26.0 |
---|
| 94 | export CC=$c_compiler |
---|
| 95 | ./configure \ |
---|
| 96 | --prefix=$install_dir | tee $APP.config.log |
---|
| 97 | make 2>&1 | tee $APP.make.log |
---|
| 98 | make install 2>&1 | tee $APP.install.log |
---|
| 99 | |
---|
| 100 | # ZLIB |
---|
| 101 | APP=zlib-1.2.8 |
---|
| 102 | ZLIB_PATH=$install_dir/$APP |
---|
| 103 | rm -rf $ZLIB_PATH |
---|
| 104 | cd $install_dir/src |
---|
| 105 | myget zlib-1.2.8 |
---|
| 106 | cd zlib-1.2.8 |
---|
| 107 | export CC=$c_compiler |
---|
| 108 | export FC=$f_compiler |
---|
| 109 | export CXX=$cxx_compiler |
---|
| 110 | ./configure \ |
---|
| 111 | --prefix=$install_dir | tee $APP.config.log |
---|
| 112 | make 2>&1 | tee $APP.make.log |
---|
| 113 | make check 2>&1 | tee $APP.make_check.log |
---|
| 114 | make install 2>&1 | tee $APP.install.log |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | # HDF5 |
---|
| 118 | APP=hdf5-1.10.5 |
---|
| 119 | HDF5_PATH=$install_dir/$APP |
---|
| 120 | rm -rf $HDF5_PATH |
---|
| 121 | cd $install_dir/src |
---|
| 122 | rm -rf hdf5-1.10.5* |
---|
| 123 | wget -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 |
---|
| 124 | tar xzf hdf5-1.10.5.tar.gz ; cd hdf5-1.10.5 |
---|
| 125 | export CC=$c_compiler |
---|
| 126 | export FC=$f_compiler |
---|
| 127 | export 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 |
---|
| 133 | make 2>&1 | tee $APP.make.log |
---|
| 134 | #make check 2>&1 | tee $APP.make_check.log |
---|
| 135 | make install 2>&1 | tee $APP.install.log |
---|
| 136 | |
---|
| 137 | # NetCDF4 |
---|
| 138 | APP=netcdf-4.3.3.1 |
---|
| 139 | NETCDF4_PATH=$install_dir/$APP |
---|
| 140 | rm -rf $NETCDF4_PATH |
---|
| 141 | cd $install_dir/src |
---|
| 142 | myget netcdf-4.3.3.1 |
---|
| 143 | cd netcdf-4.3.3.1 |
---|
| 144 | export LDFLAGS="-L${install_dir}/lib" |
---|
| 145 | export CFLAGS="-I${install_dir}/include/curl -I${install_dir}/include" |
---|
| 146 | export 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 |
---|
| 154 | make 2>&1 | tee $APP.make.log |
---|
| 155 | make check 2>&1 | tee $APP.make_check.log |
---|
| 156 | make install 2>&1 | tee $APP.install.log |
---|
| 157 | |
---|
| 158 | # NetCDF4-Fortran |
---|
| 159 | APP=netcdf-fortran-4.4.2 |
---|
| 160 | NETCDF4_FORTRAN_PATH=${install_dir}/$APP |
---|
| 161 | rm -rf $NETCDF4_FORTRAN_PATH |
---|
| 162 | cd ${install_dir}/src |
---|
| 163 | myget netcdf-fortran-4.4.2 |
---|
| 164 | cd netcdf-fortran-4.4.2 |
---|
| 165 | export LDFLAGS=-L${install_dir}/lib |
---|
| 166 | ./configure \ |
---|
| 167 | --prefix=${install_dir} 2>&1 | tee $APP.config.log |
---|
| 168 | make 2>&1 | tee $APP.make.log |
---|
| 169 | make check 2>&1 | tee $APP.make_check.log |
---|
| 170 | make install 2>&1 | tee $APP.install.log |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | if [[ -f $install_dir/bin/nf-config ]] ; then |
---|
| 174 | echo "successfully installed the netcdf library in $install_dir" |
---|
| 175 | fi |
---|