# History file 'tc.h' to analytically compute propagator matrices in
# model 'twisted crystal', and to compare the results with Green
# functions computed by CRT.
# Synthetic seismograms are generated and a figure of comparison of
# different ray-tracing methods is plotted in the second part of the
# history file.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Executables required
# greenmul
# greentc
# tcgreen
# tccomp
# crt
# green
# greenss
# ss
# sp
# append.pl
# copy.pl
# echo.pl
# go.pl

# Input files required
 #chk.pl: "tc/"  "tc-cod.dat"
 #chk.pl: "tc/"  "tc-dcr.dat"
 #chk.pl: "tc/"  "force1.dat"
 #chk.pl: "tc/"  "tc-hil.dat"
 #chk.pl: "tc/"  "tc-mod.dat"
 #chk.pl: "tc/"  "tc-rec.dat"
 #chk.pl: "tc/"  "tc-rpa.dat"
 #chk.pl: "tc/"  "tc-src.dat"
 #chk.pl: "tc/"  "unit.dat"
 #chk.pl: "crt/" "writall.dat"
 #chk.pl: "tc/"  "tc-err1.pro"
 #chk.pl: "tc/"  "tc-err2.pro"

# Computation of propagator matrices and their comparison
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Model
  MODEL='tc-mod.dat'

# Source and receivers
  SRC='tc-src.dat'  REC='tc-rec.dat'

# Other input data files for crt.for
  DCRT='tc-dcr.dat'
  INIPAR=3
  CODE='tc-cod.dat'
  RPAR='tc-rpa.dat'
  WRIT='writall.dat'
  CRTLOG='log.out'

# Frequency step and interval
  OF=0. DF=0.0125 NF=209

# Calculating Green function by programs of package CRT
  GREENAMP=8512.5336       # conversion of point source to plane wave
  crt:      'tc.h' /       # two-point ray tracing
# Coupling ray theory Green function
  GREEN='green.out' GREENMUL='greenmul.out' GREENTC='greencrt.out'
  green:    'tc.h' /       # coupling ray theory Green function
  greenmul: 'tc.h' /       # multiplication by GREENAMP
  greentc:  'tc.h' /       # conversion to propagator matrix U
# Result - propagator matrix written to the file 'greencrt.out'
# Isotropic ray theory Green function
  MODEL=                   # disabling anisotropy in 'green.for'
  GREEN='green.out' GREENMUL='greenmul.out' GREENTC='greeniso.out'
  green:    'tc.h' /       # isotropic ray theory Green function
  greenmul: 'tc.h' /       # multiplication by GREENAMP
  greentc:  'tc.h' /       # conversion to propagator matrix U
# Result - propagator matrix written to the file 'greeniso.out'

# Analytical solutions
  SIN2TH=.75  GAMMA=0.15  TCK=0.032  A44=6.  VREF2=6.9
  TCGREENE=  TCGREENW=  TCGREENQ=  TCGREENA=  TCGREENI=
  tcgreen: 'tc.h' /        # analytical Green functions
# Output in the form of Green functions written to files 'tcgreene.out',
#           'tcgreenw.out','tcgreenq.out','tcgreena.out','tcgreeni.out'.
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /        # format conversion to matrix U exact
  GREEN='tcgreenw.out' GREENTC='greentcw.out'
  greentc: 'tc.h' /        # format conversion to matrix U weak
  GREEN='tcgreenq.out' GREENTC='greentcq.out'
  greentc: 'tc.h' /        # format conversion to matrix U qi
  GREEN='tcgreena.out' GREENTC='greentca.out'
  greentc: 'tc.h' /        # format conversion to matrix U aniso
  GREEN='tcgreeni.out' GREENTC='greentci.out'
  greentc: 'tc.h' /        # format conversion to matrix U iso
# Result - propagator matrices written to the files 'greentce.out',
#           'greentcw.out','greentcq.out','greentca.out','greentci.out'.

# Comparison inv(U1)*(U2-U3) of plane-wave propagator matrices
# Analytic isotropic ray method - isotropic ray method computed by CRT
  GREENTC1='greentci.out' GREENTC2='greentci.out' GREENTC='greeniso.out'
  TCCOMP='erriso.out'      # output file
  tccomp: tc.h /
# Analytic coupling ray theory - coupling ray theory computed by CRT
  GREENTC1='greentcw.out' GREENTC2='greentcw.out' GREENTC='greencrt.out'
  TCCOMP='errcrt.out'      # output file
  tccomp: tc.h /
