Back to home page

MITgcm

 
 

    


Warning, /tools/build_options/linux_amd64_gfortran_albedo is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit c5638583 on 2023-02-07 23:00:11 UTC
c563858366 Mart*0001 #!/bin/bash
                0002 
                0003 # Build options for gfortran compiler (GNU) on Linux amd64 platform albedo (@AWI)
                0004 #
                0005 #  Tested with gcc-gfortran v12.1.0 loading the following modules
                0006 #
                0007 # module purge
                0008 # module load gcc
                0009 # module load openmpi/4.1.3
                0010 # module load netcdf-fortran/4.5.4-openmpi4.1.3-gcc12.1.0
                0011 # albedo0::> module list
                0012 # Currently Loaded Modulefiles:
                0013 #  1) gcc/12.1.0   2) openmpi/4.1.3
                0014 #  3) netcdf-fortran/4.5.4-openmpi4.1.3-oneapi2022.1.0
                0015 #
                0016 
                0017 if test "x$MPI" = xtrue ; then
                0018   CC=mpicc
                0019   FC=mpif77
                0020   F90C=mpif90
                0021 else
                0022   CC=gcc
                0023   FC=gfortran
                0024   F90C=gfortran
                0025 fi
                0026 
                0027 DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR'
                0028 EXTENDED_SRC_FLAG='-ffixed-line-length-132'
                0029 F90FIXEDFORMAT='-ffixed-form'
                0030 GET_FC_VERSION="--version"
                0031 OMPFLAG='-fopenmp'
                0032 
                0033 NOOPTFLAGS='-O0'
                0034 NOOPTFILES=''
                0035 
                0036 CFLAGS='-O0'
                0037 
                0038 #- for setting specific options, check compiler version:
                0039 fcVers=`$CC -dumpversion | head -n 1 | sed 's/^[^0-9]* //;s/\..*$//'`
                0040 if ! [[ $fcVers =~ ^[0-9]+$ ]] ; then
                0041   echo "    un-recognized compiler-version '$fcVers' ; ignored (-> set to 0)" ; fcVers=0 ;
                0042 else echo "    get compiler-version: '$fcVers'" ; fi
                0043 
                0044 if [ $fcVers -ge 10 ] ; then
                0045   FFLAGS="$FFLAGS -fallow-argument-mismatch"
                0046 fi
                0047 #- Requires gfortran from 2006 onwards for -fconvert=big-endian
                0048 FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none"
                0049 #- for big setups, compile & link with "-fPIC" or set memory-model to "medium":
                0050 #CFLAGS="$CFLAGS -fPIC"
                0051 #FFLAGS="$FFLAGS -fPIC"
                0052 #-  with FC 19, need to use this without -fPIC (which cancels -mcmodel option):
                0053 CFLAGS="$CFLAGS -mcmodel=medium"
                0054 FFLAGS="$FFLAGS -mcmodel=medium"
                0055 #- might want to use '-fdefault-real-8' for fizhi pkg:
                0056 #FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8"
                0057 #- speeds up compilation at the cost of more memory overhead
                0058 FFLAGS="$FFLAGS -pipe"
                0059 
                0060 if test "x$IEEE" = x ; then     #- with optimisation:
                0061     #- full optimisation
                0062     FOPTIM='-march=core-avx2 -mtune=core-avx2 -funroll-loops'
                0063     # -O3 is generally not recommended, so we use -O2 with -ftree-vectorize
                0064     # as the default
                0065     #FOPTIM="$FOPTIM -O3"
                0066     #- can use -O2 (safe optimisation) to avoid Pb with some gcc version of -O3:
                0067     FOPTIM="$FOPTIM -O2 -ftree-vectorize"
                0068     NOOPTFILES="$NOOPTFILES ini_masks_etc.F"
                0069 else
                0070    # these may also be useful, but require specific gfortran versions:
                0071    # -Wnonstd-intrinsics        for gfortran <= 4.3
                0072    # -Wintrinsics-std           for gfortran >= 4.4
                0073    # -Wno-tabs                  for gfortran >= 4.3
                0074    # -Wno-unused-dummy-argument for gfortran >= 4.6
                0075    #FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation"
                0076    #- or simply:
                0077     FFLAGS="$FFLAGS -Wall"
                0078     if [ $fcVers -ge 10 ] ; then
                0079       FFLAGS="$FFLAGS -Wno-unused-dummy-argument"
                0080     fi
                0081    #- to get plenty of warnings: -Wall -Wextra (older form: -Wall -W) or:
                0082    #FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels"
                0083   if test "x$DEVEL" = x ; then  #- no optimisation + IEEE :
                0084     FOPTIM='-O0'
                0085   else                          #- development/check options:
                0086     FOPTIM='-O0 -g -fbounds-check'
                0087     FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf"
                0088   fi
                0089 fi
                0090 
                0091 F90FLAGS=$FFLAGS
                0092 F90OPTIM=$FOPTIM
                0093 
                0094 INCLUDEDIRS=''
                0095 INCLUDES=''
                0096 LIBS=''
                0097 
                0098 if [[ -n $( nf-config --fflags )  && ($? == 0) ]]; then
                0099     INCLUDES=$(nf-config --fflags)
                0100 #    LIBS=$(nf-config --flibs)
                0101     LIBS="-L$(nf-config --prefix)/lib -lnetcdff"
                0102 fi
                0103 
                0104 if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then
                0105     MPI_INC_DIR="$MPI_HOME/include"
                0106 fi
                0107 
                0108 if [ "x$MPI" = xtrue ] ; then
                0109    if [ -z "$MPI_INC_DIR" ] ; then
                0110       # MPI env variables are not set, trying pkg-config insteal
                0111       if [[ -n $( pkg-config --cflags-only-I ompi ) && ($? == 0) ]] ; then
                0112          MPI_INC_DIR=$(pkg-config --cflags-only-I ompi | awk '{ print $1 }' | sed -e "s/-I//" )
                0113       else
                0114          echo MPI_HOME is not set and pkg-config not available, aborting
                0115          exit 1
                0116       fi
                0117    fi
                0118    if [ -n "$MPI_INC_DIR" ] ; then
                0119       # only fill this if we can find MPI, otherwise triggers netcdf error
                0120       INCLUDES+=" -I$MPI_INC_DIR"
                0121       INCLUDEDIRS+=" $MPI_INC_DIR"
                0122       #- used for parallel (MPI) DIVA
                0123       MPIINCLUDEDIR="$MPI_INC_DIR"
                0124    else
                0125       echo could not set MPI_INC_DIR, aborting
                0126       exit 1
                0127    fi
                0128 fi