Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
197 lines (169 loc) · 6.32 KB
/
Copy pathmakefile
File metadata and controls
197 lines (169 loc) · 6.32 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#===============================================================================
#
# VFS (Visual Fortran Solvers) Makefile
#
#-------------------------------------------------------------------------------
#-------------------------------------
# Default options for compilation
#-------------------------------------
FORTRAN ?= gnu
ASSERT ?= yes
DEBUG ?= no
#--------------------------
# Variable definitions
#--------------------------
# Directories for objects and modules. (No need to change.)
DIR_BINARY = .
DIR_MODULE = .Modules
DIR_OBJECT = .Objects
# Program name (This should hardly change)
PROGRAM_NAME = VFS
PROGRAM_FILE = $(DIR_BINARY)/$(PROGRAM_NAME)
#-------------------------------------------
# Variables to pass to compiled program
#-------------------------------------------
PASS_ON = -DVFS=1
ifeq ($(ASSERT), yes)
PASS_ON += -DVFS_ASSERT=1
else
PASS_ON += -DVFS_ASSERT=0
endif
ifeq ($(DEBUG), yes)
PASS_ON += -DVFS_DEBUG=1
else
PASS_ON += -DVFS_DEBUG=0
endif
$(info #=======================================================================)
$(info # Compiling $(PROGRAM_NAME) with compiler $(FORTRAN))
$(info #-----------------------------------------------------------------------)
$(info # Usage: )
$(info # make <FORTRAN=gnu/intel/nvidia> <ASSERT=yes/no> <DEBUG=no/yes> )
$(info # )
$(info # Examples: )
$(info # make - compile with gnu compiler )
$(info # make FORTAN=intel - compile with intel compiler )
$(info # make DEBUG=yes - compile with gnu compiler in debug mode )
$(info #-----------------------------------------------------------------------)
#-------------------------------------------------------------------------------
# Compiler and linker options
#-------------------------------------------------------------------------------
# Note: Changes only when support to a new Fortran compiler is added.
#-------------------------------------------------------------------------------
#--------------------
# Fortran == gnu
#--------------------
ifeq ($(FORTRAN), gnu)
FC = gfortran
ifeq ($(DEBUG),yes)
OPT_COMP = -J $(DIR_MODULE) -fdefault-real-8 -fdefault-integer-8 -O0 -g \
-Wunused-parameter -Wall \
-cpp
else
OPT_COMP = -J $(DIR_MODULE) -fdefault-real-8 -fdefault-integer-8 -O3 -cpp
endif
OPT_LINK = $(OPT_COMP)
$(info # Using GNU Fortran compiler with options: $(OPT_COMP))
endif
#----------------------
# Fortran == intel
#----------------------
ifeq ($(FORTRAN), intel)
FC = ifort
ifeq ($(DEBUG),yes)
OPT_COMP = -module $(DIR_MODULE) -r8 -i8 -O0 -g -warn all -check all \
-debug all -fpe-all=0 -traceback -cpp
else
OPT_COMP = -module $(DIR_MODULE) -r8 -i8 -O3 -cpp
endif
# Disable suggestion to use new version of Fortran compiler
OPT_COMP += -diag-disable=10448
OPT_LINK = $(OPT_COMP)
$(info # Using Intel Fortran compiler with options: $(OPT_COMP))
endif
#-----------------------
# Fortran == nvidia
#-----------------------
ifeq ($(FORTRAN), nvidia)
FC = nvfortran
ifeq ($(DEBUG),yes)
OPT_COMP = -module $(DIR_MODULE) -r8 -i8 -O0 -g -cpp
else
OPT_COMP = -module $(DIR_MODULE) -r8 -i8 -O3 -cpp
endif
OPT_LINK = $(OPT_COMP)
$(info # Using Nvidia Fortran compiler with options: $(OPT_COMP))
endif
#------------------------------------------------------
# List of sources for modules and functions
#------------------------------------------------------
# Modules' order must obey their dependency
# This list should therefore be written "by hand".
# Note: Modules written in lower case
# letters are candidates for deletion.
#------------------------------------------------------
#-------------
# Modules
#-------------
# Modules in shared directories
SRC_MOD = Const_Mod.f90 \
Assert_Mod.f90 \
Foul_Mod.f90 \
Swap_Mod.f90 \
Sort_Mod.f90 \
Grid_Mod.f90 \
Matrix_Mod.f90 \
Dense_Mod.f90 \
Sparse_Mod.f90 \
In_Out_Mod.f90 \
Lin_Alg_Mod.f90 \
Discretize_Mod.f90 \
Solvers_Mod.f90 \
Demo_Mod.f90
#---------------
# Functions
#---------------
# Sources for all functions are obtained by a shell command
SRC_FUN = $(shell ls -1 *.f90 \
| xargs -n1 basename \
| grep -v -i _Mod)
#----------------------------------------------------------------------
# List of objects generated from the list of modules and functions
#----------------------------------------------------------------------
# Note: This doesn't need editing.
#----------------------------------------------------------------------
OBJ_MOD = $(SRC_MOD:%.f90=$(DIR_OBJECT)/%.o)
OBJ_FUN = $(SRC_FUN:%.f90=$(DIR_OBJECT)/%.o)
OBJ = $(OBJ_MOD) $(OBJ_FUN)
#---------------------------------------------------------
# Default rule to build Fortran modules and functions
#---------------------------------------------------------
# Note: This doesn't need editing.
#---------------------------------------------------------
# Modules
$(DIR_OBJECT)/%.o: %.f90 %/*.f90 makefile*
@echo FC $<
@$(FC) $(OPT_COMP) $(PASS_ON) -c -o $@ $<
# Functions
$(DIR_OBJECT)/%.o: %.f90 makefile*
@echo FC $<
@$(FC) $(OPT_COMP) $(PASS_ON) -c -o $@ $<
#-----------------------------------
# Rule to build main program
#-----------------------------------
# Note: Should not be modified.
#-----------------------------------
$(PROGRAM_FILE): $(OBJ)
@echo Linking "\033[0;32m $(PROGRAM_FILE) \033[0m"
@$(FC) $(OPT_LINK) -o $(PROGRAM_FILE) $(OBJ)
#--------------------------------------------------------------------
# Explicit dependencies for modules
#--------------------------------------------------------------------
# These are automatically generated by:
# Sources/Utilities/create_external_dependencies_for_makefile.sh
#--------------------------------------------------------------------
include makefile_explicit_dependencies
#---------------------
# Explicit target.
#---------------------
clean:
rm -f $(DIR_OBJECT)/*.o $(DIR_MODULE)/*.mod $(PROGRAM_FILE)