# 
# Makefile for 2DHF program 
# 
# Last update: 17.01.2003 (Jacek.Kobus@phys.uni.torun.pl)

SHELL = bash

# In order to make the 2DHF program the array dimensions in various
# routines have to be set according to the values of the following
# variables:

# MAXNU    = maximum number of grid points in \nu direction 
# MAXMU    = maximum number of grid points in \mu direction 

MAXNU = 400
MAXMU = 450

# MAXFOCK is set to ${MAXNU}*${MAXMU} automatically

# MAXGRIDS = maximum number of subgrids; this version of the program
# can handle up to 3 subgrids

MAXGRIDS = 1

# MAXBASIS = maximum number of primitive gaussian basis functions used
# to construct numerical molecular orbitals out of data retrieved from
# GAUSSIAN94 outputs

MAXBASIS = 200

# REAL = real*8 (by default) or real*16 if the quadrupole precision is
# supported by the compiler; quadrupole precision is used when
# interpolating solutions between grids or calculations are carried
# out on more than one subgrid (an accuracy of the interpolation is
# markedly improved when quadrupole precision is employed)

REAL = real*8
# REAL = real*16

# If dynamic allocation is NOT possible on your system uncomment the
# MEMALLOC line. You have to edit main-static.inc file to set values
# of grid and orbital parameters according to expected range of input
# data 

#MEMALLOC = main-static.inc

# For a Sun workstation with f77 or a PC with g77 compiler 
MEMALLOC = main-dynamic-f77.inc

# For a DEC workstation and f77 compiler 
# MEMALLOC = main-dynamic-f77-dec.inc

# For f90 compiler 
# MEMALLOC = main-dynamic-f90.inc

# set system type/compiler
# available keywords are: cray, dec, ibm, lahey, linux, sgi, solaris

SYSTEM = linux

# if BLAS library is available set the BLAS variable to yes
BLAS = no

# The 2DHF program uses mxv routine for matrix times vector
# multiplication. If the BLAS library is available and contains mxv
# instead of dgemv set MXV variable to yes
MXV = no

ifeq ($(SYSTEM),solaris)
# Sun (generic)
	FC = f77
	FFLAGS = -native -O4 -dalign
	FFLAGS_ADD = -e
# Sun Enterprize 6000
#       FFLAGS = -xarch=v8plusa -O4 -dalign
# Sun Sparc Ultra processors
#	 FFLAGS = -xarch=v9 -O4 -dbl_align_all=yes -xtypemap=real:64,double:128,integer:64

	FLIB = -xlic_lib=sunperf
	BLAS = yes

	CC = cc
	CFLAGS =
endif

# Cray YMP
ifeq ($(SYSTEM),cray)
	FC = f90
	FFLAGS = -O2 -dp
	FFLAGS_ADD = -N 132
	FLIB = -lveclib
#FLIB = -l /lib/libsci.a
	BLAS   = yes
	BLAS_o = blas_ymp.o
	BLAS_f = blas_ymp.f

	CC = cc
	CFLAGS = -Dymp
endif

# DEC machines with EV5 processors 
ifeq ($(SYSTEM),dec)
	FC = f77
	FFLAGS = -O4 -tune ev5 -fpe1 -align dcommons
	FFLAGS_ADD = -extend_source
	FLIB = -ldxml
	BLAS = yes

	CC = cc
	CFLAGS = -Ddec
endif

# IBM
ifeq ($(SYSTEM),ibm)
	FC = f77
	FFLAGS = -O2 
	FFLAGS_ADD = -qfixde=120
	FLIB = -lemsl
	BLAS = yes

	CC = cc
	CFLAGS = -DAIX
endif

# Lahey/Fujitsu Fortran 95 
ifeq ($(SYSTEM),lahey)
	FC = lf95
	FFLAGS = -O -tp  
	FFLAGS_ADD =  --wide -in
	BLAS = no

	CC = gcc
	CFLAGS =
endif

# Linux 
ifeq ($(SYSTEM),linux)
	FC = g77
	FFLAGS = -O6 -malign-double -fforce-mem -fforce-addr \
	-fstrength-reduce -funroll-loops
