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 c7a06a2c on 2024-10-17 22:00:10 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"
                0045 # for big objects:
                0046 #FFLAGS="$FFLAGS -fPIC"
                0047 #- might want to use '-fdefault-real-8' for fizhi pkg:
                0048 #FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8"
                0049 
                0050 #- for setting specific options, check compiler version:
                0051 fcVers=`$FC -dumpversion | head -n 1 | sed 's/^[^0-9]* //;s/\..*$//'`
                0052 if ! [[ $fcVers =~ ^[0-9]+$ ]] ; then
                0053   echo "    un-recognized Compiler-version '$fcVers' ; ignored (-> set to 0)" ; fcVers=0 ;
                0054 else echo "    get Compiler-version: '$fcVers'" ; fi
                0055 
                0056 if [ $fcVers -ge 10 ] ; then
                0057   FFLAGS="$FFLAGS -fallow-argument-mismatch"
                0058 fi
                0059 
                0060 #  For IEEE, use the "-ffloat-store" option
                0061 if test "x$IEEE" = x ; then
                0062     FFLAGS="$FFLAGS -Wunused -Wuninitialized"
                0063     FOPTIM='-O3 -ftree-vectorize -funroll-loops'
                0064     NOOPTFLAGS='-O2 -funroll-loops'
                0065 #    NOOPTFILES='gad_c4_adv_x.F gad_u3_adv_x.F'
                0066 else
                0067     FFLAGS="$FFLAGS -Wall"
                0068     if test "x$DEVEL" = x ; then  #- no optimisation + IEEE :
                0069         FOPTIM='-O0'
                0070     else                          #- development/check options:
                0071         FOPTIM='-O0 -g -fbounds-check'
                0072         FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf"
                0073     fi
                0074 fi
                0075 
c7a06a2c29 Mart*0076 # add undocumented flag -x f95 to force gfortran to interpret any
                0077 # suffix as a f90-freeformat file, add -ffree-form to suppress the
                0078 # associated warning
                0079 F90FLAGS="$FFLAGS -x f95 -ffree-form"
fefbff5637 Mart*0080 F90OPTIM=$FOPTIM
                0081 
                0082 INCLUDEDIRS=''
                0083 INCLUDES=''
                0084 LIBS=''
                0085 
                0086 if [ "x$NETCDF_ROOT" != x ] ; then
                0087     INCLUDEDIR="${NETCDF_ROOT}/include"
                0088     INCLUDES="-I${NETCDF_ROOT}/include"
                0089     LIBDIR="${NETCDF_ROOT}/lib"
                0090     LIBS="-L${NETCDF_ROOT}/lib -lnetcdf -lcurl"
                0091 elif [ "x$NETCDF_HOME" != x ]; then
                0092     INCLUDEDIR="${NETCDF_HOME}/include"
                0093     INCLUDES="-I${NETCDF_HOME}/include"
                0094     LIBDIR="${NETCDF_HOME}/lib"
                0095     LIBS="-L${NETCDF_HOME}/lib"
                0096 elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then
                0097     NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'`
                0098     NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'`
                0099     INCLUDEDIR="${NETCDF_INC}"
                0100     INCLUDES="-I${NETCDF_INC}"
                0101     LIBDIR="${NETCDF_LIB}"
                0102     LIBS="-L${NETCDF_LIB}"
                0103 elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then
                0104     INCLUDEDIR="${NETCDF_INCDIR}"
                0105     INCLUDES="-I${NETCDF_INCDIR}"
                0106     LIBDIR="${NETCDF_LIBDIR}"
                0107     LIBS="-L${NETCDF_LIBDIR}"
                0108 elif [[ -n $( nf-config --includedir ) && ($? == 0) ]] ; then
                0109     # NETCDF env variables are not set, trying nf-config instead
                0110     INCLUDEDIR=$( nf-config --includedir )
                0111     INCLUDES="-I$INCLUDEDIR"
                0112     # although this would is the best option, the resulting -arch arm64 is
                0113     # not supported by gfortran from hpc.sourceforge.net
                0114     LIBS=$( nf-config --flibs )
                0115     # if FC=gfortran from hpc.sourceforge.net, then this works:
                0116     # LIBDIR=$( nf-config --prefix )/lib
                0117     # LIBS="-L$LIBDIR"
                0118 elif test -d /opt/local/include ; then
                0119     # if netcdf has been install by macports, this is where it is:
                0120     INCLUDES='-I/opt/local/include'
                0121     LIBS='-L/opt/local/lib'
                0122 elif test -d /usr/include/netcdf-3 ; then
                0123     INCLUDES='-I/usr/include/netcdf-3'
                0124     LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3'
                0125 elif test -d /usr/include/netcdf ; then
                0126     INCLUDES='-I/usr/include/netcdf'
                0127 elif test -d /usr/local/netcdf ; then
                0128     INCLUDES='-I/usr/local/netcdf/include'
                0129     LIBS='-L/usr/local/netcdf/lib'
                0130 elif test -d /usr/local/include/netcdf.inc ; then
                0131     INCLUDES='-I/usr/local/include'
                0132     LIBS='-L/usr/local/lib64'
                0133 elif test -d /usr/include/netcdf.inc ; then
                0134     INCLUDES='-I/usr/include'
                0135     LIBS='-L/usr/lib64'
                0136 fi
                0137 
                0138 if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then
                0139     MPI_INC_DIR="$MPI_HOME/include"
                0140 fi
                0141 
                0142 if [ "x$MPI" = xtrue ] ; then
                0143    if [ -z "$MPI_INC_DIR" ] ; then
                0144       # MPI env variables are not set, trying pkg-config insteal
                0145       # this works for macport installs of openmpi
                0146       if [[ -n $( pkg-config --cflags-only-I mpich ) && ($? == 0) ]] ; then
                0147          MPI_INC_DIR=$(pkg-config --cflags-only-I mpich | awk '{ print $1 }' | sed -e "s/-I//" )
                0148       else
                0149          echo MPI_HOME is not set and pkg-config not available, aborting
                0150          exit 1
                0151       fi
                0152    fi
                0153    if [ -n "$MPI_INC_DIR" ] ; then
                0154       # only fill this if we can find MPI, otherwise triggers netcdf error
                0155       INCLUDES+=" -I$MPI_INC_DIR"
                0156       INCLUDEDIRS+=" $MPI_INC_DIR"
                0157       #- used for parallel (MPI) DIVA
                0158       MPIINCLUDEDIR="$MPI_INC_DIR"
                0159    else
                0160       echo could not set MPI_INC_DIR, aborting
                0161       exit 1
                0162    fi
                0163 fi