#!/bin/bash
#
#  $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_pgf77+mpi,v 1.3 2011/08/10 23:30:41 jmc Exp $
#  $Name:  $
#
# Build options for PGI compiler on Linux AMD64 platform
#
# tested with PGI version 11.7 on acesgrid cluster (Linux 2.6.38.8-35.fc15.x86_64), 
#   using:
#          module load pgi
#   and with mpich2:
#          module load mvapich2
#   or  with openmpi
#          module load openmpi
#-------

FC=mpif77
CC=mpicc
LINK=mpif77

DEFINES='-DWORDLENGTH=4 -DNML_EXTENDED_F77'
CPP='cpp -traditional -P'
EXTENDED_SRC_FLAG='-Mextend'
GET_FC_VERSION="-V"

NOOPTFLAGS='-O0'
NOOPTFILES=''

INCLUDEDIRS=''
INCLUDES=''
LIBS=''

if test "x$IEEE" = x ; then
    #  No need for IEEE-754
    FFLAGS="$FFLAGS -byteswapio -Ktrap=fp"
    FOPTIM='-tp k8-64 -pc=64 -O2 -Mvect=sse'
   #FOPTIM="$FOPTIM -fastsse -O3 -Msmart -Mvect=cachesize:1048576,transform"
else
    #  Try to follow IEEE-754
    FFLAGS="$FFLAGS -byteswapio -Ktrap=fp"
   #FFLAGS="$FFLAGS -Mdclchk"  #- pkg/zonal_filt does not pass with declaration-check
    FOPTIM='-pc=64 -O0 -Kieee'
fi
#- might want to use '-r8' for fizhi pkg:
#FFLAGS="$FFLAGS -r8"

if [ -n "$MPI_INC_DIR" ]; then
    INCLUDES="$INCLUDES -I$MPI_INC_DIR"
    INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR"
    MPIINCLUDEDIR="$MPI_INC_DIR"
    MPI_HEADER_FILES='mpif.h mpiof.h'
    MPI_HEADER_FILES_INC='./mpi_headers/mpif.h ./mpi_headers/mpiof.h'
fi
