-
Notifications
You must be signed in to change notification settings - Fork 1
/
gaia.sh
143 lines (134 loc) · 4.55 KB
/
gaia.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
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
#!/bin/bash
#================================================================================================
# GAIAHPC initialization script
# Usage: ./gaia.sh <config.dat
#================================================================================================
# Authors: N. D. Vilanakis
# Details: Applied Mathematics and Computers Lab, Technical University of Crete
# * A 3D frequency-domain electromagnetic solver employing a high order compact finite-difference scheme
# * N. D. Vilanakis, N. Economou, E. N. Mathioudakis, A. Vafidis
# * Computers and Geosciences
#================================================================================================
# Check if stdin was redirected
if [ -t 0 ]
then
# No redirection - warn and ask for manual mode
echo "Warning: No configuration file was used as input."
echo "Please supply a suitable configuration file by appending <config.dat to the script."
echo "Alternatively, use manual mode to supply the parameters."
while true; do
read -p "Do you wish to enter manual mode? (y/n) " -n1 yn
case $yn in
[yY] ) echo " ";
echo "Manual mode: Please input the following parameters:";
break;;
[nN] ) echo " ";
echo "Exiting...";
exit;;
* ) echo "";;
esac
done
echo "Enter Lx:"
read lx
echo "Enter Ly:"
read ly
echo "Enter Lz:"
read lz
echo "Enter Tx:"
read tx
echo "Enter Ty:"
read ty
echo "Enter Tz:"
read tz
echo "Enter gl:"
read gl
echo "Enter sigma0:"
read sigma0
echo "Enter sigma:"
read sigma
echo "Enter frequency (Hz):"
read f
echo "All necessary parameters have been supplied."
else
# Automatic mode
read lx ly lz
read tx ty tz
read gl
read sigma0
read sigma
read f
fi
exec 0>&1 1>&0
# Read grid size
grid=`grep -o nx=[0-9]*, ./halfspace/main.f | cut -c 4- | rev | cut -c 2- | rev`\
"x"`grep -o ny=[0-9]*, ./halfspace/main.f | cut -c 4- | rev | cut -c 2- | rev`\
"x"`grep -o nz=[0-9]*, ./halfspace/main.f | cut -c 4- | rev | cut -c 2- | rev`
echo "Grid size now is: " $grid
echo " "
while true; do
read -p "Press c to change grid size, q to quit, or any other key to continue: " -n1 gs
case $gs in
[cC] ) echo " ";
echo "Enter nx";
read nx;
echo "Enter ny";
read ny;
echo "Enter nz";
read nz;
sed -i 's/nx=[0-9]\+,/nx='$nx',/' ./halfspace/main.f;
sed -i 's/ny=[0-9]\+,/ny='$ny',/' ./halfspace/main.f;
sed -i 's/nz=[0-9]\+,/nz='$nz',/' ./halfspace/main.f;
# sed -i 's/ns=[0-9]\+;/ns='$nx';/' ./repo/create_EbackFiles_Halfspace.m;
sed -i 's/nx=[0-9]\+;/nx='$nx';/' ./repo/create_EbackFiles_Halfspace.m;
sed -i 's/ny=[0-9]\+;/ny='$ny';/' ./repo/create_EbackFiles_Halfspace.m;
sed -i 's/nz=[0-9]\+;/nz='$nz';/' ./repo/create_EbackFiles_Halfspace.m;
grid=`grep -o nx=[0-9]*, ./halfspace/main.f | cut -c 4- | rev | cut -c 2- | rev`\
"x"`grep -o ny=[0-9]*, ./halfspace/main.f | cut -c 4- | rev | cut -c 2- | rev`\
"x"`grep -o nz=[0-9]*, ./halfspace/main.f | cut -c 4- | rev | cut -c 2- | rev`;
echo "Grid size now is: " $grid;
break;;
[qQ] ) echo " ";
echo "Exiting...";
exit;;
* ) echo " ";
break;;
esac
done
# Start working processes
echo `date`": Running Matlab..."
cd repo
/usr/local/MATLAB/R2014b/bin/matlab -nodesktop -nosplash -r "run('create_EbackFiles_Halfspace.m');exit;" | tail -n +17
cd ..
echo `date`": Matlab finished."
echo `date`": Running main exec with the following params:"
echo " " $lx $ly $lz $tx $ty $tz $gl $sigma0 $sigma $f
cd halfspace
make
cd ..
./halfspace/exe
echo `date`": Main exec finished."
echo `date`": Creating directory structure..."
dirstr=./halfspace/Results/"$grid"/"$lx"_"$ly"_"$lz"/"$tx"_"$ty"_"$tz"_"$gl"/"${sigma0}"_"${sigma}"_"$f"/`date +%Y-%m-%d-%H:%M`
echo $dirstr
mkdir -p $dirstr
mkdir -p $dirstr/f2m
cd repo
python3 convert_files.py
/usr/local/MATLAB/R2014b/bin/matlab -nodesktop -nosplash -r "run('convert_file_type.m');exit;" | tail -n +17
cd ../
echo `date`": Moving files..."
mv ./temp/EX.txt $dirstr
mv ./temp/EY.txt $dirstr
mv ./temp/EZ.txt $dirstr
mv ./temp/EtotalX.txt $dirstr
mv ./temp/EtotalY.txt $dirstr
mv ./temp/ETX.mat $dirstr/f2m
mv ./temp/ETY.mat $dirstr/f2m
mv ./temp/Ex.mat $dirstr/f2m
mv ./temp/Ey.mat $dirstr/f2m
mv ./temp/TotalEX.mat $dirstr/f2m
mv ./temp/TotalEY.mat $dirstr/f2m
mv ./temp/info.txt $dirstr
echo `date`": Cleaning up..."
rm ./temp/*
echo `date`": Finished."