saveseis.c 5.69 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 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * This file is part of DENISE.
 * 
 * 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.
 * 
 * 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.
 * 
 * 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>.
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   write seismograms to files 
 *   last update 19/01/02, T. Bohlen
 *  ----------------------------------------------------------------------*/

#include "fd.h"

void saveseis(FILE *fp, float **sectionvx, float **sectionvy,float **sectionp,
float **sectioncurl, float **sectiondiv, int  **recpos, int  **recpos_loc, 
int ntr, float ** srcpos, int ishot, int ns, int iter){ 
29 30
    
    extern int VERBOSE;
Tilman Steinweg's avatar
Tilman Steinweg committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
	extern int SEISMO, SEIS_FORMAT, MYID, RUN_MULTIPLE_SHOTS;	
	extern char  SEIS_FILE_VX[STRING_SIZE], SEIS_FILE_VY[STRING_SIZE];
	extern char  SEIS_FILE_CURL[STRING_SIZE], SEIS_FILE_DIV[STRING_SIZE], SEIS_FILE_P[STRING_SIZE];

        char vxf[STRING_SIZE], vyf[STRING_SIZE], curlf[STRING_SIZE], divf[STRING_SIZE], pf[STRING_SIZE];
        int nsrc=1;		
	
	 /*if (RUN_MULTIPLE_SHOTS){*/
                sprintf(vxf,"%s.shot%d.%d",SEIS_FILE_VX,ishot,MYID);
                sprintf(vyf,"%s.shot%d.%d",SEIS_FILE_VY,ishot,MYID);
                sprintf(curlf,"%s.shot%d.%d",SEIS_FILE_CURL,ishot,MYID);
                sprintf(divf,"%s.shot%d.%d",SEIS_FILE_DIV,ishot,MYID);
                sprintf(pf,"%s.shot%d.%d",SEIS_FILE_P,ishot,MYID);
        /*}
        else{
                sprintf(vxf,"%s.%d",SEIS_FILE_VX,MYID);
                sprintf(vyf,"%s.%d",SEIS_FILE_VY,MYID);
                sprintf(curlf,"%s.%d",SEIS_FILE_CURL,MYID);
                sprintf(divf,"%s.%d",SEIS_FILE_DIV,MYID);
                sprintf(pf,"%s.%d",SEIS_FILE_P,MYID);
                 
        }*/

	
	if(iter>0){
	sprintf(vxf,"%s.shot%d_it%d.%d",SEIS_FILE_VX,ishot,iter,MYID);
	sprintf(vyf,"%s.shot%d_it%d.%d",SEIS_FILE_VY,ishot,iter,MYID);
	sprintf(pf,"%s.shot%d_it%d.%d",SEIS_FILE_P,ishot,iter,MYID);
	}
	
	if(iter==-1){
	sprintf(vxf,"%s.shot%d_it%d.%d",SEIS_FILE_VX,ishot,iter,MYID);
	sprintf(vyf,"%s.shot%d_it%d.%d",SEIS_FILE_VY,ishot,iter,MYID);
	sprintf(pf,"%s.shot%d_it%d.%d",SEIS_FILE_P,ishot,iter,MYID);
	}
	
	
	switch (SEISMO){
	case 1 : /* particle velocities only */
70
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms (vx) to\n\t %s \n",MYID,ntr,vxf);
Tilman Steinweg's avatar
Tilman Steinweg committed
71
		outseis(fp,fopen(vxf,"w"),1,sectionvx,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
72
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms (vy) to\n\t %s \n",MYID,ntr,vyf);
Tilman Steinweg's avatar
Tilman Steinweg committed
73 74 75 76
		outseis(fp,fopen(vyf,"w"),2,sectionvy,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
		break;
		
	case 2 : /* pressure only */
77
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of pressure to\n\t %s \n",MYID,ntr,SEIS_FILE_P);
Tilman Steinweg's avatar
Tilman Steinweg committed
78 79 80 81
		outseis(fp,fopen(pf,"w"), 0, sectionp,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
		break;
		
	case 3 : /* curl and div only */
82
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of divergence to\n\t %s \n",MYID,ntr,SEIS_FILE_DIV);
Tilman Steinweg's avatar
Tilman Steinweg committed
83
		outseis(fp,fopen(divf,"w"), 0, sectiondiv,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
84
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of curl to\n\t %s \n",MYID,ntr,SEIS_FILE_CURL);
Tilman Steinweg's avatar
Tilman Steinweg committed
85 86 87 88
		outseis(fp,fopen(curlf,"w"), 0, sectioncurl,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
		break;
		
	case 4 : /* everything */
89
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms (vx) to\n\t %s \n",MYID,ntr,SEIS_FILE_VX);
Tilman Steinweg's avatar
Tilman Steinweg committed
90
		outseis(fp,fopen(vxf,"w"),1,sectionvx,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
91
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms (vy) to\n\t %s \n",MYID,ntr,SEIS_FILE_VY);
Tilman Steinweg's avatar
Tilman Steinweg committed
92 93
		outseis(fp,fopen(vyf,"w"),2,sectionvy,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
		
94
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of pressure to\n\t %s \n",MYID,ntr,SEIS_FILE_P);
Tilman Steinweg's avatar
Tilman Steinweg committed
95 96
		outseis(fp,fopen(pf,"w"), 0, sectionp,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);

97
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of divergence to\n\t %s \n",MYID,ntr,SEIS_FILE_DIV);
Tilman Steinweg's avatar
Tilman Steinweg committed
98
		outseis(fp,fopen(divf,"w"),0, sectiondiv,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
99
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of curl to\n\t %s \n",MYID,ntr,SEIS_FILE_CURL);
Tilman Steinweg's avatar
Tilman Steinweg committed
100 101 102 103
		outseis(fp,fopen(curlf,"w"),0, sectioncurl,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);	
		break;
		
	case 5 : /* everything except curl and div */
104
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms (vx) to\n\t %s \n",MYID,ntr,SEIS_FILE_VX);
Tilman Steinweg's avatar
Tilman Steinweg committed
105
		outseis(fp,fopen(vxf,"w"),1,sectionvx,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
106
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms (vy) to\n\t %s \n",MYID,ntr,SEIS_FILE_VY);
Tilman Steinweg's avatar
Tilman Steinweg committed
107 108
		outseis(fp,fopen(vyf,"w"),2,sectionvy,recpos,recpos_loc, ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
		
109
		if(VERBOSE) fprintf(fp," PE %d is writing %d seismograms of pressure to\n\t %s \n",MYID,ntr,SEIS_FILE_P);
Tilman Steinweg's avatar
Tilman Steinweg committed
110 111 112 113 114
		outseis(fp,fopen(pf,"w"), 0, sectionp,recpos,recpos_loc,ntr,srcpos,nsrc,ns,SEIS_FORMAT,ishot,1);
		break;
		
      }     
}