Skip to content

Commit

Permalink
Added TFILE parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-koehn committed Mar 17, 2021
1 parent 06c2d14 commit 96ac042
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 50 deletions.
2 changes: 1 addition & 1 deletion include/globvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int SPATFILTER, SPAT_FILT_SIZE, SPAT_FILT_1, SPAT_FILT_ITER;
int INV_RHO_ITER, INV_VS_ITER, INV_VP_ITER, INV_QS_ITER;
int MIN_ITER, GRAD_FORM, IDXI, IDYI, NTDTINV, NXNYI;

char INV_MODELFILE[STRING_SIZE];
char INV_MODELFILE[STRING_SIZE], TFILE[STRING_SIZE];

float VPUPPERLIM, VPLOWERLIM, VSUPPERLIM, VSLOWERLIM, RHOUPPERLIM, RHOLOWERLIM;
float QSUPPERLIM, QSLOWERLIM;
Expand Down
1 change: 1 addition & 0 deletions par/DENISE_marm_OBC.inp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ radius_in_m_(SRTRADIUS) = 5.0
# --> minimum for SRTRADIUS is 5x5 gridpoints
filtsize_in_gridpoints_(FILTSIZE) = 1
read_taper_from_file_(yes=1)_(SWS_TAPER_FILE) = 0
taper_file_basename_(TFILE) = taper/taper
#
#
# ----- Output of inverted models ----- #
Expand Down
4 changes: 4 additions & 0 deletions par/taper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
75 changes: 39 additions & 36 deletions src/read_par.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern float FPML;
extern int SEISMO, NDT, SEIS_FORMAT, FREE_SURF, READMOD, READREC, SRCREC, RUN_MULTIPLE_SHOTS;
extern int BOUNDARY, LOG, TAPER, TAPERLENGTH, FW, PHYSICS, MODE;
extern float TSNAP1, TSNAP2, TSNAPINC, REFREC[4];
extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE], LOG_FILE[STRING_SIZE];
extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE], LOG_FILE[STRING_SIZE], TFILE[STRING_SIZE];
extern char SNAP_FILE[STRING_SIZE], SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE];
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];
Expand Down Expand Up @@ -329,111 +329,114 @@ int c=0, lineno=0, l;
fscanf(fp_in,"%s =%i",s,&SWS_TAPER_FILE);
break;
case 78 :
fscanf(fp_in,"%s =%s",s,TFILE);
break;
case 79 :
fscanf(fp_in,"%s =%i",s,&INV_MOD_OUT);
break;
case 79 :
case 80 :
fscanf(fp_in,"%s =%s",s,INV_MODELFILE);
break;
case 80 :
case 81 :
fscanf(fp_in,"%s =%f",s,&VPUPPERLIM);
break;
case 81 :
case 82 :
fscanf(fp_in,"%s =%f",s,&VPLOWERLIM);
break;
case 82 :
case 83 :
fscanf(fp_in,"%s =%f",s,&VSUPPERLIM);
break;
case 83 :
case 84 :
fscanf(fp_in,"%s =%f",s,&VSLOWERLIM);
break;
case 84 :
case 85 :
fscanf(fp_in,"%s =%f",s,&RHOUPPERLIM);
break;
case 85 :
case 86 :
fscanf(fp_in,"%s =%f",s,&RHOLOWERLIM);
break;
case 86 :
case 87 :
fscanf(fp_in,"%s =%f",s,&QSUPPERLIM);
break;
case 87 :
case 88 :
fscanf(fp_in,"%s =%f",s,&QSLOWERLIM);
break;
case 88 :
case 89 :
fscanf(fp_in,"%s =%i",s,&GRAD_METHOD);
break;
case 89 :
case 90 :
fscanf(fp_in,"%s =%i",s,&PCG_BETA);
break;
case 90 :
case 91 :
fscanf(fp_in,"%s =%i",s,&NLBFGS);
break;
case 91 :
case 92 :
fscanf(fp_in,"%s =%i",s,&MODEL_FILTER);
break;
case 92 :
case 93 :
fscanf(fp_in,"%s =%i",s,&FILT_SIZE);
break;
case 93 :
case 94 :
fscanf(fp_in,"%s =%i",s,&DTINV);
break;
case 94 :
case 95 :
fscanf(fp_in,"%s =%f",s,&EPS_SCALE);
break;
case 95 :
case 96 :
fscanf(fp_in,"%s =%i",s,&STEPMAX);
break;
case 96 :
case 97 :
fscanf(fp_in,"%s =%f",s,&SCALEFAC);
break;
case 97 :
case 98 :
fscanf(fp_in,"%s =%i",s,&TRKILL);
break;
case 98 :
case 99 :
fscanf(fp_in,"%s =%s",s,TRKILL_FILE);
break;
case 99 :
case 100 :
fscanf(fp_in,"%s =%s",s,PICKS_FILE);
break;
case 100 :
case 101 :
fscanf(fp_in,"%s =%s",s,&MISFIT_LOG_FILE);
break;
case 101 :
case 102 :
fscanf(fp_in,"%s =%i",s,&MIN_ITER);
break;
case 102 :
case 103 :
fscanf(fp_in,"%s =%i",s,&GRAD_FILTER);
break;
case 103 :
case 104 :
fscanf(fp_in,"%s =%i",s,&FILT_SIZE_GRAD);
break;
case 104 :
case 105 :
fscanf(fp_in,"%s =%i",s,&TIMELAPSE);
break;
case 105 :
case 106 :
fscanf(fp_in,"%s =%s",s,DATA_DIR_T0);
break;
case 106 :
case 107 :
fscanf(fp_in,"%s =%i",s,&RTMOD);
break;
case 107 :
case 108 :
fscanf(fp_in,"%s =%i",s,&GRAVITY);
break;
case 108 :
case 109 :
fscanf(fp_in,"%s =%i",s,&NGRAVB);
break;
case 109 :
case 110 :
fscanf(fp_in,"%s =%i",s,&NZGRAV);
break;
case 110 :
case 111 :
fscanf(fp_in,"%s =%i",s,&GRAV_TYPE);
break;
case 111 :
case 112 :
fscanf(fp_in,"%s =%i",s,&BACK_DENSITY);
break;
case 112 :
case 113 :
fscanf(fp_in,"%s =%s",s,DFILE);
break;
case 113 :
case 114 :
fscanf(fp_in,"%s =%i",s,&RTM_SHOT);
break;
default:
Expand Down
25 changes: 15 additions & 10 deletions src/taper_grad.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ void taper_grad(float **waveconv, float **taper_coeff, float **srcpos, int nshot
/* extern variables */

extern float DH;
extern float SRTRADIUS, EXP_TAPER_GRAD_HOR;
extern int SRTSHAPE, FILTSIZE;
extern int FREE_SURF, NX, NY, NXG, NYG;
extern int NPROCX, NPROCY, MYID, POS[3];
extern int GRADT1, GRADT2, GRADT3, GRADT4;
extern char TFILE[STRING_SIZE];
extern FILE *FP;

/* local variables */
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;

extern int GRADT1, GRADT2, GRADT3, GRADT4;

float amp, a, *window, grad_tap, **waveconvtmp;
char modfile[STRING_SIZE];

extern float SRTRADIUS, EXP_TAPER_GRAD_HOR;
extern int SRTSHAPE, FILTSIZE;
float **m, **edgemat, **mm, **msum, minm, maxm, x, y, rad, **taper_coeff_glob;
float maxrad;

Expand Down Expand Up @@ -166,7 +168,7 @@ void taper_grad(float **waveconv, float **taper_coeff, float **srcpos, int nshot
}
}

