-
Notifications
You must be signed in to change notification settings - Fork 17
/
setup
executable file
·91 lines (79 loc) · 2.33 KB
/
setup
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
#!/bin/bash
#
# Ben Fasoli
#
# Convenience script to ensure code is fetched from different sources and
# fortran binaries and DLLs are compiled and moved to the correct location
set -e
# Check if ./setup is run from the top level of the project
dircnt=$(ls -d */ | grep -x -e bin/ -e r/ -e exe/ | wc -l)
if [ $dircnt -lt 3 ]; then
echo "./setup must be run from the top level directory of the STILT project" >/dev/stderr
exit 1
fi
# Check dependency versions
if ! command -v Rscript &>/dev/null; then
echo "Rscript not found" >/dev/stderr
exit 1
fi
if ! command -v bc &>/dev/null; then
echo "bc not found, continuing without checking R version"
else
R_VERSION=$(Rscript --version &>/dev/stdout | cut -d " " -f 5 | cut -d "." -f 1-2)
if (($(echo "$R_VERSION <= 3.5" | bc -l >/dev/null))); then
echo "R version $R_VERSION must be 3.5 or higher" >/dev/stderr
exit 1
fi
fi
if ! command -v nc-config &>/dev/null; then
echo "NetCDF library (nc-config) not found" >/dev/stderr
exit 1
fi
NC_VERSION=$(nc-config --version | cut -d " " -f 2 | cut -d "." -f 1)
if [ "$NC_VERSION" -lt 4 ]; then
echo "NetCDF library (nc-config) version must be 4.0 or higher" >/dev/stderr
exit 1
fi
# Compile permute DLL for footprint kernel aggregation
echo "Compiling footprint kernel aggregation subroutine..."
R CMD SHLIB r/src/permute.f90
if [ ! -s r/src/permute.so ]; then
echo "Problem compiling r/src/permute.so." >/dev/stderr
exit 1
fi
if [[ "$OSTYPE" == "linux"* ]]; then
install="1"
elif [[ "$OSTYPE" == "darwin"* ]]; then
install="2"
else
echo "
STILT hycs_std installation options:
1 - linux_x64
2 - macos_x64
9 - Compile hycs_std from source (unavailable)
"
echo -n "Install option (number from above): "
read -n 1 install
echo
fi
if [[ $install -eq 1 ]]; then
cp bin/linux_x64/* exe/
elif [[ $install -eq 2 ]]; then
cp bin/macos_x64/* exe/
else
echo "Invalid install option." >/dev/stderr
exit 1
fi
# Check that hycs_std was created from methods above
if [ ! -s exe/hycs_std ]; then
echo "Problem installing hycs_std" >/dev/stderr
exit 1
fi
# Ensure hysplit, run_stilt.r, and stilt_cli.r are executable
chmod +x exe/hycs_std r/run_stilt.r r/stilt_cli.r
echo "
STILT installation successful.
We strongly suggest you subscribe to the mailing list at
https://uataq.github.io/stilt/
to be notified of critical code updates.
"