forked from NOAA-OWP/t-route
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcompiler.sh
More file actions
executable file
·174 lines (152 loc) · 5 KB
/
Copy pathcompiler.sh
File metadata and controls
executable file
·174 lines (152 loc) · 5 KB
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
#!/bin/bash
#TODO add options for clean/noclean, make/nomake, cython/nocython
#TODO include instuctions on blowing away entire package for fresh install e.g. rm -r ~/venvs/mesh/lib/python3.6/site-packages/troute/*
#set root folder of github repo (should be named t-route)
REPOROOT=`pwd`
#For each build step, you can set these to true to make it build
#or set it to anything else (or unset) to skip that step
build_mc_kernel=true
build_diffusive_tulane_kernel=true
build_reservoir_kernel=true
build_framework=true
build_routing=true
build_config=true
build_nwm=true
build_bmi=true
if [ -z "$F90" ]
then
export F90="gfortran"
echo "using F90=${F90}"
fi
if [ -z "$CC" ]
then
export CC="gcc"
echo "using CC=${CC}"
fi
# Parse command line arguments
WITH_EDITABLE=true
USE_UV=false
while [[ $# -gt 0 ]]; do
case $1 in
no-e)
WITH_EDITABLE=false
shift
;;
--uv)
USE_UV=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [no-e] [--uv]"
echo " no-e: Install packages without editable mode"
echo " --uv: Use uv pip instead of pip"
exit 1
;;
esac
done
# set pip command based on UV flag
if [[ "$USE_UV" == true ]]; then
PIP_CMD="uv pip"
echo "Using uv pip for package installation"
else
PIP_CMD="pip"
echo "Using standard pip for package installation"
fi
#if you have custom static library paths, uncomment below and export them
#export LIBRARY_PATH=<paths>:$LIBRARY_PATH
#if you have custom dynamic library paths, uncomment below and export them
#export LD_LIBRARY_PATHS=<paths>:$LD_LIBRARY_PATHS
if [ -z "$NETCDF" ]
then
export NETCDFINC="/usr/include/openmpi-$(uname -m)/"
# set alternative NETCDF variable include path, for example for WSL
# (Windows Subsystems for Linux).
#
# EXAMPLE USAGE: export NETCDFALTERNATIVE=$HOME/.conda/envs/py39/include/
# (before ./compiler.sh)
if [ -n "$NETCDFALTERNATIVE" ]
then
echo "using alternative NETCDF inc ${NETCDFALTERNATIVE}"
export NETCDFINC=$NETCDFALTERNATIVE
fi
else
export NETCDFINC="${NETCDF}"
fi
echo "using NETCDFINC=${NETCDFINC}"
if [[ "$build_mc_kernel" == true ]]; then
#building reach and resevoir kernel files .o
cd $REPOROOT/src/kernel/muskingum/
make clean
# ``TROUTE_NATIVE=1 ./compiler.sh`` opts into -mcpu=native / -march=native
# for the kernel build. Default is the portable -O3 build (no native
# arch flags), which is required for any artifact that may run on a
# different CPU than the build host. See src/kernel/muskingum/makefile.
make TROUTE_NATIVE=${TROUTE_NATIVE:-0} || exit
make install || exit
fi
if [[ "$build_diffusive_tulane_kernel" == true ]]; then
#building reach and resevoir kernel files .o
cd $REPOROOT/src/kernel/diffusive/
make clean
make diffusive.o
make pydiffusive.o
make chxsec_lookuptable.o
make pychxsec_lookuptable.o
make install || exit
fi
if [[ "$build_reservoir_kernel" == true ]]; then
cd $REPOROOT/src/kernel/reservoir/
make clean
# The makefile's `all` target lists bind_hybrid.a whose build rule
# is commented out -- bare `make` fails. Build only the two
# archives we actually need + install them, matching what the
# pixi-build path does.
make binding_lp.a bind_rfc.a || exit
make install_lp || exit
make install_rfc || exit
fi
if [[ "$build_framework" == true ]]; then
cd $REPOROOT/src/troute-network
if [[ ${WITH_EDITABLE} == true ]]; then
USE_CYTHON=1 pip install --no-build-isolation --config-setting='--build-option=--use-cython' --editable . --config-setting='editable_mode=compat' || exit
else
USE_CYTHON=1 pip install --no-build-isolation --config-setting='--build-option=--use-cython' . || exit
fi
fi
if [[ "$build_routing" == true ]]; then
#updates troute package with the execution script
cd $REPOROOT/src/troute-routing
rm -rf build
if [[ ${WITH_EDITABLE} == true ]]; then
USE_CYTHON=1 $PIP_CMD install --no-build-isolation --config-setting='--build-option=--use-cython' --editable . --config-setting='editable_mode=compat' || exit
else
USE_CYTHON=1 $PIP_CMD install --no-build-isolation --config-setting='--build-option=--use-cython' . || exit
fi
fi
if [[ "$build_config" == true ]]; then
#updates troute package with the execution script
cd $REPOROOT/src/troute-config
if [[ ${WITH_EDITABLE} == true ]]; then
$PIP_CMD install --editable . || exit
else
$PIP_CMD install . || exit
fi
fi
if [[ "$build_nwm" == true ]]; then
#updates troute package with the execution script
cd $REPOROOT/src/troute-nwm
if [[ ${WITH_EDITABLE} == true ]]; then
$PIP_CMD install --editable . || exit
else
$PIP_CMD install . || exit
fi
fi
if [[ "$build_bmi" == true ]]; then
cd $REPOROOT/src/troute-bmi
if [[ ${WITH_EDITABLE} == true ]]; then
pip install --editable . || exit
else
pip install . || exit
fi
fi