inseis.c 2.6 KB
Newer Older
tilman.metz's avatar
tilman.metz committed
1
/*-----------------------------------------------------------------------------------------
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
tilman.metz's avatar
tilman.metz committed
3
 *
Florian Wittkamp's avatar
Florian Wittkamp committed
4
 * This file is part of IFOS.
tilman.metz's avatar
tilman.metz committed
5
 * 
Florian Wittkamp's avatar
Florian Wittkamp committed
6
 * IFOS is free software: you can redistribute it and/or modify
tilman.metz's avatar
tilman.metz committed
7 8 9
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
Florian Wittkamp's avatar
Florian Wittkamp committed
10
 * IFOS is distributed in the hope that it will be useful,
tilman.metz's avatar
tilman.metz committed
11 12 13 14 15
 * 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
Florian Wittkamp's avatar
Florian Wittkamp committed
16
 * along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
tilman.metz's avatar
tilman.metz committed
17 18 19 20 21 22 23 24 25 26 27 28
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   Write seismograms to disk                                  
 *  ----------------------------------------------------------------------*/
#include "fd.h"
#include "segy.h"

void  inseis(FILE *fp, int comp, float **section, int ntr, int ns, int sws, int iter){

	/* declaration of extern variables */
	extern int NDT, MYID;
29
    extern char DATA_DIR[STRING_SIZE];
tilman.metz's avatar
tilman.metz committed
30 31 32 33 34
	extern float  TIME, DH, DT, REFREC[4];
        char data[STRING_SIZE];
        FILE *fpdata;
	
	if(sws==1){  /* open seismic data vx */
35
		sprintf(data,"%s_vx.su.shot%d",DATA_DIR,comp);
tilman.metz's avatar
tilman.metz committed
36 37 38
	}
	
	if(sws==2){  /* open seismic data vy */
39
		sprintf(data,"%s_vy.su.shot%d",DATA_DIR,comp);
tilman.metz's avatar
tilman.metz committed
40 41
	}
	
42 43
    /* sws 3 -- 6 not used */
    
tilman.metz's avatar
tilman.metz committed
44
	if(sws==7){  /* open convolved seismic data vx */
45
		sprintf(data,"%s_vx.su.conv.shot%d",DATA_DIR,comp);
tilman.metz's avatar
tilman.metz committed
46 47 48
	}
	
	if(sws==8){  /* open convolved seismic data vy */
49
		sprintf(data,"%s_vy.su.conv.shot%d",DATA_DIR,comp);
tilman.metz's avatar
tilman.metz committed
50 51 52 53 54
	}
	
	if(sws==9){  /* open seismic data p */
		sprintf(data,"%s_p.su.shot%d",DATA_DIR,comp);
	}
55 56
    
    if(sws==10){  /* open seismic data vz */
57
        sprintf(data,"%s_vz.su.shot%d",DATA_DIR,comp);
58
    }
tilman.metz's avatar
tilman.metz committed
59
	
60

tilman.metz's avatar
tilman.metz committed
61
	fpdata = fopen(data,"r");
62 63
    if (fpdata==NULL) {
        if(MYID==0) printf(" Was not able to read %s",data);
64
        declare_error(" Seismograms for inversion were not found ");
65
    }
tilman.metz's avatar
tilman.metz committed
66 67

	/* declaration of local variables */
68
	int j;
tilman.metz's avatar
tilman.metz committed
69 70
	segy tr;
	int tracl1 ;
71
	float dump;
tilman.metz's avatar
tilman.metz committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

		for(tracl1=1;tracl1<=ntr;tracl1++){        /* SEGY (without file-header) */
                        
			fread(&tr,240,1,fpdata);
			fread(&tr.data,4,ns,fpdata);
			
			section[tracl1][1]=0.0;
			
			  
			for(j=1;j<=ns;j++){
				dump=tr.data[j];
				section[tracl1][j+1]=dump;
			}
		}
	fclose(fpdata);
}