[cig-commits] [commit] pluggable: Several fixes, mostly having to do with SACAUX. (ec3cf48)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Apr 9 08:55:55 PDT 2014


Repository : ssh://geoshell/specfem3d_globe

On branch  : pluggable
Link       : https://github.com/geodynamics/specfem3d_globe/compare/64e1b38f0c5ebb4056cce0b15d41c0b9f94ab6e5...099a4d330d5b173b21e51ad441f9f429e5d37842

>---------------------------------------------------------------

commit ec3cf48d85afaf31e957655b20996a7e8b44e6af
Author: Leif Strand <leif at geodynamics.org>
Date:   Thu May 7 01:55:26 2009 +0000

    Several fixes, mostly having to do with SACAUX.


>---------------------------------------------------------------

ec3cf48d85afaf31e957655b20996a7e8b44e6af
 UTILS/seis_process/configure.ac       |  3 +++
 UTILS/seis_process/convolve_stf.c     |  3 ++-
 UTILS/seis_process/process_data.pl.in | 21 ++++++++++++++-------
 UTILS/seis_process/process_syn.pl.in  | 22 ++++++++++++++--------
 UTILS/seis_process/rotate.pl.in       | 15 +++++++++++----
 5 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/UTILS/seis_process/configure.ac b/UTILS/seis_process/configure.ac
index 4d10f2a..8bb6c59 100644
--- a/UTILS/seis_process/configure.ac
+++ b/UTILS/seis_process/configure.ac
@@ -14,6 +14,9 @@ fi
 if test ! -d "$SACAUX"; then
     AC_MSG_ERROR([SACAUX (=$SACAUX) does not name a directory])
 fi
+if test ! -f "$SACAUX/messages" -o ! -e "$SACAUX/../bin/sac"; then
+    AC_MSG_ERROR([SACAUX (=$SACAUX) is not valid])
+fi
 
 # Checks for programs.
 AC_PROG_CC
diff --git a/UTILS/seis_process/convolve_stf.c b/UTILS/seis_process/convolve_stf.c
index c3f7d5e..696585f 100644
--- a/UTILS/seis_process/convolve_stf.c
+++ b/UTILS/seis_process/convolve_stf.c
@@ -180,8 +180,9 @@ main(int argc, char *argv[])
 
         /* get additional info */
         getfhv("delta", &dt, &nerr, strlen("delta"));
-        getfhv("o", &origin, &nerr, strlen("o"));
         getfhv("scale", &scale, &nerr, strlen("scale"));
+        
+        getfhv("o", &origin, &nerr, strlen("o"));
         if(nerr) {
             fprintf(stderr,"No origin time is defined for the sac file\n");
             return 1;
diff --git a/UTILS/seis_process/process_data.pl.in b/UTILS/seis_process/process_data.pl.in
index f079002..3d4909a 100755
--- a/UTILS/seis_process/process_data.pl.in
+++ b/UTILS/seis_process/process_data.pl.in
@@ -43,7 +43,12 @@ END
   exit(1);
 }
 
-$sacaux = $ENV{SACAUX} or "@sacaux@";
+if (defined $ENV{SACAUX}) {
+    $sacaux = $ENV{SACAUX};
+} else {
+    $sacaux = "@sacaux@";
+    $ENV{SACAUX}=$sacaux;
+}
 unless (-d $sacaux) {die("missing SAC aux directory: '$sacaux'\n");}
 
 if (@ARGV == 0) { Usage(); }
