-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
361 lines (311 loc) · 13.6 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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#------------------------------------------------------------------------------
# GEOS-Chem Global Chemical Transport Model !
#------------------------------------------------------------------------------
#BOP
#
# !MODULE: Makefile
#
# !DESCRIPTION:
#\\
#\\
# !REMARKS:
# To build the programs, call "make" with the following syntax:
# .
# make -jN TARGET REQUIRED-FLAGS [ OPTIONAL-FLAGS ]
# .
# To display a complete list of options, type "make help".
# .
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%% NOTE: Normally you will not have to call this Makefile directly, %%%
# %%% it will be called automatically from the Makefile in the directory %%%
# %%% just above this one! %%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# .
# Makefile uses the following variables:
# .
# Variable Description
# -------- -----------
# SHELL Specifies the shell for "make" to use (usually SHELL=/bin/sh)
# ROOTDIR Specifies the root-level directory of the GEOS-Chem code
# HDR Specifies the directory where GEOS-Chem include files are found
# LIB Specifies the directory where library files (*.a) are stored
# MOD Specifies the directory where module files (*.mod) are stored
# AR Sys var w/ name of library creator program (i.e., "ar", "ranlib")
# MAKE Sys var w/ name of Make command (i.e, "make" or "gmake")
# R8 Specifies the c
#
# !REVISION HISTORY:
# 18 Sep 2013 - M. Long - Initial version
# 17 Oct 2014 - R. Yantosca - Added "gigc_debug" target to print debug output
# 17 Oct 2014 - R. Yantosca - Added "the_nuclear_option" target to totally
# clean the ESMF, MAPL, and FVDYCORE directories
# 17 Oct 2014 - R. Yantosca - Cosmetic changes
# 18 Nov 2014 - R. Yantosca - Remove the fvdycore.install file again after
# making distclean, for safety's sake.
# 12 Dec 2014 - R. Yantosca - Define defaults for ESMF, MAPL, FVdycore
# that can be overridden by cmd line or env var
# 08 Mar 2018 - E. Lundgren - Remove gigc_initialization_mod, gigc_types_mod,
# and gchp_utils
# 21 Dec 2018 - E. Lundgren - Remove compilation condition that xxx.install
# does not exist
#EOP
#------------------------------------------------------------------------------
#BOC
###############################################################################
### ###
### Initialization section ###
### ###
###############################################################################
# Use the bash shell
SHELL=/bin/bash
# ROOTDIR is the directory just above this one.
ROOTDIR=..
# Directories where GEOS-Chem code live
HDR=$(ROOTDIR)/Headers
HELP=$(ROOTDIR)/help
LIB=$(ROOTDIR)/lib
MOD=$(ROOTDIR)/mod
# This code here should get the exact number of the intel version (MDY)
ifeq ($(ESMF_COMPILER),intel)
INTELVERSIONTEXT :=$(shell ifort --version))
INTELVERSIONTEXT :=$(sort $(INTELVERSIONTEXT))
LONGVERSION :=$(word 3, $(INTELVERSIONTEXT))
MAJORVERSION :=$(subst ., ,$(LONGVERSION))
MAJORVERSION :=$(firstword $(MAJORVERSION))
MAJORVERSION :=$(strip $(MAJORVERSION))
else ifeq ($(ESMF_COMPILER),intelgcc)
INTELVERSIONTEXT :=$(shell ifort --version))
INTELVERSIONTEXT :=$(sort $(INTELVERSIONTEXT))
LONGVERSION :=$(word 3, $(INTELVERSIONTEXT))
MAJORVERSION :=$(subst ., ,$(LONGVERSION))
MAJORVERSION :=$(firstword $(MAJORVERSION))
MAJORVERSION :=$(strip $(MAJORVERSION))
else ifeq ($(ESMF_COMPILER),gfortran)
GNUVERSIONTEXT :=$(shell gfortran -dumpversion))
LONGVERSION :=$(GNUVERSIONTEXT))
MAJORVERSION :=$(subst ., ,$(LONGVERSION))
MAJORVERSION :=$(firstword $(MAJORVERSION))
MAJORVERSION :=$(strip $(MAJORVERSION))
else
MAJORVERSION :="0"
endif
# Include header file. This returns variables CC, F90, FREEFORM, LD, R8,
# as well as the default Makefile compilation rules for source code files.
include $(ROOTDIR)/Makefile_header.mk
# BASEDIR is a synonym for ROOTDIR
ifndef BASEDIR
export BASEDIR=$(realpath $(ROOTDIR))
endif
#-----------------------------------------------------------------------------
# Settings for ESMF
#-----------------------------------------------------------------------------
# Directory where ESMF lives
ifndef ESMF_DIR
export ESMF_DIR=$(CURDIR)/ESMF
endif
# Compiler for ESMF - eg intel, intelgcc, gfortran
ifndef ESMF_COMPILER
$(error ESMF_COMPILER is not defined)
endif
# MPI type for ESMF
ifndef ESMF_COMM
$(error ESMF_COMM is not defined)
endif
# Operating system type for ESMF
ifndef ESMF_OS
export ESMF_OS=$(ARCH)
endif
# Optimization level for ESMF
ifndef ESMF_BOPT
export ESMF_BOPT=O
endif
# Other ESMF directory settings
export ESMF_INSTALL_PREFIX=$(ESMF_DIR)/$(ARCH)
export ESMF_INSTALL_LIBDIR=$(ESMF_DIR)/$(ARCH)/lib
export ESMF_INSTALL_MODDIR=$(ESMF_DIR)/$(ARCH)/mod
export ESMF_INSTALL_HEADERDIR=$(ESMF_DIR)/$(ARCH)/include
# Other ESMF compilation settings
ifeq ($(ESMF_COMPILER),intel)
export ESMF_F90COMPILEOPTS=-align all -fPIC -traceback
else ifeq ($(ESMF_COMPILER),intelgcc)
export ESMF_F90COMPILEOPTS=-align all -fPIC -traceback
else ifeq ($(ESMF_COMPILER),gfortran)
export ESMF_F90COMPILEOPTS=-falign-commons -fPIC -fbacktrace
else
export ESMF_F90COMPILEOPTS=-fPIC
endif
export ESMF_CXXCOMPILEOPTS=-fPIC
export ESMF_OPENMP=OFF
#-----------------------------------------------------------------------------
# Settings for MAPL
#-----------------------------------------------------------------------------
# ESMADIR is the directory where MAPL lives
ifndef ESMADIR
ESMADIR:=$(CURDIR)/Shared
endif
# Fortran compiler for MAPL
export ESMA_FC=$(FC)
# RCDIR is the directory where the registry files live
export RCDIR=$(CURDIR)/Registry
# Inline the proper include files
ifeq ($(HPC),yes)
include $(ESMADIR)/Config/ESMA_base.mk # Generic stuff
include $(ESMADIR)/Config/ESMA_arch.mk # System dependencies
else
include ./Shared/Config/ESMA_base.mk # Generic stuff
include ./Shared/Config/ESMA_arch.mk # System dependencies
endif
#-----------------------------------------------------------------------------
# Settings for FVdycore
#-----------------------------------------------------------------------------
# FVDIR is where the FVDycore lives
ifndef FVDIR
export FVDIR=$(CURDIR)/FVdycoreCubed_GridComp
endif
###############################################################################
### ###
### List of files to compile ###
### ###
###############################################################################
# List of source files
SRC = $(wildcard *.F) $(wildcard *.F90)
# Replace .F and .F90 extensions with *.o
TMP = $(SRC:.F=.o)
OBJ = $(TMP:.F90=.o)
###############################################################################
### ###
### Makefile targets: type "make help" for a complete listing! ###
### ###
###############################################################################
.PHONY: clean help baselibs
baselibs:
@$(MAKE) baselibs_esmf
@$(MAKE) baselibs_mapl
@$(MAKE) baselibs_fvdycore
baselibs_esmf:
ifeq ($(wildcard $(ESMF_DIR)/esmf.install),)
$(MAKE) -C $(ESMF_DIR)
$(MAKE) -C $(ESMF_DIR) install
cp -f $(ESMF_DIR)/src/include/*.inc $(ESMF_INSTALL_HEADERDIR)
@touch $(ESMF_DIR)/esmf.install
endif
baselibs_mapl:
ifeq ($(wildcard $(ESMADIR)/mapl.install),)
$(MAKE) -C $(ESMADIR) install
rm -f $(ESMADIR)/$(ARCH)/lib/libGMAO_gfio.a
ln -sf $(ESMADIR)/$(ARCH)/lib/libGMAO_gfio_r4.a $(ESMADIR)/$(ARCH)/lib/libGMAO_gfio.a
rm -f $(ESMADIR)/$(ARCH)/lib/libMAPL_cfio.a
ln -sf $(ESMADIR)/$(ARCH)/lib/libMAPL_cfio_r4.a $(ESMADIR)/$(ARCH)/lib/libMAPL_cfio.a
@touch $(ESMADIR)/mapl.install
endif
baselibs_fvdycore:
ifeq ($(wildcard $(FVDIR)/fvdycore.install),)
@echo "<><>"
$(MAKE) -C $(FVDIR) ESMADIR=$(ESMADIR) install
@touch $(FVDIR)/fvdycore.install
endif
lib: $(OBJ)
$(AR) crs libGIGC.a $(OBJ)
mv libGIGC.a $(LIB)
libesmf:
@$(MAKE) -C $(GCHP) esmf
libmapl:
@$(MAKE) -C $(GCHP) mapl
clean:
rm -f *.o *.mod
help:
@$(MAKE) -C $(HELP)
gigc_debug gigc_help:
@echo "Directories:"
@echo "----------------------------------------------------------"
@echo "Current working dir : $(CURDIR)"
@echo "ROOTDIR : $(ROOTDIR)"
@echo "HDR : $(HDR)"
@echo "HELP : $(HELP)"
@echo "LIB : $(LIB)"
@echo "MOD : $(MOD)"
@echo "BASEDIR : $(BASEDIR)"
@echo ""
@echo "Settings for ESMF"
@echo "----------------------------------------------------------"
@echo "ESMF_DIR : $(ESMF_DIR)"
@echo "ESMF_COMPILER : $(ESMF_COMPILER)"
@echo "ESMF_COMM : $(ESMF_COMM)"
@echo "ESMF_OS : $(ESMF_OS)"
@echo "ESMF_BOPT : $(ESMF_BOPT)"
@echo "ESMF_INSTALL_PREFIX : $(ESMF_INSTALL_PREFIX)"
@echo "ESMF_INSTALL_LIBDIR : $(ESMF_INSTALL_LIBDIR)"
@echo "ESMF_INSTALL_MODDIR : $(ESMF_INSTALL_MODDIR)"
@echo "ESMF_INSTALL_HEADERDIR : $(ESMF_INSTALL_HEADERDIR)"
@echo "ESMF_F90COMPILEOPTS : $(ESMF_F90COMPILEOPTS)"
@echo "ESMF_CXXCOMPILEOPTS : $(ESMF_CXXCOMPILEOPTS)"
@echo ""
@echo "Settings for MAPL"
@echo "----------------------------------------------------------"
@echo "ESMADIR : $(ESMADIR)"
@echo "ESMA_FC : $(ESMA_FC)"
@echo "RCDIR : $(RCDIR)"
@echo ""
@echo "Settings for FVdycore"
@echo "----------------------------------------------------------"
@echo "FVDIR : $(FVDIR)"
@$(MAKE) -C $(FVDIR) ESMADIR=$(ESMADIR) help
###############################################################################
### ###
### Targets to remove ESMF, MAPL, and FVDYCORE! ###
### USE WITH EXTREME CAUTION!!! ###
### ###
###############################################################################
.PHONY: the_nuclear_option
the_nuclear_option:
@$(MAKE) wipeout_esmf
@$(MAKE) wipeout_mapl
@$(MAKE) wipeout_fvdycore
wipeout_esmf:
@echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
@echo '%%%%% Wiping out the ESMF installation %%%%%'
@echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
rm -f $(ESMF_DIR)/esmf.install
@$(MAKE) -C $(ESMF_DIR) distclean
rm -rf $(ESMF_DIR)/$(ARCH)
rm -f $(ESMF_DIR)/esmf.install
wipeout_mapl:
@echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
@echo '%%%%% Wiping out the MAPL installation %%%%%'
@echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
rm -f $(ESMADIR)/mapl.install
rm -rf $(ESMADIR)/$(ARCH)
rm -f $(ESMADIR)/Config/bin/*.x
rm -f ./*___.*
@$(MAKE) -C $(ESMADIR) distclean
rm -f $(ESMADIR)/mapl.install
wipeout_fvdycore:
@echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
@echo '%%%%% Wiping out the FVDYCORE installation %%%%%'
@echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
rm -f $(FVDIR)/fvdycore.install
@$(MAKE) -C $(FVDIR) ESMADIR=$(ESMADIR) distclean
rm -f $(FVDIR)/fvdycore.install
###############################################################################
### ###
### Dependencies listing ###
### (grep "USE " to get the list of module references!) ###
### ###
### From this list of dependencies, the "make" utility will figure out ###
### correct order of compilation (so we don't have to do that ourselves). ###
### This also allows us to compile on multiple processors with "make -j". ###
### ###
### NOTES: ###
### (1) Only specify object-file dependencies that are within this ###
### directory. Object files in other directories will be referenced ###
### at link-time. ###
### (2) For "make -jN" (i.e. compile N files simultaneously), all files ###
### in this directory must have a listed dependency. ###
### ###
###############################################################################
GEOSChem.o : GEOSChem.F90 \
GIGC_GridCompMod.o
GIGC_GridCompMod.o : GIGC_GridCompMod.F90 \
GEOS_ctmEnvGridComp.o
GEOS_ctmEnvGridComp.o : GEOS_ctmEnvGridComp.F90
#EOC