readseis_split.c 2.01 KB
Newer Older
Simone Butzer's avatar
Simone Butzer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/*------------------------------------------------------------------------
 * Copyright (C) 2015 For the list of authors, see file AUTHORS.
 *
 * This file is part of IFOS3D.
 * 
 * IFOS3D is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
 * IFOS3D is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with IFOS3D. See file COPYING and/or 
 * <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
 * reads seismograms from files 
 -----------------------------------------------------------------------------*/


#include "fd.h"

void readseis_split(int ishot, float **section, int ntr,int *rnum_loc, int ns, int comp){
  

    extern FILE *FP;
    extern char  SEIS_OBS_FILE[STRING_SIZE];
    char file_ext[5];
    FILE *fpdata;
    char data[STRING_SIZE];
    int i,j,k;
    
    memset(data, '\0', sizeof(data));    
    
    sprintf(file_ext,"su");

    if(comp==1) sprintf(data,"%s_vx_ext.%s.shot%d",SEIS_OBS_FILE,file_ext,ishot);
42 43
    if(comp==2) sprintf(data,"%s_vy_ext.%s.shot%d",SEIS_OBS_FILE,file_ext,ishot);
    if(comp==3) sprintf(data,"%s_vz_ext.%s.shot%d",SEIS_OBS_FILE,file_ext,ishot);
Simone Butzer's avatar
Simone Butzer committed
44

45
    fprintf(FP,"\n reads %s",data);
Simone Butzer's avatar
Simone Butzer committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    
    if(ntr>0){
    fpdata=fopen(data,"r");
     
    k=1;
    for(i=1;i<=ntr;i++){ 
	fseek(fpdata,240,SEEK_CUR);
	
	if(rnum_loc[i]==1){
		for(j=1;j<=ns;j++){
			section[k][j]=0.0; 
			fread(&section[k][j],sizeof(float),1,fpdata);
		}	
		k++;
	}
	else fseek(fpdata,4*ns,SEEK_CUR); 
    }
    fclose(fpdata);
    }
65
   // fprintf(FP," readseis_split finished\n");  
Simone Butzer's avatar
Simone Butzer committed
66
}