/* Extrap.c Wavefield extrapolation program for monochromatic waves. Provides a number of x-z timeslices that may be displayed as a movie. From Claerbout (1985) p. 105. Usage: extrap >outfile Compile: cc extrap.c ctris.c -fswitch -lm -o extrap */ /* The usual includes */ #include #include /* Define complex multiplication and conjugate for declared struct complex */ #define rmul(x,y) (x.re * y.re - x.im * y.im) #define imul(x,y) (x.im * y.re + x.re * y.im) #define rcmul(x,y) (x.re * y.re + x.im * y.im) #define icmul(x,y) (x.im * y.re - x.re * y.im) /* Define complex division -- x/y for declared struct complex */ #define rdiv(x,y) ((x.re * y.re + x.im * y.im)/(y.re * y.re + y.im * y.im)) #define idiv(x,y) ((x.im * y.re - x.re * y.im)/(y.re * y.re + y.im * y.im)) /* Declare the structure to hold complex numbers */ struct complex { float re; float im; }; main() { int ix, nx, iz, nz, iw, nw, it, nt; float p[12][48][96], phase, pi2, dx, dz, v; float z0, x0, dt, dw, lambda, w, wov, x; struct complex cd[48], ce[48], cf[48], q[48], aa, a, b, c, cshift; struct complex num, den, num2; /* Set dimensions */ nt = 12; nx = 48; nz = 96; dx = 2; dz = 1; nw = 2; /* Initialize constants */ pi2 = 2.0*3.141592; v = 1; lambda = nz*dz/4; dw = v*pi2/lambda; dt = pi2/(nt*dw); /* Zero out data volume */ for (it=0; it