[cig-commits] [commit] pluggable: Removed most hard-coded paths from Perl scripts. (8a65149)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Apr 9 08:55:45 PDT 2014
Repository : ssh://geoshell/specfem3d_globe
On branch : pluggable
Link : https://github.com/geodynamics/specfem3d_globe/compare/64e1b38f0c5ebb4056cce0b15d41c0b9f94ab6e5...099a4d330d5b173b21e51ad441f9f429e5d37842
>---------------------------------------------------------------
commit 8a651495862ad3eb5daaeaada4de5b75d6fb62cf
Author: Leif Strand <leif at geodynamics.org>
Date: Wed May 6 19:10:14 2009 +0000
Removed most hard-coded paths from Perl scripts.
>---------------------------------------------------------------
8a651495862ad3eb5daaeaada4de5b75d6fb62cf
UTILS/seis_process/Makefile.am | 11 +++++++++++
UTILS/seis_process/configure.ac | 3 +++
.../seis_process/{process_data.pl => process_data.pl.in} | 15 +++++++++------
UTILS/seis_process/{process_syn.pl => process_syn.pl.in} | 13 ++++++++-----
UTILS/seis_process/{rotate.pl => rotate.pl.in} | 8 +++++---
5 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/UTILS/seis_process/Makefile.am b/UTILS/seis_process/Makefile.am
index 59b81e2..f0e36ae 100644
--- a/UTILS/seis_process/Makefile.am
+++ b/UTILS/seis_process/Makefile.am
@@ -1,5 +1,7 @@
## Process this file with automake to produce Makefile.in
+SUFFIXES = .pl.in .pl
+
bin_PROGRAMS = asc2sac convolve_stf
bin_SCRIPTS = process_data.pl process_syn.pl rotate.pl
@@ -8,3 +10,12 @@ AM_LDFLAGS = -L$(SACAUX)/../lib
asc2sac_SOURCES = asc2sac.c
convolve_stf_SOURCES = convolve_stf.c
+
+
+do_build = sed -e s:[@]sacaux[@]:$(SACAUX):g -e s:[@]prefix[@]:$(prefix):g
+
+.pl.in.pl:
+ $(do_build) $< > $@ || (rm -f $@ && exit 1)
+
+CLEANFILES = $(bin_SCRIPTS)
+EXTRA_DIST = process_data.pl.in process_syn.pl.in rotate.pl.in
diff --git a/UTILS/seis_process/configure.ac b/UTILS/seis_process/configure.ac
index 36a87dc..83dd39e 100644
--- a/UTILS/seis_process/configure.ac
+++ b/UTILS/seis_process/configure.ac
@@ -11,6 +11,9 @@ AC_ARG_VAR(SACAUX, [SAC 'aux' directory])
if test "x$SACAUX" = x; then
AC_MSG_ERROR([environment variable SACAUX is not set])
fi
+if test ! -d "$SACAUX"; then
+ AC_MSG_ERROR([SACAUX (=$SACAUX) does not name a directory])
+fi
# Checks for programs.
AC_PROG_CC
diff --git a/UTILS/seis_process/process_data.pl b/UTILS/seis_process/process_data.pl.in
similarity index 95%
rename from UTILS/seis_process/process_data.pl
rename to UTILS/seis_process/process_data.pl.in
index 8823b1f..f079002 100755
--- a/UTILS/seis_process/process_data.pl
+++ b/UTILS/seis_process/process_data.pl.in
@@ -7,9 +7,9 @@ use POSIX;
sub Usage{
print STDERR <<END;
- process_data_new.pl -m CMTFILE -l Start/End -t Ts/Tl -i -p -x Ext -d OutDir
- -s Sps -P n/p -T Taper_width -c -y t1/v1/...
- data_sac_files
+ process_data.pl -m CMTFILE -l Start/End -t Ts/Tl -i -p -x Ext -d OutDir
+ -s Sps -P n/p -T Taper_width -c -y t1/v1/...
+ data_sac_files
with
-m -- use CMTSOLUTION file to set event info
@@ -43,6 +43,9 @@ END
exit(1);
}
+$sacaux = $ENV{SACAUX} or "@sacaux@";
+unless (-d $sacaux) {die("missing SAC aux directory: '$sacaux'\n");}
+
if (@ARGV == 0) { Usage(); }
if (!getopts('m:l:t:ipx:d:s:P:T:y:c')) {die('Check input arguments\n');}
@@ -60,10 +63,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;}
-$saclst="/opt/seismo-util/source/saclst/saclst";
-$phtimes="/opt/seismo-util/bin/phtimes";
+$saclst="$sacaux/../bin/saclst";
+$phtimes="phtimes";
if (! -e $saclst) {die(" No $saclst file\n");}
-if (! -e $phtimes) {die("No $phtimes file\n");}
+#if (! -e $phtimes) {die("No $phtimes file\n");}
$eps=1e-5; $undef=-12345.0; $cundef="-12345";
diff --git a/UTILS/seis_process/process_syn.pl b/UTILS/seis_process/process_syn.pl.in
similarity index 96%
rename from UTILS/seis_process/process_syn.pl
rename to UTILS/seis_process/process_syn.pl.in
index 3dcf7f0..906e0d9 100755
--- a/UTILS/seis_process/process_syn.pl
+++ b/UTILS/seis_process/process_syn.pl.in
@@ -41,6 +41,9 @@ END
exit(1);
}
+$sacaux = $ENV{SACAUX} or "@sacaux@";
+unless (-d $sacaux) {die("missing SAC aux directory: '$sacaux'\n");}
+
@ARGV > 1 or Usage();
if (!getopts('Sm:ho:l:t:i:pP:a:cd:x:vs:y:A:')) {die(" check input arguments\n");}
@@ -63,11 +66,11 @@ if ($opt_A) {if ($opt_A !~ /^\d/) {die("-A option should be numbers\n");}}
$undef = -12345;
$eps = 0.1;
-$saclst="/opt/seismo-util/source/saclst/saclst";
-$phtimes="/opt/seismo-util/bin/phtimes";
-$asc2sac="/opt/seismo-util/bin/ascii2sac.csh";
+$saclst="$sacaux/../bin/saclst";
+$phtimes="phtimes";
+$asc2sac="@prefix@/bin/ascii2sac.csh";
if (! -e $saclst) {die(" No $saclst file\n");}
-if (! -e $phtimes) {die("No $phtimes file\n");}
+#if (! -e $phtimes) {die("No $phtimes file\n");}
if (! -e $asc2sac) {die("No $asc2sac file\n");}
$min_hdur=1.0;
@@ -116,7 +119,7 @@ foreach $file (@ARGV) {
print SAC "echo on\n r $outfile\n";}
if ($opt_h and $hdur > $min_hdur) { # convolve source time function
- system("/opt/seismo-util/bin/convolve_stf g $hdur $outfile");
+ system("@prefix@/bin/convolve_stf g $hdur $outfile");
system("mv ${outfile}.conv ${outfile}");}
diff --git a/UTILS/seis_process/rotate.pl b/UTILS/seis_process/rotate.pl.in
similarity index 93%
rename from UTILS/seis_process/rotate.pl
rename to UTILS/seis_process/rotate.pl.in
index d73ca6e..601b7a3 100755
--- a/UTILS/seis_process/rotate.pl
+++ b/UTILS/seis_process/rotate.pl.in
@@ -25,11 +25,13 @@ EOF
exit(1)
}
+$sacaux = $ENV{SACAUX} or "@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;}
-$saclst = "saclst";
+$saclst = "$sacaux/../bin/saclst";
if (not -f $saclst) {die("No such file as $saclst\n");}
$undef=-12345.0;
$eps=0.1;
@@ -81,8 +83,8 @@ foreach $file (@ARGV) {
# check if the reference time is the same or not!
- if ($opt_c) {open(SAC,"| sac");}
- else {open(SAC,"| sac > /dev/null");}
+ if ($opt_c) {open(SAC,"|$sacaux/../bin/sac");}
+ else {open(SAC,"|$sacaux/../bin/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