-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun_asofi3D.sh
executable file
·68 lines (57 loc) · 1.72 KB
/
run_asofi3D.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
#!/usr/bin/env bash
# Compile and run ASOFI3D solver and then prepare snapshots for visualization.
# Correctly determine the exit status of a pipe.
set -o pipefail
# Separator line to separate output of different stages.
sep="************************************************************************"
# Number of the MPI processes. Default value is adapted for Macbook Pro laptop.
nmpiprocs=4
if [[ $# -gt 0 ]]; then
nmpiprocs="$1"
fi
# Working directory for simulation input and output.
sim_dir="par/"
if [[ $# -gt 1 ]]; then
sim_dir="$2"
fi
# Compile the whole code.
echo "$sep"
echo "Compilation"
make asofi3d
if [ "$?" -eq 0 ]; then
echo "Compilation successful"
else
echo "ERROR: Compilation failed" > /dev/stderr
exit 1
fi
# Add `bin` directory to $PATH to be able to execute programs
# (asofi3d, snapmerge, etc.) without specifying the file path.
script_dir="$(cd "$(dirname $0)" && pwd)"
export PATH=${script_dir}/bin:$PATH
# Go to the working directory with simulation input files.
pushd "$sim_dir" > /dev/null || exit 1
# Run the code
config_file="in_and_out/asofi3D.json"
printf "Run code\n"
mpirun -n $nmpiprocs nice -19 asofi3D $config_file | tee in_and_out/ASOFI3D.log
if [ $? -eq 0 ]; then
echo "OK"
else
echo "ERROR: running ASOFI3D solver has failed. Check the output above" > /dev/stderr
exit 1
fi
# Merge snapshots made by individual MPI processes for visualization.
echo "$sep"
echo "Prepare snapshots"
snapmerge $config_file
if [ $? -eq 0 ]; then
echo "OK"
else
echo "ERROR: merging snapshots has failed" > /dev/stderr
exit 1
fi
popd > /dev/null || exit 1
echo "$sep"
echo "Done."
script="./ASOFI3D/mfiles/snap_ASOFI3D.m"
printf "Run MATLAB script %s to see the wavefield.\n" "$script"