#!/bin/bash
#
#  $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_g77,v 1.8 2011/05/16 19:03:37 jmc Exp $
#  $Name:  $
#
# Build options for Suse 9 Opteron
# tested on Linux 2.4.21-102-smp (x86_64), 
#           Linux 2.6.26.8-57.fc8 (x86_64), Linux 2.6.27.9-159.fc10.x86_64
#

FC=g77
CC=gcc34
DEFINES='-D_BYTESWAPIO -DWORDLENGTH=4 -DNML_EXTENDED_F77'
CPP='cpp  -traditional -P'
NOOPTFLAGS='-O0'
EXTENDED_SRC_FLAG='-ffixed-line-length-132'
GET_FC_VERSION="--version"

#  For IEEE, use the "-ffloat-store" option
if test "x$IEEE" = x ; then
    FFLAGS='-Wimplicit -Wunused -Wuninitialized'
    FOPTIM='-O3 -funroll-loops'
else
    FFLAGS='-Wimplicit -Wunused -ffloat-store'
#   FFLAGS="$FFLAGS -g -mfpmath=sse -msse -msse2 -fbounds-check"
    FOPTIM='-O0'
fi
# for big objects:
FFLAGS="$FFLAGS -fPIC"
CFLAGS="-O0 -fPIC"

if test -d /usr/include/netcdf-3 ; then
#-- some FedoraCore standard location used to be "netcdf-3"
    INCLUDES='-I/usr/include/netcdf-3'
    if test -d /usr/lib64/netcdf-3 ; then
        if test -f /usr/lib64/netcdf-3/libnetcdf_g77.a ; then
            LIBS='-L/usr/lib64/netcdf-3 -lnetcdf_g77'
        else
            LIBS='-L/usr/lib64/netcdf-3'
        fi
    elif test -d /usr/lib/netcdf-3 ; then
        if test -f /usr/lib/netcdf-3/libnetcdf_g77.a ; then
            LIBS='-L/usr/lib/netcdf-3 -lnetcdf_g77'
        else
            LIBS='-L/usr/lib/netcdf-3'
        fi
    fi
elif test -d /usr/include/netcdf -o -f /usr/include/netcdf.h ; then
#-- allows a "compat"(gcc 3.4) 2nd version of libs for g77 , next to the
#   standard one (for gfortran, gcc 4.x). But uses same include files.
    if test -d /usr/include/netcdf ; then
       INCLUDES='-I/usr/include/netcdf'
    fi
    if test -d /usr/lib64/netcdf34 ; then
        if test -f /usr/lib64/netcdf34/libnetcdf_g77.a ; then
            LIBS='-L/usr/lib64/netcdf34 -lnetcdf_g77'
        else
            LIBS='-L/usr/lib64/netcdf34'
        fi
    elif test -d /usr/lib/netcdf34 ; then
        if test -f /usr/lib/netcdf34/libnetcdf_g77.a ; then
            LIBS='-L/usr/lib/netcdf34 -lnetcdf_g77'
        else
            LIBS='-L/usr/lib/netcdf34'
        fi
    fi
elif test -d /usr/local/netcdf ; then
    INCLUDES='-I/usr/local/netcdf/include'
    LIBS='-L/usr/local/netcdf/lib'
fi

