# Makefile per ADFrom
#
# Please note that in some systems you need to compile with
# system libraries and not with the libraries which come with ADF.
# For examples I know that this is true for Sylicon G.
# Change the library name as for compile ADF. Documentation
# comes with ADF.
# Becouse I am not sure about the right libraries
# the variables LIBBLAS and LIBLAPAK are left blank.
# Change these variables value with the right parameters
# Change the value of LIB if needed.
# ..and please let me know your working changes. 
#
# rwgeom.f and rwgeom.o are not yet present in makefile
# because Geometry Optimizzation is not yet implemented.
#

# Define arch
ADFHOME=/home/adf
ADFARCH=dec_osf1

# DEC alfa osf (Working on Jensen)
FC = f77
LIBBLAS =
LIBLAPAK = 
# These warning options are used for debug porpose remove this in FFLAGS variable.
FWARNS = -warn argument_checking -warn declarations -warn general -warn truncated_source -warn unused
#
#
#  -warn argument_checking
#               Enables warnings about argument mismatches between caller and
#               callee, when compiled together.  The default is -warn
#               noargument_checking.
#
#  -warn declarations
#               Makes the default type of a variable undefined (IMPLICIT
#               NONE), which causes the compiler to issue a warning for any
#               undeclared symbols.  This behavior differs from default FOR-
#               TRAN rules.  The default is -warn nodeclarations.
#
#  -warn noalignments
#               Suppresses warning messages for data that is not naturally
#               aligned.  The default is -warn alignments.
#
#  -warn nogeneral
#               Suppresses all warning messages (same as the -nowarn option).
#               The default is -warn general.
#
#  -warn noinformational
#               Suppresses all informational messages. The default is -warn
#               informational, unless you also specify -warn nogeneral.  In
#               this case, no warning or informational messages are displayed.
#
#  -warn nouncalled
#               Suppresses warning messages when a statement function is never
#               called. The default is -warn uncalled.
#
#  -warn nouninitialized
#               Suppresses warning messages for a variable that is used before
#               a value is assigned to it. The default is -warn uninitialized.
#
#  -warn nounreachable
#               Suppresses warning messages for a section of code that is
#               unreachable (no path to it). The default is -warn unreachable.
#
#  -warn nousage
#               Suppresses warning messages about questionable programming
#               practices which, although allowed, often are the result of
#               programming errors.  For example, a continued character or
#               Hollerith literal whose first part ends before the statement
#               field and appears to end with trailing spaces.  The default is
#               -warn usage.
#
#  -warn truncated_source
#               Displays a warning at compile time when there are source char-
#               acters to the right of column 80 (or column 132 if
#               -extend_source is specified) in a non-comment line.  The
#               default is -warn notruncated_source, which suppresses the
#               warning.
#
#  -warn unused Enables warning messages about unused variables.  The default
#               is -warn nounused.
#

FFLAGS = -fast -O3 -w -i8 $(FWARNS)
FFLAGS = -fast -g -w -i8 $(FWARNS)
LIBDEF =  -ltc -lstd 


#alfa osf @chim1.unifi.it g77 doesn't work: g77 give error compiling adf
# FC = g77
# LIB = /home/adf/lib
# FFLAGS = -fno-second-underscore
# LIBDEF =  -ltc -lstd -lresolv 


# other
#
# CRAY - ARCH
# 
# This options are due to
# Joern Amundsen
#
# I have not tested if with the new source
# it still work
#
# ADFHOME=/local/adf/adf2.3/
# ADFARCH=cray_t3e
# FC = f90
# LIBDEF =  -ltc -lstd -X1
# FFLAGS = -dp -M6010,6306 -Oscalar3,vector3,aggress,msgs,negmsgs

#
# PC PentiumII running Linux with g77
#
#
# ADFHOME=/home/adf
# ADFARCH = pentium_linux
# FC = /bin/g77
# LIB = /home/adf/lib
# FFLAGS = -fno-second-underscore -Wall -Wimplicit
# LIBDEF =  -ltc -lstd  -lresolv 



#
# PC 486 Linux with dummy KF function
# this system is used develop the ADFrom
# in a little system with no ADF licence
#
# ADFHOME=
# ADFARCH=
# FC = g77
# LIBDEF =
# FFLAGS = -Wall -g -Wimplicit
# these varables must be void to use the program
# KFDUMF = kfdummy.f
# KFDUMO = kfdummy.o

# Standard names and directories
#
LIB = $(ADFHOME)/OFILES
LIBOBJS = $(ADFHOME)/Install/$(ADFARCH)/ftc.o $(ADFHOME)/Install/$(ADFARCH)/ctc.o
# 
# these varables must be void to use the program
KFDUMF = 
KFDUMO = 

# FtnCheck Options
FTNCOPT = -calltree -crossref -declare -extern -f77 -portability -reference
#
FFILES = cifadf.f cssubs.f moldensubs.f scrio.f openkf.f rwgeneral.f rwbasis.f rwsym.f rwlint.f rwfreq.f sectools.f  $(KFDUMF)
OFILES = cifadf.o cssubs.o moldensubs.o scrio.o openkf.o rwgeneral.o rwbasis.o rwsym.o rwlint.o rwfreq.o sectools.o $(KFDUMO)
IFILES = common.fi cifadf.fi tape21.fh commons.fh lint.fh freq.fh

        all : adfrom

   cifadf.o : cifadf.f tape21.fh
	$(FC) $(FFLAGS) -c cifadf.f

   cssubs.o : cssubs.f
	$(FC) $(FFLAGS) -c cssubs.f

   moldensubs.o : moldensubs.f
	$(FC) $(FFLAGS) -c moldensubs.f

   scrio.o : scrio.f tape21.fh
	$(FC) $(FFLAGS) -c scrio.f

   openkf.o : openkf.f tape21.fh
	$(FC) $(FFLAGS) -c openkf.f

   rwgeneral.o : rwgeneral.f general.fh tape21.fh comcoo.fh
	$(FC) $(FFLAGS) -c rwgeneral.f

   rwbasis.o : rwbasis.f general.fh tape21.fh comcoo.fh
	$(FC) $(FFLAGS) -c rwbasis.f

   rwsym.o : rwsym.f general.fh tape21.fh symmetry.fh
	$(FC) $(FFLAGS) -c rwsym.f

   rwlint.o : rwlint.f lint.fh general.fh tape21.fh
	$(FC) $(FFLAGS) -c rwlint.f

   rwfreq.o : rwfreq.f freq.fh general.fh tape21.fh
	$(FC) $(FFLAGS) -c rwfreq.f

   sectools.o : sectools.f section.fh
	$(FC) $(FFLAGS) -c sectools.f

   kfdummy.o : kfdummy.f tape21.fh
	$(FC) $(FFLAGS) -c kfdummy.f

      adfrom: $(OFILES) $(LIBOBJS)
	$(FC) $(FFLAGS) $(OFILES) $(LIBOBJS) -L$(LIB) $(LIBBLAS) $(LIBLAPAK)  $(LIBDEF) -o adfrom


#
#
# Fortran check!
#

   ftncheck: $(FFILES)
	ftnchek $(FTNCOPT) $(FFILES) > ftncheck.out
#
#
#
      clean:
	rm adfrom *.o ftncheck.out
#
#