Compilatore gcc e gfortran: differenze tra le versioni
| (11 revisioni intermedie di un utente non mostrate) | |||
| Riga 48: | Riga 48: | ||
6) compile Delft3D: | 6) compile Delft3D: | ||
| + | |||
| + | LD_LIBRARY_PATH=/opt/netcdf_4411_gfor/lib64/:/opt/netcdf_444_fortran_gfor/lib64:/opt/mpich_gfor/lib64:/usr/local/lib:/usr/local/lib64:/lib:/lib64 | ||
| + | PATH=/opt/mpich3.2/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/opt/netcdf_444_fortran_gfor/bin:/opt/netcdf_4411_gfor/bin | ||
./build.sh .-gnu | ./build.sh .-gnu | ||
| Riga 55: | Riga 58: | ||
| − | |||
| − | |||
| − | #------------------------------------------------------------------------------- | + | #! /bin/bash |
| − | # Top-Level Build Script for Delft3D Open Source Code | + | |
| − | # | + | #------------------------------------------------------------------------------- |
| − | # There are command-line options to select Fortran compiler and debug or not. | + | # Top-Level Build Script for Delft3D Open Source Code |
| − | # | + | # |
| − | # ToDo: Remove stripping of executables when the debug flag is set. | + | # There are command-line options to select Fortran compiler and debug or not. |
| − | # It's even debatable whether stripping belongs in the build. I think not. | + | # |
| − | # | + | # ToDo: Remove stripping of executables when the debug flag is set. |
| − | # ToDo: Don't preintialize the compiler, the user should do this himself | + | # It's even debatable whether stripping belongs in the build. I think not. |
| − | # so that he's aware exactly which version he's using. Besides, we can't | + | # |
| − | # keep up with every new compiler update. This script should be ultra-low | + | # ToDo: Don't preintialize the compiler, the user should do this himself |
| − | # maintanence. | + | # so that he's aware exactly which version he's using. Besides, we can't |
| − | # | + | # keep up with every new compiler update. This script should be ultra-low |
| − | # irv.elshoff@deltares.nl | + | # maintanence. |
| − | # adri.mourits@deltares.nl | + | # |
| − | # 04 Feb 2015 | + | # irv.elshoff@deltares.nl |
| − | # | + | # adri.mourits@deltares.nl |
| − | # Copyright (C) Stichting Deltares, 2011-2013. | + | # 04 Feb 2015 |
| − | #------------------------------------------------------------------------------- | + | # |
| − | # | + | # Copyright (C) Stichting Deltares, 2011-2013. |
| − | # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | + | #------------------------------------------------------------------------------- |
| − | # | + | # |
| − | # This script contains references to Deltares specific systems. | + | # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
| − | # Use this script as an example and modify it to fit to your system. | + | # |
| − | # See file README for compiling without using this script. | + | # This script contains references to Deltares specific systems. |
| − | # | + | # Use this script as an example and modify it to fit to your system. |
| − | #------------------------------------------------------------------------------- | + | # See file README for compiling without using this script. |
| − | + | # | |
| − | # This script must be executed in the directory where it resides | + | #------------------------------------------------------------------------------- |
| − | orgdir=`pwd` | + | |
| − | scriptdirname=`readlink \-f \$0` | + | # This script must be executed in the directory where it resides |
| − | maindir=`dirname $scriptdirname` | + | orgdir=`pwd` |
| − | cd $maindir | + | scriptdirname=`readlink \-f \$0` |
| − | + | maindir=`dirname $scriptdirname` | |
| − | + | cd $maindir | |
| − | # Default values | + | |
| − | compiler='' | + | |
| − | configureArgs='' | + | # Default values |
| − | debug=0 | + | compiler='' |
| − | noMake=0 | + | configureArgs='' |
| − | platform='ia32' | + | debug=0 |
| − | useSp=0 | + | noMake=0 |
| − | + | platform='ia32' | |
| − | #------------------------------------------------------------------------------- | + | useSp=0 |
| − | function usage { | + | |
| − | + | #------------------------------------------------------------------------------- | |
| − | + | function usage { | |
| − | + | echo "Usage: `basename $0` <compiler> [-debug] [-make] [-64bit] [-sp] [-configure <args>] [-?]" | |
| − | + | echo "Compiler is one of:" | |
| − | + | echo " -gnu" | |
| − | + | echo " -intel10" | |
| − | + | echo " -intel11.0 (-intel11)" | |
| − | + | echo " -intel11.1" | |
| − | + | echo " -intel12" | |
| − | + | echo " -intel14 (-intel14.0.3)" | |
| − | + | } | |
| − | #------------------------------------------------------------------------------- | + | |
| − | # Add date time to logging info | + | |
| − | function log { | + | #------------------------------------------------------------------------------- |
| − | + | # Add date time to logging info | |
| − | + | function log { | |
| − | + | echo "`date +%Y%m%d.%H%M%S` :: $*" | |
| − | + | } | |
| − | + | ||
| − | #------------------------------------------------------------------------------- | + | |
| − | # Add a directory to an environment parameter | + | |
| − | function addpath { | + | #------------------------------------------------------------------------------- |
| − | + | # Add a directory to an environment parameter | |
| − | + | function addpath { | |
| − | + | path="$1" | |
| − | + | shift | |
| − | + | ||
| − | + | for dir in $*; do | |
| − | + | if [ -d $dir ]; then | |
| + | eval "export $path=\"$dir:\$$path\"" | ||
| + | fi | ||
done | done | ||
} | } | ||
| − | + | ||
| − | + | ||
| − | #------------------------------------------------------------------------------- | + | #------------------------------------------------------------------------------- |
| − | # Identify which program is used | + | # Identify which program is used |
| − | function witch { | + | function witch { |
w=`which $1` | w=`which $1` | ||
( | ( | ||
| Riga 147: | Riga 150: | ||
) | ) | ||
} | } | ||
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # Process command-line arguments | + | # Process command-line arguments |
| − | + | ||
| − | while [ $# -gt 0 ]; do | + | while [ $# -gt 0 ]; do |
case $1 in | case $1 in | ||
-64bit) | -64bit) | ||
| Riga 200: | Riga 203: | ||
esac | esac | ||
shift | shift | ||
| − | done | + | done |
| − | + | ||
| − | if [ "$compiler" == '' ]; then | + | if [ "$compiler" == '' ]; then |
echo "You must specify a compiler" | echo "You must specify a compiler" | ||
usage | usage | ||
cd $orgdir | cd $orgdir | ||
exit 1 | exit 1 | ||
| − | fi | + | fi |
| − | + | ||
| − | mkdir -p logs | + | mkdir -p logs |
| − | + | ||
| − | if [ "$BASH_ENV" != '' ]; then | + | if [ "$BASH_ENV" != '' ]; then |
echo 'Warning: Unsetting BASH_ENV' | echo 'Warning: Unsetting BASH_ENV' | ||
unset BASH_ENV | unset BASH_ENV | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # Initialize Fortran compiler | + | # Initialize Fortran compiler |
| − | + | ||
| − | case $compiler in | + | case $compiler in |
gnu) | gnu) | ||
ifortInit="" | ifortInit="" | ||
iccInit="" | iccInit="" | ||
| − | # addpath PATH /opt/gcc/bin | + | # addpath PATH /opt/gcc/bin |
| − | + | addpath PATH /usr/bin | |
| − | # addpath LD_LIBRARY_PATH /opt/gcc/lib /opt/gcc/lib64 | + | # addpath LD_LIBRARY_PATH /opt/gcc/lib /opt/gcc/lib64 |
| − | + | addpath LD_LIBRARY_PATH /usr/lib64 | |
echo "Using GNU compilers in `witch gfortran`" | echo "Using GNU compilers in `witch gfortran`" | ||
;; | ;; | ||
| − | + | ||
intel14) | intel14) | ||
ifortInit=". /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh $platform" | ifortInit=". /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh $platform" | ||
| Riga 236: | Riga 239: | ||
echo "Using Intel 14.0.3 Fortran ($platform) compiler" | echo "Using Intel 14.0.3 Fortran ($platform) compiler" | ||
;; | ;; | ||
| − | + | ||
intel12) | intel12) | ||
ifortInit=". /opt/intel/bin/ifortvars.sh $platform" | ifortInit=". /opt/intel/bin/ifortvars.sh $platform" | ||
| Riga 242: | Riga 245: | ||
echo "Using Intel 12 Fortran ($platform) compiler" | echo "Using Intel 12 Fortran ($platform) compiler" | ||
;; | ;; | ||
| − | + | ||
intel11.1) | intel11.1) | ||
if [ "$platform" == 'intel64' ]; then | if [ "$platform" == 'intel64' ]; then | ||
| Riga 260: | Riga 263: | ||
fi | fi | ||
;; | ;; | ||
| − | + | ||
intel11.0) | intel11.0) | ||
if [ -d /opt/intel/Compiler/11.0/081 ]; then | if [ -d /opt/intel/Compiler/11.0/081 ]; then | ||
| Riga 270: | Riga 273: | ||
fi | fi | ||
;; | ;; | ||
| − | + | ||
intel10) | intel10) | ||
ifortInit='. /opt/intel/fc/10/bin/ifortvars.sh' | ifortInit='. /opt/intel/fc/10/bin/ifortvars.sh' | ||
| Riga 277: | Riga 280: | ||
echo "Using Intel 10 Fortran compiler (DEPRECATED!)" | echo "Using Intel 10 Fortran compiler (DEPRECATED!)" | ||
;; | ;; | ||
| − | + | ||
*) | *) | ||
ifortInit='/bin/true' | ifortInit='/bin/true' | ||
| Riga 283: | Riga 286: | ||
iccInit="" | iccInit="" | ||
;; | ;; | ||
| − | esac | + | esac |
| − | + | ||
| − | if [ "$ifortInit" != '' ]; then | + | if [ "$ifortInit" != '' ]; then |
eval $ifortInit | eval $ifortInit | ||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | ||
| Riga 292: | Riga 295: | ||
exit 1 | exit 1 | ||
fi | fi | ||
| − | fi | + | fi |
| − | + | ||
| − | if [ "$iccInit" != '' ]; then | + | if [ "$iccInit" != '' ]; then |
eval $iccInit | eval $iccInit | ||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | ||
| Riga 301: | Riga 304: | ||
exit 1 | exit 1 | ||
fi | fi | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # Use the correct Autotools | + | # Use the correct Autotools |
| − | + | ||
| − | # When the autotools are not installed in the default location, | + | # When the autotools are not installed in the default location, |
| − | # point to them explicitly | + | # point to them explicitly |
| − | + | ||
| − | #addpath PATH \ | + | #addpath PATH \ |
| − | # /opt/automake/bin \ | + | # /opt/automake/bin \ |
| − | # /opt/autoconf/bin \ | + | # /opt/autoconf/bin \ |
| − | # /opt/libtool/bin | + | # /opt/libtool/bin |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # Additional library settings | + | # Additional library settings |
| − | + | ||
| − | #--------------------- | + | #--------------------- |
| − | # mpich2 | + | # mpich2 |
| − | if [ "$compiler" = 'gnu' ]; then | + | if [ "$compiler" = 'gnu' ]; then |
| − | # addpath PATH /opt/mpich2-1.4.1-gcc-4.6.2/bin | + | # addpath PATH /opt/mpich2-1.4.1-gcc-4.6.2/bin |
addpath PATH /opt/mpich_gfor/bin | addpath PATH /opt/mpich_gfor/bin | ||
| − | # export MPI_INCLUDE=/opt/mpich2-1.4.1-gcc-4.6.2/include | + | # export MPI_INCLUDE=/opt/mpich2-1.4.1-gcc-4.6.2/include |
export MPI_INCLUDE=/opt/mpich_gfor/include | export MPI_INCLUDE=/opt/mpich_gfor/include | ||
| − | # export MPILIBS_ADDITIONAL="-L/opt/mpich2-1.4.1-gcc-4.6.2/lib -lfmpich -lmpich -lmpl" | + | # export MPILIBS_ADDITIONAL="-L/opt/mpich2-1.4.1-gcc-4.6.2/lib -lfmpich -lmpich -lmpl" |
export MPILIBS_ADDITIONAL="-L/opt/mpich_gfor/lib64 -lfmpich -lmpich -lmpl" | export MPILIBS_ADDITIONAL="-L/opt/mpich_gfor/lib64 -lfmpich -lmpich -lmpl" | ||
# export MPILIBS_ADDITIONAL=" " | # export MPILIBS_ADDITIONAL=" " | ||
| − | # export MPIFC=/opt/mpich2-1.4.1-gcc-4.6.2/bin/mpif90 | + | # export MPIFC=/opt/mpich2-1.4.1-gcc-4.6.2/bin/mpif90 |
export MPIFC=/opt/mpich_gfor/bin/mpif90 | export MPIFC=/opt/mpich_gfor/bin/mpif90 | ||
| − | else | + | else |
# Intel compilers | # Intel compilers | ||
addpath PATH /opt/mpich2-1.0.8-intel64/bin | addpath PATH /opt/mpich2-1.0.8-intel64/bin | ||
| Riga 339: | Riga 342: | ||
export MPIFC=/opt/mpich2-1.0.8-intel64-PIC/bin/mpif90 | export MPIFC=/opt/mpich2-1.0.8-intel64-PIC/bin/mpif90 | ||
fi | fi | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #--------------------- | + | #--------------------- |
| − | # Additional compile flags | + | # Additional compile flags |
| − | if [ "$compiler" = 'gnu' ]; then | + | if [ "$compiler" = 'gnu' ]; then |
fflags='' | fflags='' | ||
| − | else | + | else |
# Intel compilers | # Intel compilers | ||
fflags='-threads' | fflags='-threads' | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #--------------------- | + | #--------------------- |
| − | # Additional link flags/libraries | + | # Additional link flags/libraries |
| − | if [ "$compiler" = 'gnu' ]; then | + | if [ "$compiler" = 'gnu' ]; then |
export LDFLAGSMT_ADDITIONAL=" " | export LDFLAGSMT_ADDITIONAL=" " | ||
| − | else | + | else |
# Intel compilers | # Intel compilers | ||
export LDFLAGSMT_ADDITIONAL="-lifcoremt" | export LDFLAGSMT_ADDITIONAL="-lifcoremt" | ||
| − | fi | + | fi |
| − | + | ||
| − | #--------------------- | + | #--------------------- |
| − | # netcdf | + | # netcdf |
| − | # export NETCDFROOT=/p/delft3d/opt/netcdf-4.1.3mt/intel11.1 | + | # export NETCDFROOT=/p/delft3d/opt/netcdf-4.1.3mt/intel11.1 |
export NETCDFROOT=/opt/netcdf_444_fortran_gfor #/opt/netcdf_4411_gfor | export NETCDFROOT=/opt/netcdf_444_fortran_gfor #/opt/netcdf_4411_gfor | ||
| − | # export PKG_CONFIG_PATH=$NETCDFROOT/lib/pkgconfig:$PKG_CONFIG_PATH | + | # export PKG_CONFIG_PATH=$NETCDFROOT/lib/pkgconfig:$PKG_CONFIG_PATH |
export PKG_CONFIG_PATH=$NETCDFROOT/lib64/pkgconfig:$PKG_CONFIG_PATH | export PKG_CONFIG_PATH=$NETCDFROOT/lib64/pkgconfig:$PKG_CONFIG_PATH | ||
| − | # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDFROOT/lib | + | # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDFROOT/lib |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDFROOT/lib64:/opt/netcdf_4411_gfor/lib64 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDFROOT/lib64:/opt/netcdf_4411_gfor/lib64 | ||
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | echo "Current settings:" | + | echo "Current settings:" |
| − | echo "export ACLOCAL=\"$ACLOCAL\"" | + | echo "export ACLOCAL=\"$ACLOCAL\"" |
| − | echo "export AUTOMAKE=\"$AUTOMAKE\"" | + | echo "export AUTOMAKE=\"$AUTOMAKE\"" |
| − | echo "export AUTOHEADER=\"$AUTOHEADER\"" | + | echo "export AUTOHEADER=\"$AUTOHEADER\"" |
| − | echo "export AUTOCONF=\"$AUTOCONF\"" | + | echo "export AUTOCONF=\"$AUTOCONF\"" |
| − | echo "export AUTORECONF_FLAGS=\"$AUTORECONF_FLAGS\"" | + | echo "export AUTORECONF_FLAGS=\"$AUTORECONF_FLAGS\"" |
| − | echo "export LIBTOOLIZE=\"$LIBTOOLIZE\"" | + | echo "export LIBTOOLIZE=\"$LIBTOOLIZE\"" |
| − | echo "export LDFLAGS=\"$LDFLAGS\"" | + | echo "export LDFLAGS=\"$LDFLAGS\"" |
| − | echo "export LDFLAGSMT_ADDITIONAL=\"$LDFLAGSMT_ADDITIONAL\"" | + | echo "export LDFLAGSMT_ADDITIONAL=\"$LDFLAGSMT_ADDITIONAL\"" |
| − | echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" | + | echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" |
| − | echo "export MPIFC=\"$MPIFC\"" | + | echo "export MPIFC=\"$MPIFC\"" |
| − | echo "export MPI_INCLUDE=\"$MPI_INCLUDE\"" | + | echo "export MPI_INCLUDE=\"$MPI_INCLUDE\"" |
| − | echo "export MPILIBS_ADDITIONAL=\"$MPILIBS_ADDITIONAL\"" | + | echo "export MPILIBS_ADDITIONAL=\"$MPILIBS_ADDITIONAL\"" |
| − | echo "export PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH\"" | + | echo "export PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH\"" |
| − | echo "export PATH=\"$PATH\"" | + | echo "export PATH=\"$PATH\"" |
| − | echo | + | echo |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # Single precision executables require preparation before hand | + | # Single precision executables require preparation before hand |
| − | + | ||
| − | if [ $useSp -eq 1 ]; then | + | if [ $useSp -eq 1 ]; then |
( | ( | ||
cd utils_lgpl/deltares_common | cd utils_lgpl/deltares_common | ||
| Riga 405: | Riga 408: | ||
fi | fi | ||
) | ) | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # autogen: sanity checks, libtoolize and autoreconf | + | # autogen: sanity checks, libtoolize and autoreconf |
| − | + | ||
| − | log='logs/autogen.log' | + | log='logs/autogen.log' |
| − | command="./autogen.sh --verbose &> $log" | + | command="./autogen.sh --verbose &> $log" |
| − | + | ||
| − | log "Running $command" | + | log "Running $command" |
| − | eval $command | + | eval $command |
| − | + | ||
| − | if [ $? -ne 0 ]; then | + | if [ $? -ne 0 ]; then |
log "Autogen fails!" | log "Autogen fails!" | ||
cd $orgdir | cd $orgdir | ||
exit 1 | exit 1 | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # configure: Create makefiles | + | # configure: Create makefiles |
| − | + | ||
| − | log='logs/configure.log' | + | log='logs/configure.log' |
| − | + | ||
| − | if [ $debug -eq 1 ]; then | + | if [ $debug -eq 1 ]; then |
flags='-g -O0' | flags='-g -O0' | ||
| − | else | + | else |
flags='-O2' | flags='-O2' | ||
| − | fi | + | fi |
| − | + | ||
| − | # fPIC is the result of the mixing of static and libtool libraries. | + | # fPIC is the result of the mixing of static and libtool libraries. |
| − | # If you want to avoid this you can use convenience libraries. | + | # If you want to avoid this you can use convenience libraries. |
| − | # Don't do this for non AMD64 because it will lead to worse performance. | + | # Don't do this for non AMD64 because it will lead to worse performance. |
| − | # More information here: | + | # More information here: |
| − | # http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?full=1#book_part1_chap3 | + | # http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?full=1#book_part1_chap3 |
| − | + | ||
| − | command=" \ | + | command=" \ |
CFLAGS='$flags $CFLAGS' \ | CFLAGS='$flags $CFLAGS' \ | ||
CXXFLAGS='$flags $CXXFLAGS' \ | CXXFLAGS='$flags $CXXFLAGS' \ | ||
| Riga 451: | Riga 454: | ||
./configure --prefix=`pwd` $configureArgs &> $log \ | ./configure --prefix=`pwd` $configureArgs &> $log \ | ||
" | " | ||
| − | + | ||
| − | log "Running `echo $command | sed 's/ +/ /g'`" | + | log "Running `echo $command | sed 's/ +/ /g'`" |
| − | eval $command | + | eval $command |
| − | + | ||
| − | if [ $? -ne 0 ]; then | + | if [ $? -ne 0 ]; then |
log "Configure fails!" | log "Configure fails!" | ||
cd $orgdir | cd $orgdir | ||
exit 1 | exit 1 | ||
| − | fi | + | fi |
| − | + | ||
| − | + | ||
| − | #=============================================================================== | + | #=============================================================================== |
| − | # make: Build and install everything | + | # make: Build and install everything |
| − | + | ||
| − | if [ $noMake -eq 1 ]; then | + | if [ $noMake -eq 1 ]; then |
log "Skipping make; execute the following command before doing manual makes:" | log "Skipping make; execute the following command before doing manual makes:" | ||
echo $ifortInit | echo $ifortInit | ||
cd $orgdir | cd $orgdir | ||
exit 0 | exit 0 | ||
| − | fi | + | fi |
| − | + | ||
| − | log='logs/make.log' | + | log='logs/make.log' |
| − | command="make ds-install &> $log" | + | command="make ds-install &> $log" |
| − | + | ||
| − | log "Running $command" | + | log "Running $command" |
| − | eval $command | + | eval $command |
| − | + | ||
| − | if [ $? -ne 0 ]; then | + | if [ $? -ne 0 ]; then |
log "Make fails!" | log "Make fails!" | ||
cd $orgdir | cd $orgdir | ||
exit 1 | exit 1 | ||
| − | fi | + | fi |
| − | + | ||
| − | log "Build finished" | + | log "Build finished" |
| − | cd $orgdir | + | cd $orgdir |
| − | exit 0 | + | exit 0 |
Versione attuale delle 16:26, 30 mar 2017
How to install Delft3D with gfortran
1) Install all pre-requisites required (read Delft3D website)
2) compile mpich
./configure --prefix=/opt/mpich_gfor/ --enable-shared --enable-sharedlibs=gcc --enable-lib-depend F77=gfortran FC=gfortran CC=gcc CXX=g++ FCFLAGS=-fPIC CFLAGS=-fPIC CCFLAGS=-fPIC CXXFLAGS=-fPIC 2>&1 | tee c.txt make 2>&1 | tee m.txt make install 2>&1 | tee mi.txt
3) compile hdf5
LDFLAGS="-L/opt/mpich_gfor/lib64 -L/usr/local/lib" CPPFLAGS="-I/opt/mpich_gfor/include -I/usr/local/include" ./configure --prefix=/opt/hdf5_gfor --enable-shared --enable-hl --enable-fortran --enable-parallel
make make check make install
update PATH update LD_LIBRARY_PATH
4) compile netcdf
LDFLAGS="-L/opt/mpich_gfor/lib64 -L/opt/hdf5_gfor/lib64 -L/usr/local/lib" CPPFLAGS="-I/opt/mpich_gfor/include -I/opt/hdf5_gfor/include/ -I/usr/local/include" ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/opt/netcdf_4411_gfor
make make check make install
update PATH update LD_LIBRARY_PATH
5) compile netcdf fortran
LDFLAGS="-L/opt/mpich_gfor/lib64 -L/opt/hdf5_gfor/lib64 -L/usr/local/lib -L/opt/netcdf_4411_gfor/lib64" CPPFLAGS="-I/opt/mpich_gfor/include -I/opt/hdf5_gfor/include/ -I/usr/local/include -I/opt/netcdf_4411_gfor/include" ./configure --enable-shared --prefix=/opt/netcdf_444_fortran_gfor/
make make check make install
update PATH update LD_LIBRARY_PATH
6) compile Delft3D:
LD_LIBRARY_PATH=/opt/netcdf_4411_gfor/lib64/:/opt/netcdf_444_fortran_gfor/lib64:/opt/mpich_gfor/lib64:/usr/local/lib:/usr/local/lib64:/lib:/lib64 PATH=/opt/mpich3.2/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/opt/netcdf_444_fortran_gfor/bin:/opt/netcdf_4411_gfor/bin
./build.sh .-gnu
This is my build.sh:
#! /bin/bash
#-------------------------------------------------------------------------------
# Top-Level Build Script for Delft3D Open Source Code
#
# There are command-line options to select Fortran compiler and debug or not.
#
# ToDo: Remove stripping of executables when the debug flag is set.
# It's even debatable whether stripping belongs in the build. I think not.
#
# ToDo: Don't preintialize the compiler, the user should do this himself
# so that he's aware exactly which version he's using. Besides, we can't
# keep up with every new compiler update. This script should be ultra-low
# maintanence.
#
# irv.elshoff@deltares.nl
# adri.mourits@deltares.nl
# 04 Feb 2015
#
# Copyright (C) Stichting Deltares, 2011-2013.
#-------------------------------------------------------------------------------
#
# WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
#
# This script contains references to Deltares specific systems.
# Use this script as an example and modify it to fit to your system.
# See file README for compiling without using this script.
#
#-------------------------------------------------------------------------------
# This script must be executed in the directory where it resides
orgdir=`pwd`
scriptdirname=`readlink \-f \$0`
maindir=`dirname $scriptdirname`
cd $maindir
# Default values
compiler=
configureArgs=
debug=0
noMake=0
platform='ia32'
useSp=0
#-------------------------------------------------------------------------------
function usage {
echo "Usage: `basename $0` <compiler> [-debug] [-make] [-64bit] [-sp] [-configure <args>] [-?]"
echo "Compiler is one of:"
echo " -gnu"
echo " -intel10"
echo " -intel11.0 (-intel11)"
echo " -intel11.1"
echo " -intel12"
echo " -intel14 (-intel14.0.3)"
}
#-------------------------------------------------------------------------------
# Add date time to logging info
function log {
echo "`date +%Y%m%d.%H%M%S` :: $*"
}
#-------------------------------------------------------------------------------
# Add a directory to an environment parameter
function addpath {
path="$1"
shift
for dir in $*; do
if [ -d $dir ]; then
eval "export $path=\"$dir:\$$path\""
fi
done
}
#-------------------------------------------------------------------------------
# Identify which program is used
function witch {
w=`which $1`
(
cd `dirname $w`
/bin/pwd
)
}
#===============================================================================
# Process command-line arguments
while [ $# -gt 0 ]; do
case $1 in
-64bit)
platform='intel64'
;;
-c|-configure)
shift
configureArgs="$1"
;;
-d|-debug)
debug=1
;;
-gnu)
compiler='gnu'
;;
-intel10)
compiler='intel10'
;;
-intel11.0|-intel11)
compiler='intel11.0'
;;
-intel11.1)
compiler='intel11.1'
;;
-intel12)
compiler='intel12'
;;
-intel14|-intel14.0.3)
compiler='intel14'
;;
-m|-make)
noMake=1
;;
-sp)
useSp=1
;;
-?)
usage
cd $orgdir
exit 0
;;
*)
usage
cd $orgdir
exit 1
;;
esac
shift
done
if [ "$compiler" == ]; then
echo "You must specify a compiler"
usage
cd $orgdir
exit 1
fi
mkdir -p logs
if [ "$BASH_ENV" != ]; then
echo 'Warning: Unsetting BASH_ENV'
unset BASH_ENV
fi
#===============================================================================
# Initialize Fortran compiler
case $compiler in
gnu)
ifortInit=""
iccInit=""
# addpath PATH /opt/gcc/bin
addpath PATH /usr/bin
# addpath LD_LIBRARY_PATH /opt/gcc/lib /opt/gcc/lib64
addpath LD_LIBRARY_PATH /usr/lib64
echo "Using GNU compilers in `witch gfortran`"
;;
intel14)
ifortInit=". /opt/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh $platform"
iccInit=""
echo "Using Intel 14.0.3 Fortran ($platform) compiler"
;;
intel12)
ifortInit=". /opt/intel/bin/ifortvars.sh $platform"
iccInit=""
echo "Using Intel 12 Fortran ($platform) compiler"
;;
intel11.1)
if [ "$platform" == 'intel64' ]; then
if [ -d /opt/intel/Compiler/11.1/072/bin/intel64 ]; then
ifortInit=". /opt/intel/Compiler/11.1/072/bin/intel64/ifortvars_intel64.sh $platform"
iccInit=""
idbInit=". /opt/intel/Compiler/11.1/072/bin/intel64/idbvars.sh"
echo "Using Intel 11.1 Fortran ($platform) compiler"
fi
else
if [ -d /opt/intel/Compiler/11.1/072 ]; then
ifortInit=". /opt/intel/Compiler/11.1/072/bin/ifortvars.sh $platform"
iccInit=""
idbInit=". /opt/intel/Compiler/11.1/072/bin/$platform/idbvars.sh"
echo "Using Intel 11.1 Fortran ($platform) compiler"
fi
fi
;;
intel11.0)
if [ -d /opt/intel/Compiler/11.0/081 ]; then
ifortInit=". /opt/intel/Compiler/11.0/081/bin/ifortvars.sh $platform"
idbInit=". /opt/intel/Compiler/11.0/081/bin/$platform/idbvars.sh"
echo "Using Intel 11.0 Fortran ($platform) compiler"
iccInit=". /opt/intel/Compiler/11.0/081/bin/iccvars.sh $platform"
echo "Using Intel 11.0 C ($platform) compiler"
fi
;;
intel10)
ifortInit='. /opt/intel/fc/10/bin/ifortvars.sh'
iccInit=""
idbInit='. /opt/intel/idb/10/bin/idbvars.sh'
echo "Using Intel 10 Fortran compiler (DEPRECATED!)"
;;
*)
ifortInit='/bin/true'
echo "Using default Linux Fortran compiler"
iccInit=""
;;
esac
if [ "$ifortInit" != ]; then
eval $ifortInit
if [ $? -ne 0 ]; then
echo 'Initialization of the Fortran compiler fails!'
cd $orgdir
exit 1
fi
fi
if [ "$iccInit" != ]; then
eval $iccInit
if [ $? -ne 0 ]; then
echo 'Initialization of the C compiler fails!'
cd $orgdir
exit 1
fi
fi
#===============================================================================
# Use the correct Autotools
# When the autotools are not installed in the default location,
# point to them explicitly
#addpath PATH \
# /opt/automake/bin \
# /opt/autoconf/bin \
# /opt/libtool/bin
#===============================================================================
# Additional library settings
#---------------------
# mpich2
if [ "$compiler" = 'gnu' ]; then
# addpath PATH /opt/mpich2-1.4.1-gcc-4.6.2/bin
addpath PATH /opt/mpich_gfor/bin
# export MPI_INCLUDE=/opt/mpich2-1.4.1-gcc-4.6.2/include
export MPI_INCLUDE=/opt/mpich_gfor/include
# export MPILIBS_ADDITIONAL="-L/opt/mpich2-1.4.1-gcc-4.6.2/lib -lfmpich -lmpich -lmpl"
export MPILIBS_ADDITIONAL="-L/opt/mpich_gfor/lib64 -lfmpich -lmpich -lmpl"
# export MPILIBS_ADDITIONAL=" "
# export MPIFC=/opt/mpich2-1.4.1-gcc-4.6.2/bin/mpif90
export MPIFC=/opt/mpich_gfor/bin/mpif90
else
# Intel compilers
addpath PATH /opt/mpich2-1.0.8-intel64/bin
export MPI_INCLUDE=/opt/mpich2-1.0.8-intel64-PIC/include
export MPILIBS_ADDITIONAL="-L/opt/mpich2-1.0.8-intel64-PIC/lib -lfmpich -lmpich"
if [ "$platform" = 'intel64' ]; then
export MPIFC=/opt/mpich2-1.0.8-intel64-PIC/bin/mpif90
fi
fi
#---------------------
# Additional compile flags
if [ "$compiler" = 'gnu' ]; then
fflags=
else
# Intel compilers
fflags='-threads'
fi
#---------------------
# Additional link flags/libraries
if [ "$compiler" = 'gnu' ]; then
export LDFLAGSMT_ADDITIONAL=" "
else
# Intel compilers
export LDFLAGSMT_ADDITIONAL="-lifcoremt"
fi
#---------------------
# netcdf
# export NETCDFROOT=/p/delft3d/opt/netcdf-4.1.3mt/intel11.1
export NETCDFROOT=/opt/netcdf_444_fortran_gfor #/opt/netcdf_4411_gfor
# export PKG_CONFIG_PATH=$NETCDFROOT/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=$NETCDFROOT/lib64/pkgconfig:$PKG_CONFIG_PATH
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDFROOT/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDFROOT/lib64:/opt/netcdf_4411_gfor/lib64
#===============================================================================
echo "Current settings:"
echo "export ACLOCAL=\"$ACLOCAL\""
echo "export AUTOMAKE=\"$AUTOMAKE\""
echo "export AUTOHEADER=\"$AUTOHEADER\""
echo "export AUTOCONF=\"$AUTOCONF\""
echo "export AUTORECONF_FLAGS=\"$AUTORECONF_FLAGS\""
echo "export LIBTOOLIZE=\"$LIBTOOLIZE\""
echo "export LDFLAGS=\"$LDFLAGS\""
echo "export LDFLAGSMT_ADDITIONAL=\"$LDFLAGSMT_ADDITIONAL\""
echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\""
echo "export MPIFC=\"$MPIFC\""
echo "export MPI_INCLUDE=\"$MPI_INCLUDE\""
echo "export MPILIBS_ADDITIONAL=\"$MPILIBS_ADDITIONAL\""
echo "export PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH\""
echo "export PATH=\"$PATH\""
echo
#===============================================================================
# Single precision executables require preparation before hand
if [ $useSp -eq 1 ]; then
(
cd utils_lgpl/deltares_common
command='scripts/changeprecision.tcl single'
log "Executing \"$command\" in \"$PWD\" for single-precision executables"
eval $command
if [ $? -ne 0 ]; then
log 'ABORT: Single-precision script failed'
cd $orgdir
exit 1
fi
)
fi
#===============================================================================
# autogen: sanity checks, libtoolize and autoreconf
log='logs/autogen.log'
command="./autogen.sh --verbose &> $log"
log "Running $command"
eval $command
if [ $? -ne 0 ]; then
log "Autogen fails!"
cd $orgdir
exit 1
fi
#===============================================================================
# configure: Create makefiles
log='logs/configure.log'
if [ $debug -eq 1 ]; then
flags='-g -O0'
else
flags='-O2'
fi
# fPIC is the result of the mixing of static and libtool libraries.
# If you want to avoid this you can use convenience libraries.
# Don't do this for non AMD64 because it will lead to worse performance.
# More information here:
# http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?full=1#book_part1_chap3
command=" \
CFLAGS='$flags $CFLAGS' \
CXXFLAGS='$flags $CXXFLAGS' \
AM_FFLAGS='$LDFLAGSMT_ADDITIONAL $AM_FFLAGS' \
FFLAGS='$flags $fflags $FFLAGS' \
AM_FCFLAGS='$LDFLAGSMT_ADDITIONAL $AM_FCFLAGS' \
FCFLAGS='$flags $fflags $FCFLAGS' \
AM_LDFLAGS='$LDFLAGSMT_ADDITIONAL $AM_LDFLAGS' \
./configure --prefix=`pwd` $configureArgs &> $log \
"
log "Running `echo $command | sed 's/ +/ /g'`"
eval $command
if [ $? -ne 0 ]; then
log "Configure fails!"
cd $orgdir
exit 1
fi
#===============================================================================
# make: Build and install everything
if [ $noMake -eq 1 ]; then
log "Skipping make; execute the following command before doing manual makes:"
echo $ifortInit
cd $orgdir
exit 0
fi
log='logs/make.log'
command="make ds-install &> $log"
log "Running $command"
eval $command
if [ $? -ne 0 ]; then
log "Make fails!"
cd $orgdir
exit 1
fi
log "Build finished"
cd $orgdir
exit 0