This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
makefile
142 lines (117 loc) · 4.1 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#
# Define relative path...
#
SRCDIR = sources/main/
SRCDIR2 = sources/variabledef/
SRCDIR3 = sources/wave/
SRCDIR4 = sources/fourier/
SRCDIR5 = sources/timeintegration/
SRCDIR6 = sources/IO/
OBJDIR = obj/
LIBDIR = /usr/local/lib/
BINDIR = bin/
LINKLIB = $(LIBDIR)libfftw3.a $(LIBDIR)liblapack.a $(LIBDIR)librefblas.a
#
# ifort compiler
#
#FC=ifort
#
#OPTFLAGS= -O3 -xHOST -ipo -ip # -fp-model precise this option to keep exactly same fp description
#DBFLAGS= -O0 -traceback -check all -warn all
#
#FLAGMOD1= -module $(OBJDIR) #Flag for writing modules in $(OBJ)
#FLAGMOD2= -module $(OBJDIR) #Flag for reading modules in $(OBJ)
#
# gfortran compiler (optimized for Mac Pro with intel corei7: avx not working on Mac)
FC=gfortran
#
OPTFLAGS= -O3 -march=corei7 -msse2 -funroll-loops -fno-protect-parens -ffast-math
DBFLAGS = -O0 -Wline-truncation -fbounds-check -fpack-derived -fbacktrace -ffpe-summary=all -fimplicit-none -fcheck=all -Wall -Wtabs -Wextra -Wunderflow -Wno-zerotrip -finit-integer=inf -finit-real=nan -ffpe-trap=zero,overflow
FLAGMOD1= -J $(OBJDIR) #Flag for writing modules in $(OBJ)
FLAGMOD2= -I $(OBJDIR) #Flag for reading modules in $(OBJ)
#
nomcode=HOS-NWT
#
#define all modules and subroutines
#
module=\
wavemaking\
filtering\
dealiasing\
resol_HOS\
resol_wmkr\
initial_condition
module2=\
variables\
common_vars\
type
module3=\
definition2\
config_def\
read_ocean_txt\
wave_def\
linear_wave
module4=\
fourier_FFTW
module5=\
runge_kutta\
variablechange
module6=\
input\
vol_energy\
velocities\
output
subroutine=\
# define the list of source files.
SRCS1 = $(addprefix $(SRCDIR), $(addsuffix .f90, $(module))) $(addprefix $(SRCDIR), $(addsuffix .f90, $(subroutine)))
SRCS2 = $(addprefix $(SRCDIR2), $(addsuffix .f90, $(module2)))
SRCS3 = $(addprefix $(SRCDIR3), $(addsuffix .f90, $(module3)))
SRCS4 = $(addprefix $(SRCDIR4), $(addsuffix .f90, $(module4)))
SRCS5 = $(addprefix $(SRCDIR5), $(addsuffix .f90, $(module5)))
SRCS6 = $(addprefix $(SRCDIR6), $(addsuffix .f90, $(module6)))
#
SRCS0 = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) $(SRCS5) $(SRCS6)
SRCS = $(addprefix $(SRCDIR), $(addsuffix .f90, $(nomcode))) $(SRCS0)
build:Release
# top-level rule, to compile everything.
all:clean depend Release
# Targets for compilation
Release: FFLAGS1 = $(OPTFLAGS) $(FLAGMOD1)
Release: FFLAGS2 = $(OPTFLAGS) $(FLAGMOD2)
Release: $(BINDIR)$(nomcode) $(SRCS)
Debug: FFLAGS1 = $(DBFLAGS) $(FLAGMOD1)
Debug: FFLAGS2 = $(DBFLAGS) $(FLAGMOD2)
Debug: $(BINDIR)$(nomcode) $(SRCS)
# now add a line to include the dependency list.
include $(OBJDIR).depend
Objlink = $(addprefix $(OBJDIR), $(addsuffix .o, $(module))) $(addprefix $(OBJDIR), $(addsuffix .o, $(subroutine))) $(addprefix $(OBJDIR), $(addsuffix .o, $(module2))) $(addprefix $(OBJDIR), $(addsuffix .o, $(module3))) $(addprefix $(OBJDIR), $(addsuffix .o, $(module4))) $(addprefix $(OBJDIR), $(addsuffix .o, $(module5))) $(addprefix $(OBJDIR), $(addsuffix .o, $(module6)))
# rule to link the program
$(BINDIR)$(nomcode): $(SRCDIR)$(nomcode:%=%.f90) $(Objlink) $(OBJDIR).depend
$(FC) $(FFLAGS2) -o $(BINDIR)$(nomcode) $(SRCDIR)$(nomcode:%=%.f90) $(Objlink) $(LINKLIB)
# now comes a meta-rule for compiling any ".f90" source file.
$(OBJDIR)%.o: $(SRCDIR)%.f90 $(OBJDIR).depend
$(FC) $(FFLAGS1) -c $< -o $@
$(OBJDIR)%.o: $(SRCDIR2)%.f90 $(OBJDIR).depend
$(FC) $(FFLAGS1) -c $< -o $@
$(OBJDIR)%.o: $(SRCDIR3)%.f90 $(OBJDIR).depend
$(FC) $(FFLAGS1) -c $< -o $@
$(OBJDIR)%.o: $(SRCDIR4)%.f90 $(OBJDIR).depend
$(FC) $(FFLAGS1) -c $< -o $@
$(OBJDIR)%.o: $(SRCDIR5)%.f90 $(OBJDIR).depend
$(FC) $(FFLAGS1) -c $< -o $@
$(OBJDIR)%.o: $(SRCDIR6)%.f90 $(OBJDIR).depend
$(FC) $(FFLAGS1) -c $< -o $@
clean:
rm -f $(OBJDIR)*
rm -f $(OBJDIR).depend
rm -f $(BINDIR)$(nomcode)
@echo "all cleaned up!"
# rule for building dependency lists, and writing them to a file
# named ".depend".
depend $(OBJDIR).depend:
@if test -d bin; then echo "exists"; else mkdir bin; fi
@if test -d obj; then echo "exists"; else mkdir obj; fi
@if test -d bin/Results; then echo "exists"; else mkdir bin/Results; fi
rm -f $(OBJDIR).depend
makedepf90 -b $(OBJDIR) $(SRCS) > $(OBJDIR).depend
.PHONY: clean depend