/
Makefile
111 lines (90 loc) · 3.16 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
# Compiler options
HOSTNAME = $(firstword $(subst -, ,$(shell hostname)))
FC = gfortran
FCFLAGS = -O3 -ffast-math -funroll-loops -march=native
DEBUG = -O0 -ffast-math -funroll-loops -march=native -fcheck=bounds -g -fbacktrace
DEBUGALL = -O0 -ffast-math -funroll-loops -march=native -Wall -pedantic -Wconversion-extra -fcheck=all -g -fbacktrace
# Required libraries: Lapack, FFTW3, HDF5
LIBS = -lm -L/usr/local/lib -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lfftw3 -llapack -lhdf5_fortran -lhdf5 -lhdf5_hl -lblas
# Source tree definitions
SRC = src
VPATH = $(SRC)
BINDIR = bin
EXEC = mueller_calc
.SUFFIXES:
.SUFFIXES: .o .mod .f90
# Hello world
yell = "Starting Make..."
# Includes and flag for putting .mod files to directory bin, home version
INCS = -I/usr/include -I/usr/local/include/ -I/usr/include/hdf5/serial/ -J${BINDIR}
# Dependency tree
OBJECTS = ${BINDIR}/common.o \
${BINDIR}/sfunctions.o \
${BINDIR}/h5io.o \
${BINDIR}/io.o \
${BINDIR}/gaussquad.o \
${BINDIR}/integration_points.o \
${BINDIR}/translations.o \
${BINDIR}/mie.o \
${BINDIR}/possu.o \
${BINDIR}/sparse.o \
${BINDIR}/singularity_subtraction.o \
${BINDIR}/singularity_subtraction_N.o \
${BINDIR}/integrals.o \
${BINDIR}/geometry.o \
${BINDIR}/sparse_mat.o \
${BINDIR}/precorrection.o \
${BINDIR}/projection.o \
${BINDIR}/build_G.o \
${BINDIR}/gmres_module.o \
${BINDIR}/transformation_matrices.o \
${BINDIR}/setup.o \
${BINDIR}/T_matrix.o \
${BINDIR}/mueller.o \
${BINDIR}/main.o
###############################################################################
# Taito version for everything
FCTAITO = mpif90
INCSTAITO = -I/usr/include -I/usr/local/include/ -I${FFTW_ROOT}/include/ -I${H5ROOT}/include/ -m64 -I$(MKLROOT)/include/ -J${BINDIR}
LIBSTAITO = -L${FFTW_ROOT}/lib -lfftw3 -lfftw3_mpi -L${H5ROOT}/lib -lhdf5_fortran -lhdf5 -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_gf_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm -ldl
ifeq ($(HOSTNAME),taito)
yell = "Starting Make... When in taito, remember to run 'module load gcc mkl fftw hdf5-serial' or Make will fail. Upon failure, load modules, clean and run Make again."
FC := $(FCTAITO)
INCS := $(INCSTAITO)
LIBS := $(LIBSTAITO)
endif
###############################################################################
# No need to touch below, unless bad makefileing or messages need tweaking...
.PHONY: all clean
.SECONDARY: main-build
all: pre-build main-build post-build
pre-build:
@echo $(yell)
main-build: ${EXEC} | $(BINDIR)
post-build:
@echo "Target $(EXEC) compiled successfully"
debug: FCFLAGS = $(DEBUG)
debug: all
debugall: FCFLAGS = $(DEBUGALL)
debugall: all
$(BINDIR):
@echo "Binary files are put into the directory $(BINDIR)"
@mkdir -p ${BINDIR}
${BINDIR}/%.o: %.f90 |$(BINDIR)
@echo "Compiling $^"
@${FC} ${FCFLAGS} $(INCS) -c $^ -o $@
${EXEC}: ${OBJECTS}
@echo "Linking the target"
@${FC} ${FCFLAGS} ${OBJECTS} ${LIBS} -o $@
# Clean only objects
clean:
@echo "Deleted all .o files"
@rm -rf $(BINDIR)/*.o
@rm -rf *.mod
@rm -f *~
# Full clean
veryclean: clean
@echo "Deleted all .mod files"
@echo "Deleted executable and directory bin"
@rm -f $(EXEC)
@rm -rf $(BINDIR)