fd.h 29.2 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1 2 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 29 30 31 32 33 34 35 36 37 38 39
/*------------------------------------------------------------------------
 * Copyright (C) 2011 For the list of authors, see file AUTHORS.
 *
 * This file is part of SOFI2D.
 *
 * SOFI2D 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.
 *
 * SOFI2D 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 SOFI2D. See file COPYING and/or
  * <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/
/* $Id: fd.h 865 2015-09-22 12:57:11Z tmetz $ */
/*------------------------------------------------------------------------
 *  fd.h - include file for viscoelastic FD program sofi2D
 *
 *  ---------------------------------------------------------------------*/

/* files to include */
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
#include <mpi.h>

#define iround(x) ((int)(floor)(x+0.5))
#define min(x,y) ((x<y)?x:y)
#define max(x,y) ((x<y)?y:x)
#define fsign(x) ((x<0.0)?(-1):1)

#define PI (3.141592653589793238462643383279502884197169)
40
#define NPAR 41
Tilman Steinweg's avatar
Tilman Steinweg committed
41 42 43 44 45 46
//#define STRING_SIZE 74 // previous value, sometimes not enough to handle longer file names
#define STRING_SIZE 256
#define REQUEST_COUNT 4


/* declaration of functions */
Tilman Steinweg's avatar
Tilman Steinweg committed
47
void abs_update_s(int i, int j, float **sxx,float **sxy,float **syy, float **absorb_coeff);
Tilman Steinweg's avatar
Tilman Steinweg committed
48

Tilman Steinweg's avatar
Tilman Steinweg committed
49
void abs_update_v(int i, int j, float **vx,float **vy, float **absorb_coeff);
Tilman Steinweg's avatar
Tilman Steinweg committed
50

Tilman Steinweg's avatar
Tilman Steinweg committed
51
void absorb(float **absorb_coeff);
Tilman Steinweg's avatar
Tilman Steinweg committed
52

Tilman Steinweg's avatar
Tilman Steinweg committed
53 54
void av_mat(float   **pi, float   **u,
            float   **ppijm, float   **puip, float **pujm);
Tilman Steinweg's avatar
Tilman Steinweg committed
55

Tilman Steinweg's avatar
Tilman Steinweg committed
56
void av_mue(float **u, float **uipjp);
Tilman Steinweg's avatar
Tilman Steinweg committed
57

Tilman Steinweg's avatar
Tilman Steinweg committed
58
void av_rho(float **rho, float **rip, float **rjp);
Tilman Steinweg's avatar
Tilman Steinweg committed
59

Tilman Steinweg's avatar
Tilman Steinweg committed
60
void av_tau(float **taus, float **tausipjp);
Tilman Steinweg's avatar
Tilman Steinweg committed
61

Tilman Steinweg's avatar
Tilman Steinweg committed
62
void check_fs(FILE *fp, int argc, char *fileinp);
Tilman Steinweg's avatar
Tilman Steinweg committed
63

Tilman Steinweg's avatar
Tilman Steinweg committed
64 65
void checkfd(FILE *fp, float **prho, float **ppi, float **pu,
             float **ptaus, float **ptaup, float *peta, float *hc, float **srcpos, int nsrc, int **recpos, int ntr);
Tilman Steinweg's avatar
Tilman Steinweg committed
66

Tilman Steinweg's avatar
Tilman Steinweg committed
67
void catseis(float **data, float **fulldata, int *recswitch, int ntr_glob, int ns);
Tilman Steinweg's avatar
Tilman Steinweg committed
68

Tilman Steinweg's avatar
Tilman Steinweg committed
69 70 71
void comm_ini(float **bufferlef_to_rig, float **bufferrig_to_lef,
              float **buffertop_to_bot, float **bufferbot_to_top,
              MPI_Request *req_send, MPI_Request *req_rec);
Tilman Steinweg's avatar
Tilman Steinweg committed
72

Tilman Steinweg's avatar
Tilman Steinweg committed
73 74
void cpml_update_s_x(int i, int j,float   *vxx, float *vyx,float *K_x, float *a_x,
                     float *b_x, float *K_x_half, float *a_x_half, float *b_x_half ,float **psi_vxx,float **psi_vyx);
Tilman Steinweg's avatar
Tilman Steinweg committed
75

Tilman Steinweg's avatar
Tilman Steinweg committed
76 77
void cpml_update_s_y(int i, int j,float *vxy,float *vyy,float *K_y, float *a_y,
                     float *b_y, float *K_y_half, float *a_y_half, float *b_y_half ,float **psi_vyy,float **psi_vxy);
Tilman Steinweg's avatar
Tilman Steinweg committed
78

Tilman Steinweg's avatar
Tilman Steinweg committed
79 80
void cpml_update_v_x(int i, int j,float   *sxx_x, float *sxy_x,float *K_x, float *a_x,float *b_x,
                     float *K_x_half, float *a_x_half, float *b_x_half ,float **psi_sxx_x,float **psi_sxy_x);
Tilman Steinweg's avatar
Tilman Steinweg committed
81

