-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (57 loc) · 2.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# This makefile is constructed for GNU make - 4/00.
# Meant for use with a project using modules (with module code in MODDIR)
SRCDIR = ./src
MODDIR = ./mod
MODUTILDIR = ./mod/util
# split f95, and module lists... Modules need to be compiled first
# split into f95, and module lists... Modules need to be compiled first
SRCf95 = $(wildcard $(SRCDIR)/*.f95)
OBJf95 = $(SRCf95:%.f95=%.o)
SRCMODf95 = $(wildcard $(MODDIR)/*.f95)
OBJMODf95 = $(SRCMODf95:%.f95=%.o)
SRCMODUTILf95 = $(wildcard $(MODUTILDIR)/*.f95)
OBJMODUTILf95 = $(SRCMODUTILf95:%.f95=%.o)
INC = $(wildcard $(SRCDIR)/*.inc)
# for debugging, debug flag and detailed runtime error checking.
#FLAGS = -g -C -r8 -Mbounds
# standard compiler optimization
# Note: was having issues with compiling the code with -fast on newer pgi compilers...
# using all -fast options other than -Munroll which seems to cause the issue...
#FLAGS = -fast -r8
FLAGS = -O -Mvect=sse -Mcache_align -Mpre -Mnoframe -Mlre -Mflushz -Mautoinline -r8
# No compiler optimization
#FLAGS = -r8
# includes in SRCDIR, .mod files in MODDIR
OPT = -I$(SRCDIR) -I$(MODDIR) -I$(MODUTILDIR) $(FLAGS)
LINKOPT = $(FLAGS)
# Include default liblapack.a and libblas.a for LAPACK calculations
LIBS = -llapack -lblas -fopenmp
COMPILER = pgf95
# Primary goal: create executable from object files if object files have changed. Depends on OBJMODUTIL, OBJMOD, and OBJ
# Note: Generally, fortran modules must come first in the compile list... Also, if a module depends on another module in fortran,
# this module must be compiled first so that the subsequent module can see it's .mod file during compile. This appears to be due to the fact that
# the .mod file performs some external function prototyping for the module functions, and since the .mod is autogenerated when a module is compiled,
# these prototypes cant be explicitly included a-priori in the code that uses the module (ala .h files in C). Modules used in
# other modules must be compiled first...
cactus : $(OBJMODUTILf95) $(OBJMODf95) $(OBJf95)
$(COMPILER) -o $@ $(LINKOPT) $(OBJMODUTILf95) $(OBJMODf95) $(OBJf95) $(LIBS)
# Secondary goals: rules for OBJ. If Makefile or include files are changed, update
$(OBJMODUTILf95) $(OBJMODf95) $(OBJf95) : Makefile $(INC)
# Further secondary goals for OBJ: If individual source files are changed, update the corresponding OBJ
$(OBJMODUTILf95):$(MODUTILDIR)%.o : $(MODUTILDIR)%.f95
$(COMPILER) $(OPT) -c $<
mv $(@F) ${MODUTILDIR}
mv *.mod ${MODUTILDIR}
$(OBJMODf95):$(MODDIR)%.o : $(MODDIR)%.f95
$(COMPILER) $(OPT) -c $<
mv $(@F) ${MODDIR}
mv *.mod ${MODDIR}
$(OBJf95):$(SRCDIR)%.o : $(SRCDIR)%.f95
$(COMPILER) $(OPT) -c $<
mv $(@F) ${SRCDIR}
clean :
rm -f $(SRCDIR)/*.o
rm -f $(MODDIR)/*.o
rm -f $(MODDIR)/*.mod
rm -f $(MODUTILDIR)/*.o
rm -f $(MODUTILDIR)/*.mod