inseis.c 2.6 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
/*-----------------------------------------------------------------------------------------
Florian Wittkamp's avatar
Florian Wittkamp committed
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
Tilman Steinweg's avatar
Tilman Steinweg committed
3
 *
Florian Wittkamp's avatar
Florian Wittkamp committed
4
 * This file is part of IFOS.
Tilman Steinweg's avatar
Tilman Steinweg committed
5
 * 
Florian Wittkamp's avatar
Florian Wittkamp committed
6
 * IFOS is free software: you can redistribute it and/or modify
Tilman Steinweg's avatar
Tilman Steinweg 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 Steinweg's avatar
Tilman Steinweg 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 Steinweg's avatar
Tilman Steinweg 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 Steinweg's avatar
Tilman Steinweg 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 */
Florian Wittkamp's avatar
Florian Wittkamp committed
35
		sprintf(data,"%s_vx.su.shot%d",DATA_DIR,comp);
Tilman Steinweg's avatar
Tilman Steinweg committed
36 37 38
	}
	
	if(sws==2){  /* open seismic data vy */
Florian Wittkamp's avatar
Florian Wittkamp committed
39
		sprintf(data,"%s_vy.su.shot%d",DATA_DIR,comp);
Tilman Steinweg's avatar
Tilman Steinweg committed
40 41
	}
	
42 43
    /* sws 3 -- 6 not used */
    
Tilman Steinweg's avatar
Tilman Steinweg committed
44
	if(sws==7){  /* open convolved seismic data vx */
Florian Wittkamp's avatar
Florian Wittkamp committed
45
		sprintf(data,"%s_vx.su.conv.shot%d",DATA_DIR,comp);
Tilman Steinweg's avatar
Tilman Steinweg committed
46 47 48
	}
	
	if(sws==8){  /* open convolved seismic data vy */
Florian Wittkamp's avatar
Florian Wittkamp committed
49
		sprintf(data,"%s_vy.su.conv.shot%d",DATA_DIR,comp);
Tilman Steinweg's avatar
Tilman Steinweg 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 */
Florian Wittkamp's avatar
Florian Wittkamp committed
57
        sprintf(data,"%s_vz.su.shot%d",DATA_DIR,comp);
58
    }
Tilman Steinweg's avatar
Tilman Steinweg committed
59
	
60

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

	/* declaration of local variables */
Florian Wittkamp's avatar
Florian Wittkamp committed
68
	int j;
Tilman Steinweg's avatar
Tilman Steinweg committed
69 70
	segy tr;
	int tracl1 ;
Florian Wittkamp's avatar
Florian Wittkamp committed
71
	float dump;
Tilman Steinweg's avatar
Tilman Steinweg 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);
}