-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
247 lines (174 loc) · 8.49 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
# This file needs GNU make
#generated by: makedep -v OS=Linux;;FORT=pgi;;FORMAT=big_endian -o Makefile assim.F90
#---------#
# Rules #
#---------#
# .f90.o:
# $(F90C) $(F90FLAGS) -c $<
# .F90.o:
# $(F90C) $(F90FLAGS) -c $<
# use -o to ensure that the object file is in the same directory that source file
%.o: %.F90
$(F90C) $(F90FLAGS) -o $@ -c $<
%.o: %.f90
$(F90C) $(F90FLAGS) -o $@ -c $<
.SUFFIXES: $(SUFFIXES) .f90 .F90
.PHONY: test
#-------------------------------#
# Platform specific variables #
#-------------------------------#
include config.mk
# default settings
# If you need to adapt any of these variabels OS, FORT, ... JOBS, then make the corresponding changes in config.mk
OS ?= Linux
FORT ?= gfortran
FORMAT ?= big_endian
PRECISION ?= double
USE_MPIF90 ?= on
MPI ?=
OPENMP ?=
DEBUG ?=
JOBS ?= 1
VERSION=1.7
OAK_SONAME ?= liboak.so.1
OAK_LIBNAME ?= liboak.a
include Compilers/$(OS)-$(strip $(FORT)).mk
include Compilers/libs.mk
#---------#
# assim #
#---------#
ASSIM_PROG ?= assim
ASSIM_SRCS = sangoma_base.f90 \
anamorphosis.F90 assim.F90 assimilation.F90 date.F90 \
initfile.F90 matoper.F90 covariance.F90 ndgrid.F90 parall.F90 rrsqrt.F90 \
ufileformat.F90 random_d.f90 sangoma_ewpf.F90 user_base.f90 oak.F90
ASSIM_OBJS = anamorphosis.o assim.o assimilation.o date.o initfile.o \
matoper.o covariance.o ndgrid.o parall.o rrsqrt.o ufileformat.o match.o sangoma_ewpf.o \
random_d.o sangoma_base.o user_base.o oak.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
MODULES = anamorphosis.mod assimilation.mod date.mod initfile.mod \
matoper.mod covariance.mod ndgrid.mod parall.mod rrsqrt.mod ufileformat.mod oak.mod sangoma_base.mod user_base.mod
#-----------------#
# Common macros #
#-----------------#
PROG = $(ASSIM_PROG)
SRCS = $(ASSIM_SRCS)
OBJS = $(ASSIM_OBJS)
#-------------------#
# Standard tagets #
#-------------------#
all: $(PROG) $(OAK_LIBNAME)
clean: test-clean
rm -f $(PROG) $(OBJS) $(MODULES)
$(OAK_LIBNAME): $(OBJS)
ar rs $(OAK_LIBNAME) $(filter-out assim.o,$(OBJS))
$(OAK_SONAME): $(OBJS)
@if test $$(getconf LONG_BIT) = 64 -a ! "$(PIC)"; then \
echo "Warning: Your system seems to be 64-bit and PIC is not activated. Creating dynamic libraries will probaly fail."; \
echo "Use 'make PIC=on ...' or set PIC=on in config.mk"; \
fi
$(CC) -shared -Wl,-soname,$(OAK_SONAME) -o $(OAK_SONAME) $(filter-out assim.o,$(OBJS)) $(LIBS) $(FRTLIB)
allbin:
make -j $(JOBS) FORT=$(FORT) DEBUG=on clean
make -j $(JOBS) FORT=$(FORT) DEBUG=on all
make -j $(JOBS) FORT=$(FORT) DEBUG=on OPENMP=on clean
make -j $(JOBS) FORT=$(FORT) DEBUG=on OPENMP=on all
make -j $(JOBS) FORT=$(FORT) DEBUG=on MPI=on clean
make -j $(JOBS) FORT=$(FORT) DEBUG=on MPI=on all
# create install directories (if needed)
$(OAK_LIBDIR):
$(MKDIR_P) $(OAK_LIBDIR)
$(OAK_INCDIR):
$(MKDIR_P) $(OAK_INCDIR)
$(OAK_BINDIR):
$(MKDIR_P) $(OAK_BINDIR)
install: all $(OAK_LIBDIR) $(OAK_INCDIR) $(OAK_BINDIR)
cp $(PROG) $(OAK_BINDIR)
if [ -e $(OAK_LIBNAME) ]; then cp $(OAK_LIBNAME) $(OAK_LIBDIR); fi
if [ -e $(OAK_SONAME) ]; then cp $(OAK_SONAME) $(OAK_LIBDIR); fi
cp $(MODULES) $(OAK_INCDIR)
print:
echo ASSIM_OBJS: $(ASSIM_OBJS)
echo $(LIBS) $(F90FLAGS) $(PRECISION) $(OAK_DIR)
#---------------#
# Executables #
#---------------#
$(ASSIM_PROG): $(ASSIM_OBJS)
$(F90C) $(LDFLAGS) -o $@ $(ASSIM_OBJS) $(LIBS)
#----------------#
# Dependencies #
#----------------#
assim.o: assim.F90 assimilation.o initfile.o matoper.o rrsqrt.o ufileformat.o \
ppdef.h
ndgrid.o: ndgrid.F90 ndgrid_inc.F90 matoper.o ufileformat.o ppdef.h
parall.o: parall.F90 ppdef.h
matoper.o: matoper.F90 ppdef.h matoper_inc.F90 $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
covariance.o: matoper.o covariance.F90
date.o: date.F90 ppdef.h
anamorphosis.o: anamorphosis.F90 initfile.o ufileformat.o ppdef.h
initfile.o: initfile.F90 ppdef.h
rrsqrt.o: rrsqrt.F90 matoper.o parall.o ufileformat.o ppdef.h covariance.o
sangoma_ewpf.o: random_d.o equal_weights_step.f90 quicksort.f90 gen_random.f90 subroutines_for_EWPF.f90 proposal_step.f90
user_base.o: sangoma_base.o
assimilation.o: assimilation.F90 user_base.o sangoma_base.o sangoma_ewpf.o anamorphosis.o date.o initfile.o \
matoper.o ndgrid.o parall.o rrsqrt.o ufileformat.o ppdef.h covariance.o
ufileformat.o: ufileformat.F90 ppdef.h
match.o: match.c
oak.o: oak.F90 assimilation.o ndgrid.o
covariance.o: covariance.F90 matoper.o
# We use a single Makefile
# http://stackoverflow.com/a/1139423/3801401
# Tests
test-clean:
rm -f test/*.mod test/*.o test/test_ndgrid test/toymodel test/test_covariance test/test_matoper
rm -Rf test/Analysis001 test/Analysis002 test/Ens001 test/Ens002
test/toymodel.o: test/toymodel.F90 oak.o assimilation.o
test/toymodel: test/toymodel.o matoper.o covariance.o ndgrid.o assimilation.o rrsqrt.o anamorphosis.o \
date.o parall.o initfile.o user_base.o oak.o ufileformat.o random_d.f90 sangoma_base.f90 \
sangoma_ewpf.o match.o $(ifdef $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_covariance.o: test/test_covariance.F90 matoper.o covariance.o ndgrid.o
test/test_covariance: test/test_covariance.o matoper.o covariance.o ndgrid.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o) ufileformat.o
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_ndgrid.o: test/test_ndgrid.F90 matoper.o ndgrid.o ufileformat.o
test/test_ndgrid: test/test_ndgrid.o matoper.o ndgrid.o ufileformat.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_cellgrid.o: test/test_cellgrid.F90 matoper.o ndgrid.o ufileformat.o
test/test_cellgrid: test/test_cellgrid.o matoper.o ndgrid.o ufileformat.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/assimtest2.o: test/assimtest2.F90 matoper.o rrsqrt.o covariance.o
test/assimtest2: test/assimtest2.o matoper.o rrsqrt.o covariance.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_matoper.o: test/test_matoper.F90 matoper.o
test/test_matoper: test/test_matoper.o matoper.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_rrsqrt.o: test/test_rrsqrt.F90 matoper.o covariance.o rrsqrt.o
test/test_rrsqrt: test/test_rrsqrt.o matoper.o covariance.o rrsqrt.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_assim.o: test/test_assim.F90 matoper.o assimilation.o
test/test_assim: test/test_assim.o matoper.o assimilation.o rrsqrt.o covariance.o ufileformat.o initfile.o user_base.o sangoma_ewpf.o anamorphosis.o parall.o ndgrid.o date.o random_d.o match.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_nondiag.o: test/test_nondiag.F90 matoper.F90 rrsqrt.o covariance.o ndgrid.o ufileformat.o
test/test_nondiag: test/test_nondiag.o matoper.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o) rrsqrt.o covariance.o ndgrid.o ufileformat.o
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test/test_cholmod.o: test/test_cholmod.F90 matoper.o
test/test_cholmod: test/test_cholmod.o matoper.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
ifdef CHOLMOD_LIB
test/test_cholmod_wrapper.o: test/test_cholmod_wrapper.c
test/test_cholmod_wrapper: test/test_cholmod_wrapper.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
endif
test/test_bootstrap.o: test/test_bootstrap.F90 matoper.o covariance.o rrsqrt.o
test/test_bootstrap: test/test_bootstrap.o matoper.o covariance.o rrsqrt.o $(if $(CHOLMOD_LIB), cholmod_wrapper.o)
$(F90C) $(F90FLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(EXTRA_LDFLAGS)
test: test/test_covariance test/test_ndgrid test/test_cellgrid test/assimtest2 test/test_matoper test/test_rrsqrt test/toymodel $(ifdef $(CHOLMOD_LIB), test/test_nondiag test/test_cholmod test/test_cholmod_wrapper) test/test_assim #test/test_bootstrap
echo $+;
for i in $+; do echo $$i; ./$$i; done
release:
TMPOAK=$$(mktemp -d -t --suffix -OAK); \
mkdir $$TMPOAK/OAK-$(VERSION); \
git archive master | tar -x -C $$TMPOAK/OAK-$(VERSION); \
mv $$TMPOAK/OAK-$(VERSION)/config.mk.template $$TMPOAK/OAK-$(VERSION)/config.mk; \
tar -cvzf OAK-$(VERSION).tar.gz -C $$TMPOAK --exclude-vcs OAK-$(VERSION)
upload:
scp OAK-$(VERSION).tar.gz modb:/var/lib/mediawiki/upload/Alex/OAK/release/