Back to home page

MITgcm

 
 

    


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

view on githubraw file Latest commit 11d5e9fc on 2021-06-17 17:00:19 UTC
ff4c95725d Jean*0001 #!/bin/bash
                0002 #
15978f0412 Jean*0003 # tested on MacBook Pro with Snow Leopard & Snow Lion
ff4c95725d Jean*0004 # ==> need to update folowing comments:
                0005 # on 20-Nov-2009
                0006 # gcc and gfortran obtained from
                0007 # http://hpc.sourceforge.net/
                0008 # http://prdownloads.sourceforge.net/hpc/gcc-snwleo-intel-bin.tar.gz?download
                0009 # http://prdownloads.sourceforge.net/hpc/gfortran-snwleo-intel-bin.tar.gz?download
                0010 
                0011 #-------
                0012 # need to set NETCDF_ROOT to where the NetCDF is installed, e.g.:
                0013 #       export NETCDF_ROOT='/usr/NetCDF'
                0014 # MPI : need to set environment variable MPI_INC_DIR to the include
                0015 #       directory of your MPI implementation
                0016 
                0017 #-------
                0018 # run with OpenMP: needs to set environment var. OMP_NUM_THREADS
                0019 #    and generally, needs to increase the thread stack-size:
                0020 #   -  sh,bash:
                0021 #     > export OMP_NUM_THREADS=2
                0022 #     > export GOMP_STACKSIZE=400m
                0023 #   - csh,tcsh:
                0024 #     > setenv OMP_NUM_THREADS 2
                0025 #     > setenv GOMP_STACKSIZE 400m
                0026 #-------
                0027 
                0028 if test "x$MPI" = xtrue ; then
                0029   CC=mpicc
                0030   FC=mpif77
                0031   F90C=mpif90
                0032   LINK=$F90C
                0033 else
                0034   CC=gcc
                0035   FC=gfortran
                0036   F90C=gfortran
                0037   LINK=$F90C
                0038 fi
                0039 
                0040 FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _"
                0041 S64='$(TOOLSDIR)/set64bitConst.sh'
                0042 DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR'
                0043 CPP='/usr/bin/cpp -traditional -P'
                0044 GET_FC_VERSION="--version"
                0045 EXTENDED_SRC_FLAG='-ffixed-line-length-132'
                0046 OMPFLAG='-fopenmp'
                0047 
                0048 #MAKEDEPEND=tools_xmakedepend
                0049 
                0050 #Following flag is needed when using 32-bit gfortran with 64-bit gcc,
                0051 #as can be the case right after switching to Snow Leopard.
                0052 #CFLAGS='-arch i386'
                0053 
                0054 NOOPTFLAGS='-O0'
                0055 NOOPTFILES=''
                0056 
                0057 FFLAGS="$FFLAGS -fconvert=big-endian"
                0058 # for big objects:
                0059 #FFLAGS="$FFLAGS -fPIC"
                0060 #- might want to use '-fdefault-real-8' for fizhi pkg:
a7064d0a77 Jean*0061 #FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8"
ff4c95725d Jean*0062 
11d5e9fc04 Gael*0063 #- for setting specific options, check compiler version:
                0064 fcVers=`$FC -dumpversion | head -n 1 | sed 's/^[^0-9]* //;s/\..*$//'`
                0065 if ! [[ $fcVers =~ ^[0-9]+$ ]] ; then
                0066   echo "    un-recognized Compiler-version '$fcVers' ; ignored (-> set to 0)" ; fcVers=0 ;
                0067 else echo "    get Compiler-version: '$fcVers'" ; fi
                0068 
                0069 if [ $fcVers -ge 10 ] ; then
                0070   FFLAGS="$FFLAGS -fallow-argument-mismatch"
                0071 fi
                0072 
ff4c95725d Jean*0073 #  For IEEE, use the "-ffloat-store" option
                0074 if test "x$IEEE" = x ; then
                0075     FFLAGS="$FFLAGS -Wunused -Wuninitialized"
                0076     FOPTIM='-O3 -ftree-vectorize -funroll-loops'
                0077     NOOPTFLAGS='-O2 -funroll-loops'
