#!/bin/bash
#
#  tested on frost, ce107 Aug 4 2005
#  using the following invocation:
#  ../../../tools/genmake2 -of=../../../tools/build_options/linux_ppc64_xlf
#  or with OpenMP:
#  ../../../tools/genmake2 -of=../../../tools/build_options/linux_ppc64_xlf -omp

#  Tested on Big Red, ce107 Aug 30 2007, need to set NETCDF_ROOT to:
#     > export NETCDF_ROOT='/N/soft/linux-sles9-ppc64/netcdf-3.6.1-ibm-64'
#     and at NCAR (on frost ?), need to set NETCDF_ROOT to:
#     > export NETCDF_ROOT='/contrib/fe_tools/xlc64/netcdf-3.6.0-p1'

if test "x$OMP" = xtrue ; then
  CC='xlc_r -q64 -qsmp=omp'
  FC='xlf_r -q64'
  LINK='xlf_r -q64'
else
  CC='xlc -q64'
  FC='xlf -q64'
  LINK='xlf -q64'
fi

FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X"
S64='$(TOOLSDIR)/set64bitConst.sh'
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR'
CPP='/lib/cpp -traditional -P'
OMPFLAG='-qsmp=omp'

#FFLAGS="$FFLAGS -qfixed=72"
FFLAGS="$FFLAGS -qfixed=132"

if test "x$IEEE" = x ; then
    #  No need for IEEE-754
    FOPTIM='-O5 -qarch=auto -qtune=auto -qcache=auto -qmaxmem=-1'
    FOPTIM="$FOPTIM -qipa=noobject:partition=large:threads"
    CFLAGS="-qinlglue $FOPTIM"
else
    FOPTIM='-O3 -qstrict -qarch=auto -qtune=auto -qcache=auto -qmaxmem=-1'
    CFLAGS=$FOPTIM
fi

INCLUDES=''
LIBS=''

if [ "x$NETCDF_ROOT" != x ] ; then
    INCLUDEDIR="${NETCDF_ROOT}/include"
    INCLUDES="-I${NETCDF_ROOT}/include"
    LIBDIR="${NETCDF_ROOT}/lib"
    LIBS="-L${NETCDF_ROOT}/lib"
fi
