-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile_gckpp
274 lines (218 loc) · 7.28 KB
/
Makefile_gckpp
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# User: Set here the F90 compiler and options
# Pedefined compilers: INTEL, PGF, HPUX, LAHEY
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Pick a default compiler if not supplied
ifndef COMPILER
#COMPILER = LAHEY
#COMPILER = INTEL
#COMPILER = PGF
#COMPILER = HPUX
COMPILER = GFORTRAN
endif
FC_LAHEY = lf95
# More aggressive for production runs:
#FOPT_LAHEY = -Cpp --pca -O
# More checking for debugging:
FOPT_LAHEY = -Cpp --chk a,e,s,u --pca --ap -O0 -g --trap --trace --chkglobal
FC_INTEL = ifort
# More aggressive for production runs:
#FOPT_INTEL = -cpp -O -fp-model precise -pc80 -prec_div
# More checking for debugging:
FOPT_INTEL = -cpp -O0 -fp-model strict -implicitnone -ftrapuv \
-debug all -check all -warn all -g
FC_PGF = pgf90
# More aggressive for production runs:
FOPT_PGF = -Mpreprocess -O -fast -pc 80 -Kieee
# More checking for debugging:
#FOPT_PGF = -Mpreprocess -O0 -Mbounds -Mchkfpstk -Mchkptr -Mchkstk \
# -Ktrap=fp -pc 80 -Kieee
FC_HPUX = f90
FOPT_HPUX = -O -u +Oall +check=on
FC_GFORTRAN = gfortran
FOPT_GFORTRAN = -cpp -O -g
# define FULL_ALGEBRA for non-sparse integration
FC = $(FC_$(COMPILER))
FOPT = $(FOPT_$(COMPILER)) # -DFULL_ALGEBRA
LIBS =
#LIBS = -llapack -lblas
#############################################################################
# Test if various files are found on disk or not
# so that we can include/exclude them from the Make process
#############################################################################
# JacobianSP
HAS_JAC_SP =0
ifeq ($(shell test -f gckpp_JacobianSP.F90 && echo y),y)
HAS_JAC_SP =1
endif
# Jacobian
HAS_JAC = 0
ifeq ($(shell test -f gckpp_Jacobian.F90 && echo y),y)
HAS_JAC = 1
endif
# HessianSP
HAS_HES_SP = 0
ifeq ($(shell test -f gckpp_HessianSP.F90 && echo y),y)
HAS_HES_SP = 1
endif
# Hessian
HAS_HES=0
ifeq ($(shell test -f gckpp_Hessian.F90 && echo y),y)
HAS_HES = 1
endif
# StoichiomSP
HAS_STM_SP = 0
ifeq ($(shell test -f gckpp_StoichiomSP.F90 && echo y),y)
HAS_STM_SP=1
endif
# Stoichiom
HAS_STM = 0
ifeq ($(shell test -f gckpp_Stoichiom.F90 && echo y),y)
HAS_STM=1
endif
# If an external rates module has been suppllied,
# also define the correspoinding object file
ifdef EXTERNAL_RATES_F90
EXTERNAL_RATES_OBJ := $(EXTERNAL_RATES_F90:.f90=.o)
EXTERNAL_RATES_OBJ := $(EXTERNAL_RATES_OBJ:.F90=.o)
endif
#############################################################################
# Construct lists of objects and sources
#############################################################################
# Command to create Matlab mex gateway routines
# Note: use $(FC) as the mex Fortran compiler
MEX = mex
# NOTE: Allow for an external module to be USE-d by F90_Rates
# by specifying the relevant environment variables.
GENSRC = gckpp_Precision.F90 gckpp_Parameters.F90 \
gckpp_Global.F90 $(EXTERNAL_RATES_F90)
GENOBJ = gckpp_Precision.o gckpp_Parameters.o \
gckpp_Global.o $(EXTERNAL_RATES_OBJ)
FUNSRC = gckpp_Function.F90
FUNOBJ = gckpp_Function.o
JACSRC =
JACOBJ =
JACSPOBJ =
ifeq ($(HAS_JAC_SP),1)
JACSRC += gckpp_JacobianSP.F90
JACOBJ += gckpp_JacobianSP.o
JACSPOBJ += gckpp_JacobianSP.o
endif
ifeq ($(HAS_JAC),1)
JACSRC += gckpp_Jacobian.F90
JACOBJ += gckpp_Jacobian.o
endif
HESSRC =
HESOBJ =
HESSPOBJ =
ifeq ($(HAS_HES_SP),1)
HESSRC += gckpp_HessianSP.F90
HESOBJ += gckpp_HessianSP.o
HESSPOBJ += gckpp_HessianSP.o
endif
ifeq ($(HAS_HES),1)
HESSRC += gckpp_Hessian.F90
HESOBJ += gckpp_Hessian.o
endif
STMSRC =
STMOBJ =
STMSPOBJ =
ifeq ($(HAS_STM_SP),1)
STMSRC += gckpp_StoichiomSP.F90
STMOBJ += gckpp_StoichiomSP.o
STMSPOBJ += gckpp_StoichiomSP.o
endif
ifeq ($(HAS_HES),1)
HESSRC += gckpp_Stoichiom.F90
HESOBJ += gckpp_Stoichiom.o
endif
UTLSRC = gckpp_Rates.F90 gckpp_Util.F90 gckpp_Monitor.F90
UTLOBJ = gckpp_Rates.o gckpp_Util.o gckpp_Monitor.o
LASRC = gckpp_LinearAlgebra.F90
LAOBJ = gckpp_LinearAlgebra.o
STOCHSRC = gckpp_Stochastic.F90
STOCHOBJ = gckpp_Stochastic.o
MAINSRC = gckpp_Main.F90 gckpp_Initialize.F90 \
gckpp_Integrator.F90 gckpp_Model.F90
MAINOBJ = gckpp_Main.o gckpp_Initialize.o \
gckpp_Integrator.o gckpp_Model.o
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# User: modify the line below to include only the
# objects needed by your application
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALLOBJ = $(GENOBJ) $(FUNOBJ) $(JACOBJ) $(HESOBJ) $(STMOBJ) \
$(UTLOBJ) $(LAOBJ)
SIMPLEOBJ = $(GENOBJ) $(FUNOBJ) $(UTLOBJ) $(LAOBJ)
#############################################################################
# Makefile targets and rules
#############################################################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# User: modify the line below to include only the
# executables needed by your application
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
all: exe
exe: $(ALLOBJ) $(MAINOBJ)
$(FC) $(FOPT) $(ALLOBJ) $(MAINOBJ) $(LIBS) -o gckpp.exe
stochastic:$(ALLOBJ) $(STOCHOBJ) $(MAINOBJ)
$(FC) $(FOPT) $(ALLOBJ) $(STOCHOBJ) $(MAINOBJ) $(LIBS) \
-o gckpp_stochastic.exe
mex: $(ALLOBJ)
$(MEX) FC#$(FC) -fortran -O gckpp_mex_Fun.F90 $(ALLOBJ)
$(MEX) FC#$(FC) -fortran -O gckpp_mex_Jac_SP.F90 $(ALLOBJ)
$(MEX) FC#$(FC) -fortran -O gckpp_mex_Hessian.F90 $(ALLOBJ)
clean:
rm -f *.o *.mod \
gckpp*.dat gckpp.exe gckpp*.mexglx \
gckpp.log
distclean:
rm -f *.o *.mod \
gckpp*.dat gckpp*.exe gckpp.log \
gckpp_*.f90 gckpp_*.F90 gckpp_*.mexglx \
results*.m *.dat
gckpp_Precision.o: gckpp_Precision.F90
$(FC) $(FOPT) -c $<
gckpp_Parameters.o: gckpp_Parameters.F90 gckpp_Precision.o
$(FC) $(FOPT) -c $<
gckpp_Monitor.o: gckpp_Monitor.F90 gckpp_Precision.o
$(FC) $(FOPT) -c $<
gckpp_Global.o: gckpp_Global.F90 gckpp_Parameters.o gckpp_Precision.o
$(FC) $(FOPT) -c $<
gckpp_Initialize.o: gckpp_Initialize.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_Function.o: gckpp_Function.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_Stochastic.o: gckpp_Stochastic.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_JacobianSP.o: gckpp_JacobianSP.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_Jacobian.o: gckpp_Jacobian.F90 $(GENOBJ) $(JACSPOBJ)
$(FC) $(FOPT) -c $<
gckpp_LinearAlgebra.o: gckpp_LinearAlgebra.F90 $(GENOBJ) $(JACSPOBJ)
$(FC) $(FOPT) -c $<
gckpp_Rates.o: gckpp_Rates.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_HessianSP.o: gckpp_HessianSP.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_Hessian.o: gckpp_Hessian.F90 $(GENOBJ) $(HESSPOBJ)
$(FC) $(FOPT) -c $<
gckpp_StoichiomSP.o: gckpp_StoichiomSP.F90 $(GENOBJ)
$(FC) $(FOPT) -c $<
gckpp_Stoichiom.o: gckpp_Stoichiom.F90 $(GENOBJ) $(STMSPOBJ)
$(FC) $(FOPT) -c $<
gckpp_Util.o: gckpp_Util.F90 $(GENOBJ) gckpp_Monitor.o
$(FC) $(FOPT) -c $<
gckpp_Main.o: gckpp_Main.F90 $(ALLOBJ) \
gckpp_Initialize.o gckpp_Model.o gckpp_Integrator.o
$(FC) $(FOPT) -c $<
gckpp_Model.o: gckpp_Model.F90 $(ALLOBJ) gckpp_Integrator.o
$(FC) $(FOPT) -c $<
gckpp_Integrator.o: gckpp_Integrator.F90 $(ALLOBJ)
$(FC) $(FOPT) -c $<
# Define rule for a user-defined module that gets USE-d by F90_Rates.
# This rule is only applied if both variables are not blank.
ifdef EXTERNAL_RATES_F90
ifdef EXTERNAL_RATES_OBJ
$(EXTERNAL_RATES_OBJ): $(EXTERNAL_RATES_F90) gckpp_Precision.o gckpp_Global.o gckpp_Parameters.o
$(FC) $(FOPT) -c $<
endif
endif