#	FFLAGS = -O1 -malign-double 
#       FFLAGS = -g -C 
	FFLAGS_ADD =  -w -ffixed-line-length-none
	BLAS = no

	CC = gcc
	CFLAGS =
endif	

# SGI
ifeq ($(SYSTEM),sgi)
	FC = f77
	FFLAGS = -O2 -static 
	FFLAGS_ADD = -col120
	BLAS = no

	CC = cc
	CFLAGS = 
endif


# nothing to be set below this line
########################################################################################

ifeq ($(BLAS),no)
	BLAS_o = $(O)blas.o
	BLAS_f = $(S)blas.f
	MXV    = yes
else
	BLAS_o = 
	BLAS_f = 
endif

ifeq ($(MXV),no)
	MXV  = $(O)mxv.o
else
	MXV  =
endif


VER = "2dhf_"`date +%d.%m.%y`
VER_DIST = "2dhf_"`date +%m.%y`

BIN =./bin/
S   =./src/
O   =./obj/

MAXNI=${MAXNU}

OBJECTS=$(O)fmalloc.o $(O)getdatetime.o $(O)getusedcpu.o \
	$(O)add.o $(O)asympot.o $(O)asympti.o $(O)asymptp.o $(O)asymorb.o $(O)banner.o \
	$(O)card.o $(O)chasympot.o $(O)clrstring.o $(O)coulmom.o\
	$(O)dbgp.o $(O)difmu.o $(O)difni.o $(O)dointerp.o \
	$(O)dointerp_nu.o $(O)dointerp_mu.o \
	$(O)es.o $(O)exchmom.o $(O)excont.o $(O)exint.o $(O)exocc.o \
	$(O)factor.o $(O)factor2.o $(O)fermi.o $(O)fill.o $(O)fill1.o $(O)fill2.o \
	$(O)fill3.o $(O)fill4.o $(O)fock.o $(O)focksl.o \
	$(O)gauss_ovlap.o $(O)gmtran.o $(O)grid_old.o \
	$(O)homo.o $(O)homo_check.o $(O)homo_det.o $(O)hypgf.o $(O)hypgf3.o \
	$(O)iniaddr.o $(O)iniaorb.o $(O)inifun.o $(O)inigauss.o $(O)inihyd.o \
	$(O)inisuppl.o $(O)inpa.o $(O)inpf.o $(O)inpi.o \
	$(O)lagra.o $(O)locenergy.o \
	$(O)main_2dhf.o $(O)mcsor.o $(O)mesh.o $(O)momen.o $(O)mulex.o \
	$(O)mulex1.o $(O)multi.o $(O)multi1.o \
	$(O)nmucalc.o $(O)norm.o $(O)norm94.o $(O)ortho.o $(O)oshell.o \
	$(O)plaguer.o $(O)plegend.o $(O)plegendg.o $(O)pmtx.o $(O)prepdiff.o \
	$(O)prepfix.o $(O)prepg94.o $(O)prepg94l.o $(O)prepmesh.o $(O)prepscf.o \
	$(O)prepwexch.o $(O)prepvar.o $(O)printall.o $(O)prod.o $(O)prod2.o \
	$(O)proda.o $(O)prodas.o $(O)propet.o $(O)prtmat.o $(O)quadp.o \
	$(O)rayln.o $(O)raylsl.o $(O)raynsl.o $(O)reada.o \
	$(O)rayl.o $(O)rfdexch.o $(O)rinputd.o $(O)refill.o $(O)refill34.o $(O)relax.o \
	$(O)relcoul1.o $(O)relcoul2.o $(O)relorb1.o $(O)relorb2.o \
	$(O)relexch1.o $(O)relexch2.o $(O)r_exponents.o $(O)rfdisk.o \
	$(O)rfun.o $(O)rfun_int.o $(O)rfunorb.o $(O)rheader.o $(O)rrec.o \
	$(O)scf.o $(O)setmaxunit.o $(O)setomega.o $(O)slaterp.o $(O)sor.o $(O)summary.o \
	$(O)tail.o $(O)tfpot.o $(O)thofe.o $(O)toten.o $(O)totenp.o \
	$(O)totensl.o $(O)ttime.o \
	$(O)wrec.o $(O)writea.o $(O)wtdexch.o $(O)wtdexch1.o $(O)wtdisk.o \
	$(O)zasyx.o $(O)zasyxtail.o $(O)zasyx1.o $(O)zasyxtail1.o\
	$(O)zasyxi.o $(O)zmulti.o $(O)zmultii.o \
	$(O)zeroarray.o $(O)zz1.o $(O)zz2.o $(O)zz1g.o $(O)zz2g.o  \
	$(BLAS_o) $(MXV) 

