-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.example
288 lines (253 loc) · 6.9 KB
/
Makefile.example
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
# Makfile for SiB3crop
#
# You will need GNU's version of Make, which is the default on Linux, OS X
# but not necessarily other Unixes.
#
# If you want to change the compiler or optimization without editing the
# makefile, set the COMPILER or OPT environment variables on the command
# line like so:
#
# user@host:~$ COMPILER=ifort OPT=opt make clean all
#
# Values for COMPILER: gcc*, pgi, ifort
# Values for OPT: debug*, opt
#
# * = default
#
# To name the SiB binary with the platform, define the FULL_SUFFIX environment
# like this before running make:
#
# user@host:~$ export FULL_SUFFIX=1 # bourne shells
#
# user@host:~$ setenv FULL_SUFFIX 1 # c shell
#
# You can tell the Makefile where to find NetCDF and LAPACK/BLAS libraries
# by setting the NETCDF_ROOT and LAPACK_ROOT environment variables as well:
#
# user@host:~$ export NETCDF_ROOT=/usr/local
#
# the includes will be searched for in $(NETCDF_ROOT)/include and
# $(LAPACK_ROOT)/include, and the libraries will be searched for in
# $(NETCDF_ROOT)/lib and $(LAPACK_ROOT)/lib.
OS = $(shell uname -s)
PROC = $(shell uname -p)
# Uncomment one of these to select your compiler. Use gcc for gfortran
# and pgi for the portland group compilers.
ifndef COMPILER
COMPILER = gcc
#COMPILER = pgi
#COMPILER = ifort
endif
# Uncomment one of these to select optimize vs. debug compile modes.
ifndef OPT
#OPT = opt
OPT = debug
endif
# nothing to do
ifndef PROF
PROF =
endif
# Non-System Headers and Libraries
# -------------------------------------------------------------------------
# BLAS (Basic Linear Algebra System) and LAPACK (Linear Algebra Package)
# Directory containing netcdf's include/ and lib/ directories.
ifndef NETCDF_ROOT
NETCDF_ROOT = /usr/local/netcdf3-$(COMPILER)
#NETCDF_ROOT = /usr/local/
endif
ifndef LAPACK_ROOT
LAPACK_ROOT = /usr/local/atlas
endif
ifeq ($(OS),Darwin)
ifdef FULL_SUFFIX
SUFFIX = -mac$(COMPILER)-$(OPT)
endif
INCLUDES = -I$(NETCDF_ROOT)/include
LALIB = -framework vecLib
LIBS = $(LALIB) -L$(NETCDF_ROOT)/lib -lnetcdf
endif
ifeq ($(OS),Linux)
ifdef FULL_SUFFIX
SUFFIX = -lx$(COMPILER)-$(OPT)
endif
LALIB = -L$(LAPACK_ROOT)/lib -llapack -lblas -lcblas -latlas
INCLUDES = -I$(NETCDF_ROOT)/include
LIBS = $(LALIB) -L$(NETCDF_ROOT)/lib -lnetcdf
endif
ifeq ($(COMPILER),gcc)
F90 = gfortran
ifeq ($(OPT),opt)
F90FLAGS = -O2
F90FLAGS_NOOPT =
else ifeq ($(OPT),debug)
F90FLAGS = -g -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow
F90FLAGS_NOOPT = $(F90FLAGS)
endif
ifeq ($(PROC),powerpc)
F90FLAGS += -fconvert=little-endian
endif
ifeq ($(PROF),prof)
F90FLAGS += -pg
LFLAGS += -pg
endif
F90FLAGS += -fimplicit-none -Wall -Wsurprising $(INCLUDES)
F90FLAGS_NOOPT += -fimplicit-none -Wall -Wsurprising $(INCLUDES)
LFLAGS = $(LIBS)
ifeq ($(PROF),prof)
LFLAGS += -pg
endif
endif
ifeq ($(COMPILER),pgi)
F90 = pgf90
ifeq ($(OPT),opt)
F90FLAGS = -fast -Mnoframe
F90FLAGS_NOOPT =
else ifeq ($(OPT),debug)
F90FLAGS = -g -Mbounds -Ktrap=fp
F90FLAGS_NOOPT = $(F90FLAGS)
endif
F90FLAGS += -Minfo=loop,inline -Minform=inform $(INCLUDES)
F90FLAGS_NOOPT += -Minfo=loop,inline -Minform=inform $(INCLUDES)
LFLAGS = -v -Minform=inform $(LIBS)
endif
ifeq ($(COMPILER),ifort)
F90 = ifort
ifeq ($(OPT),opt)
F90FLAGS = -O2
F90FLAGS_NOOPT = -O0
else ifeq ($(OPT),debug)
F90FLAGS = -g -check bounds -fpe0
F90FLAGS_NOOPT = $(F90FLAGS)
endif
ifeq ($(PROC),powerpc)
F90FLAGS += -convert little_endian
endif
F90FLAGS += -implicitnone -warn all $(INCLUDES)
F90FLAGS_NOOPT += -implicitnone -warn all $(INCLUDES)
LFLAGS = $(LIBS)
endif
# Objects (DO NOT EDIT - Unless You Add or Remove Files)
# -------------------------------------------------------------------------
# Variable objects
VAR_OBJS = kinds.o \
physical_parameters.o \
eau_params.o \
sib_const_module.o \
sib_io_module.o \
sib_bc_module.o \
sibtype.o \
timetype.o
# Pre-requisite objects (Required for the Scientific objects)
PRE_OBJS =
# Scientific objects
SCI_OBJS = addinc.o \
balan.o \
dtess_eau.o \
begtem.o \
cfrax.o \
clm_combo.o \
combine_snow.o \
compact_snow.o \
cycalc.o \
delef.o \
delhf.o \
dellwf.o \
hydro_canopy.o \
hydro_snow.o \
hydro_soil.o \
qsat_eau.o \
ess_eau.o \
netrad.o \
phosib.o \
rada2.o \
rbrd.o \
respsib.o \
rnload.o \
soilwater.o \
sortin.o \
subdivide_snow.o \
tridiag_solver.o \
vmfcalz.o \
vmfcalzo.o \
vntlat.o \
sibslv.o \
update.o \
resp_control.o \
sib.o # sib.o NEEDS TO BE LAST
# Netcdf Objects
NCDF_OBJS = nc_util.o
# SiB Drive objects
DRV_OBJS = init_grid.o \
init_var.o\
zenith.o \
phen_mapper.o \
crop_accum.o \
leaf_weight.o \
init_sibdrv.o \
init_crop.o \
time_init.o \
time_manager.o \
sibdrv_read_single.o \
sibdrv_read_ecmwf.o \
sibdrv_read_ncep2.o \
sibdrv_read_geos4.o \
sibdrv_read_narr.o \
read_ti.o \
set_ti.o \
mapper.o \
phen_mapper.o \
calculate_td.o \
read_ndvi.o \
previous_bc.o \
update_bc.o \
rtape_sib.o \
diagnostic_output.o \
pbpwrite.o \
qpwrite.o \
output_control.o \
sibdrv_interp.o \
bc_interp.o \
SiBDRV.o
# Compilation (DO NOT EDIT BELOW THIS LINE)
# -------------------------------------------------------------------------
%.o: %.f90
$(F90) $(F90FLAGS) -c $< -o $@
%.o: %.F90
$(F90) $(F90FLAGS) -c $< -o $@
all: SiBD3crop$(SUFFIX) sibmerge$(SUFFIX)
remake: clean all
SiBD3crop$(SUFFIX): $(VAR_OBJS) $(PRE_OBJS) $(SCI_OBJS) $(NCDF_OBJS) $(DRV_OBJS)
$(F90) $^ -o $@ $(LFLAGS)
@echo -e "\n"
@date
sibmerge$(SUFFIX): sibmerge.o $(NCDF_OBJS)
$(F90) sibmerge.o $(NCDF_OBJS) -o $@ $(LFLAGS)
crop_accum.o: crop_accum.F90
$(F90) $(F90FLAGS_NOOPT) -c $< -o $@
leaf_weight.o: leaf_weight.F90
$(F90) $(F90FLAGS_NOOPT) -c $< -o $@
clean:
rm -f SiBD3crop$(SUFFIX) sibmerge$(SUFFIX) *.o *.mod *.stb *~
distclean: clean
rm -rf SiBD3crop-* sibmerge-* #*#
help:
@echo ""
@echo "Supported Rules:"
@echo "1) [nothing], SiBD3 and sibmerge: compile sib3 model, " \
"recompiling dependencies as necessary. Then, compile sibmerge program"
@echo "2) SiBD3: compile sib3 model only, recompiling dependencies " \
"as necessary."
@echo "3) sibmerge: compile sibmerge program"
@echo "4) <object name>.o: compile specific object. matches the file" \
"name."
@echo "5) remake: delete all objects, and re-compile the sib3 model " \
"and sibmerge."
@echo "6) clean: remove all compiler-generated files and executable."
@echo "7) help: print this message."
@echo ""
# Dependencies
$(VAR_OBJS):
$(PRE_OBJS): $(VAR_OBJS)
$(SCI_OBJS): $(VAR_OBJS) $(PRE_OBJS)
$(NCDF_OBJS): $(VAR_OBJS)
$(DRV_OBJS): $(VAR_OBJS) $(NCDF_OBJS)