# Makefile pour compiler le code d'advection-diffusion
# Code issu du bureau d'etudes Volumes Finis du departement hydraulique de l'ENSEEIHT
# IMFT - Service Cosinus
# A. Pedrono & H. Neau

FC = gfortran
OPT = #-g -O0 -fbounds-check

# Pour "brancher" VisIt, mettre BUILD_VISIT=1
BUILD_VISIT=1
VISIT_DIR=/PRODCOM/VISIT/visit2_12_0.linux-x86_64/

VISIT_INCDIR = -I$(VISIT_DIR)/2.12.0/linux-x86_64/libsim/V2/include
VISIT_LIBS = -L$(VISIT_DIR)/2.12.0/linux-x86_64/libsim/V2/lib -lsimV2 -lsimV2f -lstdc++ -Wl,--no-as-needed -ldl

EXE = advdiff.x
OBJS = modules.o prog.o lecture.o creer_maillage.o vitesse.o pas_de_temps.o initialisation.o \
       calcul_advection.o calcul_diffusion.o calcul_advection_diffusion.o mainloop.o simulate_one_timestep.o 

# Bibliotheques et includes VisIt
ifeq ($(BUILD_VISIT),1)
       DEFINE += -DUSE_VISIT
       OBJS += simulationexamplev2.o prog_InSitu.o
       LIBS += $(VISIT_LIBS)
       INCLUDE += $(VISIT_INCDIR)
       EXE = advdiff_batch.x
endif

exe:	$(OBJS) 
	$(FC) $(OPT) $(OBJS) $(INCLUDE) $(LIBS) -o $(EXE)
	
modules.o:	modules.f90
	$(FC) $(OPT) modules.f90 -c
	
prog.o:	prog.f90
	$(FC) $(OPT) prog.f90 -c
	
mainloop.o:		mainloop.F90
	$(FC) $(OPT) $(INCLUDE) $(DEFINE) mainloop.F90 -c
	
lecture.o:		lecture.f90
	$(FC) $(OPT) lecture.f90 -c

creer_maillage.o:		creer_maillage.f90
	$(FC) $(OPT) creer_maillage.f90 -c
	
vitesse.o:		vitesse.f90
	$(FC) $(OPT) vitesse.f90 -c
	
pas_de_temps.o:		pas_de_temps.f90
	$(FC) $(OPT) pas_de_temps.f90 -c

initialisation.o:		initialisation.f90
	$(FC) $(OPT) initialisation.f90 -c

calcul_advection.o:		calcul_advection.f90
	$(FC) $(OPT) calcul_advection.f90 -c

calcul_diffusion.o:		calcul_diffusion.f90
	$(FC) $(OPT) calcul_diffusion.f90 -c
	
calcul_advection_diffusion.o:		calcul_advection_diffusion.f90
	$(FC) $(OPT) calcul_advection_diffusion.f90 -c
	
simulate_one_timestep.o:	simulate_one_timestep.f90
	$(FC) $(OPT) simulate_one_timestep.f90 -c
	
simulationexamplev2.o:	simulationexamplev2.f
	$(FC) $(OPT) $(INCLUDE)  simulationexamplev2.f -c

prog_InSitu.o:		prog_InSitu.f
	$(FC) $(OPT) $(INCLUDE)  prog_InSitu.f -c

clean :
	/bin/rm -f $(OBJS) *.mod $(EXE)