# making x2dhf
$(BIN)x2dhf: $(OBJECTS) 
	$(FC) $(FFLAGS) -o $(BIN)x2dhf $(OBJECTS) $(FLIB)


# making source files
$(S)main_2dhf.f: $(S)main_2dhf.f.raw
	cd $(S); sed s/_MEMALLOC_/${MEMALLOC}/  main_2dhf.f.raw > main_2dhf.f; cd ..

$(S)blk_data.inc: MAXFOCK:=$$((${MAXNU}*${MAXMU}))
$(S)blk_data.inc: $(S)blk_data.inc.raw
	cd $(S); sed s/_MAXMU_/${MAXMU}/g  blk_data.inc.raw | \
	sed s/_MAXNI_/${MAXNU}/g  | sed s/_MAXFOCK_/${MAXFOCK}/g | \
	sed s/_MAXGRIDS_/${MAXGRIDS}/g  | \
	sed s/_MAXBASIS_/${MAXBASIS}/g > blk_data.inc; cd ..

$(S)commons8.inc: MAXFOCK:=$$((${MAXNU}*${MAXMU}))
$(S)commons8.inc: $(S)commons8.inc.raw
	cd  $(S); sed s/_MAXMU_/${MAXMU}/g  commons8.inc.raw | \
	sed s/_MAXNI_/${MAXNU}/g | sed s/_MAXFOCK_/${MAXFOCK}/g | \
	sed s/_MAXBASIS_/${MAXBASIS}/g > commons8.inc; cd ..

$(S)commons16.inc: $(S)commons16.inc.raw
	cd $(S); sed s/_MAXMU_/${MAXMU}/g  commons16.inc.raw > commons16.inc; cd ..

$(S)dointerp.f: $(S)dointerp.f.raw
	cd $(S); sed s/_REAL_/${REAL}/ dointerp.f.raw > dointerp.f; cd ..

$(S)dointerp_nu.f: $(S)dointerp_nu.f.raw
	cd $(S); sed s/_REAL_/${REAL}/ dointerp_nu.f.raw > dointerp_nu.f; cd ..

$(S)dointerp_mu.f: $(S)dointerp_mu.f.raw
	cd $(S); sed s/_REAL_/${REAL}/ dointerp_mu.f.raw > dointerp_mu.f; cd ..

$(S)prepg94.f: $(S)prepg94.f.raw 
	cd $(S); sed s/_REAL_/${REAL}/ prepg94.f.raw | \
	sed s/_MAXBASIS_/${MAXBASIS}/g> prepg94.f; cd ..

$(S)prepg94l.f: $(S)prepg94l.f.raw
	cd $(S); sed s/_REAL_/${REAL}/ prepg94l.f.raw |\
	sed s/_MAXBASIS_/${MAXBASIS}/g > prepg94l.f; cd ..

$(S)r_exponents.f: $(S)r_exponents.f.raw
	cd $(S); sed s/_MAXBASIS_/${MAXBASIS}/g r_exponents.f.raw > r_exponents.f; cd ..

$(S)fill2.f: $(S)fill2.f.raw
	cd $(S); sed s/_MAXMU_/${MAXMU}/g  fill2.f.raw > fill2.f; cd ..

$(S)fill3.f: $(S)fill3.f.raw
	cd $(S); sed s/_MAXMU_/${MAXMU}/g  fill3.f.raw > fill3.f; cd ..

