forked from NOAA-EPIC/hpc-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_stack.sh
executable file
·281 lines (235 loc) · 6.21 KB
/
build_stack.sh
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
#!/bin/bash
# The purpose of this script is to build the software stack using
# the compiler/MPI combination
#
# sample usage:
# build_stack.sh -p "prefix" -c "config.sh" -y "stack.yaml" -l "library" -m
# build_stack.sh -h
set -eu
# root directory for the repository
export HPC_STACK_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# ==============================================================================
usage() {
set +x
echo
echo "Usage: $0 -p <prefix> | -c <config> | -y <yaml> | -l <library> -m -h"
echo
echo " -p installation prefix <prefix> DEFAULT: $HOME/opt"
echo " -c use configuration file <config> DEFAULT: config/config_custom.sh"
echo " -y use yaml file <yaml> DEFAULT: config/stack_custom.yaml"
echo " -m use modules DEFAULT: NO"
echo " -l library to install <library> DEFAULT: ALL"
echo " -h display this message and quit"
echo
exit 1
}
# ==============================================================================
echo "Starting hpc-stack build: `date` "
# Defaults:
library=""
export PREFIX="$HOME/opt"
config="${HPC_STACK_ROOT}/config/config_custom.sh"
yaml="${HPC_STACK_ROOT}/stack/stack_custom.yaml"
export MODULES=false
while getopts ":p:c:y:l:mh" opt; do
case $opt in
p)
export PREFIX=$OPTARG
;;
c)
config=$OPTARG
;;
y)
yaml=$OPTARG
;;
l)
library=$OPTARG
;;
m)
export MODULES=true
;;
h|\?|:)
usage
;;
esac
done
# ==============================================================================
# Source helper functions
source "${HPC_STACK_ROOT}/stack_helpers.sh"
#===============================================================================
# Source the config file
if [[ -e $config ]]; then
source $config
else
echo "ERROR: CONFIG FILE $config DOES NOT EXIST, ABORT!"
exit 1
fi
# Source the yaml to determine software and version
if [[ -e $yaml ]]; then
eval $(parse_yaml $yaml "STACK_")
else
echo "ERROR: YAML FILE $yaml DOES NOT EXIST, ABORT!"
exit 1
fi
# ==============================================================================
# install with root permissions?
[[ $USE_SUDO =~ [yYtT] ]] && export SUDO="sudo" || export SUDO=""
# ==============================================================================
# create build directory if needed
pkgdir=${HPC_STACK_ROOT}/${PKGDIR:-"pkg"}
mkdir -p $pkgdir
# This is for the log files
logdir=$HPC_STACK_ROOT/${LOGDIR:-"log"}
mkdir -p $logdir
# ==============================================================================
# start with a clean slate
if $MODULES; then
source $MODULESHOME/init/bash
module use $PREFIX/modulefiles/stack
module load hpc
else
no_modules
set_no_modules_path
set_pkg_root
fi
# ==============================================================================
# Echo compiler, mpi and build information
compilermpi_info
build_info
# ==============================================================================
# Is this a single library build or the entire stack?
if [ -n "${library:-""}" ]; then
build_lib $library
echo "build_stack.sh: SUCCESS!"
exit 0
fi
# ==============================================================================
#----------------------
# Compiler and MPI
build_lib gnu
$MODULES || { [[ ${STACK_gnu_build:-} =~ [yYtT] ]] && export PATH="$PREFIX/bin:$PATH"; }
build_lib mpi
$MODULES || { [[ ${STACK_mpi_build:-} =~ [yYtT] ]] && export PATH="$PREFIX/bin:$PATH"; }
# ==============================================================================
#----------------------
# MPI-independent
# - should add a check at some point to see if they are already there.
# this can be done in each script individually
# it might warrant a --force flag to force rebuild when desired
build_lib cmake
build_lib udunits
build_lib jpeg
build_lib zlib
build_lib libpng
build_lib szip
build_lib jasper
build_lib gsl
build_lib sqlite
build_lib libtiff
build_lib proj
build_lib geos
build_lib openblas
# Also build serial versions of HDF5 and netCDF, if using MODULES
if $MODULES; then
# Save $HPC_MPI variable
_HPC_MPI=$HPC_MPI
export HPC_MPI=""
# Build hdf5 and netcdf as serial versions
build_lib hdf5
build_lib netcdf
# Build netcdf utilities with the serial netCDF library
build_lib nccmp
build_lib nco
build_lib cdo
# Restore $HPC_MPI variable
export HPC_MPI=$_HPC_MPI
unset _HPC_MPI
fi
#----------------------
# MPI-dependent
# These must be rebuilt for each MPI implementation
build_lib hdf5
build_lib pnetcdf
build_lib netcdf
# Only build these if only parallel builds are installed
if ! $MODULES; then
build_lib nccmp
build_lib nco
build_lib cdo
fi
build_lib pio
# NCEPlibs
build_lib bacio
build_lib sigio
build_lib sfcio
build_lib gfsio
build_lib w3nco
build_lib w3emc
build_lib sp
build_lib ip
build_lib ip2
build_lib landsfcutil
build_lib nemsio
build_lib nemsiogfs
build_lib g2
build_lib g2c
build_lib g2tmpl
build_lib crtm
build_lib nceppost
build_lib upp
build_lib wrf_io
build_lib bufr
build_lib wgrib2
build_lib prod_util
build_lib grib_util
build_lib ncio
build_lib ncdiag
if $MODULES; then
# Save $HPC_MPI variable
_HPC_MPI=$HPC_MPI
export HPC_MPI=""
build_lib nemsio
# Restore $HPC_MPI variable
export HPC_MPI=$_HPC_MPI
unset _HPC_MPI
fi
# Other
build_lib madis
# Python and associate virtual environments
build_lib miniconda3
build_lib r2d2
# JEDI 3rd party dependencies
build_lib boost
build_lib eigen
build_lib gsl_lite
build_lib gptl
build_lib fftw
build_lib tau2
build_lib cgal
build_lib json
build_lib json_schema_validator
build_lib pybind11
# JEDI dependencies
build_lib ecbuild
build_lib eckit
build_lib fckit
build_lib atlas
# MET and METplus
build_lib met
build_lib metplus
# UFS 3rd party dependencies
build_lib esmf
build_lib scotch
build_lib fms
build_lib cmakemodules
build_lib esma_cmake
build_lib gftl_shared
build_lib yafyaml
build_lib mapl
# ==============================================================================
# optionally clean up
[[ $MAKE_CLEAN =~ [yYtT] ]] && \
( $SUDO rm -rf $pkgdir; $SUDO rm -rf $logdir )
# ==============================================================================
echo "build_stack.sh: SUCCESS!"
echo "Finished hpc-stack build: `date` "