sprintf(modfile, "taper_coeff_vert.bin");
sprintf(modfile, "%s_coeff_vert.bin", TFILE);

writemod(modfile, taper_coeff, 3);

Expand Down Expand Up @@ -309,7 +311,7 @@ void taper_grad(float **waveconv, float **taper_coeff, float **srcpos, int nshot
}
}*/

sprintf(modfile, "taper_coeff_hor.bin");
sprintf(modfile, "%s_coeff_hor.bin", TFILE);
writemod(modfile, taper_coeff, 3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID == 0)
Expand Down Expand Up @@ -553,7 +555,7 @@ void taper_grad(float **waveconv, float **taper_coeff, float **srcpos, int nshot
free_matrix(waveconvtmp, 0, NX + 1, 0, NY + 1);

MPI_Barrier(MPI_COMM_WORLD);
sprintf(modfile, "taper_coeff_sources.bin");
sprintf(modfile, "%s_coeff_sources.bin", TFILE);
writemod(modfile, taper_coeff, 3);
MPI_Barrier(MPI_COMM_WORLD);
if (MYID == 0)
Expand All @@ -575,15 +577,18 @@ void taper_grad(float **waveconv, float **taper_coeff, float **srcpos, int nshot

if (sws == 4)
{
fp_taper = fopen("taper.bin", "r");
sprintf(modfile, "%s.bin", TFILE);
fp_taper = fopen(modfile, "r");
}
if (sws == 5)
{
fp_taper = fopen("taper_u.bin", "r");
sprintf(modfile, "%s_u.bin", TFILE);
fp_taper = fopen(modfile, "r");
}
if (sws == 6)
{
fp_taper = fopen("taper_rho.bin", "r");
sprintf(modfile, "%s_rho.bin", TFILE);
fp_taper = fopen(modfile, "r");
}

/* loop over global grid */
Expand Down Expand Up @@ -614,7 +619,7 @@ void taper_grad(float **waveconv, float **taper_coeff, float **srcpos, int nshot

fclose(fp_taper);

sprintf(modfile, "taper_coeff_file.bin");
sprintf(modfile, "%s_coeff_file.bin", TFILE);
writemod(modfile, taper_coeff, 3);

MPI_Barrier(MPI_COMM_WORLD);
Expand Down
7 changes: 4 additions & 3 deletions src/taper_grad_shot.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ void taper_grad_shot(float ** waveconv,float ** taper_coeff, float **srcpos, int
/* extern variables */

extern float DH;
extern float SRTRADIUS;
extern int FREE_SURF, NX, NY, NXG, NYG;
extern int NPROCX, NPROCY, MYID_SHOT, POS[3];
extern int SRTSHAPE, FILTSIZE;
extern char TFILE[STRING_SIZE];
extern FILE *FP;
extern MPI_Comm SHOT_COMM;

Expand All @@ -27,8 +30,6 @@ void taper_grad_shot(float ** waveconv,float ** taper_coeff, float **srcpos, int
float amp, a, *window, grad_tap, **waveconvtmp;
char modfile[STRING_SIZE];

extern float SRTRADIUS;
extern int SRTSHAPE, FILTSIZE;
float **m, **edgemat, **mm, **msum, minm, maxm, x, y, rad, **taper_coeff_glob;
float maxrad;

Expand Down Expand Up @@ -262,7 +263,7 @@ void taper_grad_shot(float ** waveconv,float ** taper_coeff, float **srcpos, int


MPI_Barrier(SHOT_COMM);
sprintf(modfile,"taper_coeff_%i.bin",ishot);
sprintf(modfile,"%s_coeff_%i.bin",TFILE,ishot);
writemod(modfile,taper_coeff,3);
MPI_Barrier(SHOT_COMM);
if (MYID_SHOT==0) mergemod(modfile,3);
Expand Down

0 comments on commit 96ac042

Please sign in to comment.