$(S)fill4.f: $(S)fill4.f.raw
	cd $(S); sed s/_MAXMU_/${MAXMU}/g  fill4.f.raw > fill4.f; cd ..

$(S)quadp.f: $(S)quadp.f.raw
	cd $(S); sed s/_REAL_/${REAL}/ quadp.f.raw > quadp.f; cd ..

# making object files
$(O)fmalloc.o: $(S)fmalloc.c
	$(CC) -c $(CFLAGS) $(S)fmalloc.c -o $(O)fmalloc.o	
$(O)getdatetime.o: $(S)getdatetime.c
	$(CC) -c $(CFLAGS) $(S)getdatetime.c -o $(O)getdatetime.o
$(O)getusedcpu.o: $(S)getusedcpu.c
	$(CC) -c $(CFLAGS) $(S)getusedcpu.c -o $(O)getusedcpu.o
$(O)add.o: $(S)add.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)add.f -o $(O)add.o
$(O)asymorb.o: $(S)asymorb.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)asymorb.f -o $(O)asymorb.o
$(O)asympot.o: $(S)asympot.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)asympot.f -o $(O)asympot.o
$(O)asympti.o: $(S)asympti.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)asympti.f -o $(O)asympti.o
$(O)asymptp.o: $(S)asymptp.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)asymptp.f -o $(O)asymptp.o
$(O)banner.o: $(S)banner.f
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)banner.f -o $(O)banner.o
$(O)card.o: $(S)card.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)card.f -o $(O)card.o
$(O)chasympot.o: $(S)chasympot.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)chasympot.f -o $(O)chasympot.o
$(O)clrstring.o: $(S)clrstring.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)clrstring.f -o $(O)clrstring.o
$(O)coulmom.o: $(S)coulmom.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)coulmom.f -o $(O)coulmom.o
$(O)dbgp.o: $(S)dbgp.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)dbgp.f -o $(O)dbgp.o
$(O)difmu.o: $(S)difmu.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)difmu.f -o $(O)difmu.o
$(O)difni.o: $(S)difni.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)difni.f -o $(O)difni.o
$(O)dointerp.o: $(S)dointerp.f $(S)commons8.inc $(S)commons16.inc
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)dointerp.f -o $(O)dointerp.o
$(O)dointerp_mu.o: $(S)dointerp_mu.f $(S)commons8.inc $(S)commons16.inc
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)dointerp_mu.f -o $(O)dointerp_mu.o
$(O)dointerp_nu.o: $(S)dointerp_nu.f $(S)commons8.inc $(S)commons16.inc
	$(FC) -c $(FFLAGS) $(S)dointerp_nu.f -o $(O)dointerp_nu.o
$(O)es.o: $(S)es.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)es.f -o $(O)es.o
$(O)exchmom.o: $(S)exchmom.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)exchmom.f -o $(O)exchmom.o
$(O)excont.o: $(S)excont.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)excont.f -o $(O)excont.o
$(O)exint.o: $(S)exint.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)exint.f -o $(O)exint.o 
$(O)exocc.o: $(S)exocc.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)exocc.f -o $(O)exocc.o
$(O)factor.o: $(S)factor.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)factor.f -o $(O)factor.o
$(O)factor2.o: $(S)factor2.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)factor2.f -o $(O)factor2.o
$(O)fermi.o: $(S)fermi.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)fermi.f -o $(O)fermi.o
$(O)fill.o: $(S)fill.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)fill.f -o $(O)fill.o
$(O)fill1.o: $(S)fill1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)fill1.f -o $(O)fill1.o
$(O)fill2.o: $(S)fill2.f $(S)fill2.f.raw $(S)commons8.inc 
	$(FC) -c $(FFLAGS) $(S)fill2.f -o $(O)fill2.o
$(O)fill3.o: $(S)fill3.f $(S)fill3.f.raw $(S)commons8.inc 
	$(FC) -c $(FFLAGS) $(S)fill3.f -o $(O)fill3.o
