forked from uaf-arctic-eco-modeling/dvm-dos-tem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
204 lines (163 loc) · 7.52 KB
/
SConstruct
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
#To examine commands:
# scons --dry-run
import os
import platform
import distutils.spawn
import subprocess
USEOMP = False
USEMPI = False
libs = Split("""jsoncpp
readline
netcdf
pthread
boost_system
boost_filesystem
boost_program_options
boost_thread
boost_log""")
local_include_paths = Split("""./src
./include
./src/atmosphere
./src/data
./src/disturb
./src/ecodomain
./src/ecodomain/horizon
./src/ecodomain/layer
./src/inc
./src/input
./src/lookup
./src/runmodule
./src/snowsoil
./src/util
./src/vegetation""")
src_files = Split("""src/TEM.cpp
src/TEMUtilityFunctions.cpp
src/OutputEstimate.cpp
src/CalController.cpp
src/TEMLogger.cpp
src/ArgHandler.cpp
src/Climate.cpp
src/ModelData.cpp
src/Runner.cpp
src/data/BgcData.cpp
src/data/CohortData.cpp
src/data/EnvData.cpp
src/data/EnvDataDly.cpp
src/data/FirData.cpp
src/data/RestartData.cpp
src/disturb/WildFire.cpp
src/ecodomain/DoubleLinkedList.cpp
src/ecodomain/Ground.cpp
src/ecodomain/Vegetation.cpp
src/ecodomain/horizon/MineralInfo.cpp
src/ecodomain/horizon/Moss.cpp
src/ecodomain/horizon/Organic.cpp
src/ecodomain/horizon/Snow.cpp
src/ecodomain/horizon/SoilParent.cpp
src/ecodomain/layer/Layer.cpp
src/ecodomain/layer/MineralLayer.cpp
src/ecodomain/layer/MossLayer.cpp
src/ecodomain/layer/OrganicLayer.cpp
src/ecodomain/layer/ParentLayer.cpp
src/ecodomain/layer/SnowLayer.cpp
src/ecodomain/layer/SoilLayer.cpp
src/lookup/CohortLookup.cpp
src/runmodule/Cohort.cpp
src/runmodule/Integrator.cpp
src/snowsoil/Richards.cpp
src/snowsoil/Snow_Env.cpp
src/snowsoil/Soil_Bgc.cpp
src/snowsoil/Soil_Env.cpp
src/snowsoil/SoilParent_Env.cpp
src/snowsoil/Stefan.cpp
src/snowsoil/TemperatureUpdator.cpp
src/util/CrankNicholson.cpp
src/util/tbc-debug-util.cpp
src/vegetation/Vegetation_Bgc.cpp
src/vegetation/Vegetation_Env.cpp""")
platform_name = platform.system()
release = platform.release()
comp_name = platform.node()
uname = platform.uname()
platform_libs = []
platform_include_path = []
platform_library_path = []
# By default, attempt to find g++. Will be overwritten later if necessary.
compiler = distutils.spawn.find_executable('g++')
# Determine platform and modify libraries and paths accordingly
if platform_name == 'Linux':
platform_include_path = ['/usr/include',
'/usr/include/openmpi-x86_64',
'/usr/include/jsoncpp',
'~/usr/local/include']
platform_library_path = ['/usr/lib64', '~/usr/local/lib']
compiler_flags = '-Werror -ansi -g -fPIC -DBOOST_ALL_DYN_LINK -DGNU_FPE'
platform_libs = libs
elif platform_name == 'Darwin':
# See ua-snap/dvm-dos-tem PR #300 for discussion
if(USEOMP):
print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
print "NOTE: OpenMP not working on OSX! Reverting to serial build...."
print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
print ""
USEOMP = False
# On OSX, using Homebrew, alternate g++ versions are installed so as not
# to interfere with the system g++, so here, we have to set the compiler
# to the specific version of g++ that we need.
compiler = distutils.spawn.find_executable('g++-4.8')
platform_include_path = ['/usr/local/include']
platform_library_path = ['/usr/local/lib']
compiler_flags = '-Werror -fpermissive -ansi -g -fPIC -DBOOST_ALL_DYN_LINK -DBSD_FPE'
# This is not really a Darwin-specific thing so much as the fact that
# for Tobey, when he installed boost, he inadvertantly specified that
# the multi-threaded libs be named with the -mt suffix.
for lib in libs:
if lib.startswith('boost'):
platform_libs.append(lib + '-mt')
else:
platform_libs.append(lib)
# statically link jsoncpp
# apparently the shared library version of jsoncpp has some bugs.
# See the note at the top of the SConstruct file:
# https://github.com/jacobsa/jsoncpp/blob/master/SConstruct
platform_libs[:] = [lib for lib in platform_libs if not lib == 'jsoncpp']
platform_libs.append(File('/usr/local/lib/libjsoncpp.a'))
# no profiler at this time
platform_libs[:] = [lib for lib in platform_libs if not lib == 'profiler']
if comp_name == 'aeshna':
platform_include_path.append('/home/tobey/usr/local/include')
platform_library_path.append('/home/tobey/usr/local/lib')
if comp_name == 'atlas.snap.uaf.edu':
platform_libs[:] = [lib for lib in platform_libs if not lib == 'jsoncpp']
platform_libs.append('json_linux-gcc-4.4.7_libmt')
# Note: 07-21-2017 - tbc updated the jsoncpp build, so we
# can use his version instead of ruth's. Ruth's older build
# is in /home/UA/rarutter/include, and /home/UA/rarutter/lib
platform_include_path.insert(0, '/home/UA/tcarman2/boost_1_55_0/')
platform_include_path.insert(0, '/home/UA/tcarman2/custom-software/jsoncpp/include')
platform_library_path.insert(0, '/home/UA/tcarman2/custom-software/jsoncpp/libs/linux-gcc-4.4.7')
platform_library_path.insert(0, '/home/UA/tcarman2/boost_1_55_0/stage/lib')
if(USEOMP):
#append build flag for openmp
compiler_flags = compiler_flags + ' -fopenmp'
# Modify setup for MPI, if necessary
if(USEMPI):
compiler = distutils.spawn.find_executable('mpic++')
# append src/parallel-code stuff to src_files and include_paths and libs
local_include_paths.append('src/parallel-code')
compiler_flags = compiler_flags + ' -m64 -DWITHMPI'
libs.append(Split("""mpi_cxx
mpi"""))
#VariantDir('scons_obj','src', duplicate=0)
print "Compiler: " + compiler
GIT_SHA = subprocess.Popen('git describe --abbrev=6 --dirty --always --tags', stdout=subprocess.PIPE, shell=True).stdout.read().strip()
compiler_flags += ' -DGIT_SHA=\\"' + GIT_SHA + '\\"'
#Object compilation
object_list = Object(src_files, CXX=compiler, CPPPATH=platform_include_path,
CPPFLAGS=compiler_flags)
#remove paths from the object file names - unused for now
#object_file_list = [os.path.basename(str(object)) for object in object_list]
Program('dvmdostem', object_list, CXX=compiler, CPPPATH=local_include_paths,
LIBS=platform_libs, LIBPATH=platform_library_path,
LINKFLAGS="-fopenmp")
#Library()