# define F90 flag. The default is ifort ifort if not specified.
ifdef F90
   ifeq ($(F90),mpif90)
         F90FLAGS = -O3 
   endif
   ifeq ($(F90),pgf90)
         F90FLAGS = -O2 -mcmodel=medium
   endif
else
         F90 = mpif90
         F90FLAGS = -O3
         $(info The default compiler is Intel ifort ...)
endif


LDFLAGS=$(F90FLAGS)

SRCS =  mpi_primes_v0.f90        \
	mpi_primes_v1.f90        \
	mpi_primes_v2.f90        \
	mpi_primes_v3.f90        \
	mpi_primes_v4.f90        \
	mpi_primes_io_v0.f90     \
	mpi_primes_io_v1.f90     \
	mpi_primes_io_v2.f90     \
	mpi_matvec_elements.f90  \
	mpi_matvec_v0.f90        \
	mpi_matvec_v1.f90        \
	mpi_matvec_v2.f90        \
	mpi_matvec_v3.f90        \



OBJS =	$(SRCS:.f90=.o)
PROG =  $(SRCS:.f90=)

all: $(PROG)


clean:
	rm -f $(PROG) $(OBJS) *.mod *~

# clenaomod only remove *.o, *.mod, and *~ file. 
# Executable file is not removed.
cleanomod:
	rm -f $(OBJS) *.mod *~


%:%.f90
	$(F90) $(F90FLAGS) -o $@  $<