$(O)fill4.o: $(S)fill4.f $(S)fill4.f.raw $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)fill4.f -o $(O)fill4.o
$(O)fock.o: $(S)fock.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)fock.f -o $(O)fock.o
$(O)focksl.o: $(S)focksl.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)focksl.f -o $(O)focksl.o
$(O)gauss_ovlap.o: $(S)gauss_ovlap.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)gauss_ovlap.f -o $(O)gauss_ovlap.o
$(O)gmtran.o: $(S)gmtran.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)gmtran.f -o $(O)gmtran.o
$(O)grid_old.o: $(S)grid_old.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)grid_old.f -o $(O)grid_old.o
$(O)homo.o: $(S)homo.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)homo.f -o $(O)homo.o
$(O)homo_check.o: $(S)homo_check.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)homo_check.f -o $(O)homo_check.o
$(O)homo_det.o: $(S)homo_det.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)homo_det.f -o $(O)homo_det.o
$(O)hypgf.o: $(S)hypgf.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)hypgf.f -o $(O)hypgf.o
$(O)hypgf3.o: $(S)hypgf3.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)hypgf3.f -o $(O)hypgf3.o
$(O)iniaddr.o: $(S)iniaddr.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)iniaddr.f -o $(O)iniaddr.o
$(O)iniaorb.o: $(S)iniaorb.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)iniaorb.f -o $(O)iniaorb.o
$(O)inifun.o: $(S)inifun.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)inifun.f -o $(O)inifun.o
$(O)inigauss.o: $(S)inigauss.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)inigauss.f -o $(O)inigauss.o
$(O)inihyd.o: $(S)inihyd.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)inihyd.f -o $(O)inihyd.o
$(O)inisuppl.o: $(S)inisuppl.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)inisuppl.f -o $(O)inisuppl.o
$(O)inpa.o: $(S)inpa.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)inpa.f -o $(O)inpa.o
$(O)inpf.o: $(S)inpf.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)inpf.f -o $(O)inpf.o
$(O)inpi.o: $(S)inpi.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)inpi.f -o $(O)inpi.o
$(O)lagra.o: $(S)lagra.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)lagra.f -o $(O)lagra.o
$(O)locenergy.o: $(S)locenergy.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)locenergy.f -o $(O)locenergy.o
$(O)main_2dhf.o: $(S)main_2dhf.f $(S)main_2dhf.f.raw $(S)main-dynamic-f77.inc \
	$(S)main-dynamic-f90.inc $(S)main-static.inc $(S)main-dynamic-f77-dec.inc \
	$(S)commons8.inc $(S)blk_data.inc  
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)main_2dhf.f -o $(O)main_2dhf.o
$(O)mcsor.o: $(S)mcsor.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)mcsor.f -o $(O)mcsor.o
$(O)mesh.o: $(S)mesh.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)mesh.f -o $(O)mesh.o
$(O)momen.o: $(S)momen.f $(S)commons8.inc  
	$(FC) -c $(FFLAGS) $(S)momen.f -o $(O)momen.o
$(O)mulex.o: $(S)mulex.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)mulex.f -o $(O)mulex.o
$(O)mulex1.o: $(S)mulex1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)mulex1.f -o $(O)mulex1.o
$(O)multi.o: $(S)multi.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)multi.f -o $(O)multi.o
$(O)multi1.o: $(S)multi1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)multi1.f -o $(O)multi1.o
$(O)nmucalc.o: $(S)nmucalc.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)nmucalc.f -o $(O)nmucalc.o
$(O)norm.o: $(S)norm.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)norm.f -o $(O)norm.o
$(O)norm94.o: $(S)norm94.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)norm94.f -o $(O)norm94.o
$(O)ortho.o: $(S)ortho.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)ortho.f -o $(O)ortho.o
$(O)oshell.o: $(S)oshell.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)oshell.f -o $(O)oshell.o
$(O)plaguer.o: $(S)plaguer.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)plaguer.f -o $(O)plaguer.o
$(O)plegend.o: $(S)plegend.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)plegend.f -o $(O)plegend.o
$(O)plegendg.o: $(S)plegendg.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)plegendg.f -o $(O)plegendg.o
$(O)pmtx.o: $(S)pmtx.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)pmtx.f -o $(O)pmtx.o
$(O)prepdiff.o: $(S)prepdiff.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepdiff.f -o $(O)prepdiff.o
$(O)prepfix.o: $(S)prepfix.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepfix.f -o $(O)prepfix.o
$(O)prepg94.o: $(S)prepg94.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepg94.f -o $(O)prepg94.o
$(O)prepg94l.o: $(S)prepg94l.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepg94l.f -o $(O)prepg94l.o
$(O)prepmesh.o: $(S)prepmesh.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepmesh.f -o $(O)prepmesh.o
$(O)prepscf.o: $(S)prepscf.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepscf.f -o $(O)prepscf.o
$(O)prepwexch.o: $(S)prepwexch.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepwexch.f -o $(O)prepwexch.o
$(O)prepvar.o: $(S)prepvar.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prepvar.f -o $(O)prepvar.o
$(O)printall.o: $(S)printall.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)printall.f -o $(O)printall.o
$(O)prod.o: $(S)prod.f 
	$(FC) -c $(FFLAGS) $(S)prod.f -o $(O)prod.o
