#Makefile --- WMAP Likelihood code...

#CFITSIO=/usr/local
CFITSIO=/home/nolta/local

#
#			Non-test object files.
#
OBJS = read_archive_map.o \
       read_fits.o \
       WMAP_3yr_options.o \
       WMAP_3yr_util.o \
       WMAP_3yr_tt_pixlike.o \
       WMAP_3yr_tt_beam_and_ptsrc_corr.o \
       WMAP_3yr_teeebb_pixlike.o \
       WMAP_3yr_likelihood.o
#
#			General Commands.
#
DIFF = diff -w
RM = rm -f

# See the CHANGES files for a description of these options
WMAPFLAGS = -DFASTERTT -DOPTIMIZE #-DOPTIMIZE2 -DTIMING

#
#			Compiler/linker configuration.  Several samples
#			are supplied.
#
## SGI IRIX/MIPSpro-- gets the LAPACK functions from the system SCSL library.
#F90    = f90
#FFLAGS = -O -64 $(WMAPFLAGS)
#INCS   = -I. -I$(CFITSIO)/include 
#LIBS   = -L. -L$(CFITSIO)/lib -lcfitsio -lscs_mp

## SGI ProPack(Altix)/Intel -- gets the LAPACK functions from the system SCSL library.
#F90    = ifort
#FFLAGS = -O $(WMAPFLAGS)
#INCS   = -I. -I$(CFITSIO)/include
#LIBS   = -L. -L$(CFITSIO)/lib -lcfitsio -lscs_mp

## CITA McKenzie
F90     = ifort
FFLAGS  = -O $(WMAPFLAGS)
INCS    = -I. -I$(CFITSIO)/include
LIBS    = -L. -L$(CFITSIO)/lib -lcfitsio -llapack -L$(MCKENZIE_GOTO_LIB_PATH) -lgoto -lpthread

## NAG
#F90	 = f95
#FFLAGS  = -g -O2 -kind=byte -colour $(WMAPFLAGS)
#INCS	 = -I. -I$(CFITSIO)/include -I<lapack path>/include
#LIBS	 = -L. -L$(CFITSIO)/lib -L<lapack path>/lib -llapack -lcfitsio

## MacOS X, G5 hardware
#F90 = <path to compiler>/xlf90 
#FFLAGS  = -qsuffix=f=f90:cpp=F90 -qstrict -qmaxmem=-1 \
#          -qarch=auto -qtune=auto -qunroll=auto -framework Accelerate -O2 \
#          $(WMAPFLAGS)
#INCS = -I. -I$(CFITSIO)/include
#LIBS = -L$(CFITSIO)/lib -lcfitsio -lm -lSystemStubs

## MacOS X, G4 hardware
#F90 = <path to compiler>/xlf90 
#FFLAGS  = -qsuffix=f=f90:cpp=F90 -qstrict -qmaxmem=-1 \
#          -qarch=auto -qtune=auto -qunroll=auto -framework Accelerate -O2 \
#          $(WMAPFLAGS)
#INCS = -I. -I$(CFITSIO)/include
#LIBS = -L$(CFITSIO)/lib -lcfitsio

## PGF90 -- Portland Group compiler.
#F90    = <path to compiler>/pgf90
#FFLAGS = -fast $(WMAPFLAGS)
#INCS   = <-DMPI if using mpi> -I<your mpi path>/include \
#         -I$(CFITSIO)/include
#LIBS   = -L. -L/usr/local/lib -l$(LLIB) \
#         -L<your cfitsio library path>/lib -L<your lapack/blas library path>/lib \
#         -L<other library path>/lib -llapack -lcfitsio -lblas -l<other libraries, e.g. mpi>
#
#			Rules.
#
all: test

test: $(OBJS) test.o
	$(F90) $(FFLAGS) -o $@ $(OBJS) test.o $(LIBS)

check: test
	./test | tee output.log
	$(DIFF) output.log output.std

%.o: %.f90
	$(F90) $(FFLAGS) $(INCS) -c -o $@ $<

%.o: %.F90
	$(F90) $(FFLAGS) $(INCS) -c -o $@ $<

clean:
	$(RM) *.o *.mod *.log *~

distclean: clean
	$(RM) test

