#
# Declaration de l'extension
.SUFFIXES:.f90

# Compilateur et editeur de liens
FC         = xlf90_r
FLD        = $(FC)

RM         = /usr/bin/rm -f

#
# COMPILATION
#

# Options d'optimisation
OLEV       = -qhot -O3 -qtune=auto -qarch=auto -qcache=auto
FOPT       = -qstrict
FOPT       =

FMAX       = -qipa
FMAX       = 

# Options de parallelisation
OPAR       = -qsmp=omp

# Options de deboguage
ODEB       = -qnooptimize
FDEB       = -qcheck -qdbg -qextchk -qfullpath -qundef \
	-qflttrap=:ov:und:zero:inv:en -qinitauto=FF

# Options de portage
OPRT       = -qautodbl=dbl4 -qdpc=e
OPRT       = 

# Options d'entrees / sorties du compilateur
OES        = -qfree=f90 -qsuffix=f=f90

# Options de listing
OLST       = -qlistopt -qreport=hotlist -qsource
OLST       = 

# Options de profilage
PROF       = -pg -qfullpath -qdbg
PROF       = 

# Options compilation
FFLAGS     = $(OLEV) $(FOPT) $(FMAX) $(OPAR) $(OPRT) $(PROF) $(OES) $(OLST)

#
# EDITION DES LIENS
#

# Librairies Fortran
LIBS      = -lmass -lmassv -lessl -lm

# Option optimisation
LDLEV     = $(OLEV)

# Option de portage
LDREN     = -brename:.flush,.flush_
LDREN     = 

# Options memoire
LDMEM     = -bmaxdata:0x30000000 -blpdata

# Options editions des liens
LDFLAGS   = $(LDLEV) $(LDMEM) $(OPAR) $(LDREN) $(PROF)


# Includes Fortran
FHDRS      =

# objects Fortran
FOBJS      = \
		numerics.o \
		calcul.o\
		converge.o \
		domaine.o\
		erreur.o\
		initialisation.o\
		main.o

# sources Fortran
FSRCS      = \
		numerics.f90 \
		calcul.f90\
		converge.f90 \
		domaine.f90\
		erreur.f90\
		initialisation.f90\
		main.f90

# compilation Fortran
.f90.o:
	$(FC) $(FFLAGS) $< -c

# link Fortran
EXEC = H3Dja_omp.out
DEST = ../bin

all: 	$(FOBJS)
	$(FLD) $(LDFLAGS) $(FOBJS) $(LIBS) -o $(EXEC)
	mv $(EXEC) $(DEST)

# nettoyage
clean:
	$(RM) $(FOBJS) $(EXEC) *.mod

###
numerics.o: numerics.f90
	$(FC) -c $(FFLAGS) numerics.f90
calcul.o: calcul.f90 numerics.o
	$(FC) -c $(FFLAGS) calcul.f90
converge.o: converge.f90 numerics.o
	$(FC) -c $(FFLAGS) converge.f90
domaine.o: domaine.f90 numerics.o
	$(FC) -c $(FFLAGS) domaine.f90
erreur.o: erreur.f90 numerics.o
	$(FC) -c $(FFLAGS) erreur.f90
initialisation.o: initialisation.f90 numerics.o
	$(FC) -c $(FFLAGS) initialisation.f90
main.o  : main.f90 numerics.o
	$(FC) -c $(FFLAGS) main.f90
