Back to home page

MITgcm

 
 

    


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

view on githubraw file Latest commit e2eee477 on 2025-04-09 09:31:24 UTC
fefbff5637 Mart*0001 #!/bin/bash
                0002 #
                0003 # tested on MacBook Pro with macOS Monterey
                0004 # uname -a
                0005 # Darwin bkli04m056 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64
                0006 # gcc, gfortran, netcdf/netcdf-fortran, and openmpi obtained from
                0007 # https://www.macports.org
                0008 # sudo port install gcc11
                0009 # sudo port select --set gcc mp-gcc11
                0010 # similar results can be achieved using homebrew
                0011 
                0012 # Note: at the time of creating this file (Mar2022), the
                0013 # gfortran-build of http://hpc.sourceforge.net does not work with
                0014 # testreport (also: cannot compile like the "etime" test and leads to
                0015 # multile warnings at the link step), because the model compiled with
                0016 # this gfortran does not print the last line before the stop statement
                0017 # without an additional flush-statement.
                0018 
                0019 if test "x$MPI" = xtrue ; then
                0020   CC=mpicc
                0021   FC=mpif77
                0022   F90C=mpif90
                0023   LINK=$F90C
                0024 else
                0025   CC=gcc
                0026   FC=gfortran
                0027   F90C=gfortran
                0028   LINK=$F90C
                0029 fi
                0030 
                0031 FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _"
                0032 S64='$(TOOLSDIR)/set64bitConst.sh'
                0033 DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR'
                0034 CPP='/usr/bin/cpp -traditional -P'
                0035 GET_FC_VERSION="--version"
                0036 EXTENDED_SRC_FLAG='-ffixed-line-length-132'
                0037 OMPFLAG='-fopenmp'
                0038 
                0039 #MAKEDEPEND=tools_xmakedepend
                0040 
                0041 NOOPTFLAGS='-O0'
                0042 NOOPTFILES=''
                0043 
                0044 FFLAGS="$FFLAGS -fconvert=big-endian"
e2eee4773e mjlo*0045 # needed for big objects (e.g., to compile and run TAF AD of
                0046 # global_ocean.cs32x15), but requires larger stack sizes (set with
                0047 # ulimit -s) in other cases, so we leave this commented out:
                0048 # man gfortran: Allow indirect recursion by forcing all local arrays
                0049 #               to be allocated on the stack.
                0050 #FFLAGS="$FFLAGS -frecursive"
