# Smoothing Marmousi velocity model
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Input files required
 #chk.pl: "data/mar/" "mar-vel.dat"
 #chk.pl: "data/mar/" "mar-mod0.dat"
 #chk.pl: "model/"    "sob22.dat"
 #chk.pl: "forms/"    "inv.cal"
 #chk.pl: "forms/"    "addsob.cal"
 #chk.pl: "forms/"    "sub.cal"
 #chk.pl: "forms/"    "sqrt.cal"

# Inversion
# ~~~~~~~~~
# Initial and updated models
  MODEL='mar-mod0.dat'  MODOUT='mar-mod.out'  NEGPAR=0

# Gridded slowness to fit (intervals 40m*80m)
  N1=76  N2=116  D1=40  D2=80  O1=0  O2=0
  CAL='inv.cal' GRD1='mar-vel.dat' GRD2='mar-u0.out'
  grdcal: 'mar-inv.h' /

# Calculating matrices for inversion
  M1='m1.out'  M2='m2.out'  MODL2=' '  MODSOB='modsob.out'
  SOBOLEV='sob22.dat'  SOBW01=1  # minimizing second slowness derivatives
  invsoft: 'mar-inv.h' /
# Unit given standard deviation of slowness: ERRMUL=SQRT(N1*N2)
  GRD='mar-u0.out'  INDFUN=1  MPAR=1  POWERM=-1  ERRMUL=93.9
  GM1='gm1.out'  GM2='gm2.out'  GM3=' '  DM1='dm1.out'
  invpts: 'mar-inv.h' /
  GRD=' '

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

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

# Calculating components of the residual objective function
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Standard slowness deviation 'mar-ud1.out' of the updated model
  M1=' '  M2='m1.out'  M3='m2.out'
  GM1='gm5.out'  GM2='gm1.out'  GM3='gm8.out'
  gmgm: 'mar-inv.h' /
  M3=' '
  N1=0  N2=1  N3=1  M1='m2.out'
  CAL='sub.cal' GRD1='gm2.out' GRD2='gm8.out' GRD3='gm9.out'
  grdcal: 'mar-inv.h' /
  M1=' '  M2='m2.out'  GM1='gm9.out'  DM1='dm2.out'  SM1='gm0.out'
  gmdmgmt: 'mar-inv.h' /
  N1=0  N2=1  N3=1  M1=' '
  CAL='sqrt.cal' GRD1='gm0.out' GRD2='mar-ud1.out' GRD3=
  grdcal: 'mar-inv.h' /

# Sobolev norm 'mar-un1.out' of the slowness in the updated model
  M1='m1.out'  M2=' '  SM1='modsob.out'  GM1='gm5.out'  GM2='gm6.out'
  smgm: 'mar-inv.h' /
  M1=' '  M2='m1.out'  GM1='gm5.out'  GM2='gm6.out'  GM3='gm7.out'
  gmgm: 'mar-inv.h' /
  N1=0  N2=1  N3=1  M1=' '
  CAL='sqrt.cal' GRD1='gm7.out' GRD2='mar-un1.out'
  grdcal: 'mar-inv.h' /

# Important output files
# ~~~~~~~~~~~~~~~~~~~~~~
# 'mar-u0.out'...  Gridded slowness being fit.
# 'mar-mod0.dat'...Smoothed model.
# 'mar-ud1.out'... Standard slowness deviation of the model.
# 'mar-un1.out'... Sobolev norm of the slowness in the model.