$(O)prod2.o: $(S)prod2.f 
	$(FC) -c $(FFLAGS) $(S)prod2.f -o $(O)prod2.o
$(O)proda.o: $(S)proda.f 
	$(FC) -c $(FFLAGS) $(S)proda.f -o $(O)proda.o
$(O)prodas.o: $(S)prodas.f 
	$(FC) -c $(FFLAGS) $(S)prodas.f -o $(O)prodas.o
$(O)propet.o: $(S)propet.f $(S)commons8.inc 
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)propet.f -o $(O)propet.o
$(O)prtmat.o: $(S)prtmat.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)prtmat.f -o $(O)prtmat.o
$(O)quadp.o: $(S)quadp.f $(S)quadp.f.raw $(S)commons8.inc $(S)commons16.inc
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)quadp.f -o $(O)quadp.o
$(O)rayl.o: $(S)rayl.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rayl.f -o $(O)rayl.o
$(O)rayln.o: $(S)rayln.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rayln.f -o $(O)rayln.o
$(O)raylsl.o: $(S)raylsl.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)raylsl.f -o $(O)raylsl.o
$(O)raynsl.o: $(S)raynsl.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)raynsl.f -o $(O)raynsl.o
$(O)reada.o: $(S)reada.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)reada.f -o $(O)reada.o
$(O)refill.o: $(S)refill.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)refill.f -o $(O)refill.o
$(O)refill34.o: $(S)refill34.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)refill34.f -o $(O)refill34.o
$(O)relax.o: $(S)relax.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relax.f -o $(O)relax.o
$(O)relexch1.o: $(S)relexch1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relexch1.f -o $(O)relexch1.o
$(O)relexch2.o: $(S)relexch2.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relexch2.f -o $(O)relexch2.o
$(O)relcoul1.o: $(S)relcoul1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relcoul1.f -o $(O)relcoul1.o
$(O)relcoul2.o: $(S)relcoul2.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relcoul2.f -o $(O)relcoul2.o
$(O)relorb1.o: $(S)relorb1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relorb1.f -o $(O)relorb1.o
$(O)relorb2.o: $(S)relorb2.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)relorb2.f -o $(O)relorb2.o
$(O)r_exponents.o: $(S)r_exponents.f $(S)r_exponents.f.raw $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)r_exponents.f -o $(O)r_exponents.o
$(O)rfdisk.o: $(S)rfdisk.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rfdisk.f -o $(O)rfdisk.o
$(O)rfun_int.o: $(S)rfun_int.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(FFLAGS_ADD) $(S)rfun_int.f -o $(O)rfun_int.o
$(O)rfunorb.o: $(S)rfunorb.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rfunorb.f -o $(O)rfunorb.o
$(O)rfdexch.o: $(S)rfdexch.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rfdexch.f -o $(O)rfdexch.o
$(O)rfun.o: $(S)rfun.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rfun.f -o $(O)rfun.o
$(O)rheader.o: $(S)rheader.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rheader.f -o $(O)rheader.o
$(O)rinputd.o: $(S)rinputd.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rinputd.f -o $(O)rinputd.o
$(O)rrec.o: $(S)rrec.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)rrec.f -o $(O)rrec.o
$(O)scf.o: $(S)scf.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)scf.f -o $(O)scf.o
$(O)setmaxunit.o: $(S)setmaxunit.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)setmaxunit.f -o $(O)setmaxunit.o
$(O)setomega.o: $(S)setomega.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)setomega.f -o $(O)setomega.o
$(O)slaterp.o: $(S)slaterp.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)slaterp.f -o $(O)slaterp.o
$(O)sor.o: $(S)sor.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)sor.f -o $(O)sor.o
$(O)summary.o: $(S)summary.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)summary.f -o $(O)summary.o
$(O)tail.o: $(S)tail.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)tail.f -o $(O)tail.o
$(O)thofe.o: $(S)thofe.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)thofe.f  -o $(O)thofe.o
$(O)tfpot.o: $(S)tfpot.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)tfpot.f -o $(O)tfpot.o
$(O)toten.o: $(S)toten.f $(S)commons8.inc 
	$(FC) -c $(FFLAGS) $(S)toten.f -o $(O)toten.o