fefbff5637 Mart*0051 #- might want to use '-fdefault-real-8' for fizhi pkg:
                0052 #FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8"
                0053 
                0054 #- for setting specific options, check compiler version:
                0055 fcVers=`$FC -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
                0063 
                0064 #  For IEEE, use the "-ffloat-store" option
                0065 if test "x$IEEE" = x ; then
                0066     FFLAGS="$FFLAGS -Wunused -Wuninitialized"
                0067     FOPTIM='-O3 -ftree-vectorize -funroll-loops'
                0068     NOOPTFLAGS='-O2 -funroll-loops'
                0069 #    NOOPTFILES='gad_c4_adv_x.F gad_u3_adv_x.F'
                0070 else
                0071     FFLAGS="$FFLAGS -Wall"
                0072     if test "x$DEVEL" = x ; then  #- no optimisation + IEEE :
                0073         FOPTIM='-O0'
                0074     else                          #- development/check options:
                0075         FOPTIM='-O0 -g -fbounds-check'
                0076         FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf"
                0077     fi
                0078 fi
                0079 
c7a06a2c29 Mart*0080 # add undocumented flag -x f95 to force gfortran to interpret any
                0081 # suffix as a f90-freeformat file, add -ffree-form to suppress the
                0082 # associated warning
                0083 F90FLAGS="$FFLAGS -x f95 -ffree-form"
fefbff5637 Mart*0084 F90OPTIM=$FOPTIM
                0085 
                0086 INCLUDEDIRS=''
                0087 INCLUDES=''
                0088 LIBS=''
                0089 
                0090 if [ "x$NETCDF_ROOT" != x ] ; then
                0091     INCLUDEDIR="${NETCDF_ROOT}/include"
                0092     INCLUDES="-I${NETCDF_ROOT}/include"
                0093     LIBDIR="${NETCDF_ROOT}/lib"
                0094     LIBS="-L${NETCDF_ROOT}/lib -lnetcdf -lcurl"
                0095 elif [ "x$NETCDF_HOME" != x ]; then
                0096     INCLUDEDIR="${NETCDF_HOME}/include"
                0097     INCLUDES="-I${NETCDF_HOME}/include"
                0098     LIBDIR="${NETCDF_HOME}/lib"
                0099     LIBS="-L${NETCDF_HOME}/lib"
                0100 elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then
                0101     NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'`
                0102     NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'`
                0103     INCLUDEDIR="${NETCDF_INC}"
                0104     INCLUDES="-I${NETCDF_INC}"
                0105     LIBDIR="${NETCDF_LIB}"
                0106     LIBS="-L${NETCDF_LIB}"
                0107 elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then
                0108     INCLUDEDIR="${NETCDF_INCDIR}"
                0109     INCLUDES="-I${NETCDF_INCDIR}"
                0110     LIBDIR="${NETCDF_LIBDIR}"
                0111     LIBS="-L${NETCDF_LIBDIR}"
                0112 elif [[ -n $( nf-config --includedir ) && ($? == 0) ]] ; then
                0113     # NETCDF env variables are not set, trying nf-config instead
                0114     INCLUDEDIR=$( nf-config --includedir )
                0115     INCLUDES="-I$INCLUDEDIR"
                0116     # although this would is the best option, the resulting -arch arm64 is
                0117     # not supported by gfortran from hpc.sourceforge.net
                0118     LIBS=$( nf-config --flibs )
                0119     # if FC=gfortran from hpc.sourceforge.net, then this works:
                0120     # LIBDIR=$( nf-config --prefix )/lib
                0121     # LIBS="-L$LIBDIR"
                0122 elif test -d /opt/local/include ; then
                0123     # if netcdf has been install by macports, this is where it is:
                0124     INCLUDES='-I/opt/local/include'
                0125     LIBS='-L/opt/local/lib'
                0126 elif test -d /usr/include/netcdf-3 ; then
                0127     INCLUDES='-I/usr/include/netcdf-3'
                0128     LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3'
                0129 elif test -d /usr/include/netcdf ; then
                0130     INCLUDES='-I/usr/include/netcdf'
                0131 elif test -d /usr/local/netcdf ; then
                0132     INCLUDES='-I/usr/local/netcdf/include'
                0133     LIBS='-L/usr/local/netcdf/lib'
                0134 elif test -d /usr/local/include/netcdf.inc ; then
                0135     INCLUDES='-I/usr/local/include'
                0136     LIBS='-L/usr/local/lib64'
                0137 elif test -d /usr/include/netcdf.inc ; then
                0138     INCLUDES='-I/usr/include'
                0139     LIBS='-L/usr/lib64'
                0140 fi
                0141 
                0142 if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then
                0143     MPI_INC_DIR="$MPI_HOME/include"
                0144 fi
                0145 
                0146 if [ "x$MPI" = xtrue ] ; then
                0147    if [ -z "$MPI_INC_DIR" ] ; then
                0148       # MPI env variables are not set, trying pkg-config insteal
                0149       # this works for macport installs of openmpi
                0150       if [[ -n $( pkg-config --cflags-only-I mpich ) && ($? == 0) ]] ; then
                0151          MPI_INC_DIR=$(pkg-config --cflags-only-I mpich | awk '{ print $1 }' | sed -e "s/-I//" )
                0152       else
                0153          echo MPI_HOME is not set and pkg-config not available, aborting
                0154          exit 1
                0155       fi
                0156    fi
                0157    if [ -n "$MPI_INC_DIR" ] ; then
                0158       # only fill this if we can find MPI, otherwise triggers netcdf error
                0159       INCLUDES+=" -I$MPI_INC_DIR"
                0160       INCLUDEDIRS+=" $MPI_INC_DIR"
                0161       #- used for parallel (MPI) DIVA
                0162       MPIINCLUDEDIR="$MPI_INC_DIR"
                0163    else
                0164       echo could not set MPI_INC_DIR, aborting
                0165       exit 1
                0166    fi
                0167 fi