generated from NOAA-OWP/owp-open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_sfincs.sh
executable file
·62 lines (48 loc) · 1.52 KB
/
run_sfincs.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
#!/bin/bash
set -e
# Function to display usage information
usage() {
echo "Usage: $0 [-s|--serverless]"
echo " -s, --serverless Enable serverless pre-processing and post-processing steps"
exit 1
}
cwd=$(pwd)
# Parse command line options
ENABLE_SERVERLESS=false
while [[ $# -gt 0 ]]; do
case $1 in
-s|--serverless)
ENABLE_SERVERLESS=true
shift # past argument
;;
*)
usage
;;
esac
done
# Pre-processing step (if serverless is enabled)
if [ "$ENABLE_SERVERLESS" = true ]; then
echo "Pre-processing Data (Serverless)"
curl -X 'GET' \
'http://localhost:8000/api/v1/publish/start/' \
-H 'accept: application/json'
# Wait for the sfincs.inp file to be created
FILE_PATH="data/SFINCS/ngwpc_data/sfincs.inp"
echo "Waiting for sfincs.inp to be created..."
while [ ! -f "$FILE_PATH" ]; do
sleep 5 # Wait 5 seconds before checking again
echo "sfincs.inp not found yet. Retrying..."
done
fi
echo "Pulling image"
docker pull deltares/sfincs-cpu:sfincs-v2.0.3-Cauberg
echo "Copying data"
rm -rf /tmp/sfincs_temp/ && mkdir /tmp/sfincs_temp/
cp -r data/SFINCS/ngwpc_data /tmp/sfincs_temp/
echo "Running SFINCS"
sudo chmod -R 777 /tmp/sfincs_temp/
docker run -v /tmp/sfincs_temp/ngwpc_data/:/data:rw deltares/sfincs-cpu:sfincs-v2.0.3-Cauberg
sudo chmod -R 777 /tmp/sfincs_temp/
echo "Copying Data"
cp -r /tmp/sfincs_temp/ngwpc_data/sfincs_map.nc data/SFINCS/ngwpc_data/
echo "Done Running SFINCS"