.SUFFIXES:  .o .f90 .F90
#following shows two examples of where to find numerical recipes:
#NRROOT=/linuxlocal/recipes_f-90
NRROOT=/usr/local/recipes_f-90
#following are needed if you want to do some "numerical recipes demos"
NRF90DIR=$(NRROOT)/recipes
NRF90DEMO=$(NRROOT)/demo/src
NRF90DATA=$(NRROOT)/demo/data

vpath  %.F90 ../src
vpath  %.f90 ../recipes:$(NRF90DIR):$(NRF90DEMO)

#NAG:  the unsharedf95 option makes a binary that does not use NAG runtime lib: 
#compile =  f95 -free -V -unsharedf95

#Lahey/Fujitsu:
#compile =  lf95 --nfix -V 

#Intel: believe it or not, only -O3 allows svd to work !!!!
#(static option not needed unless you are sharing the executable)
compile = ifort -FR -O3 -static
#compile = ifort -FR -O3 
#compile = ifort -FR 

compc := $(compile) -c

mymods= precismod.o utilmod.o network.o

nrmods= nrtype.o nrutil.o nr.o

recipes= ludcmp.o lubksb.o svdcmp.o pythag.o

#my codes

nn: nn.F90 $(mymods) nn.o
	$(compile) -o ../exe/nn $(mymods) nn.o 

nn.o: nn.F90 $(mymods)
	$(compc) $< -o $@

svd: svd.F90 $(nrmods) $(recipes) $(mymods) svd.o
	$(compile) -o ../exe/svd $(nrmods) $(recipes) $(mymods) svd.o 

svd.o: svd.F90 $(nrmods) $(recipes) $(mymods)
	$(compc) $< -o $@

clean:
	rm -f *.o *.mod *.l *.d *.pc *.pcl *~

#my modules

network.o: network.F90 
	$(compc) $< -o $@

utilmod.o: utilmod.F90 
	$(compc) $< -o $@

precismod.o: precismod.F90 
	$(compc) $< -o $@

#numerical recipes demos 

xludcmp: xludcmp.f90 $(nrmods) $(recipes) xludcmp.o
	$(compile) -o ../exe/xludcmp $(nrmods) $(recipes) xludcmp.o 
	cp $(NRF90DATA)/MATRX1.DAT ../exe/MATRX1.DAT

xludcmp.o: xludcmp.f90
	$(compc) $< -o $@


#numerical recipes modules
nrtype.o: nrtype.f90
	$(compc) $< -o $@

nr.o: nr.f90
	$(compc) $< -o $@

nrutil.o: nrutil.f90
	$(compc) $< -o $@

#numerical recipes subroutines
lubksb.o: lubksb.f90 $(nrmods) 
	$(compc) $< -o $@

ludcmp.o: ludcmp.f90 $(nrmods) 
	$(compc) $< -o $@

svdcmp.o: svdcmp.f90 $(nrmods) 
	$(compc) $< -o $@

pythag.o: pythag.f90 $(nrmods) 
	$(compc) $< -o $@
