--- MITgcm/tools/build_options/linux_amd64_gfortran 2007/08/20 20:31:00 1.3 +++ MITgcm/tools/build_options/linux_amd64_gfortran 2014/10/01 23:12:14 1.26 @@ -1,45 +1,113 @@ #!/bin/bash -# -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/build_options/linux_amd64_gfortran,v 1.3 2007/08/20 20:31:00 ce107 Exp $ + +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/build_options/linux_amd64_gfortran,v 1.26 2014/10/01 23:12:14 jmc Exp $ # $Name: $ -# -# Tested with gcc-gfortran v4.0.x as shipped with Fedora Core 4. -# It fixes the ' \' versus ' &' terminator problem but some -# namelist problems remain. The biggest seems to be the inability -# of current gfortran versions to support namelist syntax such as: +# Build options for gfortran compiler (GNU) on Linux AMD64 platform # -# fields(1,1) = 'UVELSLT ','VVELSLT ','WVELSLT ', +# Tested with gcc-gfortran v4.1.x as shipped with Fedora Core 6,7,8 +# with gcc-gfortran v4.3.x as shipped with Fedora Core 9,10 # -# which results in run-time errors. - +# OpenMP : Tested on dickens with gcc-gfortran v4.3.2 as shipped with FC 10 +# on baudelaire with gcc-gfortran v4.4.5 as shipped with FC 13 +# on danton with gcc-gfortran v4.5.1 as shipped with FC 14 +# with gcc-gfortran v4.7.x as shipped with FC 17 +# with gcc-gfortran v4.8.1 as shipped with FC 19 +# on acesgrid with gcc-gfortran v4.6.0 as shipped with FC 15 +# +# MPI : Tested on acesgrid (Fedora Core 15), using: +# module load gcc (Version 4.6.0) +# and with mpich1: +# module load mvapich +# or with mpich2: +# module load mvapich2 +# or with openmpi: +# module load openmpi +# and on baudelaire.csail.mit.edu (FC13), using: +# export MPI_GCC_DIR=/srv/software/gcc/gcc-packages/gcc-4.4.5/mpich2/mpich2-1.3 +# export MPI_INC_DIR=$MPI_GCC_DIR/include +# export PATH=$MPI_GCC_DIR/bin:$PATH +# +# and on IRIDIS at Southampton +# http://www.southampton.ac.uk/isolutions/computing/hpc/iridis/ +# with +# module load openmpi/1.4.3/gcc-4.3.3 +# and +# export MPI_INC_DIR=$MPIROOT/include + +#------- +# run with OpenMP: needs to set environment var. OMP_NUM_THREADS +# and generally, needs to increase the thread stack-size: +# - sh,bash: +# > export OMP_NUM_THREADS=2 +# > export GOMP_STACKSIZE=400m +# - csh,tcsh: +# > setenv OMP_NUM_THREADS 2 +# > setenv GOMP_STACKSIZE 400m +#------- + +if test "x$MPI" = xtrue ; then + CC=${CC:=mpicc} + FC=${FC:=mpif77} + F90C=${F90C:=mpif90} +else + CC=gcc + FC=gfortran + F90C=gfortran +fi -FC=gfortran -F90C=gfortran -CC=gcc DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR' -CPP='cpp -traditional -P' -NOOPTFLAGS='-O0' +EXTENDED_SRC_FLAG='-ffixed-line-length-132' +F90FIXEDFORMAT='-ffixed-form' +GET_FC_VERSION="--version" +OMPFLAG='-fopenmp' -if test "x$DEVEL" != x ; then - FFLAGS='-g -Wall -W -ffpe-trap=invalid,zero,overflow -fbounds-check' -else - FFLAGS='' -fi +NOOPTFLAGS='-O0' +NOOPTFILES='' -# Requires gfortran from 2006 onwards for -fconvert=big-endian +CFLAGS='-O0' +#- Requires gfortran from 2006 onwards for -fconvert=big-endian FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none" +#- for big setups, compile & link with "-fPIC" or set memory-model to "medium": +#CFLAGS="$CFLAGS -fPIC" +#FFLAGS="$FFLAGS -fPIC" +#- with FC 19, need to use this without -fPIC (which cancels -mcmodel option): + CFLAGS="$CFLAGS -mcmodel=medium" + FFLAGS="$FFLAGS -mcmodel=medium" +#- might want to use '-fdefault-real-8' for fizhi pkg: +#FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8" -if test "x$IEEE" = x ; then - # No need for IEEE-754 +if test "x$IEEE" = x ; then #- with optimisation: + #- full optimisation FOPTIM='-O3 -funroll-loops' + NOOPTFILES="$NOOPTFILES ini_masks_etc.F" + #- can use -O2 (safe optimisation) to avoid Pb with some gcc version of -O3: + #FOPTIM='-O2 -funroll-loops' else - # Try to follow IEEE-754 + # these may also be useful, but require specific gfortran versions: + # -Wnonstd-intrinsics for gfortran <= 4.3 + # -Wintrinsics-std for gfortran >= 4.4 + # -Wno-tabs for gfortran >= 4.3 + # -Wno-unused-dummy-argument for gfortran >= 4.6 + #FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation" + #- or simply: + FFLAGS="$FFLAGS -Wall" + #- to get plenty of warnings: -Wall -Wextra (older form: -Wall -W) or: + #FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels" + if test "x$DEVEL" = x ; then #- no optimisation + IEEE : FOPTIM='-O0' + else #- development/check options: + FOPTIM='-O0 -g -fbounds-check' + FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf" + fi fi + F90FLAGS=$FFLAGS F90OPTIM=$FOPTIM -CFLAGS=$FOPTIM + +INCLUDEDIRS='' +INCLUDES='' +LIBS='' if [ "x$NETCDF_ROOT" != x ] ; then INCLUDEDIR="${NETCDF_ROOT}/include" @@ -74,4 +142,18 @@ elif test -d /usr/local/include/netcdf.inc ; then INCLUDES='-I/usr/local/include' LIBS='-L/usr/local/lib64' +elif test -d /usr/include/netcdf.inc ; then + INCLUDES='-I/usr/include' + LIBS='-L/usr/lib64' +fi + +if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then + MPI_INC_DIR="$MPI_HOME/include" +fi +if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then + INCLUDES="$INCLUDES -I$MPI_INC_DIR" + INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" + #- used for parallel (MPI) DIVA + MPIINCLUDEDIR="$MPI_INC_DIR" + #MPI_HEADER_FILES='mpif.h mpiof.h' fi