[cig-commits] r14897 - seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process
tan2 at geodynamics.org
tan2 at geodynamics.org
Wed May 6 13:15:31 PDT 2009
Author: tan2
Date: 2009-05-06 13:15:31 -0700 (Wed, 06 May 2009)
New Revision: 14897
Modified:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/convolve_stf.c
Log:
Using long int instead of int to be compatible with SAC. Scaling the result.
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/convolve_stf.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/convolve_stf.c 2009-05-06 20:01:40 UTC (rev 14896)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/convolve_stf.c 2009-05-06 20:15:31 UTC (rev 14897)
@@ -29,26 +29,26 @@
/* defined in libsac */
-void fft(float *xreal, float *ximag, int n, int idir);
+void fft(float *xreal, float *ximag, long int n, long int idir);
-static void fzero(float *dst, int n) {
+static void fzero(float *dst, long int n) {
while (n)
dst[--n] = 0.0;
}
-static void fcpy(float *dst, const float *src, int n) {
+static void fcpy(float *dst, const float *src, long int n) {
while (n) {
--n;
dst[n] = src[n];
}
}
-void convolve(float **pconv, int *pnconv,
- const float *data, int ndata,
- const float *stf, int nstf)
+void convolve(float **pconv, long int *pnconv,
+ const float *data, long int ndata,
+ const float *stf, long int nstf)
{
- int nconv, ncorr, i;
+ long int nconv, ncorr, i;
struct { float *xreal, *ximag; } cdata, cstf, ccorr;
float *conv, *buffer;
@@ -105,19 +105,17 @@
int errno, j, datasize, len_fn;
const int min_nhdur = 10;
-
if(argc < 4) {
fprintf(stderr,
"Usage: %s g[|t] HDUR FILE...\n"
- " This program convolves SAC files with gaussian(|triangle)\n"
+ " This program convolves SAC files with a gaussian(|triangle)\n"
" source time function of given half duration\n",
argv[0]);
return -1;
}
if(strcmp(argv[1], "t") != 0 && strcmp(argv[1], "g") != 0) {
- fprintf(stderr,"Usage: convolve_stf g[/t] hdur sacfiles\n");
- fprintf(stderr," The source time function type could only be triangle(t) or gaussian(g) \n");
+ fprintf(stderr,"The source time function type could only be triangle(t) or gaussian(g) \n");
return -1;
}
cstf = argv[1][0];
@@ -141,9 +139,9 @@
datasize = 0;
data = NULL;
for (j=3; j<argc; j++) {
- int max, npts, nlen, nerr;
- float beg, del, dt, origin, tmp[1];
- int nstf, nconv, i;
+ long int max, npts, nlen, nerr;
+ float beg, del, dt, origin, scale, tmp[1];
+ long int nstf, nconv, i;
float hstf, *stf, *conv;
@@ -182,6 +180,7 @@
/* get additional info */
getfhv("delta", &dt, &nerr, strlen("delta"));
getfhv("o", &origin, &nerr, strlen("o"));
+ getfhv("scale", &scale, &nerr, strlen("scale"));
if(nerr) {
fprintf(stderr,"No origin time is defined for the sac file\n");
return -1;
@@ -222,7 +221,7 @@
/* creat convolution time series */
convolve(&conv,&nconv,data,npts,stf,nstf);
for(i=0; i<nconv; i++)
- conv[i] *= dt;
+ conv[i] *= dt * scale;
/* update sac file header */
More information about the CIG-COMMITS
mailing list