# Exact analytic solution - analytic ray methods
  GREENTC1='greentce.out' GREENTC2='greentce.out'
  GREENTC='greentcw.out'  TCCOMP='errw.out'
  tccomp: tc.h /
  GREENTC='greentcq.out'  TCCOMP='errq.out'
  tccomp: tc.h /
  GREENTC='greentca.out'  TCCOMP='erra.out'
  tccomp: tc.h /
  GREENTC='greentci.out'  TCCOMP='erri.out'
  tccomp: tc.h /


# Synthetic seismograms
# ~~~~~~~~~~~~~~~~~~~~~
# Note: For X1 component, change BoundingBox from B1 B2   B3 B4
#                                              to B1 B2+4 B3 B4-5

# Anisotropic travel times for plotting
  SPHILI='tc-hil.dat'  SPHIWI=7.0

# Data describing the source time function
  SOURCE='force1.dat'
  KSIG=1 # (Gabor signal)
  SIGT=0.  SIGF=1.30  SIGW=4.  SIGPH=0.  SIGA=1.

# Data describing the filtration of the source time function
  FMIN=0.00  FLOW=0.13  FHIGH=2.47  FMAX=2.60  # (cosine filter)

# Time step and time interval for the Fast Fourier Transform
  DT=0.01953125  NFFT=4096

# Optional plotting of the source time function in program SS
  SIGPLOT='tc-sig.ps'  SIGGSE='tc-sig.gse'  MPTS=200
 #ss:      'tc.h' /          # source time function
  SIGPLOT=' '  SIGGSE=' '    # avoiding repeated plots of the s.t.f

# Computation of synthetic seismograms
  SIGPLOT=' '  SIGGSE=' '
# Exact Green function
  GREEN='tcgreene.out' SS='tc-sse.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
# Analytical coupling ray theory Green function
  GREEN='tcgreenw.out' SS='tc-ssw.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
# Analytical quasi-isotropic Green function
  GREEN='tcgreenq.out' SS='tc-ssq.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
# Analytical anisotropic Green function
  GREEN='tcgreena.out' SS='tc-ssa.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
# Analytical isotropic Green function
  GREEN='tcgreeni.out' SS='tc-ssi.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms

# Plotting seismograms
  SS='tc-ssi.gse'   KOLOR=2    # isotropic       red
  SS1='tc-ssa.gse'  KOLOR1=4   # anisotropic     blue
  SS2='tc-ssq.gse'  KOLOR2=19  # quasi-isotropic deep yellow
  SS3='tc-ssw.gse'  KOLOR3=3   # coupling        green
  SS4='tc-sse.gse'  KOLOR4=1   # exact           black
  SPTMIN=35.  SPTMAX=42.  SPTLEN=14.0  SPTDIV=7   SPTSUB=10
  KODESP=0    SPXLEN=7.0  NORMSP=1     SPAMP=3.5  SPCHRH=0.3
  SP1='tc-ss1.ps'  SP2='         '  SP3=' '
  sp:      'tc.h' /          # seismogram plotting
  SPTDIV=-7
  SP1='         '  SP2='tc-ss2.ps'  SP3=' '
  sp:      'tc.h' /          # seismogram plotting


# Synthetic seismograms at coupling frequency
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Anisotropic travel times for plotting
  SPHILI='tc-hilc.dat'  SPHIWI=7.0

# Data describing the coupling-frequency source time function
  SIGT=0.  SIGF=0.26  SIGW=4.  SIGPH=0.  SIGA=1.
  FMIN=0.00  FLOW=0.026  FHIGH=2.47  FMAX=2.60  # (cosine filter)

# Time step and time interval for the Fast Fourier Transform
  DT=0.0390625  NFFT=2048

# Computation of synthetic seismograms
  GREEN='tcgreene.out' SS='tc-ssec.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
  GREEN='tcgreenw.out' SS='tc-sswc.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
  GREEN='tcgreenq.out' SS='tc-ssqc.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
  GREEN='tcgreena.out' SS='tc-ssac.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms
  GREEN='tcgreeni.out' SS='tc-ssic.gse'
  greenss: 'tc.h' /          # response function
  ss:      'tc.h' /          # synthetic seismograms

# Plotting seismograms
  SS='tc-ssic.gse'   KOLOR=2
  SS1='tc-ssac.gse'  KOLOR1=4
  SS2='tc-ssqc.gse'  KOLOR2=19
  SS3='tc-sswc.gse'  KOLOR3=3
  SS4='tc-ssec.gse'  KOLOR4=1
  SPTMIN=32.  SPTMAX=46.  SPTLEN=14.0  SPTDIV=14  SPTSUB=10
  KODESP=0    SPXLEN=7.0  NORMSP=1     SPAMP=3.5  SPCHRH=0.3
  SP1='tc-ss1c.ps'  SP2='          '  SP3=' '
  sp:      'tc.h' /          # seismogram plotting
  SPTDIV=-14
  SP1='          '  SP2='tc-ss2c.ps'  SP3=' '
  sp:      'tc.h' /          # seismogram plotting


