# Makefile for DDSCAT.5a9
# export version

# FC specifies the fortran compiler
# FFLAGS is used to compile the modules in "OBJS"
# FFLAGS2 is used to compile the modules listed separately below OBJS
# LDFLAGS are flags for linking
# timeit specifies system-dependent code for timing, select from:
#	timeit_sun
#	timeit_hp
#	timeit_sgi
#	timeit_null
#	timeit_convex
#	timeit_ibm6000
#	timeit_osf
#	timeit_vms
#	timeit_cray
#	timeit_titan

#*********************************   Linux g77 ********************************
# Note: timeit_sun is available under the "egcs" version of g77
#	under some versions of g77 it may be necessary to use timeit_ull

FC		= g77
FFLAGS		= -c -O2
FFLAGS2		= -c -O2
LDFLAGS		=
timeit		= timeit_sun

#******************************** Sun fortran *********************************

#FC		= f77
#FFLAGS		= -fast -u -c
#FFLAGS2	= -fast -O3 -c
#LDFLAGS	= -fast -O3
#timeit		= timeit_sun

# for debugging, may enable the following:
#FFLAGS	= -u -g -fnonstd -c
#FFLAGS2 = -g -fnonstd -c
#LDFLAGS = -g -fnonstd

#****************************** AIX fortran on RS6000 *************************

#FC		= xlf
#FFLAGS		= -O -c
#FFLAGS2	= -O -c
#LDFLAGS	= -O
#timeit		= timeit_ibm6000

#****************************** SGI IRIX on R4000  ****************************
# -mips2 option generates code using the MIPS 2 instruction set [R4000 cpu]

#FC		= f77
#FFLAGS		= -u -mips2 -O2 -c
#FFLAGS2	= -mips2 -O2 -c
#LDFLAGS	= -mips2 -O2
#timeit		= timeit_sgi

#****************************** SGI IRIX on R8000 *****************************
# -mips4 option generates code using the MIPS 4 instruction set [R8000 cpu]

#FC		= f77
#FFLAGS		= -u -mips4 -O2 -c
#FFLAGS2	= -mips4 -O2 -c
#LDFLAGS	= -mips4 -O2
#timeit		= timeit_sgi

#****************************** HP AUX ****************************************

#FC		= f77
#FFLAGS		= -O3 -c
#FFLAGS2	= -O3 -c
#LDFLAGS	=
#timeit		= timeit_hp

#******************************************************************************

# Note: DDSCAT is set up to use C3DFFT = native 3d FFT routine in
# Convex vector library.  If NOT on Convex system, need to substitute
# a dummy module "dummyfft" to stand in place of this routine to
# satisfy the linker.
# When running on Convex with vector library, uncomment next 2 definitions:

#c3dfft.f     =
#c3dfft.o     = 

# When NOT running on Convex with vector library, uncomment next 2 definitions:

c3dfft.f      = dummyfft.f
c3dfft.o      = dummyfft.o

# Note: DDSCAT is set up to permit use of the netCDF library to produce
# binary output files compliant with netCDF protocols (see the User Guide).
# To NOT link to the netCDF library, uncomment next 3 definitions:

writenet      = dummywritenet
LIBNETCDF     = 
LINKNETCDF    =

# To link to the netCDF library, uncomment next 3 definitions and modify
# LIBNETCDF to include the correct path to the netCDF libraries
#		("-L/u/flatau/netcdf-2.4.3/lib" works for astro)
#		("-L/usr/peyton/lib" should work for astro, but doesn't)
# LINKNETCDF to include the names (x) of the libx.a libaries which are
#            needed for linking
#		("-lnetcdf -lnsl" works for astro)
# You may need to consult your systems adminstrator to find out whether
# netCDF is installed on your system and, if so, what LIBNETCDF and
# LINKNETCDF should be set to in order to find the netCDF libraries

#writenet      = writenet
#LIBNETCDF     = -L/u/flatau/netcdf-2.4.3/lib
#LINKNETCDF    = -lnetcdf -lnsl

