[cig-commits] r14907 - seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process

leif at geodynamics.org leif at geodynamics.org
Wed May 6 15:56:28 PDT 2009


Author: leif
Date: 2009-05-06 15:56:27 -0700 (Wed, 06 May 2009)
New Revision: 14907

Modified:
   seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c
   seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/configure.ac
   seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/convolve_stf.c
Log:
Added a configure test to check whether SAC uses 'int' instead of
'long' in function prototypes.  The current v101.3 (and later?) uses
'int'.  This was probably the most recent change listed in CHANGES:

2009/03/23 Brian Savage <savage at uri.edu>
        * 32bit to 64 bit Conversion

I'm guessing that, when sizeof(long) != sizeof(int) (like on Pangu
64-bit), the old "long" protos have compatibility problems with
Fortran code.


Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c	2009-05-06 22:47:23 UTC (rev 14906)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c	2009-05-06 22:56:27 UTC (rev 14907)
@@ -25,10 +25,11 @@
 #include <limits.h>
 #include <errno.h>
 #include "sacio.h"
+#include "config.h"
 
+
 void asc2sac(char *ascfn) {
-    long int npts, max_npts, nerr, nconv, len;
-    long int itmp;
+    sac_int_t npts, max_npts, nerr, nconv, itmp;
     float ftmp;
     char *sacfn;
     float *time, *data, a, b;
@@ -69,7 +70,7 @@
         data[npts] = b;
     }
     if (nconv != EOF || ferror(f)) {
-        fprintf(stderr, "error while reading file '%s' (on or near line %d)\n", ascfn, npts);
+        fprintf(stderr, "error while reading file '%s' (on or near line %ld)\n", ascfn, (long)npts);
 	exit(1);
     }
     fclose(f);

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/configure.ac
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/configure.ac	2009-05-06 22:47:23 UTC (rev 14906)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/configure.ac	2009-05-06 22:56:27 UTC (rev 14907)
@@ -42,6 +42,23 @@
 AC_FUNC_STRTOD
 AC_CHECK_FUNCS([sqrt strtol])
 
+# Check whether SAC uses 'int' instead of 'long' in function prototypes.
+# (the current v101.3 -- and later? -- uses 'int').
+AC_MSG_CHECKING([whether SAC prototypes use 'int' instead of 'long'])
+AC_LANG_WERROR
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include "sacio.h"
+]], [[
+    int nerr;
+    getfhv(0,0,&nerr,0);
+]])], [
+    AC_MSG_RESULT(yes)
+    AC_DEFINE([sac_int_t], [int], [SAC integer type.])
+], [
+    AC_MSG_RESULT(no)
+    AC_DEFINE([sac_int_t], [long], [SAC integer type.])
+])
+
 LDFLAGS=$save_LDFLAGS
 CPPFLAGS=$save_CPPFLAGS
 

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 22:47:23 UTC (rev 14906)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/convolve_stf.c	2009-05-06 22:56:27 UTC (rev 14907)
@@ -24,31 +24,31 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <math.h>
-#include "sac.h"
 #include "sacio.h"
+#include "config.h"
 
 
 /* defined in libsac */
-void fft(float *xreal, float *ximag, long int n, long int idir);
+void fft(float *xreal, float *ximag, sac_int_t n, sac_int_t idir);
 
 
-static void fzero(float *dst, long int n) {
+static void fzero(float *dst, sac_int_t n) {
     while (n)
         dst[--n] = 0.0;
 }
 
-static void fcpy(float *dst, const float *src, long int n) {
+static void fcpy(float *dst, const float *src, sac_int_t n) {
     while (n) {
         --n;
         dst[n] = src[n];
     }
 }
 
-void convolve(float **pconv, long int *pnconv,
-              const float *data, long int ndata,
-              const float *stf,  long int nstf)
+void convolve(float **pconv, sac_int_t *pnconv,
+              const float *data, sac_int_t ndata,
+              const float *stf,  sac_int_t nstf)
 {
-    long int nconv, ncorr, i;
+    sac_int_t nconv, ncorr, i;
     struct { float *xreal, *ximag; } cdata, cstf, ccorr;
     float *conv, *buffer;
     
@@ -102,7 +102,8 @@
 {
     char cstf, *endpt, *outf;
     float hdur, *data;
-    int errno, j, datasize, len_fn;
+    int j, len_fn;
+    sac_int_t datasize;
     const int min_nhdur = 10;
 
     if(argc < 4) {
@@ -139,9 +140,9 @@
     datasize = 0;
     data = NULL;
     for (j=3; j<argc; j++) {
-        long int max, npts, nlen, nerr;
+        sac_int_t max, npts, nlen, nerr;
         float beg, del, dt, origin, scale, tmp[1];
-        long int nstf, nconv, i;
+        sac_int_t nstf, nconv, i;
         float hstf, *stf, *conv;
 
 



More information about the CIG-COMMITS mailing list