Tilman Steinweg's avatar
Tilman Steinweg committed
82 83
void cpml_update_v_y(int i, int j,float *sxy_y,float *syy_y,float *K_y, float *a_y,
                     float *b_y, float *K_y_half, float *a_y_half, float *b_y_half ,float **psi_syy_y,float **psi_sxy_y);
Tilman Steinweg's avatar
Tilman Steinweg committed
84

Tilman Steinweg's avatar
Tilman Steinweg committed
85 86 87
void exchange_s_rsg(float **vx, float **vy, float **vz,
                    float **bufferlef_to_rig, float **bufferrig_to_lef,
                    float **buffertop_to_bot, float **bufferbot_to_top);
Tilman Steinweg's avatar
Tilman Steinweg committed
88

Tilman Steinweg's avatar
Tilman Steinweg committed
89 90 91 92
void exchange_v(int nd, float **vx, float **vy,
                float **bufferlef_to_rig, float **bufferrig_to_lef,
                float **buffertop_to_bot, float **bufferbot_to_top,
                MPI_Request *req_send, MPI_Request *req_rec);
Tilman Steinweg's avatar
Tilman Steinweg committed
93

Tilman Steinweg's avatar
Tilman Steinweg committed
94 95 96 97
void exchange_s(int nd, float **sxx, float **syy,
                float **sxy, float **bufferlef_to_rig, float **bufferrig_to_lef,
                float **buffertop_to_bot, float **bufferbot_to_top,
                MPI_Request *req_send, MPI_Request *req_rec);
Tilman Steinweg's avatar
Tilman Steinweg committed
98 99


Tilman Steinweg's avatar
Tilman Steinweg committed
100
void exchange_par(void);
Tilman Steinweg's avatar
Tilman Steinweg committed
101

Tilman Steinweg's avatar
Tilman Steinweg committed
102
float *holbergcoeff(void);
Tilman Steinweg's avatar
Tilman Steinweg committed
103

Tilman Steinweg's avatar
Tilman Steinweg committed
104
void info(FILE *fp);
Tilman Steinweg's avatar
Tilman Steinweg committed
105

Tilman Steinweg's avatar
Tilman Steinweg committed
106
void initproc(void);
Tilman Steinweg's avatar
Tilman Steinweg committed
107

Tilman Steinweg's avatar
Tilman Steinweg committed
108
void interpol(int ni1, int ni2, float   **intvar, int cfgt_check);
Tilman Steinweg's avatar
Tilman Steinweg committed
109

Tilman Steinweg's avatar
Tilman Steinweg committed
110 111
void model_visco(float    **rho, float   **pi, float   **u,
                 float   **taus, float   **taup, float   *eta);
Tilman Steinweg's avatar
Tilman Steinweg committed
112

Tilman Steinweg's avatar
Tilman Steinweg committed
113
void model_elastic(float    **rho, float   **pi, float   **u);
Tilman Steinweg's avatar
Tilman Steinweg committed
114

Tilman Steinweg's avatar
Tilman Steinweg committed
115 116 117
void model_ani(float    **rho, float   **c11, float   **c15, float   **c13,
               float   **c35, float   **c33, float   **c55,
               float   **taus, float   **taup, float   *eta);
Tilman Steinweg's avatar
Tilman Steinweg committed
118

Tilman Steinweg's avatar
Tilman Steinweg committed
119 120
void matcopy(float **prho, float **ppi, float **pu, float **ptaup,
             float **ptaus);
Tilman Steinweg's avatar
Tilman Steinweg committed
121

Tilman Steinweg's avatar
Tilman Steinweg committed
122
void matcopy_elastic(float **prho, float **ppi, float **pu);
Tilman Steinweg's avatar
Tilman Steinweg committed
123

Tilman Steinweg's avatar
Tilman Steinweg committed
124 125 126
void matcopy_ani(float **rho, float   **c11, float   **c15, float   **c13,
                 float   **c35, float   **c33, float   **c55, float **taus,
                 float **taup);
Tilman Steinweg's avatar
Tilman Steinweg committed
127

Tilman Steinweg's avatar
Tilman Steinweg committed
128
void merge(int nsnap, int type);
Tilman Steinweg's avatar
Tilman Steinweg committed
129

Tilman Steinweg's avatar
Tilman Steinweg committed
130
void mergemod(char modfile[STRING_SIZE], int format);
Tilman Steinweg's avatar
Tilman Steinweg committed
131

Tilman Steinweg's avatar
Tilman Steinweg committed
132
void note(FILE *fp);
Tilman Steinweg's avatar
Tilman Steinweg committed
133

Tilman Steinweg's avatar
Tilman Steinweg committed
134 135 136
void  outseis(FILE *fp, FILE *fpdata, float **section,
              int **recpos, int **recpos_loc, int ntr, float **srcpos_loc,
              int nsrc, int ns, int seis_form, int ishot);
Tilman Steinweg's avatar
Tilman Steinweg committed
137

Tilman Steinweg's avatar
Tilman Steinweg committed
138 139 140
void  outseis_glob(FILE *fp, FILE *fpdata, float **section,
                   int **recpos, int **recpos_loc, int ntr, float **srcpos_loc,
                   int nsrc, int ns, int seis_form, int ishot, int comp);
Tilman Steinweg's avatar
Tilman Steinweg committed
141

