forked from pseudospectators/FLUSI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·132 lines (107 loc) · 4.36 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
# Makefile for fsi and mhd codes. See README for necessary environment
# variables.
# Non-module Fortran files to be compiled:
FFILES = rhs.f90 vis.f90 fluid_time_step.f90 init_fields.f90 \
mask.f90 mask_fsi.f90 mask_mhd.f90 save_fields.f90 time_step.f90 \
init_fields_mhd.f90 init_fields_fsi.f90 integrals.f90 params.f90 \
postprocessing.f90 runtime_control.f90 drag.f90 \
sponge.f90 fft_unit_test.f90 draw_plate.f90 draw_sphere.f90 \
kineloader.f90 rotation_matrices.f90 \
add_channel.f90 add_cavity.f90 init_scalar.f90 \
passive_scalar.f90 noncircular_cylinder.f90 ghostpoints.f90 draw_flexible_plate.f90
# Object and module directory:
OBJDIR=obj
OBJS := $(FFILES:%.f90=$(OBJDIR)/%.o)
# Files that create modules:
MFILES = vars.f90 kine.f90 cof_p3dfft.f90 solid_solver.f90 \
interpolation.f90 basic_operators.f90 insects.f90
MOBJS := $(MFILES:%.f90=$(OBJDIR)/%.o)
# Source code directories (colon-separated):
VPATH = src
VPATH += :src/inicond:src/inicond/hyd:src/inicond/mhd:src/inicond/scalar
VPATH += :src/geometry:src/geometry/hyd:src/geometry/mhd
VPATH += :src/insects:src/solid_solver
# Set the default compiler if it's not already set, make sure it's not F77.
ifndef FC
FC = mpif90
endif
ifeq ($(FC),f77)
FC = mpif90
endif
# GNU compiler
ifeq ($(shell $(FC) --version 2>&1 | head -n 1 | head -c 3),GNU)
# Specify directory for compiled modules:
FFLAGS += -J$(OBJDIR) # specify directory for modules.
FFLAGS += -Wall # warn for unused and uninitialzied variables
#FFLAGS += -Werror # warnings are errors
FFLAGS += -pedantic
PPFLAG= -cpp #preprocessor flag
# Debug flags for gfortran:
#FFLAGS += -Wuninitialized -O -fimplicit-none -fbounds-check -g -ggdb
endif
# Intel compiler
ifort:=$(shell $(FC) --version | head -c 5)
ifeq ($(ifort),ifort)
PPFLAG= -fpp #preprocessor flag
DIFORT= -DIFORT # define the IFORT variable
FFLAGS += -module $(OBJDIR) # specify directory for modules.
FFLAGS += -vec_report0
endif
#IBM compiler
ifeq ($(shell $(FC) -qversion 2>&1 | head -c 3),IBM)
FFLAGS += -qmoddir=$(OBJDIR)
FFLAGS += -I$(OBJDIR)
DIFORT=-WF,-DTURING # this defines the TURING with the IBM compiler
PPFLAG=-qsuffix=cpp=f90 #preprocessor flag
endif
PROGRAMS = flusi mhd
# FFT_ROOT is set in envinroment.
FFT_LIB = $(FFT_ROOT)/lib
FFT_INC = $(FFT_ROOT)/include
# P3DFFT_ROOT is set in environment.
P3DFFT_LIB = $(P3DFFT_ROOT)/lib
P3DFFT_INC = $(P3DFFT_ROOT)/include
# HDF_ROOT is set in environment.
HDF_LIB = $(HDF_ROOT)/lib
HDF_INC = $(HDF_ROOT)/include
LDFLAGS = -L$(P3DFFT_LIB) -lp3dfft -L$(FFT_LIB) -lfftw3 -lm
LDFLAGS += $(HDF5_FLAGS) -L$(HDF_LIB) -lhdf5_fortran -lhdf5 -lz -ldl
LDFLAGS += -llapack
FFLAGS += -I$(HDF_INC) -I$(P3DFFT_INC) -I$(FFT_INC) $(PPFLAG) $(DIFORT)
# Both programs are compiled by default.
all: directories $(PROGRAMS)
# Compile main programs, with dependencies.
flusi: flusi.f90 $(MOBJS) $(OBJS)
$(FC) $(FFLAGS) -o $@ $^ $(LDFLAGS)
mhd: mhd.f90 $(MOBJS) $(OBJS)
$(FC) $(FFLAGS) -o $@ $^ $(LDFLAGS)
# Compile modules (module dependency must be specified by hand in
# Fortran). Objects are specified in MOBJS (module objects).
$(OBJDIR)/vars.o: vars.f90
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
$(OBJDIR)/kine.o: kine.f90
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
$(OBJDIR)/cof_p3dfft.o: cof_p3dfft.f90 $(OBJDIR)/vars.o
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
$(OBJDIR)/insects.o: insects.f90 $(OBJDIR)/vars.o $(OBJDIR)/kine.o \
body_geometry.f90 body_motion.f90 rigid_solid_time_stepper.f90 wings_geometry.f90 wings_motion.f90 stroke_plane.f90
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
$(OBJDIR)/solid_solver.o: solid_solver.f90 $(OBJDIR)/vars.o $(OBJDIR)/interpolation.o $(OBJDIR)/basic_operators.o $(OBJDIR)/insects.o \
mouvement.f90 integrate_position.f90 init_beam.f90 save_beam.f90 BeamForces.f90 plate_geometry.f90
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
$(OBJDIR)/interpolation.o: interpolation.f90 $(OBJDIR)/vars.o $(OBJDIR)/basic_operators.o
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
$(OBJDIR)/basic_operators.o: basic_operators.f90 $(OBJDIR)/vars.o $(OBJDIR)/cof_p3dfft.o
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
# Compile remaining objects from Fortran files.
$(OBJDIR)/%.o: %.f90 $(MOBJS)
$(FC) $(FFLAGS) -c -o $@ $< $(LDFLAGS)
clean:
rm -rf $(PROGRAMS) $(OBJDIR)/*.o $(OBJDIR)/*.mod a.out
tidy:
rm -rf $(OBJDIR)/*.o $(OBJDIR)/*.mod a.out
# If the object directory doesn't exist, create it.
.PHONY: directories
directories: ${OBJDIR}
${OBJDIR}:
mkdir -p ${OBJDIR}