# 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"
 #chk.pl: "forms/"    "inv.cal"
 #chk.pl: "forms/"    "add.cal"

# 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: 'len-inv.h' /

# 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:  'len-inv.h' /
  VEL='len-den.out'  MPAR=3  ICB=' '
  grid:  'len-inv.h' /

# Generating starting model for inversion (all functions zero)
  MODEL='len-mod.dat'  MODOUT='len-mod0.out'  OLDMOD=0.00
  invsoft: 'len-inv.h' /
  modmod: 'len-inv.h' /
  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: 'len-inv.h' /
  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: 'len-inv.h' /
  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: 'len-inv.h' /
  GRD=' '  M2IN=' '

# Matrix operations
  N1=0  N2=1  N3=1  M1='m2.out'
  CAL='inv.cal' GRD1='dm1.out' GRD2='dm2.out'
  grdcal: 'len-inv.h' /
  M1='m1.out'  M2='m2.out'  GM1='gm1.out'  DM1='dm2.out'  SM1='sm1.out'
  gmdmgmt: 'len-inv.h' /
  Regularization to keep the initial coefficients of densities
  N1=0  N2=0  N3=1  M1='m1.out' M2='m1.out'
  CAL='add.cal' GRD1='sm1.out' GRD2='modl2.out' GRD3='sm2.out'
  grdcal: 'len-inv.h' /
  M1='m1.out'               SM1='sm2.out'  SM2='sm3.out'
  sminv: 'len-inv.h' /
  M1='m2.out'  M2=' '       DM1='dm2.out'  GM1='gm2.out'  GM2='gm3.out'
  dmgm: 'len-inv.h' /
  M1='m1.out'  M2='m2.out'  GM1='gm1.out'  GM2='gm3.out'  GM3='gm4.out'
  gmgm: 'len-inv.h' /
  M1='m1.out'  M2=' '       SM1='sm3.out'  GM1='gm4.out'  GM2='gm5.out'
  smgm: 'len-inv.h' /

# Updating the model
  M1='m1.out'  MODNEW='gm5.out'
  modmod: 'len-inv.h' /

# 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: 'len-inv.h' /
  GM1='gm1.out'  GM2='gm2.out'  GM3=' '  DM1='dm1.out'
  PTS='len-pts.out'  KOLUMN=0  KOLFUN=7    MPAR=0  ERRMUL=0.0025
  invpts: 'len-inv.h' /
  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: 'len-inv.h' /
  GRD='len-den.out'  GRDICB='len-icb.out'  MPAR=3  ERRMUL=0.0001
  invpts: 'len-inv.h' /
  GRD=' '  M2IN=' '

# Matrix operations
  N1=0  N2=1  N3=1  M1='m2.out'
  CAL='inv.cal' GRD1='dm1.out' GRD2='dm2.out' GRD3=
  grdcal: 'len-inv.h' /
  M1='m1.out'  M2='m2.out'  GM1='gm1.out'  DM1='dm2.out'  SM1='sm1.out'
  gmdmgmt: 'len-inv.h' /
  M1='m1.out'               SM1='sm1.out'  SM2='sm3.out'
  sminv: 'len-inv.h' /
  M1='m2.out'  M2=' '       DM1='dm2.out'  GM1='gm2.out'  GM2='gm3.out'
  dmgm: 'len-inv.h' /
  M1='m1.out'  M2='m2.out'  GM1='gm1.out'  GM2='gm3.out'  GM3='gm4.out'
  gmgm: 'len-inv.h' /
  M1='m1.out'  M2=' '       SM1='sm3.out'  GM1='gm4.out'  GM2='gm5.out'
  smgm: 'len-inv.h' /

# Updating the model
  M1='m1.out'  MODNEW='gm5.out'
  modmod: 'len-inv.h' /

# 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: 'len-inv.h' /

# 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:  'len-inv.h' /
  VEL='len-den.tmp'  MPAR=3  ICB=' '
  grid:  'len-inv.h' /

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

