Warning, /tools/build_options/linux_amd64_gfortran is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 1e25bc25 on 2021-02-16 20:56:47 UTC
ff25ef6c6f Ed H*0001 #!/bin/bash
7ce1a97e55 Jean*0002
c474f7219d Jean*0003 # Build options for gfortran compiler (GNU) on Linux AMD64 platform
0004 #
1e25bc2551 Jean*0005 # Tested with gcc-gfortran v4.1.x as shipped with Fedora Core 6,7,8
0006 # up to gcc-gfortran v10.2.1 as shipped with Fedora Core 33
c474f7219d Jean*0007 #
1e25bc2551 Jean*0008 # OpenMP : Tested with gcc-gfortran v4.3.2 with FC 10 (on dickens)
0009 # with gcc-gfortran v4.4.5 with FC 13 (on baudelaire)
0010 # with gcc-gfortran v7.5.0 with Ubuntu 18 LTS (on villon)
0011 # up to gcc-gfortran v10.2.1 with FC 33 (on batsi)
c474f7219d Jean*0012 #
1e25bc2551 Jean*0013 # MPI : Tested on engaging, using:
0014 # module load gcc (Version 4.8.4)
0015 # module add mvapich2/gcc/64/2.0b
c474f7219d Jean*0016 # and on baudelaire.csail.mit.edu (FC13), using:
0017 # export MPI_GCC_DIR=/srv/software/gcc/gcc-packages/gcc-4.4.5/mpich2/mpich2-1.3
0018 # export MPI_INC_DIR=$MPI_GCC_DIR/include
0019 # export PATH=$MPI_GCC_DIR/bin:$PATH
1e25bc2551 Jean*0020 # and with openmpi, on several platforms (e.g, with Ubuntu)
c474f7219d Jean*0021
7ce1a97e55 Jean*0022 #-------
78812250ef Jean*0023 # run with OpenMP: needs to set environment var. OMP_NUM_THREADS
7ce1a97e55 Jean*0024 # and generally, needs to increase the thread stack-size:
0025 # - sh,bash:
0026 # > export OMP_NUM_THREADS=2
0027 # > export GOMP_STACKSIZE=400m
0028 # - csh,tcsh:
0029 # > setenv OMP_NUM_THREADS 2
0030 # > setenv GOMP_STACKSIZE 400m
0031 #-------
ff25ef6c6f Ed H*0032
c474f7219d Jean*0033 if test "x$MPI" = xtrue ; then
0034 CC=${CC:=mpicc}
0035 FC=${FC:=mpif77}
0036 F90C=${F90C:=mpif90}
0037 else
0038 CC=gcc
0039 FC=gfortran
0040 F90C=gfortran
0041 fi
0042
a55812cda4 Cons*0043 DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR'
6257938f4b Jean*0044 EXTENDED_SRC_FLAG='-ffixed-line-length-132'
79a3cc7b1a Jean*0045 F90FIXEDFORMAT='-ffixed-form'
ede1bd7ab5 Jean*0046 GET_FC_VERSION="--version"
7ce1a97e55 Jean*0047 OMPFLAG='-fopenmp'
ff25ef6c6f Ed H*0048
c474f7219d Jean*0049 NOOPTFLAGS='-O0'
0050 NOOPTFILES=''
a55812cda4 Cons*0051
5f6f59d9c2 Jean*0052 CFLAGS='-O0'
1e25bc2551 Jean*0053
0054 #- for setting specific options, check compiler version:
0055 fcVers=`$CC -dumpversion | head -n 1 | sed 's/^[^0-9]* //;s/\..*$//'`
0056 if ! [[ $fcVers =~ ^[0-9]+$ ]] ; then
0057 echo " un-recognized Compiler-version '$fcVers' ; ignored (-> set to 0)" ; fcVers=0 ;
0058 else echo " get Compiler-version: '$fcVers'" ; fi
0059
0060 if [ $fcVers -ge 10 ] ; then
0061 FFLAGS="$FFLAGS -fallow-argument-mismatch"
0062 fi
5f6f59d9c2 Jean*0063 #- Requires gfortran from 2006 onwards for -fconvert=big-endian
a55812cda4 Cons*0064 FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none"
5f6f59d9c2 Jean*0065 #- for big setups, compile & link with "-fPIC" or set memory-model to "medium":
f42b53d908 Jean*0066 #CFLAGS="$CFLAGS -fPIC"
0067 #FFLAGS="$FFLAGS -fPIC"
5f6f59d9c2 Jean*0068 #- with FC 19, need to use this without -fPIC (which cancels -mcmodel option):
f42b53d908 Jean*0069 CFLAGS="$CFLAGS -mcmodel=medium"
0070 FFLAGS="$FFLAGS -mcmodel=medium"
c474f7219d Jean*0071 #- might want to use '-fdefault-real-8' for fizhi pkg:
a7064d0a77 Jean*0072 #FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8"
a55812cda4 Cons*0073
c474f7219d Jean*0074 if test "x$IEEE" = x ; then #- with optimisation:
0075 #- full optimisation
80497dc312 Cons*0076 FOPTIM='-O3 -funroll-loops'
c474f7219d Jean*0077 NOOPTFILES="$NOOPTFILES ini_masks_etc.F"
0078 #- can use -O2 (safe optimisation) to avoid Pb with some gcc version of -O3:
0079 #FOPTIM='-O2 -funroll-loops'
ff25ef6c6f Ed H*0080 else
c474f7219d Jean*0081 # these may also be useful, but require specific gfortran versions:
92cb825e81 Jean*0082 # -Wnonstd-intrinsics for gfortran <= 4.3
0083 # -Wintrinsics-std for gfortran >= 4.4
0084 # -Wno-tabs for gfortran >= 4.3
0085 # -Wno-unused-dummy-argument for gfortran >= 4.6
118560d5b0 Jean*0086 #FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation"
0087 #- or simply:
25d40fc6e4 Jean*0088 FFLAGS="$FFLAGS -Wall"
1e25bc2551 Jean*0089 if [ $fcVers -ge 10 ] ; then
0090 FFLAGS="$FFLAGS -Wno-unused-dummy-argument"
0091 fi
c474f7219d Jean*0092 #- to get plenty of warnings: -Wall -Wextra (older form: -Wall -W) or:
0093 #FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels"
0094 if test "x$DEVEL" = x ; then #- no optimisation + IEEE :
0095 FOPTIM='-O0'
0096 else #- development/check options:
6bc3761f6d Jean*0097 FOPTIM='-O0 -g -fbounds-check'
0098 FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf"
c474f7219d Jean*0099 fi
ff25ef6c6f Ed H*0100 fi
c474f7219d Jean*0101
a55812cda4 Cons*0102 F90FLAGS=$FFLAGS
0103 F90OPTIM=$FOPTIM
ff25ef6c6f Ed H*0104
c474f7219d Jean*0105 INCLUDEDIRS=''
0106 INCLUDES=''
0107 LIBS=''
0108
a55812cda4 Cons*0109 if [ "x$NETCDF_ROOT" != x ] ; then
0110 INCLUDEDIR="${NETCDF_ROOT}/include"
0111 INCLUDES="-I${NETCDF_ROOT}/include"
0112 LIBDIR="${NETCDF_ROOT}/lib"
0113 LIBS="-L${NETCDF_ROOT}/lib"
0114 elif [ "x$NETCDF_HOME" != x ]; then
0115 INCLUDEDIR="${NETCDF_HOME}/include"
0116 INCLUDES="-I${NETCDF_HOME}/include"
0117 LIBDIR="${NETCDF_HOME}/lib"
0118 LIBS="-L${NETCDF_HOME}/lib"
0119 elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then
0120 NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'`
0121 NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'`
0122 INCLUDEDIR="${NETCDF_INC}"
0123 INCLUDES="-I${NETCDF_INC}"
0124 LIBDIR="${NETCDF_LIB}"
0125 LIBS="-L${NETCDF_LIB}"
0126 elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then
0127 INCLUDEDIR="${NETCDF_INCDIR}"
0128 INCLUDES="-I${NETCDF_INCDIR}"
0129 LIBDIR="${NETCDF_LIBDIR}"
0130 LIBS="-L${NETCDF_LIBDIR}"
1e25bc2551 Jean*0131 elif [[ -n $( nf-config --includedir 2> /dev/null ) && ($? == 0) ]] ; then
565472bb19 Raph*0132 # NETCDF env variables are not set, trying nf-config instead
0133 INCLUDEDIR=$( nf-config --includedir )
0134 INCLUDES="-I$INCLUDEDIR"
0135 LIBS=$( nf-config --flibs )
a55812cda4 Cons*0136 elif test -d /usr/include/netcdf-3 ; then
ff25ef6c6f Ed H*0137 INCLUDES='-I/usr/include/netcdf-3'
0138 LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3'
0139 elif test -d /usr/include/netcdf ; then
0140 INCLUDES='-I/usr/include/netcdf'
0141 elif test -d /usr/local/netcdf ; then
0142 INCLUDES='-I/usr/local/netcdf/include'
0143 LIBS='-L/usr/local/netcdf/lib'
a55812cda4 Cons*0144 elif test -d /usr/local/include/netcdf.inc ; then
0145 INCLUDES='-I/usr/local/include'
0146 LIBS='-L/usr/local/lib64'
81bb0f3fd4 Mart*0147 elif test -d /usr/include/netcdf.inc ; then
0148 INCLUDES='-I/usr/include'
0149 LIBS='-L/usr/lib64'
ff25ef6c6f Ed H*0150 fi
c474f7219d Jean*0151
7f6255c73a Oliv*0152 if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then
0153 MPI_INC_DIR="$MPI_HOME/include"
0154 fi
565472bb19 Raph*0155
0156 if [ "x$MPI" = xtrue ] ; then
0157 if [ -z "$MPI_INC_DIR" ] ; then
0158 # MPI env variables are not set, trying pkg-config insteal
d0b5b76295 Raph*0159 if [[ -n $( pkg-config --cflags-only-I ompi ) && ($? == 0) ]] ; then
003b422c78 Raph*0160 MPI_INC_DIR=$(pkg-config --cflags-only-I ompi | awk '{ print $1 }' | sed -e "s/-I//" )
0161 else
0162 echo MPI_HOME is not set and pkg-config not available, aborting
0163 exit 1
0164 fi
565472bb19 Raph*0165 fi
0166 if [ -n "$MPI_INC_DIR" ] ; then
0167 # only fill this if we can find MPI, otherwise triggers netcdf error
0168 INCLUDES+=" -I$MPI_INC_DIR"
0169 INCLUDEDIRS+=" $MPI_INC_DIR"
0170 #- used for parallel (MPI) DIVA
0171 MPIINCLUDEDIR="$MPI_INC_DIR"
0172 else
003b422c78 Raph*0173 echo could not set MPI_INC_DIR, aborting
565472bb19 Raph*0174 exit 1
0175 fi
c474f7219d Jean*0176 fi