Subroutine `kirchslow()` below is the best tutorial Kirchhoff
migration-modeling program I could devise.
A nice feature of this program is that it works OK
while the edge complications do not clutter it.
The program copies information from data space `data(it,iy)`
to model space `modl(iz,ix)` or vise versa.
Notice that of these four axes,
three are independent (stated by loops)
and the fourth is derived by the circle-hyperbola
relation .Migration programs are said to be ``hyperbola-like'' if is given and *t* is solved for, and ``semicircle-like''
if *t* is given and is solved for.
Subroutine `kirchslow()` is hyperbola-like and for `conj=0`,
information is copied from model space to data space,
i.e. from the hyperbola top to its flanks.
Otherwise data flows from the flanks to the top.

# Kirchhoff migration and diffraction. (tutorial, slow) # subroutine kirchslow( conj, add, velocity, t0,dt,dx, nt,nx, modl, data) integer ix,iy,it,iz,nz, conj, add, nt,nx real x0,y0,dy,z0,dz,t,x,y,z,hs, velocity, t0,dt,dx, modl(nt,nx), data(nt,nx) call conjnull( conj, add, modl,nt*nx, data,nt*nx) x0=0.; y0=0; dy=dx; z0=t0; dz=dt; nz=nt do ix= 1, nx { x = x0 + dx * (ix-1) do iy= 1, nx { y = y0 + dy * (iy-1) do iz= 1, nz { z = z0 + dz * (iz-1) # z = travel-time depth hs= (x-y) / velocity t = sqrt( z * z + hs * hs ) it = 1.5 + (t-t0) / dt if( it <= nt ) if( conj == 0 ) data(it,iy) = data(it,iy) + modl(iz,ix) else modl(iz,ix) = modl(iz,ix) + data(it,iy)}}} return; end

The three loops in subroutine `kirchslow()`
may be interchanged at will without changing the result.
To emphasize this flexibility, the loops are set at the same
indentation level.
We tend to think of fixed values of the outer two loops
and then describe what happens on the inner loop.
For example, if the outer two loops are those of the model space
`modl(iz,ix)`, then
for `conj=1` the program sums data along the hyperbola into
the ``fixed'' point of model space.
When loops are reordered,
we think differently
and opportunities arise for speed improvements.

11/18/1997