62f0461069 Dimi*0078 #    NOOPTFILES='gad_c4_adv_x.F gad_u3_adv_x.F'
ff4c95725d Jean*0079 else
768556b997 Mart*0080     FFLAGS="$FFLAGS -Wall"
                0081     if test "x$DEVEL" = x ; then  #- no optimisation + IEEE :
                0082         FOPTIM='-O0'
                0083     else                          #- development/check options:
                0084         FOPTIM='-O0 -g -fbounds-check'
                0085         FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf"
                0086     fi
ff4c95725d Jean*0087 fi
                0088 
565472bb19 Raph*0089 F90FLAGS=$FFLAGS
                0090 F90OPTIM=$FOPTIM
                0091 
ff4c95725d Jean*0092 INCLUDEDIRS=''
                0093 INCLUDES=''
                0094 LIBS=''
                0095 
                0096 if [ "x$NETCDF_ROOT" != x ] ; then
                0097     INCLUDEDIR="${NETCDF_ROOT}/include"
                0098     INCLUDES="-I${NETCDF_ROOT}/include"
                0099     LIBDIR="${NETCDF_ROOT}/lib"
09726172f6 Raph*0100     LIBS="-L${NETCDF_ROOT}/lib -lnetcdf -lcurl"
565472bb19 Raph*0101 elif [ "x$NETCDF_HOME" != x ]; then
                0102     INCLUDEDIR="${NETCDF_HOME}/include"
                0103     INCLUDES="-I${NETCDF_HOME}/include"
                0104     LIBDIR="${NETCDF_HOME}/lib"
                0105     LIBS="-L${NETCDF_HOME}/lib"
                0106 elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then
                0107     NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'`
                0108     NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'`
                0109     INCLUDEDIR="${NETCDF_INC}"
                0110     INCLUDES="-I${NETCDF_INC}"
                0111     LIBDIR="${NETCDF_LIB}"
                0112     LIBS="-L${NETCDF_LIB}"
                0113 elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then
                0114     INCLUDEDIR="${NETCDF_INCDIR}"
                0115     INCLUDES="-I${NETCDF_INCDIR}"
                0116     LIBDIR="${NETCDF_LIBDIR}"
                0117     LIBS="-L${NETCDF_LIBDIR}"
d0b5b76295 Raph*0118 elif [[ -n $( nf-config --includedir ) && ($? == 0) ]] ; then
565472bb19 Raph*0119     # NETCDF env variables are not set, trying nf-config instead
                0120     INCLUDEDIR=$( nf-config --includedir )
                0121     INCLUDES="-I$INCLUDEDIR"
                0122     LIBS=$( nf-config --flibs )
                0123 elif test -d /usr/include/netcdf-3 ; then
                0124     INCLUDES='-I/usr/include/netcdf-3'
                0125     LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3'
                0126 elif test -d /usr/include/netcdf ; then
                0127     INCLUDES='-I/usr/include/netcdf'
                0128 elif test -d /usr/local/netcdf ; then
                0129     INCLUDES='-I/usr/local/netcdf/include'
                0130     LIBS='-L/usr/local/netcdf/lib'
                0131 elif test -d /usr/local/include/netcdf.inc ; then
                0132     INCLUDES='-I/usr/local/include'
                0133     LIBS='-L/usr/local/lib64'
                0134 elif test -d /usr/include/netcdf.inc ; then
                0135     INCLUDES='-I/usr/include'
                0136     LIBS='-L/usr/lib64'
                0137 fi
                0138 
                0139 if [ -n "$MPI_HOME" -a -z "$MPI_INC_DIR" ]; then
                0140     MPI_INC_DIR="$MPI_HOME/include"
ff4c95725d Jean*0141 fi
                0142 
565472bb19 Raph*0143 if [ "x$MPI" = xtrue ] ; then
                0144    if [ -z "$MPI_INC_DIR" ] ; then
                0145       # MPI env variables are not set, trying pkg-config insteal
d0b5b76295 Raph*0146       if [[ -n $( pkg-config --cflags-only-I ompi ) && ($? == 0) ]] ; then
003b422c78 Raph*0147          MPI_INC_DIR=$(pkg-config --cflags-only-I ompi | 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
565472bb19 Raph*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
003b422c78 Raph*0160       echo could not set MPI_INC_DIR, aborting
565472bb19 Raph*0161       exit 1
                0162    fi
ff4c95725d Jean*0163 fi
                0164