-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmakefile
163 lines (133 loc) · 3.79 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ options to choose ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# -- GPU --
arch = gpu
# extreme scale simulation results in very large array
#x_scale = enabled
# -- CPU --
#arch = cpu
#openmp = enabled
# whether or not to use avx512 for intel cpu, test before use
#AVX512 = enabled
# -- MIC(KNL) --
# arch = mic
# OpenMP and AVX512 should both be enabled for MIC
# openmp = enabled
# AVX512 = enabled
# -- compiler --
#tool = gcc
tool = nvidia
#tool = intel
# -- optimization options --
#optimization = debug
#optimization = release
optimization = speedy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ options to choose ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
############# DIR #################################
# Directories
DIR=./
OBJ_DIR = $(DIR)1.obj/
EXEC_DIR = $(DIR)1.exec/
SRC_DIR = $(DIR)0.src/
############# DIR #################################
############# architecture ########################
ifeq ($(strip $(arch)), cpu)
BIN_SUFFIX = cpu
ifeq ($(strip $(AVX512)), enabled)
ARCH_FLAGS = -xCORE-AVX512
endif
endif
ifeq ($(strip $(arch)), gpu)
BIN_SUFFIX = gpu
openmp = disabled
#compatible with pgi compiler, for cray compiler: ARCH_FLAGS = -h acc,noomp -h msgs
ARCH_FLAGS = -acc -Mcuda -Minfo=accel -ta=tesla:pinned
FPP_FLAGS = -D_openacc
#enable gpu profiling
#FPP_FLAGS += -Dgpu_profiling
endif
ifeq ($(strip $(arch)), mic)
BIN_SUFFIX = mic
ifeq ($(strip $(AVX512)), enabled)
ARCH_FLAGS = -xMIC-AVX512
endif
endif
############# architecture ########################
############# tools ################################
# -------------- gcc ----------------
ifeq ($(strip $(tool)), gcc)
# -J 0.obj put .mod files to 0.obj directory
MISC_FLAGS = -ffree-line-length-300 -J $(OBJ_DIR)
#for gcc10+, enable the following temporary fix:
#MISC_FLAGS += -fallow-argument-mismatch
ifeq ($(strip $(optimization)), debug)
OPT_FLAGS = -g
else ifeq ($(strip $(optimization)), release)
OPT_FLAGS = -O3
else
OPT_FLAGS = -Ofast
endif
ifeq ($(strip $(openmp)), enabled)
OMP_FLAGS = -fopenmp
endif
endif
# -------------- nvidia ----------------
ifeq ($(strip $(tool)), nvidia)
MISC_FLAGS = -module $(OBJ_DIR)
ifeq ($(strip $(optimization)), debug)
OPT_FLAGS = -g
else ifeq ($(strip $(optimization)), release)
OPT_FLAGS = -O3
else
OPT_FLAGS = -fast
endif
ifeq ($(strip $(openmp)), enabled)
OMP_FLAGS = -mp
endif
#for very large array, add: MISC_FLAGS = -mcmodel=medium
ifeq ($(strip $(x_scale)), enabled)
MISC_FLAGS += -mcmodel=medium
endif
endif
# -------------- intel ----------------
ifeq ($(strip $(tool)), intel)
MISC_FLAGS = -module $(OBJ_DIR)
ifeq ($(strip $(optimization)), debug)
OPT_FLAGS = -debug
else ifeq ($(strip $(optimization)), release)
OPT_FLAGS = -O3
else
OPT_FLAGS = -Ofast
endif
ifeq ($(strip $(openmp)), enabled)
OMP_FLAGS = -qopenmp
endif
endif
############# tools ################################
compiler = mpif90
#compiler = ftn
#compiler = mpiifort
CFLAGS += $(ARCH_FLAGS)
CFLAGS += $(OPT_FLAGS)
CFLAGS += $(OMP_FLAGS)
CFLAGS += $(MISC_FLAGS)
CFLAGS += $(FPP_FLAGS)
LFLAGS = $(CFLAGS)
COMPILE = ${compiler}
LINK = ${compiler}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
objects = Module.o Main.o Initialization.o Misc.o IO.o Kernel.o Monitor.o Mpi_misc.o Mpi.o Boundary.o
pref_objects = $(addprefix $(OBJ_DIR), $(objects))
LBM : | make_dir $(pref_objects)
${LINK} $(LFLAGS) -o $(EXEC_DIR)MF_LBM_singlephase.$(BIN_SUFFIX) $(pref_objects)
$(OBJ_DIR)%.o: $(SRC_DIR)%.F90
${COMPILE} $(CFLAGS) -c $< -o $@
# $@ is the name of the target being generated
# $< the first prerequisite (usually a source file)
.PHONY: clean
clean:
rm -r $(OBJ_DIR)
rm -r $(EXEC_DIR)
make_dir:
@echo "Create directories."
mkdir -p $(DIR)1.exec
mkdir -p $(DIR)1.obj