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


LDFLAGS=$(F90FLAGS)

SRCS =  hello_f.f90              \
	mapping_threads_f.f90    \
	data_racing_f.f90        \
	threadprivate_v0_f.f90   \
	threadprivate_v1_f.f90   \
	threadprivate_v2_f.f90   \
	atomic_f.f90             \
	sections_f.f90           \
	single_f.f90             \
	firstprivate_v0_f.f90    \
	firstprivate_v1_f.f90    \
	privatevar_f.f90         \
	threaded_dgemm_mkl_f.f90 \
	nested_loops_v0_f.f90    \
	nested_loops_v1_f.f90    \
	nested_loops_v2_f.f90    \
	false_sharing_v0_f.f90   \
	false_sharing_v1_f.f90   \
	false_sharing_v2_f.f90   \
	false_sharing_v3_f.f90   \
	false_sharing_v4_f.f90   \
	loops_f.f90              \
	loops_out_f.f90          \
	sum_order_f.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 $@  $<