# Figure comparing the errors of four ray methods in frequency domain
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Comparisons inv(U1)*(U2-U3) are plotted, where U1 is unit matrix,
# U2 is the exact propagator matrix, and U3 is the analytic propagator
# matrix corresponding to the selected method

  GREENTC1='unit.dat'  GREENTC2='greentce.out'

  OF=0.001  DF=0.00025   NF=397
  tcgreen: 'tc.h' /        # analytic Green functions
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /
# Comparisons
  GREEN='tcgreenw.out' GREENTC='greentcw.out'  TCCOMP='errw1.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreenq.out' GREENTC='greentcq.out'  TCCOMP='errq1.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreena.out' GREENTC='greentca.out'  TCCOMP='erra1.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreeni.out' GREENTC='greentci.out'  TCCOMP='erri1.out'
  greentc: 'tc.h' /
  tccomp: tc.h /

  OF=0.1  DF=0.0025  NF=361
  tcgreen: 'tc.h' /        # analytic Green functions
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /
# Comparisons
  GREEN='tcgreenw.out' GREENTC='greentcw.out'  TCCOMP='errw2.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreenq.out' GREENTC='greentcq.out'  TCCOMP='errq2.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreena.out' GREENTC='greentca.out'  TCCOMP='erra2.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreeni.out' GREENTC='greentci.out'  TCCOMP='erri2.out'
  greentc: 'tc.h' /
  tccomp: tc.h /

  OF=1.0  DF=0.025  NF=361
  tcgreen: 'tc.h' /        # analytic Green functions
  tcgreen: 'tc.h' /
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /
# Comparisons
  GREEN='tcgreenw.out' GREENTC='greentcw.out'  TCCOMP='errw3.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreenq.out' GREENTC='greentcq.out'  TCCOMP='errq3.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreena.out' GREENTC='greentca.out'  TCCOMP='erra3.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  GREEN='tcgreeni.out' GREENTC='greentci.out'  TCCOMP='erri3.out'
  greentc: 'tc.h' /
  tccomp: tc.h /

# Changing reference velocity
  VREF2=6.675
  OF=0.001  DF=0.00025   NF=397  TCCOMP='err01.out'
  tcgreen: 'tc.h' /
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /
  GREEN='tcgreenq.out' GREENTC='greentc0.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  OF=0.1    DF=0.0025    NF=361  TCCOMP='err02.out'
  tcgreen: 'tc.h' /
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /
  GREEN='tcgreenq.out' GREENTC='greentc0.out'
  greentc: 'tc.h' /
  tccomp: tc.h /
  OF=1.0    DF=0.025     NF=361  TCCOMP='err03.out'
  tcgreen: 'tc.h' /
  GREEN='tcgreene.out' GREENTC='greentce.out'
  greentc: 'tc.h' /
  GREEN='tcgreenq.out' GREENTC='greentc0.out'
  greentc: 'tc.h' /
  tccomp: tc.h /

# Writing the PostScript figure
  copy.pl: tc-err1.pro                    tc-err.ps
  echo.pl: "stroke 1 0 0 setrgbcolor"   >>tc-err.ps
  append.pl: tc-err.ps erri1.out
  append.pl: tc-err.ps erri2.out
  append.pl: tc-err.ps erri3.out
  echo.pl: "stroke 0 0 1 setrgbcolor"   >>tc-err.ps
  append.pl: tc-err.ps erra1.out
  append.pl: tc-err.ps erra2.out
  append.pl: tc-err.ps erra3.out
  echo.pl: "stroke 1 0.8 0 setrgbcolor" >>tc-err.ps
  append.pl: tc-err.ps errq1.out
  append.pl: tc-err.ps errq2.out
  append.pl: tc-err.ps errq3.out
  echo.pl: "stroke 1 0.8 0 setrgbcolor" >>tc-err.ps
  append.pl: tc-err.ps err01.out
  append.pl: tc-err.ps err02.out
  append.pl: tc-err.ps err03.out
  echo.pl: "stroke 0 1 0 setrgbcolor"   >>tc-err.ps
  append.pl: tc-err.ps errw1.out
  append.pl: tc-err.ps errw2.out
  append.pl: tc-err.ps errw3.out
  append.pl: tc-err.ps tc-err2.pro

