RUNFILE=jscat  # the name of the executable
RUNFILE2=testmat  # the name of the executable
# below various needed compliers, my need modifications
F90=xlf
#jscatn:=F90=nf        # nag compiler
#jscatnf:=F90=nf        # nag compiler
FC=/usr/local/bin/f77
LD=f77   # note, sometimes f77 compiler is better for linking, very macine dependent.
CC=/usr/local/bin/cc

#LIBS=-llapack -lblas -lnag         # ,nagd,veclib,scilib,essl  # use, what available in your system
LIBS=lapack/liblapack1.a 

#F90lib=/usr/local/lib/f/libf.a  /usr/lib/libm.a    # one of these may be needed when 
F90lib=/lapack
F77libb=-lm -lc -lfor -lots -lUfor -lFutil             # mixing f and f77

VPATH=.:src
.SUFFIXES:
.SUFFIXES: .o .f .f .a



OBJS=jscat.o scatterer.o resultize.o gridizer.o fillix.o matrixia.o vectorix.o special.o incident.o  constant.o mie.o timing.o

jscatf= constant.f timing.f incident.f  vectorix.f special.f scatterer.f gridizer.f fillix.f matrixia.f mie.f resultize.f jscat.f 


#OPTIONS= -O
OPTIONS=-pg -O 

#OPTIONS= -g -p  -check overflow -check underflow -check all 

jscatn:=OPTIONS= -C=all -info 9 -hpf -gline 


testmat: constant.o matrixia.o testmatmul.f
	$(F90) -O -o $(RUNFILE2) $(OPTIONS) constant.o matrixia.o testmatmul.f -bloadmap:2 $(LIBS)

jscat: $(OBJS) nonag.o makefile
	$(F90) -O -o $(RUNFILE) $(OPTIONS) $(OBJS)  nonag.o -bloadmap:1 $(LIBS)

#jscat: $(OBJS) nonag.o makefile
#	$(F90) -O -o $(RUNFILE) $(OPTIONS) $(OBJS)  nonag.o -ldxml

jscatn: $(OBJS) nonag.o 
	$(F90) -o jscatn $(OPTIONS)  $(OBJS)  nonag.o -ldxml   $(F77libb)

jscatdf: $(jscatf) nonag.f makefile
	$(F90) -o jscatdf -fast -V -u -v $(jscatf)  nonag.f -ldxml

jscatnf: $(jscatf) nonag.f makefile
	$(F90) -o jscatnf -O -hpf $(jscatf)  nonag.f -ldxml -lUfor

jscatsun: $(OBJS) makefile
	$(LD) -o $(RUNFILE)  -O $(OBJS) $(F90lib) $(LIBS)

nonag: $(OBJS) nonag.o makefile
	$(LD) -o $(RUNFILE)  -O $(OBJS) $(LAPACK) nonag.o $(F90lib) 

decold: $(oOBJS) nonag.o makefile
	$(F90) -o $(RUNFILE) -p  -O $(oOBJS)  nonag.o -ldxml

dec: $(OBJS) nonag.o makefile
	$(F90) -o $(RUNFILE) -p  -O $(OBJS)  nonag.o -ldxml


decnag: $(OBJS)  makefile
	$(F90) -o $(RUNFILE)  -O $(OBJS)  -ldxml -lnag


jscat2: $(OBJS) makefile
	$(F90) -o $(RUNFILE)  -O $(OBJS) -llapack -lnag $(F77libb)


constant.o: constant.f 
	$(F90) -c $(OPTIONS) constant.f

vectorix.o: constant.o vectorix.f
	$(F90) -c $(OPTIONS)  vectorix.f

matrixia.o: constant.o matrixia.f
	$(F90) -c $(OPTIONS)  matrixia.f

special.o: constant.o vectorix.o special.f
	$(F90) -c $(OPTIONS)  special.f

incident.o: constant.o vectorix.o incident.f
	$(F90) -c $(OPTIONS)  incident.f

scatterer.o: constant.o vectorix.o incident.o scatterer.f
	$(F90) -c $(OPTIONS)  scatterer.f

gridizer.o: constant.o  scatterer.o incident.o special.o vectorix.o timing.o gridizer.f
	$(F90) -c $(OPTIONS) gridizer.f

fillix.o: constant.o  incident.o  gridizer.o timing.o fillix.f
	$(F90) -c $(OPTIONS) fillix.f

mie.o: constant.o mie.f
	$(F90) -c $(OPTIONS)  mie.f

timing.o: constant.o timing.f
	$(F90) -c $(OPTIONS)  timing.f

resultize.o: constant.o  scatterer.o incident.o  mie.o resultize.f
	$(F90) -c $(OPTIONS)  resultize.f

jscat.o: constant.o matrixia.o vectorix.o scatterer.o incident.o gridizer.o fillix.o  mie.o special.o resultize.o timing.o jscat.f
	$(F90) -c $(OPTIONS)  jscat.f


.f.o: constant.o
	$(F90) -c $(OPTIONS) $<

#.f.o:
#	$(F90) -c $(OPTIONS) $<

#.f.c:
#	$(F90) -S $<

#.c.o:
#	$(CC)  -c -I/home/pelto/amm/ $<

#.f.o:
#	$(FC)  -c $<

clean:
	rm $(OBJS) testall.o core Core a.out


oOBJS=jscat.o scatterer.o resultize.o gridix.o fillmatrices.o matrixia.o intfield.o vectorix.o special.o incident.o  constant.o mie.o timing.o

ojscatf= constant.f timing.f incident.f  vectorix.f special.f scatterer.f gridix.f fillmatrices.f matrixia.f intfield.f mie.f resultize.f jscat.f 