@@ -63,8 +68,10 @@ else{($poles,$pass)=split(/\//,$opt_P);
 if (!$opt_T) {$opt_T = 0.05;}
 if ($opt_l) {($lmin,$lmax) = split(/\//,$opt_l);} else {$lmin = 0; $lmax = 3600;}
 
+$sac="$sacaux/../bin/sac";
 $saclst="$sacaux/../bin/saclst";
 $phtimes="phtimes";
+if (! -e $sac)  {die(" No $sac file\n");}
 if (! -e $saclst) {die(" No $saclst file\n");}
 #if (! -e $phtimes) {die("No $phtimes file\n");}
 
@@ -80,8 +87,8 @@ foreach $file (@ARGV) {
   if ($ext or $opt_d) {system("\\cp -f $file $outfile");}
 
   # process data
-  if ($opt_c) {open(SAC,"|sac ") || die("Can't open sac\n");}
-  else {open(SAC,"|sac > /dev/null") || die("Can't open sac\n");}
+  if ($opt_c) {open(SAC,"|$sac ") || die("Can't open sac\n");}
+  else {open(SAC,"|$sac > /dev/null") || die("Can't open sac\n");}
   print SAC "echo on\n";
   print SAC "r $outfile\n";
 
@@ -98,8 +105,8 @@ foreach $file (@ARGV) {
     print SAC "ch evla $elat evlo $elon evdp $edep \n";
     print SAC "w $outfile\nquit\n";
     close(SAC);
-    if ($opt_c) {open(SAC,"|sac ") || die("Can't open sac\n");}
-    else {open(SAC,"|sac > /dev/null") || die("Can't open sac\n");}
+    if ($opt_c) {open(SAC,"|$sac ") || die("Can't open sac\n");}
+    else {open(SAC,"|$sac > /dev/null") || die("Can't open sac\n");}
     print SAC "echo on\n";
     print SAC "r $outfile\n";}
 
@@ -112,8 +119,8 @@ foreach $file (@ARGV) {
     print SAC "cut %begin% %end% \n";
     print SAC "r $outfile\n cut off\n  w over \nquit\n";
     close (SAC);
-    if ($opt_c) {open(SAC,"|sac ") || die("Can't open sac\n");}
-    else {open(SAC,"|sac > /dev/null") || die("Can't open sac\n");}
+    if ($opt_c) {open(SAC,"|$sac ") || die("Can't open sac\n");}
+    else {open(SAC,"|$sac > /dev/null") || die("Can't open sac\n");}
     print SAC "echo on\n";
     print SAC "r $outfile\n";}
 
diff --git a/UTILS/seis_process/process_syn.pl.in b/UTILS/seis_process/process_syn.pl.in
index c233ccf..d221dc6 100755
--- a/UTILS/seis_process/process_syn.pl.in
+++ b/UTILS/seis_process/process_syn.pl.in
@@ -22,8 +22,7 @@ where
     -i Dir -- convolve synthetics with instrument response in Dir
     -A amp_factor -- multiple all files with an amplification factor
     -p -- pick P and S arrivals according to iasp91 model to t1/t2 headers
-    -a STAFILE -- add station information from STAFILE, use "-a none"
-       to get information from Vala''s station file
+    -a STAFILE -- add station information from STAFILE
     -s sps -- resampling rate for synthetics (default is 1.0)
     -y t0/V0/t1/V1 -- add to t3/t4 the arrival times of t + dist/V
     -c -- show sac output
@@ -41,7 +40,12 @@ END
 exit(1);
 }
 
-$sacaux = $ENV{SACAUX} or "@sacaux@";
+if (defined $ENV{SACAUX}) {
+    $sacaux = $ENV{SACAUX};
+} else {
+    $sacaux = "@sacaux@";
+    $ENV{SACAUX}=$sacaux;
+}
 unless (-d $sacaux) {die("missing SAC aux directory: '$sacaux'\n");}
 
 @ARGV > 1 or Usage();
@@ -57,7 +61,7 @@ else{($poles,$pass)=split(/\//,$opt_P);
      if(not defined $pass or $pass<1){$pass=2;}}
 if ($opt_l) {($lmin,$lmax) = split(/\//,$opt_l);} 
 else {$lmin = 0; $lmax = 3600;}
-if ($opt_a and not -f $opt_a) {$opt_a="/opt/seismo-util/data/STATIONS_new";}
+if ($opt_a and not -f $opt_a) {die("No such file as $opt_a\n");}
 if ($opt_o and not $opt_m) {die("Specify centroid time first\n");}
 if ($opt_d and not -d $opt_d) {die("No such directory as $opt_d\n");}
 if ($opt_i and not -d $opt_i) {die("No such directory as $opt_i\n");}
@@ -66,9 +70,11 @@ if ($opt_A) {if ($opt_A !~ /^\d/) {die("-A option should be numbers\n");}}
 $undef = -12345;
 $eps = 0.1;
 
+$sac="$sacaux/../bin/sac";
 $saclst="$sacaux/../bin/saclst";
 $phtimes="phtimes";
 $asc2sac="@prefix@/bin/asc2sac";
+if (! -e $sac)  {die(" No $sac file\n");}
 if (! -e $saclst)  {die(" No $saclst file\n");}
 #if (! -e $phtimes) {die("No $phtimes file\n");}
 if (! -e $asc2sac) {die("No $asc2sac file\n");}
@@ -103,7 +109,7 @@ foreach $file (@ARGV) {
   if ($ext or $opt_d) {system("\\cp -f $file $outfile");}
   print "Output to file $outfile\n";
 
-  if ($opt_c) { open(SAC,"|sac");}else {open(SAC,"|sac > /dev/null");}
+  if ($opt_c) { open(SAC,"|$sac");}else {open(SAC,"|$sac > /dev/null");}
   print SAC "echo on\n";
 
   print SAC "r $outfile\n";
@@ -115,10 +121,10 @@ foreach $file (@ARGV) {
     print SAC "ch evla $elat evlo $elon evdp $edep \n wh\n";
     print SAC "w over \nquit\n";
     close(SAC);
-    if ($opt_c) {open(SAC,"|sac");}else {open(SAC,"|sac > /dev/null");}
+    if ($opt_c) {open(SAC,"|$sac");}else {open(SAC,"|$sac > /dev/null");}
     print SAC "echo on\n r $outfile\n";}
 
-    if ($opt_h and $hdur > $min_hdur) { # convolve source time function
+  if ($opt_h and $hdur > $min_hdur) { # convolve source time function
     system("@prefix@/bin/convolve_stf g $hdur $outfile");
     system("mv ${outfile}.conv ${outfile}");}
 
@@ -151,7 +157,7 @@ foreach $file (@ARGV) {
   if ($opt_s) {print SAC "interp delta $dt\n";}
   print SAC "w over\nquit\n";
   close(SAC);
-  if ($opt_c) { open(SAC,"|sac");}else {open(SAC,"|sac > /dev/null");}
+  if ($opt_c) { open(SAC,"|$sac");}else {open(SAC,"|$sac > /dev/null");}
   print SAC "echo on\n r $outfile\n ";
 
   if ($opt_t){ # filter record
diff --git a/UTILS/seis_process/rotate.pl.in b/UTILS/seis_process/rotate.pl.in
index 601b7a3..185310a 100755
--- a/UTILS/seis_process/rotate.pl.in
+++ b/UTILS/seis_process/rotate.pl.in
@@ -25,14 +25,21 @@ EOF
 exit(1)
 }
 
-$sacaux = $ENV{SACAUX} or "@sacaux@";
+if (defined $ENV{SACAUX}) {
+    $sacaux = $ENV{SACAUX};
+} else {
+    $sacaux = "@sacaux@";
+    $ENV{SACAUX}=$sacaux;
+}
 unless (-d $sacaux) {die("missing SAC aux directory: '$sacaux'\n");}
 
 if (!getopts('l:L:cdts')) {die('Check input arguments\n');}
 @ARGV > 0 or Usage();
 if (!$opt_l) {$opt_l = 0;}
+$sac="$sacaux/../bin/sac";
 $saclst = "$sacaux/../bin/saclst";
-if (not -f $saclst) {die("No such file as $saclst\n");}
+if (! -e $sac)  {die(" No $sac file\n");}
+if (! -e $saclst) {die(" No $saclst file\n");}
 $undef=-12345.0;
 $eps=0.1;
 
@@ -83,8 +90,8 @@ foreach $file (@ARGV) {
 
   # check if the reference time is the same or not!
 
-  if ($opt_c) {open(SAC,"|$sacaux/../bin/sac");}
-  else {open(SAC,"|$sacaux/../bin/sac > /dev/null");}
+  if ($opt_c) {open(SAC,"|$sac");}
+  else {open(SAC,"|$sac > /dev/null");}
   print SAC "echo on\n";
   print SAC "r $north $east\n ";
   if ($opt_L or $npts_n != $npts_e or abs($nb-$eb) > $eps) { #cut properly



More information about the CIG-COMMITS mailing list