# -nolocal or -local : local or nonlocal emulation.
# Run command:  mpirun -c2c -np $NP cav < cav.in
LIBS = -lm
COMP = mpif77 $(LIBS)
#COMP = mpif77 -w $(LIBS)
#COMP = /usr/rels/mpich-1.2.1/bin/mpif77 -w $(LIBS)
FLAG = -c -O3
 
OBCA = ns.o mp.o io.o \
       init.o conv.o pred.o corr.o trid.o scal.o\
       pres.o cg.o smad.o resd.o fctr.o exch.o eddy.o

OBCAS =nsst.o mp.o io.o stat.o\
       init.o conv.o pred.o corr.o trid.o scal.o\
       pres.o cg.o smad.o resd.o fctr.o exch.o eddy.o

INCS = size.inc mpi.inc para.inc \
       ns.inc metric.inc stat.inc gsize.inc

# 3-D cavity 
cav : $(OBCA) $(INCS) cavity.inc cavity.o 
	$(COMP) -o cav $(LIBS) $(OBCA) $(FLIBS) cavity.o

# 3-D cavity    ( with statistics )
cavs : $(OBCAS) $(INCS) cavity.inc cavity.o 
	$(COMP) -o cavs $(OBCAS) cavity.o

# delete files
clean :
	/bin/rm -f *.o

# main program ( with statistics )
nsst.o : nsst.f $(INCS)
	$(COMP) $(FLAG) nsst.f 

# statistic
stat.o : stat.f $(INCS)
	 $(COMP) $(FLAG) stat.f 

# main program
ns.o : ns.f $(INCS)
	$(COMP) $(FLAG) ns.f 

# message passing
mp.o : mp.f $(INCS)
	$(COMP) $(FLAG) mp.f 

# input / output
io.o : io.f $(INCS)
	$(COMP) $(FLAG) io.f 

# les
eddy.o : eddy.f $(INCS)
	$(COMP) $(FLAG) eddy.f 

# initialization
init.o : init.f $(INCS)
	$(COMP) $(FLAG) init.f 

# convection
conv.o : conv.f $(INCS)
	$(COMP) $(FLAG) conv.f 

# prediction
pred.o : pred.f $(INCS)
	$(COMP) $(FLAG) pred.f 

# correction
corr.o : corr.f $(INCS)
	$(COMP) $(FLAG) corr.f 

# tridiagonal solver
trid.o : trid.f $(INCS)
	$(COMP) $(FLAG) trid.f 

# pressure initialization
pres.o : pres.f $(INCS)
	$(COMP) $(FLAG) pres.f 

# pressure initialization
cg.o : cg.f $(INCS)
	$(COMP) $(FLAG) cg.f 

# ADI smoother	        
smad.o : smad.f $(INCS)
	$(COMP) $(FLAG) smad.f

# residue
resd.o : resd.f $(INCS)
	$(COMP) $(FLAG) resd.f 

# fine / coarse transfer
fctr.o : fctr.f $(INCS)
	$(COMP) $(FLAG) fctr.f  

# message exchange
exch.o : exch.f $(INCS)
	$(COMP) $(FLAG) exch.f 

# cavity		
cavity.o : cavity.f $(INCS)
	$(COMP) $(FLAG) cavity.f 

# scalar 
scal.o : scal.f $(INCS)
	$(COMP) $(FLAG) scal.f 

# subset (subset per node with ghost points)
nsub : nsub.f size.inc mpi.inc 
	$(COMP) -o nsub nsub.f 

# subset 
sub : sub.f size.inc mpi.inc 
	$(COMP) -o sub sub.f 

# subset  ( with statistics ) 
subst : subst.f size.inc mpi.inc stat.inc
	$(COMP) -o subst subst.f

# mid-plane cut (cavity u.v)
cmid : cmid.f 
	$(COMP) -o cmid cmid.f 

# 3D to 2D (for cavity tracer)
c2d : c2d.f
	$(COMP) -o c2d c2d.f 


