forked from SPECFEM/specfem3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_simulation_type.pl
executable file
·64 lines (55 loc) · 1.46 KB
/
change_simulation_type.pl
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
#!/usr/bin/perl
# this script changes the simulation_type in DATA/Par_file
# Qinya Liu, May 2007, Caltech
use Time::Local;
use Getopt::Std;
use POSIX;
sub Usage{
print STDERR <<END;
Usage: change_simulation_type.pl [-a|-f|-b|-F]
Changes SIMULATION_TYPE in DATA/Par_file
-a -- change type to run adjoint calculation(2)
-f -- change type to run forward calculation(1)
-b -- change type to run both simultaneously(3)
-F -- change type to run forward calculation(1) with save_forward = .true.
END
exit(1);
}
@ARGV == 1 or Usage();
if(!getopts('abfF')) {die(" check input arguments\n");}
open(IN,"DATA/Par_file");
@vfm=<IN>;
close(IN);
foreach $vfm (@vfm){
if($vfm=~/SIMULATION_TYPE/){
if(${opt_a}){
print "Changed simulation_type to 2 in Par_file \n";
$vfm=~s/= 1/= 2/;
$vfm=~s/= 3/= 2/;
}
elsif(${opt_f}){
print "Changed simulation_type to 1 in Par_file \n";
$vfm=~s/= 2/= 1/;
$vfm=~s/= 3/= 1/;
}
elsif(${opt_b}){
print "Changed simulation_type to 3 in Par_file \n";
$vfm=~s/= 1/= 3/;
$vfm=~s/= 2/= 3/;
}
elsif(${opt_F}){
print "Changed simulation_type to 1 and save_forward = .true. in Par_file \n";
$vfm=~s/= 2/= 1/;
$vfm=~s/= 3/= 1/;
}
}
if ($vfm=~/SAVE_FORWARD/) {
if ($opt_F) { $vfm=~s/false/true/; }
else {$vfm=~s/true/false/;}
}
}
open(OUT,">DATA/Par_file");
foreach $vfm (@vfm){
print OUT "$vfm";
}
close(OUT);