forked from ecmwf-ifs/ecrad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
199 lines (160 loc) · 5.53 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
# ecRad Makefile - read the README file before editing
#############################
### --- CONFIGURATION --- ###
#############################
# Use the nf-config utility, if available, to set the NETCDF_INCLUDE
# and NETCDF_LIB flags
HAVE_NFCONFIG := $(shell nf-config --version 2> /dev/null)
ifdef HAVE_NFCONFIG
$(info *** Using nf-config to obtain NetCDF flags)
NETCDF_INCLUDE = $(shell nf-config --fflags)
NETCDF_LIB = $(shell nf-config --flibs)
ifeq ($(shell nf-config --has-nc4),yes)
NETCDF4 = 1
endif
else
$(info *** nf-config not found)
endif
# make can be invoked using "make PROFILE=<prof>" in which case your
# local configuration parameters will be obtained from
# Makefile_include.<prof>
ifndef PROFILE
$(info *** No "PROFILE" variable provided, assuming "gfortran")
PROFILE = gfortran
endif
# Include a platform-specific makefile that defines FC, FCFLAGS and
# LIBS
include Makefile_include.$(PROFILE)
# Check for presence of the NETCDF_INCLUDE and NETCDF_LIB flags
ifndef NETCDF_INCLUDE
$(info *** You may need to set NETCDF_INCLUDE manually)
endif
ifndef NETCDF_LIB
$(info *** You may need to set NETCDF_LIB manually)
endif
# Add single-precision flag if SINGLE_PRECISION=1 was given on the
# "make" command line
ifdef SINGLE_PRECISION
CPPFLAGS += -DPARKIND1_SINGLE
endif
# If PRINT_ENTRAPMENT_DATA=1 was given on the "make" command line
# then the SPARTACUS shortwave solver will write data to fort.101 and
# fort.102
ifdef PRINT_ENTRAPMENT_DATA
CPPFLAGS += -DPRINT_ENTRAPMENT_DATA
endif
# For backwards compatibility we allow the following as well
ifdef PRINT_ENCROACHMENT_DATA
CPPFLAGS += -DPRINT_ENTRAPMENT_DATA
endif
# Allow the capability to write NetCDF4/HDF5 files, provided the code
# is compiled against the NetCDF4 library
ifdef NETCDF4
$(info *** Building with NetCDF4/HDF5 support)
CPPFLAGS += -DNC_NETCDF4
endif
# Consolidate flags
export FC
export FCFLAGS = $(WARNFLAGS) $(BASICFLAGS) $(CPPFLAGS) -I../include -I/usr/local/ai4sim/lib \
$(OPTFLAGS) $(DEBUGFLAGS) $(NETCDF_INCLUDE) $(OMPFLAG)
export LIBS = $(LDFLAGS) -L../lib -L/usr/local/ai4sim/lib -lai4sim_binding_ecrad -lradiation -lutilities \
-lifsrrtm -ldrhook -lifsaux $(FCLIBS) $(NETCDF_LIB) $(OMPFLAG)
# Do we include Dr Hook from ECMWF's fiat library?
ifdef FIATDIR
# Prepend location of yomhook.mod module file from fiat library, so
# that it is found in preference to the dummy one in ecRad
FCFLAGS := -I$(FIATDIR)/module/fiat $(FCFLAGS)
# Append fiat library (usually shared: libfiat.so)
LIBS += -L$(FIATDIR)/lib -Wl,-rpath,$(FIATDIR)/lib -lfiat
else
# Dummy Dr Hook library
LIBS += -ldrhook
endif
#############################
### --- BUILD TARGETS --- ###
#############################
all: build
help:
@echo "Usage:"
@echo " make PROFILE=<prof>"
@echo "where <prof> is one of gfortran, pgi, intel or cray (see Makefile_include.<prof>)"
@echo "Other possible arguments are:"
@echo " DEBUG=1 Compile with debug settings on and optimizations off"
@echo " SINGLE_PRECISION=1 Compile with single precision"
@echo " FIATDIR=/my/path Compile with Dr Hook, specifying the directory containing lib/libfiat.so and module/fiat/yomhook.mod"
@echo " test Run test cases in test directory"
@echo " clean Remove all compiled files"
ifndef FIATDIR
build: directories libifsaux libdummydrhook libutilities libifsrrtm \
libradiation driver ifsdriver symlinks
libradiation libutilities: libdummydrhook
else
# Note that if we are using Dr Hook from the fiat library we don't
# want to create mod/yomhook.mod as this can sometimes be found before
# the one in the fiat directory leading to an error at link stage
build: directories libifsaux libutilities libifsrrtm libradiation \
driver ifsdriver symlinks
endif
# git cannot store empty directories so they may need to be created
directories: mod lib
mod:
mkdir -p mod
lib:
mkdir -p lib
deps: clean-deps
cd ifsaux && $(MAKE) deps
cd ifsrrtm && $(MAKE) deps
cd ifs && $(MAKE) deps
clean-deps:
rm -f include/*.intfb.h
libifs: libradiation
cd ifs && $(MAKE)
libifsaux:
cd ifsaux && $(MAKE)
libdummydrhook: libifsaux
cd drhook && $(MAKE) dummy
libutilities: libifsaux
cd utilities && $(MAKE)
libifsrrtm: libifsaux
cd ifsrrtm && $(MAKE)
libradiation: libifsrrtm libutilities libifsaux
cd radiation && $(MAKE)
driver: libifsaux libifsrrtm libutilities libradiation
cd driver && $(MAKE) driver
ifsdriver: libifsaux libifsrrtm libutilities libradiation libifs
cd driver && $(MAKE) ifs_driver
test_programs: driver
cd driver && $(MAKE) test_programs
symlinks: clean-symlinks
cd practical && ln -s ../bin/ecrad
cd practical && ln -s ../data
test: test_ifs test_i3rc test_ckdmip
test_ifs: driver
cd test/ifs && $(MAKE) test
test_i3rc: driver
cd test/i3rc && $(MAKE) test
test_ckdmip:
cd test/ckdmip && $(MAKE) test
clean: clean-tests clean-toplevel clean-utilities clean-mods clean-symlinks
clean-tests:
cd test/ifs && $(MAKE) clean
cd test/i3rc && $(MAKE) clean
cd test/ckdmip && $(MAKE) clean
clean-toplevel:
cd radiation && $(MAKE) clean
cd driver && $(MAKE) clean
clean-utilities:
cd ifsaux && $(MAKE) clean
cd utilities && $(MAKE) clean
cd ifsrrtm && $(MAKE) clean
cd drhook && $(MAKE) clean
cd ifs && $(MAKE) clean
clean-mods:
rm -f mod/*.mod
clean-symlinks:
rm -f practical/ecrad practical/data
clean-autosaves:
rm -f *~ .gitignore~ */*~ */*/*~
.PHONY: all build help deps clean-deps libifsaux libdummydrhook libutilities libifsrrtm \
libradiation driver symlinks clean clean-toplevel test test_ifs ifsdriver \
test_i3rc clean-tests clean-utilities clean-mods clean-symlinks