-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_frechet_simulations.sh
executable file
·118 lines (85 loc) · 2.45 KB
/
run_frechet_simulations.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
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
#!/bin/bash
# This script was originally written to run a test
# for checking the difference between the true frechet derivatives
# with respect to the source location and the ones
# that were missing a second order term.
#
# The SOURCE_DERIVATIVE_TYPE1 flag has since been removed
# from specfem. And the code will not work.
# It is kept because it contains a quite simple script that
# can test a variety of source location, and possibly
# moment tensor variations with just minor modifications.
#
# 2021.09.16 10:45 -- Lucas Sawade
# Scriptdir
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Specfem
submissiondir="${SCRIPT_DIR}/submission/slurm"
specfem="${SCRIPT_DIR}/specfem3d_globe"
specfemdata="${specfem}/DATA"
outdir="${specfem}/OUTPUT_FILES"
oldparfile="${SCRIPT_DIR}/Par_file"
newparfile="${specfemdata}/Par_file"
oldcmt="${SCRIPT_DIR}/CMTSOLUTION"
newcmt="${specfemdata}/CMTSOLUTION"
# Output dirs
OUT="${SCRIPT_DIR}/outdir"
# Event parameters ( Foot of Himalaya, Andes-Pacific )
lats=( 26.8363 -24.6024 )
lons=( 87.4610 -70.4798 )
typeder=( .true. .false. )
for i in ${!lats[@]}
do
# Make one directory for each event
maindir="${OUT}/event_${i}"
if [ ! -d $maindir ]
then
mkdir -p $maindir
fi
# Seimogram dir
seismograms="${maindir}/seismograms"
if [ ! -d $seismograms ]
then
mkdir $seismograms
fi
# Editing CMTSOLUTION
echo "Latitude ${lats[${i}]}"
echo "Longitude ${lons[${i}]}"
latitude="${lats[${i}]}"
longitude="${lons[${i}]}"
repl=$(printf "latitude: %18.4f" "$latitude")
sed "s/.*latitude.*/$repl/" $oldcmt > $newcmt
repl=$(printf "longitude: %17.4f" "$longitude")
sed -i "s/.*longitude.*/$repl/" $newcmt
# Check
diff $oldcmt $newcmt
# Copy cmtsolution to the directory
cp $newcmt $maindir/
# Change up the seismogram game
for j in ${typeder[@]}
do
if [ "${j}" == ".true." ]
then
seisdir="${seismograms}/2nd"
echo 2nd Order Derivative
else
seisdir="${seismograms}/DD"
echo Double Differentiation
fi
# Change Parfile
repl="USE_SOURCE_DERIVATIVE_TYPE1 = ${j}"
echo $repl
sed "s/.*USE_SOURCE_DERIVATIVE_TYPE1.*/$repl/" $oldparfile > $newparfile
diff $oldparfile $newparfile
if [ ! -d $seisdir ]
then
mkdir $seisdir
fi
# switch to submissiondir
cd $submissiondir
sbatch --wait run.sh
cd -
# Move computed seismograms
mv ${outdir}/*.sac ${seisdir}/
done
done