# Simple demonstration history file used to debug and test the
# inversion programs.  The data to be inverted are created by
# discretization of model 'len-mod.dat'.  The same model is
# then obtained by the overdetermined least-square inversion.
# ============================================================

# Input files required
  chk.pl: "data/len/" "len-mod.dat"

# Preparing data to be inverted
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Model to generate the values
  MODEL='len-mod.dat'

# Generating points at interfaces
  VRTX='len-pts.out'  COLUMN07='ISRF'  PLGN=' '
  N1=25   N2=17   N3=13
  D1=2.5  D2=2.5  D3=2.5
  O1=0    O2=-20  O3=-25
  modsrf:

# Generating gridded P wave velocities and densities
  N1=7    N2=5    N3=7
  D1=10   D2=10   D3=5
  O1=0    O2=-20  O3=-25
  VEL='len-vel.out'  MPAR=1  ICB='len-icb.out'
  grid:
  VEL='len-den.out'  MPAR=3  ICB=' '
  grid:

# Generating starting model for inversion (all functions zero)
  MODEL='len-mod.dat'  MODOUT='len-mod0.out'  OLDMOD=0.00
  invsoft:
  modmod:
  OLDMOD=1.00

# Inversion (iteration 1)
# ~~~~~~~~~~~~~~~~~~~~~~~
# Initial and updated models
  MODEL='len-mod0.out'  MODOUT='len-mod1.out'  NEGPAR=1

# Calculating matrices for inversion (without densities)
  M1='m1.out'  M2='m2.out'  MODL2='modl2.out'  SOBW03=1
  invsoft:
  MODL2=' '  SOBW03=0
  GM1='gm1.out'  GM2='gm2.out'  GM3=' '  DM1='dm1.out'
  PTS='len-pts.out'  KOLUMN=0  KOLFUN=7    MPAR=0  ERRMUL=0.0025
  invpts:
  PTS=' '  M2IN='m2.out'
  N1=7    N2=5    N3=7
  D1=10   D2=10   D3=5
  O1=0    O2=-20  O3=-25
  GRD='len-vel.out'  GRDICB='len-icb.out'  MPAR=1  ERRMUL=0.0001
  invpts:
  GRD=' '  M2IN=' '

# Matrix operations
  MATIN1='dm1.out' MATOUT='dm2.out' MATFUN='inv'
  matfun:
  MATIN1='dm2.out'    MATIN2='gm1.out'     MATOUT='dm2gm1.out'
  SYMMETRY=      MATT1=  MATT2=1
  matmul:
  MATIN1='gm1.out'    MATIN2='dm2gm1.out'  MATOUT='sm1.out'
  SYMMETRY='sym' MATT1=  MATT2=
  matmul:
# Regularization to keep the initial coefficients of densities
  MATIN1='sm1.out'    MATIN2='modl2.out'  MATOUT='sm2.out'
  matlin:
  MATIN1='sm2.out'                        MATOUT='sm3.out'
  matinv:
  MATIN1='dm2.out'    MATIN2='gm2.out'    MATOUT='gm3.out'
  SYMMETRY=' '   MATT1=  MATT2=
  matmul:
  MATIN1='gm1.out'    MATIN2='gm3.out'    MATOUT='gm4.out'
  matmul:
  MATIN1='sm3.out'    MATIN2='gm4.out'    MATOUT='gm5.out'
  matmul:

# Updating the model
  M1='m1.out'  MODNEW='gm5.out'
  modmod:

# Inversion (iteration 2)
# ~~~~~~~~~~~~~~~~~~~~~~~
# Initial and updated models
  MODEL='len-mod1.out'  MODOUT='len-mod2.out'  NEGPAR=0

# Calculating matrices for inversion (with densities)
  M1='m1.out'  M2='m2.out'
  invsoft:
  GM1='gm1.out'  GM2='gm2.out'  GM3=' '  DM1='dm1.out'
  PTS='len-pts.out'  KOLUMN=0  KOLFUN=7    MPAR=0  ERRMUL=0.0025
  invpts:
  PTS=' '  M2IN='m2.out'
  N1=7    N2=5    N3=7
  D1=10   D2=10   D3=5
  O1=0    O2=-20  O3=-25
  GRD='len-vel.out'  GRDICB='len-icb.out'  MPAR=1  ERRMUL=0.0001
  invpts:
  GRD='len-den.out'  GRDICB='len-icb.out'  MPAR=3  ERRMUL=0.0001
  invpts:
  GRD=' '  M2IN=' '

# Matrix operations
  MATIN1='dm1.out' MATOUT='dm2.out' MATFUN='inv'
  matfun:
  MATIN1='dm2.out'    MATIN2='gm1.out'     MATOUT='dm2gm1.out'
  SYMMETRY=      MATT1=  MATT2=1
  matmul:
  MATIN1='gm1.out'    MATIN2='dm2gm1.out'  MATOUT='sm1.out'
  SYMMETRY='sym' MATT1=  MATT2=
  matmul:
  MATIN1='sm1.out'                        MATOUT='sm3.out'
  matinv:
  MATIN1='dm2.out'    MATIN2='gm2.out'    MATOUT='gm3.out'
  SYMMETRY=' '   MATT1=  MATT2=
  matmul:
  MATIN1='gm1.out'    MATIN2='gm3.out'    MATOUT='gm4.out'
  matmul:
  MATIN1='sm3.out'    MATIN2='gm4.out'    MATOUT='gm5.out'
  matmul:

# Updating the model
  M1='m1.out'  MODNEW='gm5.out'
  modmod:

# Tests and debugging
# ~~~~~~~~~~~~~~~~~~~
# Updated model
  MODEL='len-mod2.out'

# Generating points at interfaces
  VRTX='len-pts.tmp'  COLUMN07='ISRF'  PLGN=' '
  N1=25   N2=17   N3=13
  D1=2.5  D2=2.5  D3=2.5
  O1=0    O2=-20  O3=-25
  modsrf:

# Generating gridded P wave velocities and densities
  N1=7    N2=5    N3=7
  D1=10   D2=10   D3=5
  O1=0    O2=-20  O3=-25
  VEL='len-vel.tmp'  MPAR=1  ICB='len-icb.tmp'
  grid:
  VEL='len-den.tmp'  MPAR=3  ICB=' '
  grid:

# Files '*.tmp' ('len-pts.tmp', 'len-vel.tmp', 'len-icb.tmp' and
# 'len-den.tmp') may now be compared with files '*.out' being inverted.
