Converts velocity models

Compiler information:

   Compiler : ANSI-C
   Op. Sys. : tested on Solaris, IRIX 6.2
   Libraries: lm my_getpars opterr process10 process11 process14

Calling sequence:

   chform_vm [optional parameters] outfile

   Parameter descriptions, with default values:
   inform=0		: input format, so far:
			  0: internal
			  1: rayinvr
			  2: ray_window
   outform=0		: output format, so far:
			: 0: internal
			  1: rayinvr
			  2: ray_window
   cx=0			: add constant to x, outform=2
   cz=0			: add constant to z, outform=2
   iround=1		: 1: round output to %0.3f, outform=2
   istri=0		: 1: interpolate structure onto
			     top/base velocity pairs
   tracing=0            : 1: tracing (rem. 4)


   Reads, inform to internal format
   Writes, internal format to outform
   outform=2 (ray_window):
   - Extends layers to xmin/xmax of whole model
   - Top and bottom velocity points of layers need
     to have the same x-position -> interpolation
     where necessary

I/O formats:

internal: 0

      vm.zt[MAX_NL][MAX_NP*2+10][3]: layer depth picks
      vm.vt[MAX_NL][MAX_NP*2+10][3]: layer vel. (top) picks 
      vm.vb[MAX_NL][MAX_NP*2+10][3]: layer vel. (bottom) picks

      vm.zt[i][0][0]: layer no. according to
      vm.zt[i][0][1]: layer no. (internal, =i)
      vm.zt[i][0][2]: no. of picks
      vm.zt[i][j][0] (j>0) : x (km)
      vm.zt[i][j][1] (j>0) : z (km)
      vm.zt[i][j][2] (j>0) : -1/0/1: for partial derivatives, see rayinvr
      vt, vb: accordingly

rayinvr: 1

 1    0.00  50.00 200.00	layer no.; x[0-2] (km)
 0(*) 0.00   1.00   0.00	1: cont. (*); vm.zt[0-2] (km)
         0      0      0	ignore here
 1    0.00 150.00		layer no.; x[0-1]
 0    1.50   1.55		1: cont.; vm.vt[0-1] (v top) (km/s)
         0      0		ignore here
 1    0.00 100.00		layer no.; x[0-2]
 0    1.60   1.65		1: cont.; vm.vb[0-1] (v bottom)
         0      0		ignore here
 5    0.00 200.00		layer no.; x[0-1]
 0   20.00  20.00		1: continue in next line; vm.zt[0-1]

 (*) If 2nd line of "triplet" for x, v1, or v2 starts with 0 instead of 1,
     it continues three lines later. See rayinvr for further documentation.

   Must not have 0.00 as a velocity on either top or base of layer
   (which is permitted in rayinvr).

ray_window: 2

   x[] vm.zt[] (vm.vt[] vm.vb[], only if >0)	(%f %f %f %f\n)
   layers separated by blank line

   - Must have "duplet" of x zt \n x zt vt vb at the beginning of each layer
     (always apply "Add end velocities" in ray_window).
   - Values for both xmin and xmax have to be given for ray_window
     (done during output)
   - Can't deal with vt and vb-picks at different x -> applies
     interpolation for output if necessary
   - Last layer (base of model) may be problematic because it expects
     "duplets" x zt \n z zt vt vb (apply "Add end velocities" here, too)

Bugs and Pitfalls:

   1. Not tested very well.  Be a little bit careful!
   2. inform=1 (rayinvr): Velocities=0 not possible.
   3. Inconsistencies with last layer (base of model) as to whether
      it needs "duplets" x zt \n z zt vt vb or not (also compared 
      to ray2tomo.c etc.)


   4/26/99 : original version.
   4/5/01  : minor bug fixed with outform=1: partial derivative for
             inversion now always set to 0.
   4/10/02 : istri=0 added, i.e., for outform=2, allowing for NOT
                interpolating structure
             Bug fixed, outform=2, if fewer velocity nodes at base
                of layer than at top of layer


   1. Current dimensions:
      MAX_NL 32: maximum no. of layers
      MAX_NP 512: maximum no. of picks + 1 (for no. of picks)
      MAX_NLIN 512: maximum no. of lines in rayinvr input model
      MAX_NCIN 128: maximum no. of characters in line of 
         input rayinvr model

      [MAX_NP*2+10] necessary, buffer for extending the model.
      vtop and vbot have to be [MAX_NP*2+..] because they are 
         interpolated to have the same x-picks.

      Set in process14.h

   2. No shear wave velocities. 

Ingo Pecher, GNS, Lower Hutt, New Zealand
Apr. 10, 2002