forked from 2decomp-fft/2decomp-fft
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
168 lines (137 loc) · 4.78 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
163
164
165
166
167
168
#=======================================================================
# Makefile for 2DECOMP&FFT
#=======================================================================
# Choose pre-processing options
# -DDOUBLE_PREC - use double-precision
# -DSAVE_SINGLE - Save 3D data in single-precision
# -DDEBG - debugging
# -DOVERWIR - Enable overwriting optimisation in MKL FFT
# generate a Git version string
GIT_VERSION := $(shell git describe --tag --long --always)
#DEFS = -DDOUBLE_PREC -DVERSION=\"$(GIT_VERSION)\" # add under Makefile.compilers
LCL = local# local,lad,sdu,archer
CMP = gcc# intel,gcc,nagfor,cray,nvhpc
FFT ?= generic# fftw3,fftw3_f03,generic,mkl,cufft
PARAMOD = mpi # multicore,gpu
PROFILER ?= none# none, caliper
BUILD ?= # debug can be used with gcc
FCFLAGS ?= # user can set default compiler flags
LDFLAGS ?= # user can set default linker flags
FFLAGS = $(FCFLAGS)
LFLAGS = $(LDFLAGS)
MODFLAG = -J
LIBDECOMP = decomp2d
AR = ar
LIBOPT = rcs
#######CMP settings###########
CANS_CONF=../../build.conf
ifeq ("$(wildcard $(CANS_CONF))","")
CMPINC = Makefile.compilers
else
CMPINC = Makefile-CaNS.compilers
endif
include $(CMPINC)
### List of files for the main code
SRCDECOMP = decomp_2d_constants.f90 factor.f90 decomp_2d.f90 log.f90 io.f90
#######FFT settings##########
ifeq ($(FFT),fftw3)
FFTW3_PATH ?= /usr
FFTW3_PATH_INCLUDE ?= $(FFTW3_PATH)/include
FFTW3_PATH_LIB ?= $(FFTW3_PATH)/lib
INC=-I$(FFTW3_PATH_INCLUDE)
LIBFFT=-L$(FFTW3_PATH_LIB) -lfftw3 -lfftw3f
else ifeq ($(FFT),fftw3_f03)
FFTW3_PATH ?= /usr
FFTW3_PATH_INCLUDE ?= $(FFTW3_PATH)/include
FFTW3_PATH_LIB ?= $(FFTW3_PATH)/lib
INC=-I$(FFTW3_PATH_INCLUDE)
LIBFFT=-L$(FFTW3_PATH_LIB) -lfftw3 -lfftw3f
else ifeq ($(FFT),generic)
SRCDECOMP += ./glassman.f90
INC=
LIBFFT=
else ifeq ($(FFT),mkl)
SRCDECOMP += $(MKLROOT)/include/mkl_dfti.f90
LIBFFT=-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_sequential.a $(MKLROOT)/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread
INC=-I$(MKLROOT)/include
else ifeq ($(FFT),cufft)
CUFFT_PATH ?= $(NVHPC)/Linux_x86_64/$(EBVERSIONNVHPC)/compilers
INC=-I$(CUFFT_PATH)/include
#LIBFFT=-L$(CUFFT_PATH)/lib64 -Mcudalib=cufft
endif
### IO Options ###
LIBIO :=
OPTIO :=
INCIO :=
ADIOS2DIR :=
ifeq ($(IO),adios2)
ifeq ($(ADIOS2DIR),)
$(error Set ADIOS2DIR=/path/to/adios2/install/)
endif
OPTIO := -DADIOS2 $(OPT)
INCIO := $(INC) $(shell $(ADIOS2DIR)/bin/adios2-config --fortran-flags) #$(patsubst $(shell $(ADIOS2DIR)/bin/adios2-config --fortran-libs),,$(shell $(ADIOS2DIR)/bin/adios2-config -f))
LIBIO := $(shell $(ADIOS2DIR)/bin/adios2-config --fortran-libs)
endif
### Add the profiler if needed
ifneq ($(PROFILER),none)
DEFS += -DPROFILER
endif
ifeq ($(PROFILER),caliper)
CALIPER_PATH ?= xxxxxxxxx/caliper/caliper_2.8.0
SRCDECOMP := $(SRCDECOMP) profiler_caliper.f90
INC := $(INC) -I$(CALIPER_PATH)/include/caliper/fortran
LFLAGS := $(LFLAGS) -L$(CALIPER_PATH)/lib -lcaliper
endif
#######OPTIONS settings###########
OPT =
LINKOPT = $(FFLAGS)
#-----------------------------------------------------------------------
# Normally no need to change anything below
OBJDIR = obj
SRCDIR = src
DECOMPINC = mod
FFLAGS += $(MODFLAG)$(DECOMPINC) -I$(DECOMPINC)
SRCDECOMP := $(SRCDECOMP) fft_$(FFT).f90 fft_log.f90
SRCDECOMP_ = $(patsubst %.f90,$(SRCDIR)/%.f90,$(filter-out %/mkl_dfti.f90,$(SRCDECOMP)))
SRCDECOMP_ += $(filter %/mkl_dfti.f90,$(SRCDECOMP))
OBJDECOMP_MKL_ = $(patsubst $(MKLROOT)/include/%.f90,$(OBJDIR)/%.f90,$(filter %/mkl_dfti.f90,$(SRCDECOMP_)))
OBJDECOMP_MKL = $(OBJDECOMP_MKL_:%.f90=%.o)
OBJDECOMP = $(SRCDECOMP_:$(SRCDIR)/%.f90=$(OBJDIR)/%.o)
OPT += $(OPTIO)
INC += $(INCIO)
-include Makefile.settings
all: $(DECOMPINC) $(OBJDIR) $(LIBDECOMP)
$(DECOMPINC):
mkdir $(DECOMPINC)
$(LIBDECOMP) : Makefile.settings lib$(LIBDECOMP).a
lib$(LIBDECOMP).a: $(OBJDECOMP_MKL) $(OBJDECOMP)
$(AR) $(LIBOPT) $@ $^
$(OBJDIR):
mkdir $(OBJDIR)
$(OBJDECOMP) : $(OBJDIR)/%.o : $(SRCDIR)/%.f90
$(FC) $(FFLAGS) $(OPT) $(DEFS) $(INC) -c $< -o $@
$(OBJDECOMP_MKL) : $(OBJDIR)/%.o : $(MKLROOT)/include/%.f90
$(FC) $(FFLAGS) $(OPT) $(DEFS) $(INC) -c $(MKLROOT)/include/mkl_dfti.f90 -o $(OBJDIR)/mkl_dfti.o
examples: $(LIBDECOMP)
$(MAKE) -C examples
.PHONY: check
check: examples
$(MAKE) -C examples $@
.PHONY: clean
clean: clean-examples
rm -f $(OBJDIR)/*.o $(DECOMPINC)/*.mod $(DECOMPINC)/*.smod lib$(LIBDECOMP).a
rm -f ./*.o ./*.mod ./*.smod # Ensure old files are removed
rm -f Makefile.settings
clean-examples:
$(MAKE) -C examples clean
.PHONY: Makefile.settings
Makefile.settings:
echo "FC = $(FC)" > $@
echo "FFLAGS = $(FFLAGS)" >> $@
echo "OPT = $(OPT)" >> $@
echo "DEFS = $(DEFS)" >> $@
echo "INC = $(INC)" >> $@
echo "LIBOPT = $(LIBOPT)" >> $@
echo "LIBFFT = ${LIBFFT}" >> $@
echo "LFLAGS = $(LFLAGS)" >> $@
export