saveseis_glob.c 7.67 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
4
 *
 * This file is part of DENISE.
5
 *
Tilman Steinweg's avatar
Tilman Steinweg committed
6
7
8
 * DENISE 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.
9
 *
Tilman Steinweg's avatar
Tilman Steinweg committed
10
11
12
13
 * DENISE 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.
14
 *
Tilman Steinweg's avatar
Tilman Steinweg committed
15
16
 * You should have received a copy of the GNU General Public License
 * along with DENISE. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
17
 -----------------------------------------------------------------------------------------*/
Tilman Steinweg's avatar
Tilman Steinweg committed
18
19

/*------------------------------------------------------------------------
20
 *   write seismograms to files
21
 *   last update Oct 2015 F.Wittkamp
Tilman Steinweg's avatar
Tilman Steinweg committed
22
23
24
25
 *  ----------------------------------------------------------------------*/

#include "fd.h"

Florian Wittkamp's avatar
Florian Wittkamp committed
26
27
28
29
30
31
32
void saveseis_glob(FILE *fp, float **sectionvx, float **sectionvy,float **sectionvz,float **sectionp,float **sectioncurl, float **sectiondiv, int  **recpos, int  **recpos_loc,int ntr, float ** srcpos, int ishot, int ns, int iter, int type_switch){
    
     /* type_switch:
     *  1== synthetic data
     *  2== measured - synthetic data (residuals)
     *  3== filtered measured data
     */
33
34
    
    extern int SEISMO, SEIS_FORMAT, RUN_MULTIPLE_SHOTS, WAVETYPE, VERBOSE;
Florian Wittkamp's avatar
Florian Wittkamp committed
35
36
    extern char SEIS_FILE_VX[STRING_SIZE], SEIS_FILE_VY[STRING_SIZE], SEIS_FILE_VZ[STRING_SIZE];
    extern char SEIS_FILE_CURL[STRING_SIZE], SEIS_FILE_DIV[STRING_SIZE], SEIS_FILE_P[STRING_SIZE];
37
38
39
    
    char vxf[STRING_SIZE], vyf[STRING_SIZE],vzf[STRING_SIZE], curlf[STRING_SIZE], divf[STRING_SIZE], pf[STRING_SIZE];
    int nsrc=1;
40
    
Florian Wittkamp's avatar
Florian Wittkamp committed
41
    if(type_switch==1){
42
43
44
45
46
47
48
49
50
51
        sprintf(vxf,"%s.shot%d.it%d",SEIS_FILE_VX,ishot,iter);
        sprintf(vyf,"%s.shot%d.it%d",SEIS_FILE_VY,ishot,iter);
        if(WAVETYPE==2 || WAVETYPE==3) {
            sprintf(vzf,"%s.shot%d.it%d",SEIS_FILE_VZ,ishot,iter);
        }
        sprintf(pf,"%s.shot%d.it%d",SEIS_FILE_P,ishot,iter);
        sprintf(divf,"%s.shot%d.it%d",SEIS_FILE_DIV,ishot,iter);
        sprintf(curlf,"%s.shot%d.it%d",SEIS_FILE_CURL,ishot,iter);
    }
    
Florian Wittkamp's avatar
Florian Wittkamp committed
52
    if(type_switch==2){
53
54
55
56
57
58
59
60
61
62
        sprintf(vxf,"%s.shot%d_adjoint_src",SEIS_FILE_VX,ishot);
        sprintf(vyf,"%s.shot%d_adjoint_src",SEIS_FILE_VY,ishot);
        if(WAVETYPE==2 || WAVETYPE==3) {
            sprintf(vzf,"%s.shot%d_adjoint_src",SEIS_FILE_VZ,ishot);
        }
        sprintf(pf,"%s.shot%d_adjoint_src",SEIS_FILE_P,ishot);
        sprintf(divf,"%s.shot%d_adjoint_src",SEIS_FILE_DIV,ishot);
        sprintf(curlf,"%s.shot%d_adjoint_src",SEIS_FILE_CURL,ishot);
    }
    
Florian Wittkamp's avatar
Florian Wittkamp committed
63
    if(type_switch==3){
64
65
66
67
68
69
70
71
72
        sprintf(vxf,"%s_measured.shot%d.it%d",SEIS_FILE_VX,ishot,iter);
        sprintf(vyf,"%s_measured.shot%d.it%d",SEIS_FILE_VY,ishot,iter);
        if(WAVETYPE==2 || WAVETYPE==3) {
            sprintf(vzf,"%s_measured.shot%d.it%d",SEIS_FILE_VZ,ishot,iter);
        }
        sprintf(pf,"%s_measured.shot%d.it%d",SEIS_FILE_P,ishot,iter);
        sprintf(divf,"%s_measured.shot%d.it%d",SEIS_FILE_DIV,ishot,iter);
        sprintf(curlf,"%s_measured.shot%d.it%d",SEIS_FILE_CURL,ishot,iter);
    }
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    
    switch (SEISMO){
        case 1 : /* particle velocities only */
            if (WAVETYPE==1 || WAVETYPE==3) {
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vx) to\n\t %s \n",0,ntr,vxf);
                outseis_glob(fp,fopen(vxf,"w"),1,sectionvx,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vy) to\n\t %s \n",0,ntr,vyf);
                outseis_glob(fp,fopen(vyf,"w"),2,sectionvy,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            }
            if(WAVETYPE==2 || WAVETYPE==3) {
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vz) to\n\t %s \n",0,ntr,vzf);
                outseis_glob(fp,fopen(vzf,"w"),2,sectionvz,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            }
            break;
            
        case 2 : /* pressure only */
            if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of pressure to\n\t %s \n",0,ntr,pf);
            outseis_glob(fp,fopen(pf,"w"), 0, sectionp,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            break;
            
        case 3 : /* curl and div only */
            if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of divergence to\n\t %s \n",0,ntr,divf);
            outseis_glob(fp,fopen(divf,"w"), 0, sectiondiv,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of curl to\n\t %s \n",0,ntr,curlf);
            outseis_glob(fp,fopen(curlf,"w"), 0, sectioncurl,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            break;
            
        case 4 : /* everything */
            if (WAVETYPE==1 || WAVETYPE==3) {
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vx) to\n\t %s \n",0,ntr,vxf);
                outseis_glob(fp,fopen(vxf,"w"),1,sectionvx,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vy) to\n\t %s \n",0,ntr,vyf);
                outseis_glob(fp,fopen(vyf,"w"),2,sectionvy,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of pressure to\n\t %s \n",0,ntr,pf);
                outseis_glob(fp,fopen(pf,"w"), 0, sectionp,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of divergence to\n\t %s \n",0,ntr,divf);
                outseis_glob(fp,fopen(divf,"w"),0, sectiondiv,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of curl to\n\t %s \n",0,ntr,curlf);
                outseis_glob(fp,fopen(curlf,"w"),0, sectioncurl,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            }
            if(WAVETYPE==2 || WAVETYPE==3) {
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vz) to\n\t %s \n",0,ntr,vzf);
                outseis_glob(fp,fopen(vzf,"w"),2,sectionvz,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            }
            break;
            
        case 5 : /* everything except curl and div */
            if (WAVETYPE==1 || WAVETYPE==3) {
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vx) to\n\t %s \n",0,ntr,vxf);
                outseis_glob(fp,fopen(vxf,"w"),1,sectionvx,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vy) to\n\t %s \n",0,ntr,vyf);
                outseis_glob(fp,fopen(vyf,"w"),2,sectionvy,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms of pressure to\n\t %s \n",0,ntr,pf);
                outseis_glob(fp,fopen(pf,"w"), 0, sectionp,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            }
            if(WAVETYPE==2 || WAVETYPE==3) {
                if(VERBOSE==1) fprintf(fp," PE %d is writing %d seismograms (vz) to\n\t %s \n",0,ntr,vzf);
                outseis_glob(fp,fopen(vzf,"w"),2,sectionvz,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
            }
            break;
            
135
    }
Tilman Steinweg's avatar
Tilman Steinweg committed
136
}