[cig-commits] [commit] pluggable: 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: (d7a8c07)

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


Repository : ssh://geoshell/specfem3d_globe

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

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

commit d7a8c07e9a704cb075bafe20e6f452531459020e
Author: Leif Strand <leif at geodynamics.org>
Date:   Wed May 6 22:56:27 2009 +0000

    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.


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

d7a8c07e9a704cb075bafe20e6f452531459020e
 UTILS/seis_process/asc2sac.c      |  7 ++++---
 UTILS/seis_process/configure.ac   | 17 +++++++++++++++++
 UTILS/seis_process/convolve_stf.c | 23 ++++++++++++-----------
 3 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/UTILS/seis_process/asc2sac.c b/UTILS/seis_process/asc2sac.c
index b55b4b3..46d1532 100644
--- a/UTILS/seis_process/asc2sac.c
+++ b/UTILS/seis_process/asc2sac.c
@@ -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 @@ void asc2sac(char *ascfn) {
         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);
diff --git a/UTILS/seis_process/configure.ac b/UTILS/seis_process/configure.ac
index 83dd39e..4d10f2a 100644
--- a/UTILS/seis_process/configure.ac
+++ b/UTILS/seis_process/configure.ac
@@ -42,6 +42,23 @@ AC_FUNC_MALLOC
 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
 
diff --git a/UTILS/seis_process/convolve_stf.c b/UTILS/seis_process/convolve_stf.c
index 225a27e..5fb39fb 100644
--- a/UTILS/seis_process/convolve_stf.c
+++ b/UTILS/seis_process/convolve_stf.c
@@ -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 @@ main(int argc, char *argv[])
 {
     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 @@ main(int argc, char *argv[])
     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