forked from MeteoSwiss-APN/ecrad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (144 loc) · 4.57 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
# 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 += -DSINGLE_PRECISION
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 \
$(OPTFLAGS) $(DEBUGFLAGS) $(NETCDF_INCLUDE) $(OMPFLAG)
export LIBS = $(LDFLAGS) -L../lib -lradsurf -lradiation -lutilities \
-lifsrrtm -ldrhook -lifsaux $(FCLIBS) $(NETCDF_LIB) $(OMPFLAG)
ifdef DR_HOOK
LIBS += -ldl -lrt
export CFLAGS = -g -O2
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 arguments to make are:"
@echo " DEBUG=1 Compile with debug settings on and optimizations off"
@echo " SINGLE_PRECISION=1 Compile with single precision"
@echo " DR_HOOK=1 Compile with the Dr Hook profiling system"
@echo " test Run test cases in test directory"
@echo " clean Remove all compiled files"
ifdef DR_HOOK
build: directories libifsaux libdrhook libutilities libifsrrtm libradiation libradsurf driver symlinks
else
build: directories libifsaux libdummydrhook libutilities libifsrrtm libradiation libradsurf driver 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
clean-deps:
rm -f include/*.intfb.h
libifsaux:
cd ifsaux && $(MAKE)
libdrhook:
cd drhook && $(MAKE)
libdummydrhook:
cd drhook && $(MAKE) dummy
libutilities:
cd utilities && $(MAKE)
libifsrrtm:
cd ifsrrtm && $(MAKE)
libradiation:
cd radiation && $(MAKE)
libradsurf:
cd radsurf && $(MAKE)
driver:
cd driver && $(MAKE)
symlinks: clean-symlinks
cd practical && ln -s ../bin/ecrad
cd practical && ln -s ../data
test: test_ifs test_i3rc
test_ifs:
cd test/ifs && $(MAKE) test
test_i3rc:
cd test/i3rc && $(MAKE) test
test_surface:
cd test/surface && $(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/surface && $(MAKE) clean
clean-toplevel:
cd radiation && $(MAKE) clean
cd radsurf && $(MAKE) clean
cd driver && $(MAKE) clean
clean-utilities:
cd ifsaux && $(MAKE) clean
cd utilities && $(MAKE) clean
cd ifsrrtm && $(MAKE) clean
cd drhook && $(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 libdrhook libutilities libifsrrtm \
libradiation libradsurf driver symlinks clean clean-toplevel test test_ifs \
test_i3rc test_surface clean-tests clean-utilities clean-mods clean-symlinks