.SUFFIXES: .f90 .f .F .c .o
.f90.o:
    $(FC) $(FFLAGS) -c $<
.f.o:
    $(FC77) $(F77FLAGS) -c $<
.F.o:
    $(FC) $(FFLAGS) $(CPPFLAGS) -c $<
.c.o:
    $(CC) $(CFLAGS) -c $<
#................................................
#    Compilers, linkers and libraries
#................................................
FC=ifort
FC77=ifort
LFLAGS =-O3
FFLAGS =-O3
F77FLAGS=-I /opt/cluster/intel/mkl9.0/include
MKLPATH7.2 =/opt/cluster/intel/mkl7.2/mkl72/lib/32/
LIBS7.2=$(MKLPATH7.2)/libmkl_lapack.a $(MKLPATH7.2)/libmkl_p4.so
MKLPATH9.0=/opt/cluster/intel/mkl9.0/lib/em64t
LIBS9.0=-L$(MKLPATH9.0) -lmkl_lapack -lmkl_em64t -lmkl
CSTANDLIB=-lm
CC=icc
CFLAGS=-O3 -I /opt/cluster/intel/mkl9.0/include
#................................................
#             Object files
#................................................
OBJ_VSL=mkl_vsl.o
OBJ1=mymodule.o test1.o
OBJ2=test2.o
OBJ3=test3.o
OBJ4=test_rand.o
OBJ5=test_rand_lib.o
OBJ6=fort_rand.o
OBJ7=$(OBJ_VSL) fort_rand_lib.o
#................................................
#      How to compile whole program
#................................................
All:$ test1.x test2.x testlib.x test_rand.x test_rand_lib.x\
     fort_rand.x fort_rand_lib.x
clear:
    rm -f *.o *.mod *~
#................................................
#       Fortran file dependencies
#................................................
fort_rand_lib.x:$ mkl_vsl_type.mod
#................................................
#              Linking
#................................................
test1.x:$ $(OBJ1) #
    $(FC) -o $@ $(OBJ1) $(LFLAGS)
test2.x:$ $(OBJ2) #
    $(FC) -o $@ $(OBJ2) $(LFLAGS)
testlib.x:$ $(OBJ3) #
    $(FC) -o $@ $(OBJ3) $(LFLAGS) $(LIBS9.0)
test_rand.x:$ $(OBJ4) #
    $(CC) -o $@ $(OBJ4) $(CSTANDLIB)
test_rand_lib.x:$ $(OBJ5) #
    $(CC) -o $@ $(OBJ5) $(CSTANDLIB) $(LIBS9.0)
fort_rand.x:$ $(OBJ6) #
    $(FC) -o $@ $(OBJ6)
fort_rand_lib.x:$ $(OBJ7) #
    $(FC) -o $@ $(OBJ7) $(LIBS9.0)