# 
# PURPOSE:   MAKEFILE FOR GNU/Linux SPIDER using FFTW3 with MPI on Opteron 64 
# 
# COMPILER:  Portland Group F95 compiler  & OpenMPI
# TARGET:    AMD Opteron 64 (x86_64) running GNU/Linux 
# IMAGES:    Optimal SPIDER image byte order:   Big-endian (SGI) (Non-native) 
# USAGE:     make -f Makefile_linux_mpi_opt64 
#
# NOTE:     Uses FFTW3 configured with: --enable-float --enable-type-prefix
# NOTE:     You may ignore any undefined QFFLAGS, QLFLAGS & SUFFIX
#
# WARNING: Using 'gethostbyname'  & 'getpwuid' from MPI in statically linked applications 
#          requires runtime shared libraries from the glibc version used for linking

SHELL    = /bin/sh

AFLAGS   = r

# Location of compiler for use with openmpi (OpenMPI sets link to PGI compiler when OpenMPI installed) 
# LAM-MPI does not provide a separate mpif90.  When installing LAM-MPI
# one has to specify either pgf90 or ifc as the backend compiler for mpif77.
#COMP    = /usr/pgi7.2/linux86-64/7.2/mpi/mpich/bin/mpif90 -I /usr/pgi7.2/linux86-64/7.2/mpi/mpich/include
#COMP    = /usr8/repository/openmpi-1.3.3/bin/mpif90 
 COMP    = /usr8/repository/openmpi-1.2.8/bin/mpif90 

PGM      = spider

WHICH    = mpi_opt64

EXE      = $(PGM)_linux_$(WHICH)$(SUFFIX)

LIB      = $(EXE).a

FFLAGS   = -DUSE_MPI -tp k8-64 -fastsse -mcmodel=medium -O2 -Mpreprocess -Kieee -Minfo -byteswapio -DSP_LIBFFTW3  -c  

LF       = -tp k8-64 -fastsse -mcmodel=medium $(QLFLAGS)

# FFTW3 static library location
FFTWLIBDIR = ../fftw/fftw3-opt64/lib

# MPI library location
#MPILIBDIR = /usr/pgi7.2/linux86-64/7.2/mpi/mpich/lib
#MPILIBDIR = /usr8/repository/openmpi-1.3.3/lib
 MPILIBDIR = /usr8/repository/openmpi-1.2.8/lib

# Could not fully link with MPI static libraries and with math library GAVE UP ON STATIC
LINKLIBS  =  -Bstatic_pgi -L$(FFTWLIBDIR) -lfftw3f -lfftw3f_threads -L$(MPILIBDIR) -lmpi -lm 

.PRECIOUS :  ../bin/$(EXE) $(LIB)

include Makefile.inc

include Makebody.inc

