#=======================================================================
# User definitions
#

NAME = zeqfc1

F90FILES =
LIBFILES =
F77FILES = openfl.f setup.f constc.f mloop.f cforce.f \
	ztmfc1.f akcalc.f bndary.f uhcalc.f uhinit.f tridag.f\
	nrdhist.f initdat.f setup2.f ssta.f fft2c.f zeq1main.f
CFILES = 
#LIBS = -lcomplib.sgimath
#LIBS = -ldrfftw -ldfftw -lm
LIBS = 
#=======================================================================
# Standard definitions
#
OFILESF90 = $(F90FILES:.f90=.o)
OFILESF77 = $(F77FILES:.f=.o)

# LINUX compilers
F90 = ifort
F77 = ifort
FC = ifort
CC = icc
LD = ifort

VPATH = obj
.SUFFIXES:
.SUFFIXES: .out .o .f90 .f .c .inc .h

#=======================================================================
# Targets and dependencies
#
default: opt
all: a.out
debug:
	@make all "FLAGS = -g $(FLAGS)"
prof:
	@make all "LIBS = -p $(LIBS)"
opt:
	@make all "FLAGS = -O3 $(FLAGS)"
clean:
	rm -rf obj a.out *.o *.kmo *.mod $(NAME)

a.out: obj $(OFILESF77) $(OFILESF90)
	@echo "$(LD) $(OFILESF77) $(OFILESF90) $(LIBS)"
	@cd obj; $(LD) $(OFILESF77) $(OFILESF90) $(LIBS); mv a.out ../$(NAME)
	-rm -r output
	-mkdir output
obj:
	mkdir obj

FFLAGS 	= 	$(opt)
#=======================================================================
# Compilation rules
#
.f90.o:
	$(F90) $(FLAGS) -c $*.f90 -o obj/$*.o
.f.o:
	$(F77) $(FLAGS) -c $*.f -o obj/$*.o
.c.o:
	$(CC) $(FLAGS) -c $*.c -o obj/$*.o