$(O)totenp.o: $(S)totenp.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)totenp.f -o $(O)totenp.o
$(O)totensl.o: $(S)totensl.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)totensl.f -o $(O)totensl.o
$(O)ttime.o: $(S)ttime.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)ttime.f -o $(O)ttime.o
$(O)wrec.o: $(S)wrec.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)wrec.f -o $(O)wrec.o
$(O)writea.o: $(S)writea.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)writea.f -o $(O)writea.o
$(O)wtdexch.o: $(S)wtdexch.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)wtdexch.f -o $(O)wtdexch.o
$(O)wtdexch1.o: $(S)wtdexch1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)wtdexch1.f -o $(O)wtdexch1.o
$(O)wtdisk.o: $(S)wtdisk.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)wtdisk.f -o $(O)wtdisk.o
$(O)zasyx.o: $(S)zasyx.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zasyx.f -o $(O)zasyx.o
$(O)zasyxtail.o: $(S)zasyxtail.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zasyxtail.f -o $(O)zasyxtail.o
$(O)zasyx1.o: $(S)zasyx1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zasyx1.f -o $(O)zasyx1.o
$(O)zasyxtail1.o: $(S)zasyxtail1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zasyxtail1.f -o $(O)zasyxtail1.o
$(O)zasyxi.o: $(S)zasyxi.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zasyxi.f -o $(O)zasyxi.o
$(O)zeroarray.o: $(S)zeroarray.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zeroarray.f -o $(O)zeroarray.o
$(O)zmulti.o: $(S)zmulti.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zmulti.f -o $(O)zmulti.o
$(O)zmultii.o: $(S)zmultii.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zmultii.f -o $(O)zmultii.o
$(O)zz1.o: $(S)zz1.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zz1.f -o $(O)zz1.o
$(O)zz2.o: $(S)zz2.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zz2.f -o $(O)zz2.o
$(O)zz1g.o: $(S)zz1g.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zz1g.f -o $(O)zz1g.o
$(O)zz2g.o: $(S)zz2g.f $(S)commons8.inc
	$(FC) -c $(FFLAGS) $(S)zz2g.f -o $(O)zz2g.o
$(BLAS_o): $(BLAS_f)
	$(FC) -c $(FFLAGS) $(BLAS_f) -o $(BLAS_o)
$(MXV): $(S)mxv.f   
	$(FC) -c $(FFLAGS) $(S)mxv.f -o $(O)mxv.o

########################################################################################
# extras

all:
	rm -rf ./obj/ 2> /dev/null 
	mkdir obj
	rm -f $(S)blk_data.inc $(S)commons16.inc $(S)commons8.inc \
	$(S)dointerp.f $(S)dointerp_mu.f $(S)dointerp_nu.f \
	$(S)fill2.f $(S)fill3.f $(S)fill4.f $(S)main_2dhf.f \
	$(S)prepg94.f $(S)prepg94l.f $(S)quadp.f $(S)r_exponents.f
	touch $(S)blk_data.inc.raw $(S)commons16.inc.raw $(S)commons8.inc.raw \
	$(S)dointerp.f.raw $(S)dointerp_mu.f.raw $(S)dointerp_nu.f.raw \
	$(S)fill2.f.raw $(S)fill3.f.raw $(S)fill4.f.raw $(S)main_2dhf.f.raw \
	$(S)prepg94.f.raw $(S)prepg94l.f.raw $(S)quadp.f.raw $(S)r_exponents.f.raw 2> /dev/null 
	make 

