Changeset 3194


Ignore:
Timestamp:
12/16/07 14:18:43 (12 years ago)
Author:
paulf
Message:

fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes.

Location:
trunk/src/seismic_processing/pick_ew
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/seismic_processing/pick_ew/pick_ew.c

    r2820 r3194  
    88 *    Revision history: 
    99 *     $Log$ 
     10 *     Revision 1.14  2007/12/16 19:18:43  paulf 
     11 *     fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes. 
     12 * 
    1013 *     Revision 1.13  2007/03/13 14:42:08  paulf 
    1114 *     fixed another time_t printing 
     
    121124void Interpolate( STATION *, char *, int ); 
    122125int  GetEwh( EWH * ); 
    123 void Sample( long, STATION * ); 
     126void Sample( int, STATION * ); 
    124127 
    125128    
     
    138141   TRACE_HEADER  *TraceHead;       /* Pointer to trace header w/o loc code */ 
    139142   TRACE2_HEADER *Trace2Head;      /* Pointer to header with loc code */ 
    140    long          *TraceLong;       /* Long pointer to waveform data */ 
     143   int          *TraceLong;       /* Long pointer to waveform data */ 
    141144   short         *TraceShort;      /* Short pointer to waveform data */ 
    142145   long          MsgLen;           /* Size of retrieved message */ 
     
    220223/* Allocate the waveform buffer 
    221224   ****************************/ 
    222    InBufl = MAX_TRACEBUF_SIZ*2 + sizeof(long)*(Gparm.MaxGap-1); 
     225   InBufl = MAX_TRACEBUF_SIZ*2 + sizeof(int)*(Gparm.MaxGap-1); 
    223226   TraceBuf = (char *) malloc( (size_t) InBufl ); 
    224227   if ( TraceBuf == NULL ) 
     
    234237   TraceHead  = (TRACE_HEADER *)TraceBuf; 
    235238   Trace2Head = (TRACE2_HEADER *)TraceBuf; 
    236    TraceLong  = (long *) (TraceBuf + sizeof(TRACE_HEADER)); 
     239   TraceLong  = (int *) (TraceBuf + sizeof(TRACE_HEADER)); 
    237240   TraceShort = (short *) (TraceBuf + sizeof(TRACE_HEADER)); 
    238241 
     
    301304      time_t  now;              /* Current time */ 
    302305      double  GapSizeD;         /* Number of missing samples (double) */ 
    303       long    GapSize;          /* Number of missing samples (integer) */ 
     306      int    GapSize;          /* Number of missing samples (integer) */ 
    304307      unsigned char seq;        /* msg sequence number from tport_copyfrom() */ 
    305308 
     
    385388      } 
    386389 
    387 /* If the samples are shorts, make them longs 
     390/* If the samples are shorts, make them longs (actually just int's now since long could be 8 bytes!) 
    388391   ******************************************/ 
    389392      strcpy( type, Trace2Head->datatype ); 
     
    392395      { 
    393396         for ( i = Trace2Head->nsamp - 1; i > -1; i-- ) 
    394             TraceLong[i] = (long)TraceShort[i]; 
     397            TraceLong[i] = (int)TraceShort[i]; 
    395398      } 
    396399 
     
    405408         GapSize = 0; 
    406409      else 
    407          GapSize  = (long) (GapSizeD + 0.5); 
     410         GapSize  = (int) (GapSizeD + 0.5); 
    408411 
    409412/* Interpolate missing samples and prepend them to the current message 
  • trunk/src/seismic_processing/pick_ew/pick_ew.h

    r2711 r3194  
    88 *    Revision history: 
    99 *     $Log$ 
     10 *     Revision 1.6  2007/12/16 19:18:43  paulf 
     11 *     fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes. 
     12 * 
    1013 *     Revision 1.5  2007/02/26 13:59:08  paulf 
    1114 *     no coda changes (option) 
     
    8285   int    MinSmallZC;       /* Minimum number of small zero crossings */ 
    8386   int    MinBigZC;         /* Minimum number of big zero crossings */ 
    84    long   MinPeakSize;      /* Minimum size of 1'st three peaks */ 
     87   int    MinPeakSize;      /* Minimum size of 1'st three peaks */ 
    8588   int    MaxMint;          /* Max interval between zero crossings in samples */ 
    8689   int    MinCodaLen;       /* Mininum coda length in seconds */ 
     
    113116   double ecrit;            /* Criterion level to determine if event is over */ 
    114117   double elta;             /* Long-term average of edat */ 
    115    long   enddata;          /* Last data value of previous message */ 
     118   int    enddata;          /* Last data value of previous message */ 
    116119   double endtime;          /* Stop time of previous message */ 
    117120   double eref;             /* STA/LTA reference level */ 
     
    126129   int    next;             /* Counter of zero crossings early in P-phase */ 
    127130   int    nzero;            /* Big zero-crossing counter */ 
    128    long   old_sample;       /* Old value of integer data */ 
     131   int    old_sample;       /* Old value of integer data */ 
    129132   int    ns_restart;       /* Number of samples since restart */ 
    130133   double rdat;             /* Filtered data value */ 
     
    133136   double rold;             /* Previous value of filtered data */ 
    134137   double rsrdat;           /* Running sum of rdat in coda calculation */ 
    135    long   sarray[10];       /* First 10 points after pick for 1'st motion determ */ 
     138   int    sarray[10];       /* First 10 points after pick for 1'st motion determ */ 
    136139   double tmax;             /* Instantaneous maximum in current half cycle */ 
    137    long   xdot;             /* First difference at pick time */ 
     140   int    xdot;             /* First difference at pick time */ 
    138141   double xfrz;             /* Used in first motion calculation */ 
    139142} STATION; 
  • trunk/src/seismic_processing/pick_ew/pick_ra.c

    r2711 r3194  
    88 *    Revision history: 
    99 *     $Log$ 
     10 *     Revision 1.5  2007/12/16 19:18:43  paulf 
     11 *     fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes. 
     12 * 
    1013 *     Revision 1.4  2007/02/26 13:59:08  paulf 
    1114 *     no coda changes (option) 
     
    3942#include <transport.h> 
    4043#include "pick_ew.h" 
     44#include "sample.h" 
    4145 
    4246/* Function prototypes 
     
    4448void   ReportPick( PICK *, CODA *, STATION *, GPARM *, EWH * ); 
    4549void   ReportCoda( CODA *, GPARM *, EWH * ); 
    46 void   Sample( long, STATION * ); 
    4750int    ScanForEvent( STATION *, GPARM *, char *, int * ); 
    4851int    EventActive( STATION *, char *, GPARM *, EWH *, int * ); 
     
    157160 
    158161   TRACE_HEADER *WaveHead = (TRACE_HEADER *) WaveBuf; 
    159    long         *WaveLong = (long *) (WaveBuf + sizeof(TRACE_HEADER)); 
     162   int         *WaveLong = (int *) (WaveBuf + sizeof(TRACE_HEADER)); 
    160163 
    161164/* An event (pick and/or coda) is active. 
     
    164167   while ( ++(*sample_index) < WaveHead->nsamp ) 
    165168   { 
    166       long new_sample;         /* Current sample */ 
     169      int new_sample;         /* Current sample */ 
    167170 
    168171      new_sample = WaveLong[*sample_index]; 
  • trunk/src/seismic_processing/pick_ew/restart.c

    r11 r3194  
    88 *    Revision history: 
    99 *     $Log$ 
     10 *     Revision 1.2  2007/12/16 19:18:43  paulf 
     11 *     fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes. 
     12 * 
    1013 *     Revision 1.1  2000/02/14 19:06:49  lucky 
    1114 *     Initial revision 
     
    8386   int      nInterp = GapSize - 1; 
    8487   TRACE_HEADER *WaveHead  = (TRACE_HEADER *) WaveBuf; 
    85    long         *WaveLong  = (long *) (WaveBuf + sizeof(TRACE_HEADER)); 
     88   int         *WaveLong  = (int *) (WaveBuf + sizeof(TRACE_HEADER)); 
    8689   double   SampleInterval = 1. / WaveHead->samprate; 
    8790   double   delta = (double)(WaveLong[0] - Sta->enddata) / GapSize; 
     
    9497 
    9598   for ( i = 0; i < nInterp; i++ ) 
    96       WaveLong[i] = (long) (Sta->enddata + (++j * delta) + 0.5); 
     99      WaveLong[i] = (int) (Sta->enddata + (++j * delta) + 0.5); 
    97100 
    98101   WaveHead->nsamp += nInterp; 
  • trunk/src/seismic_processing/pick_ew/sample.c

    r11 r3194  
    88 *    Revision history: 
    99 *     $Log$ 
     10 *     Revision 1.2  2007/12/16 19:18:43  paulf 
     11 *     fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes. 
     12 * 
    1013 *     Revision 1.1  2000/02/14 19:06:49  lucky 
    1114 *     Initial revision 
     
    3437   ******************************************************************/ 
    3538 
    36 void Sample( long LongSample, STATION *Sta ) 
     39void Sample( int LongSample, STATION *Sta ) 
    3740{ 
    3841   PARM *Parm = &Sta->Parm; 
  • trunk/src/seismic_processing/pick_ew/scan.c

    r882 r3194  
    88 *    Revision history: 
    99 *     $Log$ 
     10 *     Revision 1.3  2007/12/16 19:18:43  paulf 
     11 *     fixed an improper use of long for 4 byte sample data, some OS have long as 8bytes. 
     12 * 
    1013 *     Revision 1.2  2002/03/05 17:18:53  dietz 
    1114 *     minor debug logging changes 
     
    3134#include <trace_buf.h> 
    3235#include "pick_ew.h" 
    33  
    34 /* Function prototypes 
    35    *******************/ 
    36 void Sample( long, STATION * ); 
     36#include "sample.h" 
    3737 
    3838 
     
    5252 
    5353   TRACE_HEADER *WaveHead = (TRACE_HEADER *) WaveBuf; 
    54    long         *WaveLong = (long *) (WaveBuf + sizeof(TRACE_HEADER)); 
     54   int         *WaveLong = (int *) (WaveBuf + sizeof(TRACE_HEADER)); 
    5555 
    5656/* Set pick and coda calculations to inactive mode 
     
    6262   while ( ++(*sample_index) < WaveHead->nsamp ) 
    6363   { 
    64       long   old_sample;                  /* Previous sample */ 
    65       long   new_sample;                  /* Current sample */ 
     64      int   old_sample;                  /* Previous sample */ 
     65      int   new_sample;                  /* Current sample */ 
    6666      double old_eref;                    /* Old value of eref */ 
    6767 
Note: See TracChangeset for help on using the changeset viewer.