#---------------------------------------------------------------------------
SRCS	      = DDSCAT.f\
		alpha.f\
		$(c3dfft.f)\
		ccgpack.f\
		cfft99f.f\
		cgcommon.f\
		copyit.f\
		cprod.f\
		cxfft3.f\
		cxfft3n.f\
		dielec.f\
		divide.f\
		errmsg.f\
		eself.f\
		evala.f\
		evale.f\
		evalq.f\
		extend.f\
		fourx.f\
		getfml.f\
		getmueller.f\
		gpfa.f\
		interp.f\
		lapack.f\
		namer.f\
		nuller.f\
		orient.f\
		pim.f\
		prinaxis.f\
		reapar.f\
		reashp.f\
		reduce.f\
		refice.f\
		refwat.f\
		rotate.f\
		rot2.f\
		scat.f\
		scavec.f\
		tar2el.f\
		tar2sp.f\
		tar3el.f\
		tarblocks.f\
		tarcel.f\
		tarcyl.f\
		tarell.f\
		target.f\
		tarhex.f\
		tarrec.f\
		tartet.f\
		$(timeit).f\
		version.f\
		wrimsg.f\
		writebin.f\
		$(writenet).f\
		writesca.f

OBJS	      = DDSCAT.o\
		alpha.o\
		$(c3dfft.o)\
		ccgpack.o\
		cfft99f.o\
		cgcommon.o\
		copyit.o\
		cprod.o\
		cxfft3.o\
		cxfft3n.o\
		dielec.o\
		divide.o\
		errmsg.o\
		eself.o\
		evala.o\
		evale.o\
		evalq.o\
		extend.o\
		fourx.o\
		getfml.o\
		getmueller.o\
		gpfa.o\
		interp.o\
		lapack.o\
		namer.o\
		nuller.o\
		orient.o\
		pim.o\
		prinaxis.o\
		reapar.o\
		reashp.o\
		reduce.o\
		refice.o\
		refwat.o\
		rotate.o\
		rot2.o\
		scat.o\
		scavec.o\
		tar2el.o\
		tar2sp.o\
		tar3el.o\
		tarblocks.o\
		tarcel.o\
		tarcyl.o\
		tarell.o\
		target.o\
		tarhex.o\
		tarrec.o\
		tartet.o\
		$(timeit).o\
		version.o\
		wrimsg.o\
		writebin.o\
		$(writenet).o\
		writesca.o

CALLTARGET.o:	CALLTARGET.f
		$(FC) $(FFLAGS) CALLTARGET.f -o CALLTARGET.o

#-----------------------------------------------------------------------------
# Most of the $(OBJS) modules can be compiled with the -u option on Sun.
# (The -u option requires that every variable type be declared explicitly).
# Only exceptions are the following routines:

cfft99f.o:	cfft99f.f
		$(FC) $(FFLAGS2) cfft99f.f
cxfft3.o:	cxfft3.f
		$(FC) $(FFLAGS2) cxfft3.f
gpfa.o:		gpfa.f
		$(FC) $(FFLAGS2) gpfa.f -o gpfa.o

refwat.o:	refwat.f
		$(FC) $(FFLAGS2) refwat.f
#-----------------------------------------------------------------------------
# dependencies for calltarget:

SRCS2	      =	CALLTARGET.f \
		errmsg.f\
		lapack.f\
		prinaxis.f\
		reashp.f\
		sizer.f\
		tar2el.f\
		tar2sp.f\
		tar3el.f\
		tarblocks.f\
		tarcel.f\
		tarcyl.f\
		tarell.f\
		target.f\
		tarhex.f\
		tarrec.f\
		tartet.f\
		wrimsg.f

OBJS2	      =	CALLTARGET.o \
		errmsg.o\
		lapack.o\
		prinaxis.o\
		reashp.o\
		sizer.o\
		tar2el.o\
		tar2sp.o\
		tar3el.o\
		tarblocks.o\
		tarcel.o\
		tarcyl.o\
		tarell.o\
		target.o\
		tarhex.o\
		tarrec.o\
		tartet.o\
		wrimsg.o

all:		ddscat calltarget tstfft

ddscat:		$(OBJS)
		$(FC) $(OBJS) $(LDFLAGS) $(LIBNETCDF) $(LINKNETCDF) -o ddscat

calltarget:	$(OBJS2)
		$(FC) $(OBJS2) $(LDFLAGS) -o calltarget

tstfft:		TSTFFT.o cfft99f.o cxfft3.o cxfft3n.o errmsg.o fourx.o \
		gpfa.o $(timeit).o wrimsg.o
		$(FC) TSTFFT.o cfft99f.o cxfft3.o cxfft3n.o errmsg.o fourx.o \
		gpfa.o $(timeit).o wrimsg.o \
		$(LDFLAGS) -o tstfft

clean:;		rm -f *.o *.FOR make.out* *.lnt *.xrf *.tre

veryclean:	clean
		rm -f calltarget ddscat tstfft *~


