-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
227 lines (203 loc) · 10 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
##############################################################################
# (c) Crown copyright 2017 Met Office. All rights reserved.
# The file LICENCE, distributed with this code, contains details of the terms
# under which the code may be used.
##############################################################################
# This top level makefile is very order sensitive. Source code extraction and
# generation must happen in a certain order. Due to this we turn off
# multithreading for this file only. Any called recursively (i.e. with $(MAKE))
# run in parallel. Unless they specify NOTPARALLEL as well.
#
.NOTPARALLEL:
export PROJECT_NAME = adjoint_test
export PROJECT_DIR_NAME = adjoint_test
PROFILE ?= fast-debug
export IGNORE_DEPENDENCIES = netcdf MPI yaxt pfunit_mod xios mod_wait
export EXTERNAL_DYNAMIC_LIBRARIES = yaxt yaxt_c netcdff netcdf hdf5
export EXTERNAL_STATIC_LIBRARIES = xios
LFRIC_TARGET_PLATFORM ?= generic-x86
export OPTIMISATION_PATH ?= $(wildcard optimisation/$(LFRIC_TARGET_PLATFORM))
export PROJECT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
export ROOT_DIR ?= ../..
export SUITE_GROUP ?= developer
export SUITE_GROUP_NAME ?= $(notdir $(realpath $(shell pwd)/$(ROOT_DIR)))-$(PROJECT_NAME)-.*
META_VN ?= HEAD
META_FILE_DIR = $(PROJECT_DIR)/rose-meta/lfric-$(PROJECT_NAME)/$(META_VN)
.PHONY: default
default: build unit-tests integration-tests
$(Q)echo > /dev/null
.PHONY: documentation doc docs
documentation doc docs: document-uml document-latex document-api
$(Q)echo > /dev/null
include $(ROOT_DIR)/infrastructure/build/lfric.mk
-include $(PROJECT_DIR)/build/project.mk
##############################################################################
# Launch gscan to monitor suites from this suite-group
#
.PHONY: launch-suite-gscan
launch-suite-gscan: gscan_processes := $(shell ps --no-headers -o command -C cylc-gscan)
launch-suite-gscan: ALWAYS
$(Q)-if [[ "$(gscan_processes)" != *"--name=$(SUITE_GROUP_NAME)"* ]]; then \
cylc gscan $(DOUBLE_VERBOSE_ARG) --name=$(SUITE_GROUP_NAME) & \
usleep 1 ;\
fi
##############################################################################
.PHONY: test-suite
test-suite: SUITE_BASE_NAME = $(notdir $(realpath $(shell pwd)/$(ROOT_DIR)))-$(PROJECT_NAME)
test-suite: SUITE_CONFIG = rose-stem
test-suite: launch-suite-gscan launch-test-suite
$(Q)echo > /dev/null
##############################################################################
# Documentation
#
.PHONY: document-uml
document-uml: DOCUMENT_DIR ?= $(PROJECT_DIR)/documents/uml
document-uml: SOURCE_DIR = documentation/uml
document-uml: WORKING_DIR := $(WORKING_DIR)/uml
document-uml: uml-documentation
$(Q)echo > /dev/null
.PHONY: document-latex
document-latex: DOCUMENT_DIR ?= $(PROJECT_DIR)/documents
document-latex: SOURCE_DIR = documentation
document-latex: DOCUMENTS = $(shell find $(SOURCE_DIR) -name '*.latex' -print)
document-latex: WORKING_DIR := $(WORKING_DIR)/latex
document-latex: TEX_STUFF = documentation/tex
document-latex: COMMON_FIGURES = documentation/common-figures
document-latex: ALWAYS
$(Q)$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/latex.mk \
SOURCE_DIR=$(SOURCE_DIR) \
WORKING_DIR=$(WORKING_DIR) \
DOCUMENT_DIR=$(DOCUMENT_DIR) \
TEX_STUFF=$(TEX_STUFF) \
COMMON_FIGURES=$(COMMON_FIGURES) \
DOCUMENTS="$(DOCUMENTS)"
.PHONY: document-api
document-api: PROJECT = $(PROJECT_NAME)
document-api: DOCUMENT_DIR ?= $(PROJECT_DIR)/documents/api
document-api: CONFIG_DIR = documentation
document-api: SOURCE_DIR = source
document-api: WORKING_DIR := $(WORKING_DIR)/api
document-api: api-documentation
$(Q)echo > /dev/null
##############################################################################
# Build
#
.PHONY: build
build: export BIN_DIR ?= $(PROJECT_DIR)/bin
build: export CXX_LINK = TRUE
build: export PROGRAMS := $(basename $(notdir $(shell find source -maxdepth 1 -name '*.[Ff]90' -print)))
build: export PROJECT = $(PROJECT_NAME)
build: export WORKING_DIR := $(WORKING_DIR)
ifeq "$(PROFILE)" "full-debug"
build: export FFLAG_GROUPS = DEBUG WARNINGS INIT RUNTIME NO_OPTIMISATION FORTRAN_STANDARD
else ifeq "$(PROFILE)" "fast-debug"
build: export FFLAG_GROUPS = DEBUG WARNINGS SAFE_OPTIMISATION FORTRAN_STANDARD
else ifeq "$(PROFILE)" "production"
build: export FFLAG_GROUPS = DEBUG WARNINGS RISKY_OPTIMISATION
else
$(error Unrecognised profile "$(PROFILE)". Must be one of full-debug, fast-debug or production)
endif
build: ALWAYS
$(call MESSAGE,========================================)
$(call MESSAGE,Extracting LFRic infrastructure)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/extract.mk \
SOURCE_DIR=$(LFRIC_INFRASTRUCTURE)/source
$(call MESSAGE,========================================)
$(call MESSAGE,Extracting LFRic driver model component)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/extract.mk \
SOURCE_DIR=$(ROOT_DIR)/components/driver/source
$(call MESSAGE,========================================)
$(call MESSAGE,Extracting LFRic science model component)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/extract.mk \
SOURCE_DIR=$(ROOT_DIR)/components/science/source
$(call MESSAGE,========================================)
$(call MESSAGE,Extracting LFRic-XIOS model component)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/extract.mk \
SOURCE_DIR=$(ROOT_DIR)/components/lfric-xios/source
$(call MESSAGE,========================================)
$(call MESSAGE,Extracting $(PROJECT_NAME))
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/extract.mk \
SOURCE_DIR=source
$(call MESSAGE,========================================)
$(call MESSAGE,PSycloning LFRic infrastructure)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/psyclone.mk \
SOURCE_DIR=$(LFRIC_INFRASTRUCTURE)/source \
OPTIMISATION_PATH=$(OPTIMISATION_PATH)
$(call MESSAGE,========================================)
$(call MESSAGE,PSycloning LFRic science model component)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/psyclone.mk \
SOURCE_DIR=$(ROOT_DIR)/components/science/source \
OPTIMISATION_PATH=$(OPTIMISATION_PATH)
$(call MESSAGE,========================================)
$(call MESSAGE,PSycloning LFRic-XIOS model component)
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/psyclone.mk \
SOURCE_DIR=$(ROOT_DIR)/components/lfric-xios/source \
OPTIMISATION_PATH=$(OPTIMISATION_PATH)
$(call MESSAGE,========================================)
$(call MESSAGE,PSycloning $(PROJECT_NAME))
$(call MESSAGE,========================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/psyclone.mk \
SOURCE_DIR=source \
OPTIMISATION_PATH=$(OPTIMISATION_PATH)
$(call MESSAGE,=========================================================)
$(call MESSAGE,Generating $(PROJECT) namelist loaders)
$(call MESSAGE,=========================================================)
$Q$(MAKE) $(QUIET_ARG) -f $(LFRIC_BUILD)/configuration.mk \
SOURCE_DIR=source \
META_FILE_DIR=$(META_FILE_DIR) \
FIX_ENUMS_OPT=$(FIX_ENUMS_OPT)
$(call MESSAGE,=========================================================)
$(call MESSAGE,Analysing $(PROJECT) build dependencies)
$(call MESSAGE,=========================================================)
$Q$(MAKE) $(QUIET_ARG) -C $(WORKING_DIR) -f $(LFRIC_BUILD)/analyse.mk
$(call MESSAGE,=========================================================)
$(call MESSAGE,Compiling $(PROJECT))
$(call MESSAGE,=========================================================)
$Q$(MAKE) $(QUIET_ARG) -C $(WORKING_DIR) -f $(LFRIC_BUILD)/compile.mk \
BIN_DIR=$(BIN_DIR) PROGRAMS="$(PROGRAMS)"
##############################################################################
# Unit tests
#
.PHONY: unit-tests
unit-tests: export ADDITIONAL_EXTRACTION = $(ROOT_DIR)/infrastructure/source \
$(ROOT_DIR)/components/science/source/kernel
unit-tests: export BIN_DIR ?= $(PROJECT_DIR)/test
unit-tests: export FFLAG_GROUPS = DEBUG NO_OPTIMISATION INIT UNIT_WARNINGS
unit-tests: export META_FILE_DIR = rose-meta/lfric-adjoint_test/HEAD
unit-tests: export PROGRAMS = $(PROJECT_NAME)_unit_tests
unit-tests: export PROJECT = $(PROJECT_NAME)
unit-tests: export SOURCE_DIR = source/kernel
unit-tests: export TEST_DIR = unit-test
unit-tests: export WORKING_DIR := $(WORKING_DIR)/unit-test
unit-tests: do-unit-tests
##############################################################################
# Integration tests
#
.PHONY: integration-tests
integration-tests: export BIN_DIR ?= $(PROJECT_DIR)/test
integration-tests: export META_FILE_DIR = rose-meta/lfric-adjoint_test/HEAD
integration-tests: export PROJECT = $(PROJECT_NAME)
integration-tests: export SOURCE_DIR = source
integration-tests: export TEST_DIR = integration-test
integration-tests: export WORKING_DIR := $(WORKING_DIR)/integration-test
integration-tests: do-integration-tests
##############################################################################
# Clean
#
.PHONY: clean
clean: ALWAYS
$(call MESSAGE,Removing,"$(PROJECT_NAME) work space")
$(Q)-if [ $(WORKING_DIR) != *[\*]* ] && [ -d $(WORKING_DIR) ] ; then rm -r $(WORKING_DIR) ; fi
$(call MESSAGE,Removing,"$(PROJECT_NAME) documents")
$(Q)-if [ -d documents ] ; then rm -r documents; fi
$(call MESSAGE,Removing,"$(PROJECT_NAME) binaries")
$(Q)-if [ -d bin ] ; then rm -r bin ; fi
$(Q)-if [ -d test ] ; then rm -r test ; fi