readseis.c 2.33 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
/*------------------------------------------------------------------------
 * 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(int ishot, float **section, float **sectionf, int ntr, int ns, int comp){
  

    extern FILE *FP;
31
    extern int MYID, RUN_MULTIPLE_SHOTS;
Simone Butzer's avatar
Simone Butzer committed
32 33 34 35 36 37 38
    extern char  SEIS_OBS_FILE[STRING_SIZE];
    char file_ext[5];
    FILE *fpdata;
    char data[STRING_SIZE];
    int i,j;
    
    memset(data, '\0', sizeof(data));    
39
    //fprintf(FP,"comp=%i",comp);
Simone Butzer's avatar
Simone Butzer committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53
    
    sprintf(file_ext,"su");

    if (RUN_MULTIPLE_SHOTS){
		if(comp==1){sprintf(data,"%s_vx_it1.%s.shot%d.%d",SEIS_OBS_FILE,file_ext,ishot,MYID);}
		if(comp==2){sprintf(data,"%s_vy_it1.%s.shot%d.%d",SEIS_OBS_FILE,file_ext,ishot,MYID);}
		if(comp==3){sprintf(data,"%s_vz_it1.%s.shot%d.%d",SEIS_OBS_FILE,file_ext,ishot,MYID);}
	}
    else{
	      
		if(comp==1){sprintf(data,"%s_vx.%s.shot%d.%d",SEIS_OBS_FILE,file_ext,ishot,MYID);}
		if(comp==2){sprintf(data,"%s_vy.%s.shot%d.%d",SEIS_OBS_FILE,file_ext,ishot,MYID);}
		if(comp==3){sprintf(data,"%s_vz.%s.shot%d.%d",SEIS_OBS_FILE,file_ext,ishot,MYID);}
	}
54
    fprintf(FP,"\n reads %s",data);
Simone Butzer's avatar
Simone Butzer committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
    
    if(ntr>0){
    fpdata=fopen(data,"r");
     
    for(i=1;i<=ntr;i++){
    
	fseek(fpdata,240,SEEK_CUR);
	
    	for(j=1;j<=ns;j++){
	  section[i][j]=0.0; 
	  fread(&section[i][j],sizeof(float),1,fpdata); }
    }
    
    fclose(fpdata);
    }
70
    //fprintf(FP," readseis finished\n");
Simone Butzer's avatar
Simone Butzer committed
71 72 73

  
}