Tilman Steinweg's avatar
Tilman Steinweg committed
142
void  output_source_signal(FILE *fp, float **signals, int ns, int seis_form);
Tilman Steinweg's avatar
Tilman Steinweg committed
143

Tilman Steinweg's avatar
Tilman Steinweg committed
144 145
void operator_s_fd2(int i, int j,float   *vxx, float *vyx,float *vxy,
                    float *vyy, float **vx, float **vy,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
146

Tilman Steinweg's avatar
Tilman Steinweg committed
147 148
void operator_s_fd4(int i, int j,float   *vxx, float *vyx,float *vxy,
                    float *vyy, float **vx, float **vy,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
149

Tilman Steinweg's avatar
Tilman Steinweg committed
150 151
void operator_s_fd6(int i, int j,float   *vxx, float *vyx,float *vxy,
                    float *vyy, float **vx, float **vy,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
152

Tilman Steinweg's avatar
Tilman Steinweg committed
153 154
void operator_s_fd8(int i, int j,float   *vxx, float *vyx,float *vxy,
                    float *vyy, float **vx, float **vy,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
155

Tilman Steinweg's avatar
Tilman Steinweg committed
156 157
void operator_s_fd10(int i, int j,float   *vxx, float *vyx,float *vxy,
                     float *vyy, float **vx, float **vy,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
158

Tilman Steinweg's avatar
Tilman Steinweg committed
159 160
void operator_s_fd12(int i, int j,float   *vxx, float *vyx,float *vxy,
                     float *vyy, float **vx, float **vy,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
161

Tilman Steinweg's avatar
Tilman Steinweg committed
162 163
void operator_v_fd2(int i, int j,float   *sxx_x, float *sxy_x,float *sxy_y,
                    float *syy_y, float **sxx, float **syy,float **sxy, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
164

Tilman Steinweg's avatar
Tilman Steinweg committed
165 166
void operator_v_fd4(int i, int j,float   *sxx_x, float *sxy_x,float *sxy_y,
                    float *syy_y, float **sxx, float **syy,float **sxy, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
167

Tilman Steinweg's avatar
Tilman Steinweg committed
168 169
void operator_v_fd6(int i, int j,float   *sxx_x, float *sxy_x,float *sxy_y,
                    float *syy_y, float **sxx, float **syy,float **sxy, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
170

Tilman Steinweg's avatar
Tilman Steinweg committed
171 172
void operator_v_fd8(int i, int j,float   *sxx_x, float *sxy_x,float *sxy_y,
                    float *syy_y, float **sxx, float **syy,float **sxy, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
173

Tilman Steinweg's avatar
Tilman Steinweg committed
174 175
void operator_v_fd10(int i, int j,float   *sxx_x, float *sxy_x,float *sxy_y,
                     float *syy_y, float **sxx, float **syy,float **sxy, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
176

Tilman Steinweg's avatar
Tilman Steinweg committed
177 178
void operator_v_fd12(int i, int j,float   *sxx_x, float *sxy_x,float *sxy_y,
                     float *syy_y, float **sxx, float **syy,float **sxy, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
179

Tilman Steinweg's avatar
Tilman Steinweg committed
180
void par_mult_dt(float **pi, float **u, float **uipjp);
Tilman Steinweg's avatar
Tilman Steinweg committed
181

Tilman Steinweg's avatar
Tilman Steinweg committed
182 183
void psource(int nt, float **sxx, float **syy,
             float   **srcpos_loc, float **signals, int nsrc);
Tilman Steinweg's avatar
Tilman Steinweg committed
184

Tilman Steinweg's avatar
Tilman Steinweg committed
185 186
void psource_rsg(int nt, float **sxx, float **syy,
                 float   **srcpos_loc, float **signals, int nsrc);
Tilman Steinweg's avatar
Tilman Steinweg committed
187 188


Tilman Steinweg's avatar
Tilman Steinweg committed
189
float *rd_sour(int *nts,FILE *fp_source);
Tilman Steinweg's avatar
Tilman Steinweg committed
190

Tilman Steinweg's avatar
Tilman Steinweg committed
191
float readdsk(FILE *fp_in, int format);
Tilman Steinweg's avatar
Tilman Steinweg committed
192

Tilman Steinweg's avatar
Tilman Steinweg committed
193 194 195
void readbufs(float **sxx, float **syy,
              float **sxy, float **bufferlef_to_rig, float **bufferrig_to_lef,
              float **buffertop_to_bot, float **bufferbot_to_top);
Tilman Steinweg's avatar
Tilman Steinweg committed
196

Tilman Steinweg's avatar
Tilman Steinweg committed
197 198 199
void readbufv(float **vx, float **vy,
              float **bufferlef_to_rig, float **bufferrig_to_lef,
              float **buffertop_to_bot, float **bufferbot_to_top);
Tilman Steinweg's avatar
Tilman Steinweg committed
200

Tilman Steinweg's avatar
Tilman Steinweg committed
201 202
void read_checkpoint(int nx1, int nx2, int ny1, int ny2,
                     float   **vx, float **vy, float **sxx, float **syy, float **sxy);
Tilman Steinweg's avatar
Tilman Steinweg committed
203

Tilman Steinweg's avatar
Tilman Steinweg committed
204
void read_par_json(FILE *fp, char *fileinp);
Tilman Steinweg's avatar
Tilman Steinweg committed
205 206


Tilman Steinweg's avatar
Tilman Steinweg committed
207 208
void readmod_visco(float    **rho, float   **pi, float   **u,
                   float   **taus, float   **taup, float   *eta);
Tilman Steinweg's avatar
Tilman Steinweg committed
209

Tilman Steinweg's avatar
Tilman Steinweg committed
210
void readmod_elastic(float    **rho, float   **pi, float   **u);
Tilman Steinweg's avatar
Tilman Steinweg committed
211

Tilman Steinweg's avatar
Tilman Steinweg committed
212
int **receiver(FILE *fp, int *ntr);
Tilman Steinweg's avatar
Tilman Steinweg committed
213

Tilman Steinweg's avatar
Tilman Steinweg committed
214 215
void save_checkpoint(int nx1, int nx2, int ny1, int ny2,
                     float   **vx, float **vy, float **sxx, float **syy, float **sxy);
Tilman Steinweg's avatar
Tilman Steinweg committed
216

Tilman Steinweg's avatar
Tilman Steinweg committed
217 218 219
void saveseis(FILE *fp, float **sectionvx, float **sectionvy,float **sectionp,
              float **sectioncurl, float **sectiondiv, int  **recpos, int  **recpos_loc,
              int ntr, float **srcpos_loc, int nsrc,int ns);
Tilman Steinweg's avatar
Tilman Steinweg committed
220

Tilman Steinweg's avatar
Tilman Steinweg committed
221 222
void saveseis_glob(FILE *fp, float **sectiondata, int  **recpos, int  **recpos_loc,
                   int ntr, float **srcpos, int ishot,int ns, int sectiondatatype);
Tilman Steinweg's avatar
Tilman Steinweg committed
223

Tilman Steinweg's avatar
Tilman Steinweg committed
224 225
void snap(FILE *fp,int nt, int nsnap, float **vx, float **vy, float **sxx,
          float **syy, float **u, float **pi, float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
226 227


Tilman Steinweg's avatar
Tilman Steinweg committed
228
void snap_rsg(FILE *fp,int nt, int nsnap, float **vx, float **vy, float **sxx, float **syy, float **u, float **pi);
Tilman Steinweg's avatar
Tilman Steinweg committed
229

Tilman Steinweg's avatar
Tilman Steinweg committed
230
void snapmerge(int nsnap);
Tilman Steinweg's avatar
Tilman Steinweg committed
231

Tilman Steinweg's avatar
Tilman Steinweg committed
232
float **sources(int *nsrc);
Tilman Steinweg's avatar
Tilman Steinweg committed
233

Tilman Steinweg's avatar
Tilman Steinweg committed
234 235 236
void seismo(int lsamp, int ntr, int **recpos, float **sectionvx,
            float **sectionvy, float **sectionp, float **sectioncurl, float **sectiondiv,
            float **pvx, float **pvy, float **psxx, float **psyy, float **ppi, float **pu);
Tilman Steinweg's avatar
Tilman Steinweg committed
237

Tilman Steinweg's avatar
Tilman Steinweg committed
238 239 240 241
void seismo_ssg(int lsamp, int ntr, int **recpos, float **sectionvx,
                float **sectionvy, float **sectionp, float **sectioncurl, float **sectiondiv,
                float **pvx, float **pvy, float **psxx, float **psyy, float **ppi, float **pu,
                float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
242

Tilman Steinweg's avatar
Tilman Steinweg committed
243 244 245
void seismo_rsg(int lsamp, int ntr, int **recpos, float **sectionvx,
                float **sectionvy, float **sectionp, float **sectioncurl, float **sectiondiv,
                float **pvx, float **pvy, float **psxx, float **psyy, float **ppi, float **pu);
Tilman Steinweg's avatar
Tilman Steinweg committed
246

Tilman Steinweg's avatar
Tilman Steinweg committed
247
int **splitrec(int **recpos,int *ntr_loc, int ntr, int *recswitch);
Tilman Steinweg's avatar
Tilman Steinweg committed
248

Tilman Steinweg's avatar
Tilman Steinweg committed
249
float **splitsrc(float **srcpos,int *nsrc_loc, int nsrc);
Tilman Steinweg's avatar
Tilman Steinweg committed
250

Tilman Steinweg's avatar
Tilman Steinweg committed
251
void subgrid_bounds(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy);
Tilman Steinweg's avatar
Tilman Steinweg committed
252

Tilman Steinweg's avatar
Tilman Steinweg committed
253 254 255 256 257
void surface(int ndepth, float **pvx, float **pvy,
             float **psxx, float **psyy,
             float **psxy, float *** pp, float *** pq,
             float    **ppi, float    **pu, float **ptaup,
             float **ptaus, float *etajm, float *peta, float *hc, float *K_x, float *a_x, float *b_x, float **psi_vxx);
Tilman Steinweg's avatar
Tilman Steinweg committed
258

Tilman Steinweg's avatar
Tilman Steinweg committed
259 260 261
void surface_elastic(int ndepth, int *gx, float **vx, float **vy, float **sxx, float **syy,
                     float **sxy, float    **pi, float    **u, float *hc, float *K_x, float *a_x, float *b_x, float**
                     psi_vxx);
Tilman Steinweg's avatar
Tilman Steinweg committed
262 263


Tilman Steinweg's avatar
Tilman Steinweg committed
264 265 266 267 268 269
void prepare_update_s(float *etajm, float *etaip, float *peta, float **fipjp, float **pu,
                      float **puipjp, float **ppi, float **ptaus, float **ptaup,
                      float **ptausipjp, float **f, float **g, float *bip, float *bjm,
                      float *cip, float *cjm, float ***dip, float ***d, float ***e);

void prepare_update_s_4(float *etajm, float *etaip, float *peta, float **fipjp, float **pu,
Tilman Steinweg's avatar
Tilman Steinweg committed
270 271
                        float **puipjp, float **ppi, float **ptaus, float **ptaup,
                        float **ptausipjp, float **f, float **g, float *bip, float *bjm,
Tilman Steinweg's avatar
Tilman Steinweg committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
                        float *cip, float *cjm, float ***dip, float ***d, float ***e);

void update_s_visc_abs(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                       float **vx, float **vy, float **sxx, float **syy,
                       float **sxy, float ***r, float *** p, float ***q,
                       float **pi,
                       float **fipjp, float **f, float **g, float *bip, float *bjm, float *cip,
                       float *cjm, float ***d, float ***e, float ***dip,
                       float **absorb_coeff,float *hc);

void update_s_visc_abs_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                         float **vx, float **vy, float **sxx, float **syy,
                         float **sxy, float ***r, float *** p, float ***q,
                         float **pi,
                         float **fipjp, float **f, float **g, float *bip, float *bjm, float *cip,
                         float *cjm, float ***d, float ***e, float ***dip,
                         float **absorb_coeff,float *hc,  float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4,float ***pr_2,float ***pr_3,float ***pr_4, float ***pp_2, float ***pp_3, float ***pp_4, float ***pq_2, float ***pq_3, float ***pq_4);

void update_s_elastic(int nx1, int nx2, int ny1, int ny2, int nt,
                      float   **vx, float    **vy, float    **sxx, float    **syy,
                      float    **sxy, float **pi, float **u, float **uipjp, float **absorb_coeff,
                      float *hc);

void update_s_elastic_abs(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                          float   **vx, float    **vy, float    **sxx, float    **syy,
                          float    **sxy, float **pi, float **u, float **uipjp,
                          float **absorb_coeff, float *hc);

void update_s_elastic_abs_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                            float   **vx, float    **vy, float    **sxx, float    **syy,
                            float    **sxy, float **pi, float **u, float **uipjp,
                            float **absorb_coeff, float *hc ,float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4);

void update_s_elastic_interior(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                               float   **vx, float    **vy, float    **sxx, float    **syy,
                               float    **sxy, float **pi, float **u, float **uipjp,
                               float *hc);

void update_s_elastic_interior_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                                 float   **vx, float    **vy, float    **sxx, float    **syy,
                                 float    **sxy, float **pi, float **u, float **uipjp, float *hc,float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4);

void update_s_elastic_PML(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                          float   **vx, float    **vy, float    **sxx, float    **syy,
                          float    **sxy, float **pi, float **u, float **uipjp, float *hc,
                          float *K_x, float *a_x, float *b_x, float *K_x_half, float *a_x_half, float *b_x_half,
                          float *K_y, float *a_y, float *b_y, float *K_y_half, float *a_y_half, float *b_y_half,
                          float **psi_vxx, float **psi_vyy, float **psi_vxy, float **psi_vyx);

void update_s_elastic_PML_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                            float   **vx, float    **vy, float    **sxx, float    **syy,
                            float    **sxy, float **pi, float **u, float **uipjp, float *hc,
                            float *K_x, float *a_x, float *b_x, float *K_x_half, float *a_x_half, float *b_x_half,
                            float *K_y, float *a_y, float *b_y, float *K_y_half, float *a_y_half, float *b_y_half,
                            float **psi_vxx, float **psi_vyy, float **psi_vxy, float **psi_vyx,float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4);
327

Tilman Steinweg's avatar
Tilman Steinweg committed
328
void update_s_visc_interior(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
329 330
                            float **vx, float **vy, float **sxx, float **syy,
                            float **sxy, float ***r, float *** p, float ***q,
Tilman Steinweg's avatar
Tilman Steinweg committed
331
                            float **fipjp, float **f, float **g, float *bip, float *bjm, float *cip,
332
                            float *cjm, float ***d, float ***e, float ***dip,
Tilman Steinweg's avatar
Tilman Steinweg committed
333
                            float *hc);
334

Tilman Steinweg's avatar
Tilman Steinweg committed
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
void update_s_visc_PML(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy,int nt,
                       float   **vx, float    **vy, float    **sxx, float    **syy,
                       float    **sxy, float *hc, float ***r, float ***p, float ***q, float **fipjp, float **f, float **g,
                       float *bip, float *bjm, float *cip, float *cjm, float ***d, float ***e, float ***dip,
                       float *K_x, float *a_x, float *b_x, float *K_x_half, float *a_x_half, float *b_x_half,
                       float *K_y, float *a_y, float *b_y, float *K_y_half, float *a_y_half, float *b_y_half,
                       float **psi_vxx, float **psi_vyy, float **psi_vxy, float **psi_vyx);

void update_s_visc_interior_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                              float **vx, float **vy, float **sxx, float **syy,
                              float **sxy, float ***r, float *** p, float ***q,
                              float **fipjp, float **f, float **g, float *bip, float *bjm, float *cip,
                              float *cjm, float ***d, float ***e, float ***dip,
                              float *hc,  float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4,float ***pr_2,float ***pr_3,float ***pr_4, float ***pp_2, float ***pp_3, float ***pp_4, float ***pq_2, float ***pq_3, float ***pq_4);

void update_s_visc_PML_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy,int nt,
                         float   **vx, float    **vy, float    **sxx, float    **syy,
                         float    **sxy, float *hc, float ***r, float ***p, float ***q, float **fipjp, float **f, float **g,
                         float *bip, float *bjm, float *cip, float *cjm, float ***d, float ***e, float ***dip,
                         float *K_x, float *a_x, float *b_x, float *K_x_half, float *a_x_half, float *b_x_half,
                         float *K_y, float *a_y, float *b_y, float *K_y_half, float *a_y_half, float *b_y_half,
                         float **psi_vxx, float **psi_vyy, float **psi_vxy, float **psi_vyx,  float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4,float ***pr_2,float ***pr_3,float ***pr_4, float ***pp_2, float ***pp_3, float ***pp_4, float ***pq_2, float ***pq_3, float ***pq_4);
Tilman Steinweg's avatar
Tilman Steinweg committed
357

Tilman Steinweg's avatar
Tilman Steinweg committed
358 359 360 361
void PML_pro(float *d_x, float *K_x, float *alpha_prime_x, float *a_x, float *b_x,
             float *d_x_half, float *K_x_half, float *alpha_prime_x_half, float *a_x_half, float *b_x_half,
             float *d_y, float *K_y, float *alpha_prime_y, float *a_y, float *b_y,
             float *d_y_half, float *K_y_half, float *alpha_prime_y_half, float *a_y_half, float *b_y_half);
Tilman Steinweg's avatar
Tilman Steinweg committed
362 363


Tilman Steinweg's avatar
Tilman Steinweg committed
364 365 366 367 368
void update_v(int nx1, int nx2, int ny1, int ny2, int nt,
              float   **pvx, float **pvy, float **psxx, float **psyy,
              float **psxy, float **prho, float  **prip, float **prjp,
              float   **srcpos_loc, float **signals, int nsrc, float **absorb_coeff,
              float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
369

Tilman Steinweg's avatar
Tilman Steinweg committed
370 371 372
void update_v_abs(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt, float   **vx, float **vy,
                  float **sxx, float **syy, float **sxy,  float  **rip, float **rjp,
                  float **absorb_coeff,float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
373

Tilman Steinweg's avatar
Tilman Steinweg committed
374 375 376
void update_v_abs_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                    float   **vx, float **vy, float **sxx, float **syy, float **sxy,
                    float  **rip, float **rjp, float **absorb_coeff,float *hc,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4);
377

Tilman Steinweg's avatar
Tilman Steinweg committed
378
void update_v_interior(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
Tilman Steinweg's avatar
Tilman Steinweg committed
379 380 381 382
                       float   **vx, float **vy, float **sxx, float **syy,
                       float **sxy, float **rho, float  **rip, float **rjp,
                       float   **srcpos_loc, float **signals, int nsrc,
                       float *hc);
Tilman Steinweg's avatar
Tilman Steinweg committed
383

Tilman Steinweg's avatar
Tilman Steinweg committed
384 385 386 387
void update_v_interior_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt,
                         float   **vx, float **vy, float **sxx, float **syy,
                         float **sxy, float **rho, float  **rip, float **rjp,
                         float   **srcpos_loc, float **signals, int nsrc,float *hc,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4);
388

Tilman Steinweg's avatar
Tilman Steinweg committed
389 390 391 392 393 394 395 396 397 398
void update_v_PML(int nx1, int nx2, int ny1, int ny2,int *gx, int *gy, int nt, float   **vx, float **vy,
                  float **sxx, float **syy, float **sxy, float  **rip, float **rjp,
                  float *hc, float *K_x, float *a_x, float *b_x, float *K_x_half,
                  float *a_x_half, float *b_x_half, float *K_y, float *a_y, float *b_y, float *K_y_half, float *a_y_half, float *b_y_half, float **psi_sxx_x, float **psi_syy_y,
                  float **psi_sxy_y, float **psi_syx_x);
void update_v_PML_4(int nx1, int nx2, int ny1, int ny2, int *gx, int *gy, int nt, float   **vx, float **vy,
                    float **sxx, float **syy, float **sxy,  float  **rip, float **rjp,
                    float *hc, float *K_x, float *a_x, float *b_x, float *K_x_half, float *a_x_half,
                    float *b_x_half, float *K_y, float *a_y, float *b_y, float *K_y_half, float *a_y_half, float *b_y_half,
                    float **psi_sxx_x, float **psi_syy_y, float **psi_sxy_y, float **psi_sxy_x,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4);
Tilman Steinweg's avatar
Tilman Steinweg committed
399

Tilman Steinweg's avatar
Tilman Steinweg committed
400 401
void wavefield_update_s_el(int i, int j,float   vxx, float  vyx,float vxy,float  vyy, float **sxy,
                           float **sxx, float **syy, float **pi, float **u, float **uipjp);
Tilman Steinweg's avatar
Tilman Steinweg committed
402

Tilman Steinweg's avatar
Tilman Steinweg committed
403 404 405 406
void wavefield_update_s_visc(int i, int j,float   vxx, float  vyx,float vxy,float  vyy, float **sxy,
                             float **sxx, float **syy, float ***r, float ***p,
                             float ***q,float **fipjp, float **f, float **g, float *bip,
                             float *bjm,float *cip, float *cjm, float ***d, float ***e, float ***dip);
Tilman Steinweg's avatar
Tilman Steinweg committed
407

Tilman Steinweg's avatar
Tilman Steinweg committed
408 409 410 411
void wavefield_update_s_visc_4(int i, int j,float   vxx, float  vyx,float vxy,float  vyy, float **sxy,
                               float **sxx, float **syy, float ***r, float ***p,
                               float ***q,float **fipjp, float **f, float **g, float *bip,
                               float *bjm,float *cip, float *cjm, float ***d, float ***e, float ***dip,  float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4,float ***pr_2,float ***pr_3,float ***pr_4, float ***pp_2, float ***pp_3, float ***pp_4, float ***pq_2, float ***pq_3, float ***pq_4);
412

Tilman Steinweg's avatar
Tilman Steinweg committed
413 414 415 416
void wavefield_update_v(int i, int j,float   sxx_x, float  sxy_x,float sxy_y,float  syy_y, float **vx,
                        float **vy, float **rip, float **rjp);
void wavefield_update_v_4(int i, int j,float   sxx_x, float  sxy_x,float sxy_y,float  syy_y, float **vx,
                          float **vy, float **rip, float **rjp,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4);
Tilman Steinweg's avatar
Tilman Steinweg committed
417

Tilman Steinweg's avatar
Tilman Steinweg committed
418 419
void wavefield_update_s_el_4(int i, int j,float   vxx, float  vyx,float vxy,float  vyy, float **sxy,
                             float **sxx, float **syy, float **pi, float **u, float **uipjp,float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4);
Tilman Steinweg's avatar
Tilman Steinweg committed
420

Tilman Steinweg's avatar
Tilman Steinweg committed
421
float **wavelet(float **srcpos_loc, int nsrc);
Tilman Steinweg's avatar
Tilman Steinweg committed
422

Tilman Steinweg's avatar
Tilman Steinweg committed
423 424 425
void writebufs(float **sxx, float **syy,
               float **sxy, float **bufferlef_to_rig, float **bufferrig_to_lef,
               float **buffertop_to_bot, float **bufferbot_to_top);
Tilman Steinweg's avatar
Tilman Steinweg committed
426

Tilman Steinweg's avatar
Tilman Steinweg committed
427 428 429
void writebufv(float **vx, float **vy,
               float **bufferlef_to_rig, float **bufferrig_to_lef,
               float **buffertop_to_bot, float **bufferbot_to_top);
Tilman Steinweg's avatar
Tilman Steinweg committed
430

Tilman Steinweg's avatar
Tilman Steinweg committed
431
void write_par(FILE *fp);
Tilman Steinweg's avatar
Tilman Steinweg committed
432

Tilman Steinweg's avatar
Tilman Steinweg committed
433
void writedsk(FILE *fp_out, float amp, int format);
Tilman Steinweg's avatar
Tilman Steinweg committed
434

Tilman Steinweg's avatar
Tilman Steinweg committed
435
void writemod(char modfile[STRING_SIZE], float **array, int format);
Tilman Steinweg's avatar
Tilman Steinweg committed
436

Tilman Steinweg's avatar
Tilman Steinweg committed
437
void zero_elastic(int nx1, int nx2, int ny1, int ny2, float **vx, float **vy, float **sxx, float **syy, float **sxy);
Tilman Steinweg's avatar
Tilman Steinweg committed
438

Tilman Steinweg's avatar
Tilman Steinweg committed
439
void zero_elastic_4(int nx1, int nx2, int ny1, int ny2, float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4);
440

Tilman Steinweg's avatar
Tilman Steinweg committed
441
void zero_visco_4(int nx1, int nx2, int ny1, int ny2, float **vxx_1,float **vxx_2,float **vxx_3,float **vxx_4,float **vyy_1,float **vyy_2,float **vyy_3,float **vyy_4,float **vxy_1,float **vxy_2,float **vxy_3,float **vxy_4,float **vyx_1,float **vyx_2,float **vyx_3,float **vyx_4,float **svx_1,float **svx_2,float **svx_3,float **svx_4,float **svy_1,float **svy_2,float **svy_3,float **svy_4,float ***pr_2,float ***pr_3,float ***pr_4, float ***pp_2, float ***pp_3, float ***pp_4, float ***pq_2, float ***pq_3, float ***pq_4);
442

Tilman Steinweg's avatar
Tilman Steinweg committed
443
void zero_visc(int nx1, int nx2, int ny1, int ny2, float **vx, float **vy, float **sxx, float **syy, float **sxy, float *** pr, float *** pp, float *** pq);
Tilman Steinweg's avatar
Tilman Steinweg committed
444

Tilman Steinweg's avatar
Tilman Steinweg committed
445 446 447
void zero_PML_elastic(int ny1, int ny2, int nx1, int nx2, float **vx, float **vy, float **sxx,
                      float **syy, float **sxy,
                      float **psi_sxx_x, float **psi_sxy_x, float **psi_vxx, float **psi_vyx, float **psi_syy_y, float **psi_sxy_y, float **psi_vyy, float **psi_vxy,float **psi_vxxs);
Tilman Steinweg's avatar
Tilman Steinweg committed
448

Tilman Steinweg's avatar
Tilman Steinweg committed
449 450 451 452
void zero_PML_visc(int ny1, int ny2, int nx1, int nx2, float **vx, float **vy, float **sxx,
                   float **syy, float **sxy,
                   float **psi_sxx_x, float **psi_sxy_x, float **psi_vxx, float **psi_vyx, float **psi_syy_y, float **psi_sxy_y, float **psi_vyy, float **psi_vxy, float **psi_vxxs,
                   float ***pr, float ***pp, float ***pq);
Tilman Steinweg's avatar
Tilman Steinweg committed
453 454 455 456

/* declaration of functions for parser*/

/* declaration of functions for json parser in json_parser.c*/
Tilman Steinweg's avatar
Tilman Steinweg committed
457
int read_objects_from_intputfile(FILE *fp, char input_file[STRING_SIZE],char **varname_list,char **value_list);
Tilman Steinweg's avatar
Tilman Steinweg committed
458

Tilman Steinweg's avatar
Tilman Steinweg committed
459
void print_objectlist_screen(FILE *fp, int number_readobject,char **varname_list,char **value_list);
Tilman Steinweg's avatar
Tilman Steinweg committed
460

Tilman Steinweg's avatar
Tilman Steinweg committed
461
int count_occure_charinstring(char stringline[STRING_SIZE], char teststring[]);
Tilman Steinweg's avatar
Tilman Steinweg committed
462

Tilman Steinweg's avatar
Tilman Steinweg committed
463
void copy_str2str_uptochar(char string_in[STRING_SIZE], char string_out[STRING_SIZE], char teststring[]);
Tilman Steinweg's avatar
Tilman Steinweg committed
464

Tilman Steinweg's avatar
Tilman Steinweg committed
465 466
int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject, int *int_buffer,
                            char **varname_list,char **value_list);
Tilman Steinweg's avatar
Tilman Steinweg committed
467

Tilman Steinweg's avatar
Tilman Steinweg committed
468 469
int get_float_from_objectlist(char string_in[STRING_SIZE], int number_readobject, float *double_buffer,
                              char **varname_list,char **value_list);
Tilman Steinweg's avatar
Tilman Steinweg committed
470

Tilman Steinweg's avatar
Tilman Steinweg committed
471 472
int get_string_from_objectlist(char string_in[STRING_SIZE], int number_readobject, char string_buffer[STRING_SIZE],
                               char **varname_list,char **value_list);
Tilman Steinweg's avatar
Tilman Steinweg committed
473

Tilman Steinweg's avatar
Tilman Steinweg committed
474
int is_string_blankspace(char string_in[STRING_SIZE]);
Tilman Steinweg's avatar
Tilman Steinweg committed
475

Tilman Steinweg's avatar
Tilman Steinweg committed
476
void remove_blankspaces_around_string(char string_in[STRING_SIZE]);
Tilman Steinweg's avatar
Tilman Steinweg committed
477

Tilman Steinweg's avatar
Tilman Steinweg committed
478 479
void add_object_tolist(char string_name[STRING_SIZE],char string_value[STRING_SIZE], int *number_read_object,
                       char **varname_list,char **value_list);
Tilman Steinweg's avatar
Tilman Steinweg committed
480 481 482


/* utility functions */
Tilman Steinweg's avatar
Tilman Steinweg committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
void declare_error(char err_text[]);
void err2(char errformat[],char errfilename[]);
void warning(char warn_text[]);

double maximum(float **a, int nx, int ny);
float *vector(int nl, int nh);
int *ivector(int nl, int nh);
float **matrix(int nrl, int nrh, int ncl, int nch);
int **imatrix(int nrl, int nrh, int ncl, int nch);
float ** *f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh);
void free_vector(float *v, int nl, int nh);
void free_ivector(int *v, int nl, int nh);
void free_matrix(float **m, int nrl, int nrh, int ncl, int nch);
void free_imatrix(int **m, int nrl, int nrh, int ncl, int nch);
void free_f3tensor(float ***t, int nrl, int nrh, int ncl, int nch, int ndl,
                   int ndh);
Tilman Steinweg's avatar
Tilman Steinweg committed
499