all64:
	rm -rf ./obj/ 2> /dev/null 
	mkdir obj
	rm -f $(S)blk_data.inc $(S)commons16.inc $(S)commons8.inc \
	$(S)dointerp.f $(S)dointerp_mu.f $(S)dointerp_nu.f \
	$(S)fill2.f $(S)fill3.f $(S)fill4.f $(S)main_2dhf.f \
	$(S)prepg94.f $(S)prepg94l.f $(S)quadp.f $(S)r_exponents.f
	touch $(S)blk_data.inc.raw $(S)commons16.inc.raw $(S)commons8.inc.raw \
	$(S)dointerp.f.raw $(S)dointerp_mu.f.raw $(S)dointerp_nu.f.raw \
	$(S)fill2.f.raw $(S)fill3.f.raw $(S)fill4.f.raw $(S)main_2dhf.f.raw \
	$(S)prepg94.f.raw $(S)prepg94l.f.raw $(S)quadp.f.raw $(S)r_exponents.f.raw
	cd $(S); ../Perl_scripts/Change32_2_64.pl; cd ../ 2> /dev/null 
	make 

./doc/2dhf.pdf:	./doc/2dhf.tex
	cd ./doc; pdflatex 2dhf.tex; cd ..

./doc/users_guide.pdf:	./doc/users_guide.tex
	cd ./doc; pdflatex users_guide.tex; cd ..

./doc/users_guide.html:	./doc/users_guide.tex 
	cd ./doc; latex2html -navigation -noinfo -auto_prefix -font_size 12pt \
	users_guide.tex; cd ..
	cd ./doc/users_guide; ../../Perl_scripts/RmBullet.pl; cd ../../; 
	cd ./doc; ln -s users_guide/users_guide.html .; cd ..;
#	cd ./doc; tth < users_guide.tex> users_guide.html; cd  ..

doc:	./doc/users_guide.pdf ./doc/users_guide.html ./doc/2dhf.pdf

clean:
	find . \( -name "*~" -or -name ".*~" -or -name "*.aux" -or -name "*.log" \
	-name "*.dvi" -or -name "*.log" -or -name "*.log"  -or -name "a.out"\
	-name "*.bbl" -or -name "*.blg" -or -name "*.idx" -or -name "*.ind" \
	-name "*.ilg" -or -name ".#*" -or -name "#*#" \) -exec rm -f {} \; 

clean-obj:
	rm -f $(O)*.o 2> /dev/null 

clean-bin:
	rm -f $(BIN)*.orb $(BIN)*.coul $(BIN)*.exch $(BIN)*.lst $(BIN)*.output 2> /dev/null 

tgz:
	make clean
	tar -czvf $(VER_DIST).tgz $(S)*.c $(S)*.f $(S)*.raw $(S)*.inc \
	./examples ./doc/2dhf.pdf ./doc/users_guide.pdf ./doc/users_guide/ \
	./bin/xhf README INSTALLATION COPYING CHANGES Makefile \
	./Perl_scripts/Run_tests.pl ./Perl_scripts/Run_elprop.pl \
	./Perl_scripts/elprop.pl ./Perl_scripts/Change32_2_64.pl ./Run_tests.pl

tgz-all:
	make clean
	tar  -czvf $(VER).tgz $(S)*.c $(S)*.f $(S)*.raw $(S)*.inc \
	./examples ./doc/*.tex ./doc/*.epsi ./doc/users_guide.pdf \
	./doc/users_guide/ ./bin/xhf README INSTALLATION COPYING CHANGES\
	Makefile ./Perl_scripts/ ./Run_tests.pl *.txt

########################################################################################


