Commit f6697382 authored by Florian Wittkamp's avatar Florian Wittkamp
Browse files

Taper: Check if EOF is reached

Changed output of L2 to STDOUT if WAVETYPE != 3
parent 0d135133
...@@ -2802,7 +2802,7 @@ int main(int argc, char **argv){ ...@@ -2802,7 +2802,7 @@ int main(int argc, char **argv){
energy_sum_all_shots = 0.0; energy_sum_all_shots = 0.0;
MPI_Allreduce(&energy_all_shots,&energy_sum_all_shots,1,MPI_FLOAT,MPI_SUM,MPI_COMM_WORLD); MPI_Allreduce(&energy_all_shots,&energy_sum_all_shots,1,MPI_FLOAT,MPI_SUM,MPI_COMM_WORLD);
if(MYID==0) printf("\n\n PSV: L2=%f",L2sum_all_shots/energy_sum_all_shots); if(MYID==0&&(WAVETYPE==3)) printf("\n\n PSV: L2=%f",L2sum_all_shots/energy_sum_all_shots);
} }
if(WAVETYPE==2||WAVETYPE==3){ if(WAVETYPE==2||WAVETYPE==3){
L2sum_SH = 0.0; L2sum_SH = 0.0;
...@@ -2814,7 +2814,7 @@ int main(int argc, char **argv){ ...@@ -2814,7 +2814,7 @@ int main(int argc, char **argv){
energy_sum_all_shots_SH = 0.0; energy_sum_all_shots_SH = 0.0;
MPI_Allreduce(&energy_all_shots_SH,&energy_sum_all_shots_SH,1,MPI_FLOAT,MPI_SUM,MPI_COMM_WORLD); MPI_Allreduce(&energy_all_shots_SH,&energy_sum_all_shots_SH,1,MPI_FLOAT,MPI_SUM,MPI_COMM_WORLD);
if(MYID==0) printf("\n\n SH: L2=%f",L2sum_all_shots_SH/energy_sum_all_shots_SH); if(MYID==0&&(WAVETYPE==3)) printf("\n SH: L2=%f",L2sum_all_shots_SH/energy_sum_all_shots_SH);
} }
sum_killed_traces=0; sum_killed_traces=0;
MPI_Allreduce(&killed_traces,&sum_killed_traces,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); MPI_Allreduce(&killed_traces,&sum_killed_traces,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
...@@ -2835,7 +2835,7 @@ int main(int argc, char **argv){ ...@@ -2835,7 +2835,7 @@ int main(int argc, char **argv){
L2t[1]+=L2sum_SH/energy_sum_SH; L2t[1]+=L2sum_SH/energy_sum_SH;
L2t[4]+=L2sum_all_shots_SH/energy_sum_all_shots_SH; L2t[4]+=L2sum_all_shots_SH/energy_sum_all_shots_SH;
} }
if(MYID==0) printf("\n\n Sum: L2=%f",L2t[4]); if(MYID==0&&(WAVETYPE==3)) printf("\n Sum: L2=%f",L2t[4]);
break; break;
case 7: case 7:
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
* Copyright (C) 2016 For the list of authors, see file AUTHORS. * Copyright (C) 2016 For the list of authors, see file AUTHORS.
* *
* This file is part of DENISE. * This file is part of DENISE.
* *
* DENISE is free software: you can redistribute it and/or modify * DENISE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only. * the Free Software Foundation, version 2.0 of the License only.
* *
* DENISE is distributed in the hope that it will be useful, * DENISE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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>. * along with DENISE. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------*/
/* /*
* taper gradient with a gaussian frame to damp inversion artefacts near the sources and receivers * taper gradient with a gaussian frame to damp inversion artefacts near the sources and receivers
...@@ -28,574 +28,582 @@ ...@@ -28,574 +28,582 @@
void taper_grad(float ** waveconv,float ** taper_coeff, float **srcpos, int nshots, int **recpos, int ntr, int sws) void taper_grad(float ** waveconv,float ** taper_coeff, float **srcpos, int nshots, int **recpos, int ntr, int sws)
{ {
/* extern variables */ /* extern variables */
extern float DH; extern float DH;
extern int FREE_SURF, NX, NY, NXG, NYG; extern int FREE_SURF, NX, NY, NXG, NYG;
extern int NPROCX, NPROCY, MYID, POS[3]; extern int NPROCX, NPROCY, MYID, POS[3];
extern FILE *FP; extern FILE *FP;
extern char TAPER_FILE_NAME[STRING_SIZE], TAPER_FILE_NAME_U[STRING_SIZE], TAPER_FILE_NAME_RHO[STRING_SIZE]; extern char TAPER_FILE_NAME[STRING_SIZE], TAPER_FILE_NAME_U[STRING_SIZE], TAPER_FILE_NAME_RHO[STRING_SIZE];
/* local variables */ /* local variables */
int i, j, h, ifw, ii, jj, n, xb, yb, xe, ye, taperlength,taperlength2, VTON, SRTON; int i, j, h, ifw, ii, jj, n, xb, yb, xe, ye, taperlength,taperlength2, VTON, SRTON;
int ijc, iy, ix, iii, jjj, xx, yy, srctaper_gridpt, i1, j1; int ijc, iy, ix, iii, jjj, xx, yy, srctaper_gridpt, i1, j1;
extern int GRADT1, GRADT2, GRADT3, GRADT4; extern int GRADT1, GRADT2, GRADT3, GRADT4;
float amp, a, *window, grad_tap, **waveconvtmp; float amp, a, *window, grad_tap, **waveconvtmp;
char modfile[STRING_SIZE]; char modfile[STRING_SIZE];
extern float SRTRADIUS; extern float SRTRADIUS;
extern int SRTSHAPE, FILTSIZE; extern int SRTSHAPE, FILTSIZE;
float **m, **edgemat, **mm, **msum, minm, maxm, x, y, rad, **taper_coeff_glob; float **m, **edgemat, **mm, **msum, minm, maxm, x, y, rad, **taper_coeff_glob;
float maxrad; float maxrad;
char taper_file[STRING_SIZE]; char taper_file[STRING_SIZE];
extern int VERBOSE; extern int VERBOSE;
FILE *fp_taper; FILE *fp_taper;
/*SRTSHAPE=2; /*SRTSHAPE=2;
SRTRADIUS=25.0; SRTRADIUS=25.0;
filtsize=2;*/ filtsize=2;*/
/* =============== */ /* =============== */
/* Vertical taper */ /* Vertical taper */
/* =============== */ /* =============== */
if(sws==1){ if(sws==1){
/* define taper geometry */
taperlength=GRADT2-GRADT1;
taperlength2=GRADT4-GRADT3;
ifw = GRADT4-GRADT1;
/*printf("%d \t %d \t %d \t %d \n",GRADT1, GRADT2, GRADT3, GRADT4);
printf("%d \t %d \t %d \n",taperlength, taperlength2,ifw);*/
if (MYID==0&&VERBOSE)
{
fprintf(FP,"\n **Message from taper_grid (printed by PE %d):\n",MYID);
fprintf(FP," Coefficients for gradient taper are now calculated.\n");
}
waveconvtmp = matrix(0,NY+1,0,NX+1);
window=vector(1,ifw);
/* Gaussian window */
a=3; /* damping coefficient */
for (i=1;i<=ifw;i++){
window[i] = 1.0;
if(i<=taperlength){
window[i] = exp(-(1.0/2.0)*(a*(i-taperlength)/(taperlength/2.0))*(a*(i-taperlength)/(taperlength/2.0)));
}
if(i>=(ifw-taperlength2)){
window[i] = exp(-(1.0/2.0)*(a*(i-(ifw-taperlength2))/(taperlength2/2.0))*(a*(i-(ifw-taperlength2))/(taperlength2/2.0)));
}
}
/* loop over global grid */
for (j=1;j<=NYG;j++){
h=1;
for (i=1;i<=NXG;i++){
grad_tap=0.0;
if((i>GRADT1)&&(i<GRADT4)){
grad_tap=window[h];
h++;
}
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
taper_coeff[jj][ii]=grad_tap;
}
}
}
/* apply taper on local gradient */
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i]*=taper_coeff[j][i];
waveconvtmp[j][i] = waveconv[j][i];
}
}
/* apply filter at shot and receiver points */
for (n=1;n<=nshots;n++)
{
i = iround(srcpos[1][n]/DH);
j = iround(srcpos[2][n]/DH);
if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){
ii = i-POS[1]*NX;
jj = j-POS[2]*NY;
/*waveconvtmp[jj][ii] = 1*waveconv[jj][ii]
+ 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1])
+ 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]);
waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49;*/
waveconvtmp[jj][ii] = 0.0;
}
}
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i] = waveconvtmp[j][i];
}
}
for (n=1;n<=ntr;n++)
{
i = recpos[1][n];
j = recpos[2][n];
if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){
ii = i-POS[1]*NX;
jj = j-POS[2]*NY;
/*waveconvtmp[jj][ii] = 1*waveconv[jj][ii]
+ 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1])
+ 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]);
waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49;*/
waveconvtmp[jj][ii] = 0.0;
}
}
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i] = waveconvtmp[j][i];
}
}
sprintf(modfile,"taper_coeff_vert.bin");
writemod(modfile,taper_coeff,3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID==0) mergemod(modfile,3);
free_vector(window,1,ifw);
free_matrix(waveconvtmp,0,NX+1,0,NY+1);
}
/* ======================== */
/* Horizontal Taper */
/* ======================== */
if(sws==2){
/* define taper geometry */ /* define taper geometry */
taperlength=GRADT2-GRADT1; taperlength=GRADT2-GRADT1;
taperlength2=GRADT4-GRADT3; taperlength2=GRADT4-GRADT3;
ifw = GRADT2-GRADT1+1; ifw = GRADT4-GRADT1;
if (MYID==0&&VERBOSE){ /*printf("%d \t %d \t %d \t %d \n",GRADT1, GRADT2, GRADT3, GRADT4);
printf("%d \t %d \t %d \t %d \n",GRADT1, GRADT2, GRADT3, GRADT4); printf("%d \t %d \t %d \n",taperlength, taperlength2,ifw);*/
printf("%d \t %d \t %d \n",taperlength, taperlength2,ifw);
if (MYID==0&&VERBOSE)
{
fprintf(FP,"\n **Message from taper_grid (printed by PE %d):\n",MYID); fprintf(FP,"\n **Message from taper_grid (printed by PE %d):\n",MYID);
fprintf(FP," Coefficients for gradient taper are now calculated.\n"); fprintf(FP," Coefficients for gradient taper are now calculated.\n");
} }
waveconvtmp = matrix(0,NY+1,0,NX+1); waveconvtmp = matrix(0,NY+1,0,NX+1);
window=vector(1,ifw); window=vector(1,ifw);
/* Gaussian window */ /* Gaussian window */
a=3; /* damping coefficient */ a=3; /* damping coefficient */
for (i=1;i<=ifw;i++){ for (i=1;i<=ifw;i++){
window[i] = 1.0; window[i] = 1.0;
if(i<=taperlength){ if(i<=taperlength){
window[i] = exp(-(1.0/2.0)*(a*(i-taperlength)/(taperlength/2.0))*(a*(i-taperlength)/(taperlength/2.0))); window[i] = exp(-(1.0/2.0)*(a*(i-taperlength)/(taperlength/2.0))*(a*(i-taperlength)/(taperlength/2.0)));
}
if(i>=(ifw-taperlength2)){
window[i] = exp(-(1.0/2.0)*(a*(i-(ifw-taperlength2))/(taperlength2/2.0))*(a*(i-(ifw-taperlength2))/(taperlength2/2.0)));
} }
} }
/* loop over global grid */ /* loop over global grid */
h=1;
for (j=1;j<=NYG;j++){ for (j=1;j<=NYG;j++){
for (i=1;i<=NXG;i++){
h=1;
grad_tap=0.0; for (i=1;i<=NXG;i++){
if((j>=GRADT1)&&(j<=GRADT2)){ grad_tap=0.0;
grad_tap=window[h];
} if((i>GRADT1)&&(i<GRADT4)){
grad_tap=window[h];
if(j>GRADT2){ h++;
}
/*grad_tap=((float)(j*DH))*((float)(j*DH))*((float)(j*DH));*/
/* grad_tap=((float)(j*DH))*((float)(j*DH));*/ if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
/*grad_tap=((float)(j*DH));*/ /*Version of Daniel */ ii=i-POS[1]*NX;
grad_tap=1.0; jj=j-POS[2]*NY;
} taper_coeff[jj][ii]=grad_tap;
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
taper_coeff[jj][ii]=grad_tap;
}
} }
}
if(j>=GRADT1){h++;}
} }
/* apply taper on local gradient */ /* apply taper on local gradient */
for (j=1;j<=NY;j++){ for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){ for (i=1;i<=NX;i++){
waveconv[j][i]*=taper_coeff[j][i]; waveconv[j][i]*=taper_coeff[j][i];
waveconvtmp[j][i] = waveconv[j][i]; waveconvtmp[j][i] = waveconv[j][i];
} }
} }
/* apply filter at shot and receiver points */ /* apply filter at shot and receiver points */
/*for (n=1;n<=nshots;n++) for (n=1;n<=nshots;n++)
{ {
i = iround(srcpos[1][n]/DH); i = iround(srcpos[1][n]/DH);
j = iround(srcpos[2][n]/DH); j = iround(srcpos[2][n]/DH);
if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){ if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){
ii = i-POS[1]*NX; ii = i-POS[1]*NX;
jj = j-POS[2]*NY; jj = j-POS[2]*NY;
waveconvtmp[jj][ii] = 1*waveconv[jj][ii] /*waveconvtmp[jj][ii] = 1*waveconv[jj][ii]
+ 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1]) + 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1])
+ 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]); + 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]);
waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49; waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49;*/
}
waveconvtmp[jj][ii] = 0.0;
}
} }
for (j=1;j<=NY;j++){ for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){ for (i=1;i<=NX;i++){
waveconv[j][i] = waveconvtmp[j][i]; waveconv[j][i] = waveconvtmp[j][i];
} }
} }
for (n=1;n<=ntr;n++) for (n=1;n<=ntr;n++)
{ {
i = recpos[1][n]; i = recpos[1][n];
j = recpos[2][n]; j = recpos[2][n];
if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){ if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){
ii = i-POS[1]*NX; ii = i-POS[1]*NX;
jj = j-POS[2]*NY; jj = j-POS[2]*NY;
waveconvtmp[jj][ii] = 1*waveconv[jj][ii] /*waveconvtmp[jj][ii] = 1*waveconv[jj][ii]
+ 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1]) + 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1])
+ 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]); + 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]);
waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49; waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49;*/
}
waveconvtmp[jj][ii] = 0.0;
}
} }
for (j=1;j<=NY;j++){ for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){ for (i=1;i<=NX;i++){
waveconv[j][i] = waveconvtmp[j][i]; waveconv[j][i] = waveconvtmp[j][i];
}
}
sprintf(modfile,"taper_coeff_vert.bin");
writemod(modfile,taper_coeff,3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID==0) mergemod(modfile,3);
free_vector(window,1,ifw);
free_matrix(waveconvtmp,0,NX+1,0,NY+1);
}
/* ======================== */
/* Horizontal Taper */
/* ======================== */
if(sws==2){
/* define taper geometry */
taperlength=GRADT2-GRADT1;
taperlength2=GRADT4-GRADT3;
ifw = GRADT2-GRADT1+1;
if (MYID==0&&VERBOSE){
printf("%d \t %d \t %d \t %d \n",GRADT1, GRADT2, GRADT3, GRADT4);
printf("%d \t %d \t %d \n",taperlength, taperlength2,ifw);
fprintf(FP,"\n **Message from taper_grid (printed by PE %d):\n",MYID);
fprintf(FP," Coefficients for gradient taper are now calculated.\n");
}
waveconvtmp = matrix(0,NY+1,0,NX+1);
window=vector(1,ifw);
/* Gaussian window */
a=3; /* damping coefficient */
for (i=1;i<=ifw;i++){
window[i] = 1.0;
if(i<=taperlength){
window[i] = exp(-(1.0/2.0)*(a*(i-taperlength)/(taperlength/2.0))*(a*(i-taperlength)/(taperlength/2.0)));
}
}
/* loop over global grid */
h=1;
for (j=1;j<=NYG;j++){
for (i=1;i<=NXG;i++){
grad_tap=0.0;
if((j>=GRADT1)&&(j<=GRADT2)){
grad_tap=window[h];
} }
}*/
if(j>GRADT2){
/*grad_tap=((float)(j*DH))*((float)(j*DH))*((float)(j*DH));*/
/* grad_tap=((float)(j*DH))*((float)(j*DH));*/
/*grad_tap=((float)(j*DH));*/ /*Version of Daniel */
grad_tap=1.0;
}
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY))){
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
taper_coeff[jj][ii]=grad_tap;
}
}
if(j>=GRADT1){h++;}
}
/* apply taper on local gradient */
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i]*=taper_coeff[j][i];
waveconvtmp[j][i] = waveconv[j][i];
}
}
/* apply filter at shot and receiver points */
/*for (n=1;n<=nshots;n++)
{
i = iround(srcpos[1][n]/DH);
j = iround(srcpos[2][n]/DH);
if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){
ii = i-POS[1]*NX;
jj = j-POS[2]*NY;
waveconvtmp[jj][ii] = 1*waveconv[jj][ii]
+ 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1])
+ 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]);
waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49;
}
}
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i] = waveconvtmp[j][i];
}
}
for (n=1;n<=ntr;n++)
{
i = recpos[1][n];
j = recpos[2][n];
if ((POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY))){
ii = i-POS[1]*NX;
jj = j-POS[2]*NY;
waveconvtmp[jj][ii] = 1*waveconv[jj][ii]
+ 8*(waveconv[jj-1][ii] + waveconv[jj+1][ii] + waveconv[jj][ii-1] + waveconv[jj][ii+1])
+ 4*(waveconv[jj-1][ii-1] + waveconv[jj-1][ii+1] + waveconv[jj+1][ii+1] + waveconv[jj+1][ii-1]);
waveconvtmp[jj][ii] = waveconvtmp[jj][ii]/49;
}
}
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
waveconv[j][i] = waveconvtmp[j][i];
}
}*/
sprintf(modfile,"taper_coeff_hor.bin"); sprintf(modfile,"taper_coeff_hor.bin");
writemod(modfile,taper_coeff,3); writemod(modfile,taper_coeff,3);
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
if (MYID==0) mergemod(modfile,3); if (MYID==0) mergemod(modfile,3);