forked from CIMM-ORG/SWMM5plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_dependencies.sh
More file actions
executable file
·164 lines (146 loc) · 5.27 KB
/
build_dependencies.sh
File metadata and controls
executable file
·164 lines (146 loc) · 5.27 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
#!/bin/bash
# --------------------------------------------------------------------------------------
# Alpha Release:
# Shell script for installing dependencies
#
# [README]
# This shell script is for downloading the dependencies of SWMM 5+. The dependencies
# include:
# (1) json-fortran, from: https://github.com/jacobwilliams/json-fortran.git
# (2) SWMM 5 libraries, from: https://github.com/USEPA/Stormwater-Management-Model/archive/v5.1.13.tar.gz
# (3) OpenCoarray and its dependencies, from: https://github.com/sourceryinstitute/OpenCoarrays
#
# OpenCoarray is a Fortran Coarray libaray designed for GNC compiler (e.g. gfortran series).
# Before we start the installation/compile of SWMM5+, we strongly recommand users to check the
# of compiler version. If user is using Intel Compiler, then the OpenCoarray dependencies
# installation can be skipped by simply adding a "-t" flag after the command "./build.sh". If
# user is using gcc compiler, please make sure the compiler version is higher than 6.1.0.
# The dependencies of OpenCoarray include:
#
# opencoarrays
# ├── cmake-3.4.0
# └── mpich-3.2
# └── gcc-6.1.0
# ├── flex-2.6.0
# │ └── bison-3.0.4
# │ └── m4-1.4.17
# ├── gmp
# ├── mpc
# └── mpfr
#
# This script will first check if the above-mentioned pakcages exist in the local directory,
# If not found -> then download and install.
# For the OpenCoarray dependencies, script will check the existencce of local copy of cmake and mpich,
# For the user first time download/compile SWMM5+, all these packages will be downloaded and installed.
# This is an one-time installation work if user keeps working in the same SWMM5+ directory. However,
# the dependencies installation process is required everytime after cloning a new version of SWMM 5+.
#
# More information for the packages can refer to :
# json fortran : https://github.com/jacobwilliams/json-fortran#brief-description
# SWMM 5 library: https://www.epa.gov/water-research/storm-water-management-model-swmm
# OpenCoarray: http://www.opencoarrays.org/
# --------------------------------------------------------------------------------------
shopt -s extglob
# Create directory for dependencies
if [[ ! -d $DDIR ]]
then
mkdir $DDIR
fi
# --------------------------------------------------------------------------------------
# Download json-fortran
# --------------------------------------------------------------------------------------
if [ ! -d "$JSON_DIR" ]
then
echo
echo "Downloading json-fortran"
echo
cd $DDIR
git clone 'https://github.com/jacobwilliams/json-fortran.git'
cd json-fortran
rm -rf -v !('src'|'LICENSE')
rm -rf .*
mv src/*.* .
rm -rf src
cd $SWMM5PLUS_DIR
fi
# --------------------------------------------------------------------------------------
# Download EPA-SWMM
# --------------------------------------------------------------------------------------
if [[ $compile_swmmc = "true" ]]
then
if [[ $compile_fortran = "true" ]]
then
if [[ $download_swmmc = "true" ]] # false skips the delete of existing swmmc brh 20211209
then
if [[ -d interface/src ]]
then
rm -rf interface/src
fi
fi
fi
fi
if [ ! -d "$API_DIR/src" ]
then
if [[ $download_swmmc = "true" ]] # false skips the download brh20211209
then
echo
echo "Downloading SWMM 5.1.13"
echo
if [[ $machine = "linux" ]]
then
wget https://github.com/USEPA/Stormwater-Management-Model/archive/v5.1.13.tar.gz
elif [[ $machine = "mac" ]]
then
curl -L "https://github.com/USEPA/Stormwater-Management-Model/archive/v5.1.13.tar.gz" > v5.1.13.tar.gz
else
echo
echo "OS is not supported (only mac, linux)"
echo
exit
fi
tar -xvf *.tar.gz
rm *.tar.gz
cp -r Stormwater*/src "$API_DIR/src"
rm -rf Stormwater*
fi
fi
# Compile EPA-SWMM
echo
echo Compiling SWMM 5.13 ...
echo
cp -f "$API_DIR/api.h" "$API_DIR/src/"
cp -f "$API_DIR/api.c" "$API_DIR/src/"
cp -f "$API_DIR/api_error.h" "$API_DIR/src/"
cp -f "$API_DIR/api_error.c" "$API_DIR/src/"
# Insert new files in EPA-SWMM Makefile
SCRIPTS='api_error.o api.o'
OBJECTS='api_error.o : headers.h api_error.h\
api.o : api.h api_error.h headers.h\
'
API_TEST_FILES=""
for fname in $(find $TEST_DIR -name '*.c')
do
F=$(basename -- "$fname")
F="${F%.*}"
SCRIPTS="$SCRIPTS $F.o"
if [[ -f "${fname%.*}.h" ]]
then
OBJECTS="${OBJECTS}$F.o : headers.h $F.h\
"
cp -f "$TEST_DIR/$F.h" "$API_DIR/src/"
else
OBJECTS="${OBJECTS}$F.o : headers.h\
"
fi
cp -f "$TEST_DIR/$F.c" "$API_DIR/src/"
done
sed "s#{{SCRIPTS}}#$SCRIPTS#" "$API_DIR/Makefile" > "$API_DIR/src/Makefile"
sed -i'.original' -e "s#{{OBJECTS}}#$OBJECTS#" "$API_DIR/src/Makefile"
rm "$API_DIR/src/Makefile.original"
cd "$API_DIR/src" && make
cd $SWMM5PLUS_DIR
cp $API_DIR/src/libswmm5.so $SWMM5PLUS_DIR/libswmm5.so
# --------------------------------------------------------------------------------------
echo
echo Completed Installation of Dependencies!
echo