[cig-commits] r13378 - in seismo/3D/ADJOINT_TOMO/iterate_adj: . SEM2D_iterate SEM2D_iterate/INPUT SEM2D_iterate/INPUT/BOUNDARIES SEM2D_iterate/INPUT/COLOR_MAPS SEM2D_iterate/PLOTTING SEM2D_iterate/PLOTTING/FIGURES SEM2D_iterate/gji_paper SEM2D_iterate/gji_paper/codes_18_06Aug2006 SEM2D_iterate/matlab SEM2D_iterate/src

carltape at geodynamics.org carltape at geodynamics.org
Sun Nov 23 17:23:55 PST 2008


Author: carltape
Date: 2008-11-23 17:23:54 -0800 (Sun, 23 Nov 2008)
New Revision: 13378

Added:
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/bird_boundaries
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/jennings.xy
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_coast
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_shelf
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/COLOR_MAPS/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/COLOR_MAPS/socal_color.cpt
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/README
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand15
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand30
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand40
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_005_island
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_067_nobasin
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_144_noisland
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_149_full
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/events_xy_pert.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/oms_shelf
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/sigma_0p1_pert.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand10.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand15.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand20.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand25.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N025.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N034.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_02.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_05.dat
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_sources.txt
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/Makefile
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/OUTPUT/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/DATA_FILES/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Example1_run_0100.pdf
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Example7_run_0700.pdf
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Examples_all.pdf
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/README
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_inversion.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_subspace.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/make_sac_files.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/multi_plot_rs.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_compare_seis.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_seis.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_wavefield.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_geometry.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_image.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_kernel.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_rs.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_16frames.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_ker_mod.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_model.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_smooth_func.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/README
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/Makefile
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/gll_library.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/lagrange_poly.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/numerical_recipes.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_cmap.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_constants.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_define_der_matrices.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_solver.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub2.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub3.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_variables.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_2wid.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_3wid.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper_source.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_talk.pl
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/axes_expand.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/colors.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/cpt2cmap.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/curvature.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/fontsize.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/gcvfctn.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/genfit.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/griddataXB.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/linefit.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ocv_carl.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_min_4.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_shift.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ridge_carl.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/theoryHyp.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_figs.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_poly.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_subspace.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wysiwyg.m
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/mod/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/obj/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/Makefile
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/gll_library.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/lagrange_poly.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/numerical_recipes.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/test_smooth.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_cmap.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants_gji2007.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_define_der_matrices.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_solver.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub2.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub3.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub4.f90
   seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_variables.f90
Modified:
   seismo/3D/ADJOINT_TOMO/iterate_adj/README
Log:
Checking in a 2D spectral-element method wave propagation code for testing inverse problems.  This is not a substitute for SPECFEM2D, the official 2D version.  This uses a SEM forward solver, but the emphasis is on testing inverse techniques.  There is a long README with seven examples to try.  Results from this code have been published in Tromp, Tape, and Liu (2005) and also Tape, Liu, and Tromp (2007).


Modified: seismo/3D/ADJOINT_TOMO/iterate_adj/README
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/README	2008-11-24 00:05:12 UTC (rev 13377)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/README	2008-11-24 01:23:54 UTC (rev 13378)
@@ -7,13 +7,17 @@
 measure_adj
 iterate_adj
 
-Several operations are done on pangu, like computing the Hessian matrix for the subspace method.  And several operations are done in Matlab, like choosing the damping parameter.
+Several operations are done on pangu, like computing the Hessian matrix for the subspace method.  And several operations are done in Matlab, like choosing the damping parameter.  Thus, the two main directories for these processes are:
 
-Thus, the two main directories for scripts are
+pangu           -- scripts are executed on a cluster
+matlab          -- scripts are executed NOT on a cluster
 
-pangu
-matlab
+Other directories are:
 
-The scripts in matlab are executed NOT on a cluster, while the scripts in pangu are.
+misfit_plot     -- directory for plotting seismogram comparisons from two different models
+UTILS           -- various scripts for ploting figures
+SEM2D_iterate   -- 2D test code for two inversion algorithms
+                      conjugate gradient
+                      source subspace method
 
 ---------------------

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/bird_boundaries
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/bird_boundaries	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/bird_boundaries	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,6278 @@
+> AF-AN                      Mueller et al. [1987]
+ -4.37900E-01  -5.48518E+01
+ -3.88257E-02  -5.46772E+01
+ +4.43182E-01  -5.44512E+01
+ +9.64534E-01  -5.48322E+01
+ +1.69481E+00  -5.43990E+01
+ +2.35975E+00  -5.40374E+01
+ +3.02542E+00  -5.36507E+01
+ +3.36894E+00  -5.38341E+01
+ +3.95638E+00  -5.41267E+01
+ +4.41458E+00  -5.44303E+01
+ +4.82661E+00  -5.41616E+01
+ +5.08372E+00  -5.43093E+01
+ +5.49469E+00  -5.45429E+01
+ +6.18373E+00  -5.41145E+01
+ +6.62540E+00  -5.38142E+01
+ +7.23729E+00  -5.41012E+01
+ +7.77235E+00  -5.43960E+01
+> AF-AN                      by Peter Bird   October 2001
+ +7.77235E+00  -5.43960E+01
+ +8.28834E+00  -5.40326E+01
+ +8.79876E+00  -5.36680E+01
+ +9.42869E+00  -5.32326E+01
+ +9.99306E+00  -5.27923E+01
+ +1.05424E+01  -5.30655E+01
+ +1.09748E+01  -5.33320E+01
+ +1.17084E+01  -5.27829E+01
+ +1.22989E+01  -5.23750E+01
+ +1.28951E+01  -5.19629E+01
+ +1.32042E+01  -5.21410E+01
+ +1.37876E+01  -5.24769E+01
+ +1.44633E+01  -5.19971E+01
+ +1.51124E+01  -5.23075E+01
+ +1.54280E+01  -5.20836E+01
+ +1.58223E+01  -5.17870E+01
+ +1.69072E+01  -5.21693E+01
+ +1.78063E+01  -5.24669E+01
+ +1.85374E+01  -5.27343E+01
+ +1.87125E+01  -5.25529E+01
+ +1.99938E+01  -5.28167E+01
+ +2.12504E+01  -5.29088E+01
+ +2.25042E+01  -5.30512E+01
+ +2.30753E+01  -5.30977E+01
+ +2.30214E+01  -5.32004E+01
+ +2.38862E+01  -5.33086E+01
+ +2.46851E+01  -5.34215E+01
+ +2.48726E+01  -5.33453E+01
+> AN-AF                      Lemaux et al. [2002]
+ +3.21258E+01  -4.69998E+01
+ +3.18654E+01  -4.72011E+01
+ +3.15885E+01  -4.76822E+01
+ +3.13065E+01  -4.81627E+01
+ +3.10081E+01  -4.85871E+01
+ +3.07046E+01  -4.90106E+01
+ +3.03617E+01  -4.92155E+01
+ +3.00060E+01  -4.96108E+01
+ +2.97115E+01  -4.99335E+01
+ +2.93431E+01  -5.05070E+01
+ +2.89688E+01  -5.11373E+01
+ +2.86054E+01  -5.17716E+01
+ +2.84027E+01  -5.22771E+01
+ +2.83122E+01  -5.25400E+01
+ +2.81108E+01  -5.29037E+01
+ +2.74795E+01  -5.27708E+01
+ +2.73704E+01  -5.26730E+01
+ +2.73221E+01  -5.25472E+01
+ +2.67131E+01  -5.23780E+01
+ +2.65129E+01  -5.26201E+01
+ +2.63382E+01  -5.30650E+01
+ +2.61809E+01  -5.34288E+01
+ +2.59869E+01  -5.35818E+01
+ +2.58614E+01  -5.34799E+01
+ +2.56475E+01  -5.34100E+01
+ +2.51797E+01  -5.34441E+01
+ +2.48726E+01  -5.33453E+01
+> SO-AN                      Lemaux et al. [2002]
+ +3.21258E+01  -4.69998E+01
+ +3.31739E+01  -4.72644E+01
+ +3.33585E+01  -4.68055E+01
+ +3.35400E+01  -4.63464E+01
+ +3.38184E+01  -4.59791E+01
+ +3.39824E+01  -4.60812E+01
+ +3.40869E+01  -4.60899E+01
+ +3.42672E+01  -4.62123E+01
+ +3.45037E+01  -4.62216E+01
+ +3.47040E+01  -4.59714E+01
+ +3.48682E+01  -4.54657E+01
+ +3.50145E+01  -4.51058E+01
+ +3.51819E+01  -4.48555E+01
+ +3.56603E+01  -4.48660E+01
+ +3.59729E+01  -4.49607E+01
+ +3.63029E+01  -4.49665E+01
+ +3.66774E+01  -4.49197E+01
+ +3.70855E+01  -4.48043E+01
+ +3.75083E+01  -4.48753E+01
+ +3.80827E+01  -4.46188E+01
+> SO-AN                      Mueller et al. [1987]
+ +3.80827E+01  -4.46188E+01
+ +3.81937E+01  -4.44010E+01
+ +3.83383E+01  -4.40547E+01
+ +3.90729E+01  -4.41648E+01
+ +3.92673E+01  -4.37257E+01
+ +3.94588E+01  -4.32862E+01
+ +4.05058E+01  -4.34376E+01
+ +4.15578E+01  -4.35794E+01
+ +4.16859E+01  -4.31174E+01
+ +4.18120E+01  -4.26553E+01
+ +4.24686E+01  -4.27299E+01
+ +4.25719E+01  -4.22602E+01
+ +4.26737E+01  -4.17904E+01
+ +4.27740E+01  -4.13205E+01
+ +4.28729E+01  -4.08505E+01
+ +4.40092E+01  -4.09150E+01
+ +4.40230E+01  -4.06708E+01
+ +4.46858E+01  -4.06911E+01
+ +4.47160E+01  -4.03689E+01
+ +4.53027E+01  -4.03659E+01
+ +4.53318E+01  -4.01085E+01
+ +4.60744E+01  -4.01190E+01
+ +4.61602E+01  -3.94945E+01
+ +4.62444E+01  -3.88699E+01
+ +4.71353E+01  -3.87637E+01
+ +4.80234E+01  -3.86507E+01
+ +4.80171E+01  -3.84780E+01
+ +4.86326E+01  -3.80142E+01
+ +4.90344E+01  -3.79999E+01
+ +4.90366E+01  -3.77917E+01
+ +4.99451E+01  -3.77902E+01
+ +4.99622E+01  -3.75968E+01
+ +5.08233E+01  -3.75799E+01
+ +5.08270E+01  -3.74507E+01
+ +5.15548E+01  -3.74415E+01
+ +5.22827E+01  -3.74322E+01
+ +5.23106E+01  -3.67973E+01
+ +5.23380E+01  -3.61624E+01
+ +5.29023E+01  -3.61530E+01
+ +5.34665E+01  -3.61409E+01
+ +5.34706E+01  -3.55167E+01
+ +5.42161E+01  -3.53024E+01
+ +5.42551E+01  -3.45416E+01
+ +5.52747E+01  -3.45605E+01
+ +5.53010E+01  -3.42872E+01
+ +5.56987E+01  -3.42350E+01
+ +5.57379E+01  -3.36528E+01
+ +5.64006E+01  -3.36268E+01
+ +5.70607E+01  -3.35542E+01
+ +5.70912E+01  -3.28350E+01
+ +5.71223E+01  -3.23028E+01
+ +5.71530E+01  -3.17706E+01
+ +5.78000E+01  -3.17220E+01
+ +5.84563E+01  -3.16910E+01
+ +5.85299E+01  -3.10553E+01
+ +5.91667E+01  -3.10497E+01
+ +5.91880E+01  -3.05671E+01
+ +6.00054E+01  -3.05607E+01
+ +6.07628E+01  -3.05315E+01
+ +6.07473E+01  -3.00145E+01
+ +6.07624E+01  -2.99990E+01
+ +6.07864E+01  -2.94652E+01
+ +6.08102E+01  -2.89313E+01
+ +6.15322E+01  -2.89199E+01
+ +6.15176E+01  -2.87772E+01
+ +6.21619E+01  -2.88114E+01
+ +6.21351E+01  -2.84896E+01
+ +6.27462E+01  -2.84585E+01
+ +6.27030E+01  -2.81525E+01
+ +6.32112E+01  -2.81640E+01
+ +6.31942E+01  -2.80214E+01
+ +6.36211E+01  -2.80388E+01
+ +6.36037E+01  -2.78313E+01
+ +6.44669E+01  -2.78175E+01
+ +6.53321E+01  -2.78122E+01
+ +6.53475E+01  -2.75141E+01
+ +6.63590E+01  -2.75145E+01
+ +6.63730E+01  -2.72811E+01
+ +6.71290E+01  -2.72692E+01
+ +6.71555E+01  -2.68674E+01
+ +6.74240E+01  -2.68699E+01
+ +6.74333E+01  -2.65715E+01
+ +6.79622E+01  -2.65830E+01
+ +6.79791E+01  -2.62906E+01
+ +6.86219E+01  -2.62625E+01
+ +6.85979E+01  -2.61206E+01
+ +6.88197E+01  -2.61410E+01
+ +6.88294E+01  -2.60089E+01
+ +6.91500E+01  -2.59933E+01
+ +6.91379E+01  -2.57843E+01
+ +6.94603E+01  -2.57822E+01
+ +6.94900E+01  -2.56762E+01
+ +6.99595E+01  -2.56512E+01
+> SO-IN                      Mueller et al. [1987]
+ +5.82392E+01  +1.27455E+01
+ +5.78675E+01  +1.30023E+01
+ +5.76392E+01  +1.31377E+01
+ +5.77327E+01  +1.33090E+01
+ +5.78096E+01  +1.34509E+01
+ +5.76891E+01  +1.35225E+01
+ +5.74775E+01  +1.36430E+01
+ +5.73015E+01  +1.37400E+01
+ +5.72990E+01  +1.37718E+01
+ +5.71397E+01  +1.38476E+01
+ +5.69688E+01  +1.39372E+01
+ +5.70372E+01  +1.40681E+01
+ +5.69031E+01  +1.41407E+01
+ +5.67616E+01  +1.42076E+01
+ +5.68188E+01  +1.43021E+01
+ +5.62652E+01  +1.46232E+01
+> AU-SO                      Mueller et al. [1987]
+ +6.82738E+01  -6.81090E+00
+ +6.78113E+01  -7.25250E+00
+ +6.80731E+01  -7.64768E+00
+ +6.76424E+01  -8.02709E+00
+ +6.80390E+01  -8.49189E+00
+ +6.75648E+01  -8.88140E+00
+ +6.70896E+01  -9.27031E+00
+ +6.73780E+01  -9.62999E+00
+ +6.69195E+01  -9.99041E+00
+ +6.64600E+01  -1.03502E+01
+ +6.67874E+01  -1.07620E+01
+ +6.61674E+01  -1.12100E+01
+ +6.64182E+01  -1.15590E+01
+ +6.56978E+01  -1.20185E+01
+ +6.60330E+01  -1.24258E+01
+ +6.63692E+01  -1.28327E+01
+ +6.58205E+01  -1.32681E+01
+ +6.62097E+01  -1.37773E+01
+ +6.59278E+01  -1.39791E+01
+ +6.62076E+01  -1.43387E+01
+ +6.64883E+01  -1.46980E+01
+ +6.68882E+01  -1.52696E+01
+ +6.72902E+01  -1.58215E+01
+ +6.73827E+01  -1.59419E+01
+ +6.70330E+01  -1.61389E+01
+ +6.74105E+01  -1.66587E+01
+ +6.67081E+01  -1.70901E+01
+ +6.61428E+01  -1.74501E+01
+ +6.55424E+01  -1.77830E+01
+ +6.50073E+01  -1.80579E+01
+ +6.52639E+01  -1.84432E+01
+ +6.55217E+01  -1.88281E+01
+ +6.60333E+01  -1.95775E+01
+ +6.64280E+01  -2.00783E+01
+ +6.67513E+01  -1.98703E+01
+ +6.70404E+01  -2.02181E+01
+ +6.73095E+01  -2.00725E+01
+ +6.75930E+01  -2.03689E+01
+ +6.77679E+01  -2.02800E+01
+ +6.78967E+01  -2.04690E+01
+ +6.82125E+01  -2.02907E+01
+ +6.85592E+01  -2.07119E+01
+ +6.82768E+01  -2.08777E+01
+ +6.86529E+01  -2.14495E+01
+ +6.92017E+01  -2.20877E+01
+ +6.87967E+01  -2.23870E+01
+ +6.91621E+01  -2.28305E+01
+ +6.95577E+01  -2.33731E+01
+ +6.98497E+01  -2.37087E+01
+ +6.94016E+01  -2.40396E+01
+ +6.96804E+01  -2.43686E+01
+ +6.99393E+01  -2.46785E+01
+ +6.95921E+01  -2.49701E+01
+ +7.00896E+01  -2.54825E+01
+ +6.99595E+01  -2.56512E+01
+> EU-AF                      W part   by Peter Bird   1999
+ -2.97698E+01  +3.93996E+01
+ -2.93350E+01  +3.93150E+01
+ -2.92971E+01  +3.92554E+01
+ -2.92603E+01  +3.92502E+01
+ -2.91881E+01  +3.92786E+01
+ -2.91472E+01  +3.92937E+01
+ -2.90904E+01  +3.93232E+01
+ -2.90495E+01  +3.93382E+01
+ -2.89819E+01  +3.93656E+01
+ -2.89505E+01  +3.93789E+01
+ -2.88946E+01  +3.94120E+01
+ -2.88529E+01  +3.93725E+01
+ -2.87812E+01  +3.92993E+01
+ -2.87454E+01  +3.92626E+01
+ -2.86863E+01  +3.92144E+01
+ -2.86660E+01  +3.91790E+01
+ -2.86192E+01  +3.91208E+01
+ -2.85665E+01  +3.91299E+01
+ -2.84836E+01  +3.91558E+01
+ -2.84522E+01  +3.91339E+01
+ -2.84204E+01  +3.90927E+01
+ -2.83955E+01  +3.90580E+01
+ -2.83649E+01  +3.90204E+01
+ -2.83421E+01  +3.89931E+01
+ -2.82919E+01  +3.89394E+01
+ -2.82155E+01  +3.89524E+01
+ -2.81199E+01  +3.89685E+01
+ -2.80588E+01  +3.89827E+01
+ -2.79546E+01  +3.90041E+01
+ -2.77933E+01  +3.89998E+01
+ -2.77223E+01  +3.89416E+01
+ -2.76797E+01  +3.89136E+01
+ -2.76061E+01  +3.88635E+01
+ -2.75588E+01  +3.88363E+01
+ -2.74844E+01  +3.87824E+01
+ -2.72394E+01  +3.87796E+01
+ -2.72033E+01  +3.86999E+01
+ -2.71743E+01  +3.86658E+01
+ -2.71290E+01  +3.86070E+01
+ -2.70895E+01  +3.85706E+01
+ -2.70289E+01  +3.84911E+01
+ -2.70068E+01  +3.84635E+01
+ -2.69408E+01  +3.84003E+01
+ -2.69006E+01  +3.83601E+01
+ -2.68299E+01  +3.82782E+01
+ -2.67180E+01  +3.84202E+01
+ -2.66474E+01  +3.83576E+01
+ -2.66141E+01  +3.83240E+01
+ -2.65323E+01  +3.82554E+01
+ -2.64943E+01  +3.82225E+01
+ -2.64166E+01  +3.81493E+01
+ -2.63787E+01  +3.81164E+01
+ -2.63021E+01  +3.80468E+01
+ -2.61714E+01  +3.80360E+01
+ -2.60752E+01  +3.79655E+01
+ -2.60432E+01  +3.79355E+01
+ -2.59162E+01  +3.78386E+01
+ -2.58081E+01  +3.78783E+01
+ -2.57341E+01  +3.78159E+01
+ -2.56984E+01  +3.77902E+01
+ -2.56332E+01  +3.77225E+01
+ -2.55384E+01  +3.78181E+01
+ -2.54638E+01  +3.77517E+01
+ -2.54265E+01  +3.77185E+01
+ -2.53547E+01  +3.76633E+01
+ -2.52671E+01  +3.77692E+01
+ -2.51013E+01  +3.76463E+01
+ -2.49835E+01  +3.76441E+01
+ -2.49315E+01  +3.76091E+01
+ -2.48915E+01  +3.75839E+01
+ -2.48451E+01  +3.75519E+01
+ -2.48164E+01  +3.75328E+01
+ -2.47748E+01  +3.75001E+01
+ -2.47332E+01  +3.74673E+01
+ -2.46669E+01  +3.74110E+01
+ -2.47022E+01  +3.73519E+01
+ -2.47379E+01  +3.72733E+01
+ -2.47495E+01  +3.72174E+01
+ -2.46805E+01  +3.71267E+01
+ -2.46345E+01  +3.70946E+01
+ -2.45541E+01  +3.70172E+01
+ -2.45002E+01  +3.69707E+01
+ -2.44337E+01  +3.69105E+01
+ -2.43846E+01  +3.68633E+01
+ -2.43111E+01  +3.67925E+01
+ -2.42554E+01  +3.67810E+01
+ -2.41461E+01  +3.67885E+01
+ -2.40456E+01  +3.67548E+01
+ -2.35697E+01  +3.66459E+01
+ -2.28933E+01  +3.67020E+01
+ -2.22160E+01  +3.67543E+01
+ -2.15072E+01  +3.68197E+01
+ -2.07973E+01  +3.68809E+01
+ -2.02403E+01  +3.69543E+01
+ -1.96823E+01  +3.70251E+01
+ -1.86180E+01  +3.73070E+01
+ -1.81244E+01  +3.74657E+01
+ -1.75843E+01  +3.75034E+01
+ -1.67420E+01  +3.74354E+01
+ -1.58415E+01  +3.72966E+01
+ -1.53865E+01  +3.72117E+01
+ -1.51427E+01  +3.70206E+01
+ -1.44109E+01  +3.72101E+01
+ -1.36754E+01  +3.73950E+01
+ -1.29035E+01  +3.68638E+01
+ -1.21424E+01  +3.63276E+01
+ -1.15854E+01  +3.58512E+01
+ -1.09233E+01  +3.60984E+01
+ -1.04287E+01  +3.63916E+01
+ -9.97685E+00  +3.66514E+01
+ -9.54521E+00  +3.64296E+01
+ -8.78455E+00  +3.60509E+01
+ -8.03122E+00  +3.56675E+01
+ -7.19261E+00  +3.52729E+01
+ -6.73029E+00  +3.50633E+01
+ -6.06375E+00  +3.47839E+01
+ -6.03973E+00  +3.45174E+01
+ -6.00024E+00  +3.42634E+01
+ -5.80797E+00  +3.40191E+01
+ -5.39658E+00  +3.39850E+01
+ -5.07226E+00  +3.40783E+01
+ -4.70562E+00  +3.40681E+01
+ -4.05645E+00  +3.41993E+01
+ -3.78187E+00  +3.50136E+01
+ -3.74936E+00  +3.55962E+01
+ -3.29595E+00  +3.58577E+01
+ -2.89332E+00  +3.60184E+01
+ -2.57291E+00  +3.61053E+01
+ -1.99172E+00  +3.58985E+01
+ -1.51624E+00  +3.57709E+01
+ -7.47757E-01  +3.57757E+01
+ +3.04743E-03  +3.59040E+01
+ +6.67028E-01  +3.60723E+01
+ +1.24471E+00  +3.62823E+01
+ +1.97018E+00  +3.65026E+01
+ +2.37988E+00  +3.65942E+01
+ +3.45358E+00  +3.68509E+01
+ +4.29653E+00  +3.69695E+01
+ +5.14204E+00  +3.70821E+01
+ +5.97383E+00  +3.71540E+01
+ +6.78405E+00  +3.73219E+01
+> EU-AF                      by Peter Bird   2002.03
+ +6.78405E+00  +3.73219E+01
+ +7.21517E+00  +3.73203E+01
+ +7.80465E+00  +3.73582E+01
+ +8.26517E+00  +3.74675E+01
+ +8.62697E+00  +3.77896E+01
+ +8.94209E+00  +3.82117E+01
+ +9.26382E+00  +3.83410E+01
+ +9.70015E+00  +3.84698E+01
+ +1.00893E+01  +3.85717E+01
+ +1.03732E+01  +3.86850E+01
+> EU\AF                      by Peter Bird   2002.03
+ +1.03732E+01  +3.86850E+01
+ +1.06091E+01  +3.88209E+01
+ +1.08274E+01  +3.89939E+01
+ +1.11176E+01  +3.90672E+01
+ +1.13626E+01  +3.90748E+01
+ +1.16589E+01  +3.90327E+01
+ +1.17777E+01  +3.89344E+01
+ +1.20574E+01  +3.88781E+01
+ +1.24335E+01  +3.88487E+01
+ +1.27076E+01  +3.86004E+01
+ +1.33137E+01  +3.86105E+01
+ +1.38115E+01  +3.86250E+01
+ +1.41139E+01  +3.86953E+01
+ +1.45145E+01  +3.87653E+01
+> EU-AF                      by Peter Bird   2002.03
+ +1.45145E+01  +3.87653E+01
+ +1.51752E+01  +3.82924E+01
+ +1.54993E+01  +3.84014E+01
+ +1.56387E+01  +3.82993E+01
+ +1.55511E+01  +3.81136E+01
+ +1.54207E+01  +3.78857E+01
+ +1.53444E+01  +3.76152E+01
+ +1.53751E+01  +3.73401E+01
+> EU/AF                      by Peter Bird   2002.03
+ +1.53751E+01  +3.73401E+01
+ +1.58319E+01  +3.72743E+01
+ +1.62365E+01  +3.73088E+01
+ +1.68237E+01  +3.73985E+01
+ +1.71676E+01  +3.75026E+01
+ +1.74195E+01  +3.77008E+01
+ +1.76117E+01  +3.79929E+01
+ +1.77731E+01  +3.82855E+01
+ +1.78447E+01  +3.84615E+01
+ +1.80307E+01  +3.85162E+01
+ +1.80857E+01  +3.87941E+01
+ +1.80621E+01  +3.90063E+01
+ +1.79599E+01  +3.91696E+01
+> EU-AF                      by Peter Bird   2002.03
+ +1.79599E+01  +3.91696E+01
+ +1.83644E+01  +3.89474E+01
+ +1.88950E+01  +3.86942E+01
+ +1.95844E+01  +3.82716E+01
+ +2.00000E+01  +3.79075E+01
+> IN-SO                      Mueller et al. [1987]
+ +5.82392E+01  +1.27455E+01
+ +5.80174E+01  +1.22835E+01
+ +5.77963E+01  +1.18213E+01
+ +5.75760E+01  +1.13589E+01
+ +5.73564E+01  +1.08963E+01
+ +5.71375E+01  +1.04336E+01
+ +5.69192E+01  +9.97076E+00
+ +5.69775E+01  +9.85724E+00
+ +5.70289E+01  +9.85747E+00
+ +5.72606E+01  +9.68141E+00
+ +5.74906E+01  +9.94156E+00
+ +5.80630E+01  +9.53244E+00
+ +5.80184E+01  +9.45008E+00
+ +5.82625E+01  +9.29259E+00
+ +5.81476E+01  +9.08978E+00
+ +5.84302E+01  +8.86262E+00
+ +5.82514E+01  +8.64690E+00
+ +5.86106E+01  +8.40075E+00
+ +5.89183E+01  +8.16694E+00
+ +5.88800E+01  +8.09719E+00
+ +5.93092E+01  +7.76825E+00
+ +5.92197E+01  +7.67308E+00
+ +5.96997E+01  +7.31217E+00
+ +6.01789E+01  +6.95076E+00
+ +6.00383E+01  +6.76686E+00
+ +6.06701E+01  +6.30983E+00
+ +6.11417E+01  +5.90952E+00
+ +6.16573E+01  +5.48967E+00
+ +6.15293E+01  +5.26156E+00
+ +6.19997E+01  +4.91131E+00
+ +6.24568E+01  +4.52272E+00
+ +6.30023E+01  +4.10805E+00
+ +6.28678E+01  +3.89294E+00
+ +6.33307E+01  +3.63067E+00
+ +6.33882E+01  +3.70015E+00
+ +6.38192E+01  +3.48212E+00
+ +6.38898E+01  +3.60222E+00
+ +6.46181E+01  +3.21695E+00
+ +6.46822E+01  +3.29895E+00
+ +6.52128E+01  +2.92078E+00
+ +6.54890E+01  +3.29907E+00
+ +6.59626E+01  +2.97150E+00
+ +6.63795E+01  +2.75200E+00
+ +6.61794E+01  +2.39253E+00
+ +6.59923E+01  +2.05200E+00
+ +6.63328E+01  +1.85871E+00
+ +6.66728E+01  +1.62094E+00
+ +6.64925E+01  +1.33138E+00
+ +6.68698E+01  +1.06795E+00
+ +6.66573E+01  +7.22009E-01
+ +6.71594E+01  +3.37135E-01
+ +6.68392E+01  -3.88400E-02
+ +6.72089E+01  -3.39840E-01
+ +6.70231E+01  -5.77879E-01
+ +6.76620E+01  -1.03960E+00
+ +6.73671E+01  -1.43996E+00
+ +6.79291E+01  -1.91296E+00
+ +6.77884E+01  -2.08765E+00
+ +6.82490E+01  -2.54022E+00
+ +6.78921E+01  -2.88800E+00
+ +6.82702E+01  -3.35132E+00
+ +6.86672E+01  -3.77068E+00
+ +6.83485E+01  -4.11762E+00
+ +6.87510E+01  -4.54877E+00
+ +6.81985E+01  -5.04193E+00
+ +6.86069E+01  -5.47188E+00
+ +6.82191E+01  -5.89099E+00
+ +6.77823E+01  -6.25933E+00
+ +6.82738E+01  -6.81090E+00
+> NA-AF                      Mueller et al. [1987]
+ -4.67658E+01  +1.54506E+01
+ -4.66476E+01  +1.60187E+01
+ -4.65287E+01  +1.65868E+01
+ -4.65887E+01  +1.66067E+01
+ -4.64982E+01  +1.70865E+01
+ -4.64072E+01  +1.75663E+01
+ -4.65202E+01  +1.75883E+01
+ -4.63907E+01  +1.84220E+01
+ -4.63182E+01  +1.84215E+01
+ -4.62243E+01  +1.89351E+01
+ -4.61844E+01  +1.89319E+01
+ -4.60932E+01  +1.93773E+01
+ -4.60015E+01  +1.98227E+01
+ -4.59398E+01  +1.98022E+01
+ -4.57737E+01  +2.06180E+01
+ -4.55570E+01  +2.05958E+01
+ -4.54187E+01  +2.12217E+01
+ -4.55152E+01  +2.12465E+01
+ -4.53853E+01  +2.18223E+01
+ -4.52483E+01  +2.18064E+01
+ -4.51574E+01  +2.23898E+01
+ -4.50658E+01  +2.29731E+01
+ -4.50239E+01  +2.29632E+01
+ -4.49245E+01  +2.36459E+01
+ -4.56993E+01  +2.37836E+01
+ -4.64758E+01  +2.39174E+01
+ -4.61961E+01  +2.45974E+01
+ -4.61188E+01  +2.45904E+01
+ -4.57915E+01  +2.52542E+01
+ -4.54988E+01  +2.51918E+01
+ -4.52960E+01  +2.56367E+01
+ -4.50917E+01  +2.60814E+01
+ -4.48989E+01  +2.60554E+01
+ -4.48163E+01  +2.62700E+01
+ -4.48666E+01  +2.62796E+01
+ -4.46870E+01  +2.67668E+01
+ -4.45059E+01  +2.72538E+01
+ -4.43831E+01  +2.72355E+01
+ -4.42031E+01  +2.76713E+01
+ -4.40217E+01  +2.81069E+01
+ -4.39423E+01  +2.81049E+01
+ -4.35632E+01  +2.88108E+01
+ -4.34828E+01  +2.88021E+01
+ -4.30882E+01  +2.94691E+01
+ -4.30373E+01  +2.94714E+01
+ -4.27286E+01  +3.00697E+01
+ -4.21364E+01  +2.99733E+01
+ -4.17857E+01  +3.06056E+01
+ -4.14304E+01  +3.12370E+01
+ -4.11836E+01  +3.11941E+01
+ -4.07100E+01  +3.18173E+01
+ -4.05526E+01  +3.18025E+01
+ -4.01293E+01  +3.24440E+01
+ -3.96999E+01  +3.30841E+01
+ -3.95860E+01  +3.30673E+01
+ -3.93993E+01  +3.37676E+01
+ -3.85972E+01  +3.36370E+01
+ -3.77975E+01  +3.35012E+01
+ -3.76776E+01  +3.37362E+01
+ -3.75328E+01  +3.37052E+01
+ -3.73364E+01  +3.41362E+01
+ -3.72446E+01  +3.41238E+01
+ -3.70461E+01  +3.45669E+01
+ -3.68618E+01  +3.45542E+01
+ -3.67846E+01  +3.47122E+01
+ -3.66231E+01  +3.46929E+01
+ -3.63731E+01  +3.52798E+01
+ -3.55584E+01  +3.51477E+01
+ -3.47464E+01  +3.50102E+01
+ -3.44595E+01  +3.56246E+01
+ -3.43354E+01  +3.56160E+01
+ -3.41424E+01  +3.60794E+01
+ -3.40568E+01  +3.60713E+01
+ -3.39816E+01  +3.62212E+01
+ -3.37717E+01  +3.61850E+01
+ -3.35947E+01  +3.67422E+01
+ -3.33135E+01  +3.66910E+01
+ -3.32246E+01  +3.69408E+01
+ -3.30049E+01  +3.69159E+01
+ -3.29431E+01  +3.70654E+01
+ -3.27077E+01  +3.70333E+01
+ -3.26456E+01  +3.71763E+01
+ -3.23946E+01  +3.71369E+01
+ -3.22826E+01  +3.73915E+01
+ -3.15164E+01  +3.72823E+01
+ -3.13713E+01  +3.77049E+01
+ -3.10706E+01  +3.76802E+01
+ -3.06055E+01  +3.84025E+01
+ -3.04301E+01  +3.83883E+01
+ -3.01714E+01  +3.88880E+01
+ -2.99091E+01  +3.93871E+01
+ -2.97698E+01  +3.93996E+01
+> AF-SA                      Mueller et al. [1987]
+ -4.67658E+01  +1.54506E+01
+ -4.59475E+01  +1.53604E+01
+ -4.51300E+01  +1.52673E+01
+ -4.51362E+01  +1.46467E+01
+ -4.51423E+01  +1.40261E+01
+ -4.50614E+01  +1.39917E+01
+ -4.50493E+01  +1.33358E+01
+ -4.50373E+01  +1.26799E+01
+ -4.42620E+01  +1.26256E+01
+ -4.42775E+01  +1.21008E+01
+ -4.38845E+01  +1.20854E+01
+ -4.39026E+01  +1.15062E+01
+ -4.39206E+01  +1.09270E+01
+ -4.34482E+01  +1.09055E+01
+ -4.29758E+01  +1.08832E+01
+ -4.25035E+01  +1.08602E+01
+ -4.20313E+01  +1.08365E+01
+ -4.15592E+01  +1.08121E+01
+ -4.10871E+01  +1.07869E+01
+ -4.10829E+01  +9.97939E+00
+ -4.08615E+01  +9.97269E+00
+ -4.08648E+01  +9.38937E+00
+ -4.06402E+01  +9.37285E+00
+ -4.06522E+01  +8.84060E+00
+ -4.01196E+01  +8.81526E+00
+ -4.01408E+01  +8.21537E+00
+ -3.96608E+01  +8.19726E+00
+ -3.91808E+01  +8.17858E+00
+ -3.87009E+01  +8.15934E+00
+ -3.82210E+01  +8.13953E+00
+ -3.82065E+01  +7.70334E+00
+ -3.75356E+01  +7.67935E+00
+ -3.68648E+01  +7.65432E+00
+ -3.68514E+01  +7.40089E+00
+ -3.60577E+01  +7.36342E+00
+ -3.60469E+01  +7.02322E+00
+ -3.53665E+01  +6.93495E+00
+ -3.53629E+01  +6.61393E+00
+ -3.44937E+01  +6.61577E+00
+ -3.36244E+01  +6.61760E+00
+ -3.36203E+01  +6.10421E+00
+ -3.35136E+01  +6.07619E+00
+ -3.35068E+01  +5.64946E+00
+ -3.29780E+01  +5.64716E+00
+ -3.29198E+01  +4.80377E+00
+ -3.28617E+01  +3.96038E+00
+ -3.23870E+01  +3.98590E+00
+ -3.19122E+01  +4.01114E+00
+ -3.14374E+01  +4.03611E+00
+ -3.09625E+01  +4.06081E+00
+ -3.08868E+01  +3.25477E+00
+ -3.08113E+01  +2.44874E+00
+ -3.07358E+01  +1.64269E+00
+ -3.00269E+01  +1.60709E+00
+ -2.99203E+01  +7.97401E-01
+ -2.92096E+01  +8.48907E-01
+ -2.83465E+01  +9.53033E-01
+ -2.78309E+01  +1.00748E+00
+ -2.73153E+01  +1.06184E+00
+ -2.64740E+01  +1.15918E+00
+ -2.62887E+01  +4.98136E-01
+ -2.56591E+01  +5.56165E-01
+ -2.50294E+01  +6.14126E-01
+ -2.48206E+01  -2.44593E-01
+ -2.46117E+01  -1.10331E+00
+ -2.40507E+01  -1.03387E+00
+ -2.34897E+01  -9.64324E-01
+ -2.29355E+01  -8.80401E-01
+ -2.23813E+01  -7.96390E-01
+ -2.15437E+01  -6.80222E-01
+ -2.10168E+01  -5.88493E-01
+ -2.04899E+01  -4.96709E-01
+ -1.96747E+01  -3.33378E-01
+ -1.88497E+01  -1.76113E-01
+ -1.83693E+01  -7.27519E-02
+ -1.78889E+01  +3.06094E-02
+ -1.73229E+01  +1.49605E-01
+ -1.67569E+01  +2.68587E-01
+ -1.64982E+01  +2.98947E-01
+ -1.62522E+01  -5.56200E-01
+ -1.60372E+01  -5.19631E-01
+ -1.58406E+01  -1.14320E+00
+ -1.55652E+01  -1.07324E+00
+ -1.54103E+01  -1.49342E+00
+ -1.46594E+01  -1.30094E+00
+ -1.39087E+01  -1.10824E+00
+ -1.31580E+01  -9.15345E-01
+ -1.29298E+01  -1.50722E+00
+ -1.27014E+01  -2.09908E+00
+ -1.21641E+01  -1.94545E+00
+ -1.19989E+01  -2.40025E+00
+ -1.18336E+01  -2.85504E+00
+ -1.20293E+01  -3.01345E+00
+ -1.18975E+01  -3.49273E+00
+ -1.17655E+01  -3.97199E+00
+ -1.20968E+01  -4.10303E+00
+ -1.20386E+01  -4.58743E+00
+ -1.21445E+01  -4.60882E+00
+ -1.20185E+01  -5.02557E+00
+ -1.16044E+01  -4.94231E+00
+ -1.15161E+01  -5.41504E+00
+ -1.11669E+01  -5.37706E+00
+ -1.10222E+01  -5.93021E+00
+ -1.12671E+01  -6.02023E+00
+ -1.11805E+01  -6.75542E+00
+ -1.19933E+01  -6.96082E+00
+ -1.28068E+01  -7.16482E+00
+ -1.36210E+01  -7.36740E+00
+ -1.34894E+01  -7.88908E+00
+ -1.33574E+01  -8.41071E+00
+ -1.31911E+01  -8.37401E+00
+ -1.30230E+01  -9.22523E+00
+ -1.32482E+01  -9.27648E+00
+ -1.31663E+01  -9.79444E+00
+ -1.33151E+01  -9.82468E+00
+ -1.31736E+01  -1.06231E+01
+ -1.30313E+01  -1.14215E+01
+ -1.35243E+01  -1.15387E+01
+ -1.40177E+01  -1.16551E+01
+ -1.45115E+01  -1.17706E+01
+ -1.50058E+01  -1.18853E+01
+ -1.49077E+01  -1.23390E+01
+ -1.48611E+01  -1.23196E+01
+ -1.47910E+01  -1.26562E+01
+ -1.45501E+01  -1.25770E+01
+ -1.44102E+01  -1.32181E+01
+ -1.45996E+01  -1.32655E+01
+ -1.45391E+01  -1.37366E+01
+ -1.44784E+01  -1.42077E+01
+ -1.36428E+01  -1.40355E+01
+ -1.34352E+01  -1.48494E+01
+ -1.32261E+01  -1.56632E+01
+ -1.33835E+01  -1.56882E+01
+ -1.32386E+01  -1.62117E+01
+ -1.37702E+01  -1.63229E+01
+ -1.43024E+01  -1.64327E+01
+ -1.42381E+01  -1.67645E+01
+ -1.43688E+01  -1.67770E+01
+ -1.42242E+01  -1.73859E+01
+ -1.40786E+01  -1.79946E+01
+ -1.35189E+01  -1.78930E+01
+ -1.29598E+01  -1.77898E+01
+ -1.28598E+01  -1.82872E+01
+ -1.27593E+01  -1.87845E+01
+ -1.24772E+01  -1.87465E+01
+ -1.23703E+01  -1.93409E+01
+ -1.22626E+01  -1.99353E+01
+ -1.19446E+01  -1.98248E+01
+ -1.18522E+01  -2.02784E+01
+ -1.19708E+01  -2.02991E+01
+ -1.17632E+01  -2.11759E+01
+ -1.20066E+01  -2.12091E+01
+ -1.18495E+01  -2.17351E+01
+ -1.19359E+01  -2.17522E+01
+ -1.18192E+01  -2.21534E+01
+ -1.23643E+01  -2.22671E+01
+ -1.29102E+01  -2.23790E+01
+ -1.28511E+01  -2.26298E+01
+ -1.33398E+01  -2.27302E+01
+ -1.38293E+01  -2.28292E+01
+ -1.36637E+01  -2.35442E+01
+ -1.35703E+01  -2.35143E+01
+ -1.34259E+01  -2.41458E+01
+ -1.32801E+01  -2.47771E+01
+ -1.38106E+01  -2.48874E+01
+ -1.36632E+01  -2.56480E+01
+ -1.40485E+01  -2.57376E+01
+ -1.38156E+01  -2.65856E+01
+ -1.36896E+01  -2.65644E+01
+ -1.34823E+01  -2.74429E+01
+ -1.32716E+01  -2.83210E+01
+ -1.27456E+01  -2.82133E+01
+ -1.25326E+01  -2.89409E+01
+> AF-SA                      by Peter Bird   October 2001
+ -1.25326E+01  -2.89409E+01
+ -1.32624E+01  -2.90980E+01
+ -1.39902E+01  -2.92510E+01
+ -1.38201E+01  -2.98515E+01
+ -1.37159E+01  -2.98280E+01
+ -1.35428E+01  -3.04913E+01
+ -1.33666E+01  -3.11567E+01
+ -1.34988E+01  -3.11791E+01
+ -1.33714E+01  -3.16612E+01
+ -1.32453E+01  -3.21432E+01
+ -1.38830E+01  -3.22745E+01
+ -1.45229E+01  -3.24002E+01
+ -1.44461E+01  -3.28976E+01
+ -1.43668E+01  -3.34989E+01
+ -1.47018E+01  -3.35691E+01
+ -1.45151E+01  -3.40434E+01
+ -1.52741E+01  -3.42376E+01
+ -1.50834E+01  -3.46898E+01
+ -1.52659E+01  -3.47702E+01
+ -1.51000E+01  -3.51824E+01
+ -1.60274E+01  -3.53431E+01
+ -1.69619E+01  -3.54994E+01
+ -1.77032E+01  -3.56633E+01
+ -1.74191E+01  -3.60684E+01
+ -1.70847E+01  -3.64724E+01
+ -1.74404E+01  -3.65623E+01
+ -1.73331E+01  -3.69436E+01
+ -1.72335E+01  -3.73744E+01
+ -1.75331E+01  -3.74724E+01
+ -1.73878E+01  -3.80251E+01
+ -1.70505E+01  -3.84467E+01
+ -1.67985E+01  -3.84012E+01
+ -1.63610E+01  -3.85584E+01
+ -1.60438E+01  -3.88834E+01
+ -1.59651E+01  -3.93516E+01
+ -1.59224E+01  -3.96807E+01
+ -1.64146E+01  -3.97900E+01
+ -1.64698E+01  -4.02729E+01
+ -1.68674E+01  -4.03663E+01
+ -1.68166E+01  -4.07897E+01
+ -1.67436E+01  -4.11763E+01
+ -1.66780E+01  -4.15191E+01
+ -1.63316E+01  -4.18065E+01
+ -1.62146E+01  -4.23377E+01
+ -1.64299E+01  -4.28677E+01
+> AF-SA                      Mueller et al. [1987]
+ -1.64299E+01  -4.28677E+01
+ -1.63296E+01  -4.33870E+01
+ -1.62445E+01  -4.36835E+01
+ -1.60856E+01  -4.41319E+01
+ -1.59242E+01  -4.45800E+01
+ -1.57603E+01  -4.50279E+01
+ -1.55939E+01  -4.54756E+01
+ -1.48940E+01  -4.53714E+01
+ -1.47155E+01  -4.58985E+01
+ -1.38100E+01  -4.57972E+01
+ -1.35715E+01  -4.66878E+01
+ -1.33251E+01  -4.75778E+01
+ -1.26102E+01  -4.74714E+01
+ -1.18982E+01  -4.73605E+01
+ -1.11892E+01  -4.72452E+01
+ -1.04834E+01  -4.71256E+01
+ -1.02958E+01  -4.76487E+01
+ -1.01045E+01  -4.81715E+01
+ -9.90926E+00  -4.86939E+01
+ -9.70992E+00  -4.92160E+01
+ -8.92248E+00  -4.90912E+01
+ -8.13908E+00  -4.89610E+01
+ -8.02211E+00  -4.92826E+01
+ -7.96086E+00  -4.92702E+01
+ -7.63767E+00  -5.00587E+01
+ -7.43284E+00  -5.00013E+01
+ -7.15851E+00  -5.06096E+01
+ -6.15983E+00  -5.04171E+01
+ -5.16942E+00  -5.02161E+01
+ -4.94334E+00  -5.06749E+01
+ -4.71279E+00  -5.11333E+01
+ -4.47762E+00  -5.15912E+01
+ -4.23767E+00  -5.20486E+01
+ -3.95559E+00  -5.19788E+01
+ -3.44688E+00  -5.27640E+01
+ -2.91952E+00  -5.35469E+01
+ -2.37231E+00  -5.43274E+01
+ -1.38220E+00  -5.40533E+01
+ -9.14655E-01  -5.44535E+01
+ -4.37900E-01  -5.48518E+01
+> AU-AN                      Mueller et al. [1987]
+ +6.99595E+01  -2.56512E+01
+ +7.04086E+01  -2.60604E+01
+ +7.06654E+01  -2.59124E+01
+ +7.09943E+01  -2.61873E+01
+ +7.11354E+01  -2.60831E+01
+ +7.15800E+01  -2.64544E+01
+ +7.17166E+01  -2.63857E+01
+ +7.20656E+01  -2.66560E+01
+ +7.20084E+01  -2.67182E+01
+ +7.24626E+01  -2.71462E+01
+ +7.29202E+01  -2.75728E+01
+ +7.31227E+01  -2.74458E+01
+ +7.33995E+01  -2.76550E+01
+ +7.35342E+01  -2.75698E+01
+ +7.39685E+01  -2.79442E+01
+ +7.44058E+01  -2.83173E+01
+ +7.41922E+01  -2.85413E+01
+ +7.45917E+01  -2.89035E+01
+ +7.49940E+01  -2.92645E+01
+ +7.49376E+01  -2.93284E+01
+ +7.55539E+01  -2.98394E+01
+ +7.53641E+01  -3.00058E+01
+ +7.55149E+01  -3.01176E+01
+ +7.53926E+01  -3.02401E+01
+ +7.57972E+01  -3.05735E+01
+ +7.62045E+01  -3.09057E+01
+ +7.61481E+01  -3.09704E+01
+ +7.66894E+01  -3.14649E+01
+ +7.63948E+01  -3.17191E+01
+ +7.68124E+01  -3.20900E+01
+ +7.72334E+01  -3.24595E+01
+ +7.76578E+01  -3.28276E+01
+ +7.80858E+01  -3.31942E+01
+ +7.73518E+01  -3.38383E+01
+ +7.79166E+01  -3.43238E+01
+ +7.84879E+01  -3.48067E+01
+ +7.84423E+01  -3.48423E+01
+ +7.88035E+01  -3.51612E+01
+ +7.82011E+01  -3.56831E+01
+ +7.86899E+01  -3.60980E+01
+ +7.91839E+01  -3.65109E+01
+ +7.86063E+01  -3.69983E+01
+ +7.80213E+01  -3.74829E+01
+ +7.87061E+01  -3.80006E+01
+ +7.81815E+01  -3.83932E+01
+ +7.85293E+01  -3.86592E+01
+ +7.80731E+01  -3.90049E+01
+ +7.83839E+01  -3.92620E+01
+ +7.80024E+01  -3.95385E+01
+ +7.84254E+01  -3.99049E+01
+ +7.78245E+01  -4.03260E+01
+ +7.84837E+01  -4.08664E+01
+ +7.86586E+01  -4.08722E+01
+ +7.93191E+01  -4.13840E+01
+ +7.99900E+01  -4.18919E+01
+ +8.04635E+01  -4.15119E+01
+ +8.09315E+01  -4.11299E+01
+ +8.17520E+01  -4.17225E+01
+ +8.25877E+01  -4.23091E+01
+ +8.34390E+01  -4.28896E+01
+ +8.38533E+01  -4.25506E+01
+ +8.42631E+01  -4.22101E+01
+ +8.46686E+01  -4.18682E+01
+ +8.50697E+01  -4.15249E+01
+ +8.54665E+01  -4.11802E+01
+ +8.58592E+01  -4.08341E+01
+ +8.64020E+01  -4.11288E+01
+ +8.69497E+01  -4.14210E+01
+ +8.75023E+01  -4.17105E+01
+ +8.80599E+01  -4.19974E+01
+ +8.84884E+01  -4.16859E+01
+ +8.90106E+01  -4.19442E+01
+ +8.95370E+01  -4.22002E+01
+ +9.00677E+01  -4.24538E+01
+ +9.06027E+01  -4.27049E+01
+ +9.11420E+01  -4.29534E+01
+ +9.16857E+01  -4.31994E+01
+ +9.22337E+01  -4.34428E+01
+ +9.27862E+01  -4.36836E+01
+ +9.33431E+01  -4.39217E+01
+ +9.39044E+01  -4.41571E+01
+ +9.44702E+01  -4.43897E+01
+ +9.50405E+01  -4.46195E+01
+ +9.49257E+01  -4.48053E+01
+ +9.58064E+01  -4.51414E+01
+ +9.66975E+01  -4.54707E+01
+ +9.62738E+01  -4.59963E+01
+ +9.58420E+01  -4.65203E+01
+ +9.64580E+01  -4.67718E+01
+ +9.70797E+01  -4.70200E+01
+ +9.77072E+01  -4.72648E+01
+ +9.83404E+01  -4.75061E+01
+ +9.89794E+01  -4.77439E+01
+ +9.96243E+01  -4.79781E+01
+ +1.00202E+02  -4.72665E+01
+ +1.00817E+02  -4.74654E+01
+ +1.01436E+02  -4.76610E+01
+ +1.02060E+02  -4.78533E+01
+ +1.02688E+02  -4.80421E+01
+ +1.03321E+02  -4.82275E+01
+ +1.03959E+02  -4.84093E+01
+ +1.04601E+02  -4.85877E+01
+ +1.05247E+02  -4.87624E+01
+ +1.05898E+02  -4.89335E+01
+ +1.06554E+02  -4.91009E+01
+ +1.06692E+02  -4.88414E+01
+ +1.07486E+02  -4.90146E+01
+ +1.08285E+02  -4.91823E+01
+ +1.08240E+02  -4.92587E+01
+ +1.09351E+02  -4.95235E+01
+> AU-AN                      by Peter Bird   October 2001
+ +1.09351E+02  -4.95235E+01
+ +1.10472E+02  -4.97790E+01
+ +1.10868E+02  -4.98289E+01
+ +1.11129E+02  -4.98004E+01
+ +1.11363E+02  -4.99297E+01
+ +1.11666E+02  -5.00838E+01
+ +1.12967E+02  -5.02004E+01
+ +1.14024E+02  -5.03877E+01
+ +1.14362E+02  -4.98778E+01
+ +1.15500E+02  -4.99743E+01
+ +1.15988E+02  -4.98517E+01
+ +1.16256E+02  -4.95404E+01
+ +1.16635E+02  -4.92709E+01
+ +1.17523E+02  -4.96199E+01
+ +1.18194E+02  -4.98648E+01
+ +1.18547E+02  -4.98017E+01
+ +1.19366E+02  -4.99384E+01
+ +1.20273E+02  -5.00360E+01
+ +1.20516E+02  -4.95243E+01
+ +1.20842E+02  -4.88896E+01
+ +1.21555E+02  -4.90056E+01
+ +1.21437E+02  -4.96202E+01
+ +1.21866E+02  -4.97355E+01
+ +1.22224E+02  -4.98462E+01
+ +1.22553E+02  -4.98116E+01
+ +1.22797E+02  -4.97286E+01
+ +1.23013E+02  -4.95424E+01
+ +1.23328E+02  -4.95847E+01
+ +1.23771E+02  -4.91216E+01
+ +1.24007E+02  -4.89058E+01
+ +1.24213E+02  -4.88476E+01
+ +1.24607E+02  -4.89835E+01
+ +1.24992E+02  -4.91528E+01
+ +1.25125E+02  -4.93581E+01
+ +1.25262E+02  -4.95983E+01
+ +1.25896E+02  -4.97171E+01
+ +1.26074E+02  -4.94014E+01
+ +1.26264E+02  -4.90443E+01
+ +1.26434E+02  -4.86297E+01
+ +1.26861E+02  -4.86977E+01
+ +1.27313E+02  -4.87639E+01
+ +1.27243E+02  -4.92939E+01
+ +1.27196E+02  -4.96429E+01
+ +1.27143E+02  -4.99761E+01
+ +1.28312E+02  -5.01592E+01
+ +1.29412E+02  -5.03480E+01
+ +1.30569E+02  -5.05249E+01
+ +1.31256E+02  -5.06037E+01
+ +1.31515E+02  -5.02222E+01
+ +1.32261E+02  -5.02228E+01
+ +1.33465E+02  -5.03055E+01
+ +1.34245E+02  -5.03475E+01
+ +1.35026E+02  -5.03842E+01
+ +1.35246E+02  -5.02093E+01
+ +1.36226E+02  -5.02476E+01
+ +1.36946E+02  -5.02204E+01
+ +1.37700E+02  -5.02336E+01
+ +1.38401E+02  -5.02311E+01
+ +1.39110E+02  -5.02558E+01
+ +1.39645E+02  -5.02794E+01
+ +1.39733E+02  -5.11739E+01
+ +1.39813E+02  -5.18376E+01
+ +1.40323E+02  -5.17983E+01
+ +1.40400E+02  -5.22743E+01
+ +1.40478E+02  -5.27502E+01
+ +1.40584E+02  -5.35044E+01
+ +1.40659E+02  -5.38854E+01
+ +1.41451E+02  -5.40528E+01
+ +1.42250E+02  -5.42149E+01
+ +1.43778E+02  -5.42343E+01
+ +1.44282E+02  -5.47985E+01
+ +1.45401E+02  -5.47555E+01
+ +1.46881E+02  -5.46953E+01
+> AU-AN                      Mueller et al. [1987]
+ +1.46881E+02  -5.46953E+01
+ +1.47043E+02  -5.51749E+01
+ +1.47206E+02  -5.56536E+01
+ +1.47373E+02  -5.61321E+01
+ +1.47545E+02  -5.66104E+01
+ +1.47721E+02  -5.70884E+01
+ +1.47902E+02  -5.75662E+01
+ +1.48076E+02  -5.75271E+01
+ +1.48806E+02  -5.74358E+01
+ +1.49150E+02  -5.81044E+01
+ +1.49398E+02  -5.85518E+01
+ +1.49652E+02  -5.89988E+01
+ +1.50006E+02  -5.95704E+01
+ +1.50733E+02  -5.94753E+01
+ +1.51008E+02  -5.99442E+01
+ +1.51290E+02  -6.04126E+01
+ +1.52473E+02  -6.01764E+01
+ +1.53639E+02  -5.99299E+01
+ +1.54294E+02  -6.06813E+01
+ +1.54981E+02  -6.14294E+01
+ +1.55701E+02  -6.21738E+01
+ +1.56457E+02  -6.29143E+01
+ +1.57970E+02  -6.24781E+01
+ +1.59440E+02  -6.20259E+01
+ +1.60865E+02  -6.15586E+01
+ +1.61228E+02  -6.14567E+01
+> AN-NZ                      mostly Mueller et al. [1987]; edited by P. Bird   1999
+ -7.60062E+01  -4.56585E+01
+ -7.66746E+01  -4.56427E+01
+ -7.76607E+01  -4.57605E+01
+ -7.77640E+01  -4.55885E+01
+ -7.79902E+01  -4.50916E+01
+ -7.82065E+01  -4.44111E+01
+ -7.88933E+01  -4.45449E+01
+ -7.95858E+01  -4.46655E+01
+ -8.02811E+01  -4.47819E+01
+ -8.11065E+01  -4.48760E+01
+ -8.19346E+01  -4.49641E+01
+ -8.21377E+01  -4.44040E+01
+ -8.23507E+01  -4.36390E+01
+ -8.25089E+01  -4.28607E+01
+ -8.34475E+01  -4.29815E+01
+ -8.34538E+01  -4.28730E+01
+ -8.36037E+01  -4.22225E+01
+ -8.37162E+01  -4.16737E+01
+ -8.38269E+01  -4.11247E+01
+ -8.44870E+01  -4.11909E+01
+ -8.51484E+01  -4.12533E+01
+ -8.62401E+01  -4.13925E+01
+ -8.73364E+01  -4.15213E+01
+ -8.74171E+01  -4.12729E+01
+ -8.84467E+01  -4.13187E+01
+ -8.92496E+01  -4.13781E+01
+ -9.00540E+01  -4.14319E+01
+ -9.00876E+01  -4.10585E+01
+ -9.07391E+01  -4.10823E+01
+ -9.13910E+01  -4.11025E+01
+ -9.14756E+01  -4.07319E+01
+ -9.15122E+01  -4.02824E+01
+ -9.15483E+01  -3.98329E+01
+ -9.16035E+01  -3.93493E+01
+ -9.16579E+01  -3.88656E+01
+ -9.23397E+01  -3.89184E+01
+ -9.30225E+01  -3.89673E+01
+ -9.30748E+01  -3.84294E+01
+ -9.39963E+01  -3.84823E+01
+ -9.40931E+01  -3.77170E+01
+ -9.41298E+01  -3.70006E+01
+ -9.49095E+01  -3.69851E+01
+ -9.56889E+01  -3.69646E+01
+ -9.65515E+01  -3.69209E+01
+ -9.74131E+01  -3.68710E+01
+ -9.74017E+01  -3.62936E+01
+ -9.84167E+01  -3.61928E+01
+ -9.95318E+01  -3.61332E+01
+ -1.00645E+02  -3.60632E+01
+ -1.01286E+02  -3.59970E+01
+ -1.01926E+02  -3.59274E+01
+ -1.02565E+02  -3.58544E+01
+ -1.03202E+02  -3.57781E+01
+ -1.03998E+02  -3.56944E+01
+ -1.04793E+02  -3.56055E+01
+ -1.05391E+02  -3.55236E+01
+ -1.05988E+02  -3.54388E+01
+ -1.06666E+02  -3.53935E+01
+ -1.07343E+02  -3.53445E+01
+ -1.08071E+02  -3.52404E+01
+ -1.08797E+02  -3.51319E+01
+ -1.09259E+02  -3.45446E+01
+> PA-AN                      Mueller et al. [1987]
+ +1.61228E+02  -6.14567E+01
+ +1.61975E+02  -6.17630E+01
+ +1.62579E+02  -6.22128E+01
+ +1.63202E+02  -6.26599E+01
+ +1.63773E+02  -6.24746E+01
+ +1.64275E+02  -6.23219E+01
+ +1.64768E+02  -6.21772E+01
+ +1.65103E+02  -6.20772E+01
+ +1.65653E+02  -6.24727E+01
+ +1.65969E+02  -6.26676E+01
+ +1.66620E+02  -6.30869E+01
+ +1.66858E+02  -6.32206E+01
+ +1.67550E+02  -6.29712E+01
+ +1.68277E+02  -6.27732E+01
+ +1.68708E+02  -6.26321E+01
+ +1.69238E+02  -6.24461E+01
+ +1.69605E+02  -6.26762E+01
+ +1.70068E+02  -6.29724E+01
+ +1.70441E+02  -6.31488E+01
+ +1.71009E+02  -6.34473E+01
+ +1.71640E+02  -6.38072E+01
+ +1.72164E+02  -6.40974E+01
+ +1.72520E+02  -6.42561E+01
+ +1.73631E+02  -6.47379E+01
+ +1.74242E+02  -6.45079E+01
+ +1.74814E+02  -6.43149E+01
+ +1.75162E+02  -6.41741E+01
+ +1.75582E+02  -6.39840E+01
+ +1.76063E+02  -6.41878E+01
+ +1.76549E+02  -6.44101E+01
+ +1.76819E+02  -6.45060E+01
+ +1.77338E+02  -6.47362E+01
+ +1.77889E+02  -6.49749E+01
+ +1.78240E+02  -6.50791E+01
+ +1.78759E+02  -6.52740E+01
+ +1.79381E+02  -6.54773E+01
+ +1.79963E+02  -6.57385E+01
+ -1.79197E+02  -6.59859E+01
+ -1.78793E+02  -6.61632E+01
+ -1.77926E+02  -6.58623E+01
+ -1.77072E+02  -6.56069E+01
+ -1.75729E+02  -6.51825E+01
+ -1.75070E+02  -6.55050E+01
+ -1.74418E+02  -6.58352E+01
+ -1.73709E+02  -6.55061E+01
+ -1.72517E+02  -6.49783E+01
+ -1.71300E+02  -6.43564E+01
+ -1.70043E+02  -6.48585E+01
+ -1.69839E+02  -6.47637E+01
+ -1.69109E+02  -6.42448E+01
+ -1.68379E+02  -6.37303E+01
+ -1.67513E+02  -6.31060E+01
+ -1.66608E+02  -6.24900E+01
+ -1.66199E+02  -6.26056E+01
+ -1.65149E+02  -6.30070E+01
+ -1.63921E+02  -6.34667E+01
+ -1.63001E+02  -6.29675E+01
+ -1.62061E+02  -6.23936E+01
+ -1.61338E+02  -6.26144E+01
+ -1.60430E+02  -6.29233E+01
+ -1.59888E+02  -6.25954E+01
+ -1.58703E+02  -6.30044E+01
+ -1.58394E+02  -6.27885E+01
+ -1.57601E+02  -6.30700E+01
+ -1.56717E+02  -6.33240E+01
+ -1.56022E+02  -6.29525E+01
+ -1.55254E+02  -6.24327E+01
+ -1.54324E+02  -6.17762E+01
+ -1.54181E+02  -6.18361E+01
+ -1.53661E+02  -6.13992E+01
+ -1.52943E+02  -6.08407E+01
+ -1.52119E+02  -6.01575E+01
+ -1.51329E+02  -5.94694E+01
+ -1.50382E+02  -5.97176E+01
+ -1.49809E+02  -5.93141E+01
+ -1.49264E+02  -5.88221E+01
+ -1.48276E+02  -5.81300E+01
+ -1.47692E+02  -5.75547E+01
+ -1.47167E+02  -5.76379E+01
+ -1.46681E+02  -5.73076E+01
+ -1.45979E+02  -5.66686E+01
+ -1.45412E+02  -5.62277E+01
+ -1.44857E+02  -5.57842E+01
+ -1.44482E+02  -5.59103E+01
+ -1.43324E+02  -5.62625E+01
+ -1.42086E+02  -5.66193E+01
+ -1.41211E+02  -5.68392E+01
+ -1.40325E+02  -5.70528E+01
+ -1.40041E+02  -5.67722E+01
+ -1.39545E+02  -5.62678E+01
+ -1.39191E+02  -5.57249E+01
+ -1.39578E+02  -5.56146E+01
+ -1.39253E+02  -5.52509E+01
+ -1.38799E+02  -5.47123E+01
+ -1.38338E+02  -5.41410E+01
+ -1.37890E+02  -5.35679E+01
+ -1.37522E+02  -5.36878E+01
+ -1.36590E+02  -5.39067E+01
+ -1.36180E+02  -5.33957E+01
+ -1.35307E+02  -5.36430E+01
+ -1.34205E+02  -5.38871E+01
+ -1.32870E+02  -5.42371E+01
+ -1.32126E+02  -5.44323E+01
+ -1.31375E+02  -5.46229E+01
+ -1.30059E+02  -5.49314E+01
+ -1.29345E+02  -5.51286E+01
+ -1.28624E+02  -5.53215E+01
+ -1.27231E+02  -5.55654E+01
+ -1.26800E+02  -5.50641E+01
+ -1.26197E+02  -5.51382E+01
+ -1.25077E+02  -5.54541E+01
+ -1.24262E+02  -5.55873E+01
+ -1.23442E+02  -5.57150E+01
+ -1.22655E+02  -5.58731E+01
+ -1.21862E+02  -5.60262E+01
+ -1.21635E+02  -5.58321E+01
+ -1.21228E+02  -5.52189E+01
+ -1.20663E+02  -5.44098E+01
+ -1.19685E+02  -5.46416E+01
+ -1.18581E+02  -5.48185E+01
+ -1.18313E+02  -5.43503E+01
+ -1.18037E+02  -5.36908E+01
+ -1.17661E+02  -5.31241E+01
+ -1.18977E+02  -5.28974E+01
+ -1.18875E+02  -5.27524E+01
+ -1.18422E+02  -5.22120E+01
+ -1.18120E+02  -5.17718E+01
+ -1.17824E+02  -5.13309E+01
+ -1.17522E+02  -5.08747E+01
+ -1.17225E+02  -5.04178E+01
+ -1.16802E+02  -4.98934E+01
+ -1.16388E+02  -4.93675E+01
+ -1.15233E+02  -4.95892E+01
+ -1.14556E+02  -4.97210E+01
+ -1.13875E+02  -4.98489E+01
+ -1.13745E+02  -4.93574E+01
+ -1.13528E+02  -4.88410E+01
+ -1.13315E+02  -4.83242E+01
+ -1.13131E+02  -4.77733E+01
+ -1.12950E+02  -4.72221E+01
+ -1.12685E+02  -4.65385E+01
+ -1.12426E+02  -4.58544E+01
+ -1.12675E+02  -4.58327E+01
+ -1.12550E+02  -4.54942E+01
+ -1.12381E+02  -4.49378E+01
+ -1.12216E+02  -4.43811E+01
+ -1.11971E+02  -4.37738E+01
+ -1.11730E+02  -4.31659E+01
+ -1.11538E+02  -4.26833E+01
+ -1.11349E+02  -4.22004E+01
+ -1.10954E+02  -4.22487E+01
+ -1.10832E+02  -4.13555E+01
+ -1.10754E+02  -4.07597E+01
+ -1.10677E+02  -4.01638E+01
+ -1.10533E+02  -3.95749E+01
+ -1.10391E+02  -3.89858E+01
+ -1.11270E+02  -3.89785E+01
+ -1.11268E+02  -3.88776E+01
+ -1.11067E+02  -3.82760E+01
+ -1.10869E+02  -3.76741E+01
+ -1.10668E+02  -3.70423E+01
+ -1.10471E+02  -3.64102E+01
+ -1.10739E+02  -3.63578E+01
+ -1.10715E+02  -3.62186E+01
+ -1.10579E+02  -3.58301E+01
+ -1.10895E+02  -3.57967E+01
+ -1.10877E+02  -3.53191E+01
+ -1.10827E+02  -3.50908E+01
+> AN-SA                      Mueller et al. [1987]
+ -4.37900E-01  -5.48518E+01
+ -1.03898E+00  -5.50190E+01
+ -1.60588E+00  -5.51293E+01
+ -1.61369E+00  -5.56529E+01
+ -2.07998E+00  -5.56568E+01
+ -2.89625E+00  -5.57072E+01
+ -3.72024E+00  -5.57399E+01
+ -4.05601E+00  -5.57694E+01
+ -4.69061E+00  -5.58072E+01
+ -4.67546E+00  -5.62102E+01
+ -4.69342E+00  -5.65916E+01
+ -5.44832E+00  -5.66270E+01
+ -6.05679E+00  -5.66721E+01
+ -6.09431E+00  -5.69823E+01
+ -6.13025E+00  -5.72402E+01
+ -6.53815E+00  -5.72700E+01
+ -6.99917E+00  -5.73176E+01
+ -7.01278E+00  -5.76172E+01
+ -7.00902E+00  -5.78694E+01
+ -7.52477E+00  -5.79204E+01
+ -8.60685E+00  -5.79888E+01
+ -9.88532E+00  -5.80915E+01
+ -1.11897E+01  -5.81577E+01
+ -1.26489E+01  -5.82406E+01
+ -1.39543E+01  -5.83173E+01
+ -1.50689E+01  -5.83904E+01
+ -1.59715E+01  -5.84388E+01
+ -1.60047E+01  -5.84593E+01
+ -1.62258E+01  -5.87672E+01
+ -1.64100E+01  -5.90984E+01
+ -1.69169E+01  -5.90982E+01
+ -1.76670E+01  -5.91289E+01
+ -1.80600E+01  -5.91526E+01
+ -1.81233E+01  -5.95093E+01
+ -1.84325E+01  -5.95423E+01
+ -1.85472E+01  -5.99376E+01
+ -1.86464E+01  -6.02500E+01
+ -1.93705E+01  -6.02891E+01
+ -1.95812E+01  -6.08108E+01
+ -2.06510E+01  -6.07817E+01
+ -2.17186E+01  -6.07441E+01
+ -2.29137E+01  -6.07232E+01
+ -2.41069E+01  -6.06917E+01
+ -2.50935E+01  -6.05450E+01
+ -2.60709E+01  -6.03910E+01
+> AN\SA                      by Peter Bird   1999
+ -7.64833E+01  -5.20684E+01
+ -7.66257E+01  -5.13775E+01
+ -7.67565E+01  -5.07289E+01
+ -7.69898E+01  -4.98446E+01
+ -7.70240E+01  -4.91923E+01
+ -7.69255E+01  -4.85065E+01
+ -7.66497E+01  -4.78746E+01
+ -7.63210E+01  -4.74777E+01
+ -7.59972E+01  -4.70799E+01
+ -7.59581E+01  -4.64220E+01
+ -7.60062E+01  -4.56585E+01
+> AR-EU                      by Peter Bird   1999
+ +6.50282E+01  +2.43824E+01
+ +6.41615E+01  +2.43498E+01
+ +6.33656E+01  +2.42854E+01
+ +6.25806E+01  +2.42830E+01
+ +6.19554E+01  +2.40869E+01
+ +6.13646E+01  +2.41220E+01
+ +6.08696E+01  +2.41775E+01
+ +6.03741E+01  +2.42315E+01
+ +5.96026E+01  +2.43113E+01
+ +5.87157E+01  +2.43633E+01
+ +5.78316E+01  +2.44427E+01
+ +5.73454E+01  +2.47884E+01
+ +5.71214E+01  +2.55518E+01
+ +5.70570E+01  +2.60485E+01
+ +5.69921E+01  +2.65452E+01
+ +5.68753E+01  +2.73007E+01
+ +5.64233E+01  +2.73685E+01
+ +5.56618E+01  +2.69471E+01
+ +5.47283E+01  +2.66679E+01
+ +5.38601E+01  +2.67173E+01
+ +5.32406E+01  +2.71213E+01
+ +5.25038E+01  +2.75611E+01
+ +5.19120E+01  +2.79573E+01
+ +5.12830E+01  +2.84873E+01
+ +5.09981E+01  +2.90719E+01
+ +5.10573E+01  +2.95780E+01
+ +5.04526E+01  +3.01031E+01
+ +4.99740E+01  +3.04532E+01
+ +4.94919E+01  +3.08016E+01
+ +4.92649E+01  +3.12117E+01
+ +4.90360E+01  +3.16214E+01
+ +4.84892E+01  +3.22374E+01
+ +4.81702E+01  +3.23082E+01
+ +4.77702E+01  +3.23111E+01
+ +4.74107E+01  +3.24479E+01
+ +4.66076E+01  +3.28874E+01
+ +4.59177E+01  +3.33905E+01
+ +4.55052E+01  +3.38933E+01
+ +4.50000E+01  +3.45906E+01
+> SU/AU                      Mueller et al. [1987]
+ +1.04576E+02  -8.16657E+00
+ +1.04981E+02  -8.56880E+00
+ +1.05590E+02  -8.92628E+00
+ +1.06123E+02  -9.23956E+00
+ +1.06345E+02  -9.37105E+00
+ +1.06827E+02  -9.66517E+00
+ +1.07379E+02  -9.89028E+00
+ +1.07836E+02  -1.00528E+01
+ +1.08363E+02  -1.01777E+01
+ +1.09067E+02  -1.03276E+01
+ +1.09626E+02  -1.03713E+01
+ +1.10159E+02  -1.04399E+01
+ +1.10615E+02  -1.04773E+01
+ +1.11015E+02  -1.04773E+01
+ +1.11523E+02  -1.05772E+01
+ +1.12170E+02  -1.06520E+01
+ +1.12563E+02  -1.07580E+01
+ +1.13204E+02  -1.08702E+01
+ +1.13756E+02  -1.09636E+01
+ +1.14410E+02  -1.10882E+01
+ +1.15013E+02  -1.11505E+01
+ +1.15571E+02  -1.12189E+01
+ +1.16174E+02  -1.12750E+01
+ +1.16853E+02  -1.13310E+01
+ +1.17576E+02  -1.13372E+01
+ +1.18236E+02  -1.13869E+01
+ +1.18750E+02  -1.13621E+01
+ +1.19270E+02  -1.13932E+01
+ +1.19841E+02  -1.14616E+01
+ +1.20451E+02  -1.15238E+01
+ +1.20886E+02  -1.14925E+01
+> TI-AU                      Mueller et al. [1987]
+ +1.20886E+02  -1.14925E+01
+ +1.21110E+02  -1.14927E+01
+ +1.21783E+02  -1.14118E+01
+ +1.22627E+02  -1.11878E+01
+ +1.23217E+02  -1.09948E+01
+ +1.23960E+02  -1.07081E+01
+ +1.24734E+02  -1.03900E+01
+ +1.25159E+02  -1.01590E+01
+ +1.25482E+02  -9.98405E+00
+ +1.25869E+02  -9.78401E+00
+ +1.26333E+02  -9.59637E+00
+ +1.26853E+02  -9.38984E+00
+ +1.27430E+02  -9.22077E+00
+ +1.27900E+02  -9.13307E+00
+ +1.28376E+02  -9.09547E+00
+ +1.29106E+02  -9.02027E+00
+ +1.29861E+02  -8.92625E+00
+ +1.30540E+02  -8.72560E+00
+ +1.30933E+02  -8.56249E+00
+ +1.31415E+02  -8.26747E+00
+> TI-AU                      by Peter Bird   September 2001
+ +1.31415E+02  -8.26747E+00
+ +1.31867E+02  -7.66120E+00
+ +1.32431E+02  -6.98943E+00
+ +1.32689E+02  -6.68099E+00
+> PA-AU                      Mueller et al. [1987]
+ +1.59803E+02  -6.00055E+01
+ +1.60327E+02  -6.05039E+01
+ +1.60740E+02  -6.10526E+01
+ +1.61129E+02  -6.13842E+01
+ +1.61228E+02  -6.14567E+01
+> AU\PA                      Mueller et al. [1987]
+ +1.66951E+02  -4.49871E+01
+ +1.67100E+02  -4.48262E+01
+ +1.67368E+02  -4.46478E+01
+ +1.67688E+02  -4.44660E+01
+ +1.68081E+02  -4.43297E+01
+ +1.68488E+02  -4.41660E+01
+ +1.68770E+02  -4.40215E+01
+> AU-PA                      Mueller et al. [1987]
+ +1.68770E+02  -4.40215E+01
+ +1.69136E+02  -4.38453E+01
+ +1.69647E+02  -4.35943E+01
+ +1.70103E+02  -4.33578E+01
+ +1.70638E+02  -4.30879E+01
+ +1.70995E+02  -4.29318E+01
+ +1.71277E+02  -4.27430E+01
+ +1.71473E+02  -4.26755E+01
+ +1.71859E+02  -4.26156E+01
+ +1.72593E+02  -4.24830E+01
+ +1.73126E+02  -4.23917E+01
+ +1.73724E+02  -4.22908E+01
+ +1.74304E+02  -4.22013E+01
+ +1.74988E+02  -4.21219E+01
+ +1.75503E+02  -4.20593E+01
+> KE/PA                      Mueller et al. [1987]
+ +1.75503E+02  -4.20593E+01
+ +1.76081E+02  -4.19100E+01
+ +1.76673E+02  -4.17560E+01
+ +1.77123E+02  -4.16566E+01
+ +1.77607E+02  -4.14997E+01
+ +1.78015E+02  -4.11879E+01
+ +1.78284E+02  -4.08071E+01
+ +1.78566E+02  -4.04240E+01
+ +1.78792E+02  -4.00870E+01
+ +1.78950E+02  -3.96848E+01
+ +1.79125E+02  -3.92296E+01
+ +1.79215E+02  -3.88885E+01
+ +1.79366E+02  -3.85380E+01
+ +1.79569E+02  -3.82045E+01
+ +1.79838E+02  -3.74758E+01
+ -1.79811E+02  -3.67930E+01
+ -1.79371E+02  -3.61790E+01
+ -1.79044E+02  -3.55423E+01
+ -1.78641E+02  -3.50218E+01
+ -1.78539E+02  -3.47058E+01
+ -1.78413E+02  -3.44854E+01
+ -1.78294E+02  -3.42413E+01
+ -1.78208E+02  -3.38459E+01
+ -1.77981E+02  -3.35795E+01
+ -1.77810E+02  -3.31908E+01
+ -1.77666E+02  -3.26959E+01
+ -1.77649E+02  -3.22028E+01
+ -1.77538E+02  -3.19574E+01
+ -1.77301E+02  -3.17932E+01
+ -1.77108E+02  -3.14517E+01
+ -1.76919E+02  -3.10374E+01
+ -1.76690E+02  -3.06779E+01
+ -1.76547E+02  -3.03215E+01
+ -1.76339E+02  -2.98808E+01
+ -1.76153E+02  -2.94691E+01
+ -1.76078E+02  -2.90653E+01
+ -1.75995E+02  -2.86971E+01
+ -1.75885E+02  -2.82638E+01
+ -1.75785E+02  -2.77843E+01
+ -1.75545E+02  -2.73180E+01
+ -1.75400E+02  -2.68569E+01
+ -1.75423E+02  -2.64372E+01
+ -1.75415E+02  -2.60248E+01
+ -1.75382E+02  -2.57295E+01
+ -1.75297E+02  -2.54257E+01
+ -1.75261E+02  -2.51425E+01
+ -1.75229E+02  -2.48362E+01
+ -1.75209E+02  -2.44719E+01
+ -1.75102E+02  -2.40701E+01
+ -1.74985E+02  -2.37499E+01
+> TO/PA                      Mueller et al. [1987]
+ -1.74985E+02  -2.37499E+01
+ -1.74842E+02  -2.35126E+01
+ -1.74663E+02  -2.32205E+01
+ -1.74489E+02  -2.29058E+01
+ -1.74323E+02  -2.26169E+01
+ -1.74139E+02  -2.22898E+01
+ -1.73952E+02  -2.19153E+01
+ -1.73818E+02  -2.15263E+01
+ -1.73703E+02  -2.12476E+01
+ -1.73551E+02  -2.08926E+01
+ -1.73403E+02  -2.05862E+01
+ -1.73218E+02  -2.02040E+01
+ -1.73053E+02  -1.97788E+01
+ -1.72970E+02  -1.94608E+01
+ -1.72874E+02  -1.90710E+01
+ -1.72786E+02  -1.87769E+01
+ -1.72698E+02  -1.84832E+01
+ -1.72591E+02  -1.81523E+01
+ -1.72540E+02  -1.79348E+01
+ -1.72445E+02  -1.76766E+01
+ -1.72374E+02  -1.72706E+01
+ -1.72335E+02  -1.69629E+01
+ -1.72311E+02  -1.67157E+01
+ -1.72307E+02  -1.63319E+01
+ -1.72300E+02  -1.60410E+01
+ -1.72331E+02  -1.57320E+01
+ -1.72355E+02  -1.55611E+01
+ -1.72428E+02  -1.53734E+01
+ -1.72602E+02  -1.51514E+01
+ -1.72774E+02  -1.50330E+01
+ -1.72939E+02  -1.48669E+01
+ -1.73130E+02  -1.47848E+01
+ -1.73273E+02  -1.46967E+01
+ -1.73407E+02  -1.45840E+01
+> KE-AU                      Circum Pacific Map Project [1981]
+ -1.77419E+02  -2.41051E+01
+ -1.77448E+02  -2.42420E+01
+ -1.77552E+02  -2.47196E+01
+ -1.77657E+02  -2.51971E+01
+ -1.77793E+02  -2.59755E+01
+ -1.78017E+02  -2.67672E+01
+ -1.78248E+02  -2.73765E+01
+ -1.78482E+02  -2.79855E+01
+ -1.78713E+02  -2.86927E+01
+ -1.78966E+02  -2.94983E+01
+ -1.79074E+02  -2.97924E+01
+ -1.79226E+02  -3.03553E+01
+ -1.79393E+02  -3.09968E+01
+ -1.79515E+02  -3.13328E+01
+ -1.79740E+02  -3.17510E+01
+ +1.79980E+02  -3.23467E+01
+ +1.79657E+02  -3.30187E+01
+ +1.79345E+02  -3.36016E+01
+ +1.78996E+02  -3.42460E+01
+ +1.78681E+02  -3.47863E+01
+ +1.78403E+02  -3.51612E+01
+ +1.77890E+02  -3.59174E+01
+ +1.77507E+02  -3.64610E+01
+ +1.77049E+02  -3.71022E+01
+ +1.76770E+02  -3.74850E+01
+ +1.76509E+02  -3.78849E+01
+ +1.76241E+02  -3.82869E+01
+ +1.75995E+02  -3.86742E+01
+ +1.75932E+02  -3.87623E+01
+ +1.75609E+02  -3.92297E+01
+ +1.76074E+02  -4.00461E+01
+ +1.75868E+02  -4.03108E+01
+ +1.75537E+02  -4.05983E+01
+ +1.75324E+02  -4.07906E+01
+ +1.75012E+02  -4.09786E+01
+ +1.74632E+02  -4.11571E+01
+ +1.74763E+02  -4.15656E+01
+ +1.74945E+02  -4.17569E+01
+ +1.75503E+02  -4.20593E+01
+> PA-NI                      Mueller et al. [1987]
+ -1.76346E+02  -1.46340E+01
+ -1.75865E+02  -1.44781E+01
+ -1.75309E+02  -1.44066E+01
+ -1.74754E+02  -1.43339E+01
+ -1.74083E+02  -1.43791E+01
+ -1.73836E+02  -1.45338E+01
+> PA-TO
+ -1.73836E+02  -1.45338E+01
+ -1.73407E+02  -1.45840E+01
+> WL-MO                      by Peter Bird   2001.05
+ +1.38972E+02  -1.60750E+00
+ +1.39205E+02  -2.09261E+00
+ +1.39439E+02  -2.57768E+00
+ +1.39809E+02  -3.17775E+00
+ +1.40070E+02  -3.64451E+00
+ +1.40328E+02  -4.04505E+00
+ +1.40566E+02  -4.58570E+00
+ +1.40798E+02  -5.10959E+00
+> WL-AU                      by Peter Bird   2001.05
+ +1.40798E+02  -5.10959E+00
+ +1.40847E+02  -5.14497E+00
+ +1.41483E+02  -5.72740E+00
+ +1.42231E+02  -5.98645E+00
+ +1.42956E+02  -6.29475E+00
+ +1.43569E+02  -6.55817E+00
+ +1.44136E+02  -6.81309E+00
+ +1.44740E+02  -7.02342E+00
+ +1.45249E+02  -7.37364E+00
+ +1.45666E+02  -7.66091E+00
+ +1.46398E+02  -8.10254E+00
+ +1.46918E+02  -8.41044E+00
+ +1.46954E+02  -8.59828E+00
+> SB/SS                      Circum Pacific Map Project [1981]
+ +1.48587E+02  -7.39451E+00
+ +1.49314E+02  -7.03217E+00
+ +1.49860E+02  -6.93936E+00
+ +1.50146E+02  -6.88149E+00
+ +1.50663E+02  -6.69359E+00
+ +1.51148E+02  -6.44252E+00
+ +1.51519E+02  -6.21031E+00
+ +1.51876E+02  -5.92553E+00
+ +1.52257E+02  -5.75490E+00
+ +1.52653E+02  -5.64024E+00
+ +1.53107E+02  -5.74072E+00
+ +1.53519E+02  -5.94643E+00
+ +1.53930E+02  -6.26500E+00
+> NB/SS                      Circum Pacific Map Project [1981]
+ +1.53930E+02  -6.26500E+00
+ +1.54225E+02  -6.50689E+00
+ +1.54540E+02  -6.81779E+00
+ +1.54927E+02  -7.29284E+00
+> PA/SS                      Circum Pacific Map Project [1981]
+ +1.54927E+02  -7.29284E+00
+ +1.55454E+02  -7.48875E+00
+> PA/WL                      Circum Pacific Map Project [1981]
+ +1.55454E+02  -7.48875E+00
+ +1.55812E+02  -7.70595E+00
+ +1.56047E+02  -7.88376E+00
+ +1.56296E+02  -8.17405E+00
+> SS\WL                      Lock et al. [1987]
+ +1.48587E+02  -7.39451E+00
+ +1.48733E+02  -7.47525E+00
+ +1.48944E+02  -7.60693E+00
+ +1.49148E+02  -7.66468E+00
+ +1.49334E+02  -7.66492E+00
+ +1.49609E+02  -7.62419E+00
+ +1.49866E+02  -7.61219E+00
+ +1.50173E+02  -7.62900E+00
+ +1.50555E+02  -7.68698E+00
+ +1.50917E+02  -7.75724E+00
+ +1.51307E+02  -7.85219E+00
+ +1.51680E+02  -7.95532E+00
+ +1.52062E+02  -8.10364E+00
+ +1.52411E+02  -8.26014E+00
+ +1.52685E+02  -8.38779E+00
+ +1.52959E+02  -8.54419E+00
+ +1.53108E+02  -8.68401E+00
+ +1.53170E+02  -8.78265E+00
+ +1.53237E+02  -8.88951E+00
+ +1.53255E+02  -9.18615E+00
+> AU-WL                      by Peter Bird   2001.05
+ +1.51654E+02  -9.76005E+00
+ +1.51545E+02  -9.67589E+00
+ +1.51005E+02  -9.68138E+00
+ +1.50466E+02  -9.68686E+00
+ +1.50245E+02  -9.94531E+00
+ +1.49676E+02  -9.80087E+00
+ +1.49133E+02  -9.35255E+00
+ +1.48751E+02  -9.56973E+00
+ +1.48207E+02  -9.21176E+00
+ +1.47539E+02  -8.88649E+00
+ +1.46954E+02  -8.59828E+00
+> PA/AU                      Mueller et al. [1987]
+ +1.56296E+02  -8.17405E+00
+ +1.56467E+02  -8.38190E+00
+ +1.56706E+02  -8.56290E+00
+ +1.56782E+02  -8.60178E+00
+ +1.56858E+02  -8.61536E+00
+ +1.56935E+02  -8.64158E+00
+ +1.57049E+02  -8.70619E+00
+ +1.57177E+02  -8.74562E+00
+ +1.57241E+02  -8.78430E+00
+ +1.57317E+02  -8.82313E+00
+ +1.57419E+02  -8.90020E+00
+ +1.57572E+02  -8.96515E+00
+ +1.57648E+02  -9.00394E+00
+ +1.57724E+02  -9.06805E+00
+ +1.57827E+02  -9.10708E+00
+ +1.57916E+02  -9.15863E+00
+ +1.57992E+02  -9.21004E+00
+ +1.58056E+02  -9.24866E+00
+ +1.58145E+02  -9.31285E+00
+ +1.58273E+02  -9.39006E+00
+ +1.58388E+02  -9.44177E+00
+ +1.58478E+02  -9.48058E+00
+ +1.58580E+02  -9.50679E+00
+ +1.58709E+02  -9.54586E+00
+ +1.58773E+02  -9.55904E+00
+ +1.58850E+02  -9.58499E+00
+ +1.58926E+02  -9.62360E+00
+ +1.59003E+02  -9.64952E+00
+ +1.59068E+02  -9.68801E+00
+ +1.59119E+02  -9.72641E+00
+ +1.59170E+02  -9.76480E+00
+ +1.59221E+02  -9.82854E+00
+ +1.59285E+02  -9.87969E+00
+ +1.59362E+02  -9.93092E+00
+ +1.59439E+02  -9.96945E+00
+ +1.59503E+02  -1.00206E+01
+ +1.59580E+02  -1.00844E+01
+ +1.59644E+02  -1.01229E+01
+ +1.59708E+02  -1.01739E+01
+ +1.59772E+02  -1.01997E+01
+ +1.59837E+02  -1.02507E+01
+ +1.59914E+02  -1.02765E+01
+ +1.59978E+02  -1.03149E+01
+ +1.60068E+02  -1.03787E+01
+ +1.60132E+02  -1.04170E+01
+ +1.60210E+02  -1.04681E+01
+ +1.60287E+02  -1.05192E+01
+ +1.60364E+02  -1.05702E+01
+ +1.60493E+02  -1.06341E+01
+ +1.60544E+02  -1.06723E+01
+ +1.60622E+02  -1.07233E+01
+ +1.60725E+02  -1.07870E+01
+ +1.60776E+02  -1.08379E+01
+ +1.60867E+02  -1.09142E+01
+ +1.60931E+02  -1.09651E+01
+ +1.60996E+02  -1.10287E+01
+ +1.61060E+02  -1.10541E+01
+ +1.61125E+02  -1.11304E+01
+ +1.61202E+02  -1.11685E+01
+ +1.61306E+02  -1.11940E+01
+ +1.61384E+02  -1.12321E+01
+ +1.61461E+02  -1.12448E+01
+ +1.61552E+02  -1.12829E+01
+ +1.61720E+02  -1.13209E+01
+ +1.61798E+02  -1.13589E+01
+ +1.61901E+02  -1.13968E+01
+ +1.62018E+02  -1.14220E+01
+ +1.62109E+02  -1.14345E+01
+ +1.62225E+02  -1.14216E+01
+ +1.62354E+02  -1.14212E+01
+ +1.62484E+02  -1.14208E+01
+ +1.62626E+02  -1.13823E+01
+ +1.62833E+02  -1.13560E+01
+ +1.63053E+02  -1.13106E+01
+ +1.63195E+02  -1.12908E+01
+ +1.63311E+02  -1.12647E+01
+ +1.63505E+02  -1.12381E+01
+ +1.63699E+02  -1.11987E+01
+ +1.63854E+02  -1.11848E+01
+ +1.63996E+02  -1.11583E+01
+ +1.64151E+02  -1.11443E+01
+ +1.64267E+02  -1.11179E+01
+ +1.64409E+02  -1.10913E+01
+ +1.64512E+02  -1.10903E+01
+ +1.64641E+02  -1.11143E+01
+ +1.64758E+02  -1.11637E+01
+ +1.64901E+02  -1.12002E+01
+ +1.65070E+02  -1.12869E+01
+ +1.65252E+02  -1.14113E+01
+ +1.65396E+02  -1.15487E+01
+ +1.65514E+02  -1.16864E+01
+ +1.65621E+02  -1.18875E+01
+ +1.65715E+02  -1.21266E+01
+ +1.65770E+02  -1.23157E+01
+ +1.65838E+02  -1.25171E+01
+ +1.65894E+02  -1.27440E+01
+ +1.65909E+02  -1.28703E+01
+ +1.65952E+02  -1.30721E+01
+ +1.66020E+02  -1.32608E+01
+ +1.66090E+02  -1.35126E+01
+ +1.66132E+02  -1.36763E+01
+ +1.66154E+02  -1.37794E+01
+> NH/AU                      Mueller et al. [1987]
+ +1.66154E+02  -1.37794E+01
+ +1.66161E+02  -1.38276E+01
+ +1.66204E+02  -1.39913E+01
+ +1.66234E+02  -1.41805E+01
+ +1.66250E+02  -1.43447E+01
+ +1.66252E+02  -1.44205E+01
+ +1.66268E+02  -1.45594E+01
+ +1.66271E+02  -1.46859E+01
+ +1.66262E+02  -1.48885E+01
+ +1.66213E+02  -1.50413E+01
+ +1.66228E+02  -1.51296E+01
+ +1.66217E+02  -1.52437E+01
+ +1.66193E+02  -1.53454E+01
+ +1.66209E+02  -1.54337E+01
+ +1.66225E+02  -1.55599E+01
+ +1.66227E+02  -1.56737E+01
+ +1.66270E+02  -1.57993E+01
+ +1.66285E+02  -1.58875E+01
+ +1.66340E+02  -1.59749E+01
+ +1.66395E+02  -1.60875E+01
+ +1.66450E+02  -1.61874E+01
+ +1.66506E+02  -1.63000E+01
+ +1.66562E+02  -1.64378E+01
+ +1.66604E+02  -1.65380E+01
+ +1.66659E+02  -1.66251E+01
+ +1.66728E+02  -1.67372E+01
+ +1.66810E+02  -1.68363E+01
+ +1.66868E+02  -1.69866E+01
+ +1.66950E+02  -1.70982E+01
+ +1.67059E+02  -1.72090E+01
+ +1.67155E+02  -1.73074E+01
+ +1.67171E+02  -1.73955E+01
+ +1.67215E+02  -1.75206E+01
+ +1.67245E+02  -1.76335E+01
+ +1.67275E+02  -1.77590E+01
+ +1.67320E+02  -1.79219E+01
+ +1.67350E+02  -1.80221E+01
+ +1.67394E+02  -1.81472E+01
+ +1.67424E+02  -1.82473E+01
+ +1.67455E+02  -1.83601E+01
+ +1.67486E+02  -1.84855E+01
+ +1.67504E+02  -1.86113E+01
+ +1.67521E+02  -1.87118E+01
+ +1.67607E+02  -1.88859E+01
+ +1.67680E+02  -1.90477E+01
+ +1.67727E+02  -1.92356E+01
+ +1.67812E+02  -1.93716E+01
+ +1.67886E+02  -1.95332E+01
+ +1.67943E+02  -1.96322E+01
+ +1.68003E+02  -1.97690E+01
+ +1.68075E+02  -1.98926E+01
+ +1.68160E+02  -2.00031E+01
+ +1.68191E+02  -2.00903E+01
+ +1.68263E+02  -2.02012E+01
+ +1.68335E+02  -2.03246E+01
+ +1.68396E+02  -2.04737E+01
+ +1.68512E+02  -2.06457E+01
+ +1.68585E+02  -2.07815E+01
+ +1.68645E+02  -2.08926E+01
+ +1.68705E+02  -2.10162E+01
+ +1.68776E+02  -2.11015E+01
+ +1.68879E+02  -2.12610E+01
+ +1.68996E+02  -2.14198E+01
+ +1.69054E+02  -2.15055E+01
+ +1.69143E+02  -2.16401E+01
+ +1.69215E+02  -2.17250E+01
+ +1.69288E+02  -2.18225E+01
+ +1.69320E+02  -2.19092E+01
+ +1.69419E+02  -2.19801E+01
+ +1.69491E+02  -2.20522E+01
+ +1.69577E+02  -2.21236E+01
+ +1.69719E+02  -2.22298E+01
+ +1.69835E+02  -2.23499E+01
+ +1.69950E+02  -2.24447E+01
+ +1.70036E+02  -2.25157E+01
+ +1.70109E+02  -2.25873E+01
+ +1.70221E+02  -2.26442E+01
+ +1.70321E+02  -2.27017E+01
+ +1.70420E+02  -2.27591E+01
+ +1.70547E+02  -2.28274E+01
+ +1.70660E+02  -2.28838E+01
+ +1.70745E+02  -2.29166E+01
+ +1.70842E+02  -2.29486E+01
+ +1.70939E+02  -2.29680E+01
+ +1.71037E+02  -2.29998E+01
+ +1.71162E+02  -2.30299E+01
+ +1.71288E+02  -2.30724E+01
+ +1.71385E+02  -2.30915E+01
+ +1.71496E+02  -2.31096E+01
+ +1.71620E+02  -2.31268E+01
+ +1.71703E+02  -2.31464E+01
+ +1.71854E+02  -2.31491E+01
+ +1.71950E+02  -2.31553E+01
+ +1.72060E+02  -2.31730E+01
+ +1.72197E+02  -2.31763E+01
+ +1.72278E+02  -2.31707E+01
+ +1.72361E+02  -2.31775E+01
+ +1.72439E+02  -2.31781E+01
+> CA-NA                      by Peter Bird   1999
+ -6.15534E+01  +1.89589E+01
+ -6.21765E+01  +1.92752E+01
+ -6.28467E+01  +1.95743E+01
+ -6.33598E+01  +1.96915E+01
+ -6.37601E+01  +1.97242E+01
+ -6.43436E+01  +1.97794E+01
+ -6.51285E+01  +1.98329E+01
+ -6.56940E+01  +1.98288E+01
+ -6.62594E+01  +1.98246E+01
+ -6.70405E+01  +1.97543E+01
+ -6.75313E+01  +1.97213E+01
+ -6.80218E+01  +1.96870E+01
+ -6.88528E+01  +1.95890E+01
+ -6.94148E+01  +1.96961E+01
+ -6.99775E+01  +1.98015E+01
+ -7.06265E+01  +2.00022E+01
+ -7.12771E+01  +2.02005E+01
+ -7.18044E+01  +2.02665E+01
+ -7.23322E+01  +2.03310E+01
+ -7.32385E+01  +2.02913E+01
+ -7.39942E+01  +2.01659E+01
+ -7.47486E+01  +2.00372E+01
+ -7.52388E+01  +1.99902E+01
+ -7.57287E+01  +1.99419E+01
+ -7.63564E+01  +1.98453E+01
+ -7.69834E+01  +1.97465E+01
+ -7.76726E+01  +1.96228E+01
+ -7.83607E+01  +1.94965E+01
+ -7.90110E+01  +1.93815E+01
+ -7.96604E+01  +1.92642E+01
+ -8.02095E+01  +1.91597E+01
+ -8.07579E+01  +1.90536E+01
+ -8.12563E+01  +1.89598E+01
+ -8.17541E+01  +1.88647E+01
+ -8.16893E+01  +1.83332E+01
+ -8.16248E+01  +1.78016E+01
+ -8.22442E+01  +1.76907E+01
+ -8.28646E+01  +1.76257E+01
+ -8.37058E+01  +1.74809E+01
+ -8.42479E+01  +1.73440E+01
+ -8.49097E+01  +1.71066E+01
+ -8.56714E+01  +1.69110E+01
+ -8.63195E+01  +1.66945E+01
+ -8.69661E+01  +1.64759E+01
+ -8.77228E+01  +1.62506E+01
+ -8.83510E+01  +1.59583E+01
+ -8.88764E+01  +1.56222E+01
+ -8.93716E+01  +1.52150E+01
+ -8.97180E+01  +1.48151E+01
+ -9.00373E+01  +1.43923E+01
+ -9.04260E+01  +1.39172E+01
+ -9.08103E+01  +1.33941E+01
+ -9.08980E+01  +1.25837E+01
+> CA/CO                      by Peter Bird   1999
+ -9.08980E+01  +1.25837E+01
+ -9.02927E+01  +1.25426E+01
+ -8.96190E+01  +1.22948E+01
+ -8.89197E+01  +1.19992E+01
+ -8.83190E+01  +1.16968E+01
+ -8.78901E+01  +1.13967E+01
+ -8.74621E+01  +1.10959E+01
+ -8.69749E+01  +1.05473E+01
+ -8.66480E+01  +1.02350E+01
+> CA-SA                      by Peter Bird   1999
+ -6.38782E+01  +1.05316E+01
+ -6.32327E+01  +1.05091E+01
+ -6.26409E+01  +1.04818E+01
+ -6.21579E+01  +1.04585E+01
+ -6.15422E+01  +1.04273E+01
+ -6.09266E+01  +1.03949E+01
+ -6.04573E+01  +1.03453E+01
+ -5.99882E+01  +1.02951E+01
+ -5.91214E+01  +1.02200E+01
+ -5.86392E+01  +1.01902E+01
+ -5.81571E+01  +1.01597E+01
+> CA/SA                      by Peter Bird   1999
+ -5.81571E+01  +1.01597E+01
+ -5.77617E+01  +1.06345E+01
+ -5.75326E+01  +1.11438E+01
+ -5.74238E+01  +1.16612E+01
+ -5.74681E+01  +1.24273E+01
+ -5.75680E+01  +1.31016E+01
+ -5.77107E+01  +1.38740E+01
+ -5.77906E+01  +1.44989E+01
+ -5.79132E+01  +1.48642E+01
+ -5.82884E+01  +1.51500E+01
+ -5.85263E+01  +1.52839E+01
+ -5.86661E+01  +1.54116E+01
+ -5.86919E+01  +1.57703E+01
+ -5.88011E+01  +1.59911E+01
+ -5.88240E+01  +1.63970E+01
+ -5.90883E+01  +1.69121E+01
+ -5.94648E+01  +1.72431E+01
+ -5.98190E+01  +1.75484E+01
+ -6.00513E+01  +1.78225E+01
+ -6.02784E+01  +1.81910E+01
+ -6.05338E+01  +1.85131E+01
+ -6.07290E+01  +1.85946E+01
+ -6.09120E+01  +1.88885E+01
+ -6.15534E+01  +1.89589E+01
+> CO\NA                      by Peter Bird   1999
+ -9.08980E+01  +1.25837E+01
+ -9.13079E+01  +1.28322E+01
+ -9.17186E+01  +1.30801E+01
+ -9.20632E+01  +1.32712E+01
+ -9.22724E+01  +1.32233E+01
+ -9.25992E+01  +1.34980E+01
+ -9.29619E+01  +1.37221E+01
+ -9.33094E+01  +1.37932E+01
+ -9.36558E+01  +1.40161E+01
+ -9.40552E+01  +1.42221E+01
+ -9.45422E+01  +1.44786E+01
+ -9.48729E+01  +1.46998E+01
+ -9.51170E+01  +1.48866E+01
+ -9.54663E+01  +1.50902E+01
+ -9.57986E+01  +1.52765E+01
+ -9.62190E+01  +1.53609E+01
+ -9.67270E+01  +1.53601E+01
+ -9.72174E+01  +1.53584E+01
+ -9.76914E+01  +1.55080E+01
+ -9.81657E+01  +1.56399E+01
+ -9.85878E+01  +1.57715E+01
+ -9.90281E+01  +1.59191E+01
+ -9.94347E+01  +1.61340E+01
+ -9.98060E+01  +1.62980E+01
+ -1.00336E+02  +1.64424E+01
+ -1.00867E+02  +1.66363E+01
+ -1.01703E+02  +1.70256E+01
+ -1.02432E+02  +1.72799E+01
+ -1.03200E+02  +1.76155E+01
+ -1.03792E+02  +1.79200E+01
+ -1.04191E+02  +1.81383E+01
+ -1.04406E+02  +1.82090E+01
+ -1.04725E+02  +1.83684E+01
+ -1.05043E+02  +1.86216E+01
+ -1.05247E+02  +1.87619E+01
+> CO-PA                      truncated from Mueller et al. [1987]
+ -1.05586E+02  +1.78808E+01
+ -1.05399E+02  +1.77679E+01
+ -1.05367E+02  +1.70308E+01
+ -1.05398E+02  +1.62605E+01
+ -1.05357E+02  +1.55576E+01
+ -1.05320E+02  +1.51076E+01
+ -1.04690E+02  +1.52745E+01
+ -1.04563E+02  +1.46722E+01
+ -1.04437E+02  +1.40698E+01
+ -1.04181E+02  +1.33284E+01
+ -1.03927E+02  +1.25868E+01
+ -1.03772E+02  +1.18904E+01
+ -1.03875E+02  +1.18723E+01
+ -1.03807E+02  +1.14045E+01
+ -1.03739E+02  +1.09366E+01
+ -1.03628E+02  +1.02746E+01
+ -1.03598E+02  +1.01232E+01
+ -1.04296E+02  +1.00171E+01
+ -1.04296E+02  +9.17474E+00
+ -1.04258E+02  +8.45574E+00
+ -1.04229E+02  +8.34001E+00
+ -1.03595E+02  +8.37048E+00
+ -1.02961E+02  +8.39993E+00
+ -1.02810E+02  +7.79085E+00
+ -1.02659E+02  +7.18172E+00
+ -1.02558E+02  +6.35535E+00
+ -1.02457E+02  +5.52897E+00
+ -1.02320E+02  +4.65326E+00
+ -1.02184E+02  +3.77753E+00
+ -1.02259E+02  +3.75071E+00
+ -1.02199E+02  +3.45816E+00
+ -1.02219E+02  +3.23869E+00
+> CO-NZ                      Mueller et al. [1987]
+ -9.97389E+01  +2.26882E+00
+ -9.96570E+01  +2.19007E+00
+ -9.89175E+01  +2.11218E+00
+ -9.88886E+01  +2.21253E+00
+ -9.83674E+01  +2.14463E+00
+ -9.78463E+01  +2.07656E+00
+ -9.75512E+01  +2.08841E+00
+ -9.75851E+01  +1.89824E+00
+ -9.68800E+01  +1.88568E+00
+ -9.61750E+01  +1.87283E+00
+ -9.61202E+01  +2.23785E+00
+ -9.52241E+01  +2.22175E+00
+ -9.51982E+01  +2.50694E+00
+ -9.44044E+01  +2.43994E+00
+ -9.36107E+01  +2.37248E+00
+ -9.29279E+01  +2.29988E+00
+ -9.22451E+01  +2.22695E+00
+ -9.20902E+01  +2.19975E+00
+ -9.21183E+01  +1.99009E+00
+ -9.15376E+01  +2.01117E+00
+ -9.15608E+01  +1.81659E+00
+ -9.06973E+01  +1.73615E+00
+ -9.06632E+01  +1.12041E+00
+ -8.97836E+01  +1.07290E+00
+ -8.89041E+01  +1.02514E+00
+ -8.80245E+01  +9.77144E-01
+ -8.71450E+01  +9.28909E-01
+ -8.62656E+01  +8.80462E-01
+ -8.53861E+01  +8.31804E-01
+ -8.53494E+01  +1.64441E+00
+ -8.45759E+01  +1.59812E+00
+ -8.45713E+01  +2.06618E+00
+ -8.45667E+01  +2.53424E+00
+ -8.44671E+01  +3.11226E+00
+ -8.39225E+01  +3.13869E+00
+ -8.33779E+01  +3.16485E+00
+ -8.28064E+01  +3.11792E+00
+ -8.28750E+01  +3.59490E+00
+ -8.28750E+01  +4.07188E+00
+ -8.28750E+01  +4.56303E+00
+ -8.28750E+01  +5.05417E+00
+ -8.28750E+01  +5.83296E+00
+ -8.28750E+01  +6.56231E+00
+ -8.28749E+01  +7.11804E+00
+ -8.28748E+01  +7.36639E+00
+> EU-IN                      by Peter Bird   1999
+ +6.50282E+01  +2.43824E+01
+ +6.54921E+01  +2.46201E+01
+ +6.59578E+01  +2.48564E+01
+ +6.65296E+01  +2.51787E+01
+ +6.71044E+01  +2.54987E+01
+ +6.72681E+01  +2.59839E+01
+ +6.72526E+01  +2.65184E+01
+ +6.72478E+01  +2.70854E+01
+ +6.73322E+01  +2.79115E+01
+ +6.73421E+01  +2.84041E+01
+ +6.72397E+01  +2.85731E+01
+ +6.72767E+01  +2.93768E+01
+ +6.73011E+01  +2.97948E+01
+ +6.78492E+01  +3.00735E+01
+ +6.83105E+01  +2.98780E+01
+ +6.86795E+01  +2.92090E+01
+ +6.90855E+01  +2.90959E+01
+ +6.98806E+01  +2.92618E+01
+ +7.00995E+01  +2.98402E+01
+ +7.01783E+01  +3.04230E+01
+ +7.02580E+01  +3.10057E+01
+ +7.01010E+01  +3.14594E+01
+ +6.99425E+01  +3.19130E+01
+ +7.04394E+01  +3.24310E+01
+ +7.09421E+01  +3.29471E+01
+ +7.13920E+01  +3.34768E+01
+ +7.18474E+01  +3.40048E+01
+ +7.24591E+01  +3.46822E+01
+> EU-IN                      by Peter Bird   1999
+ +7.24591E+01  +3.46822E+01
+ +7.30296E+01  +3.41759E+01
+ +7.35933E+01  +3.36669E+01
+ +7.43142E+01  +3.31594E+01
+ +7.50894E+01  +3.28806E+01
+ +7.56749E+01  +3.21894E+01
+ +7.57220E+01  +3.16333E+01
+ +7.65210E+01  +3.11537E+01
+ +7.70067E+01  +3.07376E+01
+ +7.76407E+01  +3.05580E+01
+ +7.80762E+01  +3.02261E+01
+ +7.84224E+01  +2.98869E+01
+ +7.89118E+01  +2.96776E+01
+ +7.91969E+01  +2.93934E+01
+ +7.97898E+01  +2.91428E+01
+ +8.02265E+01  +2.90930E+01
+ +8.05465E+01  +2.89750E+01
+ +8.10430E+01  +2.87902E+01
+ +8.13610E+01  +2.84135E+01
+ +8.22004E+01  +2.81669E+01
+ +8.29354E+01  +2.78815E+01
+ +8.36667E+01  +2.75929E+01
+ +8.41585E+01  +2.74519E+01
+ +8.46491E+01  +2.73091E+01
+ +8.56219E+01  +2.71704E+01
+ +8.62515E+01  +2.70946E+01
+ +8.64809E+01  +2.67372E+01
+ +8.68204E+01  +2.66683E+01
+ +8.72186E+01  +2.70220E+01
+ +8.77450E+01  +2.69089E+01
+ +8.83200E+01  +2.68850E+01
+ +8.92821E+01  +2.70268E+01
+ +8.97724E+01  +2.68472E+01
+ +9.03294E+01  +2.69370E+01
+ +9.12580E+01  +2.70075E+01
+ +9.17812E+01  +2.70329E+01
+ +9.23047E+01  +2.70564E+01
+ +9.32334E+01  +2.71165E+01
+ +9.35704E+01  +2.71098E+01
+ +9.41890E+01  +2.75008E+01
+ +9.48287E+01  +2.79182E+01
+ +9.54657E+01  +2.81832E+01
+ +9.62345E+01  +2.81349E+01
+ +9.67916E+01  +2.81099E+01
+ +9.73484E+01  +2.80826E+01
+> NA-EU                      by Peter Bird   1999
+ +1.25679E+02  +7.81326E+01
+ +1.26457E+02  +7.76844E+01
+ +1.27181E+02  +7.72341E+01
+ +1.27634E+02  +7.66425E+01
+ +1.28050E+02  +7.60501E+01
+ +1.28519E+02  +7.54945E+01
+ +1.28955E+02  +7.49380E+01
+ +1.29595E+02  +7.44788E+01
+ +1.30200E+02  +7.40179E+01
+ +1.31263E+02  +7.33715E+01
+ +1.32483E+02  +7.26946E+01
+ +1.33267E+02  +7.22815E+01
+ +1.34017E+02  +7.18654E+01
+ +1.34854E+02  +7.12683E+01
+ +1.35595E+02  +7.06916E+01
+ +1.35962E+02  +7.05295E+01
+ +1.36758E+02  +6.99536E+01
+ +1.37368E+02  +6.96349E+01
+ +1.38523E+02  +6.90423E+01
+ +1.38963E+02  +6.84765E+01
+ +1.39381E+02  +6.79097E+01
+ +1.40330E+02  +6.74472E+01
+ +1.41242E+02  +6.69794E+01
+ +1.42503E+02  +6.66537E+01
+ +1.43731E+02  +6.63181E+01
+ +1.44344E+02  +6.58035E+01
+ +1.44932E+02  +6.52865E+01
+> NA-EU                      Mueller et al. [1987]
+ -1.57156E+01  +6.95499E+01
+ -1.54245E+01  +6.98397E+01
+ -1.50245E+01  +7.01685E+01
+ -1.47339E+01  +7.03891E+01
+ -1.44479E+01  +7.03539E+01
+ -1.42367E+01  +7.05174E+01
+ -1.40364E+01  +7.07261E+01
+ -1.38924E+01  +7.08158E+01
+ -1.33957E+01  +7.07716E+01
+ -1.29046E+01  +7.06977E+01
+ -1.22549E+01  +7.05630E+01
+ -1.20094E+01  +7.07065E+01
+ -1.16689E+01  +7.08763E+01
+ -1.13563E+01  +7.10519E+01
+ -1.18649E+01  +7.11472E+01
+ -1.23591E+01  +7.12522E+01
+ -1.21057E+01  +7.13958E+01
+ -1.17138E+01  +7.15878E+01
+ -1.13695E+01  +7.17744E+01
+ -1.03560E+01  +7.16145E+01
+ -9.39339E+00  +7.14561E+01
+ -7.94124E+00  +7.12166E+01
+ -7.37469E+00  +7.11248E+01
+ -6.89992E+00  +7.12816E+01
+ -6.33268E+00  +7.13872E+01
+ -5.91711E+00  +7.14646E+01
+ -5.69853E+00  +7.15398E+01
+ -5.15729E+00  +7.14310E+01
+ -4.74125E+00  +7.13332E+01
+ -4.36039E+00  +7.14324E+01
+ -4.07245E+00  +7.14905E+01
+ -3.69231E+00  +7.13980E+01
+ -2.93661E+00  +7.15002E+01
+ -2.39894E+00  +7.15917E+01
+ -1.74252E+00  +7.16851E+01
+ -9.75025E-01  +7.18151E+01
+ -3.92476E-01  +7.19105E+01
+ +2.81065E-01  +7.20148E+01
+ +9.00715E-01  +7.21337E+01
+ +1.99058E+00  +7.23278E+01
+ +2.78103E+00  +7.24331E+01
+ +3.60937E+00  +7.25801E+01
+ +4.29990E+00  +7.26970E+01
+ +4.96961E+00  +7.28205E+01
+ +5.58598E+00  +7.29243E+01
+ +6.05514E+00  +7.30188E+01
+ +6.78173E+00  +7.31448E+01
+ +7.07072E+00  +7.32035E+01
+ +7.39100E+00  +7.32524E+01
+ +7.79122E+00  +7.33712E+01
+ +8.15023E+00  +7.34272E+01
+ +8.38583E+00  +7.34853E+01
+ +8.65212E+00  +7.35335E+01
+ +8.83803E+00  +7.36282E+01
+ +8.95698E+00  +7.37064E+01
+ +9.03691E+00  +7.37585E+01
+ +9.13963E+00  +7.38820E+01
+ +9.20295E+00  +7.39795E+01
+ +9.20769E+00  +7.40964E+01
+ +9.15258E+00  +7.42327E+01
+ +9.13259E+00  +7.43772E+01
+ +8.98399E+00  +7.45426E+01
+ +8.78099E+00  +7.47631E+01
+ +8.63037E+00  +7.49462E+01
+ +8.46028E+00  +7.50755E+01
+ +8.21220E+00  +7.51882E+01
+ +7.94643E+00  +7.53817E+01
+ +7.84163E+00  +7.55273E+01
+ +7.60333E+00  +7.57289E+01
+ +7.59292E+00  +7.59807E+01
+ +7.51523E+00  +7.61167E+01
+ +7.48044E+00  +7.62790E+01
+ +7.55713E+00  +7.64307E+01
+ +7.56302E+00  +7.66015E+01
+ +7.61545E+00  +7.67985E+01
+ +7.62226E+00  +7.69692E+01
+ +7.67201E+00  +7.71484E+01
+ +7.80900E+00  +7.74791E+01
+ +7.88003E+00  +7.77119E+01
+ +7.77119E+00  +7.79112E+01
+ +7.82691E+00  +7.80903E+01
+ +7.78484E+00  +7.82347E+01
+ +6.77554E+00  +7.84438E+01
+ +5.59209E+00  +7.86410E+01
+ +4.69068E+00  +7.88058E+01
+ +3.85706E+00  +7.89500E+01
+ +3.43173E+00  +7.90302E+01
+ +3.90068E+00  +7.92280E+01
+ +4.39026E+00  +7.95327E+01
+ +3.29588E+00  +7.96575E+01
+ +2.37761E+00  +7.97797E+01
+ +1.48660E+00  +7.99085E+01
+ +6.27928E-01  +8.00264E+01
+ -2.50723E-01  +8.01421E+01
+ -9.68769E-01  +8.02132E+01
+ -1.76559E+00  +8.03085E+01
+ -2.34079E+00  +8.03704E+01
+ -1.68388E+00  +8.06248E+01
+ -2.94156E+00  +8.07555E+01
+ -3.36375E+00  +8.07922E+01
+ -2.77949E+00  +8.09929E+01
+ -2.41413E+00  +8.11256E+01
+ -3.45411E+00  +8.12505E+01
+ -4.64116E+00  +8.13697E+01
+ -4.15208E+00  +8.15521E+01
+ -3.90911E+00  +8.16203E+01
+ -5.03297E+00  +8.19128E+01
+ -4.53664E+00  +8.20501E+01
+ -3.79607E+00  +8.22903E+01
+ -3.69993E+00  +8.23281E+01
+ -5.00975E+00  +8.25194E+01
+ -5.86541E+00  +8.26912E+01
+ -7.21240E+00  +8.28685E+01
+ -6.23430E+00  +8.30004E+01
+ -5.15419E+00  +8.32491E+01
+ -4.14804E+00  +8.34296E+01
+ -3.20433E+00  +8.35703E+01
+ -2.36257E+00  +8.36896E+01
+ -1.20617E+00  +8.38642E+01
+ -4.69122E-01  +8.39965E+01
+ +4.04991E-01  +8.41017E+01
+ +1.30114E+00  +8.42233E+01
+ +2.23513E+00  +8.43435E+01
+ +3.02402E+00  +8.44618E+01
+ +3.84819E+00  +8.45611E+01
+ +4.03467E+00  +8.45969E+01
+ +4.50755E+00  +8.45702E+01
+ +5.17750E+00  +8.46321E+01
+ +6.66540E+00  +8.47622E+01
+ +8.13393E+00  +8.48982E+01
+ +8.93766E+00  +8.50094E+01
+ +9.80850E+00  +8.49579E+01
+ +1.06588E+01  +8.50670E+01
+ +1.17036E+01  +8.51373E+01
+ +1.32420E+01  +8.52814E+01
+ +1.46662E+01  +8.53797E+01
+ +1.60626E+01  +8.54855E+01
+ +1.78900E+01  +8.55912E+01
+ +1.92845E+01  +8.56842E+01
+ +2.13426E+01  +8.57987E+01
+ +2.33470E+01  +8.58174E+01
+ +2.53828E+01  +8.58591E+01
+ +2.74273E+01  +8.58674E+01
+ +2.81433E+01  +8.58745E+01
+ +2.92294E+01  +8.58101E+01
+ +3.09721E+01  +8.59083E+01
+ +3.33400E+01  +8.60534E+01
+ +3.56067E+01  +8.61607E+01
+ +3.83013E+01  +8.62915E+01
+ +4.17555E+01  +8.64316E+01
+ +4.34795E+01  +8.64958E+01
+ +4.63137E+01  +8.65612E+01
+ +4.60625E+01  +8.65982E+01
+ +4.75235E+01  +8.66406E+01
+ +5.07696E+01  +8.67060E+01
+ +5.45614E+01  +8.67459E+01
+ +5.80178E+01  +8.67875E+01
+ +6.15056E+01  +8.68049E+01
+ +6.24625E+01  +8.67548E+01
+ +6.65438E+01  +8.66549E+01
+ +6.63010E+01  +8.66065E+01
+ +6.97522E+01  +8.64724E+01
+ +6.82081E+01  +8.63058E+01
+ +7.09259E+01  +8.62026E+01
+ +7.29842E+01  +8.61063E+01
+ +7.50293E+01  +8.59885E+01
+ +7.63260E+01  +8.59167E+01
+ +7.84034E+01  +8.57682E+01
+ +8.11027E+01  +8.56388E+01
+ +8.31425E+01  +8.55560E+01
+ +8.48021E+01  +8.54998E+01
+ +8.68021E+01  +8.54175E+01
+ +8.84863E+01  +8.53456E+01
+ +8.99804E+01  +8.52957E+01
+ +9.23129E+01  +8.52292E+01
+ +9.41554E+01  +8.51545E+01
+ +9.58392E+01  +8.51018E+01
+ +9.72727E+01  +8.50279E+01
+ +9.85682E+01  +8.49604E+01
+ +9.94436E+01  +8.49108E+01
+ +1.02918E+02  +8.46639E+01
+ +1.03943E+02  +8.45785E+01
+ +1.05302E+02  +8.44855E+01
+ +1.06759E+02  +8.43686E+01
+ +1.07709E+02  +8.42946E+01
+ +1.08939E+02  +8.41936E+01
+ +1.09727E+02  +8.41097E+01
+ +1.10959E+02  +8.39655E+01
+ +1.11974E+02  +8.38238E+01
+ +1.12843E+02  +8.36744E+01
+ +1.13723E+02  +8.35124E+01
+ +1.14558E+02  +8.33209E+01
+ +1.15258E+02  +8.31508E+01
+ +1.15793E+02  +8.30141E+01
+ +1.16582E+02  +8.27402E+01
+ +1.17171E+02  +8.25394E+01
+ +1.17755E+02  +8.22981E+01
+ +1.19100E+02  +8.20874E+01
+ +1.19984E+02  +8.15953E+01
+ +1.21004E+02  +8.11146E+01
+ +1.21898E+02  +8.06434E+01
+ +1.22639E+02  +8.02061E+01
+ +1.23408E+02  +7.97593E+01
+ +1.25188E+02  +7.89901E+01
+ +1.25679E+02  +7.81326E+01
+> NA-EU                      Mueller et al. [1987]
+ -2.97698E+01  +3.93996E+01
+ -2.96089E+01  +3.99928E+01
+ -2.96127E+01  +4.00328E+01
+ -2.95802E+01  +4.00788E+01
+ -2.95881E+01  +4.01065E+01
+ -2.96565E+01  +4.01068E+01
+ -2.96398E+01  +4.02082E+01
+ -2.96313E+01  +4.02851E+01
+ -2.95984E+01  +4.03835E+01
+ -2.95695E+01  +4.04695E+01
+ -2.95770E+01  +4.05495E+01
+ -2.95605E+01  +4.05987E+01
+ -2.93460E+01  +4.05699E+01
+ -2.92999E+01  +4.07050E+01
+ -2.92777E+01  +4.08710E+01
+ -2.92560E+01  +4.09847E+01
+ -2.92420E+01  +4.11261E+01
+ -2.92286E+01  +4.12153E+01
+ -2.93223E+01  +4.12467E+01
+ -2.92920E+01  +4.13849E+01
+ -2.92452E+01  +4.15200E+01
+ -2.92060E+01  +4.16828E+01
+ -2.92003E+01  +4.17997E+01
+ -2.91616E+01  +4.19101E+01
+ -2.92606E+01  +4.19294E+01
+ -2.92420E+01  +4.20831E+01
+ -2.92449E+01  +4.21754E+01
+ -2.92233E+01  +4.22368E+01
+ -2.92226E+01  +4.22891E+01
+ -2.94347E+01  +4.22905E+01
+ -2.93918E+01  +4.24133E+01
+ -2.93696E+01  +4.25271E+01
+ -2.93394E+01  +4.26130E+01
+ -2.93177E+01  +4.26744E+01
+ -2.93214E+01  +4.27145E+01
+ -2.93715E+01  +4.27240E+01
+ -2.93492E+01  +4.28378E+01
+ -2.93268E+01  +4.29515E+01
+ -2.93175E+01  +4.30284E+01
+ -2.93168E+01  +4.30807E+01
+ -2.91736E+01  +4.30796E+01
+ -2.90914E+01  +4.32082E+01
+ -2.90079E+01  +4.33890E+01
+ -2.89339E+01  +4.34929E+01
+ -2.88845E+01  +4.36278E+01
+ -2.88405E+01  +4.36981E+01
+ -2.87964E+01  +4.37684E+01
+ -2.85237E+01  +4.37680E+01
+ -2.85131E+01  +4.38448E+01
+ -2.84809E+01  +4.39305E+01
+ -2.84827E+01  +4.40229E+01
+ -2.84549E+01  +4.40963E+01
+ -2.84364E+01  +4.41453E+01
+ -2.84349E+01  +4.41976E+01
+ -2.83666E+01  +4.41843E+01
+ -2.83200E+01  +4.43067E+01
+ -2.82825E+01  +4.44046E+01
+ -2.82574E+01  +4.45180E+01
+ -2.82150E+01  +4.46281E+01
+ -2.81676E+01  +4.47505E+01
+ -2.81438E+01  +4.48116E+01
+ -2.81421E+01  +4.48639E+01
+ -2.81057E+01  +4.49094E+01
+ -2.81575E+01  +4.49196E+01
+ -2.81385E+01  +4.49685E+01
+ -2.81146E+01  +4.50296E+01
+ -2.81002E+01  +4.50663E+01
+ -2.80763E+01  +4.51274E+01
+ -2.79945E+01  +4.50983E+01
+ -2.79877E+01  +4.51628E+01
+ -2.79857E+01  +4.52151E+01
+ -2.79790E+01  +4.52796E+01
+ -2.79721E+01  +4.53441E+01
+ -2.79374E+01  +4.53373E+01
+ -2.79354E+01  +4.53896E+01
+ -2.79382E+01  +4.54296E+01
+ -2.79236E+01  +4.54663E+01
+ -2.78714E+01  +4.54561E+01
+ -2.78616E+01  +4.54805E+01
+ -2.78644E+01  +4.55206E+01
+ -2.78770E+01  +4.55362E+01
+ -2.78246E+01  +4.55259E+01
+ -2.77952E+01  +4.55992E+01
+ -2.77734E+01  +4.57003E+01
+ -2.77592E+01  +4.58293E+01
+ -2.77394E+01  +4.58782E+01
+ -2.76994E+01  +4.58835E+01
+ -2.76971E+01  +4.59358E+01
+ -2.76773E+01  +4.59846E+01
+ -2.76020E+01  +4.59830E+01
+ -2.75847E+01  +4.60719E+01
+ -2.75723E+01  +4.61486E+01
+ -2.75649E+01  +4.62131E+01
+ -2.75120E+01  +4.62027E+01
+ -2.74893E+01  +4.63037E+01
+ -2.74868E+01  +4.63560E+01
+ -2.74717E+01  +4.64850E+01
+ -2.74463E+01  +4.66383E+01
+ -2.74437E+01  +4.66906E+01
+ -2.74360E+01  +4.67551E+01
+ -2.73775E+01  +4.67568E+01
+ -2.73774E+01  +4.68491E+01
+ -2.73466E+01  +4.69223E+01
+ -2.73336E+01  +4.69990E+01
+ -2.73819E+01  +4.71140E+01
+ -2.74407E+01  +4.72047E+01
+ -2.74741E+01  +4.72640E+01
+ -2.74612E+01  +4.73406E+01
+ -2.74585E+01  +4.73929E+01
+ -2.74636E+01  +4.74731E+01
+ -2.74429E+01  +4.75219E+01
+ -2.74480E+01  +4.76020E+01
+ -2.74635E+01  +4.76578E+01
+ -2.75644E+01  +4.76508E+01
+ -2.75905E+01  +4.77746E+01
+ -2.76218E+01  +4.78861E+01
+ -2.76351E+01  +4.79942E+01
+ -2.76536E+01  +4.80900E+01
+ -2.77036E+01  +4.82050E+01
+ -2.77118E+01  +4.83252E+01
+ -2.77306E+01  +4.84210E+01
+ -2.77494E+01  +4.85169E+01
+ -2.77602E+01  +4.85848E+01
+ -2.78895E+01  +4.86089E+01
+ -2.80108E+01  +4.86050E+01
+ -2.80353E+01  +4.86885E+01
+ -2.80868E+01  +4.88034E+01
+ -2.81622E+01  +4.89093E+01
+ -2.82058E+01  +4.89962E+01
+ -2.82631E+01  +4.90987E+01
+ -2.83174E+01  +4.91611E+01
+ -2.83530E+01  +4.92201E+01
+ -2.84262E+01  +4.92858E+01
+ -2.84518E+01  +4.93693E+01
+ -2.84861E+01  +4.94806E+01
+ -2.85446E+01  +4.95830E+01
+ -2.85619E+01  +4.96386E+01
+ -2.87183E+01  +4.96528E+01
+ -2.88181E+01  +4.96570E+01
+ -2.88686E+01  +4.97314E+01
+ -2.88952E+01  +4.98148E+01
+ -2.89600E+01  +4.99047E+01
+ -2.89868E+01  +4.99880E+01
+ -2.89947E+01  +5.00681E+01
+ -2.90217E+01  +5.01515E+01
+ -2.91265E+01  +5.01954E+01
+ -2.91982E+01  +5.02206E+01
+ -2.93218E+01  +5.03199E+01
+ -2.94266E+01  +5.04159E+01
+ -2.95081E+01  +5.04686E+01
+ -2.95368E+01  +5.04995E+01
+ -2.96619E+01  +5.05984E+01
+ -2.97680E+01  +5.06941E+01
+ -2.98309E+01  +5.07435E+01
+ -2.98746E+01  +5.07897E+01
+ -2.99085E+01  +5.08605E+01
+ -2.99425E+01  +5.09313E+01
+ -2.99815E+01  +5.09898E+01
+ -2.99765E+01  +5.11067E+01
+ -3.00010E+01  +5.12544E+01
+ -2.99961E+01  +5.14236E+01
+ -3.00010E+01  +5.16205E+01
+ -3.00060E+01  +5.17652E+01
+ -3.00110E+01  +5.18575E+01
+ -3.00361E+01  +5.19528E+01
+ -3.00262E+01  +5.20297E+01
+ -3.03764E+01  +5.20568E+01
+ -3.08074E+01  +5.20945E+01
+ -3.10579E+01  +5.21048E+01
+ -3.12684E+01  +5.21089E+01
+ -3.12527E+01  +5.22628E+01
+ -3.12651E+01  +5.23427E+01
+ -3.12573E+01  +5.24197E+01
+ -3.15817E+01  +5.24649E+01
+ -3.18660E+01  +5.25038E+01
+ -3.20535E+01  +5.25160E+01
+ -3.23589E+01  +5.25564E+01
+ -3.26486E+01  +5.25810E+01
+ -3.28570E+01  +5.25946E+01
+ -3.30204E+01  +5.26151E+01
+ -3.33354E+01  +5.26281E+01
+ -3.37119E+01  +5.26477E+01
+ -3.41745E+01  +5.26630E+01
+ -3.45719E+01  +5.26822E+01
+ -3.49248E+01  +5.27080E+01
+ -3.48837E+01  +5.27036E+01
+ -3.50107E+01  +5.27044E+01
+ -3.51376E+01  +5.27051E+01
+ -3.51561E+01  +5.28611E+01
+ -3.51613E+01  +5.29901E+01
+ -3.51837E+01  +5.31336E+01
+ -3.51828E+01  +5.32105E+01
+ -3.53248E+01  +5.32380E+01
+ -3.52818E+01  +5.33875E+01
+ -3.52565E+01  +5.34747E+01
+ -3.52457E+01  +5.35121E+01
+ -3.54517E+01  +5.35459E+01
+ -3.53950E+01  +5.36684E+01
+ -3.53272E+01  +5.38282E+01
+ -3.52698E+01  +5.39507E+01
+ -3.52012E+01  +5.41105E+01
+ -3.51469E+01  +5.42204E+01
+ -3.51210E+01  +5.43076E+01
+ -3.53132E+01  +5.43269E+01
+ -3.54878E+01  +5.43313E+01
+ -3.54123E+01  +5.45161E+01
+ -3.53651E+01  +5.46781E+01
+ -3.52890E+01  +5.47860E+01
+ -3.52739E+01  +5.49127E+01
+ -3.52120E+01  +5.49707E+01
+ -3.53386E+01  +5.49959E+01
+ -3.52508E+01  +5.51412E+01
+ -3.51732E+01  +5.53259E+01
+ -3.50804E+01  +5.54835E+01
+ -3.49717E+01  +5.56909E+01
+ -3.49006E+01  +5.57738E+01
+ -3.48774E+01  +5.58485E+01
+ -3.46376E+01  +5.58119E+01
+ -3.46203E+01  +5.59386E+01
+ -3.45583E+01  +5.60608E+01
+ -3.45104E+01  +5.62101E+01
+ -3.44927E+01  +5.63368E+01
+ -3.44604E+01  +5.64363E+01
+ -3.44402E+01  +5.64985E+01
+ -3.43460E+01  +5.65020E+01
+ -3.43214E+01  +5.65766E+01
+ -3.42474E+01  +5.66592E+01
+ -3.42185E+01  +5.67462E+01
+ -3.40724E+01  +5.67388E+01
+ -3.40430E+01  +5.67799E+01
+ -3.40035E+01  +5.68274E+01
+ -3.39781E+01  +5.69019E+01
+ -3.37961E+01  +5.68833E+01
+ -3.36824E+01  +5.68715E+01
+ -3.35871E+01  +5.68745E+01
+ -3.35662E+01  +5.70010E+01
+ -3.35354E+01  +5.70880E+01
+ -3.35090E+01  +5.71625E+01
+ -3.34966E+01  +5.72643E+01
+ -3.33773E+01  +5.72647E+01
+ -3.32031E+01  +5.72849E+01
+ -3.30703E+01  +5.74512E+01
+ -3.30104E+01  +5.75480E+01
+ -3.29641E+01  +5.76076E+01
+ -3.29177E+01  +5.76671E+01
+ -3.28065E+01  +5.76422E+01
+ -3.27082E+01  +5.77735E+01
+ -3.26188E+01  +5.78800E+01
+ -3.24918E+01  +5.79566E+01
+ -3.24724E+01  +5.80062E+01
+ -3.22805E+01  +5.79979E+01
+ -3.21225E+01  +5.81484E+01
+ -3.19835E+01  +5.82492E+01
+ -3.18723E+01  +5.83402E+01
+ -3.17996E+01  +5.83967E+01
+ -3.17451E+01  +5.84683E+01
+ -3.15560E+01  +5.84466E+01
+ -3.14274E+01  +5.85743E+01
+ -3.13031E+01  +5.86896E+01
+ -3.11780E+01  +5.88048E+01
+ -3.10392E+01  +5.88923E+01
+ -3.09770E+01  +5.89759E+01
+ -3.07911E+01  +5.89408E+01
+ -3.06466E+01  +5.90925E+01
+ -3.04527E+01  +5.92383E+01
+ -3.03055E+01  +5.93897E+01
+ -3.01630E+01  +5.95286E+01
+ -3.00429E+01  +5.96182E+01
+ -2.98495E+01  +5.97508E+01
+ -2.96362E+01  +5.98678E+01
+ -2.95075E+01  +5.99692E+01
+ -2.93717E+01  +6.00827E+01
+> PA\OK                      Mueller et al. [1987]
+ +1.44454E+02  +4.08470E+01
+ +1.44479E+02  +4.05494E+01
+ +1.44399E+02  +4.03668E+01
+ +1.44328E+02  +4.02029E+01
+ +1.44283E+02  +4.00672E+01
+ +1.44254E+02  +3.99281E+01
+ +1.44225E+02  +3.97667E+01
+ +1.44236E+02  +3.95572E+01
+ +1.44203E+02  +3.93737E+01
+ +1.44189E+02  +3.91233E+01
+ +1.44119E+02  +3.89086E+01
+ +1.44061E+02  +3.87095E+01
+ +1.44017E+02  +3.85356E+01
+ +1.43973E+02  +3.83585E+01
+ +1.43928E+02  +3.81655E+01
+ +1.43888E+02  +3.79281E+01
+ +1.43843E+02  +3.77097E+01
+ +1.43743E+02  +3.74792E+01
+ +1.43637E+02  +3.72899E+01
+ +1.43518E+02  +3.70594E+01
+ +1.43408E+02  +3.68604E+01
+ +1.43275E+02  +3.66488E+01
+ +1.43151E+02  +3.65195E+01
+ +1.43020E+02  +3.63393E+01
+ +1.42887E+02  +3.62636E+01
+ +1.42761E+02  +3.61878E+01
+ +1.42681E+02  +3.60642E+01
+ +1.42606E+02  +3.60009E+01
+ +1.42555E+02  +3.59438E+01
+ +1.42460E+02  +3.56730E+01
+ +1.42325E+02  +3.55027E+01
+ +1.42221E+02  +3.53333E+01
+ +1.42170E+02  +3.52168E+01
+ +1.42067E+02  +3.51636E+01
+ +1.42029E+02  +3.48886E+01
+ +1.41992E+02  +3.46663E+01
+ +1.41883E+02  +3.42127E+01
+> PA-JF                      Mueller et al. [1987]; N end by Peter Bird   1999
+ -1.24742E+02  +4.03134E+01
+ -1.25450E+02  +4.03541E+01
+ -1.26159E+02  +4.03904E+01
+ -1.26869E+02  +4.04224E+01
+ -1.27579E+02  +4.04500E+01
+ -1.27579E+02  +4.05385E+01
+ -1.27717E+02  +4.05726E+01
+ -1.27639E+02  +4.10807E+01
+ -1.27560E+02  +4.15888E+01
+ -1.27446E+02  +4.15551E+01
+ -1.27401E+02  +4.16405E+01
+ -1.27241E+02  +4.16921E+01
+ -1.27039E+02  +4.23570E+01
+ -1.26627E+02  +4.30136E+01
+ -1.27571E+02  +4.34195E+01
+ -1.28528E+02  +4.38176E+01
+ -1.29498E+02  +4.42075E+01
+ -1.30480E+02  +4.45892E+01
+ -1.30367E+02  +4.49295E+01
+ -1.30069E+02  +4.52854E+01
+ -1.30187E+02  +4.54140E+01
+ -1.29936E+02  +4.57362E+01
+ -1.29869E+02  +4.58960E+01
+ -1.30073E+02  +4.59427E+01
+ -1.30051E+02  +4.61958E+01
+ -1.29917E+02  +4.62291E+01
+ -1.29803E+02  +4.64332E+01
+ -1.29572E+02  +4.64015E+01
+ -1.29259E+02  +4.70647E+01
+ -1.28938E+02  +4.77270E+01
+ -1.29190E+02  +4.78354E+01
+ -1.28940E+02  +4.83236E+01
+ -1.29147E+02  +4.84760E+01
+ -1.28919E+02  +4.88687E+01
+ -1.29705E+02  +4.91768E+01
+ -1.30501E+02  +4.94794E+01
+ -1.30162E+02  +4.99827E+01
+ -1.30300E+02  +5.00554E+01
+ -1.30162E+02  +5.02172E+01
+ -1.30329E+02  +5.02979E+01
+ -1.30254E+02  +5.04647E+01
+ -1.30753E+02  +5.09076E+01
+ -1.31074E+02  +5.11851E+01
+ -1.30850E+02  +5.16121E+01
+> JF\NA                      by Peter Bird   1999
+ -1.24742E+02  +4.03134E+01
+ -1.24953E+02  +4.06333E+01
+ -1.24933E+02  +4.08839E+01
+ -1.25089E+02  +4.11354E+01
+ -1.25182E+02  +4.13801E+01
+ -1.25309E+02  +4.16522E+01
+ -1.25281E+02  +4.18176E+01
+ -1.25313E+02  +4.19856E+01
+ -1.25331E+02  +4.21419E+01
+ -1.25290E+02  +4.22845E+01
+ -1.25209E+02  +4.23588E+01
+ -1.25198E+02  +4.24917E+01
+ -1.25268E+02  +4.25614E+01
+ -1.25289E+02  +4.28624E+01
+ -1.25289E+02  +4.30514E+01
+ -1.25343E+02  +4.31426E+01
+ -1.25394E+02  +4.32671E+01
+ -1.25474E+02  +4.34260E+01
+ -1.25480E+02  +4.37375E+01
+ -1.25450E+02  +4.39254E+01
+ -1.25429E+02  +4.40023E+01
+ -1.25362E+02  +4.40663E+01
+ -1.25372E+02  +4.43226E+01
+ -1.25372E+02  +4.45227E+01
+ -1.25376E+02  +4.46675E+01
+ -1.25434E+02  +4.47254E+01
+ -1.25437E+02  +4.48813E+01
+ -1.25435E+02  +4.51036E+01
+ -1.25517E+02  +4.54738E+01
+ -1.25655E+02  +4.59461E+01
+ -1.25773E+02  +4.62950E+01
+ -1.25876E+02  +4.66433E+01
+ -1.25998E+02  +4.69697E+01
+ -1.26085E+02  +4.73503E+01
+ -1.26370E+02  +4.77480E+01
+ -1.26486E+02  +4.79956E+01
+ -1.26733E+02  +4.82910E+01
+ -1.27018E+02  +4.85646E+01
+ -1.27378E+02  +4.87502E+01
+ -1.27608E+02  +4.88768E+01
+ -1.27818E+02  +4.90802E+01
+ -1.27852E+02  +4.94906E+01
+ -1.28029E+02  +4.97814E+01
+ -1.28283E+02  +4.98847E+01
+ -1.28414E+02  +5.00856E+01
+ -1.28719E+02  +5.03103E+01
+ -1.29010E+02  +5.04787E+01
+ -1.29460E+02  +5.06472E+01
+ -1.29738E+02  +5.08359E+01
+ -1.29982E+02  +5.11013E+01
+ -1.30212E+02  +5.12777E+01
+ -1.30548E+02  +5.13981E+01
+ -1.30850E+02  +5.16121E+01
+> OK/PA                      by Peter Bird   1999
+ +1.44454E+02  +4.08470E+01
+ +1.45077E+02  +4.13192E+01
+ +1.45710E+02  +4.17880E+01
+ +1.46198E+02  +4.20762E+01
+ +1.46690E+02  +4.23623E+01
+ +1.47345E+02  +4.26851E+01
+ +1.48340E+02  +4.32079E+01
+ +1.49311E+02  +4.37205E+01
+ +1.50339E+02  +4.41874E+01
+ +1.50877E+02  +4.44470E+01
+ +1.51419E+02  +4.47040E+01
+ +1.52240E+02  +4.51576E+01
+ +1.52880E+02  +4.55293E+01
+ +1.53528E+02  +4.58973E+01
+ +1.54195E+02  +4.64400E+01
+ +1.54664E+02  +4.68526E+01
+ +1.55141E+02  +4.72632E+01
+ +1.55742E+02  +4.77246E+01
+ +1.56353E+02  +4.81828E+01
+ +1.57024E+02  +4.86594E+01
+ +1.57568E+02  +4.91072E+01
+ +1.58121E+02  +4.95524E+01
+ +1.58644E+02  +4.98546E+01
+ +1.59174E+02  +5.01545E+01
+ +1.59877E+02  +5.08551E+01
+ +1.60599E+02  +5.14877E+01
+ +1.60945E+02  +5.21588E+01
+ +1.61584E+02  +5.26540E+01
+ +1.62458E+02  +5.30032E+01
+ +1.62790E+02  +5.36249E+01
+ +1.63282E+02  +5.43468E+01
+ +1.63670E+02  +5.47786E+01
+ +1.64066E+02  +5.52092E+01
+> NA/PA                      by Peter Bird   September 2001
+ +1.64066E+02  +5.52092E+01
+ +1.64847E+02  +5.49570E+01
+ +1.65771E+02  +5.45884E+01
+ +1.66407E+02  +5.42367E+01
+ +1.67413E+02  +5.39060E+01
+ +1.68188E+02  +5.35694E+01
+ +1.68836E+02  +5.32079E+01
+ +1.69752E+02  +5.28555E+01
+ +1.70700E+02  +5.24979E+01
+ +1.71847E+02  +5.20259E+01
+ +1.72964E+02  +5.16839E+01
+ +1.74219E+02  +5.14030E+01
+ +1.75571E+02  +5.11082E+01
+ +1.76720E+02  +5.08959E+01
+ +1.77680E+02  +5.06976E+01
+ +1.78498E+02  +5.06189E+01
+ +1.79688E+02  +5.05055E+01
+ -1.79202E+02  +5.04965E+01
+ -1.78480E+02  +5.04903E+01
+ -1.77758E+02  +5.04842E+01
+ -1.77088E+02  +5.04960E+01
+ -1.76223E+02  +5.05883E+01
+ -1.75629E+02  +5.07447E+01
+ -1.74907E+02  +5.08258E+01
+ -1.74119E+02  +5.08963E+01
+ -1.73328E+02  +5.09636E+01
+ -1.72484E+02  +5.10693E+01
+ -1.71634E+02  +5.11706E+01
+ -1.70897E+02  +5.13061E+01
+ -1.70159E+02  +5.14395E+01
+ -1.69378E+02  +5.16322E+01
+ -1.68972E+02  +5.17400E+01
+ -1.67990E+02  +5.20007E+01
+ -1.66819E+02  +5.22568E+01
+ -1.66108E+02  +5.24527E+01
+ -1.65390E+02  +5.26443E+01
+ -1.64665E+02  +5.28183E+01
+ -1.63934E+02  +5.29879E+01
+ -1.63177E+02  +5.31800E+01
+ -1.62413E+02  +5.33672E+01
+ -1.61664E+02  +5.34964E+01
+ -1.60910E+02  +5.36209E+01
+ -1.60129E+02  +5.37408E+01
+ -1.59344E+02  +5.38555E+01
+ -1.57986E+02  +5.41008E+01
+ -1.57067E+02  +5.43175E+01
+ -1.56138E+02  +5.45272E+01
+ -1.55239E+02  +5.47845E+01
+ -1.54160E+02  +5.52390E+01
+ -1.53164E+02  +5.56104E+01
+ -1.52227E+02  +5.60583E+01
+ -1.51218E+02  +5.63092E+01
+ -1.50547E+02  +5.64994E+01
+ -1.50081E+02  +5.66229E+01
+ -1.49220E+02  +5.69251E+01
+ -1.48257E+02  +5.73469E+01
+ -1.47449E+02  +5.78319E+01
+ -1.46759E+02  +5.83521E+01
+ -1.46264E+02  +5.88138E+01
+ -1.45756E+02  +5.92735E+01
+> NA-PA                      by Peter Bird   1999
+ -1.45756E+02  +5.92735E+01
+ -1.44977E+02  +5.95759E+01
+ -1.44316E+02  +5.99182E+01
+ -1.43332E+02  +6.02057E+01
+ -1.42405E+02  +6.04650E+01
+ -1.41598E+02  +6.04009E+01
+ -1.41074E+02  +6.03099E+01
+ -1.40128E+02  +6.03809E+01
+ -1.39396E+02  +6.00897E+01
+ -1.38860E+02  +5.97619E+01
+ -1.38353E+02  +5.93357E+01
+ -1.37819E+02  +5.89251E+01
+ -1.37107E+02  +5.84379E+01
+ -1.36895E+02  +5.80895E+01
+ -1.36522E+02  +5.76342E+01
+ -1.36209E+02  +5.71178E+01
+ -1.35903E+02  +5.66210E+01
+ -1.35429E+02  +5.61024E+01
+ -1.35180E+02  +5.58186E+01
+ -1.34669E+02  +5.53165E+01
+ -1.34151E+02  +5.48122E+01
+ -1.33840E+02  +5.43774E+01
+ -1.33426E+02  +5.39241E+01
+ -1.33093E+02  +5.35217E+01
+ -1.32714E+02  +5.31270E+01
+ -1.32169E+02  +5.26971E+01
+ -1.31592E+02  +5.22591E+01
+ -1.31177E+02  +5.18858E+01
+ -1.30850E+02  +5.16121E+01
+> NA-PA                      by Peter Bird   1999
+ -1.24742E+02  +4.03134E+01
+ -1.24416E+02  +4.03107E+01
+ -1.24163E+02  +3.99142E+01
+ -1.23890E+02  +3.94388E+01
+ -1.23597E+02  +3.89971E+01
+ -1.23305E+02  +3.85406E+01
+ -1.22696E+02  +3.78740E+01
+ -1.22380E+02  +3.75270E+01
+ -1.22005E+02  +3.72048E+01
+ -1.21305E+02  +3.66983E+01
+ -1.20897E+02  +3.63377E+01
+ -1.20438E+02  +3.59102E+01
+ -1.19936E+02  +3.54502E+01
+ -1.19329E+02  +3.49812E+01
+ -1.18912E+02  +3.48373E+01
+ -1.18400E+02  +3.46580E+01
+ -1.18072E+02  +3.45641E+01
+ -1.17746E+02  +3.44412E+01
+ -1.17507E+02  +3.43498E+01
+ -1.17159E+02  +3.41811E+01
+ -1.16660E+02  +3.40424E+01
+ -1.16209E+02  +3.37711E+01
+ -1.15773E+02  +3.34211E+01
+> NA-PA                      Mueller et al. [1987]
+ -1.15773E+02  +3.34211E+01
+ -1.15596E+02  +3.32366E+01
+ -1.15717E+02  +3.31297E+01
+ -1.15594E+02  +3.30402E+01
+ -1.15508E+02  +3.29581E+01
+ -1.15581E+02  +3.28760E+01
+ -1.15412E+02  +3.27100E+01
+ -1.15212E+02  +3.25118E+01
+ -1.15330E+02  +3.24183E+01
+ -1.15085E+02  +3.22359E+01
+ -1.14765E+02  +3.19952E+01
+ -1.14522E+02  +3.17860E+01
+ -1.14332E+02  +3.16016E+01
+ -1.14207E+02  +3.14585E+01
+ -1.14118E+02  +3.13557E+01
+ -1.14330E+02  +3.11936E+01
+ -1.14439E+02  +3.10972E+01
+ -1.14303E+02  +3.09123E+01
+ -1.14129E+02  +3.06797E+01
+ -1.13986E+02  +3.05134E+01
+ -1.13807E+02  +3.03135E+01
+ -1.14041E+02  +3.01205E+01
+ -1.13909E+02  +2.99820E+01
+ -1.13758E+02  +2.98344E+01
+ -1.13870E+02  +2.97298E+01
+ -1.13969E+02  +2.96458E+01
+ -1.13775E+02  +2.94397E+01
+ -1.13521E+02  +2.92054E+01
+ -1.13281E+02  +2.90084E+01
+ -1.13339E+02  +2.89498E+01
+ -1.13087E+02  +2.87147E+01
+ -1.12812E+02  +2.84987E+01
+ -1.12589E+02  +2.83223E+01
+ -1.12321E+02  +2.81249E+01
+ -1.12015E+02  +2.79060E+01
+ -1.11711E+02  +2.76935E+01
+ -1.11506E+02  +2.75700E+01
+ -1.11382E+02  +2.74969E+01
+ -1.11569E+02  +2.72152E+01
+ -1.11373E+02  +2.71053E+01
+ -1.11506E+02  +2.69267E+01
+ -1.11228E+02  +2.67234E+01
+ -1.10957E+02  +2.65350E+01
+ -1.10758E+02  +2.64159E+01
+ -1.10680E+02  +2.63605E+01
+ -1.10778E+02  +2.62249E+01
+ -1.10572E+02  +2.60661E+01
+ -1.10291E+02  +2.58895E+01
+ -1.10024E+02  +2.57063E+01
+ -1.09872E+02  +2.56073E+01
+ -1.09806E+02  +2.55567E+01
+ -1.10007E+02  +2.53392E+01
+ -1.09788E+02  +2.51797E+01
+ -1.09591E+02  +2.50163E+01
+ -1.09350E+02  +2.48568E+01
+ -1.09178E+02  +2.47348E+01
+ -1.09062E+02  +2.46582E+01
+ -1.09276E+02  +2.43960E+01
+ -1.09002E+02  +2.41515E+01
+ -1.08806E+02  +2.39844E+01
+ -1.08610E+02  +2.38141E+01
+ -1.08439E+02  +2.36743E+01
+ -1.08357E+02  +2.36135E+01
+ -1.08651E+02  +2.32413E+01
+ -1.08388E+02  +2.30822E+01
+ -1.08010E+02  +2.29857E+01
+ -1.08232E+02  +2.27117E+01
+> NA-SA                      by Peter Bird   September 2001
+ -6.15534E+01  +1.89589E+01
+ -6.07526E+01  +1.92082E+01
+ -5.99491E+01  +1.94547E+01
+ -5.91305E+01  +1.93251E+01
+ -5.83090E+01  +1.91922E+01
+ -5.74928E+01  +1.90520E+01
+ -5.68045E+01  +1.86941E+01
+ -5.61185E+01  +1.82576E+01
+ -5.54838E+01  +1.77843E+01
+ -5.48525E+01  +1.73090E+01
+ -5.41555E+01  +1.71359E+01
+ -5.34599E+01  +1.69565E+01
+ -5.28812E+01  +1.67607E+01
+ -5.23037E+01  +1.65670E+01
+ -5.16610E+01  +1.63210E+01
+ -5.10241E+01  +1.60729E+01
+ -5.04668E+01  +1.58704E+01
+ -4.98027E+01  +1.59830E+01
+ -4.92071E+01  +1.60346E+01
+ -4.85146E+01  +1.60126E+01
+ -4.76930E+01  +1.59566E+01
+ -4.73984E+01  +1.58043E+01
+ -4.67658E+01  +1.54506E+01
+> NZ-PA                      Mueller et al. [1987]; Naar and Hey [1991]
+ -1.02319E+02  -1.54770E-02
+ -1.02397E+02  -5.03231E-01
+ -1.02524E+02  -1.28284E+00
+ -1.02399E+02  -1.28336E+00
+ -1.02462E+02  -1.53269E+00
+ -1.02307E+02  -1.59589E+00
+ -1.02402E+02  -1.90746E+00
+ -1.02621E+02  -1.90611E+00
+ -1.02687E+02  -2.43571E+00
+ -1.02754E+02  -2.93392E+00
+ -1.02566E+02  -2.93572E+00
+ -1.02571E+02  -3.43472E+00
+ -1.02735E+02  -4.05639E+00
+ -1.03637E+02  -3.95089E+00
+ -1.04539E+02  -3.84440E+00
+ -1.04699E+02  -4.15158E+00
+ -1.05380E+02  -4.07847E+00
+ -1.05544E+02  -4.56935E+00
+ -1.06253E+02  -4.49391E+00
+ -1.06450E+02  -5.04324E+00
+ -1.06587E+02  -5.62383E+00
+ -1.06741E+02  -5.61990E+00
+ -1.06752E+02  -6.01875E+00
+ -1.06845E+02  -6.01620E+00
+ -1.06950E+02  -6.44278E+00
+ -1.07441E+02  -6.36670E+00
+ -1.07607E+02  -6.75924E+00
+ -1.07653E+02  -7.18594E+00
+ -1.07880E+02  -7.51409E+00
+ -1.08063E+02  -8.24014E+00
+ -1.08192E+02  -8.35695E+00
+ -1.08320E+02  -9.14481E+00
+ -1.09038E+02  -9.03537E+00
+ -1.09756E+02  -8.92454E+00
+ -1.09857E+02  -9.67656E+00
+ -1.10071E+02  -9.66505E+00
+ -1.10218E+02  -1.00804E+01
+ -1.10292E+02  -1.08017E+01
+ -1.10447E+02  -1.08224E+01
+ -1.10485E+02  -1.13942E+01
+ -1.10675E+02  -1.14724E+01
+ -1.10926E+02  -1.19684E+01
+ -1.11077E+02  -1.27417E+01
+ -1.10892E+02  -1.27553E+01
+ -1.11007E+02  -1.34108E+01
+ -1.11191E+02  -1.33964E+01
+ -1.11266E+02  -1.35413E+01
+ -1.11846E+02  -1.34645E+01
+ -1.12426E+02  -1.33863E+01
+ -1.12439E+02  -1.38646E+01
+ -1.12581E+02  -1.40619E+01
+ -1.12613E+02  -1.47180E+01
+ -1.12766E+02  -1.47038E+01
+ -1.12869E+02  -1.52478E+01
+ -1.12973E+02  -1.57917E+01
+ -1.13066E+02  -1.63513E+01
+ -1.12973E+02  -1.63609E+01
+ -1.13165E+02  -1.66703E+01
+ -1.13041E+02  -1.66834E+01
+ -1.13241E+02  -1.70515E+01
+ -1.13117E+02  -1.70650E+01
+ -1.13329E+02  -1.75211E+01
+ -1.13174E+02  -1.75384E+01
+ -1.13388E+02  -1.79938E+01
+ -1.13264E+02  -1.80081E+01
+ -1.13383E+02  -1.84442E+01
+ -1.13520E+02  -1.87579E+01
+ -1.13364E+02  -1.87766E+01
+ -1.13623E+02  -1.92852E+01
+ -1.13498E+02  -1.93006E+01
+ -1.13697E+02  -1.99675E+01
+ -1.13796E+02  -2.03210E+01
+ -1.13931E+02  -2.05745E+01
+ -1.14087E+02  -2.05993E+01
+ -1.14229E+02  -2.11213E+01
+ -1.14318E+02  -2.15636E+01
+ -1.14379E+02  -2.16270E+01
+ -1.14421E+02  -2.21145E+01
+> NZ\SA                      by Peter Bird   1999
+ -7.60062E+01  -4.56585E+01
+ -7.58214E+01  -4.48494E+01
+ -7.57824E+01  -4.40506E+01
+ -7.56316E+01  -4.36482E+01
+ -7.55580E+01  -4.29722E+01
+ -7.54017E+01  -4.22845E+01
+ -7.53969E+01  -4.18256E+01
+ -7.53922E+01  -4.13666E+01
+ -7.51889E+01  -4.08628E+01
+ -7.51948E+01  -4.03589E+01
+ -7.51278E+01  -3.98131E+01
+ -7.51495E+01  -3.95644E+01
+ -7.49883E+01  -3.90681E+01
+ -7.48359E+01  -3.85420E+01
+ -7.46548E+01  -3.81376E+01
+ -7.45956E+01  -3.75635E+01
+ -7.44416E+01  -3.67249E+01
+ -7.42617E+01  -3.61653E+01
+ -7.38974E+01  -3.55777E+01
+ -7.36755E+01  -3.48876E+01
+ -7.32457E+01  -3.42904E+01
+ -7.29375E+01  -3.38369E+01
+ -7.28610E+01  -3.33585E+01
+ -7.28890E+01  -3.27419E+01
+ -7.27622E+01  -3.23188E+01
+ -7.26783E+01  -3.15313E+01
+ -7.26181E+01  -3.09652E+01
+ -7.25999E+01  -3.01903E+01
+ -7.25546E+01  -2.95357E+01
+ -7.24332E+01  -2.89014E+01
+ -7.21698E+01  -2.82776E+01
+ -7.19578E+01  -2.77547E+01
+ -7.18471E+01  -2.72478E+01
+ -7.17525E+01  -2.66522E+01
+ -7.16283E+01  -2.58397E+01
+ -7.15243E+01  -2.50928E+01
+ -7.14659E+01  -2.42626E+01
+ -7.13895E+01  -2.35227E+01
+ -7.13475E+01  -2.27584E+01
+ -7.13068E+01  -2.19654E+01
+> NZ\AP                      by Peter Bird   1999
+ -7.13068E+01  -2.19654E+01
+ -7.12495E+01  -2.12622E+01
+ -7.13228E+01  -2.07577E+01
+ -7.13623E+01  -2.02491E+01
+ -7.14865E+01  -1.98112E+01
+ -7.17465E+01  -1.92981E+01
+ -7.22664E+01  -1.87215E+01
+ -7.27366E+01  -1.82567E+01
+ -7.33997E+01  -1.77470E+01
+ -7.39493E+01  -1.73735E+01
+ -7.46095E+01  -1.68230E+01
+ -7.52923E+01  -1.63302E+01
+ -7.59163E+01  -1.57355E+01
+> NZ\SA                      by Peter Bird   1999
+ -7.59163E+01  -1.57355E+01
+ -7.64029E+01  -1.52185E+01
+ -7.67648E+01  -1.48433E+01
+ -7.71254E+01  -1.44675E+01
+ -7.76388E+01  -1.39136E+01
+ -7.81476E+01  -1.33872E+01
+ -7.84069E+01  -1.30144E+01
+ -7.86654E+01  -1.26414E+01
+ -7.91472E+01  -1.18903E+01
+ -7.96181E+01  -1.12906E+01
+ -7.99966E+01  -1.05603E+01
+ -8.03684E+01  -9.92089E+00
+ -8.07010E+01  -9.43400E+00
+ -8.10406E+01  -8.66540E+00
+ -8.13747E+01  -7.98838E+00
+ -8.15492E+01  -7.30604E+00
+ -8.17840E+01  -6.65544E+00
+ -8.19541E+01  -6.00265E+00
+ -8.19985E+01  -5.25340E+00
+ -8.20098E+01  -4.50353E+00
+ -8.19258E+01  -3.72131E+00
+ -8.15989E+01  -3.24451E+00
+> NZ\ND                      by Peter Bird   1999
+ -8.15989E+01  -3.24451E+00
+ -8.16519E+01  -3.00021E+00
+ -8.15318E+01  -2.43745E+00
+ -8.15985E+01  -1.81384E+00
+ -8.14146E+01  -1.09547E+00
+ -8.12294E+01  -2.84454E-01
+ -8.08866E+01  +4.31890E-01
+ -8.05738E+01  +1.05338E+00
+ -8.02917E+01  +1.54938E+00
+ -7.97913E+01  +2.07369E+00
+ -7.94780E+01  +2.42697E+00
+ -7.91646E+01  +2.78019E+00
+ -7.86617E+01  +3.39204E+00
+ -7.83419E+01  +4.06591E+00
+ -7.80800E+01  +4.83152E+00
+ -7.79101E+01  +5.50529E+00
+ -7.80080E+01  +6.00453E+00
+> ON/PS                      by Peter Bird   May 2002
+ +1.28462E+02  +2.54576E+01
+ +1.28978E+02  +2.58591E+01
+ +1.29360E+02  +2.61908E+01
+ +1.29785E+02  +2.66709E+01
+ +1.30211E+02  +2.72135E+01
+ +1.30523E+02  +2.77094E+01
+ +1.30649E+02  +2.81358E+01
+ +1.31097E+02  +2.83182E+01
+ +1.31309E+02  +2.84508E+01
+ +1.31467E+02  +2.87508E+01
+ +1.31524E+02  +2.88591E+01
+ +1.31628E+02  +2.89874E+01
+ +1.31760E+02  +2.93921E+01
+ +1.32073E+02  +2.98177E+01
+ +1.32402E+02  +3.02149E+01
+ +1.32630E+02  +3.04926E+01
+ +1.32824E+02  +3.07544E+01
+> AM/PS                      by Peter Bird   September 2001
+ +1.32824E+02  +3.07544E+01
+ +1.32965E+02  +3.09698E+01
+ +1.33197E+02  +3.12162E+01
+ +1.33500E+02  +3.15152E+01
+ +1.34042E+02  +3.18821E+01
+ +1.34691E+02  +3.21997E+01
+ +1.35026E+02  +3.23264E+01
+ +1.35356E+02  +3.24600E+01
+ +1.35612E+02  +3.25372E+01
+ +1.36025E+02  +3.26860E+01
+ +1.36524E+02  +3.28681E+01
+ +1.37030E+02  +3.30526E+01
+ +1.37546E+02  +3.34046E+01
+ +1.38066E+02  +3.37495E+01
+ +1.38383E+02  +3.40590E+01
+ +1.38508E+02  +3.45822E+01
+ +1.38674E+02  +3.50337E+01
+> OK-PS                      by Peter Bird   September 2001
+ +1.38674E+02  +3.50337E+01
+ +1.39234E+02  +3.50141E+01
+ +1.39429E+02  +3.48599E+01
+ +1.39923E+02  +3.47126E+01
+ +1.40440E+02  +3.46310E+01
+ +1.40870E+02  +3.45295E+01
+ +1.41104E+02  +3.44389E+01
+ +1.41441E+02  +3.43565E+01
+ +1.41883E+02  +3.42127E+01
+> PS-CL                      by Peter Bird   1999
+ +1.34521E+02  +6.99019E+00
+ +1.35415E+02  +6.89507E+00
+ +1.36183E+02  +6.98895E+00
+ +1.36759E+02  +7.36771E+00
+ +1.37144E+02  +7.61961E+00
+ +1.37529E+02  +7.87117E+00
+ +1.37982E+02  +8.53360E+00
+ +1.38309E+02  +9.19616E+00
+ +1.38359E+02  +9.37865E+00
+> PS/PA                      by Peter Bird   1999
+ +1.38359E+02  +9.37865E+00
+ +1.38574E+02  +9.95256E+00
+ +1.38710E+02  +1.06492E+01
+ +1.38813E+02  +1.11214E+01
+ +1.39483E+02  +1.09006E+01
+ +1.40100E+02  +1.09459E+01
+ +1.40772E+02  +1.08578E+01
+ +1.41608E+02  +1.10581E+01
+ +1.42122E+02  +1.12852E+01
+ +1.42961E+02  +1.14031E+01
+ +1.43097E+02  +1.15689E+01
+> MA/PA                      by Peter Bird   October 2001
+ +1.43097E+02  +1.15689E+01
+ +1.43503E+02  +1.14936E+01
+ +1.44157E+02  +1.17896E+01
+ +1.44619E+02  +1.20206E+01
+ +1.45024E+02  +1.22112E+01
+ +1.45349E+02  +1.23141E+01
+ +1.45691E+02  +1.26466E+01
+ +1.46221E+02  +1.30015E+01
+ +1.46752E+02  +1.33632E+01
+ +1.47201E+02  +1.42158E+01
+ +1.47462E+02  +1.49661E+01
+ +1.47684E+02  +1.56530E+01
+ +1.47787E+02  +1.65234E+01
+ +1.47856E+02  +1.72831E+01
+ +1.47811E+02  +1.80602E+01
+ +1.47820E+02  +1.86465E+01
+ +1.47619E+02  +1.91724E+01
+ +1.47460E+02  +1.97452E+01
+ +1.47207E+02  +2.03034E+01
+ +1.47019E+02  +2.08051E+01
+ +1.46822E+02  +2.13306E+01
+ +1.46545E+02  +2.17298E+01
+ +1.46062E+02  +2.22015E+01
+ +1.45292E+02  +2.27123E+01
+ +1.44706E+02  +2.32501E+01
+ +1.44022E+02  +2.37644E+01
+ +1.43522E+02  +2.43908E+01
+> PS/PA                      by Peter Bird   1999
+ +1.43522E+02  +2.43908E+01
+ +1.43096E+02  +2.49092E+01
+ +1.43098E+02  +2.49176E+01
+ +1.43075E+02  +2.56124E+01
+ +1.43231E+02  +2.63289E+01
+ +1.43260E+02  +2.67370E+01
+ +1.43243E+02  +2.74633E+01
+ +1.43172E+02  +2.79407E+01
+ +1.43002E+02  +2.85187E+01
+ +1.42748E+02  +2.89754E+01
+ +1.42507E+02  +2.96208E+01
+ +1.42473E+02  +3.01282E+01
+ +1.42224E+02  +3.07110E+01
+ +1.42159E+02  +3.13152E+01
+ +1.42099E+02  +3.19825E+01
+ +1.41994E+02  +3.25576E+01
+ +1.42012E+02  +3.32525E+01
+ +1.41858E+02  +3.37039E+01
+ +1.41883E+02  +3.42127E+01
+> KE-TO                      by Peter Bird   2001
+ -1.74985E+02  -2.37499E+01
+ -1.75691E+02  -2.38526E+01
+ -1.76356E+02  -2.39520E+01
+ -1.76887E+02  -2.40295E+01
+ -1.77419E+02  -2.41051E+01
+> NI-FT                      Zellmer and Taylor [2001]
+ -1.76346E+02  -1.46340E+01
+ -1.76339E+02  -1.47803E+01
+ -1.76319E+02  -1.49040E+01
+ -1.76331E+02  -1.50501E+01
+ -1.76341E+02  -1.51836E+01
+ -1.76387E+02  -1.53117E+01
+ -1.76462E+02  -1.54194E+01
+ -1.76526E+02  -1.54894E+01
+ -1.76660E+02  -1.56041E+01
+ -1.77130E+02  -1.55594E+01
+> NI-AU                      Zellmer and Taylor [2001]
+ -1.77130E+02  -1.55594E+01
+ -1.77248E+02  -1.57096E+01
+ -1.77384E+02  -1.58066E+01
+ -1.77493E+02  -1.58989E+01
+ -1.77575E+02  -1.59611E+01
+ -1.77634E+02  -1.60236E+01
+ -1.77664E+02  -1.61065E+01
+ -1.77678E+02  -1.61769E+01
+ -1.77513E+02  -1.63196E+01
+ -1.77364E+02  -1.64370E+01
+ -1.77201E+02  -1.65746E+01
+ -1.77068E+02  -1.67246E+01
+ -1.76921E+02  -1.68772E+01
+ -1.76820E+02  -1.70344E+01
+ -1.76713E+02  -1.72194E+01
+ -1.76625E+02  -1.73992E+01
+ -1.76532E+02  -1.75740E+01
+ -1.76462E+02  -1.77310E+01
+ -1.76403E+02  -1.78727E+01
+ -1.76304E+02  -1.80551E+01
+ -1.76297E+02  -1.81308E+01
+ -1.76330E+02  -1.82666E+01
+ -1.76346E+02  -1.83068E+01
+ -1.76440E+02  -1.84723E+01
+ -1.76511E+02  -1.86002E+01
+ -1.76551E+02  -1.86855E+01
+ -1.76584E+02  -1.87684E+01
+ -1.76587E+02  -1.88364E+01
+ -1.76570E+02  -1.89752E+01
+ -1.76549E+02  -1.92174E+01
+ -1.75979E+02  -1.93865E+01
+> TO-NI                      Zellmer and Taylor [2001]
+ -1.73836E+02  -1.45338E+01
+ -1.73905E+02  -1.46290E+01
+ -1.74007E+02  -1.47666E+01
+ -1.74077E+02  -1.48946E+01
+ -1.74139E+02  -1.50150E+01
+ -1.74188E+02  -1.51330E+01
+ -1.74264E+02  -1.53138E+01
+ -1.74567E+02  -1.52505E+01
+ -1.74667E+02  -1.53705E+01
+ -1.74731E+02  -1.54708E+01
+ -1.74822E+02  -1.56161E+01
+ -1.74866E+02  -1.57392E+01
+ -1.74870E+02  -1.58804E+01
+ -1.74601E+02  -1.59358E+01
+ -1.74568E+02  -1.60521E+01
+ -1.74569E+02  -1.62008E+01
+ -1.74576E+02  -1.63545E+01
+ -1.74550E+02  -1.65967E+01
+ -1.74535E+02  -1.67355E+01
+ -1.74529E+02  -1.68742E+01
+ -1.74523E+02  -1.70658E+01
+ -1.74565E+02  -1.71007E+01
+ -1.74599E+02  -1.73197E+01
+ -1.74571E+02  -1.73603E+01
+ -1.74597E+02  -1.76122E+01
+ -1.74560E+02  -1.76301E+01
+ -1.74568E+02  -1.78418E+01
+ -1.74659E+02  -1.80351E+01
+ -1.74757E+02  -1.82308E+01
+ -1.74870E+02  -1.84163E+01
+ -1.74956E+02  -1.86045E+01
+ -1.75035E+02  -1.87878E+01
+ -1.75095E+02  -1.90015E+01
+ -1.75155E+02  -1.92253E+01
+ -1.75189E+02  -1.94594E+01
+ -1.75210E+02  -1.97037E+01
+ -1.75979E+02  -1.93865E+01
+> TO-AU                      Zellmer and Taylor [2001]
+ -1.75979E+02  -1.93865E+01
+ -1.76027E+02  -1.96508E+01
+ -1.76079E+02  -1.98141E+01
+ -1.76122E+02  -1.98843E+01
+ -1.76182E+02  -2.01056E+01
+ -1.76116E+02  -2.01289E+01
+ -1.76152E+02  -2.02647E+01
+ -1.76159E+02  -2.04234E+01
+ -1.76176E+02  -2.04939E+01
+ -1.76190E+02  -2.06550E+01
+ -1.76237E+02  -2.07958E+01
+ -1.76264E+02  -2.08913E+01
+ -1.76289E+02  -2.09995E+01
+ -1.76322E+02  -2.11126E+01
+ -1.76372E+02  -2.13012E+01
+ -1.76405E+02  -2.14874E+01
+ -1.76449E+02  -2.16005E+01
+ -1.76520E+02  -2.18115E+01
+ -1.76601E+02  -2.20074E+01
+ -1.76635E+02  -2.22314E+01
+ -1.76691E+02  -2.22864E+01
+ -1.76709E+02  -2.25005E+01
+ -1.76748E+02  -2.27345E+01
+ -1.76913E+02  -2.30481E+01
+ -1.77102E+02  -2.34144E+01
+ -1.77250E+02  -2.37079E+01
+ -1.77419E+02  -2.41051E+01
+> SC/AN                      Klepeis and Lawver   1996
+ -7.64833E+01  -5.20684E+01
+ -7.63121E+01  -5.29285E+01
+ -7.60197E+01  -5.34352E+01
+ -7.57203E+01  -5.39412E+01
+ -7.52389E+01  -5.42941E+01
+ -7.47492E+01  -5.46451E+01
+ -7.41202E+01  -5.50037E+01
+ -7.34799E+01  -5.53590E+01
+ -7.29952E+01  -5.56654E+01
+ -7.22772E+01  -5.59624E+01
+ -7.15481E+01  -5.62552E+01
+ -7.04011E+01  -5.66220E+01
+ -6.92561E+01  -5.68522E+01
+ -6.80972E+01  -5.70717E+01
+ -6.71018E+01  -5.75019E+01
+ -6.58672E+01  -5.77363E+01
+ -6.46170E+01  -5.79586E+01
+> SC-AN                      Klepeis and Lawver   1996
+ -6.46170E+01  -5.79586E+01
+ -6.35707E+01  -5.83592E+01
+ -6.25714E+01  -5.86029E+01
+ -6.10399E+01  -5.90105E+01
+ -5.97045E+01  -5.94535E+01
+ -5.89698E+01  -5.97285E+01
+ -5.82230E+01  -5.99993E+01
+ -5.69250E+01  -6.05647E+01
+> SL/AN                      Klepeis and Lawver   1996
+ -5.69250E+01  -6.05647E+01
+ -5.74938E+01  -6.08546E+01
+ -5.81308E+01  -6.09615E+01
+ -5.88906E+01  -6.10818E+01
+ -5.98360E+01  -6.11768E+01
+ -6.06502E+01  -6.13632E+01
+ -6.13323E+01  -6.15431E+01
+ -6.22029E+01  -6.18412E+01
+ -6.31053E+01  -6.21100E+01
+ -6.39693E+01  -6.24224E+01
+> SL-AN                      Klepeis and Lawver   1996
+ -6.39693E+01  -6.24224E+01
+ -6.32916E+01  -6.28247E+01
+ -6.24198E+01  -6.30013E+01
+ -6.17501E+01  -6.32928E+01
+ -6.01180E+01  -6.29452E+01
+ -5.86143E+01  -6.25533E+01
+ -5.73896E+01  -6.23038E+01
+ -5.63056E+01  -6.20627E+01
+ -5.54359E+01  -6.16868E+01
+ -5.43007E+01  -6.15102E+01
+> SC-SL                      Peter Bird   September 2001
+ -5.69250E+01  -6.05647E+01
+ -5.62692E+01  -6.07422E+01
+ -5.58097E+01  -6.07001E+01
+ -5.50666E+01  -6.07631E+01
+ -5.43090E+01  -6.09776E+01
+ -5.43007E+01  -6.15102E+01
+> SC-AN                      Klepeis and Lawver   1996
+ -5.43007E+01  -6.15102E+01
+ -5.31221E+01  -6.10366E+01
+ -5.20681E+01  -6.07527E+01
+ -5.11194E+01  -6.05725E+01
+ -5.08871E+01  -6.00936E+01
+ -4.95994E+01  -6.00436E+01
+ -4.82507E+01  -5.99684E+01
+ -4.69632E+01  -5.99598E+01
+ -4.56034E+01  -6.00915E+01
+ -4.42259E+01  -6.02425E+01
+> EU/AF                      Peter Bird   September 2001
+ +2.00000E+01  +3.79075E+01
+ +2.03001E+01  +3.78039E+01
+> AS-AT                      McClusky et al.   2000
+ +2.97309E+01  +3.54273E+01
+ +2.93888E+01  +3.57284E+01
+ +2.91369E+01  +3.59703E+01
+ +2.87888E+01  +3.63607E+01
+ +2.84107E+01  +3.69833E+01
+ +2.82545E+01  +3.72689E+01
+ +2.82543E+01  +3.75205E+01
+ +2.82780E+01  +3.77570E+01
+ +2.81998E+01  +3.79645E+01
+ +2.79538E+01  +3.82275E+01
+ +2.76719E+01  +3.84991E+01
+ +2.71380E+01  +3.88764E+01
+ +2.66101E+01  +3.92980E+01
+ +2.62562E+01  +3.95286E+01
+ +2.58605E+01  +3.97078E+01
+ +2.54165E+01  +4.01564E+01
+> AS-EU                      McClusky et al.   2000
+ +2.54165E+01  +4.01564E+01
+ +2.49310E+01  +4.00922E+01
+ +2.45595E+01  +4.00554E+01
+ +2.40022E+01  +3.99178E+01
+ +2.37866E+01  +3.97204E+01
+ +2.34634E+01  +3.92869E+01
+ +2.32120E+01  +3.89484E+01
+ +2.29546E+01  +3.85990E+01
+ +2.27272E+01  +3.82713E+01
+ +2.21637E+01  +3.83553E+01
+ +2.15822E+01  +3.84205E+01
+ +2.10967E+01  +3.84389E+01
+ +2.04374E+01  +3.84712E+01
+ +2.02819E+01  +3.81148E+01
+ +2.03001E+01  +3.78039E+01
+> AR-AF                      McClusky et al.   2000
+ +3.64134E+01  +3.60232E+01
+ +3.64315E+01  +3.57522E+01
+ +3.63960E+01  +3.52854E+01
+ +3.63249E+01  +3.44818E+01
+ +3.60242E+01  +3.40961E+01
+ +3.57262E+01  +3.37097E+01
+ +3.56483E+01  +3.32325E+01
+ +3.55713E+01  +3.27553E+01
+ +3.54701E+01  +3.20035E+01
+ +3.53089E+01  +3.13833E+01
+ +3.51417E+01  +3.07025E+01
+ +3.49519E+01  +3.00000E+01
+> AT-AR                      McClusky et al.   2000
+ +3.64134E+01  +3.60232E+01
+ +3.63892E+01  +3.62596E+01
+ +3.64665E+01  +3.67303E+01
+ +3.67895E+01  +3.73979E+01
+ +3.70832E+01  +3.75118E+01
+ +3.76822E+01  +3.78337E+01
+ +3.80417E+01  +3.79941E+01
+ +3.83652E+01  +3.81214E+01
+ +3.88565E+01  +3.83141E+01
+ +3.94017E+01  +3.84970E+01
+ +4.01627E+01  +3.87681E+01
+ +4.06242E+01  +3.88568E+01
+ +4.10015E+01  +3.90799E+01
+> EU-AR                      Peter Bird   September 2001
+ +4.10015E+01  +3.90799E+01
+ +4.10262E+01  +3.88487E+01
+ +4.12363E+01  +3.86156E+01
+ +4.18391E+01  +3.83551E+01
+ +4.22891E+01  +3.82127E+01
+ +4.27973E+01  +3.79905E+01
+ +4.31758E+01  +3.76850E+01
+ +4.36475E+01  +3.74066E+01
+ +4.40195E+01  +3.70984E+01
+ +4.43568E+01  +3.65716E+01
+ +4.45148E+01  +3.60150E+01
+ +4.46705E+01  +3.54581E+01
+ +4.48361E+01  +3.50245E+01
+ +4.50000E+01  +3.45906E+01
+> AT-EU                      McClusky et al.   2000
+ +4.10015E+01  +3.90799E+01
+ +4.04492E+01  +3.93925E+01
+ +3.98920E+01  +3.97025E+01
+ +3.92684E+01  +3.99087E+01
+ +3.87948E+01  +4.00091E+01
+ +3.80213E+01  +4.02690E+01
+ +3.70620E+01  +4.06003E+01
+ +3.61686E+01  +4.08487E+01
+ +3.55272E+01  +4.10018E+01
+ +3.48317E+01  +4.11231E+01
+ +3.42864E+01  +4.11587E+01
+ +3.34053E+01  +4.10231E+01
+ +3.23925E+01  +4.08601E+01
+ +3.14817E+01  +4.06786E+01
+ +3.11161E+01  +4.06149E+01
+ +3.07745E+01  +4.06010E+01
+ +3.00071E+01  +4.07682E+01
+ +2.90302E+01  +4.06861E+01
+ +2.87245E+01  +4.06679E+01
+ +2.79873E+01  +4.06176E+01
+ +2.75677E+01  +4.06400E+01
+ +2.72559E+01  +4.07892E+01
+ +2.65968E+01  +4.05532E+01
+ +2.60097E+01  +4.03255E+01
+ +2.54165E+01  +4.01564E+01
+> OK/NA                      by Peter Bird   September 2001
+ +1.64066E+02  +5.52092E+01
+ +1.63340E+02  +5.58170E+01
+ +1.62592E+02  +5.64203E+01
+ +1.62960E+02  +5.68360E+01
+ +1.63336E+02  +5.72505E+01
+ +1.63721E+02  +5.76638E+01
+ +1.64115E+02  +5.80760E+01
+ +1.64518E+02  +5.84869E+01
+ +1.64930E+02  +5.88966E+01
+ +1.66258E+02  +5.93762E+01
+ +1.67623E+02  +5.98420E+01
+ +1.69027E+02  +6.02932E+01
+ +1.69865E+02  +6.10172E+01
+ +1.70743E+02  +6.17358E+01
+> OK-NA                      by Peter Bird   September 2001
+ +1.70743E+02  +6.17358E+01
+ +1.69722E+02  +6.16666E+01
+ +1.68706E+02  +6.15898E+01
+ +1.67696E+02  +6.15055E+01
+ +1.66691E+02  +6.14138E+01
+ +1.65013E+02  +6.13376E+01
+ +1.63345E+02  +6.12409E+01
+ +1.62353E+02  +6.12721E+01
+ +1.61359E+02  +6.12961E+01
+ +1.60363E+02  +6.13128E+01
+ +1.59367E+02  +6.13222E+01
+ +1.58045E+02  +6.14068E+01
+ +1.56717E+02  +6.14785E+01
+ +1.55337E+02  +6.16067E+01
+ +1.53946E+02  +6.17209E+01
+ +1.52596E+02  +6.23526E+01
+ +1.51189E+02  +6.29707E+01
+ +1.49721E+02  +6.35742E+01
+ +1.48191E+02  +6.41621E+01
+ +1.46595E+02  +6.47332E+01
+ +1.44932E+02  +6.52865E+01
+> OK-EU                      by Peter Bird   September 2001
+ +1.44932E+02  +6.52865E+01
+ +1.45487E+02  +6.44376E+01
+ +1.46008E+02  +6.35867E+01
+ +1.46499E+02  +6.27340E+01
+ +1.46963E+02  +6.18797E+01
+ +1.46126E+02  +6.15698E+01
+ +1.45306E+02  +6.12549E+01
+ +1.44502E+02  +6.09351E+01
+ +1.43715E+02  +6.06107E+01
+ +1.42943E+02  +6.02817E+01
+ +1.42187E+02  +5.99484E+01
+ +1.42086E+02  +5.94786E+01
+ +1.41988E+02  +5.90087E+01
+ +1.41893E+02  +5.85387E+01
+ +1.41800E+02  +5.80686E+01
+ +1.41709E+02  +5.75985E+01
+ +1.41621E+02  +5.71283E+01
+ +1.41535E+02  +5.66581E+01
+ +1.41451E+02  +5.61878E+01
+ +1.41700E+02  +5.56503E+01
+ +1.41943E+02  +5.51123E+01
+ +1.42179E+02  +5.45738E+01
+ +1.42409E+02  +5.40349E+01
+> OK-AM                      Wei and Seno   1998; detail by Peter Bird
+ +1.42409E+02  +5.40349E+01
+ +1.42849E+02  +5.33843E+01
+ +1.42784E+02  +5.30425E+01
+ +1.42692E+02  +5.25418E+01
+ +1.42541E+02  +5.16998E+01
+ +1.42398E+02  +5.08574E+01
+ +1.42521E+02  +5.03178E+01
+ +1.42641E+02  +4.97781E+01
+ +1.42761E+02  +4.92409E+01
+ +1.42878E+02  +4.87036E+01
+ +1.42023E+02  +4.80512E+01
+ +1.41178E+02  +4.73923E+01
+ +1.40553E+02  +4.69557E+01
+ +1.39938E+02  +4.65157E+01
+ +1.39370E+02  +4.62240E+01
+ +1.39158E+02  +4.59466E+01
+ +1.39038E+02  +4.54118E+01
+ +1.38850E+02  +4.48113E+01
+ +1.38577E+02  +4.42948E+01
+ +1.38563E+02  +4.39389E+01
+ +1.38801E+02  +4.31922E+01
+ +1.38811E+02  +4.27664E+01
+ +1.38824E+02  +4.19955E+01
+ +1.38743E+02  +4.17693E+01
+ +1.38489E+02  +4.14818E+01
+ +1.38475E+02  +4.11030E+01
+ +1.38756E+02  +4.07823E+01
+ +1.38655E+02  +4.04744E+01
+ +1.38655E+02  +4.00722E+01
+ +1.38352E+02  +3.98324E+01
+ +1.38085E+02  +3.96594E+01
+ +1.37845E+02  +3.94043E+01
+ +1.37774E+02  +3.89816E+01
+ +1.37848E+02  +3.84846E+01
+ +1.37889E+02  +3.78556E+01
+ +1.37902E+02  +3.71840E+01
+ +1.37854E+02  +3.65997E+01
+ +1.37894E+02  +3.63109E+01
+ +1.38121E+02  +3.60267E+01
+ +1.38259E+02  +3.57340E+01
+ +1.38421E+02  +3.53600E+01
+ +1.38674E+02  +3.50337E+01
+> AM-EU                      by Peter Bird   May 2002
+ +1.42409E+02  +5.40349E+01
+ +1.41278E+02  +5.40742E+01
+ +1.40145E+02  +5.41028E+01
+ +1.39211E+02  +5.43328E+01
+ +1.37918E+02  +5.45883E+01
+ +1.36610E+02  +5.48299E+01
+ +1.35138E+02  +5.50602E+01
+ +1.33650E+02  +5.52726E+01
+ +1.32674E+02  +5.54913E+01
+ +1.31688E+02  +5.57022E+01
+ +1.30747E+02  +5.58611E+01
+ +1.29798E+02  +5.60127E+01
+ +1.28393E+02  +5.64015E+01
+ +1.26960E+02  +5.67741E+01
+ +1.25499E+02  +5.71299E+01
+ +1.24573E+02  +5.71781E+01
+ +1.23645E+02  +5.72194E+01
+ +1.22715E+02  +5.72538E+01
+ +1.21784E+02  +5.72814E+01
+ +1.20851E+02  +5.73021E+01
+ +1.19918E+02  +5.73159E+01
+ +1.19021E+02  +5.71509E+01
+ +1.18133E+02  +5.69796E+01
+ +1.17253E+02  +5.68021E+01
+ +1.16382E+02  +5.66184E+01
+ +1.15015E+02  +5.65256E+01
+ +1.13656E+02  +5.64179E+01
+ +1.12305E+02  +5.62954E+01
+ +1.10924E+02  +5.62207E+01
+ +1.09758E+02  +5.57616E+01
+ +1.09375E+02  +5.53308E+01
+ +1.09000E+02  +5.48989E+01
+ +1.08691E+02  +5.41503E+01
+ +1.08393E+02  +5.34009E+01
+ +1.07706E+02  +5.30813E+01
+ +1.07029E+02  +5.27578E+01
+ +1.06362E+02  +5.24305E+01
+ +1.05705E+02  +5.20994E+01
+ +1.05058E+02  +5.17648E+01
+ +1.04420E+02  +5.14267E+01
+ +1.04904E+02  +5.07860E+01
+ +1.05375E+02  +5.01433E+01
+ +1.05582E+02  +4.92921E+01
+ +1.05781E+02  +4.84406E+01
+ +1.05916E+02  +4.79102E+01
+ +1.06048E+02  +4.73797E+01
+ +1.06177E+02  +4.68490E+01
+ +1.06304E+02  +4.63182E+01
+ +1.06460E+02  +4.58748E+01
+ +1.06614E+02  +4.54311E+01
+ +1.06765E+02  +4.49873E+01
+ +1.06914E+02  +4.45432E+01
+ +1.07061E+02  +4.40990E+01
+ +1.07205E+02  +4.36546E+01
+ +1.08131E+02  +4.31492E+01
+ +1.09041E+02  +4.26365E+01
+ +1.09693E+02  +4.20700E+01
+ +1.10570E+02  +4.16014E+01
+ +1.11435E+02  +4.11262E+01
+ +1.12287E+02  +4.06446E+01
+ +1.12911E+02  +4.10237E+01
+ +1.13542E+02  +4.13993E+01
+ +1.14392E+02  +4.11630E+01
+ +1.15235E+02  +4.09206E+01
+ +1.15810E+02  +4.05955E+01
+ +1.16379E+02  +4.02675E+01
+ +1.17010E+02  +4.00571E+01
+ +1.17638E+02  +3.98433E+01
+ +1.18245E+02  +4.00536E+01
+ +1.18856E+02  +4.02608E+01
+ +1.19846E+02  +4.06543E+01
+ +1.20848E+02  +4.10392E+01
+ +1.21313E+02  +4.13292E+01
+ +1.21782E+02  +4.16173E+01
+ +1.22255E+02  +4.19035E+01
+ +1.22732E+02  +4.21878E+01
+ +1.23510E+02  +4.15302E+01
+ +1.24272E+02  +4.08675E+01
+ +1.25019E+02  +4.01999E+01
+ +1.25199E+02  +3.97415E+01
+ +1.25376E+02  +3.92829E+01
+ +1.25551E+02  +3.88240E+01
+ +1.25723E+02  +3.83648E+01
+ +1.25914E+02  +3.75413E+01
+ +1.26101E+02  +3.67175E+01
+ +1.26115E+02  +3.61691E+01
+ +1.26128E+02  +3.56207E+01
+ +1.26196E+02  +3.49364E+01
+ +1.26263E+02  +3.42521E+01
+> EU-SU                      by Peter Bird   September 2001
+ +9.64803E+01  +1.44000E+01
+ +9.73900E+01  +1.44188E+01
+ +9.82999E+01  +1.44340E+01
+ +9.92098E+01  +1.44458E+01
+ +9.97660E+01  +1.48381E+01
+ +1.00297E+02  +1.54616E+01
+ +1.00832E+02  +1.60838E+01
+ +1.01141E+02  +1.65753E+01
+ +1.01451E+02  +1.70663E+01
+ +1.02032E+02  +1.73503E+01
+ +1.02615E+02  +1.76327E+01
+ +1.03180E+02  +1.76596E+01
+ +1.03746E+02  +1.76848E+01
+ +1.04312E+02  +1.77085E+01
+ +1.04878E+02  +1.77305E+01
+ +1.05817E+02  +1.77504E+01
+ +1.06756E+02  +1.77659E+01
+ +1.07695E+02  +1.77769E+01
+ +1.08634E+02  +1.77835E+01
+ +1.09573E+02  +1.77855E+01
+ +1.10512E+02  +1.77831E+01
+ +1.11040E+02  +1.78697E+01
+ +1.11569E+02  +1.79548E+01
+ +1.12098E+02  +1.80385E+01
+ +1.12628E+02  +1.81207E+01
+ +1.13313E+02  +1.82804E+01
+ +1.14000E+02  +1.84377E+01
+> YA-SU                      by Peter Bird   September 2001
+ +1.14000E+02  +1.84377E+01
+ +1.14419E+02  +1.88261E+01
+ +1.14926E+02  +1.93405E+01
+ +1.15494E+02  +1.96873E+01
+ +1.16319E+02  +1.98153E+01
+ +1.17145E+02  +1.99395E+01
+ +1.17504E+02  +2.03301E+01
+ +1.17864E+02  +2.07199E+01
+ +1.18045E+02  +2.14983E+01
+ +1.18484E+02  +2.21067E+01
+ +1.18958E+02  +2.20031E+01
+ +1.19618E+02  +2.22686E+01
+ +1.20036E+02  +2.19509E+01
+ +1.20452E+02  +2.16321E+01
+> BU-EU                      Circum Pacific Mapping Project   1986
+ +9.64803E+01  +1.44000E+01
+ +9.64537E+01  +1.49093E+01
+ +9.64061E+01  +1.51355E+01
+> IN-EU                      by Peter Bird   October 2001
+ +9.64061E+01  +1.51355E+01
+ +9.64193E+01  +1.53962E+01
+ +9.64472E+01  +1.60034E+01
+ +9.64697E+01  +1.66438E+01
+ +9.64661E+01  +1.74351E+01
+ +9.64207E+01  +1.79816E+01
+ +9.63414E+01  +1.87048E+01
+ +9.62254E+01  +1.94119E+01
+ +9.60158E+01  +2.00399E+01
+ +9.59427E+01  +2.09001E+01
+ +9.59183E+01  +2.16810E+01
+ +9.59181E+01  +2.23522E+01
+ +9.59093E+01  +2.30150E+01
+ +9.59691E+01  +2.37605E+01
+ +9.61173E+01  +2.44801E+01
+ +9.63104E+01  +2.51336E+01
+ +9.65813E+01  +2.56469E+01
+ +9.69056E+01  +2.62874E+01
+ +9.71304E+01  +2.68202E+01
+ +9.73465E+01  +2.72411E+01
+ +9.74711E+01  +2.77024E+01
+ +9.73484E+01  +2.80826E+01
+> BU/IN                      Circum Pacific Mapping Project   1986
+ +9.22781E+01  +6.94757E+00
+ +9.23761E+01  +6.33253E+00
+ +9.25375E+01  +5.70195E+00
+ +9.26651E+01  +5.00508E+00
+ +9.29030E+01  +4.38448E+00
+ +9.32270E+01  +3.71599E+00
+ +9.37535E+01  +3.04767E+00
+ +9.44052E+01  +2.45683E+00
+ +9.49794E+01  +2.10410E+00
+> BU/AU                      Circum Pacific Mapping Project   1986
+ +9.49794E+01  +2.10410E+00
+ +9.55419E+01  +1.88178E+00
+ +9.60886E+01  +1.48729E+00
+ +9.62019E+01  +1.34500E+00
+> SU/AU                      by Peter Bird   October 2001
+ +9.62019E+01  +1.34500E+00
+ +9.63795E+01  +1.12302E+00
+ +9.66703E+01  +7.58714E-01
+ +9.70106E+01  +1.15925E-01
+ +9.73722E+01  -5.47177E-01
+ +9.77695E+01  -1.24714E+00
+ +9.80354E+01  -1.63424E+00
+ +9.83013E+01  -2.02129E+00
+ +9.88744E+01  -2.66500E+00
+ +9.93699E+01  -3.31150E+00
+ +9.96748E+01  -3.72852E+00
+ +9.99800E+01  -4.14544E+00
+ +1.00359E+02  -4.65588E+00
+ +1.00791E+02  -5.30492E+00
+ +1.01346E+02  -5.98298E+00
+ +1.01858E+02  -6.55836E+00
+ +1.02452E+02  -7.19719E+00
+ +1.03183E+02  -7.62145E+00
+ +1.03763E+02  -7.86277E+00
+ +1.04576E+02  -8.16657E+00
+> EU-YA                      by Peter Bird   May 2002
+ +1.14000E+02  +1.84377E+01
+ +1.13759E+02  +1.88630E+01
+ +1.13517E+02  +1.92880E+01
+ +1.13274E+02  +1.97126E+01
+ +1.13030E+02  +2.01369E+01
+ +1.12784E+02  +2.05609E+01
+ +1.12537E+02  +2.09845E+01
+ +1.12288E+02  +2.14078E+01
+ +1.12038E+02  +2.18307E+01
+ +1.11175E+02  +2.21652E+01
+ +1.10308E+02  +2.24951E+01
+ +1.09436E+02  +2.28203E+01
+ +1.08561E+02  +2.31408E+01
+ +1.07681E+02  +2.34564E+01
+ +1.07132E+02  +2.40524E+01
+ +1.06578E+02  +2.46464E+01
+ +1.06018E+02  +2.52383E+01
+ +1.05720E+02  +2.57969E+01
+ +1.05419E+02  +2.63549E+01
+ +1.05182E+02  +2.71169E+01
+ +1.04942E+02  +2.78784E+01
+ +1.05170E+02  +2.83343E+01
+ +1.05399E+02  +2.87898E+01
+ +1.06262E+02  +2.92543E+01
+ +1.07133E+02  +2.97132E+01
+ +1.08043E+02  +3.00049E+01
+ +1.08959E+02  +3.02903E+01
+ +1.09880E+02  +3.05693E+01
+ +1.10806E+02  +3.08418E+01
+ +1.11209E+02  +3.12517E+01
+ +1.11615E+02  +3.16603E+01
+ +1.11633E+02  +3.22519E+01
+ +1.11651E+02  +3.28434E+01
+ +1.12274E+02  +3.34649E+01
+ +1.12905E+02  +3.40833E+01
+ +1.13250E+02  +3.44690E+01
+ +1.13599E+02  +3.48538E+01
+ +1.14280E+02  +3.48426E+01
+ +1.14960E+02  +3.48277E+01
+ +1.15746E+02  +3.42128E+01
+ +1.16521E+02  +3.35930E+01
+ +1.17284E+02  +3.29684E+01
+ +1.17719E+02  +3.25725E+01
+ +1.18150E+02  +3.21751E+01
+ +1.18577E+02  +3.17763E+01
+ +1.19001E+02  +3.13760E+01
+ +1.19711E+02  +3.11994E+01
+ +1.20368E+02  +3.13919E+01
+ +1.21027E+02  +3.15810E+01
+ +1.21611E+02  +3.15571E+01
+ +1.22195E+02  +3.15305E+01
+ +1.22780E+02  +3.15022E+01
+ +1.23364E+02  +3.14713E+01
+> AP-SA                      by Peter Bird   September 2001
+ -7.13068E+01  -2.19654E+01
+ -7.06833E+01  -2.17339E+01
+ -7.00618E+01  -2.15000E+01
+ -6.91138E+01  -2.15000E+01
+ -6.81658E+01  -2.15000E+01
+ -6.76552E+01  -2.15000E+01
+ -6.71445E+01  -2.15000E+01
+ -6.66339E+01  -2.15000E+01
+ -6.61233E+01  -2.15000E+01
+ -6.54275E+01  -2.14652E+01
+ -6.47321E+01  -2.14275E+01
+ -6.41386E+01  -2.13989E+01
+ -6.35454E+01  -2.13683E+01
+ -6.33600E+01  -2.07593E+01
+ -6.31760E+01  -2.01502E+01
+ -6.32865E+01  -1.95109E+01
+ -6.33962E+01  -1.88716E+01
+ -6.36168E+01  -1.83751E+01
+ -6.38362E+01  -1.78783E+01
+ -6.38563E+01  -1.74643E+01
+ -6.45845E+01  -1.74023E+01
+ -6.54189E+01  -1.71100E+01
+ -6.57954E+01  -1.67293E+01
+ -6.61705E+01  -1.63479E+01
+ -6.66957E+01  -1.57138E+01
+ -6.72176E+01  -1.50785E+01
+ -6.74226E+01  -1.45267E+01
+ -6.80077E+01  -1.40278E+01
+ -6.85902E+01  -1.35274E+01
+ -6.90461E+01  -1.33947E+01
+ -6.95014E+01  -1.32611E+01
+ -7.01246E+01  -1.30350E+01
+ -7.07466E+01  -1.28075E+01
+ -7.13917E+01  -1.25783E+01
+ -7.20356E+01  -1.23476E+01
+ -7.26548E+01  -1.24178E+01
+ -7.32744E+01  -1.24865E+01
+ -7.38500E+01  -1.31819E+01
+ -7.44289E+01  -1.38760E+01
+ -7.49219E+01  -1.44969E+01
+ -7.54176E+01  -1.51167E+01
+ -7.59163E+01  -1.57355E+01
+> PA-NA                      DeMets and Wilson   1997
+ -1.08582E+02  +2.19047E+01
+ -1.08676E+02  +2.19596E+01
+ -1.08589E+02  +2.21024E+01
+ -1.08516E+02  +2.22011E+01
+ -1.08527E+02  +2.22769E+01
+ -1.08407E+02  +2.24401E+01
+ -1.08273E+02  +2.26134E+01
+ -1.08232E+02  +2.27117E+01
+> RI-PA                      DeMets and Wilson   1997
+ -1.08582E+02  +2.19047E+01
+ -1.08669E+02  +2.17739E+01
+ -1.08784E+02  +2.16428E+01
+ -1.08868E+02  +2.15360E+01
+ -1.08936E+02  +2.14513E+01
+ -1.08977E+02  +2.13470E+01
+ -1.08809E+02  +2.12529E+01
+ -1.08915E+02  +2.10679E+01
+ -1.09013E+02  +2.09490E+01
+ -1.09111E+02  +2.08240E+01
+ -1.09194E+02  +2.07392E+01
+ -1.09261E+02  +2.06426E+01
+ -1.09285E+02  +2.05584E+01
+ -1.09187E+02  +2.04995E+01
+ -1.09215E+02  +2.03973E+01
+ -1.09319E+02  +2.02423E+01
+ -1.09378E+02  +2.01757E+01
+ -1.09373E+02  +2.01418E+01
+ -1.09450E+02  +2.00271E+01
+ -1.09160E+02  +1.98065E+01
+ -1.08903E+02  +1.96255E+01
+ -1.08896E+02  +1.95496E+01
+ -1.08534E+02  +1.93837E+01
+ -1.08198E+02  +1.92235E+01
+ -1.08233E+02  +1.91073E+01
+ -1.07816E+02  +1.89360E+01
+ -1.07523E+02  +1.88632E+01
+ -1.07272E+02  +1.87561E+01
+ -1.07002E+02  +1.86471E+01
+ -1.06756E+02  +1.85899E+01
+ -1.06527E+02  +1.85444E+01
+ -1.06244E+02  +1.85199E+01
+ -1.06281E+02  +1.82814E+01
+ -1.06311E+02  +1.81198E+01
+ -1.06318E+02  +1.80163E+01
+ -1.06308E+02  +1.79290E+01
+ -1.05586E+02  +1.78808E+01
+> NA-RI                      DeMets and Wilson   1997
+ -1.08582E+02  +2.19047E+01
+ -1.08397E+02  +2.18348E+01
+ -1.08114E+02  +2.17200E+01
+ -1.07928E+02  +2.16861E+01
+ -1.07774E+02  +2.17397E+01
+ -1.07586E+02  +2.17417E+01
+ -1.07393E+02  +2.17478E+01
+ -1.07171E+02  +2.17522E+01
+ -1.07046E+02  +2.17536E+01
+ -1.06890E+02  +2.17992E+01
+> NA/RI                      DeMets and Wilson   1997
+ -1.06890E+02  +2.17992E+01
+ -1.06862E+02  +2.17156E+01
+ -1.06808E+02  +2.16403E+01
+ -1.06757E+02  +2.14830E+01
+ -1.06624E+02  +2.13106E+01
+ -1.06551E+02  +2.12355E+01
+ -1.06525E+02  +2.11838E+01
+ -1.06442E+02  +2.11208E+01
+ -1.06381E+02  +2.08397E+01
+ -1.06387E+02  +2.06379E+01
+ -1.06385E+02  +2.04281E+01
+ -1.06352E+02  +2.02027E+01
+ -1.06271E+02  +1.99158E+01
+ -1.06121E+02  +1.96437E+01
+ -1.05949E+02  +1.94019E+01
+ -1.05739E+02  +1.91644E+01
+ -1.05546E+02  +1.89807E+01
+ -1.05247E+02  +1.87619E+01
+> RI-CO                      DeMets and Wilson   1997
+ -1.05586E+02  +1.78808E+01
+ -1.05510E+02  +1.81403E+01
+ -1.05442E+02  +1.83552E+01
+ -1.05352E+02  +1.85511E+01
+ -1.05247E+02  +1.87619E+01
+> PS-YA                      by Peter Bird   September 2001
+ +1.21575E+02  +2.46914E+01
+ +1.21335E+02  +2.49630E+01
+> PS-YA                      by Peter Bird   September 2001
+ +1.21335E+02  +2.49630E+01
+ +1.20981E+02  +2.46536E+01
+ +1.20546E+02  +2.39788E+01
+ +1.20360E+02  +2.31983E+01
+ +1.20394E+02  +2.25813E+01
+ +1.20425E+02  +2.20434E+01
+ +1.20452E+02  +2.16321E+01
+> PS/SU                      by Peter Bird   September 2001
+ +1.20452E+02  +2.16321E+01
+ +1.20344E+02  +2.12021E+01
+ +1.20290E+02  +2.06307E+01
+ +1.20502E+02  +2.02550E+01
+ +1.20441E+02  +1.99370E+01
+ +1.20115E+02  +1.94868E+01
+ +1.19795E+02  +1.88781E+01
+ +1.19279E+02  +1.82014E+01
+ +1.19161E+02  +1.76290E+01
+ +1.19248E+02  +1.68402E+01
+ +1.19255E+02  +1.65557E+01
+> PS-SU                      by Peter Bird   September 2001
+ +1.19255E+02  +1.65557E+01
+ +1.19728E+02  +1.64070E+01
+ +1.20201E+02  +1.62573E+01
+ +1.20673E+02  +1.61065E+01
+ +1.21145E+02  +1.59547E+01
+ +1.21616E+02  +1.58018E+01
+ +1.22086E+02  +1.56479E+01
+ +1.22555E+02  +1.54930E+01
+ +1.23024E+02  +1.53372E+01
+ +1.23492E+02  +1.51804E+01
+ +1.23959E+02  +1.50226E+01
+ +1.24425E+02  +1.48639E+01
+ +1.24891E+02  +1.47042E+01
+> PS\SU                      by Peter Bird   September 2001
+ +1.24891E+02  +1.47042E+01
+ +1.25150E+02  +1.41321E+01
+ +1.25494E+02  +1.33056E+01
+ +1.25686E+02  +1.28181E+01
+ +1.26137E+02  +1.22653E+01
+ +1.26240E+02  +1.16304E+01
+ +1.26214E+02  +1.10599E+01
+ +1.26573E+02  +1.02964E+01
+ +1.26824E+02  +9.44925E+00
+ +1.27053E+02  +8.75031E+00
+ +1.27219E+02  +8.13649E+00
+ +1.27234E+02  +7.29165E+00
+ +1.27250E+02  +6.44683E+00
+ +1.27459E+02  +5.89653E+00
+ +1.27498E+02  +5.47404E+00
+ +1.27836E+02  +5.22401E+00
+ +1.28151E+02  +4.76318E+00
+ +1.28387E+02  +4.33466E+00
+ +1.28684E+02  +3.70046E+00
+ +1.28998E+02  +3.11403E+00
+ +1.29217E+02  +2.67063E+00
+ +1.29246E+02  +1.92806E+00
+ +1.29197E+02  +1.05932E+00
+> SU-BH                      by Peter Bird   June 2002
+ +1.26872E+02  +2.34565E+00
+ +1.27446E+02  +2.31942E+00
+ +1.28081E+02  +2.29031E+00
+ +1.28187E+02  +1.97371E+00
+ +1.28752E+02  +1.62297E+00
+ +1.29197E+02  +1.05932E+00
+> BH/SU                      by Peter Bird   October 2001
+ +1.26872E+02  +2.34565E+00
+ +1.26426E+02  +1.70646E+00
+> MS\SU                      by Peter Bird   September 2001
+ +1.26426E+02  +1.70646E+00
+ +1.26144E+02  +1.00135E+00
+ +1.25969E+02  +1.89999E-01
+> MS/SU                      Rangin et al. [1999]
+ +1.23430E+02  +2.00599E+00
+ +1.23219E+02  +2.02386E+00
+ +1.22480E+02  +2.37711E+00
+ +1.21669E+02  +2.30853E+00
+ +1.20824E+02  +2.31094E+00
+ +1.20189E+02  +2.20752E+00
+ +1.19696E+02  +2.03338E+00
+ +1.19306E+02  +1.57712E+00
+ +1.19249E+02  +7.13724E-01
+ +1.19475E+02  -8.10301E-02
+> MS-BS                      Rangin et al. [1999]
+ +1.19475E+02  -8.10301E-02
+ +1.19896E+02  -8.59330E-01
+ +1.20388E+02  -1.46145E+00
+ +1.20811E+02  -1.71008E+00
+ +1.21234E+02  -1.95861E+00
+ +1.21728E+02  -2.15418E+00
+ +1.22223E+02  -2.34960E+00
+ +1.22823E+02  -2.59799E+00
+ +1.23424E+02  -2.84609E+00
+ +1.23672E+02  -3.09361E+00
+ +1.23706E+02  -3.94122E+00
+ +1.23458E+02  -4.57644E+00
+ +1.24060E+02  -4.70066E+00
+ +1.24662E+02  -4.82436E+00
+ +1.25282E+02  -4.78921E+00
+ +1.25901E+02  -4.75351E+00
+ +1.26432E+02  -4.47072E+00
+ +1.26963E+02  -4.18755E+00
+ +1.27325E+02  -3.71910E+00
+> MS-BS                      by Peter Bird   October 2001
+ +1.27325E+02  -3.71910E+00
+ +1.27510E+02  -3.16252E+00
+ +1.27667E+02  -2.44696E+00
+ +1.27666E+02  -1.75821E+00
+> MS\BH                      by Peter Bird   September 2001
+ +1.25969E+02  -2.77582E-01
+ +1.25969E+02  +1.89999E-01
+ +1.26144E+02  +1.00135E+00
+ +1.26426E+02  +1.70646E+00
+> BS/SU                      Rangin et al. [1999]
+ +1.19475E+02  -8.10301E-02
+ +1.19296E+02  -6.80331E-01
+ +1.19045E+02  -1.49138E+00
+ +1.18884E+02  -1.94980E+00
+ +1.18723E+02  -2.40821E+00
+ +1.18578E+02  -3.25522E+00
+ +1.18823E+02  -3.60956E+00
+> BS-SU                      Rangin et al. [1999]
+ +1.18823E+02  -3.60956E+00
+ +1.19565E+02  -3.96595E+00
+ +1.19953E+02  -4.30293E+00
+ +1.20341E+02  -4.63970E+00
+ +1.20516E+02  -5.27551E+00
+ +1.20620E+02  -6.12225E+00
+ +1.20546E+02  -6.96760E+00
+ +1.20543E+02  -7.81221E+00
+> BS-AU                      by Peter Bird   October 2001
+ +1.32689E+02  -6.68099E+00
+ +1.33188E+02  -6.51458E+00
+ +1.33686E+02  -6.34769E+00
+ +1.33982E+02  -5.64060E+00
+ +1.33449E+02  -5.34429E+00
+ +1.33906E+02  -4.81200E+00
+> MS-BH                      by Peter Bird   October 2001
+ +1.27666E+02  -1.75821E+00
+ +1.27241E+02  -1.38815E+00
+ +1.26817E+02  -1.01801E+00
+ +1.26393E+02  -6.47813E-01
+ +1.25969E+02  -2.77582E-01
+> BH-BS                      by Peter Bird   October 2001
+ +1.27666E+02  -1.75821E+00
+ +1.28383E+02  -2.28637E+00
+> BH\BS                      Rangin et al. [1999]
+ +1.28383E+02  -2.28637E+00
+ +1.29258E+02  -2.41628E+00
+ +1.30107E+02  -2.51922E+00
+ +1.30585E+02  -2.69390E+00
+ +1.31063E+02  -2.86839E+00
+ +1.31489E+02  -3.14894E+00
+ +1.31915E+02  -3.42931E+00
+ +1.32316E+02  -3.93477E+00
+ +1.32717E+02  -4.44004E+00
+> BH-BS                      Rangin et al. [1999]
+ +1.32717E+02  -4.44004E+00
+ +1.33311E+02  -4.62627E+00
+ +1.33906E+02  -4.81200E+00
+> SU-TI                      by Peter Bird   September 2001
+ +1.20886E+02  -1.14925E+01
+ +1.20995E+02  -1.08294E+01
+ +1.21033E+02  -1.01650E+01
+ +1.20821E+02  -9.58604E+00
+ +1.20610E+02  -9.00696E+00
+ +1.20576E+02  -8.40958E+00
+ +1.20543E+02  -7.81221E+00
+> BS-TI                      Rangin et al. [1999]
+ +1.20543E+02  -7.81221E+00
+ +1.21253E+02  -7.99023E+00
+ +1.21891E+02  -8.06221E+00
+ +1.22673E+02  -7.85285E+00
+ +1.23383E+02  -7.78357E+00
+ +1.24235E+02  -7.78434E+00
+ +1.24750E+02  -7.64403E+00
+ +1.25264E+02  -7.50310E+00
+ +1.25761E+02  -7.43253E+00
+ +1.26258E+02  -7.30915E+00
+ +1.26755E+02  -7.18521E+00
+ +1.27393E+02  -7.18420E+00
+ +1.27854E+02  -6.98976E+00
+ +1.28315E+02  -6.79487E+00
+ +1.28776E+02  -6.56475E+00
+ +1.29236E+02  -6.33421E+00
+ +1.29839E+02  -6.52615E+00
+ +1.30443E+02  -6.71736E+00
+ +1.31010E+02  -6.67987E+00
+ +1.31577E+02  -6.64174E+00
+ +1.32133E+02  -6.66168E+00
+ +1.32689E+02  -6.68099E+00
+> BH/CL                      Puntodewo et al. [1994]
+ +1.38793E+02  -1.15941E+00
+ +1.38674E+02  -8.19845E-01
+ +1.38054E+02  -7.18157E-01
+ +1.37435E+02  -6.16387E-01
+ +1.36943E+02  -4.22280E-01
+ +1.36451E+02  -2.28139E-01
+ +1.35656E+02  -2.30418E-02
+ +1.34938E+02  +4.21235E-01
+ +1.34471E+02  +2.59038E-01
+ +1.33899E+02  +5.66802E-02
+ +1.33327E+02  -1.45685E-01
+ +1.32824E+02  -4.28971E-02
+ +1.32515E+02  +1.70583E-02
+> BH/PS                      Puntodewo et al. [1994]
+ +1.32515E+02  +1.70583E-02
+ +1.32373E+02  +3.39015E-02
+ +1.31738E+02  +1.49742E-01
+ +1.31102E+02  +2.65561E-01
+ +1.30546E+02  +4.74879E-01
+ +1.29989E+02  +6.84156E-01
+ +1.29197E+02  +1.05932E+00
+> AU-MO                      by Peter Bird   September 2001
+ +1.40798E+02  -5.10959E+00
+ +1.40264E+02  -4.93064E+00
+ +1.39731E+02  -4.75127E+00
+ +1.38959E+02  -4.54782E+00
+ +1.38484E+02  -4.44247E+00
+ +1.38010E+02  -4.33682E+00
+ +1.37177E+02  -4.22116E+00
+ +1.36672E+02  -4.19929E+00
+ +1.36167E+02  -4.17709E+00
+ +1.35459E+02  -4.21818E+00
+ +1.34966E+02  -4.29798E+00
+> AU-BH                      Rangin et al. [1999]
+ +1.34966E+02  -4.29798E+00
+ +1.34488E+02  -4.43733E+00
+ +1.33906E+02  -4.81200E+00
+> MO-BH                      Rangin et al. [1999]
+ +1.38972E+02  -1.60750E+00
+ +1.38488E+02  -1.75378E+00
+ +1.38003E+02  -1.89992E+00
+ +1.37634E+02  -2.08011E+00
+ +1.37282E+02  -2.29536E+00
+ +1.36931E+02  -2.49285E+00
+ +1.36562E+02  -2.79637E+00
+ +1.36167E+02  -3.10001E+00
+ +1.35771E+02  -3.40349E+00
+ +1.35262E+02  -3.84898E+00
+ +1.34966E+02  -4.29798E+00
+> SU-BU                      per Brian Taylor   p.c.   2002
+ +9.64803E+01  +1.44000E+01
+ +9.65031E+01  +1.41292E+01
+ +9.58571E+01  +1.37825E+01
+ +9.55046E+01  +1.29180E+01
+ +9.51546E+01  +1.20530E+01
+ +9.48068E+01  +1.11876E+01
+ +9.44146E+01  +1.06790E+01
+ +9.40238E+01  +1.01700E+01
+ +9.42164E+01  +9.71684E+00
+ +9.44146E+01  +9.27021E+00
+ +9.39860E+01  +9.01948E+00
+ +9.41712E+01  +8.68600E+00
+ +9.44288E+01  +8.31186E+00
+ +9.47747E+01  +7.84720E+00
+ +9.44599E+01  +7.60272E+00
+ +9.48826E+01  +7.13930E+00
+ +9.44975E+01  +6.83692E+00
+ +9.49496E+01  +6.25911E+00
+ +9.54350E+01  +5.71525E+00
+ +9.60135E+01  +5.11363E+00
+ +9.65669E+01  +4.64448E+00
+ +9.66014E+01  +3.77218E+00
+ +9.66968E+01  +2.97907E+00
+ +9.67828E+01  +2.18540E+00
+ +9.67427E+01  +1.76284E+00
+ +9.62019E+01  +1.34500E+00
+> IN\BU                      by Peter Bird   October 2001
+ +9.22781E+01  +6.94757E+00
+ +9.19032E+01  +7.66274E+00
+ +9.17809E+01  +8.15983E+00
+ +9.16511E+01  +8.65620E+00
+ +9.15959E+01  +9.13017E+00
+ +9.15334E+01  +9.60370E+00
+ +9.15586E+01  +1.00560E+01
+ +9.15764E+01  +1.05142E+01
+ +9.15907E+01  +1.13003E+01
+ +9.16426E+01  +1.17915E+01
+ +9.17000E+01  +1.22832E+01
+ +9.18889E+01  +1.31537E+01
+ +9.20682E+01  +1.37149E+01
+> IN-BU                      by Peter Bird   October 2001
+ +9.20682E+01  +1.37149E+01
+ +9.25168E+01  +1.43843E+01
+ +9.29413E+01  +1.48688E+01
+ +9.33678E+01  +1.53526E+01
+ +9.37878E+01  +1.55618E+01
+ +9.42086E+01  +1.57702E+01
+ +9.50951E+01  +1.58126E+01
+ +9.59115E+01  +1.55345E+01
+ +9.64061E+01  +1.51355E+01
+> MS/SU                      by Peter Bird   October 2001
+ +1.25969E+02  +1.89999E-01
+ +1.25616E+02  -1.27790E-01
+ +1.25263E+02  -4.45578E-01
+> MS-SU                      by Peter Bird   October 2001
+ +1.25263E+02  -4.45578E-01
+ +1.24857E+02  -2.69106E-01
+ +1.24416E+02  +1.33426E-02
+ +1.24010E+02  +4.36971E-01
+ +1.23746E+02  +8.42787E-01
+ +1.23535E+02  +1.35416E+00
+ +1.23448E+02  +1.81227E+00
+ +1.23430E+02  +2.00599E+00
+> EU-NA                      by Peter Bird   November 2001
+ -1.57156E+01  +6.95499E+01
+ -1.60335E+01  +6.92647E+01
+ -1.62627E+01  +6.90379E+01
+ -1.64874E+01  +6.88084E+01
+ -1.71537E+01  +6.88649E+01
+ -1.73917E+01  +6.86995E+01
+ -1.78291E+01  +6.83998E+01
+ -1.82203E+01  +6.80662E+01
+ -1.84899E+01  +6.77376E+01
+ -1.87562E+01  +6.74434E+01
+ -1.90988E+01  +6.70581E+01
+ -1.81180E+01  +6.69337E+01
+ -1.82473E+01  +6.67807E+01
+ -1.74735E+01  +6.66852E+01
+ -1.77178E+01  +6.63645E+01
+ -1.65068E+01  +6.62030E+01
+ -1.66561E+01  +6.59435E+01
+ -1.68594E+01  +6.56773E+01
+ -1.70250E+01  +6.53793E+01
+ -1.71410E+01  +6.49952E+01
+ -1.73675E+01  +6.47367E+01
+ -1.78218E+01  +6.44892E+01
+ -1.86261E+01  +6.41823E+01
+ -1.90407E+01  +6.39849E+01
+ -1.92377E+01  +6.38625E+01
+ -2.00967E+01  +6.39494E+01
+ -2.07313E+01  +6.40171E+01
+ -2.12976E+01  +6.40672E+01
+ -2.20656E+01  +6.39224E+01
+ -2.25374E+01  +6.38361E+01
+ -2.28720E+01  +6.37673E+01
+ -2.30586E+01  +6.36498E+01
+ -2.33303E+01  +6.36508E+01
+ -2.34873E+01  +6.35682E+01
+ -2.37405E+01  +6.34737E+01
+ -2.40095E+01  +6.33551E+01
+ -2.42547E+01  +6.32297E+01
+ -2.45193E+01  +6.31102E+01
+ -2.47207E+01  +6.29922E+01
+ -2.48881E+01  +6.29238E+01
+ -2.50351E+01  +6.28003E+01
+ -2.51564E+01  +6.27100E+01
+ -2.53112E+01  +6.26137E+01
+ -2.54487E+01  +6.26200E+01
+ -2.56435E+01  +6.25031E+01
+ -2.58748E+01  +6.23751E+01
+ -2.61072E+01  +6.22373E+01
+ -2.63089E+01  +6.21050E+01
+ -2.65265E+01  +6.19392E+01
+ -2.67680E+01  +6.18252E+01
+ -2.70316E+01  +6.16654E+01
+ -2.72257E+01  +6.15320E+01
+ -2.73888E+01  +6.13976E+01
+ -2.75817E+01  +6.12519E+01
+ -2.78545E+01  +6.10664E+01
+ -2.80237E+01  +6.09563E+01
+ -2.81924E+01  +6.08483E+01
+ -2.84077E+01  +6.07045E+01
+ -2.86416E+01  +6.05661E+01
+ -2.88286E+01  +6.04186E+01
+ -2.89266E+01  +6.03334E+01
+ -2.90285E+01  +6.03399E+01
+ -2.91180E+01  +6.02731E+01
+ -2.92245E+01  +6.01678E+01
+ -2.93717E+01  +6.00827E+01
+> IN-AU                      by Peter Bird   November 2001
+ +6.82738E+01  -6.81092E+00
+ +6.90074E+01  -6.53842E+00
+ +6.98059E+01  -6.44461E+00
+ +7.02918E+01  -6.47357E+00
+ +7.07856E+01  -6.50237E+00
+ +7.13125E+01  -6.59931E+00
+ +7.18341E+01  -6.69593E+00
+ +7.23549E+01  -6.86701E+00
+ +7.28839E+01  -7.03843E+00
+ +7.33917E+01  -7.03892E+00
+ +7.35440E+01  -6.19055E+00
+ +7.37043E+01  -5.77811E+00
+ +7.37697E+01  -4.92652E+00
+ +7.38831E+01  -4.30742E+00
+ +7.43580E+01  -4.41080E+00
+ +7.48331E+01  -4.51388E+00
+ +7.55177E+01  -4.77642E+00
+ +7.62028E+01  -5.03829E+00
+ +7.67791E+01  -5.04649E+00
+ +7.73555E+01  -5.05469E+00
+ +7.79808E+01  -4.99351E+00
+ +7.86060E+01  -4.93173E+00
+ +7.91411E+01  -4.75245E+00
+ +7.96759E+01  -4.57275E+00
+ +8.03741E+01  -4.39311E+00
+ +8.10720E+01  -4.21280E+00
+ +8.17010E+01  -4.03076E+00
+ +8.23298E+01  -3.84823E+00
+ +8.27964E+01  -3.64078E+00
+ +8.32627E+01  -3.43309E+00
+ +8.37288E+01  -3.22518E+00
+ +8.41947E+01  -3.01705E+00
+ +8.49865E+01  -3.18095E+00
+ +8.57786E+01  -3.34424E+00
+ +8.65012E+01  -3.71634E+00
+ +8.72245E+01  -4.08784E+00
+ +8.79227E+01  -3.52864E+00
+ +8.86200E+01  -2.96892E+00
+ +8.88280E+01  -2.27141E+00
+ +8.90359E+01  -1.57386E+00
+ +8.94304E+01  -1.17860E+00
+ +8.98247E+01  -7.83283E-01
+ +9.06301E+01  -4.50318E-01
+ +9.14355E+01  -1.17271E-01
+ +9.22408E+01  +2.15803E-01
+ +9.30462E+01  +5.48836E-01
+ +9.38517E+01  +8.81760E-01
+ +9.44154E+01  +1.49300E+00
+ +9.49794E+01  +2.10410E+00
+> PA/AU                      Massell et al.   2000   Figure 3   Puysegur thrust
+ +1.66951E+02  -4.49871E+01
+ +1.66710E+02  -4.52113E+01
+ +1.66537E+02  -4.53502E+01
+ +1.66377E+02  -4.55150E+01
+ +1.66205E+02  -4.57364E+01
+ +1.66019E+02  -4.58872E+01
+ +1.65920E+02  -4.59581E+01
+ +1.65733E+02  -4.60648E+01
+ +1.65427E+02  -4.61898E+01
+ +1.65168E+02  -4.64052E+01
+ +1.65021E+02  -4.66013E+01
+ +1.64943E+02  -4.67830E+01
+ +1.64923E+02  -4.70108E+01
+ +1.64838E+02  -4.71485E+01
+ +1.64739E+02  -4.72562E+01
+ +1.64699E+02  -4.74439E+01
+ +1.64651E+02  -4.75208E+01
+ +1.64528E+02  -4.76576E+01
+ +1.64480E+02  -4.77595E+01
+ +1.64483E+02  -4.79197E+01
+ +1.64398E+02  -4.80593E+01
+ +1.64389E+02  -4.82020E+01
+ +1.64309E+02  -4.82738E+01
+ +1.64287E+02  -4.84286E+01
+ +1.64215E+02  -4.85916E+01
+ +1.64130E+02  -4.87417E+01
+ +1.63964E+02  -4.89171E+01
+ +1.63868E+02  -4.91157E+01
+ +1.63740E+02  -4.93222E+01
+ +1.63545E+02  -4.95732E+01
+ +1.63448E+02  -4.97612E+01
+ +1.63412E+02  -4.98466E+01
+ +1.63296E+02  -4.99853E+01
+ +1.63235E+02  -5.00787E+01
+> PA-AU                      Massell et al.   2000   Figure 3
+ +1.63235E+02  -5.00787E+01
+ +1.63047E+02  -5.02732E+01
+ +1.62963E+02  -5.03688E+01
+ +1.62785E+02  -5.04433E+01
+ +1.62594E+02  -5.05495E+01
+ +1.62453E+02  -5.06679E+01
+ +1.62273E+02  -5.08174E+01
+ +1.62049E+02  -5.09621E+01
+ +1.61825E+02  -5.11182E+01
+ +1.61716E+02  -5.11921E+01
+ +1.61542E+02  -5.13988E+01
+ +1.61368E+02  -5.15421E+01
+ +1.61162E+02  -5.17508E+01
+ +1.61026E+02  -5.19244E+01
+ +1.60762E+02  -5.21656E+01
+ +1.60671E+02  -5.22918E+01
+ +1.60535E+02  -5.24327E+01
+ +1.60342E+02  -5.26336E+01
+ +1.60092E+02  -5.28217E+01
+ +1.59905E+02  -5.29907E+01
+ +1.59731E+02  -5.31704E+01
+ +1.59512E+02  -5.33452E+01
+ +1.59318E+02  -5.35980E+01
+ +1.59216E+02  -5.36195E+01
+ +1.59142E+02  -5.38122E+01
+ +1.58985E+02  -5.40883E+01
+ +1.58885E+02  -5.43080E+01
+ +1.58740E+02  -5.45589E+01
+ +1.58674E+02  -5.46894E+01
+ +1.58618E+02  -5.49279E+01
+ +1.58596E+02  -5.50467E+01
+ +1.58540E+02  -5.52724E+01
+ +1.58465E+02  -5.55216E+01
+ +1.58332E+02  -5.57793E+01
+ +1.58226E+02  -5.60216E+01
+ +1.58153E+02  -5.61647E+01
+ +1.58042E+02  -5.63105E+01
+ +1.57944E+02  -5.64385E+01
+ +1.57823E+02  -5.67248E+01
+ +1.57703E+02  -5.69918E+01
+ +1.57640E+02  -5.72302E+01
+ +1.57615E+02  -5.74740E+01
+ +1.57620E+02  -5.77835E+01
+ +1.57751E+02  -5.80681E+01
+ +1.57920E+02  -5.83342E+01
+ +1.58121E+02  -5.86051E+01
+ +1.58267E+02  -5.87792E+01
+ +1.58385E+02  -5.88581E+01
+ +1.58650E+02  -5.90705E+01
+ +1.58972E+02  -5.93046E+01
+ +1.59186E+02  -5.95107E+01
+ +1.59413E+02  -5.97316E+01
+ +1.59691E+02  -5.99387E+01
+ +1.59803E+02  -6.00055E+01
+> ON-PS                      by P. Bird   May 2002   after Lallemand et al. [1997b]
+ +1.21575E+02  +2.46914E+01
+ +1.21779E+02  +2.42554E+01
+ +1.22140E+02  +2.39492E+01
+ +1.22501E+02  +2.36429E+01
+ +1.23010E+02  +2.34686E+01
+ +1.23518E+02  +2.34541E+01
+ +1.24026E+02  +2.34381E+01
+ +1.24534E+02  +2.34203E+01
+ +1.25042E+02  +2.34009E+01
+ +1.25550E+02  +2.33799E+01
+> ON/PS                      by Peter Bird   September 2001
+ +1.25550E+02  +2.33799E+01
+ +1.25954E+02  +2.34977E+01
+ +1.26426E+02  +2.37606E+01
+ +1.26901E+02  +2.41011E+01
+ +1.27398E+02  +2.45029E+01
+ +1.27907E+02  +2.49690E+01
+ +1.28462E+02  +2.54576E+01
+> YA-ON                      Letouzey & Kimura [1985]
+ +1.21575E+02  +2.46914E+01
+ +1.22024E+02  +2.48530E+01
+ +1.22554E+02  +2.50649E+01
+ +1.23182E+02  +2.48598E+01
+ +1.23721E+02  +2.48985E+01
+ +1.23755E+02  +2.50165E+01
+ +1.24148E+02  +2.50702E+01
+ +1.24705E+02  +2.51197E+01
+ +1.24697E+02  +2.54751E+01
+ +1.25159E+02  +2.55691E+01
+ +1.25736E+02  +2.56437E+01
+ +1.25663E+02  +2.59270E+01
+ +1.26065E+02  +2.61233E+01
+ +1.26383E+02  +2.63700E+01
+ +1.26477E+02  +2.65403E+01
+ +1.26820E+02  +2.68106E+01
+ +1.26745E+02  +2.70057E+01
+ +1.26885E+02  +2.71491E+01
+ +1.27417E+02  +2.74855E+01
+ +1.27347E+02  +2.76615E+01
+ +1.27599E+02  +2.77896E+01
+ +1.28049E+02  +2.80528E+01
+ +1.28557E+02  +2.84010E+01
+ +1.28321E+02  +2.87079E+01
+ +1.28687E+02  +2.90321E+01
+ +1.29055E+02  +2.93554E+01
+ +1.28646E+02  +2.98931E+01
+ +1.28881E+02  +3.01042E+01
+ +1.28848E+02  +3.03870E+01
+ +1.29032E+02  +3.05854E+01
+ +1.28819E+02  +3.10245E+01
+ +1.29059E+02  +3.12645E+01
+ +1.29121E+02  +3.14094E+01
+ +1.29442E+02  +3.17926E+01
+> AM-ON                      by Peter Bird   May 2002
+ +1.29442E+02  +3.17926E+01
+ +1.29768E+02  +3.20417E+01
+ +1.30185E+02  +3.20194E+01
+ +1.30835E+02  +3.19821E+01
+ +1.31284E+02  +3.18771E+01
+ +1.31717E+02  +3.17606E+01
+ +1.32030E+02  +3.14844E+01
+ +1.32269E+02  +3.12571E+01
+ +1.32581E+02  +3.09906E+01
+ +1.32824E+02  +3.07544E+01
+> EU-AM                      by Peter Bird   May 2002
+ +1.23364E+02  +3.14713E+01
+ +1.24072E+02  +3.21727E+01
+ +1.24791E+02  +3.28701E+01
+ +1.25521E+02  +3.35633E+01
+ +1.26263E+02  +3.42521E+01
+> AM-YA                      by Peter Bird   May 2002
+ +1.23364E+02  +3.14713E+01
+ +1.23867E+02  +3.13257E+01
+ +1.24487E+02  +3.12501E+01
+ +1.25030E+02  +3.11957E+01
+ +1.25729E+02  +3.12017E+01
+ +1.26404E+02  +3.12274E+01
+ +1.27054E+02  +3.12730E+01
+ +1.27655E+02  +3.13620E+01
+ +1.28258E+02  +3.14706E+01
+ +1.28812E+02  +3.16013E+01
+ +1.29442E+02  +3.17926E+01
+> CL-PS                      Weissel and Anderson [1978]
+ +1.34521E+02  +6.99019E+00
+ +1.34269E+02  +6.61025E+00
+ +1.33989E+02  +6.33263E+00
+ +1.33674E+02  +6.15594E+00
+ +1.33429E+02  +5.96222E+00
+ +1.33308E+02  +5.73427E+00
+ +1.33240E+02  +5.34909E+00
+ +1.33189E+02  +5.01620E+00
+ +1.33032E+02  +4.78754E+00
+ +1.32911E+02  +4.45382E+00
+ +1.32790E+02  +4.11986E+00
+ +1.32740E+02  +3.69833E+00
+ +1.32795E+02  +3.31224E+00
+ +1.32850E+02  +2.90828E+00
+ +1.32817E+02  +2.53873E+00
+ +1.32766E+02  +2.25688E+00
+ +1.32734E+02  +1.72846E+00
+ +1.32720E+02  +1.16455E+00
+ +1.32651E+02  +8.11580E-01
+ +1.32515E+02  +1.70583E-02
+> PA-CL                      by Peter Bird   June 2002
+ +1.38359E+02  +9.37865E+00
+ +1.39192E+02  +9.06494E+00
+ +1.39886E+02  +8.86631E+00
+ +1.40579E+02  +8.66639E+00
+ +1.41048E+02  +8.39250E+00
+ +1.41517E+02  +8.11804E+00
+ +1.42262E+02  +7.61077E+00
+ +1.42666E+02  +7.38844E+00
+ +1.43070E+02  +7.16576E+00
+ +1.43558E+02  +6.80532E+00
+ +1.44026E+02  +6.67698E+00
+ +1.44664E+02  +6.61101E+00
+ +1.45067E+02  +6.50348E+00
+ +1.45471E+02  +6.35347E+00
+ +1.46001E+02  +6.16022E+00
+ +1.46382E+02  +5.88304E+00
+ +1.46730E+02  +5.51071E+00
+ +1.47078E+02  +5.13818E+00
+ +1.47425E+02  +4.76546E+00
+ +1.47772E+02  +4.39257E+00
+ +1.48191E+02  +3.77564E+00
+ +1.48694E+02  +3.13658E+00
+ +1.48668E+02  +2.62928E+00
+ +1.48684E+02  +2.05827E+00
+ +1.48700E+02  +1.48745E+00
+ +1.48863E+02  +9.36586E-01
+ +1.49112E+02  +4.06263E-01
+ +1.49191E+02  -1.43239E-01
+ +1.49251E+02  -3.96981E-01
+ +1.49270E+02  -6.50210E-01
+> CL-NB                      by Peter Bird   June 2002
+ +1.42246E+02  -2.69310E+00
+ +1.42394E+02  -2.46221E+00
+ +1.42626E+02  -1.91593E+00
+ +1.42922E+02  -1.45354E+00
+ +1.43260E+02  -1.15956E+00
+ +1.43808E+02  -9.50568E-01
+ +1.44357E+02  -7.41885E-01
+ +1.45033E+02  -5.34111E-01
+ +1.45497E+02  -4.73267E-01
+ +1.45919E+02  -3.49163E-01
+ +1.46595E+02  -2.90218E-01
+ +1.47059E+02  -2.93510E-01
+ +1.47354E+02  -2.74652E-01
+ +1.47859E+02  -4.26351E-01
+ +1.48344E+02  -4.09460E-01
+ +1.48724E+02  -3.91858E-01
+ +1.48913E+02  -4.56923E-01
+ +1.49270E+02  -6.50210E-01
+> PA-NB                      by Peter Bird   June 2002
+ +1.49270E+02  -6.50210E-01
+ +1.49481E+02  -8.18472E-01
+ +1.49769E+02  -1.00453E+00
+ +1.50023E+02  -1.02138E+00
+ +1.50344E+02  -1.12276E+00
+ +1.50717E+02  -1.22404E+00
+ +1.51089E+02  -1.30833E+00
+ +1.51427E+02  -1.46017E+00
+ +1.51816E+02  -1.64562E+00
+ +1.52155E+02  -1.86475E+00
+ +1.52578E+02  -2.13414E+00
+ +1.52916E+02  -2.15020E+00
+ +1.53119E+02  -2.20029E+00
+ +1.53390E+02  -2.43572E+00
+ +1.53542E+02  -2.60389E+00
+ +1.53711E+02  -2.68759E+00
+ +1.53882E+02  -3.04097E+00
+ +1.54035E+02  -3.32680E+00
+ +1.54256E+02  -3.61210E+00
+ +1.54359E+02  -3.94845E+00
+ +1.54700E+02  -4.28294E+00
+ +1.54955E+02  -4.55028E+00
+ +1.54992E+02  -4.88657E+00
+ +1.54978E+02  -5.24012E+00
+ +1.54592E+02  -5.58051E+00
+ +1.54545E+02  -5.90097E+00
+ +1.54533E+02  -6.42324E+00
+ +1.54730E+02  -6.85808E+00
+ +1.54927E+02  -7.29284E+00
+> CL\WL                      by Peter Bird   June 2002
+ +1.38793E+02  -1.15941E+00
+ +1.39257E+02  -1.38997E+00
+ +1.39805E+02  -1.55742E+00
+ +1.40226E+02  -1.76738E+00
+ +1.40837E+02  -1.89328E+00
+ +1.41195E+02  -2.16673E+00
+ +1.41594E+02  -2.27205E+00
+ +1.41868E+02  -2.39843E+00
+ +1.42246E+02  -2.69310E+00
+> WL-BH                      by Peter Bird   June 2001
+ +1.38793E+02  -1.15941E+00
+ +1.38972E+02  -1.60750E+00
+> NB-SB                      Auzende et al. [2000]; Martinez and Taylor [1996]
+ +1.43743E+02  -3.46045E+00
+ +1.44368E+02  -3.53117E+00
+ +1.44807E+02  -3.55013E+00
+ +1.45399E+02  -3.48507E+00
+ +1.46110E+02  -3.47062E+00
+ +1.46415E+02  -3.43769E+00
+ +1.46836E+02  -3.75493E+00
+ +1.46918E+02  -3.64099E+00
+ +1.46999E+02  -3.51435E+00
+ +1.47083E+02  -3.38515E+00
+ +1.47162E+02  -3.26100E+00
+ +1.47241E+02  -3.15205E+00
+ +1.47325E+02  -3.05326E+00
+ +1.47407E+02  -2.96204E+00
+ +1.47478E+02  -2.90886E+00
+ +1.47539E+02  -2.88103E+00
+ +1.47605E+02  -2.87857E+00
+ +1.47816E+02  -2.81284E+00
+ +1.47983E+02  -2.92212E+00
+ +1.48123E+02  -3.02628E+00
+ +1.48329E+02  -3.14063E+00
+ +1.48499E+02  -3.22195E+00
+ +1.48675E+02  -3.30577E+00
+ +1.48878E+02  -3.39465E+00
+ +1.49089E+02  -3.46572E+00
+ +1.49295E+02  -3.52151E+00
+ +1.49453E+02  -3.54429E+00
+ +1.49603E+02  -3.56959E+00
+ +1.49717E+02  -3.57966E+00
+ +1.49773E+02  -3.59230E+00
+ +1.49816E+02  -3.61764E+00
+> NB\WL                      by Peter Bird   June 2002
+ +1.42246E+02  -2.69310E+00
+ +1.42449E+02  -2.81358E+00
+ +1.42633E+02  -2.93233E+00
+ +1.42936E+02  -3.01814E+00
+ +1.43172E+02  -3.05310E+00
+ +1.43508E+02  -3.15594E+00
+ +1.43743E+02  -3.46045E+00
+> NB-MN
+ +1.49817E+02  -3.61656E+00
+ +1.49913E+02  -3.49148E+00
+ +1.50034E+02  -3.37167E+00
+ +1.50135E+02  -3.27439E+00
+ +1.50249E+02  -3.20201E+00
+ +1.50352E+02  -3.14092E+00
+ +1.50436E+02  -3.09258E+00
+ +1.50509E+02  -3.06108E+00
+ +1.50560E+02  -3.05074E+00
+ +1.50616E+02  -3.04729E+00
+ +1.50615E+02  -3.08491E+00
+ +1.50634E+02  -3.16268E+00
+ +1.50683E+02  -3.23453E+00
+ +1.50732E+02  -3.29524E+00
+ +1.50789E+02  -3.32939E+00
+ +1.50824E+02  -3.34847E+00
+ +1.50879E+02  -3.33111E+00
+ +1.50931E+02  -3.37230E+00
+ +1.50982E+02  -3.41905E+00
+ +1.51021E+02  -3.47569E+00
+ +1.51095E+02  -3.54725E+00
+ +1.51142E+02  -3.58709E+00
+ +1.51204E+02  -3.60167E+00
+ +1.51250E+02  -3.60671E+00
+ +1.51301E+02  -3.65625E+00
+> MN-SB
+ +1.49817E+02  -3.61656E+00
+ +1.49872E+02  -3.65909E+00
+ +1.49938E+02  -3.72378E+00
+ +1.50027E+02  -3.75198E+00
+ +1.50121E+02  -3.78988E+00
+ +1.50192E+02  -3.82943E+00
+ +1.50226E+02  -3.87360E+00
+ +1.50240E+02  -3.90269E+00
+ +1.50320E+02  -3.88086E+00
+ +1.50447E+02  -3.85709E+00
+ +1.50552E+02  -3.83913E+00
+ +1.50678E+02  -3.81816E+00
+ +1.50793E+02  -3.77503E+00
+ +1.50909E+02  -3.72352E+00
+ +1.50987E+02  -3.69197E+00
+ +1.51095E+02  -3.80630E+00
+ +1.51222E+02  -3.73657E+00
+ +1.51301E+02  -3.65625E+00
+> NB-SB                      Martinez and Taylor [1996]; Taylor et al. [1995]
+ +1.51301E+02  -3.65625E+00
+ +1.51375E+02  -3.70620E+00
+ +1.51428E+02  -3.75424E+00
+ +1.51563E+02  -3.66511E+00
+ +1.51675E+02  -3.76873E+00
+ +1.51814E+02  -3.72013E+00
+ +1.51929E+02  -3.67667E+00
+ +1.51987E+02  -3.64860E+00
+ +1.52038E+02  -3.63575E+00
+ +1.52132E+02  -3.66584E+00
+ +1.52226E+02  -3.73899E+00
+ +1.52328E+02  -3.82223E+00
+ +1.52415E+02  -3.90297E+00
+ +1.52478E+02  -3.97364E+00
+ +1.52557E+02  -4.03917E+00
+ +1.52616E+02  -4.13010E+00
+ +1.52662E+02  -4.18815E+00
+ +1.52927E+02  -4.60329E+00
+ +1.53193E+02  -5.01833E+00
+ +1.53403E+02  -5.36112E+00
+ +1.53614E+02  -5.70366E+00
+ +1.53823E+02  -6.04594E+00
+ +1.53930E+02  -6.26500E+00
+> SB-WL                      Tregoning et al. [1998]
+ +1.43743E+02  -3.46045E+00
+ +1.44079E+02  -3.76571E+00
+ +1.44416E+02  -4.00368E+00
+ +1.44583E+02  -4.37576E+00
+ +1.44733E+02  -4.69723E+00
+ +1.44867E+02  -4.96807E+00
+ +1.45007E+02  -5.20188E+00
+ +1.45505E+02  -5.76218E+00
+ +1.46007E+02  -6.11228E+00
+ +1.46497E+02  -6.51288E+00
+ +1.46956E+02  -6.71785E+00
+ +1.47476E+02  -7.10285E+00
+ +1.48010E+02  -7.31238E+00
+ +1.48587E+02  -7.39451E+00
+> WL-SS                      Taylor et al. [1995]
+ +1.55454E+02  -7.48875E+00
+ +1.55262E+02  -7.62863E+00
+ +1.54872E+02  -7.96237E+00
+ +1.54481E+02  -8.29620E+00
+ +1.54087E+02  -8.63265E+00
+ +1.53697E+02  -8.96649E+00
+ +1.53255E+02  -9.18615E+00
+> WL-AU                      Taylor et al. [1995]
+ +1.51654E+02  -9.76005E+00
+ +1.51834E+02  -9.76114E+00
+ +1.51838E+02  -9.90561E+00
+ +1.51918E+02  -9.93028E+00
+ +1.52024E+02  -9.94203E+00
+ +1.52086E+02  -9.94400E+00
+ +1.52214E+02  -9.94533E+00
+ +1.52223E+02  -1.00390E+01
+ +1.52413E+02  -1.00473E+01
+ +1.52547E+02  -1.00560E+01
+ +1.52651E+02  -1.00777E+01
+ +1.52849E+02  -1.00881E+01
+ +1.52855E+02  -1.03844E+01
+ +1.53174E+02  -1.03981E+01
+ +1.53362E+02  -1.03981E+01
+ +1.53552E+02  -1.03550E+01
+ +1.53752E+02  -1.03446E+01
+ +1.53847E+02  -1.03254E+01
+ +1.54010E+02  -1.03407E+01
+ +1.54125E+02  -1.03313E+01
+ +1.54169E+02  -1.03230E+01
+ +1.54219E+02  -1.02792E+01
+ +1.54218E+02  -9.91264E+00
+ +1.54379E+02  -9.87219E+00
+ +1.54596E+02  -9.81056E+00
+ +1.54719E+02  -9.76305E+00
+ +1.54849E+02  -9.72297E+00
+ +1.54856E+02  -9.83902E+00
+ +1.54951E+02  -9.83485E+00
+ +1.55070E+02  -9.79486E+00
+ +1.55172E+02  -9.72993E+00
+ +1.55172E+02  -9.62138E+00
+ +1.55291E+02  -9.55615E+00
+ +1.55347E+02  -9.53242E+00
+ +1.55436E+02  -9.49296E+00
+ +1.55473E+02  -9.56795E+00
+ +1.55577E+02  -9.53069E+00
+ +1.55599E+02  -9.58072E+00
+ +1.55708E+02  -9.54838E+00
+ +1.55797E+02  -9.52648E+00
+ +1.55813E+02  -9.57154E+00
+ +1.55908E+02  -9.55456E+00
+ +1.55979E+02  -9.54810E+00
+ +1.55989E+02  -9.55797E+00
+ +1.56086E+02  -9.53838E+00
+ +1.56066E+02  -9.40524E+00
+ +1.56124E+02  -9.38140E+00
+ +1.56101E+02  -9.26847E+00
+ +1.56258E+02  -9.22502E+00
+ +1.56350E+02  -9.20553E+00
+ +1.56428E+02  -9.17875E+00
+ +1.56390E+02  -8.80938E+00
+ +1.56361E+02  -8.59844E+00
+ +1.56331E+02  -8.38495E+00
+ +1.56296E+02  -8.17405E+00
+> PS-MA                      Martinez et al. [2000]
+ +1.43097E+02  +1.15689E+01
+ +1.43082E+02  +1.17921E+01
+ +1.43106E+02  +1.20301E+01
+ +1.43143E+02  +1.22650E+01
+ +1.43239E+02  +1.24781E+01
+ +1.43403E+02  +1.26947E+01
+ +1.43510E+02  +1.28222E+01
+ +1.43662E+02  +1.30577E+01
+ +1.43771E+02  +1.32676E+01
+ +1.43871E+02  +1.35409E+01
+ +1.43903E+02  +1.36235E+01
+ +1.43942E+02  +1.38108E+01
+ +1.43976E+02  +1.40870E+01
+ +1.44082E+02  +1.46394E+01
+ +1.44216E+02  +1.46557E+01
+ +1.44334E+02  +1.48845E+01
+ +1.44530E+02  +1.49167E+01
+ +1.44453E+02  +1.55256E+01
+ +1.44799E+02  +1.56531E+01
+ +1.44792E+02  +1.61227E+01
+ +1.44841E+02  +1.64780E+01
+ +1.44798E+02  +1.69793E+01
+ +1.44671E+02  +1.74201E+01
+ +1.44970E+02  +1.75346E+01
+ +1.44773E+02  +1.78295E+01
+ +1.44706E+02  +1.80198E+01
+ +1.44663E+02  +1.81656E+01
+ +1.44626E+02  +1.83591E+01
+ +1.44601E+02  +1.87556E+01
+ +1.44543E+02  +1.90727E+01
+ +1.44527E+02  +1.91234E+01
+ +1.44252E+02  +1.97253E+01
+ +1.44137E+02  +1.97533E+01
+ +1.44083E+02  +1.98577E+01
+ +1.43970E+02  +2.01109E+01
+ +1.43842E+02  +2.04178E+01
+ +1.43575E+02  +2.03968E+01
+ +1.43493E+02  +2.05325E+01
+ +1.43392E+02  +2.07283E+01
+ +1.43281E+02  +2.09619E+01
+ +1.43321E+02  +2.10606E+01
+ +1.43280E+02  +2.13203E+01
+ +1.43218E+02  +2.16590E+01
+ +1.43150E+02  +2.19278E+01
+ +1.42997E+02  +2.21385E+01
+ +1.42774E+02  +2.23766E+01
+ +1.42560E+02  +2.26620E+01
+ +1.42257E+02  +2.30091E+01
+> PS-MA                      by Peter Bird   June 2002
+ +1.42257E+02  +2.30091E+01
+ +1.42886E+02  +2.37012E+01
+ +1.43522E+02  +2.43908E+01
+> NH-PA                      Auzende et al. [1995a]
+ +1.72571E+02  -1.34106E+01
+ +1.72434E+02  -1.34349E+01
+ +1.72300E+02  -1.34814E+01
+ +1.72163E+02  -1.35688E+01
+ +1.71972E+02  -1.36778E+01
+ +1.71619E+02  -1.37500E+01
+ +1.71296E+02  -1.37934E+01
+ +1.71295E+02  -1.40659E+01
+ +1.71181E+02  -1.40834E+01
+ +1.70945E+02  -1.40926E+01
+ +1.70642E+02  -1.40878E+01
+ +1.70638E+02  -1.39420E+01
+ +1.70150E+02  -1.39744E+01
+ +1.69739E+02  -1.39535E+01
+ +1.69739E+02  -1.38236E+01
+ +1.69622E+02  -1.38084E+01
+ +1.69456E+02  -1.38111E+01
+ +1.69231E+02  -1.37995E+01
+ +1.69234E+02  -1.36507E+01
+ +1.69026E+02  -1.36393E+01
+ +1.68792E+02  -1.36302E+01
+ +1.68577E+02  -1.36024E+01
+ +1.68596E+02  -1.35142E+01
+ +1.68159E+02  -1.35147E+01
+ +1.67157E+02  -1.36491E+01
+ +1.66154E+02  -1.37794E+01
+> CR-NH                      Auzende et al. [1994]
+ +1.73901E+02  -1.68493E+01
+ +1.73880E+02  -1.71634E+01
+ +1.73744E+02  -1.74900E+01
+ +1.73660E+02  -1.76802E+01
+ +1.73550E+02  -1.79623E+01
+ +1.73409E+02  -1.82380E+01
+ +1.73251E+02  -1.85324E+01
+ +1.73425E+02  -1.85203E+01
+ +1.73447E+02  -1.87740E+01
+ +1.73453E+02  -1.89992E+01
+ +1.73439E+02  -1.92211E+01
+ +1.73429E+02  -1.94303E+01
+ +1.73398E+02  -1.96616E+01
+ +1.73360E+02  -1.98896E+01
+ +1.73335E+02  -2.00860E+01
+ +1.73351E+02  -2.03774E+01
+ +1.73384E+02  -2.06245E+01
+ +1.73380E+02  -2.08367E+01
+ +1.73383E+02  -2.09949E+01
+ +1.73379E+02  -2.11405E+01
+ +1.74119E+02  -2.11477E+01
+ +1.74115E+02  -2.13565E+01
+ +1.74112E+02  -2.15779E+01
+ +1.74090E+02  -2.18407E+01
+ +1.74056E+02  -2.22358E+01
+ +1.74034E+02  -2.24881E+01
+> NH-AU                      Peter Bird   June 2002
+ +1.72439E+02  -2.31781E+01
+ +1.72783E+02  -2.30686E+01
+ +1.73040E+02  -2.30068E+01
+ +1.73212E+02  -2.28339E+01
+ +1.73606E+02  -2.28350E+01
+ +1.74034E+02  -2.24881E+01
+> BR-NH                      Peter Bird   June 2002
+ +1.72571E+02  -1.34106E+01
+ +1.72740E+02  -1.36927E+01
+ +1.72881E+02  -1.39649E+01
+ +1.73019E+02  -1.42940E+01
+ +1.73139E+02  -1.45100E+01
+ +1.73178E+02  -1.46687E+01
+ +1.73210E+02  -1.47703E+01
+ +1.73259E+02  -1.48973E+01
+ +1.73294E+02  -1.49925E+01
+ +1.73320E+02  -1.50814E+01
+ +1.73346E+02  -1.51544E+01
+ +1.73359E+02  -1.52337E+01
+ +1.73388E+02  -1.53607E+01
+ +1.73428E+02  -1.54369E+01
+ +1.73464E+02  -1.55036E+01
+ +1.73516E+02  -1.55671E+01
+ +1.73539E+02  -1.56053E+01
+ +1.73555E+02  -1.56973E+01
+ +1.73400E+02  -1.57793E+01
+ +1.73485E+02  -1.59223E+01
+ +1.73531E+02  -1.60271E+01
+ +1.73567E+02  -1.61509E+01
+ +1.73455E+02  -1.62585E+01
+ +1.73593E+02  -1.64967E+01
+ +1.73669E+02  -1.66143E+01
+ +1.73718E+02  -1.67127E+01
+ +1.73788E+02  -1.67984E+01
+ +1.73901E+02  -1.68493E+01
+> BR-CR                      Auzende et al. [1994]
+ +1.73901E+02  -1.68493E+01
+ +1.74503E+02  -1.65632E+01
+ +1.74885E+02  -1.68728E+01
+ +1.75107E+02  -1.67480E+01
+ +1.75226E+02  -1.67409E+01
+ +1.75381E+02  -1.66289E+01
+ +1.75487E+02  -1.66218E+01
+ +1.75612E+02  -1.65860E+01
+ +1.75893E+02  -1.65582E+01
+ +1.76184E+02  -1.65521E+01
+> AU-CR                      Auzende et al. [1994]
+ +1.76184E+02  -1.65521E+01
+ +1.76179E+02  -1.66696E+01
+ +1.76148E+02  -1.68158E+01
+ +1.76106E+02  -1.69654E+01
+ +1.76065E+02  -1.70895E+01
+ +1.76036E+02  -1.72389E+01
+ +1.75986E+02  -1.75408E+01
+ +1.75973E+02  -1.78043E+01
+ +1.76336E+02  -1.78227E+01
+ +1.76342E+02  -1.80384E+01
+ +1.76300E+02  -1.81403E+01
+ +1.76244E+02  -1.82425E+01
+ +1.76215E+02  -1.83189E+01
+ +1.76212E+02  -1.86107E+01
+ +1.76136E+02  -1.87320E+01
+ +1.76061E+02  -1.88945E+01
+ +1.75975E+02  -1.90222E+01
+ +1.75922E+02  -1.90798E+01
+ +1.75900E+02  -1.91624E+01
+ +1.75885E+02  -1.93274E+01
+ +1.75839E+02  -1.94451E+01
+ +1.75772E+02  -1.95471E+01
+ +1.75559E+02  -1.97548E+01
+ +1.75574E+02  -1.99765E+01
+ +1.75590E+02  -2.01887E+01
+> AU-CR                      Peter Bird   June 2002
+ +1.75590E+02  -2.01887E+01
+ +1.75828E+02  -2.06294E+01
+ +1.76121E+02  -2.11655E+01
+ +1.75733E+02  -2.14216E+01
+ +1.75231E+02  -2.17500E+01
+ +1.74584E+02  -2.21704E+01
+ +1.74034E+02  -2.24881E+01
+> BR-AU                      Auzende et al. [1995a]
+ +1.76184E+02  -1.65521E+01
+ +1.76377E+02  -1.65690E+01
+ +1.76545E+02  -1.65574E+01
+ +1.76671E+02  -1.65527E+01
+ +1.76790E+02  -1.65447E+01
+ +1.76883E+02  -1.65435E+01
+ +1.76949E+02  -1.65235E+01
+ +1.77035E+02  -1.65159E+01
+ +1.77130E+02  -1.65049E+01
+ +1.77190E+02  -1.65040E+01
+ +1.77269E+02  -1.65059E+01
+ +1.77412E+02  -1.65099E+01
+ +1.77414E+02  -1.63005E+01
+ +1.77345E+02  -1.63016E+01
+ +1.77400E+02  -1.62119E+01
+ +1.77588E+02  -1.62245E+01
+ +1.77721E+02  -1.62285E+01
+ +1.77806E+02  -1.62269E+01
+ +1.77876E+02  -1.62224E+01
+ +1.78007E+02  -1.61723E+01
+ +1.78086E+02  -1.61485E+01
+ +1.78171E+02  -1.61151E+01
+ +1.78283E+02  -1.61096E+01
+ +1.78402E+02  -1.61039E+01
+ +1.78491E+02  -1.60924E+01
+ +1.78524E+02  -1.59838E+01
+ +1.78562E+02  -1.58973E+01
+> BR-AU                      Auzende et al. [1994]
+ +1.78562E+02  -1.58973E+01
+ +1.78936E+02  -1.58124E+01
+ +1.79332E+02  -1.57295E+01
+ +1.79614E+02  -1.56775E+01
+ +1.79890E+02  -1.56538E+01
+ -1.79739E+02  -1.55422E+01
+> PA-BR                      Schellart et al. [2002]
+ +1.72571E+02  -1.34106E+01
+ +1.73049E+02  -1.34895E+01
+ +1.73671E+02  -1.35168E+01
+ +1.73941E+02  -1.32954E+01
+ +1.74482E+02  -1.33961E+01
+ +1.74661E+02  -1.34146E+01
+ +1.74784E+02  -1.33952E+01
+ +1.74898E+02  -1.33345E+01
+ +1.75314E+02  -1.32436E+01
+ +1.75659E+02  -1.33265E+01
+ +1.75947E+02  -1.34221E+01
+ +1.76021E+02  -1.36431E+01
+ +1.76256E+02  -1.36723E+01
+ +1.76618E+02  -1.37312E+01
+ +1.76966E+02  -1.38531E+01
+ +1.77167E+02  -1.39483E+01
+ +1.77417E+02  -1.40551E+01
+> PA-BR                      Peter Bird   June 2002
+ +1.77417E+02  -1.40551E+01
+ +1.78029E+02  -1.43090E+01
+ +1.78469E+02  -1.45006E+01
+ +1.79012E+02  -1.47838E+01
+ +1.79389E+02  -1.49750E+01
+ +1.79790E+02  -1.52177E+01
+ -1.79739E+02  -1.55422E+01
+> PA-AU                      Pelletier et al. [1998]
+ -1.79739E+02  -1.55422E+01
+ -1.79444E+02  -1.55268E+01
+> FT-AU                      Peter Bird   June 2002
+ -1.79444E+02  -1.55268E+01
+ -1.78812E+02  -1.53773E+01
+ -1.78264E+02  -1.53255E+01
+ -1.77691E+02  -1.53981E+01
+ -1.77130E+02  -1.55594E+01
+> FT-PA                      Peter Bird   June 2002
+ -1.76346E+02  -1.46340E+01
+ -1.76880E+02  -1.46708E+01
+ -1.77415E+02  -1.47064E+01
+ -1.77746E+02  -1.46461E+01
+ -1.78240E+02  -1.43166E+01
+ -1.78733E+02  -1.39861E+01
+ -1.78768E+02  -1.42304E+01
+ -1.78888E+02  -1.42241E+01
+ -1.79048E+02  -1.49275E+01
+ -1.79288E+02  -1.49356E+01
+ -1.79444E+02  -1.55268E+01
+> EA-PA                      Naar and Hey   1991
+ -1.14421E+02  -2.21145E+01
+ -1.14505E+02  -2.21961E+01
+ -1.14498E+02  -2.25426E+01
+ -1.14567E+02  -2.30236E+01
+ -1.14875E+02  -2.30396E+01
+ -1.14962E+02  -2.31789E+01
+ -1.15183E+02  -2.32370E+01
+ -1.15254E+02  -2.33975E+01
+ -1.15599E+02  -2.34684E+01
+ -1.15424E+02  -2.38844E+01
+ -1.15402E+02  -2.40174E+01
+ -1.15482E+02  -2.41051E+01
+ -1.15912E+02  -2.42418E+01
+ -1.15968E+02  -2.43829E+01
+ -1.16184E+02  -2.44583E+01
+ -1.16225E+02  -2.45558E+01
+ -1.16099E+02  -2.48475E+01
+ -1.16490E+02  -2.51720E+01
+ -1.16353E+02  -2.54158E+01
+ -1.16028E+02  -2.56738E+01
+ -1.15769E+02  -2.59677E+01
+ -1.15518E+02  -2.62434E+01
+ -1.15291E+02  -2.64659E+01
+ -1.15105E+02  -2.66040E+01
+ -1.14526E+02  -2.67251E+01
+ -1.13944E+02  -2.67897E+01
+ -1.13608E+02  -2.68088E+01
+ -1.12976E+02  -2.68302E+01
+> EA-NZ                      Naar and Hey   1991
+ -1.12976E+02  -2.68302E+01
+ -1.12947E+02  -2.67241E+01
+ -1.12684E+02  -2.68009E+01
+ -1.12658E+02  -2.65538E+01
+ -1.12683E+02  -2.62823E+01
+ -1.12672E+02  -2.60379E+01
+ -1.12620E+02  -2.59342E+01
+ -1.12550E+02  -2.59259E+01
+ -1.12541E+02  -2.57874E+01
+ -1.12455E+02  -2.57860E+01
+ -1.12437E+02  -2.56827E+01
+ -1.12364E+02  -2.56637E+01
+ -1.12366E+02  -2.55642E+01
+ -1.12388E+02  -2.54292E+01
+ -1.12443E+02  -2.51985E+01
+ -1.12453E+02  -2.50594E+01
+ -1.11978E+02  -2.50266E+01
+ -1.11977E+02  -2.48907E+01
+ -1.12048E+02  -2.46591E+01
+ -1.12103E+02  -2.44485E+01
+ -1.12123E+02  -2.42224E+01
+ -1.12098E+02  -2.41104E+01
+ -1.11713E+02  -2.40320E+01
+ -1.11763E+02  -2.38598E+01
+ -1.11832E+02  -2.37275E+01
+ -1.11864E+02  -2.34750E+01
+ -1.11871E+02  -2.33267E+01
+ -1.11741E+02  -2.32087E+01
+ -1.11924E+02  -2.30158E+01
+ -1.12208E+02  -2.28209E+01
+ -1.12575E+02  -2.26195E+01
+ -1.12934E+02  -2.24070E+01
+ -1.13280E+02  -2.22231E+01
+ -1.13610E+02  -2.21264E+01
+ -1.13906E+02  -2.21022E+01
+ -1.14125E+02  -2.21057E+01
+ -1.14421E+02  -2.21145E+01
+> JZ-PA                      Larson et al. [1992]
+ -1.12023E+02  -3.15362E+01
+ -1.12041E+02  -3.17737E+01
+ -1.12063E+02  -3.19485E+01
+ -1.12065E+02  -3.21144E+01
+ -1.12151E+02  -3.23426E+01
+ -1.12356E+02  -3.23278E+01
+ -1.12415E+02  -3.24889E+01
+ -1.12418E+02  -3.27938E+01
+ -1.12442E+02  -3.31120E+01
+ -1.12460E+02  -3.33989E+01
+ -1.12504E+02  -3.36498E+01
+ -1.12604E+02  -3.36626E+01
+ -1.12628E+02  -3.39988E+01
+ -1.12562E+02  -3.42996E+01
+ -1.12417E+02  -3.45562E+01
+ -1.12187E+02  -3.46742E+01
+ -1.11756E+02  -3.48114E+01
+ -1.11399E+02  -3.49123E+01
+ -1.11126E+02  -3.49948E+01
+ -1.10827E+02  -3.50908E+01
+> JZ-AN                      Larson et al. [1992]
+ -1.10827E+02  -3.50908E+01
+ -1.10527E+02  -3.50613E+01
+ -1.10326E+02  -3.49460E+01
+ -1.10141E+02  -3.48171E+01
+ -1.09919E+02  -3.47019E+01
+ -1.09691E+02  -3.46092E+01
+ -1.09259E+02  -3.45446E+01
+> JZ-NZ                      Larson et al. [1992]
+ -1.09259E+02  -3.45446E+01
+ -1.09277E+02  -3.42037E+01
+ -1.09270E+02  -3.39167E+01
+ -1.09205E+02  -3.37019E+01
+ -1.09323E+02  -3.33917E+01
+ -1.09410E+02  -3.31401E+01
+ -1.09183E+02  -3.30204E+01
+ -1.08972E+02  -3.29365E+01
+ -1.09206E+02  -3.26615E+01
+ -1.09435E+02  -3.24000E+01
+ -1.09791E+02  -3.21152E+01
+ -1.10210E+02  -3.19198E+01
+ -1.10687E+02  -3.17150E+01
+ -1.11202E+02  -3.15638E+01
+ -1.11660E+02  -3.15564E+01
+ -1.12023E+02  -3.15362E+01
+> NZ-PA                      Hey et al. [1995]
+ -1.12976E+02  -2.68302E+01
+ -1.13112E+02  -2.70143E+01
+ -1.13129E+02  -2.72727E+01
+ -1.13133E+02  -2.75770E+01
+ -1.13001E+02  -2.76074E+01
+ -1.12971E+02  -2.78495E+01
+ -1.12955E+02  -2.81290E+01
+ -1.12934E+02  -2.83794E+01
+ -1.13010E+02  -2.83829E+01
+ -1.13021E+02  -2.85495E+01
+ -1.13020E+02  -2.87872E+01
+ -1.12956E+02  -2.90088E+01
+ -1.12367E+02  -2.91602E+01
+ -1.11806E+02  -2.92656E+01
+ -1.11749E+02  -2.95788E+01
+ -1.11773E+02  -3.00247E+01
+ -1.11775E+02  -3.01873E+01
+ -1.11797E+02  -3.04248E+01
+ -1.11851E+02  -3.06244E+01
+ -1.11885E+02  -3.06658E+01
+ -1.11951E+02  -3.10446E+01
+ -1.11978E+02  -3.13862E+01
+ -1.11964E+02  -3.13905E+01
+ -1.12023E+02  -3.15362E+01
+> GP-PA                      Lonsdale [1988]
+ -1.02068E+02  +2.63532E+00
+ -1.02082E+02  +2.57438E+00
+ -1.02077E+02  +2.50246E+00
+ -1.02085E+02  +2.48615E+00
+ -1.02085E+02  +2.41199E+00
+ -1.02090E+02  +2.39090E+00
+ -1.02088E+02  +2.32729E+00
+ -1.02080E+02  +2.30830E+00
+ -1.02075E+02  +2.16104E+00
+ -1.02067E+02  +2.13734E+00
+ -1.02075E+02  +2.02449E+00
+ -1.02076E+02  +1.97154E+00
+ -1.02088E+02  +1.90349E+00
+ -1.02104E+02  +1.90382E+00
+ -1.02133E+02  +1.77843E+00
+ -1.02262E+02  +1.75155E+00
+ -1.02230E+02  +1.54137E+00
+ -1.02257E+02  +1.52778E+00
+ -1.02222E+02  +1.36110E+00
+ -1.02243E+02  +1.34857E+00
+ -1.02203E+02  +1.22065E+00
+ -1.02223E+02  +1.21398E+00
+ -1.02181E+02  +1.13426E+00
+> GP-NZ                      Lonsdale [1988]
+ -1.02181E+02  +1.13426E+00
+ -1.02082E+02  +1.20646E+00
+ -1.01959E+02  +1.26876E+00
+ -1.01825E+02  +1.33439E+00
+ -1.01644E+02  +1.40377E+00
+ -1.01580E+02  +1.31773E+00
+ -1.01487E+02  +1.38887E+00
+ -1.01423E+02  +1.33816E+00
+ -1.01348E+02  +1.39907E+00
+ -1.01315E+02  +1.35013E+00
+ -1.01195E+02  +1.42309E+00
+ -1.01153E+02  +1.38576E+00
+ -1.01047E+02  +1.47077E+00
+ -1.01074E+02  +1.51368E+00
+ -1.00964E+02  +1.65513E+00
+ -1.00973E+02  +1.67885E+00
+ -1.00908E+02  +1.74348E+00
+ -1.00974E+02  +1.83189E+00
+ -1.01049E+02  +1.90637E+00
+ -1.01149E+02  +1.98018E+00
+ -1.01270E+02  +2.04850E+00
+ -1.01356E+02  +2.10436E+00
+ -1.01438E+02  +2.16015E+00
+ -1.01512E+02  +2.23226E+00
+> GP-CO                      Lonsdale [1988]
+ -1.01512E+02  +2.23226E+00
+ -1.01490E+02  +2.60499E+00
+ -1.01697E+02  +2.63971E+00
+ -1.01878E+02  +2.64213E+00
+ -1.02068E+02  +2.63532E+00
+> PA-CO                      Lonsdale [1988]
+ -1.02068E+02  +2.63532E+00
+ -1.02109E+02  +2.78564E+00
+ -1.02096E+02  +2.79833E+00
+ -1.02118E+02  +2.89294E+00
+ -1.02145E+02  +2.88876E+00
+ -1.02193E+02  +3.07219E+00
+ -1.02219E+02  +3.23869E+00
+> NZ-PA                      Lonsdale [1988]
+ -1.02181E+02  +1.13426E+00
+ -1.02240E+02  +7.12821E-01
+ -1.02210E+02  +7.06338E-01
+ -1.02253E+02  +3.71700E-01
+ -1.02294E+02  +1.57068E-01
+ -1.02319E+02  -1.54770E-02
+> CO-NZ                      Lonsdale [1988]
+ -1.01512E+02  +2.23226E+00
+ -1.01203E+02  +2.24142E+00
+ -1.01196E+02  +2.19890E+00
+ -1.01067E+02  +2.21046E+00
+ -1.00644E+02  +2.20440E+00
+ -1.00394E+02  +2.20650E+00
+ -1.00066E+02  +2.20704E+00
+ -1.00047E+02  +2.29966E+00
+ -9.99129E+01  +2.27227E+00
+ -9.98108E+01  +2.27260E+00
+ -9.97389E+01  +2.26882E+00
+> SC-SA                      Peter Bird   June 2002
+ -2.94885E+01  -5.50334E+01
+ -3.09056E+01  -5.48217E+01
+ -3.23670E+01  -5.45854E+01
+ -3.37338E+01  -5.44603E+01
+ -3.33551E+01  -5.48600E+01
+ -3.30577E+01  -5.54580E+01
+ -3.36911E+01  -5.56050E+01
+ -3.45912E+01  -5.57295E+01
+ -3.61083E+01  -5.56416E+01
+ -3.68460E+01  -5.52149E+01
+ -3.78103E+01  -5.50862E+01
+ -3.87149E+01  -5.48532E+01
+ -3.97112E+01  -5.46334E+01
+ -4.06597E+01  -5.43972E+01
+ -4.15971E+01  -5.41536E+01
+ -4.24101E+01  -5.38797E+01
+ -4.32125E+01  -5.36003E+01
+ -4.42095E+01  -5.32697E+01
+ -4.51910E+01  -5.29309E+01
+ -4.64141E+01  -5.28301E+01
+ -4.76626E+01  -5.26907E+01
+ -4.91626E+01  -5.26640E+01
+ -5.06713E+01  -5.27100E+01
+ -5.21759E+01  -5.28726E+01
+ -5.33821E+01  -5.32094E+01
+ -5.47413E+01  -5.34060E+01
+ -5.55965E+01  -5.35304E+01
+ -5.64567E+01  -5.36486E+01
+ -5.77500E+01  -5.36260E+01
+ -5.92458E+01  -5.35981E+01
+ -6.05322E+01  -5.36735E+01
+ -6.19330E+01  -5.38100E+01
+ -6.28208E+01  -5.39171E+01
+ -6.37131E+01  -5.40177E+01
+ -6.47880E+01  -5.41726E+01
+ -6.58708E+01  -5.43178E+01
+ -6.74040E+01  -5.43941E+01
+ -6.89886E+01  -5.44297E+01
+ -6.98669E+01  -5.42309E+01
+ -7.05127E+01  -5.40994E+01
+ -7.12906E+01  -5.39225E+01
+ -7.20816E+01  -5.37183E+01
+ -7.30105E+01  -5.33135E+01
+ -7.40351E+01  -5.29111E+01
+ -7.49956E+01  -5.25564E+01
+ -7.57435E+01  -5.23147E+01
+ -7.64833E+01  -5.20684E+01
+> SW-SC                      Livermore et al. [1997]; Leat et al. [2000]
+ -2.94885E+01  -5.50334E+01
+ -2.97147E+01  -5.52043E+01
+ -2.98147E+01  -5.53268E+01
+ -2.97936E+01  -5.55009E+01
+ -2.97728E+01  -5.56048E+01
+ -2.98170E+01  -5.56835E+01
+ -3.03157E+01  -5.57539E+01
+ -3.03263E+01  -5.58635E+01
+ -3.03343E+01  -5.59491E+01
+ -3.03324E+01  -5.60517E+01
+ -3.03253E+01  -5.61345E+01
+ -3.03338E+01  -5.62904E+01
+ -3.03779E+01  -5.64434E+01
+ -3.07210E+01  -5.64492E+01
+ -3.07271E+01  -5.65110E+01
+ -3.07434E+01  -5.65699E+01
+ -3.07431E+01  -5.68593E+01
+ -3.04690E+01  -5.68510E+01
+ -3.03800E+01  -5.70937E+01
+ -3.01292E+01  -5.70954E+01
+ -3.00692E+01  -5.75995E+01
+ -2.98517E+01  -5.75979E+01
+ -2.98442E+01  -5.82619E+01
+ -3.00069E+01  -5.82719E+01
+ -2.99509E+01  -5.88052E+01
+ -2.95634E+01  -5.88167E+01
+ -2.95547E+01  -5.95138E+01
+ -3.01075E+01  -5.95150E+01
+ -3.00314E+01  -5.99370E+01
+ -2.98812E+01  -6.01736E+01
+ -2.95980E+01  -6.04347E+01
+ -2.86771E+01  -6.04587E+01
+ -2.77048E+01  -6.04673E+01
+ -2.76967E+01  -6.06171E+01
+> SW-AN                      Leat et al. [2000]
+ -2.76967E+01  -6.06171E+01
+ -2.68895E+01  -6.05060E+01
+ -2.60709E+01  -6.03910E+01
+> SC-AN                      Maldonado et al.   1998
+ -4.42259E+01  -6.02425E+01
+ -4.31509E+01  -6.03761E+01
+ -4.20674E+01  -6.05010E+01
+ -4.12136E+01  -6.09750E+01
+ -3.98270E+01  -6.06340E+01
+ -3.90930E+01  -6.10180E+01
+ -3.75605E+01  -6.12433E+01
+ -3.64181E+01  -6.13920E+01
+ -3.48252E+01  -6.09895E+01
+ -3.34464E+01  -6.07009E+01
+ -3.23670E+01  -6.04089E+01
+> SC-AN                      Leat et al. [2000]
+ -3.23670E+01  -6.04089E+01
+ -3.10139E+01  -6.05118E+01
+ -2.97382E+01  -6.05753E+01
+ -2.87433E+01  -6.06010E+01
+ -2.76967E+01  -6.06171E+01
+> SW/SA                      Peter Bird   June 2002
+ -2.60709E+01  -6.03910E+01
+ -2.50688E+01  -5.99733E+01
+ -2.44559E+01  -5.93858E+01
+ -2.39907E+01  -5.89209E+01
+ -2.38194E+01  -5.81950E+01
+ -2.41302E+01  -5.74253E+01
+ -2.42327E+01  -5.71736E+01
+ -2.46963E+01  -5.67336E+01
+ -2.51492E+01  -5.62920E+01
+ -2.57205E+01  -5.58396E+01
+ -2.64140E+01  -5.54244E+01
+ -2.69949E+01  -5.52319E+01
+ -2.76044E+01  -5.50948E+01
+ -2.86466E+01  -5.50049E+01
+ -2.94885E+01  -5.50334E+01
+> AR-IN                      by Peter Bird   October 2001
+ +6.02148E+01  +1.82397E+01
+ +6.04564E+01  +1.87983E+01
+ +6.07122E+01  +1.93057E+01
+ +6.09696E+01  +1.98127E+01
+ +6.12301E+01  +2.02303E+01
+ +6.14919E+01  +2.06443E+01
+ +6.18481E+01  +2.11258E+01
+ +6.20963E+01  +2.14249E+01
+ +6.21325E+01  +2.20828E+01
+ +6.25025E+01  +2.23850E+01
+ +6.28772E+01  +2.26830E+01
+ +6.36313E+01  +2.32008E+01
+ +6.42754E+01  +2.36936E+01
+ +6.46511E+01  +2.40383E+01
+ +6.50282E+01  +2.43824E+01
+> IN-AR                      Fournier et al. [2001]
+ +6.02148E+01  +1.82397E+01
+ +6.00619E+01  +1.74577E+01
+ +6.00202E+01  +1.67126E+01
+ +5.99642E+01  +1.61423E+01
+ +5.99086E+01  +1.55721E+01
+ +5.96423E+01  +1.52418E+01
+ +5.94096E+01  +1.48951E+01
+ +5.90337E+01  +1.50876E+01
+ +5.85892E+01  +1.46460E+01
+ +5.82131E+01  +1.49160E+01
+ +5.79836E+01  +1.45994E+01
+ +5.74762E+01  +1.46620E+01
+ +5.70015E+01  +1.46601E+01
+ +5.62652E+01  +1.46232E+01
+> SO-AR                      Peter Bird   June 2002
+ +5.62652E+01  +1.46232E+01
+ +5.62079E+01  +1.46433E+01
+ +5.61791E+01  +1.46213E+01
+ +5.60574E+01  +1.46411E+01
+ +5.58218E+01  +1.46923E+01
+ +5.56685E+01  +1.47216E+01
+ +5.56312E+01  +1.46814E+01
+ +5.54800E+01  +1.47292E+01
+ +5.52778E+01  +1.47885E+01
+ +5.51084E+01  +1.48505E+01
+ +5.50473E+01  +1.47116E+01
+ +5.49576E+01  +1.47272E+01
+ +5.47308E+01  +1.48010E+01
+ +5.45489E+01  +1.48698E+01
+ +5.45110E+01  +1.47601E+01
+ +5.44505E+01  +1.46210E+01
+ +5.43873E+01  +1.46399E+01
+ +5.43319E+01  +1.46707E+01
+ +5.42874E+01  +1.46814E+01
+ +5.42493E+01  +1.46914E+01
+ +5.41926E+01  +1.47096E+01
+ +5.41494E+01  +1.47328E+01
+ +5.40687E+01  +1.47722E+01
+ +5.40177E+01  +1.46573E+01
+ +5.39287E+01  +1.44894E+01
+ +5.38625E+01  +1.43509E+01
+ +5.38180E+01  +1.43615E+01
+ +5.35790E+01  +1.44408E+01
+ +5.33584E+01  +1.45118E+01
+ +5.32202E+01  +1.45623E+01
+ +5.32113E+01  +1.45379E+01
+ +5.31222E+01  +1.45586E+01
+ +5.29071E+01  +1.46221E+01
+ +5.27370E+01  +1.46813E+01
+ +5.26672E+01  +1.45615E+01
+ +5.25469E+01  +1.45972E+01
+ +5.22992E+01  +1.46625E+01
+ +5.21389E+01  +1.46887E+01
+ +5.19400E+01  +1.43530E+01
+ +5.17625E+01  +1.40283E+01
+ +5.15698E+01  +1.36673E+01
+ +5.14487E+01  +1.34576E+01
+ +5.13429E+01  +1.32718E+01
+ +5.12532E+01  +1.31223E+01
+ +5.10790E+01  +1.31923E+01
+ +5.08416E+01  +1.32794E+01
+ +5.06615E+01  +1.33618E+01
+ +5.05730E+01  +1.32181E+01
+ +5.04294E+01  +1.32725E+01
+ +5.03102E+01  +1.33125E+01
+ +5.02524E+01  +1.32290E+01
+ +5.01673E+01  +1.31225E+01
+ +5.00614E+01  +1.31675E+01
+ +4.98491E+01  +1.32512E+01
+ +4.96800E+01  +1.33128E+01
+ +4.95926E+01  +1.31686E+01
+ +4.94721E+01  +1.30078E+01
+ +4.94296E+01  +1.30419E+01
+ +4.93490E+01  +1.28973E+01
+ +4.92784E+01  +1.28019E+01
+ +4.90705E+01  +1.28528E+01
+ +4.88820E+01  +1.29084E+01
+ +4.88025E+01  +1.27698E+01
+ +4.86992E+01  +1.26576E+01
+ +4.85671E+01  +1.26906E+01
+ +4.84479E+01  +1.27289E+01
+ +4.83487E+01  +1.25726E+01
+ +4.82675E+01  +1.26023E+01
+ +4.81420E+01  +1.26407E+01
+ +4.80479E+01  +1.26710E+01
+ +4.79914E+01  +1.25807E+01
+ +4.79014E+01  +1.24611E+01
+ +4.77883E+01  +1.24923E+01
+ +4.76494E+01  +1.25185E+01
+ +4.75875E+01  +1.24409E+01
+ +4.75389E+01  +1.23687E+01
+ +4.73190E+01  +1.24301E+01
+ +4.71613E+01  +1.24630E+01
+ +4.71303E+01  +1.23587E+01
+ +4.70489E+01  +1.23877E+01
+ +4.69923E+01  +1.24030E+01
+ +4.69297E+01  +1.23002E+01
+ +4.68487E+01  +1.22108E+01
+ +4.67168E+01  +1.22482E+01
+ +4.65789E+01  +1.22921E+01
+ +4.65108E+01  +1.22019E+01
+ +4.64290E+01  +1.20875E+01
+ +4.63107E+01  +1.21425E+01
+ +4.61976E+01  +1.21724E+01
+ +4.61503E+01  +1.21123E+01
+ +4.61097E+01  +1.20581E+01
+ +4.58509E+01  +1.21002E+01
+ +4.56496E+01  +1.21519E+01
+ +4.56372E+01  +1.21586E+01
+ +4.56018E+01  +1.20730E+01
+ +4.55218E+01  +1.19829E+01
+ +4.54280E+01  +1.20176E+01
+ +4.53277E+01  +1.20525E+01
+ +4.52811E+01  +1.19983E+01
+ +4.50969E+01  +1.19989E+01
+ +4.49132E+01  +1.20116E+01
+ +4.48817E+01  +1.20189E+01
+ +4.47802E+01  +1.20224E+01
+ +4.45131E+01  +1.20126E+01
+ +4.40493E+01  +1.20080E+01
+ +4.36495E+01  +1.20127E+01
+ +4.28413E+01  +1.17950E+01
+ +4.20332E+01  +1.15772E+01
+> AF-AR                      Peter Bird   June 2002
+ +3.92978E+01  +1.90298E+01
+ +3.88261E+01  +1.94475E+01
+ +3.83957E+01  +1.99075E+01
+ +3.80745E+01  +2.03891E+01
+ +3.79747E+01  +2.10213E+01
+ +3.78253E+01  +2.18434E+01
+ +3.75398E+01  +2.24945E+01
+ +3.70425E+01  +2.32259E+01
+ +3.65711E+01  +2.36392E+01
+ +3.64073E+01  +2.41327E+01
+ +3.62422E+01  +2.46260E+01
+ +3.60661E+01  +2.50553E+01
+ +3.58888E+01  +2.54844E+01
+ +3.55456E+01  +2.59191E+01
+ +3.51999E+01  +2.63530E+01
+ +3.48748E+01  +2.68078E+01
+ +3.45470E+01  +2.72619E+01
+ +3.42569E+01  +2.78853E+01
+ +3.44280E+01  +2.84143E+01
+ +3.46009E+01  +2.89431E+01
+ +3.47755E+01  +2.94717E+01
+ +3.49519E+01  +3.00000E+01
+> AR-AF                      Brian Taylor   pers. comm.   2002
+ +3.92978E+01  +1.90298E+01
+ +3.95899E+01  +1.84193E+01
+ +3.99867E+01  +1.79494E+01
+ +4.03313E+01  +1.72662E+01
+ +4.02512E+01  +1.67851E+01
+ +4.01716E+01  +1.63040E+01
+ +3.96707E+01  +1.57716E+01
+ +3.97767E+01  +1.51377E+01
+ +4.00263E+01  +1.47192E+01
+ +4.02750E+01  +1.43005E+01
+ +4.06140E+01  +1.37417E+01
+ +4.00912E+01  +1.32094E+01
+ +4.05071E+01  +1.25998E+01
+ +4.08568E+01  +1.22055E+01
+ +4.12055E+01  +1.18107E+01
+ +4.16487E+01  +1.21890E+01
+ +4.20332E+01  +1.15772E+01
+> AS/AF                      Peter Bird   June 2002
+ +2.03001E+01  +3.78039E+01
+ +2.07603E+01  +3.70983E+01
+ +2.13266E+01  +3.66289E+01
+ +2.15988E+01  +3.62159E+01
+ +2.18932E+01  +3.59334E+01
+ +2.23752E+01  +3.57424E+01
+ +2.28662E+01  +3.54367E+01
+ +2.33986E+01  +3.49900E+01
+ +2.38739E+01  +3.46283E+01
+ +2.45928E+01  +3.43397E+01
+ +2.55767E+01  +3.42487E+01
+ +2.64653E+01  +3.41983E+01
+ +2.72265E+01  +3.43347E+01
+ +2.76845E+01  +3.47060E+01
+ +2.80502E+01  +3.48702E+01
+ +2.84780E+01  +3.51272E+01
+ +2.87789E+01  +3.53116E+01
+ +2.90702E+01  +3.53780E+01
+ +2.93451E+01  +3.54249E+01
+ +2.97309E+01  +3.54273E+01
+> AT/AF                      Peter Bird   June 2002
+ +2.97309E+01  +3.54273E+01
+ +3.02208E+01  +3.51543E+01
+ +3.07929E+01  +3.49908E+01
+ +3.12560E+01  +3.48260E+01
+ +3.17399E+01  +3.46341E+01
+ +3.21719E+01  +3.44871E+01
+ +3.26678E+01  +3.43899E+01
+ +3.31007E+01  +3.42903E+01
+ +3.37354E+01  +3.43017E+01
+ +3.40542E+01  +3.45045E+01
+ +3.44998E+01  +3.47855E+01
+ +3.49001E+01  +3.50910E+01
+ +3.53621E+01  +3.54051E+01
+ +3.57912E+01  +3.56890E+01
+ +3.64134E+01  +3.60232E+01
+> SO-AF                      by Peter Bird   September 2001
+ +4.20332E+01  +1.15772E+01
+ +4.14423E+01  +1.13169E+01
+ +4.11166E+01  +1.07317E+01
+ +4.07921E+01  +1.01462E+01
+ +4.04494E+01  +9.79646E+00
+ +4.01074E+01  +9.44636E+00
+ +3.97898E+01  +9.07119E+00
+ +3.94729E+01  +8.69575E+00
+ +3.91565E+01  +8.29567E+00
+ +3.88408E+01  +7.89535E+00
+ +3.84775E+01  +7.44705E+00
+ +3.81150E+01  +6.99845E+00
+ +3.78487E+01  +6.47715E+00
+ +3.75829E+01  +5.95572E+00
+ +3.69136E+01  +5.95844E+00
+ +3.66014E+01  +5.48365E+00
+ +3.62897E+01  +5.00869E+00
+ +3.57824E+01  +5.09868E+00
+ +3.52749E+01  +5.18828E+00
+ +3.47673E+01  +5.27747E+00
+ +3.42596E+01  +5.36626E+00
+ +3.37517E+01  +5.45463E+00
+ +3.32437E+01  +5.54257E+00
+ +3.27355E+01  +5.63007E+00
+ +3.22271E+01  +5.71714E+00
+ +3.17527E+01  +5.09727E+00
+ +3.12793E+01  +4.47706E+00
+ +3.04713E+01  +4.23531E+00
+ +3.04748E+01  +3.52370E+00
+ +3.04783E+01  +2.81209E+00
+ +3.10492E+01  +2.64788E+00
+ +3.16199E+01  +2.48341E+00
+ +3.11221E+01  +1.96007E+00
+ +3.06247E+01  +1.43658E+00
+ +3.02459E+01  +7.48524E-01
+ +2.98673E+01  +6.04436E-02
+ +2.96297E+01  -6.26325E-01
+ +2.93920E+01  -1.31308E+00
+ +2.91299E+01  -1.80931E+00
+ +2.88677E+01  -2.30551E+00
+ +2.89103E+01  -3.13391E+00
+ +2.89529E+01  -3.96229E+00
+ +2.92804E+01  -4.55689E+00
+ +2.96085E+01  -5.15135E+00
+ +2.96040E+01  -5.62513E+00
+ +2.95996E+01  -6.09891E+00
+ +3.00455E+01  -6.79117E+00
+ +3.04927E+01  -7.48303E+00
+ +3.10420E+01  -7.63081E+00
+ +3.15917E+01  -7.77790E+00
+ +3.21166E+01  -8.16220E+00
+ +3.26426E+01  -8.54581E+00
+ +3.30990E+01  -8.64346E+00
+ +3.35557E+01  -8.74056E+00
+ +3.38175E+01  -9.59798E+00
+ +3.40806E+01  -1.04552E+01
+ +3.47091E+01  -1.10274E+01
+ +3.44411E+01  -1.17170E+01
+ +3.41717E+01  -1.24064E+01
+ +3.40714E+01  -1.31674E+01
+ +3.44608E+01  -1.38586E+01
+ +3.48525E+01  -1.45491E+01
+ +3.47288E+01  -1.51914E+01
+ +3.46043E+01  -1.58337E+01
+ +3.49008E+01  -1.63337E+01
+ +3.51989E+01  -1.68333E+01
+ +3.51995E+01  -1.74044E+01
+ +3.52001E+01  -1.79755E+01
+ +3.45989E+01  -1.83559E+01
+ +3.42716E+01  -1.86879E+01
+ +3.39430E+01  -1.90194E+01
+ +3.36131E+01  -1.93503E+01
+ +3.32818E+01  -1.96806E+01
+ +3.31963E+01  -2.05122E+01
+ +3.31098E+01  -2.13438E+01
+ +3.26356E+01  -2.14920E+01
+ +3.21605E+01  -2.16388E+01
+ +3.16844E+01  -2.17842E+01
+ +3.12073E+01  -2.19283E+01
+ +3.07293E+01  -2.20710E+01
+ +3.02503E+01  -2.22124E+01
+ +2.97704E+01  -2.23523E+01
+ +2.92895E+01  -2.24908E+01
+ +2.88442E+01  -2.29711E+01
+ +2.83958E+01  -2.34501E+01
+ +2.79441E+01  -2.39278E+01
+ +2.74890E+01  -2.44042E+01
+ +2.75920E+01  -2.48474E+01
+ +2.76957E+01  -2.52905E+01
+ +2.78002E+01  -2.57335E+01
+ +2.79054E+01  -2.61765E+01
+ +2.72526E+01  -2.64737E+01
+ +2.65964E+01  -2.67680E+01
+ +2.65952E+01  -2.74774E+01
+ +2.65940E+01  -2.81868E+01
+ +2.71792E+01  -2.86245E+01
+ +2.77693E+01  -2.90596E+01
+ +2.80540E+01  -2.94544E+01
+ +2.83409E+01  -2.98486E+01
+> AF-SO                      Lemaux et al. [2002]
+ +3.21252E+01  -4.69975E+01
+ +3.26626E+01  -4.61911E+01
+ +3.31706E+01  -4.53818E+01
+ +3.36775E+01  -4.45607E+01
+ +3.41568E+01  -4.37467E+01
+ +3.46360E+01  -4.29307E+01
+ +3.50898E+01  -4.21032E+01
+> AF-SO                      Peter Bird   June 2002
+ +3.50898E+01  -4.21032E+01
+ +3.55280E+01  -4.12537E+01
+ +3.59550E+01  -4.04026E+01
+ +3.63713E+01  -3.95500E+01
+ +3.67774E+01  -3.86959E+01
+ +3.71740E+01  -3.78404E+01
+ +3.75615E+01  -3.69837E+01
+ +3.67208E+01  -3.64328E+01
+ +3.58920E+01  -3.58761E+01
+ +3.50748E+01  -3.53138E+01
+ +3.42689E+01  -3.47461E+01
+ +3.34741E+01  -3.41731E+01
+ +3.26901E+01  -3.35951E+01
+ +3.19165E+01  -3.30122E+01
+ +3.11532E+01  -3.24246E+01
+ +3.03997E+01  -3.18325E+01
+ +2.96559E+01  -3.12360E+01
+ +2.89215E+01  -3.06352E+01
+ +2.83409E+01  -2.98486E+01
+> PM-CA                      Mann and Kolarsky [1995]
+ -7.66840E+01  +8.73130E+00
+ -7.67653E+01  +9.06455E+00
+ -7.69243E+01  +9.37587E+00
+ -7.70829E+01  +9.63133E+00
+ -7.72914E+01  +9.89982E+00
+ -7.74993E+01  +1.00985E+01
+ -7.76786E+01  +1.02696E+01
+ -7.79217E+01  +1.04324E+01
+ -7.81287E+01  +1.05470E+01
+ -7.82289E+01  +1.06146E+01
+ -7.84272E+01  +1.06388E+01
+ -7.87455E+01  +1.06534E+01
+ -7.89698E+01  +1.05795E+01
+ -7.91511E+01  +1.04787E+01
+ -7.92344E+01  +1.04145E+01
+ -7.94321E+01  +1.04311E+01
+ -7.97482E+01  +1.03894E+01
+ -8.01053E+01  +1.03050E+01
+ -8.03646E+01  +1.02712E+01
+ -8.06357E+01  +1.01539E+01
+ -8.08790E+01  +1.00579E+01
+> PM-CA                      Kellogg and Vega [1995]
+ -8.08790E+01  +1.00579E+01
+ -8.10792E+01  +9.93537E+00
+ -8.13063E+01  +9.77762E+00
+ -8.14692E+01  +9.58708E+00
+ -8.16542E+01  +9.44432E+00
+ -8.20802E+01  +9.43984E+00
+ -8.23126E+01  +9.50913E+00
+ -8.25246E+01  +9.59940E+00
+ -8.28019E+01  +9.76995E+00
+ -8.30213E+01  +9.87311E+00
+ -8.32085E+01  +1.00526E+01
+ -8.34648E+01  +1.02088E+01
+ -8.37824E+01  +1.03213E+01
+ -8.40727E+01  +1.04479E+01
+ -8.44241E+01  +1.05374E+01
+ -8.47462E+01  +1.05933E+01
+ -8.51238E+01  +1.06534E+01
+ -8.54349E+01  +1.06269E+01
+ -8.57164E+01  +1.05674E+01
+ -8.59690E+01  +1.04886E+01
+ -8.62479E+01  +1.03882E+01
+ -8.66480E+01  +1.02350E+01
+> NZ-PM                      Westbrook et al. [1995]
+ -7.86463E+01  +7.33731E+00
+ -7.87511E+01  +7.32893E+00
+ -7.89818E+01  +7.31874E+00
+ -7.92402E+01  +7.30109E+00
+ -7.94697E+01  +7.22831E+00
+ -7.96576E+01  +7.18385E+00
+ -7.98456E+01  +7.16010E+00
+ -8.00958E+01  +7.10068E+00
+ -8.02498E+01  +7.13273E+00
+> NZ-PM                      Kolarsky and Mann [1995]
+ -8.02498E+01  +7.13273E+00
+ -8.03628E+01  +7.22073E+00
+ -8.05391E+01  +7.33519E+00
+ -8.06870E+01  +7.41545E+00
+ -8.07835E+01  +7.35838E+00
+ -8.08937E+01  +7.29417E+00
+ -8.10385E+01  +7.22241E+00
+ -8.11628E+01  +7.17174E+00
+ -8.13423E+01  +7.09933E+00
+ -8.14874E+01  +7.05516E+00
+ -8.15843E+01  +7.03949E+00
+ -8.17410E+01  +7.06054E+00
+> NZ-PM                      Moore and Sender [1995]
+ -8.17410E+01  +7.06054E+00
+ -8.18886E+01  +6.97836E+00
+ -8.19436E+01  +6.94971E+00
+ -8.20896E+01  +6.96742E+00
+ -8.21252E+01  +7.00801E+00
+ -8.22021E+01  +7.04084E+00
+ -8.22734E+01  +7.12881E+00
+ -8.23385E+01  +7.25127E+00
+ -8.24920E+01  +7.29605E+00
+ -8.26171E+01  +7.30701E+00
+ -8.26857E+01  +7.27797E+00
+ -8.27482E+01  +7.28342E+00
+ -8.28110E+01  +7.30260E+00
+ -8.28748E+01  +7.36639E+00
+> CO\PM                      Kellogg and Vega [1995]
+ -8.28748E+01  +7.36639E+00
+ -8.30742E+01  +7.59169E+00
+ -8.32331E+01  +7.84854E+00
+ -8.33599E+01  +7.92759E+00
+ -8.36054E+01  +8.04445E+00
+ -8.38377E+01  +8.18189E+00
+ -8.40072E+01  +8.30028E+00
+ -8.41577E+01  +8.47377E+00
+ -8.44187E+01  +8.63674E+00
+ -8.46858E+01  +8.77169E+00
+ -8.50438E+01  +8.93723E+00
+ -8.53805E+01  +9.08908E+00
+ -8.56124E+01  +9.20327E+00
+ -8.59105E+01  +9.42337E+00
+ -8.62036E+01  +9.68364E+00
+ -8.64487E+01  +9.93830E+00
+ -8.66480E+01  +1.02350E+01
+> ND/NZ                      Westbrook et al. [1995]
+ -7.86463E+01  +7.33731E+00
+ -7.87148E+01  +7.23227E+00
+ -7.87619E+01  +7.09977E+00
+ -7.87470E+01  +7.03058E+00
+ -7.86976E+01  +6.99653E+00
+ -7.85990E+01  +6.94229E+00
+ -7.85419E+01  +6.85277E+00
+ -7.84428E+01  +6.75680E+00
+ -7.83997E+01  +6.66011E+00
+ -7.83356E+01  +6.56364E+00
+ -7.82650E+01  +6.50195E+00
+ -7.81946E+01  +6.46107E+00
+ -7.81514E+01  +6.34345E+00
+ -7.81293E+01  +6.23949E+00
+ -7.80861E+01  +6.12184E+00
+ -7.80504E+01  +6.05273E+00
+ -7.80080E+01  +6.00453E+00
+> PM-ND                      Mann and Kolarsky [1995]
+ -7.86463E+01  +7.33731E+00
+ -7.82285E+01  +7.50952E+00
+ -7.80129E+01  +7.63734E+00
+ -7.77067E+01  +7.82883E+00
+ -7.75335E+01  +8.01173E+00
+ -7.73309E+01  +8.10457E+00
+ -7.71492E+01  +8.19017E+00
+ -7.69060E+01  +8.44344E+00
+ -7.66840E+01  +8.73130E+00
+> CA\ND                      Taboada et al. [1997]
+ -7.66840E+01  +8.73130E+00
+ -7.67013E+01  +9.01654E+00
+ -7.67056E+01  +9.37852E+00
+ -7.67033E+01  +9.76145E+00
+ -7.65944E+01  +1.00900E+01
+ -7.64559E+01  +1.03285E+01
+ -7.62748E+01  +1.05744E+01
+ -7.60645E+01  +1.07650E+01
+ -7.59050E+01  +1.10873E+01
+ -7.56313E+01  +1.13900E+01
+ -7.53703E+01  +1.15948E+01
+ -7.51228E+01  +1.17645E+01
+ -7.47964E+01  +1.19138E+01
+ -7.44764E+01  +1.20208E+01
+ -7.43066E+01  +1.22243E+01
+ -7.40577E+01  +1.23863E+01
+ -7.38738E+01  +1.27431E+01
+ -7.36320E+01  +1.30583E+01
+ -7.33032E+01  +1.32898E+01
+ -7.29161E+01  +1.33675E+01
+ -7.24282E+01  +1.34097E+01
+ -7.18397E+01  +1.34647E+01
+ -7.11949E+01  +1.35029E+01
+ -7.09525E+01  +1.34376E+01
+ -7.06594E+01  +1.33101E+01
+> CA\ND                      Perez et al. [1997]
+ -7.06594E+01  +1.33101E+01
+ -7.04957E+01  +1.31623E+01
+ -7.01827E+01  +1.29296E+01
+ -6.98634E+01  +1.26685E+01
+ -6.95944E+01  +1.24496E+01
+ -6.93478E+01  +1.21751E+01
+ -6.90241E+01  +1.18437E+01
+ -6.87297E+01  +1.15126E+01
+ -6.83792E+01  +1.11736E+01
+ -6.80865E+01  +1.08145E+01
+ -6.79613E+01  +1.04995E+01
+> ND-SA                      Collot et al. [2002]
+ -8.15989E+01  -3.24451E+00
+ -8.13022E+01  -3.26785E+00
+ -8.09772E+01  -3.26376E+00
+ -8.05745E+01  -3.07358E+00
+ -8.02061E+01  -2.88264E+00
+ -7.98028E+01  -2.64299E+00
+ -7.94968E+01  -2.47156E+00
+ -7.92253E+01  -2.27888E+00
+ -7.89289E+01  -1.99438E+00
+ -7.86670E+01  -1.42089E+00
+ -7.84366E+01  -7.48094E-01
+ -7.81931E+01  -2.34463E-01
+ -7.80055E+01  +1.47576E-01
+> ND-SA                      Audemard and Audemard [2002]
+ -7.80055E+01  +1.47576E-01
+ -7.77070E+01  +5.85555E-01
+ -7.73318E+01  +8.98863E-01
+ -7.69216E+01  +1.10119E+00
+ -7.65737E+01  +1.27575E+00
+ -7.62537E+01  +1.50607E+00
+ -7.59891E+01  +1.61798E+00
+ -7.57736E+01  +1.93192E+00
+ -7.54325E+01  +2.28107E+00
+ -7.52097E+01  +2.49764E+00
+ -7.48753E+01  +2.79118E+00
+ -7.45894E+01  +3.02190E+00
+ -7.43454E+01  +3.29442E+00
+ -7.41010E+01  +3.42043E+00
+ -7.39265E+01  +3.56025E+00
+ -7.38150E+01  +3.81860E+00
+ -7.37803E+01  +3.97914E+00
+ -7.35917E+01  +4.16783E+00
+ -7.33259E+01  +4.30774E+00
+ -7.31300E+01  +4.41261E+00
+ -7.29202E+01  +4.74080E+00
+ -7.27732E+01  +4.93630E+00
+ -7.26331E+01  +5.11782E+00
+ -7.23528E+01  +5.26439E+00
+ -7.21985E+01  +5.53653E+00
+ -7.21492E+01  +5.78778E+00
+ -7.20789E+01  +6.04598E+00
+ -7.19242E+01  +6.26219E+00
+ -7.19029E+01  +6.46457E+00
+ -7.18886E+01  +6.68091E+00
+ -7.20499E+01  +7.03006E+00
+ -7.20709E+01  +7.19760E+00
+ -7.20637E+01  +7.32322E+00
+ -7.23592E+01  +7.56770E+00
+ -7.24366E+01  +7.70032E+00
+ -7.22464E+01  +7.81891E+00
+ -7.20913E+01  +7.90255E+00
+ -7.19148E+01  +8.10474E+00
+ -7.17948E+01  +8.19528E+00
+ -7.16958E+01  +8.34166E+00
+ -7.14557E+01  +8.45276E+00
+ -7.12084E+01  +8.57065E+00
+ -7.10810E+01  +8.66092E+00
+ -7.09251E+01  +8.80684E+00
+ -7.07271E+01  +8.87572E+00
+ -7.05145E+01  +9.01417E+00
+ -7.03584E+01  +9.13886E+00
+ -7.00812E+01  +9.38819E+00
+ -6.98747E+01  +9.58196E+00
+ -6.96962E+01  +9.79669E+00
+ -6.95106E+01  +9.97637E+00
+ -6.92969E+01  +1.01208E+01
+ -6.91403E+01  +1.01959E+01
+ -6.89764E+01  +1.02986E+01
+ -6.86700E+01  +1.04554E+01
+ -6.85065E+01  +1.05021E+01
+ -6.83502E+01  +1.05350E+01
+ -6.81311E+01  +1.05111E+01
+ -6.79613E+01  +1.04995E+01
+> CA-SA                      Taboada et al. [1997]
+ -6.79613E+01  +1.04995E+01
+ -6.74989E+01  +1.05924E+01
+ -6.68695E+01  +1.06666E+01
+ -6.64366E+01  +1.06624E+01
+ -6.59643E+01  +1.06528E+01
+ -6.55257E+01  +1.06153E+01
+ -6.51209E+01  +1.05999E+01
+ -6.49970E+01  +1.05392E+01
+ -6.45077E+01  +1.04740E+01
+ -6.42099E+01  +1.05194E+01
+ -6.38782E+01  +1.05316E+01
+> 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/jennings.xy
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/jennings.xy	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/jennings.xy	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,5013 @@
+>
+-115.5497 32.9312
+-115.5418 32.9142
+-115.5358 32.9028
+-115.5277 32.8890
+-115.5162 32.8702
+-115.5033 32.8535
+-115.4880 32.8372
+-115.4757 32.8213
+-115.4647 32.8068
+-115.4520 32.7905
+-115.4368 32.7762
+-115.4235 32.7598
+-115.4082 32.7432
+-115.3963 32.7302
+-115.3798 32.7143
+-115.3710 32.7030
+-115.3607 32.6887
+-115.3508 32.6765
+-115.3430 32.6670
+>
+-115.9218 32.9917
+-115.9097 32.9848
+-115.8937 32.9745
+-115.8728 32.9655
+-115.8398 32.9498
+-115.8217 32.9410
+-115.7983 32.9295
+-115.7797 32.9228
+-115.7628 32.9182
+-115.7512 32.9132
+-115.7382 32.9062
+-115.7268 32.9002
+-115.7127 32.8947
+-115.7003 32.8878
+>
+-115.8392 33.0127
+-115.8205 33.0068
+-115.8017 33.0015
+-115.7892 32.9973
+-115.7755 32.9913
+-115.7637 32.9850
+-115.7512 32.9757
+-115.7382 32.9647
+-115.7258 32.9532
+-115.7148 32.9427
+-115.7033 32.9318
+-115.6918 32.9238
+-115.6808 32.9162
+-115.6717 32.9097
+-115.6633 32.9045
+-115.6545 32.9012
+-115.6427 32.8927
+>
+-117.3472 33.0552
+-117.3402 33.0418
+-117.3342 33.0290
+-117.3243 33.0112
+-117.3177 32.9977
+-117.3128 32.9837
+-117.3083 32.9702
+-117.3038 32.9572
+-117.2980 32.9447
+-117.2925 32.9317
+-117.2882 32.9213
+-117.2815 32.9072
+-117.2745 32.8908
+-117.2687 32.8758
+-117.2627 32.8617
+-117.2542 32.8492
+-117.2458 32.8388
+-117.2333 32.8270
+-117.2233 32.8150
+-117.2153 32.8037
+-117.2048 32.7897
+-117.1978 32.7783
+-117.1918 32.7640
+-117.1883 32.7530
+-117.1835 32.7413
+-117.1772 32.7268
+-117.1687 32.7127
+-117.1610 32.7002
+-117.1505 32.6857
+-117.1398 32.6692
+-117.1317 32.6557
+-117.1237 32.6408
+-117.1193 32.6292
+>
+-118.7102 33.1937
+-118.6978 33.1828
+-118.6843 33.1702
+-118.6613 33.1512
+-118.6422 33.1357
+-118.6252 33.1250
+-118.6037 33.1017
+-118.5828 33.0847
+-118.5670 33.0722
+-118.5523 33.0602
+-118.5353 33.0433
+-118.5233 33.0305
+-118.5097 33.0143
+-118.4958 32.9982
+-118.4803 32.9803
+-118.4688 32.9657
+-118.4537 32.9503
+-118.4357 32.9300
+-118.4227 32.9193
+-118.4042 32.9063
+-118.3897 32.8923
+-118.3763 32.8823
+-118.3558 32.8633
+-118.3415 32.8472
+-118.3243 32.8282
+-118.3115 32.8143
+-118.2980 32.8005
+-118.2832 32.7857
+-118.2677 32.7747
+-118.2520 32.7612
+-118.2377 32.7482
+-118.2172 32.7338
+-118.2068 32.7263
+-118.1953 32.7160
+-118.1827 32.7027
+-118.1658 32.6877
+-118.1512 32.6738
+-118.1365 32.6622
+-118.1202 32.6515
+-118.1022 32.6403
+-118.0808 32.6268
+-118.0620 32.6155
+-118.0428 32.6043
+-118.0268 32.5932
+-118.0107 32.5823
+-117.9893 32.5687
+-117.9663 32.5545
+-117.9492 32.5435
+-117.9273 32.5315
+-117.9023 32.5177
+-117.8782 32.5027
+-117.8552 32.4857
+-117.8405 32.4743
+-117.8258 32.4612
+-117.8153 32.4568
+>
+-118.4718 33.8922
+-118.4640 33.8787
+-118.4550 33.8657
+-118.4433 33.8545
+-118.4295 33.8438
+-118.4162 33.8312
+-118.3983 33.8175
+-118.3823 33.8068
+-118.3673 33.7978
+-118.3513 33.7897
+-118.3317 33.7783
+-118.3135 33.7678
+-118.2965 33.7572
+-118.2778 33.7475
+-118.2590 33.7348
+-118.2435 33.7207
+-118.2305 33.7077
+-118.2175 33.6948
+-118.2020 33.6810
+-118.1880 33.6663
+-118.1742 33.6513
+-118.1610 33.6325
+-118.1503 33.6157
+-118.1397 33.5983
+-118.1312 33.5830
+-118.1160 33.5625
+-118.1052 33.5432
+-118.0942 33.5262
+-118.0795 33.5067
+-118.0680 33.4870
+-118.0608 33.4742
+-118.0502 33.4550
+-118.0387 33.4337
+-118.0295 33.4167
+-118.0203 33.3997
+-118.0127 33.3835
+-118.0045 33.3707
+-117.9950 33.3602
+>
+-116.2448 33.9047
+-116.2293 33.9037
+-116.2192 33.9037
+-116.2067 33.9040
+-116.1895 33.9028
+-116.1722 33.9002
+-116.1542 33.8978
+-116.1392 33.8973
+-116.1140 33.9007
+-116.0957 33.9017
+-116.0728 33.9027
+-116.0595 33.9063
+-116.0482 33.9083
+-116.0337 33.9128
+-116.0117 33.9138
+-115.9958 33.9110
+-115.9792 33.9085
+-115.9603 33.9087
+-115.9333 33.9088
+>
+-117.6987 33.9677
+-117.6882 33.9550
+-117.6772 33.9423
+-117.6628 33.9287
+-117.6470 33.9112
+-117.6323 33.8968
+-117.6192 33.8837
+-117.6093 33.8733
+-117.5957 33.8608
+-117.5823 33.8488
+-117.5697 33.8365
+-117.5550 33.8228
+-117.5398 33.8102
+-117.5257 33.7965
+-117.5148 33.7872
+-117.5037 33.7772
+-117.4928 33.7663
+-117.4797 33.7547
+-117.4637 33.7425
+-117.4512 33.7330
+-117.4362 33.7227
+-117.4212 33.7148
+-117.4070 33.7087
+-117.3927 33.7013
+-117.3835 33.6888
+-117.3807 33.6757
+-117.3763 33.6627
+-117.3622 33.6507
+-117.3423 33.6398
+-117.3228 33.6292
+-117.2987 33.6128
+-117.2787 33.5977
+-117.2638 33.5905
+-117.2447 33.5798
+-117.2277 33.5677
+-117.2143 33.5540
+-117.1992 33.5408
+-117.1815 33.5232
+-117.1628 33.5072
+-117.1397 33.4877
+-117.1213 33.4703
+-117.1040 33.4542
+-117.0893 33.4418
+-117.0677 33.4230
+-117.0503 33.4083
+-117.0348 33.3952
+-117.0115 33.3758
+-116.9887 33.3542
+-116.9713 33.3408
+-116.9535 33.3288
+-116.9280 33.3142
+-116.9012 33.3002
+-116.8687 33.2828
+-116.8437 33.2698
+-116.8207 33.2598
+-116.7983 33.2500
+-116.7848 33.2438
+-116.7692 33.2338
+-116.7552 33.2253
+-116.7370 33.2102
+-116.7165 33.1947
+-116.6885 33.1742
+-116.6712 33.1608
+-116.6550 33.1497
+-116.6373 33.1378
+-116.6172 33.1233
+-116.5813 33.0947
+-116.5608 33.0798
+-116.5442 33.0682
+-116.5242 33.0542
+-116.5072 33.0403
+-116.4947 33.0297
+-116.4787 33.0192
+-116.4648 33.0113
+-116.4495 32.9993
+-116.4318 32.9857
+-116.4103 32.9767
+-116.3872 32.9698
+-116.3663 32.9668
+-116.3428 32.9653
+-116.3203 32.9647
+-116.3007 32.9590
+-116.2728 32.9437
+-116.2577 32.9303
+-116.2428 32.9062
+-116.2305 32.8957
+-116.2208 32.8845
+-116.2088 32.8722
+-116.1973 32.8603
+-116.1888 32.8507
+-116.1747 32.8388
+-116.1603 32.8315
+-116.1432 32.8268
+-116.1245 32.8223
+-116.1065 32.8195
+-116.0868 32.8142
+-116.0677 32.8057
+-116.0503 32.7968
+-116.0387 32.7907
+-116.0255 32.7857
+-116.0083 32.7812
+>
+-115.8937 32.6708
+-115.8862 32.6585
+-115.8693 32.6443
+-115.8577 32.6328
+>
+-118.0178 33.9870
+-118.0048 33.9803
+-117.9858 33.9712
+-117.9627 33.9622
+-117.9313 33.9515
+-117.9043 33.9452
+-117.8790 33.9375
+-117.8505 33.9282
+-117.8203 33.9175
+-117.7922 33.9073
+-117.7665 33.8978
+-117.7412 33.8860
+-117.7173 33.8750
+-117.6987 33.8707
+-117.6772 33.8643
+-117.6560 33.8603
+-117.6357 33.8528
+-117.6217 33.8460
+-117.6022 33.8368
+-117.5895 33.8303
+-117.5767 33.8233
+-117.5612 33.8125
+-117.5478 33.8058
+-117.5305 33.7977
+-117.5105 33.7882
+>
+-116.6028 34.0177
+-116.5848 34.0268
+-116.5708 34.0377
+-116.5542 34.0513
+-116.5347 34.0628
+-116.5140 34.0770
+-116.4948 34.0877
+-116.4715 34.0998
+-116.4520 34.1083
+-116.4322 34.1145
+-116.4167 34.1197
+-116.3872 34.1347
+-116.3762 34.1382
+-116.3543 34.1420
+-116.3278 34.1445
+-116.3033 34.1478
+-116.2782 34.1462
+-116.2512 34.1437
+-116.2288 34.1425
+-116.1910 34.1435
+-116.1563 34.1393
+-116.1162 34.1332
+-116.0845 34.1288
+-116.0530 34.1237
+-116.0210 34.1202
+-115.9993 34.1170
+-115.9752 34.1137
+-115.9478 34.1127
+-115.9260 34.1108
+-115.8988 34.1078
+-115.8753 34.1038
+-115.8488 34.0990
+>
+-118.3748 34.0208
+-118.3692 34.0000
+-118.3598 33.9895
+-118.3537 33.9767
+-118.3432 33.9632
+-118.3327 33.9513
+-118.3198 33.9373
+-118.3057 33.9227
+-118.2955 33.9092
+-118.2837 33.8978
+-118.2713 33.8863
+-118.2557 33.8712
+-118.2382 33.8587
+-118.2213 33.8453
+-118.2073 33.8315
+-118.1912 33.8158
+-118.1763 33.8028
+-118.1608 33.7887
+-118.1402 33.7722
+-118.1203 33.7500
+-118.1042 33.7470
+-118.0863 33.7362
+-118.0732 33.7260
+-118.0573 33.7137
+-118.0428 33.7017
+-118.0248 33.6858
+-118.0060 33.6687
+-117.9918 33.6572
+-117.9758 33.6453
+-117.9598 33.6355
+-117.9437 33.6265
+-117.9303 33.6207
+>
+-118.5037 34.0268
+-118.4873 34.0285
+-118.4698 34.0345
+-118.4523 34.0418
+-118.4348 34.0508
+-118.4172 34.0573
+-118.4043 34.0635
+-118.3912 34.0702
+-118.3780 34.0757
+-118.3597 34.0828
+-118.3383 34.0887
+-118.3225 34.0938
+-118.3100 34.0953
+-118.2963 34.0992
+-118.2817 34.1033
+-118.2713 34.1030
+-118.2592 34.1060
+-118.2502 34.1082
+-118.2392 34.1098
+-118.2235 34.1113
+-118.2095 34.1115
+-118.1968 34.1103
+-118.1872 34.1098
+-118.1747 34.1092
+-118.1632 34.1088
+-118.1498 34.1093
+-118.1390 34.1073
+>
+-117.2488 34.0307
+-117.2277 34.0232
+-117.2063 34.0190
+-117.1893 34.0183
+-117.1693 34.0000
+-117.1540 34.0000
+-117.1320 34.0000
+-117.1205 33.9997
+-117.0857 33.9883
+-117.0452 33.9838
+-117.0298 33.9808
+-117.0135 33.9762
+-116.9983 33.9718
+-116.9800 33.9678
+-116.9563 33.9638
+-116.9332 33.9575
+-116.9068 33.9512
+-116.8828 33.9485
+-116.8648 33.9483
+-116.8370 33.9468
+-116.8168 33.9450
+-116.7995 33.9440
+-116.7798 33.9433
+-116.7673 33.9442
+-116.7448 33.9437
+-116.7245 33.9422
+-116.6918 33.9392
+-116.6762 33.9388
+-116.6552 33.9388
+-116.6347 33.9362
+-116.6160 33.9325
+-116.5968 33.9285
+-116.5735 33.9225
+-116.5553 33.9175
+-116.5363 33.9103
+-116.5193 33.9052
+-116.4972 33.8963
+-116.4732 33.8883
+-116.4473 33.8792
+-116.4182 33.8697
+-116.3900 33.8593
+-116.3637 33.8477
+-116.3457 33.8397
+-116.3298 33.8317
+-116.3122 33.8213
+-116.2897 33.8092
+-116.2617 33.7927
+>
+-118.9218 34.0373
+-118.9088 34.0363
+-118.8912 34.0362
+-118.8722 34.0362
+-118.8522 34.0362
+-118.8350 34.0373
+-118.8223 34.0383
+-118.8062 34.0340
+-118.7878 34.0285
+-118.7662 34.0272
+-118.7452 34.0280
+-118.7243 34.0268
+-118.7082 34.0268
+-118.6947 34.0280
+-118.6683 34.0268
+-118.6577 34.0253
+-118.6473 34.0237
+-118.6258 34.0220
+-118.6100 34.0207
+-118.5968 34.0200
+-118.5805 34.0197
+-118.5633 34.0208
+-118.5513 34.0218
+-118.5398 34.0223
+-118.5292 34.0227
+-118.5172 34.0238
+>
+-120.0555 34.0937
+-120.0428 34.0888
+-120.0000 34.0938
+>
+-119.9867 34.0507
+-119.9728 34.0473
+-119.9563 34.0438
+-119.9347 34.0368
+-119.9103 34.0287
+-119.9003 34.0268
+-119.8863 34.0255
+-119.8702 34.0228
+-119.8508 34.0190
+-119.8302 34.0157
+-119.8100 34.0103
+-119.7892 34.0068
+-119.7683 34.0032
+-119.7497 33.9992
+-119.7282 33.9953
+-119.7042 33.9903
+-119.6803 33.9843
+-119.6590 33.9815
+-119.6363 33.9772
+-119.6123 33.9718
+-119.5908 33.9703
+-119.5688 33.9698
+-119.5478 33.9708
+-119.5248 33.9720
+-119.5047 33.9727
+-119.4883 33.9732
+-119.4707 33.9735
+-119.4493 33.9757
+-119.4303 33.9770
+-119.4162 33.9773
+>
+-118.1257 34.1067
+-118.1157 34.1068
+-118.1047 34.1097
+-118.0933 34.1127
+-118.0805 34.1152
+-118.0692 34.1193
+-118.0585 34.1242
+-118.0453 34.1303
+-118.0298 34.1362
+-118.0162 34.1408
+-118.0043 34.1448
+-117.9958 34.1483
+-117.9848 34.1548
+>
+-119.2538 34.2237
+-119.2402 34.2283
+-119.2277 34.2318
+-119.2117 34.2373
+-119.1963 34.2420
+-119.1802 34.2478
+-119.1623 34.2588
+-119.1462 34.2702
+-119.1347 34.2797
+-119.1222 34.2888
+-119.1088 34.2988
+-119.0975 34.3087
+-119.0863 34.3158
+-119.0765 34.3213
+-119.0673 34.3280
+-119.0592 34.3348
+-119.0497 34.3400
+-119.0350 34.3452
+-119.0198 34.3473
+-119.0048 34.3470
+-118.9893 34.3442
+-118.9730 34.3432
+-118.9572 34.3462
+-118.9412 34.3507
+-118.9253 34.3592
+-118.9117 34.3647
+-118.9007 34.3667
+-118.8898 34.3672
+-118.8788 34.3672
+-118.8670 34.3672
+-118.8535 34.3672
+>
+-118.4693 34.2820
+-118.4498 34.2853
+-118.4342 34.2853
+-118.4192 34.2865
+-118.4043 34.2863
+-118.3858 34.2860
+-118.3658 34.2813
+-118.3452 34.2758
+-118.3268 34.2728
+-118.3090 34.2690
+-118.2968 34.2618
+-118.2847 34.2500
+-118.2713 34.2473
+-118.2558 34.2367
+-118.2403 34.2263
+-118.2260 34.2178
+-118.2123 34.2120
+-118.1945 34.2053
+-118.1748 34.1992
+-118.1632 34.1963
+-118.1472 34.1923
+-118.1353 34.1890
+-118.1250 34.1853
+-118.1105 34.1805
+-118.0967 34.1745
+-118.0877 34.1718
+-118.0698 34.1652
+-118.0590 34.1615
+-118.0468 34.1587
+-118.0298 34.1558
+-118.0157 34.1533
+-118.0018 34.1488
+-117.9857 34.1463
+-117.9687 34.1455
+-117.9523 34.1420
+-117.9373 34.1402
+-117.9212 34.1392
+-117.9073 34.1378
+-117.8900 34.1373
+-117.8772 34.1377
+-117.8573 34.1372
+-117.8428 34.1377
+-117.8310 34.1390
+-117.8107 34.1345
+-117.8017 34.1305
+-117.7867 34.1257
+-117.7742 34.1213
+-117.7598 34.1178
+-117.7427 34.1137
+-117.7252 34.1120
+-117.6962 34.1160
+-117.6863 34.1193
+-117.6792 34.1243
+-117.6708 34.1312
+-117.6623 34.1363
+-117.6533 34.1427
+-117.6392 34.1487
+-117.6263 34.1498
+-117.6150 34.1530
+-117.5980 34.1550
+-117.5798 34.1573
+-117.5592 34.1583
+-117.5393 34.1608
+-117.5188 34.1618
+-117.4998 34.1642
+-117.4813 34.1673
+-117.4650 34.1700
+-117.4505 34.1730
+-117.4370 34.1748
+-117.4280 34.1767
+-117.4172 34.1782
+-117.4083 34.1797
+>
+-117.6218 34.3103
+-117.6085 34.2987
+-117.5907 34.2908
+-117.5648 34.2797
+-117.5417 34.2500
+-117.5272 34.2500
+-117.5057 34.2457
+-117.4802 34.2325
+-117.4538 34.2125
+-117.4402 34.2065
+-117.4258 34.1972
+-117.4130 34.1877
+-117.3928 34.1708
+-117.3732 34.1510
+-117.3642 34.1393
+-117.3523 34.1282
+-117.3397 34.1155
+-117.3232 34.0997
+-117.3053 34.0827
+-117.2897 34.0668
+-117.2722 34.0515
+-117.2587 34.0397
+-117.2483 34.0293
+-117.2348 34.0163
+-117.2177 34.0000
+-117.2028 33.9922
+-117.1853 33.9778
+-117.1705 33.9650
+-117.1567 33.9540
+-117.1452 33.9440
+-117.1318 33.9337
+-117.1230 33.9240
+-117.1170 33.9152
+-117.1077 33.9020
+-117.0983 33.8917
+-117.0885 33.8813
+-117.0793 33.8702
+-117.0633 33.8527
+-117.0478 33.8398
+-117.0345 33.8273
+-117.0170 33.8118
+-117.0045 33.8008
+-116.9867 33.7858
+-116.9620 33.7717
+-116.9425 33.7580
+-116.9172 33.7415
+-116.8973 33.7273
+-116.8738 33.7133
+-116.8492 33.7007
+-116.8242 33.6868
+-116.7978 33.6697
+-116.7773 33.6568
+-116.7547 33.6425
+-116.7148 33.6182
+-116.6847 33.5948
+-116.6692 33.5862
+-116.6562 33.5775
+-116.6468 33.5717
+-116.6318 33.5653
+-116.6053 33.5538
+-116.5897 33.5428
+-116.5703 33.5263
+-116.5498 33.5112
+-116.5337 33.5003
+-116.5112 33.4848
+-116.4888 33.4753
+-116.4667 33.4643
+-116.4427 33.4457
+-116.4182 33.4333
+-116.3923 33.4207
+-116.3698 33.4107
+-116.3383 33.3942
+-116.3133 33.3810
+-116.2995 33.3717
+-116.2878 33.3618
+-116.2673 33.3498
+-116.2465 33.3415
+-116.2282 33.3313
+-116.2087 33.3205
+-116.1910 33.3103
+-116.1762 33.2997
+-116.1537 33.2873
+-116.1413 33.2790
+-116.1252 33.2657
+>
+-117.1053 33.9108
+-117.0923 33.8985
+-117.0780 33.8867
+-117.0622 33.8748
+-117.0407 33.8615
+-117.0233 33.8493
+-117.0087 33.8397
+-116.9918 33.8273
+-116.9788 33.8188
+-116.9622 33.8093
+-116.9508 33.8027
+-116.9372 33.7968
+-116.9245 33.7942
+-116.9080 33.7923
+-116.8932 33.7923
+-116.8808 33.7930
+-116.8705 33.7920
+-116.8562 33.7842
+-116.8407 33.7727
+-116.8233 33.7588
+-116.8098 33.7472
+-116.7913 33.7302
+-116.7793 33.7232
+-116.7693 33.7173
+-116.7562 33.7113
+-116.7408 33.7033
+-116.7265 33.6957
+-116.7093 33.6857
+-116.6962 33.6798
+-116.6767 33.6703
+>
+-116.5182 33.4837
+-116.5142 33.4697
+-116.5098 33.4588
+-116.5008 33.4465
+-116.4903 33.4362
+-116.4772 33.4250
+-116.4623 33.4155
+-116.4490 33.4070
+-116.4365 33.3972
+-116.4237 33.3870
+-116.4108 33.3772
+-116.3973 33.3687
+-116.3838 33.3573
+-116.3723 33.3497
+-116.3597 33.3395
+-116.3472 33.3302
+-116.3342 33.3192
+-116.3182 33.3032
+-116.3018 33.2882
+-116.2878 33.2757
+-116.2720 33.2613
+-116.2585 33.2485
+-116.2447 33.2385
+-116.2307 33.2253
+-116.2185 33.2143
+-116.2058 33.2052
+-116.1833 33.1967
+-116.1682 33.1902
+-116.1580 33.1812
+-116.1472 33.1707
+-116.1377 33.1620
+-116.1275 33.1515
+-116.1188 33.1432
+-116.1043 33.1332
+-116.0903 33.1248
+-116.0750 33.1145
+-116.0613 33.1017
+-116.0477 33.0892
+-116.0347 33.0742
+-116.0213 33.0587
+-116.0087 33.0418
+-115.9950 33.0282
+-115.9837 33.0177
+-115.9752 33.0117
+>
+-116.6385 33.5718
+-116.6232 33.5677
+-116.6078 33.5607
+-116.5925 33.5547
+-116.5763 33.5457
+-116.5588 33.5363
+-116.5413 33.5280
+-116.5272 33.5230
+-116.5098 33.5137
+-116.4917 33.5058
+-116.4742 33.5017
+-116.4582 33.4982
+-116.4427 33.4928
+-116.4272 33.4858
+-116.4118 33.4778
+-116.3952 33.4688
+-116.3742 33.4573
+-116.3562 33.4483
+-116.3393 33.4413
+-116.3262 33.4375
+-116.3077 33.4293
+-116.2942 33.4267
+-116.2783 33.4225
+>
+-118.7500 34.3470
+-118.7400 34.3428
+-118.7288 34.3390
+-118.7130 34.3377
+-118.6988 34.3358
+-118.6828 34.3328
+-118.6670 34.3298
+-118.6507 34.3252
+-118.6373 34.3223
+-118.6242 34.3177
+-118.6107 34.3132
+-118.5957 34.3062
+-118.5808 34.3007
+-118.5667 34.2962
+-118.5518 34.2917
+-118.5378 34.2893
+-118.5277 34.2902
+-118.5155 34.2937
+-118.5065 34.2992
+-118.4978 34.3068
+-118.4893 34.3143
+-118.4807 34.3183
+-118.4703 34.3232
+-118.4592 34.3242
+-118.4473 34.3227
+-118.4303 34.3248
+-118.4197 34.3252
+-118.4078 34.3237
+-118.3953 34.3210
+-118.3818 34.3172
+-118.3673 34.3153
+-118.3557 34.3167
+-118.3458 34.3183
+-118.3337 34.3183
+-118.3158 34.3188
+>
+-119.9145 34.4202
+-119.8908 34.4178
+-119.8738 34.4182
+-119.8543 34.4178
+-119.8250 34.4187
+-119.8022 34.4203
+-119.7810 34.4210
+-119.7532 34.4242
+-119.7322 34.4287
+-119.7117 34.4338
+-119.6917 34.4348
+-119.6652 34.4333
+-119.6408 34.4288
+-119.6188 34.4272
+-119.5982 34.4242
+-119.5772 34.4203
+-119.5583 34.4160
+-119.5400 34.4137
+-119.5222 34.4128
+-119.5035 34.4112
+-119.4873 34.4088
+-119.4690 34.4068
+-119.4480 34.4027
+-119.4320 34.4002
+-119.4152 34.3992
+-119.4022 34.3978
+-119.3892 34.3988
+-119.3722 34.4017
+-119.3515 34.4043
+-119.3338 34.4077
+-119.3160 34.4108
+-119.3017 34.4137
+-119.2837 34.4133
+-119.2638 34.4190
+-119.2522 34.4213
+-119.2383 34.4247
+-119.2183 34.4293
+-119.2078 34.4318
+-119.1893 34.4348
+-119.1740 34.4372
+-119.1572 34.4372
+-119.1402 34.4337
+-119.1275 34.4303
+-119.1142 34.4272
+-119.0968 34.4223
+>
+-119.0745 34.4200
+-119.0647 34.4190
+-119.0537 34.4172
+-119.0407 34.4160
+-119.0280 34.4132
+-119.0138 34.4110
+-119.0002 34.4108
+-118.9875 34.4117
+-118.9753 34.4170
+-118.9678 34.4227
+-118.9593 34.4295
+-118.9492 34.4347
+-118.9408 34.4393
+-118.9307 34.4413
+-118.9225 34.4328
+-118.9202 34.4260
+-118.9193 34.4173
+-118.9168 34.4108
+-118.9118 34.4033
+-118.9057 34.3977
+-118.8992 34.3922
+-118.8915 34.3872
+-118.8830 34.3828
+-118.8693 34.3802
+-118.8532 34.3792
+-118.8437 34.3783
+>
+-120.3043 34.4363
+-120.2892 34.4472
+-120.2823 34.4557
+-120.2698 34.4672
+-120.2560 34.4772
+-120.2423 34.4830
+-120.2300 34.4933
+-120.2063 34.5058
+-120.1968 34.5117
+-120.1865 34.5193
+-120.1788 34.5243
+-120.1677 34.5273
+-120.1535 34.5287
+-120.1338 34.5320
+-120.1113 34.5382
+-120.0942 34.5442
+-120.0767 34.5488
+-120.0568 34.5508
+-120.0000 34.5513
+-119.9803 34.5513
+-119.9632 34.5480
+-119.9477 34.5438
+-119.9328 34.5400
+-119.9157 34.5370
+-119.8977 34.5380
+-119.8813 34.5397
+-119.8665 34.5412
+-119.8508 34.5423
+-119.8308 34.5413
+-119.8117 34.5388
+-119.7932 34.5327
+-119.7688 34.5238
+-119.7488 34.5158
+-119.7300 34.5092
+-119.7072 34.5027
+-119.6923 34.4983
+-119.6807 34.4970
+-119.6688 34.4952
+-119.6548 34.4925
+-119.6378 34.4908
+-119.6207 34.4883
+-119.6037 34.4858
+-119.5887 34.4838
+-119.5712 34.4818
+-119.5483 34.4803
+-119.5313 34.4800
+-119.5103 34.4802
+-119.4913 34.4803
+-119.4653 34.4813
+-119.4438 34.4847
+-119.4207 34.4867
+-119.4012 34.4878
+-119.3813 34.4910
+-119.3650 34.4928
+-119.3432 34.4933
+-119.3252 34.4942
+-119.3070 34.4948
+-119.2923 34.4957
+-119.2783 34.4998
+-119.2640 34.5028
+-119.2505 34.5068
+-119.2337 34.5098
+-119.2217 34.5132
+-119.2060 34.5163
+-119.1875 34.5177
+-119.1692 34.5200
+-119.1508 34.5215
+-119.1293 34.5220
+-119.1103 34.5247
+-119.0907 34.5273
+-119.0752 34.5298
+-119.0573 34.5327
+-119.0427 34.5350
+-119.0288 34.5392
+-119.0142 34.5445
+-118.9997 34.5502
+-118.9797 34.5525
+-118.9553 34.5567
+-118.9327 34.5617
+-118.9040 34.5693
+-118.8812 34.5758
+>
+-116.4873 34.4815
+-116.4813 34.4767
+-116.4722 34.4688
+-116.4637 34.4628
+-116.4472 34.4538
+-116.4340 34.4485
+-116.4202 34.4412
+-116.4032 34.4278
+-116.3878 34.4120
+-116.3788 34.4028
+-116.3647 34.3878
+-116.3540 34.3782
+-116.3407 34.3642
+-116.3337 34.3557
+-116.3208 34.3418
+-116.3088 34.3318
+-116.3000 34.3232
+-116.2852 34.3097
+-116.2780 34.3003
+-116.2650 34.2807
+>
+-116.7590 34.5397
+-116.7553 34.5272
+-116.7523 34.5157
+-116.7478 34.5037
+-116.7387 34.4850
+-116.7307 34.4692
+-116.7242 34.4552
+-116.7178 34.4422
+-116.7098 34.4277
+-116.7022 34.4127
+-116.6922 34.3968
+-116.6835 34.3848
+-116.6710 34.3718
+-116.6557 34.3575
+-116.6408 34.3455
+-116.6227 34.3343
+-116.6023 34.3267
+-116.5813 34.3193
+-116.5638 34.3143
+-116.5435 34.3072
+-116.5292 34.3032
+-116.5153 34.2993
+>
+-119.3992 34.6577
+-119.3948 34.6515
+-119.3882 34.6478
+-119.3727 34.6442
+-119.3600 34.6400
+-119.3473 34.6302
+-119.3413 34.6247
+-119.3332 34.6192
+-119.3223 34.6138
+-119.3135 34.6113
+-119.3027 34.6102
+-119.2872 34.6078
+-119.2710 34.6050
+-119.2573 34.6020
+-119.2425 34.5970
+-119.2273 34.5937
+-119.2117 34.5902
+-119.2007 34.5892
+-119.1858 34.5868
+-119.1743 34.5847
+-119.1648 34.5813
+-119.1522 34.5758
+-119.1378 34.5690
+-119.1243 34.5650
+-119.1107 34.5640
+-119.0957 34.5640
+-119.0828 34.5637
+-119.0707 34.5633
+-119.0565 34.5640
+-119.0417 34.5650
+-119.0257 34.5658
+-119.0117 34.5658
+-118.9978 34.5662
+-118.9848 34.5665
+-118.9703 34.5675
+-118.9583 34.5698
+-118.9462 34.5740
+-118.9312 34.5793
+-118.9222 34.5837
+-118.9117 34.5868
+-118.9017 34.5957
+-118.8910 34.6007
+-118.8802 34.6038
+-118.8692 34.6060
+-118.8577 34.6077
+-118.8443 34.6090
+-118.8298 34.6105
+-118.8163 34.6108
+-118.8063 34.6113
+-118.7947 34.6103
+-118.7843 34.6092
+-118.7663 34.6078
+>
+-119.7185 34.6728
+-119.7058 34.6728
+-119.6875 34.6723
+-119.6777 34.6713
+-119.6670 34.6705
+-119.6537 34.6697
+-119.6418 34.6678
+-119.6282 34.6667
+-119.6167 34.6642
+-119.6008 34.6650
+-119.5878 34.6642
+-119.5758 34.6632
+-119.5492 34.6663
+-119.5307 34.6657
+-119.5153 34.6642
+-119.5018 34.6637
+-119.4877 34.6632
+-119.4763 34.6618
+-119.4633 34.6612
+-119.4485 34.6598
+-119.4375 34.6607
+-119.4117 34.6598
+-119.3978 34.6597
+-119.3790 34.6618
+-119.3592 34.6657
+-119.3397 34.6682
+-119.3217 34.6715
+-119.3047 34.6768
+-119.2922 34.6803
+-119.2818 34.6862
+-119.2740 34.6913
+-119.2628 34.6982
+-119.2520 34.7027
+-119.2357 34.7083
+-119.2162 34.7123
+-119.2020 34.7172
+-119.1903 34.7208
+-119.1778 34.7245
+-119.1667 34.7282
+-119.1570 34.7328
+-119.1458 34.7365
+-119.1380 34.7403
+-119.1262 34.7442
+-119.1097 34.7492
+-119.0963 34.7547
+-119.0863 34.7588
+-119.0740 34.7623
+-119.0625 34.7682
+-119.0503 34.7752
+-119.0408 34.7838
+-119.0340 34.7877
+-119.0157 34.7962
+-119.0002 34.8042
+-118.9903 34.8132
+>
+-116.8760 34.6747
+-116.8598 34.6612
+-116.8468 34.6508
+-116.8345 34.6385
+-116.8202 34.6265
+-116.8075 34.6125
+-116.7952 34.6002
+-116.7837 34.5868
+-116.7715 34.5625
+-116.7620 34.5582
+-116.7518 34.5433
+-116.7402 34.5288
+-116.7318 34.5150
+-116.7198 34.4948
+-116.7137 34.4822
+-116.7050 34.4675
+-116.6938 34.4483
+-116.6873 34.4363
+-116.6777 34.4213
+-116.6667 34.4027
+-116.6568 34.3872
+-116.6493 34.3755
+-116.6418 34.3672
+>
+-116.5535 34.7017
+-116.5473 34.6895
+-116.5437 34.6768
+-116.5382 34.6652
+-116.5303 34.6563
+-116.5177 34.6463
+-116.4997 34.6307
+-116.4918 34.6243
+-116.4812 34.6137
+-116.4697 34.6018
+-116.4532 34.5857
+-116.4392 34.5625
+-116.4272 34.5607
+-116.4138 34.5487
+-116.4012 34.5377
+-116.3903 34.5247
+-116.3758 34.5095
+-116.3623 34.4968
+-116.3490 34.4857
+-116.3288 34.4688
+-116.3175 34.4587
+-116.2927 34.4370
+-116.2752 34.4193
+-116.2620 34.4052
+-116.2525 34.3963
+-116.2397 34.3843
+-116.2187 34.3672
+>
+-118.9060 34.7617
+-118.8935 34.7517
+-118.8870 34.7427
+-118.8807 34.7338
+-118.8718 34.7235
+-118.8633 34.7090
+-118.8530 34.7030
+-118.8442 34.6918
+-118.8345 34.6812
+-118.8267 34.6707
+-118.8198 34.6635
+-118.8143 34.6567
+-118.8028 34.6468
+-118.7920 34.6390
+-118.7833 34.6302
+-118.7727 34.6208
+-118.7612 34.6102
+-118.7500 34.6022
+-118.7363 34.5828
+-118.7290 34.5773
+-118.7198 34.5703
+-118.7102 34.5617
+-118.7008 34.5547
+-118.6905 34.5482
+-118.6792 34.5398
+-118.6683 34.5328
+-118.6557 34.5205
+-118.6433 34.5088
+-118.6333 34.4998
+-118.6233 34.4893
+-118.6113 34.4758
+-118.5998 34.4613
+-118.5870 34.4477
+-118.5768 34.4387
+-118.5627 34.4298
+-118.5502 34.4213
+-118.5337 34.4100
+-118.5190 34.4020
+-118.5027 34.3948
+-118.4875 34.3878
+-118.4717 34.3823
+-118.4578 34.3747
+-118.4443 34.3672
+-118.4295 34.3592
+-118.4182 34.3553
+-118.3990 34.3497
+-118.3782 34.3428
+-118.3647 34.3383
+-118.3467 34.3330
+-118.3288 34.3260
+-118.3113 34.3173
+-118.2990 34.3122
+-118.2848 34.3048
+-118.2662 34.2960
+-118.2468 34.2873
+-118.2218 34.2723
+-118.2083 34.2638
+-118.1908 34.2500
+-118.1770 34.2433
+-118.1657 34.2328
+-118.1512 34.2215
+-118.1342 34.2093
+-118.1223 34.2022
+-118.1015 34.1862
+>
+-116.8190 34.7618
+-116.8057 34.7487
+-116.7885 34.7350
+-116.7735 34.7248
+-116.7610 34.7182
+-116.7365 34.7005
+-116.7107 34.6843
+-116.6823 34.6647
+-116.6572 34.6445
+-116.6390 34.6297
+-116.6308 34.6235
+-116.6237 34.6145
+-116.6108 34.6055
+-116.5935 34.5927
+-116.5830 34.5832
+-116.5697 34.5625
+-116.5595 34.5618
+-116.5492 34.5518
+-116.5383 34.5387
+-116.5253 34.5255
+-116.5122 34.5123
+-116.5037 34.4992
+-116.4972 34.4877
+>
+-116.4843 34.8327
+-116.4718 34.8127
+-116.4652 34.7952
+-116.4592 34.7812
+-116.4527 34.7693
+-116.4438 34.7573
+-116.4330 34.7425
+-116.4217 34.7283
+-116.4128 34.7127
+-116.4035 34.6993
+-116.3912 34.6780
+-116.3797 34.6610
+-116.3717 34.6455
+-116.3660 34.6303
+-116.3612 34.6178
+-116.3530 34.6017
+-116.3472 34.5898
+-116.3398 34.5625
+-116.3313 34.5563
+-116.3212 34.5392
+-116.3048 34.5292
+-116.2907 34.5158
+-116.2740 34.5027
+-116.2582 34.4858
+-116.2500 34.4733
+-116.2383 34.4622
+-116.2293 34.4455
+-116.2178 34.4327
+-116.2023 34.4230
+-116.1865 34.4133
+-116.1665 34.4017
+-116.1477 34.3843
+-116.1327 34.3672
+-116.1188 34.3560
+-116.1003 34.3323
+-116.0862 34.3127
+-116.0697 34.2887
+-116.0590 34.2695
+-116.0482 34.2500
+-116.0342 34.2415
+-116.0108 34.2263
+-115.9958 34.2202
+-115.9808 34.2108
+-115.9685 34.2012
+-115.9563 34.1945
+-115.9432 34.1832
+-115.9242 34.1667
+-115.9097 34.1492
+-115.8822 34.1062
+-115.8728 34.0908
+>
+-117.3797 34.8437
+-117.3752 34.8357
+-117.3638 34.8237
+-117.3522 34.8188
+-117.3302 34.7968
+-117.3217 34.7837
+-117.3183 34.7768
+-117.3138 34.7678
+-117.3062 34.7590
+-117.2882 34.7440
+-117.2803 34.7388
+-117.2562 34.7212
+-117.2422 34.7113
+-117.2318 34.7040
+-117.2210 34.6932
+-117.1982 34.6693
+-117.1768 34.6517
+-117.1657 34.6403
+-117.1512 34.6283
+-117.1327 34.6143
+-117.1192 34.6018
+-117.1102 34.5947
+-117.0913 34.5793
+-117.0798 34.5625
+-117.0563 34.5392
+-117.0497 34.5297
+-117.0420 34.5195
+-117.0357 34.5120
+-117.0258 34.5022
+-117.0165 34.4922
+-116.9955 34.4757
+-116.9838 34.4633
+-116.9718 34.4548
+-116.9537 34.4397
+-116.9367 34.4237
+-116.9282 34.4147
+-116.9167 34.4038
+-116.9043 34.3950
+-116.8878 34.3832
+-116.8747 34.3713
+-116.8635 34.3623
+-116.8528 34.3543
+-116.8372 34.3427
+-116.8143 34.3237
+-116.7998 34.3118
+-116.7835 34.2987
+-116.7748 34.2917
+-116.7648 34.2853
+-116.7487 34.2745
+-116.7143 34.2500
+>
+-117.2643 34.3065
+-117.2563 34.3143
+-117.2475 34.3255
+-117.2382 34.3350
+-117.2290 34.3463
+-117.2215 34.3562
+-117.2117 34.3692
+-117.2048 34.3802
+-117.1987 34.3918
+-117.1888 34.4042
+-117.1797 34.4105
+-117.1678 34.4170
+-117.1563 34.4213
+-117.1430 34.4257
+-117.1222 34.4283
+-117.1083 34.4293
+-117.0950 34.4273
+-117.0837 34.4262
+-117.0745 34.4235
+-117.0623 34.4175
+-117.0513 34.4127
+-117.0372 34.4028
+-117.0258 34.3928
+-117.0167 34.3850
+-117.0027 34.3763
+-116.9893 34.3708
+-116.9658 34.3657
+-116.9513 34.3627
+-116.9348 34.3603
+-116.9197 34.3573
+-116.9063 34.3553
+-116.8938 34.3537
+-116.8828 34.3532
+-116.8717 34.3518
+-116.8470 34.3498
+-116.8225 34.3432
+-116.8083 34.3407
+-116.7937 34.3382
+-116.7823 34.3353
+-116.7677 34.3328
+-116.7473 34.3293
+-116.7292 34.3298
+-116.7030 34.3302
+-116.6897 34.3352
+-116.6710 34.3367
+>
+-118.7188 34.9057
+-118.6972 34.9110
+-118.6843 34.9173
+-118.6675 34.9247
+>
+-118.4427 35.0047
+-118.4262 35.0142
+-118.4060 35.0272
+-118.3870 35.0393
+-118.3720 35.0488
+-118.3542 35.0607
+-118.3297 35.0718
+-118.3050 35.0870
+-118.2760 35.1008
+-118.2452 35.1142
+-118.2255 35.1265
+-118.2082 35.1348
+-118.1962 35.1413
+-118.1727 35.1542
+-118.1450 35.1692
+-118.1207 35.1847
+-118.0945 35.2013
+-118.0763 35.2163
+-118.0530 35.2353
+-118.0308 35.2497
+-117.9983 35.2722
+-117.9818 35.2848
+-117.9503 35.3015
+-117.9302 35.3120
+-117.9113 35.3237
+-117.8918 35.3338
+-117.8670 35.3472
+-117.8483 35.3593
+-117.8333 35.3693
+-117.8177 35.3782
+-117.7958 35.3912
+-117.7723 35.4052
+-117.7507 35.4140
+-117.7287 35.4242
+-117.7013 35.4362
+-117.6703 35.4487
+-117.6407 35.4562
+-117.6045 35.4665
+-117.5675 35.4767
+-117.5278 35.4858
+-117.5048 35.4907
+-117.4795 35.4955
+-117.4318 35.5108
+-117.4067 35.5193
+-117.3873 35.5242
+-117.3660 35.5283
+-117.3402 35.5352
+-117.3143 35.5423
+-117.2883 35.5480
+-117.2673 35.5527
+-117.2465 35.5577
+-117.2143 35.5650
+-117.1950 35.5677
+-117.1693 35.5727
+-117.1372 35.5788
+-117.1118 35.5823
+-117.0873 35.5877
+-117.0645 35.5913
+-117.0422 35.5945
+-117.0177 35.5977
+-116.9893 35.6025
+-116.9693 35.6053
+-116.9485 35.6082
+-116.9188 35.6093
+-116.8952 35.6093
+-116.8732 35.6093
+-116.8453 35.6045
+-116.8132 35.6003
+-116.7883 35.5977
+-116.7673 35.5973
+-116.7408 35.5977
+-116.7152 35.5957
+-116.6863 35.5967
+-116.6515 35.5967
+-116.6192 35.5977
+-116.5937 35.5967
+-116.5702 35.5958
+-116.5427 35.5955
+-116.5128 35.5958
+-116.4857 35.5957
+-116.4562 35.5972
+-116.4272 35.5998
+-116.4002 35.6003
+-116.3722 35.6027
+-116.3532 35.6023
+-116.3328 35.6020
+>
+-118.8988 34.8185
+-118.8857 34.8183
+-118.8727 34.8200
+-118.8565 34.8228
+-118.8412 34.8285
+-118.8228 34.8357
+-118.8078 34.8425
+-118.7877 34.8483
+-118.7687 34.8603
+-118.7602 34.8647
+-118.7447 34.8752
+-118.7242 34.8857
+-118.7018 34.8952
+>
+-119.2887 34.9365
+-119.2648 34.9388
+-119.2523 34.9425
+-119.2408 34.9448
+>
+-119.0652 35.0008
+-119.0525 35.0015
+>
+-118.9563 34.9357
+-118.9413 34.9353
+>
+-118.8758 34.9318
+-118.8515 34.9317
+>
+-116.2328 34.9532
+-116.2205 34.9427
+-116.2108 34.9315
+-116.2010 34.9212
+-116.1950 34.9087
+-116.1933 34.8918
+-116.1938 34.8760
+-116.1973 34.8573
+-116.1998 34.8422
+-116.2002 34.8288
+-116.1975 34.8133
+-116.1918 34.8000
+-116.1842 34.7872
+-116.1750 34.7723
+-116.1685 34.7608
+-116.1662 34.7478
+-116.1648 34.7332
+-116.1603 34.7185
+-116.1523 34.7058
+-116.1418 34.6947
+-116.1295 34.6787
+-116.1132 34.6603
+-116.1012 34.6473
+-116.0820 34.6283
+-116.0628 34.6102
+-116.0475 34.5932
+-116.0332 34.5758
+-116.0183 34.5563
+-116.0017 34.5417
+-115.9842 34.5278
+-115.9663 34.5122
+-115.9510 34.4988
+-115.9297 34.4832
+-115.9047 34.4660
+-115.8825 34.4482
+-115.8615 34.4327
+>
+-116.9142 34.9788
+-116.9053 34.9697
+-116.8972 34.9532
+-116.8738 34.9458
+-116.8572 34.9393
+-116.8455 34.9347
+-116.8282 34.9292
+-116.8090 34.9240
+-116.7933 34.9193
+-116.7748 34.9127
+-116.7625 34.9053
+-116.7460 34.8922
+-116.7357 34.8803
+-116.7287 34.8722
+-116.7173 34.8613
+-116.7088 34.8542
+-116.6838 34.8367
+-116.6582 34.8138
+-116.6478 34.8027
+-116.6342 34.7883
+-116.6157 34.7687
+-116.6042 34.7567
+-116.5843 34.7373
+-116.5652 34.7197
+-116.5537 34.7077
+-116.5425 34.6988
+-116.5358 34.6908
+-116.5263 34.6837
+-116.5157 34.6772
+-116.5002 34.6672
+>
+-119.0227 35.0062
+-119.0073 35.0142
+-118.9952 35.0213
+-118.9842 35.0272
+-118.9657 35.0402
+-118.9480 35.0493
+-118.9363 35.0550
+-118.9213 35.0635
+-118.9110 35.0715
+-118.9025 35.0792
+-118.8945 35.0858
+-118.8842 35.0937
+-118.8705 35.1048
+-118.8573 35.1140
+-118.8400 35.1243
+-118.8292 35.1312
+-118.8148 35.1407
+-118.7980 35.1537
+-118.7798 35.1672
+-118.7713 35.1753
+-118.7617 35.1875
+-118.7533 35.1937
+-118.7458 35.1998
+-118.7338 35.2015
+-118.7123 35.2065
+-118.6992 35.2108
+-118.6872 35.2193
+-118.6787 35.2277
+-118.6715 35.2338
+-118.6637 35.2395
+-118.6533 35.2468
+-118.6403 35.2508
+-118.6238 35.2582
+-118.6102 35.2658
+-118.6010 35.2715
+-118.5927 35.2768
+-118.5842 35.2838
+-118.5758 35.2933
+-118.5688 35.3032
+-118.5642 35.3107
+-118.5572 35.3168
+-118.5480 35.3262
+-118.5418 35.3377
+>
+-119.0843 35.0812
+-119.0640 35.0812
+-119.0527 35.0808
+-119.0388 35.0828
+-119.0262 35.0792
+>
+-119.0065 35.1113
+-118.9938 35.1142
+-118.9812 35.1200
+-118.9648 35.1262
+-118.9463 35.1323
+-118.9278 35.1363
+-118.9123 35.1375
+-118.8977 35.1405
+-118.8840 35.1453
+-118.8745 35.1527
+-118.8695 35.1608
+-118.8635 35.1662
+-118.8528 35.1677
+-118.8420 35.1667
+>
+-120.0078 35.0420
+-119.9993 35.0353
+-119.9887 35.0300
+-119.9773 35.0220
+-119.9627 35.0098
+>
+-119.8933 34.9605
+-119.8833 34.9570
+-119.8738 34.9490
+-119.8563 34.9422
+-119.8395 34.9372
+-119.8242 34.9358
+-119.8045 34.9333
+-119.7870 34.9293
+-119.7728 34.9237
+-119.7500 34.9200
+-119.7348 34.9082
+-119.7257 34.9050
+-119.7078 34.8965
+-119.6952 34.8878
+-119.6823 34.8812
+-119.6687 34.8727
+-119.6578 34.8685
+-119.6485 34.8597
+-119.6483 34.8462
+-119.6363 34.8390
+-119.6292 34.8343
+-119.6232 34.8303
+-119.6150 34.8248
+-119.6043 34.8190
+-119.5952 34.8143
+-119.5853 34.8090
+-119.5763 34.8040
+-119.5667 34.8018
+-119.5558 34.7993
+-119.5452 34.7978
+-119.5352 34.7975
+-119.5215 34.7948
+-119.5110 34.7927
+-119.5042 34.7898
+-119.4868 34.7812
+-119.4753 34.7748
+-119.4642 34.7682
+-119.4550 34.7617
+-119.4452 34.7548
+-119.4360 34.7462
+-119.4280 34.7408
+-119.4163 34.7347
+-119.4058 34.7282
+-119.3953 34.7207
+-119.3843 34.7122
+-119.3722 34.7003
+-119.3652 34.6943
+-119.3578 34.6880
+-119.3398 34.6670
+>
+-117.7582 35.2157
+-117.7467 35.2108
+-117.7307 35.2043
+-117.7083 35.1953
+-117.6888 35.1867
+-117.6722 35.1797
+-117.6555 35.1715
+-117.6372 35.1608
+-117.6230 35.1492
+-117.6100 35.1407
+-117.5963 35.1313
+-117.5802 35.1252
+-117.5597 35.1157
+-117.5322 35.0992
+-117.5068 35.0848
+-117.4808 35.0688
+-117.4583 35.0573
+-117.4413 35.0475
+-117.4223 35.0383
+-117.4018 35.0303
+-117.3735 35.0192
+-117.3482 35.0092
+-117.3258 35.0018
+>
+-117.2750 34.9532
+-117.2607 34.9532
+-117.2447 34.9472
+-117.2132 34.9308
+-117.1953 34.9202
+-117.1797 34.9122
+-117.1598 34.9040
+-117.1342 34.8868
+-117.1168 34.8770
+-117.1065 34.8712
+-117.0935 34.8633
+-117.0807 34.8582
+-117.0673 34.8488
+-117.0562 34.8415
+-117.0482 34.8362
+-117.0378 34.8278
+-117.0285 34.8202
+-117.0212 34.8152
+-117.0098 34.8062
+-116.9985 34.8003
+-116.9883 34.7947
+-116.9798 34.7877
+-116.9695 34.7833
+-116.9592 34.7755
+-116.9427 34.7638
+-116.9295 34.7523
+-116.9197 34.7407
+-116.9082 34.7223
+-116.8992 34.7062
+-116.8937 34.6992
+-116.8897 34.6927
+-116.8833 34.6825
+-116.8745 34.6728
+>
+-117.5752 35.3168
+-117.5673 35.3088
+-117.5590 35.3023
+-117.5447 35.2897
+-117.5322 35.2790
+-117.5097 35.2668
+-117.4867 35.2513
+-117.4698 35.2405
+-117.4535 35.2302
+-117.4327 35.2187
+-117.4162 35.2100
+-117.3950 35.1992
+-117.3793 35.1875
+-117.3593 35.1822
+-117.3342 35.1693
+-117.3202 35.1617
+-117.2942 35.1468
+-117.2670 35.1267
+-117.2393 35.1102
+-117.2157 35.0903
+-117.1882 35.0683
+-117.1620 35.0455
+-117.1417 35.0298
+-117.1290 35.0213
+-117.1153 35.0088
+-117.0948 35.0000
+-117.0903 34.9820
+-117.0763 34.9702
+-117.0547 34.9532
+-117.0393 34.9477
+-117.0233 34.9365
+-117.0067 34.9282
+-116.9888 34.9145
+-116.9750 34.9017
+-116.9640 34.8905
+-116.9492 34.8770
+>
+-117.4108 35.4567
+-117.3885 35.4395
+-117.3702 35.4245
+-117.3577 35.4108
+-117.3422 35.3985
+-117.3308 35.3750
+-117.3053 35.3677
+-117.2862 35.3487
+-117.2807 35.3398
+-117.2638 35.3233
+-117.2497 35.3072
+-117.2393 35.2930
+-117.2248 35.2728
+-117.2178 35.2617
+-117.2048 35.2412
+-117.1883 35.2223
+-117.1697 35.2062
+-117.1517 35.1883
+-117.1337 35.1768
+-117.1093 35.1468
+-117.0992 35.1327
+>
+-119.0958 35.5955
+-119.0890 35.5887
+-119.0827 35.5820
+-119.0773 35.5735
+-119.0717 35.5617
+>
+-119.0175 35.4997
+-119.0172 35.4908
+-119.0168 35.4813
+-119.0168 35.4707
+-119.0190 35.4578
+-119.0245 35.4478
+-119.0287 35.4405
+>
+-118.8763 35.4193
+-118.8663 35.4105
+-118.8552 35.4022
+-118.8437 35.3943
+-118.8312 35.3867
+-118.8187 35.3803
+-118.8053 35.3743
+-118.7948 35.3693
+-118.7842 35.3627
+-118.7727 35.3563
+>
+-118.8637 35.3457
+-118.8453 35.3453
+-118.8303 35.3447
+-118.8152 35.3447
+-118.8050 35.3432
+>
+-118.8198 35.4050
+-118.8083 35.3982
+-118.7963 35.3923
+>
+-120.2740 35.6722
+-120.2753 35.6642
+-120.2748 35.6553
+-120.2743 35.6430
+-120.2728 35.6340
+-120.2725 35.6257
+-120.2708 35.6178
+-120.2692 35.6098
+-120.2647 35.6008
+-120.2572 35.5897
+-120.2510 35.5778
+-120.2433 35.5655
+-120.2375 35.5555
+-120.2313 35.5445
+-120.2263 35.5348
+-120.2208 35.5228
+-120.2165 35.5112
+-120.2103 35.4997
+-120.2017 35.4855
+-120.1943 35.4768
+-120.1862 35.4677
+-120.1793 35.4592
+-120.1718 35.4468
+-120.1658 35.4352
+-120.1583 35.4223
+-120.1527 35.4093
+-120.1467 35.3935
+-120.1440 35.3783
+-120.1413 35.3683
+-120.1400 35.3578
+-120.1393 35.3488
+-120.1392 35.3367
+-120.1333 35.3268
+-120.1250 35.3180
+-120.1180 35.3100
+-120.1083 35.3002
+-120.0982 35.2918
+-120.0893 35.2857
+-120.0813 35.2783
+-120.0697 35.2670
+-120.0588 35.2572
+-120.0488 35.2475
+-120.0402 35.2393
+-120.0303 35.2297
+-120.0193 35.2185
+-120.0113 35.2103
+-120.0037 35.2007
+-119.9968 35.1922
+-119.9907 35.1842
+-119.9723 35.1687
+-119.9682 35.1632
+-119.9603 35.1558
+-119.9523 35.1502
+-119.9417 35.1425
+>
+-120.2308 35.5403
+-120.2285 35.5248
+-120.2260 35.5142
+-120.2233 35.5058
+-120.2202 35.4968
+-120.2202 35.4815
+-120.2207 35.4707
+-120.2202 35.4623
+-120.2193 35.4543
+-120.2168 35.4453
+-120.2115 35.4375
+-120.2045 35.4302
+-120.1977 35.4217
+-120.1902 35.4110
+-120.1823 35.3997
+-120.1762 35.3912
+-120.1700 35.3820
+-120.1647 35.3732
+-120.1598 35.3653
+-120.1550 35.3578
+-120.1505 35.3428
+>
+-116.8220 36.3998
+-116.8117 36.3873
+-116.8022 36.3715
+-116.7928 36.3612
+-116.7872 36.3493
+-116.7762 36.3125
+-116.7707 36.3045
+-116.7682 36.2908
+-116.7655 36.2797
+-116.7637 36.2698
+-116.7647 36.2558
+-116.7632 36.2402
+-116.7602 36.2187
+-116.7590 36.2048
+-116.7593 36.1898
+-116.7582 36.1732
+-116.7543 36.1593
+-116.7482 36.1518
+-116.7388 36.1397
+-116.7315 36.1272
+-116.7242 36.1143
+-116.7193 36.0953
+-116.7202 36.0868
+-116.7255 36.0782
+-116.7325 36.0702
+-116.7383 36.0627
+-116.7422 36.0528
+-116.7427 36.0415
+-116.7363 36.0283
+-116.7305 36.0173
+-116.7227 36.0082
+-116.7142 35.9905
+-116.7072 35.9740
+-116.7020 35.9657
+-116.6973 35.9492
+-116.6898 35.9332
+-116.6737 35.9158
+-116.6548 35.8960
+-116.6442 35.8855
+-116.6330 35.8772
+-116.6222 35.8617
+-116.6087 35.8492
+-116.5988 35.8323
+-116.5887 35.8138
+-116.5790 35.8032
+-116.5662 35.7857
+-116.5452 35.7635
+>
+-116.4502 35.6740
+-116.4177 35.6508
+-116.3832 35.6322
+-116.3557 35.6177
+-116.3332 35.6048
+-116.3197 35.5947
+>
+-116.9950 36.5345
+-116.9838 36.5167
+-116.9800 36.5033
+>
+-116.9392 36.4102
+-116.9353 36.3947
+-116.9338 36.3827
+-116.9362 36.3672
+-116.9357 36.3547
+-116.9368 36.3410
+-116.9373 36.3278
+-116.9370 36.3133
+-116.9352 36.2923
+-116.9352 36.2823
+-116.9348 36.2657
+-116.9333 36.2488
+-116.9332 36.2375
+-116.9317 36.2223
+-116.9288 36.2043
+-116.9280 36.1862
+-116.9270 36.1718
+-116.9253 36.1497
+-116.9238 36.1310
+-116.9213 36.1122
+-116.9143 36.0957
+-116.9102 36.0898
+-116.8997 36.0740
+-116.8882 36.0567
+-116.8730 36.0312
+-116.8560 36.0218
+-116.8398 36.0008
+-116.8292 35.9843
+-116.8205 35.9763
+-116.8107 35.9608
+>
+-121.8072 36.6875
+-121.7948 36.6838
+-121.7803 36.6803
+-121.7672 36.6758
+-121.7558 36.6722
+-121.7457 36.6692
+-121.7355 36.6637
+-121.7220 36.6590
+-121.7110 36.6552
+-121.7017 36.6503
+-121.6920 36.6443
+-121.6808 36.6375
+-121.6698 36.6307
+-121.6597 36.6243
+-121.6490 36.6187
+-121.6382 36.6133
+-121.6250 36.6052
+-121.6133 36.5975
+-121.6007 36.5890
+-121.5923 36.5827
+-121.5837 36.5755
+-121.5748 36.5682
+-121.5648 36.5602
+-121.5522 36.5458
+-121.5448 36.5377
+-121.5342 36.5268
+-121.5262 36.5182
+-121.5207 36.5000
+-121.5067 36.4927
+-121.4977 36.4857
+-121.4808 36.4673
+-121.4712 36.4618
+-121.4597 36.4523
+-121.4500 36.4438
+-121.4403 36.4353
+-121.4302 36.4273
+-121.4183 36.4192
+-121.4077 36.4100
+-121.3978 36.4012
+-121.3912 36.3918
+-121.3850 36.3807
+-121.3778 36.3718
+-121.3730 36.3602
+-121.3665 36.3493
+-121.3622 36.3400
+-121.3578 36.3317
+-121.3528 36.3227
+-121.3438 36.3125
+-121.3368 36.3027
+-121.3307 36.2942
+-121.3235 36.2852
+-121.3150 36.2768
+-121.3060 36.2677
+-121.2962 36.2598
+-121.2863 36.2530
+-121.2792 36.2458
+-121.2722 36.2393
+-121.2638 36.2318
+-121.2550 36.2247
+-121.2500 36.2167
+-121.2372 36.2052
+-121.2290 36.1958
+-121.2192 36.1858
+-121.2078 36.1748
+-121.1960 36.1625
+-121.1847 36.1518
+-121.1753 36.1407
+-121.1658 36.1302
+-121.1530 36.1172
+-121.1407 36.1043
+-121.1285 36.0918
+-121.1185 36.0815
+-121.1033 36.0678
+-121.0910 36.0558
+-121.0812 36.0422
+-121.0678 36.0278
+-121.0552 36.0147
+-121.0483 36.0038
+-121.0397 35.9928
+-121.0275 35.9797
+-121.0182 35.9658
+-121.0083 35.9532
+-120.9972 35.9388
+-120.9863 35.9257
+-120.9757 35.9105
+-120.9608 35.8920
+-120.9455 35.8727
+-120.9330 35.8532
+-120.9230 35.8383
+-120.9113 35.8228
+-120.8937 35.8040
+-120.8750 35.7898
+-120.8677 35.7733
+-120.8515 35.7580
+-120.8308 35.7430
+-120.8150 35.7295
+-120.7987 35.7127
+-120.7830 35.6978
+-120.7695 35.6823
+-120.7538 35.6660
+-120.7385 35.6533
+-120.7203 35.6367
+-120.7113 35.6240
+-120.6937 35.6103
+-120.6838 35.5973
+-120.6697 35.5785
+-120.6605 35.5625
+-120.6503 35.5438
+-120.6398 35.5247
+-120.6312 35.5057
+-120.6187 35.4822
+-120.6078 35.4607
+-120.5980 35.4408
+-120.5902 35.4263
+-120.5807 35.4085
+-120.5700 35.3928
+-120.5593 35.3767
+-120.5473 35.3605
+-120.5378 35.3452
+-120.5000 35.3273
+-120.5000 35.3158
+-120.4938 35.3057
+-120.4843 35.2973
+>
+-121.3985 36.8357
+-121.3900 36.8220
+-121.3825 36.8132
+-121.3742 36.8052
+-121.3657 36.7992
+-121.3537 36.7892
+-121.3400 36.7755
+-121.3278 36.7643
+-121.3173 36.7547
+-121.3090 36.7463
+-121.2975 36.7357
+-121.2868 36.7267
+-121.2747 36.7168
+-121.2647 36.7088
+-121.2500 36.6943
+-121.2428 36.6848
+-121.2327 36.6757
+-121.2205 36.6653
+-121.2103 36.6562
+-121.2025 36.6463
+-121.1947 36.6380
+-121.1853 36.6288
+-121.1753 36.6217
+-121.1642 36.6118
+-121.1512 36.6007
+-121.1388 36.5918
+-121.1263 36.5808
+-121.1128 36.5688
+-121.0975 36.5550
+-121.0817 36.5412
+-121.0672 36.5282
+-121.0548 36.5163
+-121.0418 36.5000
+-121.0290 36.4920
+-121.0183 36.4798
+-121.0095 36.4663
+>
+-118.2830 36.8973
+-118.2868 36.8750
+-118.2963 36.8737
+-118.3027 36.8603
+-118.3058 36.8477
+-118.3068 36.8357
+-118.3058 36.8252
+-118.3048 36.8135
+-118.3035 36.8027
+-118.3013 36.7912
+-118.2987 36.7793
+-118.2938 36.7658
+-118.2913 36.7568
+-118.2852 36.7463
+-118.2788 36.7357
+-118.2723 36.7253
+-118.2647 36.7178
+-118.2588 36.7108
+-118.2517 36.7013
+-118.2463 36.6932
+-118.2418 36.6852
+-118.2387 36.6775
+-118.2337 36.6678
+-118.2303 36.6598
+-118.2273 36.6500
+-118.2240 36.6407
+-118.2183 36.6278
+-118.2105 36.6172
+-118.1998 36.6042
+-118.1913 36.5937
+-118.1840 36.5862
+-118.1777 36.5782
+-118.1652 36.5643
+-118.1518 36.5518
+-118.1385 36.5387
+-118.1258 36.5272
+-118.1018 36.5073
+>
+-118.0557 36.4432
+-118.0527 36.4360
+-118.0475 36.4245
+-118.0392 36.3997
+-118.0372 36.3893
+-118.0348 36.3773
+-118.0340 36.3665
+-118.0327 36.3540
+-118.0337 36.3437
+-118.0358 36.3322
+-118.0380 36.3218
+-118.0387 36.3125
+-118.0382 36.3017
+-118.0370 36.2912
+-118.0327 36.2783
+-118.0248 36.2657
+-118.0172 36.2547
+-118.0100 36.2445
+-118.0008 36.2300
+-117.9943 36.2158
+-117.9900 36.1987
+-117.9880 36.1837
+-117.9888 36.1697
+-117.9895 36.1563
+-117.9900 36.1422
+-117.9907 36.1250
+-117.9917 36.1153
+-117.9893 36.0937
+-117.9818 36.0730
+-117.9747 36.0553
+-117.9680 36.0413
+-117.9605 36.0237
+-117.9522 36.0023
+-117.9450 35.9860
+-117.9337 35.9698
+-117.9238 35.9580
+-117.8983 35.9375
+-117.8983 35.9292
+-117.8843 35.9105
+-117.8742 35.8880
+-117.8740 35.8717
+-117.8773 35.8437
+-117.8787 35.8323
+-117.8783 35.8080
+-117.8783 35.7902
+-117.8787 35.7782
+-117.8775 35.7578
+-117.8742 35.7500
+-117.8707 35.7205
+-117.8678 35.7058
+-117.8670 35.6927
+-117.8707 35.6807
+-117.8763 35.6702
+-117.8983 35.6582
+-117.8983 35.6432
+-117.9028 35.6300
+-117.9105 35.6203
+-117.9207 35.6110
+-117.9305 35.6040
+-117.9438 35.5930
+-117.9550 35.5858
+-117.9678 35.5797
+-117.9795 35.5735
+-117.9912 35.5688
+-118.0027 35.5642
+-118.0127 35.5625
+-118.0173 35.5522
+-118.0210 35.5438
+-118.0268 35.5268
+-118.0307 35.5087
+-118.0328 35.5022
+-118.0337 35.4892
+-118.0353 35.4765
+-118.0370 35.4603
+-118.0388 35.4453
+-118.0388 35.4297
+-118.0393 35.4132
+-118.0383 35.3967
+-118.0370 35.3750
+-118.0330 35.3628
+-118.0302 35.3502
+-118.0267 35.3382
+-118.0235 35.3275
+-118.0202 35.3150
+-118.0170 35.3043
+-118.0135 35.2955
+-118.0070 35.2813
+-118.0028 35.2722
+>
+-117.9433 36.9223
+-117.9413 36.8997
+-117.9393 36.8813
+-117.9353 36.8662
+-117.9297 36.8507
+-117.9250 36.8378
+-117.9168 36.8172
+-117.9102 36.8018
+-117.8983 36.7812
+-117.8938 36.7678
+-117.8847 36.7523
+-117.8742 36.7382
+-117.8638 36.7227
+-117.8562 36.7110
+-117.8462 36.6875
+-117.8355 36.6838
+-117.8252 36.6692
+-117.8113 36.6592
+-117.7863 36.6508
+-117.7602 36.6412
+-117.7320 36.6320
+-117.7055 36.6212
+-117.6833 36.6118
+-117.6570 36.5982
+-117.6297 36.5810
+-117.5967 36.5587
+-117.5867 36.5517
+-117.5655 36.5425
+-117.5443 36.5323
+-117.5207 36.5232
+-117.4973 36.5127
+-117.4748 36.5032
+>
+-117.3957 36.5000
+-117.3963 36.4252
+-117.3887 36.4143
+-117.3783 36.3988
+-117.3682 36.3853
+-117.3605 36.3735
+-117.3513 36.3588
+-117.3448 36.3502
+-117.3392 36.3403
+-117.3307 36.3288
+-117.3235 36.3187
+-117.3105 36.3062
+-117.2952 36.2948
+-117.2803 36.2837
+-117.2637 36.2672
+-117.2517 36.2557
+-117.2393 36.2403
+-117.2300 36.2187
+-117.2212 36.2067
+-117.2153 36.1920
+-117.2097 36.1782
+-117.2052 36.1638
+>
+-117.4333 36.3358
+-117.4223 36.3272
+-117.4247 36.3125
+-117.4223 36.2980
+-117.4165 36.2872
+-117.4132 36.2725
+-117.4108 36.2613
+-117.4093 36.2472
+-117.4050 36.2332
+-117.3992 36.2188
+-117.3833 36.1958
+-117.3723 36.1828
+-117.3657 36.1678
+-117.3593 36.1567
+-117.3537 36.1250
+-117.3413 36.1167
+-117.3380 36.1043
+-117.3342 36.0883
+-117.3318 36.0773
+-117.3308 36.0633
+-117.3300 36.0505
+-117.3290 36.0423
+-117.3278 36.0313
+-117.3265 36.0195
+-117.3252 36.0078
+>
+-117.2082 36.0678
+-117.2088 36.0528
+-117.2103 36.0407
+-117.2097 36.0283
+-117.2112 36.0167
+-117.2118 36.0018
+-117.2117 35.9902
+-117.2097 35.9770
+-117.2070 35.9652
+-117.2038 35.9513
+-117.1975 35.9333
+-117.1935 35.9193
+-117.1893 35.9053
+-117.1828 35.8907
+-117.1762 35.8740
+-117.1722 35.8547
+-117.1658 35.8388
+-117.1562 35.8237
+-117.1450 35.8027
+-117.1378 35.7852
+-117.1302 35.7733
+-117.1205 35.7542
+-117.1107 35.7500
+-117.0997 35.7500
+-117.0878 35.7190
+-117.0722 35.7053
+-117.0577 35.6942
+-117.0450 35.6848
+-117.0317 35.6772
+-117.0143 35.6697
+-116.9973 35.6613
+-116.9788 35.6563
+-116.9647 35.6480
+-116.9505 35.6442
+-116.9353 35.6367
+-116.9212 35.6287
+-116.9097 35.6195
+-116.8977 35.6128
+-116.8842 35.5993
+>
+-121.1452 37.0885
+-121.1497 37.0818
+-121.1523 37.0737
+-121.1563 37.0602
+-121.1538 37.0518
+-121.1525 37.0430
+-121.1473 37.0282
+-121.1430 37.0222
+-121.1362 37.0153
+-121.1292 37.0088
+-121.1178 36.9992
+-121.1075 36.9895
+-121.0973 36.9823
+-121.0885 36.9747
+-121.0793 36.9667
+-121.0698 36.9595
+-121.0612 36.9513
+-121.0512 36.9423
+-121.0422 36.9337
+-121.0340 36.9228
+-121.0247 36.9142
+-121.0167 36.8977
+-121.0122 36.8902
+-121.0062 36.8812
+-120.9978 36.8717
+-120.9908 36.8597
+-120.9832 36.8497
+-120.9715 36.8368
+-120.9607 36.8272
+-120.9492 36.8162
+-120.9428 36.8098
+-120.9353 36.8032
+-120.9285 36.7963
+-120.9233 36.7888
+-120.9157 36.7752
+-120.9128 36.7658
+-120.9122 36.7552
+-120.9122 36.7453
+-120.9102 36.7343
+-120.9097 36.7237
+-120.9087 36.7095
+-120.9058 36.6995
+-120.9003 36.6900
+-120.8890 36.6782
+>
+-118.3483 37.5947
+-118.3453 37.5782
+-118.3430 37.5668
+-118.3407 37.5557
+-118.3377 37.5410
+-118.3355 37.5260
+-118.3317 37.5078
+-118.3283 37.4957
+-118.3237 37.4777
+-118.3182 37.4630
+-118.3142 37.4522
+-118.3082 37.4375
+-118.3015 37.4190
+-118.2930 37.4002
+-118.2882 37.3788
+-118.2842 37.3593
+-118.2777 37.3393
+-118.2732 37.3173
+-118.2685 37.2952
+-118.2647 37.2702
+-118.2612 37.2535
+-118.2533 37.2320
+-118.2452 37.2097
+-118.2362 37.1892
+-118.2278 37.1713
+-118.2178 37.1488
+-118.2127 37.1328
+-118.2053 37.1133
+-118.1993 37.0983
+-118.1922 37.0820
+-118.1882 37.0687
+-118.1858 37.0518
+>
+-118.4532 37.3312
+-118.4373 37.3238
+-118.4217 37.3148
+-118.4092 37.3033
+-118.3982 37.2897
+-118.3888 37.2758
+-118.3830 37.2625
+-118.3773 37.2500
+-118.3738 37.2168
+-118.3738 37.2032
+-118.3738 37.1928
+>
+-118.3323 37.3007
+-118.3285 37.2838
+-118.3240 37.2642
+-118.3202 37.2500
+-118.3175 37.2143
+-118.3183 37.1973
+-118.3203 37.1817
+-118.3220 37.1628
+-118.3242 37.1460
+-118.3242 37.1265
+-118.3232 37.1103
+-118.3243 37.0963
+-118.3252 37.0835
+>
+-118.3178 37.2128
+-118.3127 37.1995
+-118.3082 37.1898
+-118.3033 37.1747
+-118.2977 37.1623
+-118.2908 37.1497
+-118.2830 37.1342
+-118.2783 37.1192
+-118.2753 37.1035
+-118.2753 37.0890
+-118.2757 37.0782
+-118.2778 37.0625
+-118.2792 37.0503
+-118.2795 37.0400
+-118.2803 37.0288
+-118.2848 37.0157
+-118.2870 37.0078
+>
+-118.3385 37.0477
+-118.3372 37.0347
+-118.3332 37.0213
+-118.3317 37.0088
+-118.3298 36.9938
+-118.3322 36.9763
+-118.3333 36.9607
+>
+-118.2392 37.0678
+-118.2363 37.0558
+-118.2288 37.0407
+-118.2217 37.0228
+-118.2188 37.0098
+-118.2142 36.9963
+-118.2068 36.9802
+-118.2042 36.9625
+-118.2018 36.9453
+-118.1913 36.9303
+-118.1895 36.9152
+-118.1822 36.9022
+-118.1747 36.8750
+-118.1627 36.8652
+-118.1518 36.8435
+-118.1432 36.8230
+-118.1350 36.8097
+-118.1283 36.7998
+-118.1205 36.7812
+-118.1128 36.7695
+-118.1098 36.7628
+-118.0983 36.7402
+-118.0930 36.7197
+-118.0862 36.6975
+-118.0788 36.6818
+-118.0717 36.6652
+-118.0652 36.6407
+-118.0603 36.6290
+-118.0567 36.6173
+-118.0527 36.6043
+-118.0473 36.5903
+-118.0438 36.5772
+-118.0413 36.5637
+-118.0387 36.5468
+-118.0360 36.5348
+-118.0342 36.5183
+-118.0322 36.5062
+>
+-118.0123 36.4370
+-118.0073 36.4232
+-118.0033 36.4083
+-117.9983 36.3952
+-117.9962 36.3768
+-117.9953 36.3653
+-117.9962 36.3538
+-117.9977 36.3397
+-117.9985 36.3270
+-117.9992 36.3170
+-117.9933 36.2937
+-117.9893 36.2832
+-117.9817 36.2723
+-117.9732 36.2648
+-117.9648 36.2545
+>
+-118.8082 37.6167
+-118.8007 37.6033
+-118.7967 37.5933
+-118.7902 37.5800
+-118.7860 37.5678
+-118.7792 37.5553
+-118.7707 37.5402
+-118.7652 37.5267
+-118.7588 37.5113
+-118.7520 37.5002
+-118.7437 37.4898
+-118.7347 37.4742
+>
+-118.7403 37.5583
+-118.7278 37.5452
+-118.7188 37.5383
+-118.7093 37.5312
+-118.6952 37.5312
+-118.6822 37.5288
+-118.6697 37.5237
+-118.6558 37.5170
+-118.6437 37.5042
+-118.6392 37.4962
+-118.6358 37.4828
+-118.6338 37.4708
+-118.6320 37.4570
+-118.6327 37.4375
+-118.6425 37.4203
+-118.6457 37.4105
+-118.6492 37.4028
+-118.6545 37.3962
+-118.6622 37.3887
+-118.6688 37.3788
+-118.6713 37.3698
+-118.6710 37.3568
+-118.6697 37.3468
+-118.6673 37.3363
+-118.6645 37.3287
+>
+-118.6457 37.4028
+-118.6377 37.3925
+-118.6308 37.3872
+-118.6242 37.3808
+-118.6198 37.3752
+-118.6162 37.3637
+-118.6157 37.3512
+-118.6180 37.3395
+-118.6227 37.3260
+-118.6283 37.3163
+-118.6338 37.3018
+-118.6335 37.2878
+-118.6313 37.2738
+-118.6268 37.2627
+-118.6242 37.2552
+>
+-118.0862 37.6447
+-118.0798 37.6250
+-118.0703 37.6185
+-118.0575 37.6058
+-118.0448 37.5957
+-118.0362 37.5867
+-118.0220 37.5780
+-118.0108 37.5712
+-117.9953 37.5547
+-117.9905 37.5467
+-117.9803 37.5333
+-117.9692 37.5207
+-117.9617 37.5127
+-117.9492 37.4995
+-117.9373 37.4887
+-117.9198 37.4763
+-117.8983 37.4647
+-117.8977 37.4563
+-117.8898 37.4375
+-117.8792 37.4332
+-117.8518 37.4147
+-117.8443 37.4058
+-117.8328 37.3943
+-117.8212 37.3823
+-117.8060 37.3690
+-117.7965 37.3608
+-117.7698 37.3502
+-117.7468 37.3413
+-117.7318 37.3362
+-117.7123 37.3303
+-117.6965 37.3245
+-117.6800 37.3143
+-117.6630 37.3007
+-117.6488 37.2858
+-117.6333 37.2737
+-117.6195 37.2613
+>
+-117.5592 37.2003
+-117.5467 37.1850
+-117.5315 37.1678
+-117.5217 37.1562
+-117.5062 37.1410
+-117.4917 37.1265
+-117.4783 37.1102
+-117.4590 37.0913
+-117.4412 37.0728
+-117.4205 37.0538
+-117.4073 37.0417
+-117.3930 37.0310
+-117.3773 37.0153
+-117.3597 36.9983
+-117.3418 36.9833
+-117.3258 36.9637
+-117.3063 36.9438
+-117.2793 36.9115
+-117.2657 36.8750
+-117.2517 36.8740
+-117.2393 36.8482
+-117.2140 36.8282
+-117.2032 36.8163
+-117.1828 36.7920
+-117.1607 36.7668
+-117.1403 36.7452
+-117.1232 36.7273
+-117.1037 36.7095
+-117.0855 36.6925
+-117.0613 36.6758
+-117.0462 36.6658
+-117.0218 36.6500
+-116.9942 36.6297
+-116.9723 36.6172
+-116.9482 36.6002
+-116.9260 36.5820
+-116.9023 36.5595
+-116.8730 36.5428
+-116.8672 36.5315
+-116.8493 36.5200
+>
+-121.9883 37.8147
+-121.9812 37.8007
+-121.9765 37.7925
+-121.9713 37.7847
+-121.9652 37.7750
+-121.9585 37.7647
+-121.9517 37.7535
+-121.9475 37.7442
+-121.9435 37.7352
+-121.9397 37.7257
+-121.9353 37.7147
+-121.9312 37.7053
+-121.9252 37.6922
+-121.9215 37.6858
+-121.9137 37.6728
+-121.9072 37.6633
+-121.8988 37.6493
+-121.8913 37.6382
+-121.8880 37.6320
+-121.8850 37.6250
+-121.8758 37.6065
+-121.8732 37.5982
+-121.8658 37.5830
+-121.8633 37.5753
+-121.8578 37.5628
+-121.8542 37.5555
+-121.8473 37.5442
+-121.8390 37.5297
+-121.8353 37.5213
+-121.8317 37.5133
+-121.8262 37.5045
+-121.8203 37.4892
+-121.8168 37.4800
+-121.8082 37.4642
+-121.8032 37.4542
+-121.7987 37.4465
+-121.7910 37.4362
+-121.7818 37.4252
+-121.7767 37.4193
+-121.7723 37.4143
+-121.7672 37.4078
+-121.7603 37.4007
+-121.7527 37.3930
+-121.7453 37.3838
+-121.7385 37.3748
+-121.7315 37.3653
+-121.7233 37.3567
+-121.7140 37.3453
+-121.7073 37.3378
+-121.7013 37.3313
+-121.6928 37.3237
+-121.6898 37.3162
+-121.6853 37.3098
+-121.6803 37.3028
+-121.6767 37.2935
+-121.6708 37.2827
+-121.6660 37.2738
+-121.6602 37.2653
+-121.6547 37.2585
+-121.6483 37.2485
+-121.6422 37.2393
+-121.6375 37.2297
+-121.6327 37.2220
+-121.6263 37.2123
+-121.6250 37.2022
+-121.6137 37.1947
+-121.6060 37.1843
+-121.5987 37.1752
+-121.5882 37.1647
+-121.5782 37.1532
+-121.5647 37.1398
+-121.5518 37.1247
+-121.5408 37.1118
+-121.5328 37.0992
+-121.5255 37.0868
+-121.5157 37.0703
+-121.5063 37.0563
+-121.4947 37.0358
+-121.4852 37.0197
+-121.4748 37.0008
+-121.4647 36.9818
+-121.4557 36.9645
+-121.4465 36.9447
+-121.4375 36.9292
+-121.4322 36.9137
+-121.4250 36.8958
+-121.4172 36.8807
+-121.4112 36.8705
+-121.4052 36.8600
+-121.3987 36.8492
+-121.3875 36.8363
+>
+-122.6838 37.8983
+-122.6868 37.8868
+-122.6828 37.8688
+-122.6778 37.8538
+-122.6732 37.8392
+-122.6665 37.8228
+-122.6570 37.8045
+-122.6485 37.7897
+-122.6382 37.7722
+-122.6277 37.7587
+-122.6193 37.7478
+-122.6098 37.7343
+-122.6013 37.7232
+-122.5902 37.7077
+-122.5820 37.6878
+-122.5783 37.6737
+-122.5758 37.6570
+-122.5695 37.6407
+-122.5623 37.6192
+-122.5562 37.6013
+-122.5492 37.5852
+-122.5447 37.5702
+-122.5392 37.5547
+-122.5333 37.5400
+-122.5162 37.5197
+-122.5063 37.5103
+-122.4962 37.5013
+-122.4887 37.4952
+-122.4773 37.4822
+-122.4677 37.4708
+-122.4578 37.4533
+-122.4477 37.4333
+-122.4357 37.4147
+-122.4292 37.4023
+-122.4215 37.3893
+-122.4170 37.3767
+-122.4133 37.3678
+-122.4092 37.3588
+-122.3997 37.3408
+>
+-122.3873 37.3155
+-122.3785 37.2968
+-122.3712 37.2698
+-122.3678 37.2500
+-122.3618 37.2377
+-122.3567 37.2233
+-122.3512 37.2068
+-122.3468 37.1858
+-122.3402 37.1687
+-122.3338 37.1550
+-122.3252 37.1368
+-122.3128 37.1145
+-122.3007 37.0927
+-122.2905 37.0737
+-122.2778 37.0518
+-122.2690 37.0358
+-122.2578 37.0123
+-122.2458 36.9893
+-122.2363 36.9687
+-122.2290 36.9518
+-122.2173 36.9272
+-122.2105 36.9132
+-122.2023 36.9022
+-122.1963 36.8875
+-122.1825 36.8652
+-122.1732 36.8402
+-122.1675 36.8213
+-122.1557 36.7935
+-122.1483 36.7752
+-122.1342 36.7353
+-122.1238 36.7137
+-122.1128 36.6915
+-122.0977 36.6622
+-122.0798 36.6367
+-122.0658 36.6143
+-122.0547 36.5955
+-122.0468 36.5847
+-122.0367 36.5713
+-122.0253 36.5622
+-121.9983 36.5315
+-121.9888 36.5218
+-121.9817 36.5000
+-121.9725 36.4858
+-121.9670 36.4715
+-121.9503 36.4405
+-121.9442 36.4347
+-121.9352 36.4293
+>
+-122.3785 38.0000
+-122.3680 38.0000
+-122.3500 37.9933
+-122.3422 37.9850
+-122.3343 37.9753
+-122.3297 37.9692
+-122.3238 37.9617
+-122.3180 37.9552
+-122.3108 37.9487
+-122.3040 37.9428
+-122.2985 37.9373
+-122.2908 37.9308
+-122.2850 37.9253
+-122.2813 37.9178
+-122.2762 37.9103
+-122.2703 37.9003
+-122.2653 37.8910
+-122.2592 37.8833
+-122.2533 37.8757
+-122.2465 37.8678
+-122.2343 37.8573
+-122.2282 37.8508
+-122.2232 37.8435
+-122.2168 37.8345
+-122.2127 37.8242
+-122.2070 37.8148
+-122.1963 37.8042
+-122.1878 37.7923
+-122.1783 37.7812
+-122.1727 37.7740
+-122.1630 37.7613
+-122.1538 37.7522
+-122.1427 37.7402
+-122.1332 37.7292
+-122.1252 37.7188
+-122.1170 37.7092
+-122.1087 37.7002
+-122.0957 37.6882
+-122.0813 37.6755
+-122.0688 37.6627
+-122.0573 37.6512
+-122.0453 37.6382
+-122.0313 37.6250
+-122.0187 37.6132
+-122.0077 37.6002
+-121.9975 37.5852
+-121.9873 37.5733
+-121.9763 37.5578
+-121.9683 37.5468
+-121.9603 37.5377
+-121.9477 37.5252
+-121.9380 37.5168
+-121.9300 37.5093
+-121.9203 37.4992
+-121.9107 37.4893
+-121.8978 37.4740
+-121.8848 37.4615
+-121.8735 37.4503
+-121.8627 37.4400
+-121.8525 37.4300
+-121.8383 37.4178
+-121.8277 37.4070
+-121.8147 37.3950
+-121.8042 37.3853
+-121.7922 37.3738
+-121.7822 37.3632
+-121.7707 37.3507
+-121.7590 37.3362
+-121.7478 37.3212
+-121.7383 37.3053
+-121.7307 37.2910
+-121.7215 37.2695
+>
+-122.0812 38.0000
+-122.0667 38.0000
+-122.0502 37.9990
+-122.0430 37.9897
+-122.0367 37.9798
+-122.0303 37.9692
+-122.0252 37.9607
+-122.0180 37.9495
+-122.0103 37.9378
+-122.0030 37.9253
+-121.9948 37.9148
+-121.9867 37.9048
+-121.9787 37.8970
+-121.9672 37.8843
+>
+-122.1592 38.2293
+-122.1503 38.2072
+-122.1455 38.1952
+-122.1375 38.1790
+-122.1295 38.1603
+-122.1178 38.1383
+-122.1115 38.1262
+-122.1043 38.1143
+-122.0977 38.0978
+-122.0827 38.0663
+>
+-122.7093 38.4630
+-122.7038 38.4548
+-122.6975 38.4472
+-122.6927 38.4402
+-122.6848 38.4313
+-122.6782 38.4238
+-122.6725 38.4168
+-122.6653 38.4102
+-122.6580 38.4020
+-122.6500 38.3933
+-122.6448 38.3855
+-122.6405 38.3780
+-122.6368 38.3705
+-122.6317 38.3617
+-122.6242 38.3523
+-122.6173 38.3448
+-122.6098 38.3367
+-122.6032 38.3292
+-122.5963 38.3202
+-122.5893 38.3117
+-122.5833 38.3058
+-122.5762 38.2990
+-122.5648 38.2898
+-122.5562 38.2812
+-122.5467 38.2753
+-122.5327 38.2638
+-122.5242 38.2567
+-122.5127 38.2447
+-122.5058 38.2360
+-122.4988 38.2277
+-122.4917 38.2192
+-122.4832 38.2073
+-122.4747 38.1978
+-122.4637 38.1862
+-122.4567 38.1775
+-122.4502 38.1683
+-122.4452 38.1635
+-122.4368 38.1543
+>
+-122.9202 38.6923
+-122.9108 38.6858
+-122.9023 38.6803
+-122.8947 38.6732
+-122.8875 38.6662
+-122.8827 38.6605
+-122.8762 38.6528
+-122.8662 38.6442
+-122.8583 38.6358
+-122.8533 38.6303
+-122.8460 38.6237
+-122.8392 38.6177
+-122.8318 38.6115
+-122.8262 38.6050
+-122.8183 38.5978
+-122.8118 38.5913
+-122.8037 38.5833
+-122.7937 38.5725
+-122.7835 38.5602
+-122.7748 38.5498
+-122.7657 38.5385
+-122.7548 38.5263
+-122.7443 38.5157
+-122.7357 38.5050
+-122.7250 38.4933
+-122.7175 38.4843
+-122.7113 38.4772
+-122.7028 38.4653
+>
+-122.9330 38.8230
+-122.9258 38.8262
+-122.9157 38.8270
+-122.9083 38.8240
+-122.9028 38.8197
+-122.8958 38.8163
+-122.8880 38.8142
+-122.8785 38.8132
+-122.8737 38.8085
+-122.8658 38.8060
+-122.8615 38.8007
+-122.8538 38.7978
+-122.8465 38.7950
+-122.8383 38.7927
+-122.8305 38.7897
+-122.8240 38.7855
+-122.8178 38.7810
+-122.8115 38.7772
+-122.8088 38.7707
+-122.8030 38.7668
+-122.7970 38.7630
+-122.7870 38.7622
+-122.7792 38.7593
+-122.7718 38.7560
+-122.7658 38.7508
+>
+-119.8055 38.8557
+-119.7960 38.8452
+-119.7912 38.8340
+-119.7912 38.8223
+-119.7960 38.8102
+-119.7980 38.7982
+-119.7998 38.7882
+-119.8025 38.7765
+-119.8057 38.7500
+-119.8145 38.7458
+-119.8212 38.7342
+-119.8248 38.7282
+-119.8295 38.7177
+-119.8300 38.7028
+-119.8273 38.6833
+-119.8225 38.6663
+-119.8168 38.6472
+-119.8095 38.6308
+-119.8038 38.6193
+-119.7968 38.6068
+-119.7903 38.6005
+-119.7827 38.5937
+-119.7798 38.5835
+-119.7782 38.5650
+>
+-119.5482 38.6793
+-119.5412 38.6625
+-119.5323 38.6442
+-119.5268 38.6242
+-119.5195 38.6053
+-119.5158 38.5880
+-119.5087 38.5667
+-119.4993 38.5473
+-119.4878 38.5258
+-119.4783 38.5117
+-119.4695 38.5005
+>
+-119.1875 38.1587
+-119.1827 38.1368
+-119.1828 38.1183
+-119.1807 38.0997
+-119.1772 38.0803
+-119.1768 38.0658
+-119.1768 38.0495
+-119.1727 38.0330
+-119.1635 38.0152
+-119.1498 37.9973
+-119.1407 37.9852
+-119.1272 37.9677
+-119.1107 37.9495
+-119.1008 37.9382
+-119.0878 37.9195
+>
+-119.0532 37.7957
+-119.0385 37.7767
+-119.0233 37.7565
+-119.0088 37.7338
+-118.9952 37.7072
+-118.9902 37.6878
+-118.9843 37.6742
+-118.9788 37.6593
+>
+-117.0335 35.4912
+-117.0038 35.4860
+-116.9710 35.4785
+-116.9338 35.4730
+-116.8973 35.4708
+-116.8602 35.4687
+-116.8273 35.4683
+-116.7815 35.4653
+-116.7508 35.4628
+-116.7272 35.4678
+-116.6798 35.4627
+-116.6595 35.4595
+-116.6302 35.4563
+-116.5995 35.4523
+-116.5640 35.4475
+-116.5292 35.4453
+-116.4878 35.4352
+-116.4553 35.4348
+-116.4210 35.4292
+-116.3847 35.4178
+-116.3622 35.3750
+-116.3450 35.3750
+>
+-116.7798 35.3317
+-116.7545 35.3298
+-116.7278 35.3282
+-116.6995 35.3282
+-116.6723 35.3243
+-116.6400 35.3233
+-116.6128 35.3238
+-116.5773 35.3283
+-116.5577 35.3282
+-116.5272 35.3297
+-116.5068 35.3317
+-116.4773 35.3317
+-116.4490 35.3338
+-116.4273 35.3347
+-116.4022 35.3332
+-116.3863 35.3307
+-116.3678 35.3282
+-116.3492 35.3282
+>
+-122.7975 38.8838
+-122.7927 38.8767
+-122.7877 38.8717
+-122.7813 38.8678
+-122.7752 38.8640
+-122.7672 38.8575
+-122.7613 38.8527
+-122.7565 38.8470
+-122.7522 38.8418
+-122.7470 38.8373
+-122.7413 38.8323
+-122.7357 38.8282
+-122.7298 38.8233
+-122.7240 38.8177
+-122.7180 38.8122
+-122.7122 38.8058
+-122.7060 38.8007
+-122.6983 38.7957
+-122.6918 38.7917
+-122.6822 38.7873
+-122.6725 38.7858
+>
+-123.6960 39.0070
+-123.6920 39.0010
+-123.6870 38.9950
+-123.6830 38.9890
+-123.6780 38.9830
+-123.6740 38.9770
+-123.6700 38.9710
+-123.6650 38.9650
+-123.6600 38.9600
+-123.6560 38.9540
+-123.6510 38.9490
+-123.6460 38.9430
+-123.6420 38.9370
+-123.6380 38.9310
+-123.6330 38.9260
+-123.6270 38.9210
+-123.6200 38.9180
+-123.6150 38.9120
+-123.6100 38.9070
+-123.6060 38.9010
+-123.6010 38.8960
+-123.5960 38.8900
+-123.5880 38.8810
+-123.5830 38.8760
+-123.5790 38.8700
+-123.5750 38.8640
+-123.5700 38.8590
+-123.5660 38.8530
+-123.5610 38.8480
+-123.5560 38.8430
+-123.5510 38.8370
+-123.5460 38.8310
+-123.5410 38.8260
+-123.5360 38.8210
+-123.5310 38.8150
+-123.5250 38.8110
+-123.5210 38.8040
+-123.5160 38.7980
+-123.5110 38.7930
+-123.5060 38.7880
+-123.4990 38.7840
+-123.4950 38.7780
+-123.4900 38.7720
+-123.4850 38.7670
+-123.4790 38.7630
+-123.4760 38.7560
+-123.4710 38.7510
+-123.4660 38.7460
+-123.4600 38.7420
+-123.4550 38.7360
+-123.4500 38.7310
+-123.4450 38.7260
+-123.4400 38.7210
+-123.4350 38.7160
+-123.4300 38.7110
+-123.4250 38.7050
+-123.4200 38.7000
+-123.4150 38.6950
+-123.4100 38.6900
+-123.4050 38.6840
+-123.4000 38.6790
+-123.3940 38.6740
+-123.3880 38.6690
+-123.3840 38.6630
+-123.3790 38.6580
+-123.3740 38.6530
+-123.3680 38.6480
+-123.3630 38.6430
+-123.3570 38.6380
+-123.3510 38.6330
+-123.3460 38.6280
+-123.3410 38.6230
+-123.3360 38.6180
+-123.3300 38.6130
+-123.3250 38.6070
+-123.3190 38.6020
+-123.3150 38.5960
+-123.3100 38.5900
+-123.3050 38.5840
+-123.2990 38.5790
+-123.2930 38.5750
+-123.2880 38.5700
+-123.2840 38.5640
+-123.2790 38.5590
+-123.2730 38.5540
+-123.2670 38.5490
+-123.2620 38.5430
+-123.2570 38.5380
+-123.2500 38.5330
+-123.2450 38.5280
+-123.2400 38.5230
+-123.2340 38.5180
+-123.2290 38.5130
+-123.2240 38.5080
+-123.2190 38.5020
+-123.0740 38.3930
+-123.0740 38.3840
+-123.0730 38.3760
+-122.8740 38.1320
+-122.8690 38.1270
+-122.8640 38.1210
+-122.8590 38.1150
+-122.8540 38.1100
+-122.8490 38.1050
+-122.8440 38.0990
+-122.8390 38.0930
+-122.8340 38.0870
+-122.8290 38.0820
+-122.8240 38.0770
+-122.8200 38.0710
+-122.8150 38.0650
+-122.8100 38.0600
+-122.8050 38.0540
+-122.8010 38.0480
+-122.7970 38.0420
+-122.7920 38.0360
+-122.7870 38.0300
+-122.7820 38.0240
+-122.7770 38.0180
+-122.7720 38.0120
+-122.7670 38.0060
+-122.7610 38.0010
+-122.7560 37.9960
+-122.7500 37.9900
+-122.7440 37.9850
+-122.7390 37.9800
+-122.7340 37.9750
+-122.7290 37.9700
+-122.7240 37.9640
+-122.7200 37.9580
+-122.7150 37.9520
+-122.7110 37.9460
+-122.7060 37.9410
+-122.7020 37.9350
+-122.6970 37.9300
+-122.6920 37.9240
+-122.6870 37.9190
+-122.6820 37.9140
+-122.6770 37.9090
+-122.4940 37.6720
+-122.4890 37.6660
+-122.4830 37.6610
+-122.4770 37.6560
+-122.4720 37.6510
+-122.4670 37.6460
+-122.4620 37.6410
+-122.4570 37.6360
+-122.4520 37.6310
+-122.4470 37.6250
+-122.4420 37.6200
+-122.4380 37.6140
+-122.4330 37.6080
+-122.4280 37.6030
+-122.4240 37.5970
+-122.4190 37.5910
+-122.4150 37.5850
+-122.4100 37.5800
+-122.4050 37.5740
+-122.4000 37.5680
+-122.3950 37.5620
+-122.3900 37.5560
+-122.3850 37.5510
+-122.3810 37.5450
+-122.3760 37.5400
+-122.3700 37.5360
+-122.3660 37.5300
+-122.3620 37.5240
+-122.3570 37.5180
+-122.3520 37.5120
+-122.3470 37.5070
+-122.3420 37.5020
+-122.3380 37.4950
+-122.3320 37.4890
+-122.3270 37.4830
+-122.3210 37.4790
+-122.3160 37.4740
+-122.3110 37.4680
+-122.3060 37.4630
+-122.3010 37.4580
+-122.2950 37.4530
+-122.2900 37.4480
+-122.2850 37.4430
+-122.2800 37.4370
+-122.2750 37.4320
+-122.2690 37.4270
+-122.2640 37.4220
+-122.2590 37.4160
+-122.2540 37.4100
+-122.2490 37.4050
+-122.2440 37.4000
+-122.2390 37.3940
+-122.2340 37.3880
+-122.2290 37.3820
+-122.2250 37.3760
+-122.2200 37.3700
+-122.2150 37.3650
+-122.2090 37.3610
+-122.2050 37.3550
+-122.2000 37.3500
+-122.1940 37.3450
+-122.1890 37.3400
+-122.1840 37.3340
+-122.1790 37.3290
+-122.1740 37.3240
+-122.1680 37.3200
+-122.1620 37.3150
+-122.1570 37.3100
+-122.1510 37.3050
+-122.1450 37.3010
+-122.1390 37.2970
+-122.1330 37.2930
+-122.1270 37.2880
+-122.1210 37.2840
+-122.1150 37.2790
+-122.1090 37.2740
+-122.1030 37.2690
+-122.0970 37.2650
+-122.0920 37.2600
+-122.0870 37.2540
+-122.0810 37.2490
+-122.0750 37.2440
+-122.0690 37.2390
+-122.0640 37.2340
+-122.0590 37.2290
+-122.0540 37.2240
+-122.0490 37.2180
+-122.0430 37.2130
+-122.0370 37.2090
+-122.0310 37.2050
+-122.0250 37.2000
+-122.0200 37.1950
+-122.0140 37.1900
+-122.0080 37.1860
+-122.0010 37.1820
+-121.9950 37.1770
+-121.9890 37.1720
+-121.9840 37.1660
+-121.9790 37.1610
+-121.9740 37.1560
+-121.9680 37.1510
+-121.9620 37.1470
+-121.9560 37.1420
+-121.9500 37.1380
+-121.9440 37.1330
+-121.9380 37.1280
+-121.9310 37.1240
+-121.9250 37.1190
+-121.9180 37.1150
+-121.9120 37.1110
+-121.9050 37.1080
+-121.9000 37.1030
+-121.8940 37.0980
+-121.8880 37.0930
+-121.8800 37.0910
+-121.8720 37.0890
+-121.8640 37.0870
+-121.8570 37.0830
+-121.8500 37.0790
+-121.8450 37.0740
+-121.8390 37.0700
+-121.8330 37.0660
+-121.8270 37.0620
+-121.8210 37.0580
+-121.8140 37.0550
+-121.8070 37.0510
+-121.8000 37.0470
+-121.7930 37.0430
+-121.7860 37.0390
+-121.7800 37.0350
+-121.7750 37.0300
+-121.7690 37.0260
+-121.7650 37.0200
+-121.7590 37.0150
+-121.7520 37.0110
+-121.7460 37.0070
+-121.7420 37.0010
+-121.7380 36.9950
+-121.7330 36.9900
+-121.7280 36.9850
+-121.7220 36.9810
+-121.7160 36.9760
+-121.7100 36.9720
+-121.7050 36.9670
+-121.6990 36.9620
+-121.6920 36.9570
+-121.6860 36.9520
+-121.6800 36.9470
+-121.6740 36.9420
+-121.6690 36.9370
+-121.6630 36.9330
+-121.6570 36.9290
+-121.6500 36.9260
+-121.6440 36.9220
+-121.6390 36.9170
+-121.6310 36.9140
+-121.6240 36.9110
+-121.6190 36.9060
+-121.6120 36.9020
+-121.6070 36.8970
+-121.6020 36.8910
+-121.5960 36.8870
+-121.5880 36.8840
+-121.5820 36.8800
+-121.5750 36.8760
+-121.5690 36.8720
+-121.5630 36.8680
+-121.5570 36.8640
+-121.5510 36.8600
+-121.5460 36.8550
+-121.5400 36.8510
+-121.5340 36.8470
+-121.5280 36.8420
+-121.5230 36.8370
+-121.5170 36.8330
+-121.5110 36.8280
+-121.5050 36.8240
+-121.4980 36.8200
+-121.4920 36.8160
+-121.4850 36.8120
+-121.4800 36.8070
+-121.4730 36.8040
+-121.4680 36.7990
+-121.4610 36.7960
+-121.4540 36.7920
+-121.4470 36.7880
+-121.4400 36.7840
+-121.4340 36.7800
+-121.4280 36.7760
+-121.4220 36.7720
+-121.4150 36.7680
+-121.4090 36.7640
+-121.4020 36.7600
+-121.3960 36.7560
+-121.3890 36.7530
+-121.3830 36.7480
+-121.3760 36.7450
+-121.3700 36.7400
+-121.3630 36.7360
+-121.3570 36.7310
+-121.3510 36.7260
+-121.3450 36.7220
+-121.3390 36.7180
+-121.3340 36.7130
+-121.3280 36.7080
+-121.3220 36.7040
+-121.3150 36.7000
+-121.3090 36.6960
+-121.3030 36.6920
+-121.2990 36.6860
+-121.2920 36.6830
+-121.2860 36.6790
+-121.2810 36.6740
+-121.2750 36.6700
+-121.2700 36.6650
+-121.2640 36.6610
+-121.2580 36.6570
+-121.2530 36.6520
+-121.2480 36.6470
+-121.2420 36.6420
+-121.2370 36.6370
+-121.2310 36.6320
+-121.2250 36.6270
+-121.2190 36.6220
+-121.2140 36.6170
+-121.2080 36.6120
+-121.2020 36.6070
+-121.1970 36.6020
+-121.1910 36.5980
+-121.1850 36.5930
+-121.1800 36.5880
+-121.1740 36.5830
+-121.1680 36.5790
+-121.1620 36.5750
+-121.1560 36.5700
+-121.1510 36.5650
+-121.1460 36.5600
+-121.1410 36.5550
+-121.1360 36.5500
+-121.1320 36.5440
+-121.1270 36.5390
+-121.1230 36.5330
+-121.1170 36.5280
+-121.1110 36.5230
+-121.1050 36.5180
+-121.1010 36.5120
+-121.0950 36.5070
+-121.0890 36.5030
+-121.0840 36.4970
+-121.0790 36.4920
+-121.0730 36.4870
+-121.0680 36.4820
+-121.0620 36.4770
+-121.0570 36.4710
+-121.0520 36.4660
+-121.0470 36.4610
+-121.0420 36.4560
+-121.0370 36.4510
+-121.0310 36.4460
+-121.0260 36.4400
+-121.0200 36.4360
+-121.0150 36.4310
+-121.0100 36.4260
+-121.0040 36.4210
+-120.9980 36.4160
+-120.9950 36.4090
+-120.9900 36.4040
+-120.9840 36.3990
+-120.9800 36.3930
+-120.9750 36.3880
+-120.9700 36.3830
+-120.9650 36.3780
+-120.9600 36.3730
+-120.9550 36.3680
+-120.9500 36.3630
+-120.9450 36.3580
+-120.9410 36.3520
+-120.9360 36.3460
+-120.9300 36.3420
+-120.9240 36.3370
+-120.9180 36.3330
+-120.9130 36.3280
+-120.9080 36.3230
+-120.9030 36.3180
+-120.8970 36.3140
+-120.8920 36.3090
+-120.8880 36.3030
+-120.8850 36.2970
+-120.8800 36.2920
+-120.8740 36.2870
+-120.8680 36.2820
+-120.8630 36.2770
+-120.8570 36.2720
+-120.8510 36.2680
+-120.8450 36.2640
+-120.8390 36.2590
+-120.8340 36.2530
+-120.8310 36.2470
+-120.8260 36.2420
+-120.8210 36.2370
+-120.8150 36.2320
+-120.8090 36.2270
+-120.8030 36.2230
+-120.7980 36.2180
+-120.7930 36.2130
+-120.7880 36.2070
+-120.7830 36.2020
+-120.7760 36.1990
+-120.7700 36.1940
+-120.7640 36.1890
+-120.7590 36.1840
+-120.7550 36.1780
+-120.7500 36.1730
+-120.7450 36.1680
+-120.7390 36.1640
+-120.7330 36.1590
+-120.7270 36.1550
+-120.7220 36.1500
+-120.7160 36.1450
+-120.7100 36.1400
+-120.7040 36.1360
+-120.6990 36.1300
+-120.6930 36.1250
+-120.6870 36.1210
+-120.6830 36.1150
+-120.6780 36.1100
+-120.6730 36.1040
+-120.6670 36.1000
+-120.6610 36.0950
+-120.6560 36.0900
+-120.6510 36.0850
+-120.6460 36.0800
+-120.6400 36.0760
+-120.6340 36.0710
+-120.6280 36.0660
+-120.6230 36.0600
+-120.6180 36.0550
+-120.6130 36.0490
+-120.6070 36.0440
+-120.6010 36.0390
+-120.5940 36.0330
+-120.5890 36.0280
+-120.5840 36.0230
+-120.5790 36.0180
+-120.5730 36.0140
+-120.5670 36.0100
+-120.5610 36.0060
+-120.5550 36.0020
+-120.5510 35.9960
+-120.5450 35.9920
+-120.5390 35.9870
+-120.5340 35.9820
+-120.5280 35.9770
+-120.5220 35.9730
+-120.5160 35.9680
+-120.5110 35.9630
+-120.5050 35.9590
+-120.4990 35.9550
+-120.4930 35.9500
+-120.4880 35.9450
+-120.4820 35.9400
+-120.4760 35.9350
+-120.4710 35.9300
+-120.4650 35.9260
+-120.4600 35.9210
+-120.4550 35.9160
+-120.4500 35.9110
+-120.4450 35.9060
+-120.4400 35.9010
+-120.4340 35.8960
+-120.4290 35.8910
+-120.4230 35.8860
+-120.4180 35.8810
+-120.4130 35.8760
+-120.4070 35.8710
+-120.4010 35.8660
+-120.3950 35.8620
+-120.3900 35.8570
+-120.3840 35.8520
+-120.3790 35.8470
+-120.3730 35.8420
+-120.3680 35.8370
+-120.3610 35.8330
+-120.3560 35.8270
+-120.3510 35.8220
+-120.3460 35.8170
+-120.3430 35.8100
+-120.3380 35.8040
+-120.3330 35.7990
+-120.3280 35.7930
+-120.3240 35.7870
+-120.3210 35.7810
+-120.3190 35.7740
+-120.3160 35.7670
+-120.3110 35.7620
+-120.3070 35.7560
+-120.3020 35.7510
+-120.2970 35.7460
+-120.2920 35.7410
+-120.2880 35.7350
+-120.2830 35.7290
+-120.2780 35.7230
+-120.2730 35.7170
+-120.2680 35.7120
+-120.2620 35.7080
+-120.2570 35.7030
+-120.2510 35.6990
+-120.2460 35.6940
+-120.2410 35.6890
+-120.2370 35.6830
+-120.2320 35.6780
+-120.2270 35.6730
+-120.2220 35.6680
+-120.2160 35.6630
+-120.2110 35.6580
+-120.2050 35.6530
+-120.2000 35.6480
+-120.1950 35.6420
+-120.1890 35.6380
+-120.1840 35.6330
+-120.1790 35.6280
+-120.1740 35.6230
+-120.1690 35.6180
+-120.1640 35.6130
+-120.1590 35.6080
+-120.1540 35.6030
+-120.1480 35.5990
+-120.1430 35.5940
+-120.1380 35.5890
+-120.1330 35.5840
+-120.1280 35.5790
+-120.1230 35.5740
+-120.1170 35.5690
+-120.1120 35.5640
+-120.1070 35.5590
+-120.1020 35.5530
+-120.0970 35.5480
+-120.0920 35.5430
+-120.0870 35.5380
+-120.0820 35.5330
+-120.0760 35.5280
+-120.0710 35.5230
+-120.0660 35.5180
+-120.0600 35.5120
+-120.0550 35.5070
+-120.0490 35.5020
+-120.0450 35.4960
+-120.0400 35.4910
+-120.0350 35.4860
+-120.0290 35.4810
+-120.0240 35.4750
+-120.0190 35.4700
+-120.0140 35.4650
+-120.0100 35.4590
+-120.0050 35.4540
+-120.0010 35.4480
+-119.9960 35.4430
+-119.9910 35.4370
+-119.9870 35.4310
+-119.9820 35.4260
+-119.9770 35.4210
+-119.9720 35.4160
+-119.9670 35.4110
+-119.9620 35.4060
+-119.9570 35.4000
+-119.9520 35.3950
+-119.9460 35.3900
+-119.9410 35.3850
+-119.9360 35.3800
+-119.9310 35.3750
+-119.9250 35.3700
+-119.9200 35.3650
+-119.9150 35.3600
+-119.9090 35.3550
+-119.9040 35.3500
+-119.8990 35.3450
+-119.8940 35.3390
+-119.8890 35.3340
+-119.8840 35.3290
+-119.8790 35.3230
+-119.8740 35.3180
+-119.8690 35.3130
+-119.8640 35.3080
+-119.8590 35.3030
+-119.8530 35.2980
+-119.8480 35.2930
+-119.8430 35.2880
+-119.8380 35.2830
+-119.8330 35.2780
+-119.8280 35.2730
+-119.8230 35.2680
+-119.8170 35.2630
+-119.8120 35.2580
+-119.8070 35.2530
+-119.8010 35.2480
+-119.7960 35.2430
+-119.7900 35.2380
+-119.7850 35.2330
+-119.7790 35.2280
+-119.7740 35.2230
+-119.7690 35.2180
+-119.7640 35.2130
+-119.7590 35.2080
+-119.7530 35.2030
+-119.7480 35.1980
+-119.7420 35.1930
+-119.7370 35.1880
+-119.7310 35.1830
+-119.7260 35.1780
+-119.7200 35.1730
+-119.7140 35.1680
+-119.7090 35.1630
+-119.7030 35.1580
+-119.6970 35.1540
+-119.6910 35.1500
+-119.6860 35.1450
+-119.6800 35.1410
+-119.6740 35.1370
+-119.6680 35.1330
+-119.6620 35.1280
+-119.6560 35.1240
+-119.6500 35.1190
+-119.6440 35.1150
+-119.6390 35.1100
+-119.6330 35.1060
+-119.6270 35.1010
+-119.6220 35.0950
+-119.6160 35.0900
+-119.6100 35.0850
+-119.6050 35.0800
+-119.5990 35.0760
+-119.5920 35.0700
+-119.5860 35.0660
+-119.5800 35.0610
+-119.5740 35.0560
+-119.5680 35.0520
+-119.5620 35.0470
+-119.5560 35.0430
+-119.5510 35.0380
+-119.5440 35.0340
+-119.5380 35.0300
+-119.5320 35.0260
+-119.5260 35.0220
+-119.5200 35.0180
+-119.5130 35.0130
+-119.5070 35.0090
+-119.5010 35.0050
+-119.4950 35.0010
+-119.4890 34.9970
+-119.4830 34.9930
+-119.4770 34.9880
+-119.4710 34.9840
+-119.4650 34.9800
+-119.4590 34.9760
+-119.4530 34.9710
+-119.4470 34.9670
+-119.4420 34.9620
+-119.4360 34.9570
+-119.4290 34.9530
+-119.4220 34.9490
+-119.4150 34.9460
+-119.4090 34.9420
+-119.4010 34.9390
+-119.3950 34.9350
+-119.3890 34.9300
+-119.3820 34.9260
+-119.3750 34.9230
+-119.3690 34.9190
+-119.3610 34.9160
+-119.3540 34.9130
+-119.3470 34.9090
+-119.3390 34.9070
+-119.3320 34.9040
+-119.3250 34.9010
+-119.3170 34.8980
+-119.3090 34.8960
+-119.3020 34.8930
+-119.2950 34.8900
+-119.2870 34.8870
+-119.2790 34.8840
+-119.2710 34.8820
+-119.2630 34.8800
+-119.2560 34.8770
+-119.2480 34.8740
+-119.2390 34.8730
+-119.2320 34.8700
+-119.2240 34.8680
+-119.2160 34.8660
+-119.2070 34.8650
+-119.1990 34.8620
+-119.1900 34.8610
+-119.1810 34.8590
+-119.1720 34.8580
+-119.1630 34.8570
+-119.1540 34.8560
+-119.1450 34.8550
+-119.1350 34.8540
+-119.1260 34.8530
+-119.1160 34.8520
+-119.1080 34.8500
+-119.0990 34.8490
+-119.0910 34.8470
+-119.0840 34.8440
+-119.0760 34.8420
+-119.0670 34.8400
+-119.0590 34.8380
+-119.0510 34.8360
+-119.0430 34.8340
+-119.0350 34.8320
+-119.0270 34.8290
+-119.0190 34.8270
+-119.0100 34.8250
+-119.0010 34.8230
+-118.9920 34.8210
+-118.9810 34.8210
+-118.9700 34.8210
+-118.9580 34.8210
+-118.9470 34.8210
+-118.9380 34.8200
+-118.9290 34.8190
+-118.9220 34.8160
+-118.9130 34.8150
+-118.9050 34.8130
+-118.8970 34.8110
+-118.8900 34.8080
+-118.8820 34.8050
+-118.8750 34.8020
+-118.8670 34.7990
+-118.8590 34.7970
+-118.8500 34.7950
+-118.8410 34.7930
+-118.8330 34.7910
+-118.8260 34.7880
+-118.8180 34.7860
+-118.8100 34.7830
+-118.8020 34.7810
+-118.7940 34.7790
+-118.7860 34.7770
+-118.7780 34.7750
+-118.7700 34.7730
+-118.7620 34.7710
+-118.7530 34.7700
+-118.7450 34.7680
+-118.7370 34.7660
+-118.7300 34.7630
+-118.7220 34.7610
+-118.7140 34.7590
+-118.7070 34.7560
+-118.7000 34.7530
+-118.6920 34.7510
+-118.6850 34.7480
+-118.6770 34.7460
+-118.6690 34.7440
+-118.6620 34.7410
+-118.6540 34.7390
+-118.6460 34.7370
+-118.6380 34.7340
+-118.6290 34.7320
+-118.6200 34.7300
+-118.6120 34.7280
+-118.6040 34.7260
+-118.5960 34.7240
+-118.5880 34.7210
+-118.5800 34.7190
+-118.5730 34.7160
+-118.5650 34.7140
+-118.5570 34.7120
+-118.5490 34.7100
+-118.5410 34.7080
+-118.5330 34.7060
+-118.5260 34.7030
+-118.5180 34.7010
+-118.5100 34.6990
+-118.5020 34.6970
+-118.4950 34.6940
+-118.4870 34.6920
+-118.4790 34.6890
+-118.4710 34.6860
+-118.4630 34.6830
+-118.4560 34.6800
+-118.4490 34.6770
+-118.4410 34.6750
+-118.4330 34.6730
+-118.4260 34.6700
+-118.4180 34.6670
+-118.4100 34.6640
+-118.4020 34.6610
+-118.3940 34.6590
+-118.3870 34.6560
+-118.3790 34.6530
+-118.3720 34.6500
+-118.3640 34.6470
+-118.3570 34.6440
+-118.3490 34.6410
+-118.3410 34.6390
+-118.3350 34.6350
+-118.3270 34.6320
+-118.3190 34.6300
+-118.3120 34.6270
+-118.3040 34.6250
+-118.2970 34.6220
+-118.2890 34.6190
+-118.2820 34.6160
+-118.2740 34.6140
+-118.2670 34.6110
+-118.2600 34.6080
+-118.2530 34.6050
+-118.2450 34.6020
+-118.2370 34.6000
+-118.2300 34.5970
+-118.2220 34.5950
+-118.2140 34.5920
+-118.2060 34.5890
+-118.1980 34.5860
+-118.1910 34.5830
+-118.1830 34.5800
+-118.1760 34.5760
+-118.1690 34.5730
+-118.1610 34.5710
+-118.1530 34.5680
+-118.1460 34.5650
+-118.1390 34.5620
+-118.1310 34.5590
+-118.1240 34.5560
+-118.1170 34.5520
+-118.1100 34.5490
+-118.1020 34.5460
+-118.0940 34.5430
+-118.0860 34.5400
+-118.0790 34.5370
+-118.0720 34.5340
+-118.0640 34.5320
+-118.0570 34.5280
+-118.0500 34.5250
+-118.0430 34.5220
+-118.0360 34.5190
+-118.0290 34.5160
+-118.0220 34.5130
+-118.0140 34.5110
+-118.0070 34.5070
+-118.0000 34.5040
+-117.9920 34.5010
+-117.9840 34.4980
+-117.9770 34.4950
+-117.9690 34.4920
+-117.9620 34.4890
+-117.9550 34.4860
+-117.9470 34.4830
+-117.9400 34.4800
+-117.9330 34.4770
+-117.9260 34.4740
+-117.9190 34.4710
+-117.9120 34.4680
+-117.9050 34.4640
+-117.8970 34.4610
+-117.8900 34.4580
+-117.8820 34.4550
+-117.8740 34.4520
+-117.8670 34.4490
+-117.8600 34.4460
+-117.8530 34.4430
+-117.8460 34.4400
+-117.8400 34.4360
+-117.8330 34.4330
+-117.8250 34.4310
+-117.8180 34.4280
+-117.8100 34.4260
+-117.8020 34.4230
+-117.7940 34.4210
+-117.7870 34.4180
+-117.7800 34.4150
+-117.7720 34.4120
+-117.7650 34.4090
+-117.7580 34.4050
+-117.7510 34.4020
+-117.7430 34.3990
+-117.7360 34.3960
+-117.7280 34.3940
+-117.7210 34.3910
+-117.7140 34.3880
+-117.7060 34.3860
+-117.7000 34.3820
+-117.6920 34.3800
+-117.6850 34.3770
+-117.6780 34.3740
+-117.6710 34.3710
+-117.6620 34.3680
+-117.6540 34.3650
+-117.6470 34.3620
+-117.6390 34.3590
+-117.6320 34.3560
+-117.6250 34.3520
+-117.6180 34.3490
+-117.6100 34.3460
+-117.6030 34.3420
+-117.5960 34.3380
+-117.5890 34.3340
+-117.5820 34.3300
+-117.5750 34.3270
+-117.5680 34.3240
+-117.5610 34.3210
+-117.5540 34.3180
+-117.5470 34.3150
+-117.5410 34.3110
+-117.5340 34.3080
+-117.5270 34.3050
+-117.5200 34.3020
+-117.5130 34.2990
+-117.5060 34.2960
+-117.5000 34.2920
+-117.4940 34.2880
+-117.4870 34.2840
+-117.4800 34.2810
+-117.4730 34.2780
+-117.4670 34.2740
+-117.4600 34.2700
+-117.4530 34.2660
+-117.4460 34.2620
+-117.4400 34.2580
+-117.4330 34.2540
+-117.4260 34.2500
+-117.4190 34.2470
+-117.4120 34.2430
+-117.4050 34.2390
+-117.3980 34.2360
+-117.3920 34.2320
+-117.3860 34.2280
+-117.3800 34.2240
+-117.3730 34.2200
+-117.3660 34.2170
+-117.3590 34.2140
+-117.3520 34.2110
+-117.3450 34.2080
+-117.3380 34.2040
+-117.3300 34.2000
+-117.3230 34.1970
+-117.3160 34.1930
+-117.3090 34.1900
+-117.3020 34.1860
+-117.2950 34.1830
+-117.2880 34.1800
+-117.2810 34.1760
+-117.2740 34.1730
+-117.2670 34.1690
+-117.2600 34.1660
+-117.2530 34.1630
+-117.2470 34.1590
+-117.2400 34.1560
+-117.2320 34.1540
+-117.2250 34.1510
+-117.2180 34.1480
+-117.2100 34.1450
+-117.2030 34.1420
+-117.1960 34.1390
+-117.1890 34.1360
+-117.1820 34.1330
+-117.1750 34.1300
+-117.1670 34.1270
+-117.1600 34.1240
+-117.1530 34.1210
+-117.1450 34.1190
+-117.1370 34.1160
+-117.1300 34.1130
+-117.1240 34.1090
+-117.1160 34.1060
+-117.1060 34.1040
+-117.0990 34.1010
+-117.0910 34.0990
+-117.0830 34.0970
+-117.0750 34.0950
+-117.0660 34.0930
+-117.0590 34.0900
+-117.0510 34.0880
+-117.0430 34.0850
+-117.0350 34.0820
+-117.0280 34.0790
+-117.0200 34.0770
+-117.0130 34.0740
+-117.0050 34.0720
+-116.9980 34.0690
+-116.9920 34.0650
+-116.9820 34.0640
+-116.9740 34.0620
+-116.9670 34.0590
+-116.9590 34.0570
+-116.9520 34.0540
+-116.9440 34.0510
+-116.9370 34.0480
+-116.9290 34.0460
+-116.9220 34.0430
+-116.9150 34.0400
+-116.9080 34.0370
+-116.9010 34.0340
+-116.8930 34.0320
+-116.8840 34.0330
+-116.8750 34.0340
+-116.8660 34.0360
+-116.8590 34.0390
+-116.8530 34.0430
+-116.8470 34.0470
+-116.8370 34.0450
+-116.8270 34.0450
+-116.8180 34.0460
+-116.8080 34.0450
+-116.7980 34.0450
+-116.7900 34.0470
+-116.7810 34.0480
+-116.7710 34.0480
+-116.7610 34.0470
+-116.7530 34.0490
+-116.7430 34.0480
+-116.7330 34.0470
+-116.7230 34.0470
+-116.7150 34.0450
+-116.7050 34.0440
+-116.6960 34.0450
+-116.6880 34.0420
+-116.6800 34.0390
+-116.6730 34.0360
+-116.6650 34.0330
+-116.6580 34.0300
+-116.6500 34.0280
+-116.6420 34.0260
+-116.6340 34.0240
+-116.6260 34.0220
+-116.6170 34.0230
+-116.6090 34.0210
+-116.6020 34.0180
+-116.5940 34.0160
+-116.5860 34.0130
+-116.5790 34.0100
+-116.5720 34.0070
+-116.5650 34.0030
+-116.5580 33.9990
+-116.5510 33.9950
+-116.5440 33.9920
+-116.5380 33.9880
+-116.5320 33.9840
+-116.5260 33.9800
+-116.5200 33.9750
+-116.5140 33.9700
+-116.5080 33.9660
+-116.5030 33.9610
+-116.4970 33.9570
+-116.4920 33.9520
+-116.4860 33.9480
+-116.4800 33.9430
+-116.4740 33.9390
+-116.4680 33.9350
+-116.4610 33.9310
+-116.4540 33.9270
+-116.4480 33.9230
+-116.4420 33.9190
+-116.4360 33.9150
+-116.4300 33.9110
+-116.4240 33.9070
+-116.4170 33.9030
+-116.4100 33.8990
+-116.4030 33.8960
+-116.3970 33.8920
+-116.3900 33.8880
+-116.3840 33.8830
+-116.3770 33.8800
+-116.3700 33.8770
+-116.3640 33.8730
+-116.3560 33.8710
+-116.3490 33.8680
+-116.3430 33.8640
+-116.3370 33.8600
+-116.3310 33.8560
+-116.3250 33.8510
+-116.3190 33.8460
+-116.3130 33.8410
+-116.3070 33.8360
+-116.3020 33.8310
+-116.2960 33.8270
+-116.2900 33.8220
+-116.2850 33.8170
+-116.2790 33.8130
+-116.2740 33.8080
+-116.2680 33.8040
+-116.2610 33.7980
+-116.2540 33.7940
+-116.2480 33.7900
+-116.2430 33.7850
+-116.2380 33.7800
+-116.2320 33.7760
+-116.2260 33.7720
+-116.2200 33.7680
+-116.2140 33.7630
+-116.2080 33.7590
+-116.2020 33.7540
+-116.1960 33.7500
+-116.1910 33.7450
+-116.1850 33.7410
+-116.1790 33.7360
+-116.1730 33.7310
+-116.1680 33.7260
+-116.1630 33.7210
+-116.1580 33.7160
+-116.1520 33.7110
+-116.1450 33.7080
+-116.1390 33.7030
+-116.1330 33.6980
+-116.1270 33.6940
+-116.1220 33.6890
+-116.1170 33.6840
+-116.1130 33.6790
+-116.1070 33.6740
+-116.1000 33.6690
+-116.0950 33.6640
+-116.0900 33.6590
+-116.0850 33.6540
+-116.0790 33.6500
+-116.0740 33.6450
+-116.0680 33.6410
+-116.0620 33.6370
+-116.0560 33.6330
+-116.0500 33.6270
+-116.0440 33.6220
+-116.0380 33.6180
+-116.0320 33.6130
+-116.0260 33.6090
+-116.0210 33.6040
+-116.0140 33.6000
+-116.0080 33.5960
+-116.0020 33.5910
+-115.9970 33.5860
+-115.9920 33.5810
+-115.9870 33.5760
+-115.9810 33.5710
+-115.9760 33.5660
+-115.9710 33.5610
+-115.9660 33.5560
+-115.9600 33.5520
+-115.9540 33.5460
+-115.9490 33.5410
+-115.9440 33.5360
+-115.9380 33.5310
+-115.9330 33.5260
+-115.9280 33.5210
+-115.9220 33.5160
+-115.9170 33.5110
+-115.9110 33.5060
+-115.9060 33.5010
+-115.9020 33.4960
+-115.8960 33.4910
+-115.8910 33.4860
+-115.8860 33.4810
+-115.8800 33.4770
+-115.8740 33.4730
+-115.8680 33.4690
+-115.8620 33.4640
+-115.8560 33.4590
+-115.8500 33.4540
+-115.8440 33.4490
+-115.8370 33.4450
+-115.8310 33.4400
+-115.8250 33.4350
+-115.8180 33.4300
+-115.8120 33.4250
+-115.8040 33.4200
+-115.7980 33.4160
+-115.7920 33.4110
+-115.7860 33.4070
+-115.7800 33.4030
+-115.7740 33.3980
+-115.7680 33.3940
+-115.7620 33.3900
+-115.7560 33.3850
+-115.7500 33.3800
+-115.7440 33.3760
+-115.7380 33.3720
+-115.7320 33.3680
+-115.7260 33.3630
+>
+-123.5437 39.7442
+-123.5392 39.7352
+-123.5332 39.7278
+-123.5282 39.7178
+-123.5213 39.7067
+-123.5143 39.6980
+-123.5095 39.6893
+-123.5037 39.6802
+-123.4972 39.6713
+-123.4910 39.6612
+-123.4848 39.6523
+-123.4787 39.6393
+-123.4738 39.6297
+-123.4683 39.6208
+-123.4625 39.6103
+-123.4578 39.5993
+-123.4508 39.5863
+-123.4457 39.5740
+-123.4387 39.5615
+-123.4322 39.5507
+-123.4252 39.5400
+-123.4173 39.5287
+-123.4087 39.5177
+-123.3997 39.5055
+-123.3918 39.4928
+-123.3867 39.4802
+-123.3802 39.4677
+-123.3737 39.4572
+-123.3645 39.4428
+-123.3547 39.4312
+-123.3468 39.4188
+-123.3387 39.4068
+-123.3293 39.3933
+-123.3207 39.3810
+-123.3112 39.3677
+-123.3042 39.3572
+-123.2968 39.3462
+-123.2870 39.3360
+-123.2757 39.3200
+-123.2638 39.3043
+-123.2538 39.2893
+-123.2440 39.2742
+-123.2363 39.2613
+-123.2245 39.2412
+-123.2170 39.2272
+-123.2095 39.2157
+-123.1993 39.2007
+-123.1913 39.1875
+-123.1827 39.1757
+-123.1732 39.1602
+-123.1655 39.1433
+-123.1607 39.1298
+-123.1567 39.1173
+-123.1492 39.1043
+-123.1388 39.0905
+-123.1307 39.0802
+-123.1237 39.0692
+-123.1177 39.0537
+-123.1110 39.0402
+-123.0997 39.0243
+-123.0890 39.0115
+-123.0778 39.0013
+-123.0633 38.9862
+-123.0532 38.9743
+-123.0450 38.9655
+-123.0405 38.9532
+-123.0383 38.9402
+-123.0363 38.9263
+-123.0340 38.9133
+-123.0327 38.8962
+-123.0323 38.8832
+-123.0302 38.8690
+-123.0258 38.8547
+>
+-124.0747 40.0447
+-124.0697 40.0388
+-124.0652 40.0312
+-124.0607 40.0247
+-124.0572 40.0185
+-124.0498 40.0098
+-124.0430 40.0033
+-124.0367 39.9922
+-124.0323 39.9832
+-124.0293 39.9752
+-124.0238 39.9603
+-124.0210 39.9525
+-124.0167 39.9372
+-124.0138 39.9292
+-124.0118 39.9212
+-124.0092 39.9105
+-124.0070 39.9005
+-124.0048 39.8903
+-124.0017 39.8727
+-124.0005 39.8572
+-123.9997 39.8477
+-124.0005 39.8392
+-123.9995 39.8293
+-124.0000 39.8187
+-124.0008 39.8063
+-123.9998 39.7967
+-123.9998 39.7882
+-124.0007 39.7783
+-124.0012 39.7668
+-124.0010 39.7542
+-124.0017 39.7442
+-124.0020 39.7362
+-124.0012 39.7228
+-123.9990 39.7122
+-123.9967 39.7013
+-123.9945 39.6903
+-123.9913 39.6743
+-123.9878 39.6638
+-123.9865 39.6523
+-123.9858 39.6415
+-123.9842 39.6322
+-123.9827 39.6232
+-123.9802 39.6132
+-123.9790 39.6033
+-123.9767 39.5927
+-123.9742 39.5807
+-123.9723 39.5715
+-123.9707 39.5625
+-123.9662 39.5502
+-123.9602 39.5268
+-123.9573 39.5145
+-123.9507 39.4942
+-123.9463 39.4818
+-123.9437 39.4708
+-123.9418 39.4630
+-123.9393 39.4538
+-123.9368 39.4438
+-123.9315 39.4268
+-123.9272 39.4162
+-123.9252 39.4077
+-123.9217 39.3992
+-123.9182 39.3888
+-123.9127 39.3750
+-123.9088 39.3637
+-123.9042 39.3520
+-123.8998 39.3410
+-123.8957 39.3282
+-123.8930 39.3177
+-123.8828 39.2937
+-123.8770 39.2785
+-123.8725 39.2657
+-123.8662 39.2518
+-123.8602 39.2400
+-123.8548 39.2282
+-123.8488 39.2182
+-123.8403 39.2072
+-123.8328 39.1973
+-123.8263 39.1875
+-123.8193 39.1775
+-123.8113 39.1678
+-123.8048 39.1623
+-123.7975 39.1517
+-123.7907 39.1437
+-123.7840 39.1368
+-123.7743 39.1252
+-123.7675 39.1143
+-123.7618 39.1038
+-123.7582 39.0937
+-123.7533 39.0840
+-123.7500 39.0747
+-123.7422 39.0648
+-123.7332 39.0515
+-123.7288 39.0407
+-123.7247 39.0332
+-123.7162 39.0203
+-123.7113 39.0130
+-123.7008 39.0023
+-123.6917 38.9908
+-123.6848 38.9823
+-123.6785 38.9765
+-123.6718 38.9692
+>
+-120.0958 40.1028
+-120.0947 40.0887
+-120.0935 40.0787
+-120.0932 40.0688
+-120.0918 40.0573
+-120.0902 40.0483
+-120.0872 40.0403
+>
+-120.1883 40.1660
+-120.1787 40.1605
+-120.1695 40.1535
+-120.1593 40.1468
+-120.1493 40.1437
+-120.1325 40.1382
+-120.1253 40.1342
+-120.1170 40.1285
+-120.1077 40.1250
+-120.0908 40.1110
+-120.0857 40.1055
+-120.0790 40.1003
+-120.0705 40.0947
+-120.0613 40.0885
+-120.0547 40.0852
+-120.0408 40.0792
+-120.0338 40.0733
+-120.0240 40.0653
+-120.0152 40.0613
+-120.0025 40.0570
+>
+-120.5053 40.2820
+-120.4973 40.2752
+-120.4892 40.2675
+-120.4802 40.2585
+-120.4688 40.2502
+-120.4568 40.2413
+-120.4468 40.2313
+-120.4345 40.2188
+-120.4233 40.2100
+-120.4085 40.2000
+-120.3970 40.1912
+-120.3788 40.1802
+-120.3638 40.1727
+-120.3468 40.1655
+-120.3283 40.1568
+-120.3125 40.1512
+-120.3037 40.1475
+-120.2853 40.1422
+-120.2682 40.1338
+-120.2535 40.1253
+-120.2345 40.1142
+-120.2157 40.1003
+-120.1988 40.0858
+-120.1912 40.0802
+-120.1805 40.0733
+-120.1685 40.0653
+-120.1543 40.0522
+-120.1413 40.0378
+-120.1310 40.0263
+-120.1193 40.0145
+-120.1068 39.9998
+-120.0948 39.9848
+-120.0857 39.9667
+-120.0782 39.9543
+-120.0738 39.9455
+-120.0683 39.9365
+>
+-125.0000 40.3692
+-124.9787 40.3645
+-124.9608 40.3622
+-124.9423 40.3613
+-124.9222 40.3607
+-124.8993 40.3593
+-124.8753 40.3592
+-124.8553 40.3583
+-124.8297 40.3578
+-124.8043 40.3567
+-124.7830 40.3558
+-124.7538 40.3530
+-124.7303 40.3523
+-124.6833 40.3507
+-124.6603 40.3505
+-124.6387 40.3540
+-124.6182 40.3567
+-124.5973 40.3590
+-124.5788 40.3618
+-124.5548 40.3662
+-124.5287 40.3695
+-124.5015 40.3687
+-124.4795 40.3683
+-124.4602 40.3678
+-124.4443 40.3663
+>
+-124.9522 40.3593
+-124.9382 40.3553
+-124.9257 40.3520
+-124.9098 40.3490
+-124.8937 40.3458
+-124.8785 40.3418
+-124.8633 40.3377
+-124.8438 40.3340
+-124.8288 40.3303
+-124.8127 40.3273
+-124.7942 40.3233
+-124.7793 40.3193
+-124.7593 40.3158
+-124.7393 40.3137
+-124.7178 40.3103
+-124.7000 40.3062
+-124.6787 40.3022
+-124.6552 40.2998
+-124.6348 40.2980
+-124.6138 40.2965
+-124.5937 40.2938
+-124.5753 40.2902
+-124.5517 40.2852
+-124.5312 40.2812
+-124.5108 40.2772
+-124.4877 40.2723
+-124.4602 40.2640
+-124.4390 40.2572
+-124.4143 40.2483
+-124.3932 40.2398
+-124.3713 40.2305
+-124.3497 40.2202
+-124.3327 40.2117
+-124.3142 40.2005
+-124.2908 40.1873
+-124.2707 40.1758
+-124.2537 40.1660
+-124.2303 40.1503
+-124.2203 40.1420
+-124.2068 40.1312
+-124.1903 40.1210
+-124.1762 40.1133
+-124.1628 40.1052
+-124.1470 40.0940
+-124.1303 40.0840
+-124.1140 40.0740
+-124.0988 40.0623
+-124.0875 40.0522
+-124.0798 40.0447
+>
+-120.9993 41.5652
+-120.9953 41.5565
+-120.9905 41.5450
+-120.9853 41.5350
+-120.9758 41.5182
+-120.9707 41.5043
+-120.9627 41.4932
+-120.9562 41.4827
+-120.9477 41.4735
+-120.9432 41.4683
+-120.9375 41.4627
+-120.9283 41.4573
+-120.9218 41.4533
+-120.9142 41.4473
+-120.9077 41.4413
+-120.9003 41.4362
+-120.8930 41.4313
+-120.8847 41.4280
+-120.8727 41.4210
+-120.8663 41.4165
+-120.8593 41.4113
+-120.8468 41.4017
+-120.8388 41.3967
+-120.8298 41.3912
+-120.8212 41.3857
+-120.8117 41.3818
+-120.8018 41.3765
+-120.7910 41.3685
+-120.7853 41.3643
+-120.7738 41.3577
+-120.7655 41.3505
+-120.7592 41.3445
+-120.7492 41.3382
+-120.7430 41.3342
+-120.7350 41.3272
+-120.7245 41.3193
+-120.7168 41.3132
+-120.7092 41.3067
+-120.6988 41.2977
+-120.6908 41.2912
+-120.6837 41.2852
+-120.6718 41.2767
+-120.6632 41.2713
+-120.6523 41.2623
+-120.6425 41.2532
+-120.6250 41.2500
+-120.6250 41.2338
+-120.6092 41.2173
+-120.6023 41.2090
+-120.5930 41.2023
+-120.5852 41.1968
+-120.5767 41.1895
+-120.5700 41.1822
+-120.5613 41.1737
+-120.5545 41.1652
+-120.5468 41.1587
+-120.5410 41.1533
+-120.5330 41.1448
+-120.5247 41.1368
+-120.5183 41.1307
+-120.5132 41.1257
+-120.5073 41.1193
+-120.5023 41.1138
+-120.4960 41.1072
+-120.4897 41.1013
+-120.4832 41.0947
+-120.4747 41.0877
+-120.4638 41.0802
+-120.4543 41.0740
+-120.4427 41.0625
+-120.4352 41.0592
+-120.4268 41.0513
+-120.4207 41.0447
+-120.4127 41.0357
+-120.4067 41.0277
+-120.3993 41.0177
+-120.3918 41.0082
+-120.3847 40.9978
+-120.3803 40.9920
+-120.3747 40.9840
+-120.3687 40.9737
+-120.3522 40.9573
+-120.3328 40.9455
+-120.3193 40.9348
+-120.3090 40.9285
+-120.2977 40.9218
+-120.2837 40.9127
+-120.2602 40.8997
+>
+-120.1510 41.8858
+-120.1537 41.8737
+-120.1560 41.8593
+-120.1592 41.8508
+-120.1627 41.8383
+-120.1663 41.8248
+-120.1688 41.8075
+-120.1717 41.8008
+-120.1772 41.7852
+-120.1817 41.7728
+-120.1833 41.7657
+-120.1875 41.7523
+-120.1920 41.7385
+-120.1953 41.7302
+-120.1995 41.7177
+-120.2038 41.7032
+-120.2072 41.6910
+-120.2112 41.6798
+-120.2158 41.6670
+-120.2158 41.6548
+-120.2130 41.6432
+-120.2108 41.6355
+-120.2033 41.6250
+-120.2013 41.6133
+-120.1873 41.5828
+-120.1888 41.5652
+-120.1932 41.5345
+-120.1943 41.5230
+-120.1943 41.5068
+-120.1903 41.4950
+-120.1877 41.4853
+-120.1775 41.4577
+-120.1713 41.4467
+-120.1698 41.4343
+-120.1658 41.4207
+-120.1627 41.4127
+-120.1563 41.4002
+-120.1513 41.3923
+-120.1468 41.3823
+-120.1388 41.3633
+-120.1303 41.3342
+-120.1295 41.3197
+-120.1277 41.3123
+-120.1247 41.3048
+-120.1208 41.2983
+-120.0992 41.2713
+-120.0933 41.2643
+-120.0842 41.2537
+-120.0733 41.2308
+-120.0702 41.2223
+-120.0660 41.2132
+-120.0598 41.2038
+-120.0553 41.1975
+-120.0500 41.1907
+-120.0443 41.1818
+-120.0373 41.1712
+-120.0297 41.1637
+-120.0217 41.1570
+-120.0152 41.1498
+-120.0062 41.1413
+>

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_coast
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_coast	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_coast	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,810 @@
+    36.9609000   -122.0000000 
+    36.9542000   -121.9730000 
+    36.9707000   -121.9540000 
+    36.9772000   -121.9400000 
+    36.9775000   -121.9300000 
+    36.9634000   -121.8980000 
+    36.9316000   -121.8640000 
+    36.8537000   -121.8150000 
+    36.8514000   -121.8100000 
+    36.8074000   -121.7900000 
+    36.7571000   -121.8050000 
+    36.7525000   -121.8040000 
+    36.7518000   -121.8080000 
+    36.7126000   -121.8090000 
+    36.6807000   -121.8160000 
+    36.6479000   -121.8320000 
+    36.6124000   -121.8600000 
+    36.6042000   -121.8750000 
+    36.6025000   -121.8880000 
+    36.6232000   -121.9030000 
+    36.6251000   -121.9130000 
+    36.6366000   -121.9240000 
+    36.6390000   -121.9350000 
+    36.6365000   -121.9400000 
+    36.6295000   -121.9390000 
+    36.6268000   -121.9440000 
+    36.6119000   -121.9490000 
+    36.6116000   -121.9570000 
+    36.6082000   -121.9610000 
+    36.5849000   -121.9680000 
+    36.5850000   -121.9740000 
+    36.5805000   -121.9800000 
+    36.5685000   -121.9720000 
+    36.5592000   -121.9530000 
+    36.5650000   -121.9490000 
+    36.5642000   -121.9430000 
+    36.5605000   -121.9420000 
+    36.5610000   -121.9360000 
+    36.5520000   -121.9310000 
+    36.5394000   -121.9340000 
+    36.5358000   -121.9290000 
+    36.5264000   -121.9270000 
+    36.5250000   -121.9380000 
+    36.5219000   -121.9400000 
+    36.5251000   -121.9550000 
+    36.5205000   -121.9560000 
+    36.5049000   -121.9410000 
+    36.4984000   -121.9390000 
+    36.4916000   -121.9470000 
+    36.4882000   -121.9430000 
+    36.4696000   -121.9370000 
+    36.4602000   -121.9280000 
+    36.4484000   -121.9300000 
+    36.4258000   -121.9160000 
+    36.4172000   -121.9190000 
+    36.4024000   -121.9150000 
+    36.3979000   -121.9070000 
+    36.3924000   -121.9040000 
+    36.3819000   -121.9040000 
+    36.3737000   -121.9080000 
+    36.3645000   -121.9040000 
+    36.3565000   -121.9080000 
+    36.3374000   -121.8930000 
+    36.3132000   -121.8970000 
+    36.3086000   -121.9000000 
+    36.3087000   -121.9040000 
+    36.3043000   -121.9030000 
+    36.3017000   -121.8880000 
+    36.2888000   -121.8760000 
+    36.2794000   -121.8620000 
+    36.2766000   -121.8520000 
+    36.2594000   -121.8400000 
+    36.2477000   -121.8360000 
+    36.2385000   -121.8170000 
+    36.2342000   -121.8140000 
+    36.2317000   -121.8060000 
+    36.2334000   -121.7970000 
+    36.2276000   -121.7870000 
+    36.2270000   -121.7800000 
+    36.2101000   -121.7540000 
+    36.2100000   -121.7480000 
+    36.1950000   -121.7180000 
+    36.1745000   -121.6990000 
+    36.1620000   -121.6770000 
+    36.1261000   -121.6460000 
+    36.1193000   -121.6350000 
+    36.1018000   -121.6250000 
+    36.0866000   -121.6220000 
+    36.0710000   -121.6070000 
+    36.0633000   -121.5940000 
+    36.0529000   -121.5910000 
+    36.0485000   -121.5940000 
+    36.0416000   -121.5840000 
+    36.0217000   -121.5740000 
+    36.0184000   -121.5670000 
+    36.0185000   -121.5530000 
+    36.0142000   -121.5360000 
+    36.0000000   -121.5050000 
+    35.9700000   -121.4880000 
+    35.9501000   -121.4850000 
+    35.9336000   -121.4760000 
+    35.9302000   -121.4790000 
+    35.9265000   -121.4700000 
+    35.9234000   -121.4700000 
+    35.9190000   -121.4760000 
+    35.8968000   -121.4630000 
+    35.8878000   -121.4650000 
+    35.8704000   -121.4470000 
+    35.8587000   -121.4260000 
+    35.8558000   -121.4150000 
+    35.8218000   -121.3880000 
+    35.8158000   -121.3760000 
+    35.8103000   -121.3730000 
+    35.8050000   -121.3580000 
+    35.7834000   -121.3330000 
+    35.7698000   -121.3260000 
+    35.7599000   -121.3280000 
+    35.7553000   -121.3180000 
+    35.7497000   -121.3160000 
+    35.7452000   -121.3210000 
+    35.7377000   -121.3170000 
+    35.7272000   -121.3190000 
+    35.7209000   -121.3140000 
+    35.7144000   -121.3180000 
+    35.6926000   -121.2930000 
+    35.6643000   -121.2850000 
+    35.6671000   -121.2810000 
+    35.6662000   -121.2720000 
+    35.6638000   -121.2610000 
+    35.6543000   -121.2500000 
+    35.6521000   -121.2430000 
+    35.6510000   -121.2200000 
+    35.6343000   -121.1960000 
+    35.6359000   -121.1930000 
+    35.6410000   -121.1940000 
+    35.6428000   -121.1910000 
+    35.6366000   -121.1690000 
+    35.6056000   -121.1450000 
+    35.6000000   -121.1330000 
+    35.5929000   -121.1260000 
+    35.5828000   -121.1230000 
+    35.5756000   -121.1150000 
+    35.5605000   -121.1070000 
+    35.5517000   -121.1050000 
+    35.5095000   -121.0610000 
+    35.5033000   -121.0480000 
+    35.4900000   -121.0400000 
+    35.4834000   -121.0260000 
+    35.4600000   -121.0060000 
+    35.4588000   -120.9700000 
+    35.4513000   -120.9540000 
+    35.4463000   -120.9500000 
+    35.4480000   -120.9070000 
+    35.4312000   -120.8860000 
+    35.3971000   -120.8670000 
+    35.3814000   -120.8630000 
+    35.3740000   -120.8650000 
+    35.3722000   -120.8720000 
+    35.3680000   -120.8720000 
+    35.3672000   -120.8680000 
+    35.3723000   -120.8630000 
+    35.3712000   -120.8580000 
+    35.3425000   -120.8430000 
+    35.3404000   -120.8360000 
+    35.3424000   -120.8340000 
+    35.3389000   -120.8280000 
+    35.3330000   -120.8350000 
+    35.3324000   -120.8450000 
+    35.3239000   -120.8450000 
+    35.3195000   -120.8620000 
+    35.3146000   -120.8670000 
+    35.3263000   -120.8610000 
+    35.3446000   -120.8580000 
+    35.3688000   -120.8590000 
+    35.3700000   -120.8630000 
+    35.3480000   -120.8640000 
+    35.3165000   -120.8730000 
+    35.2946000   -120.8820000 
+    35.2812000   -120.8920000 
+    35.2755000   -120.8920000 
+    35.2750000   -120.8960000 
+    35.2623000   -120.8960000 
+    35.2571000   -120.9010000 
+    35.2498000   -120.8980000 
+    35.2478000   -120.9000000 
+    35.2344000   -120.8870000 
+    35.2313000   -120.8800000 
+    35.2190000   -120.8700000 
+    35.2164000   -120.8620000 
+    35.2132000   -120.8630000 
+    35.2090000   -120.8590000 
+    35.1872000   -120.8150000 
+    35.1779000   -120.7870000 
+    35.1680000   -120.7800000 
+    35.1624000   -120.7700000 
+    35.1593000   -120.7540000 
+    35.1716000   -120.7560000 
+    35.1781000   -120.7490000 
+    35.1789000   -120.7360000 
+    35.1742000   -120.7260000 
+    35.1745000   -120.7060000 
+    35.1581000   -120.6850000 
+    35.1530000   -120.6730000 
+    35.1514000   -120.6580000 
+    35.1438000   -120.6470000 
+    35.1351000   -120.6410000 
+    35.1040000   -120.6310000 
+    35.0513000   -120.6320000 
+    34.9858000   -120.6460000 
+    34.9393000   -120.6620000 
+    34.9304000   -120.6690000 
+    34.9262000   -120.6650000 
+    34.9026000   -120.6740000 
+    34.8999000   -120.6730000 
+    34.9000000   -120.6480000 
+    34.8879000   -120.6410000 
+    34.8807000   -120.6420000 
+    34.8616000   -120.6130000 
+    34.8407000   -120.6120000 
+    34.8076000   -120.6200000 
+    34.7578000   -120.6400000 
+    34.7495000   -120.6310000 
+    34.7451000   -120.6330000 
+    34.7385000   -120.6290000 
+    34.7316000   -120.6170000 
+    34.7129000   -120.6090000 
+    34.7073000   -120.6020000 
+    34.6932000   -120.6040000 
+    34.6924000   -120.5990000 
+    34.6895000   -120.6070000 
+    34.6498000   -120.6200000 
+    34.6112000   -120.6380000 
+    34.6037000   -120.6450000 
+    34.5924000   -120.6430000 
+    34.5861000   -120.6480000 
+    34.5790000   -120.6470000 
+    34.5765000   -120.6530000 
+    34.5715000   -120.6410000 
+    34.5637000   -120.6420000 
+    34.5594000   -120.6390000 
+    34.5606000   -120.6340000 
+    34.5534000   -120.6250000 
+    34.5523000   -120.6180000 
+    34.5570000   -120.6020000 
+    34.5566000   -120.5820000 
+    34.5506000   -120.5680000 
+    34.5400000   -120.5550000 
+    34.5391000   -120.5420000 
+    34.5233000   -120.5120000 
+    34.5123000   -120.5030000 
+    34.4942000   -120.4980000 
+    34.4923000   -120.4930000 
+    34.4880000   -120.4920000 
+    34.4807000   -120.4810000 
+    34.4743000   -120.4770000 
+    34.4481000   -120.4730000 
+    34.4483000   -120.4640000 
+    34.4417000   -120.4550000 
+    34.4510000   -120.4450000 
+    34.4492000   -120.4210000 
+    34.4526000   -120.4180000 
+    34.4542000   -120.4090000 
+    34.4584000   -120.3380000 
+    34.4615000   -120.3340000 
+    34.4657000   -120.3040000 
+    34.4698000   -120.2970000 
+    34.4665000   -120.2770000 
+    34.4709000   -120.2190000 
+    34.4682000   -120.1720000 
+    34.4734000   -120.1410000 
+    34.4699000   -120.1170000 
+    34.4599000   -120.0930000 
+    34.4590000   -120.0790000 
+    34.4631000   -120.0690000 
+    34.4608000   -120.0610000 
+    34.4624000   -120.0340000 
+    34.4574000   -120.0230000 
+    34.4618000   -120.0170000 
+    34.4601000   -120.0060000 
+    34.4558000   -120.0000000 
+    34.4558000   -120.0000000 
+    34.4491000   -119.9910000 
+    34.4482000   -119.9810000 
+    34.4357000   -119.9580000 
+    34.4348000   -119.9300000 
+    34.4316000   -119.9210000 
+    34.4166000   -119.8890000 
+    34.4067000   -119.8810000 
+    34.4085000   -119.8640000 
+    34.4033000   -119.8450000 
+    34.4143000   -119.8380000 
+    34.4167000   -119.7960000 
+    34.4017000   -119.7440000 
+    34.3941000   -119.7280000 
+    34.3941000   -119.7140000 
+    34.3952000   -119.7050000 
+    34.4008000   -119.6990000 
+    34.4027000   -119.6920000 
+    34.4073000   -119.6930000 
+    34.4116000   -119.6880000 
+    34.4151000   -119.6730000 
+    34.4150000   -119.6350000 
+    34.4201000   -119.6150000 
+    34.4184000   -119.5980000 
+    34.4116000   -119.5800000 
+    34.4142000   -119.5660000 
+    34.3952000   -119.5380000 
+    34.3933000   -119.5280000 
+    34.3861000   -119.5160000 
+    34.3818000   -119.4900000 
+    34.3720000   -119.4800000 
+    34.3752000   -119.4720000 
+    34.3717000   -119.4590000 
+    34.3544000   -119.4450000 
+    34.3541000   -119.4310000 
+    34.3176000   -119.3920000 
+    34.3193000   -119.3730000 
+    34.3024000   -119.3500000 
+    34.2901000   -119.3410000 
+    34.2826000   -119.3220000 
+    34.2777000   -119.3180000 
+    34.2726000   -119.3050000 
+    34.2732000   -119.2890000 
+    34.2616000   -119.2760000 
+    34.2512000   -119.2720000 
+    34.2510000   -119.2680000 
+    34.2445000   -119.2600000 
+    34.2402000   -119.2650000 
+    34.2473000   -119.2670000 
+    34.2459000   -119.2710000 
+    34.2232000   -119.2650000 
+    34.1675000   -119.2360000 
+    34.1497000   -119.2230000 
+    34.1442000   -119.2160000 
+    34.1416000   -119.1960000 
+    34.0992000   -119.1330000 
+    34.0932000   -119.1090000 
+    34.0983000   -119.0990000 
+    34.0976000   -119.0900000 
+    34.0840000   -119.0640000 
+    34.0815000   -119.0380000 
+    34.0651000   -119.0100000 
+    34.0659000   -119.0030000 
+    34.0588000   -118.9800000 
+    34.0464000   -118.9560000 
+    34.0422000   -118.9400000 
+    34.0447000   -118.9270000 
+    34.0406000   -118.9180000 
+    34.0382000   -118.8780000 
+    34.0331000   -118.8510000 
+    34.0002000   -118.8080000 
+    34.0057000   -118.8040000 
+    34.0086000   -118.7940000 
+    34.0206000   -118.7860000 
+    34.0257000   -118.7570000 
+    34.0332000   -118.7430000 
+    34.0288000   -118.7100000 
+    34.0314000   -118.7000000 
+    34.0306000   -118.6830000 
+    34.0381000   -118.6730000 
+    34.0355000   -118.6120000 
+    34.0390000   -118.6010000 
+    34.0367000   -118.5860000 
+    34.0399000   -118.5740000 
+    34.0374000   -118.5450000 
+    34.0338000   -118.5350000 
+    34.0287000   -118.5240000 
+    34.0118000   -118.5010000 
+    34.0067000   -118.4990000 
+    34.0064000   -118.4940000 
+    34.0000000   -118.4870000 
+    34.0000000   -118.4870000 
+    34.0000000   -118.4870000 
+    33.9950000   -118.4860000 
+    33.9916000   -118.4790000 
+    33.9858000   -118.4770000 
+    33.9646000   -118.4580000 
+    33.9691000   -118.4490000 
+    33.9720000   -118.4490000 
+    33.9725000   -118.4530000 
+    33.9733000   -118.4490000 
+    33.9775000   -118.4520000 
+    33.9783000   -118.4490000 
+    33.9800000   -118.4530000 
+    33.9825000   -118.4500000 
+    33.9838000   -118.4540000 
+    33.9821000   -118.4460000 
+    33.9775000   -118.4460000 
+    33.9767000   -118.4430000 
+    33.9679000   -118.4470000 
+    33.9617000   -118.4570000 
+    33.8842000   -118.4130000 
+    33.8475000   -118.4000000 
+    33.8408000   -118.3930000 
+    33.8067000   -118.3950000 
+    33.8013000   -118.4080000 
+    33.7925000   -118.4100000 
+    33.7837000   -118.4260000 
+    33.7758000   -118.4300000 
+    33.7541000   -118.4160000 
+    33.7421000   -118.4130000 
+    33.7421000   -118.4060000 
+    33.7370000   -118.4000000 
+    33.7429000   -118.3870000 
+    33.7429000   -118.3810000 
+    33.7371000   -118.3760000 
+    33.7387000   -118.3640000 
+    33.7346000   -118.3570000 
+    33.7279000   -118.3530000 
+    33.7187000   -118.3240000 
+    33.7146000   -118.3200000 
+    33.7104000   -118.3010000 
+    33.7054000   -118.2960000 
+    33.7054000   -118.2890000 
+    33.7100000   -118.2810000 
+    33.7141000   -118.2850000 
+    33.7183000   -118.2810000 
+    33.7246000   -118.2830000 
+    33.7137000   -118.2760000 
+    33.7150000   -118.2730000 
+    33.7208000   -118.2750000 
+    33.7217000   -118.2700000 
+    33.7375000   -118.2790000 
+    33.7491000   -118.2770000 
+    33.7525000   -118.2730000 
+    33.7562000   -118.2800000 
+    33.7550000   -118.2880000 
+    33.7579000   -118.2780000 
+    33.7667000   -118.2780000 
+    33.7679000   -118.2730000 
+    33.7558000   -118.2750000 
+    33.7546000   -118.2710000 
+    33.7596000   -118.2700000 
+    33.7545000   -118.2670000 
+    33.7600000   -118.2610000 
+    33.7662000   -118.2630000 
+    33.7629000   -118.2590000 
+    33.7671000   -118.2540000 
+    33.7654000   -118.2490000 
+    33.7729000   -118.2230000 
+    33.7696000   -118.2210000 
+    33.7717000   -118.2130000 
+    33.7663000   -118.2220000 
+    33.7696000   -118.2240000 
+    33.7696000   -118.2300000 
+    33.7654000   -118.2480000 
+    33.7529000   -118.2690000 
+    33.7358000   -118.2760000 
+    33.7221000   -118.2680000 
+    33.7233000   -118.2650000 
+    33.7325000   -118.2690000 
+    33.7379000   -118.2680000 
+    33.7317000   -118.2650000 
+    33.7313000   -118.2620000 
+    33.7467000   -118.2540000 
+    33.7512000   -118.2480000 
+    33.7441000   -118.2450000 
+    33.7412000   -118.2390000 
+    33.7396000   -118.2310000 
+    33.7429000   -118.2230000 
+    33.7454000   -118.2230000 
+    33.7429000   -118.2300000 
+    33.7446000   -118.2420000 
+    33.7500000   -118.2440000 
+    33.7554000   -118.2280000 
+    33.7520000   -118.2220000 
+    33.7621000   -118.2150000 
+    33.7570000   -118.2140000 
+    33.7604000   -118.2110000 
+    33.7592000   -118.2090000 
+    33.7558000   -118.2090000 
+    33.7509000   -118.2150000 
+    33.7446000   -118.2140000 
+    33.7404000   -118.2070000 
+    33.7492000   -118.2120000 
+    33.7521000   -118.2070000 
+    33.7450000   -118.2070000 
+    33.7446000   -118.2010000 
+    33.7504000   -118.1990000 
+    33.7425000   -118.1950000 
+    33.7404000   -118.2040000 
+    33.7379000   -118.2050000 
+    33.7388000   -118.1860000 
+    33.7499000   -118.1900000 
+    33.7534000   -118.1870000 
+    33.7588000   -118.2020000 
+    33.7654000   -118.2070000 
+    33.7595000   -118.1980000 
+    33.7621000   -118.1920000 
+    33.7595000   -118.1910000 
+    33.7595000   -118.1870000 
+    33.7637000   -118.1820000 
+    33.7621000   -118.1630000 
+    33.7512000   -118.1320000 
+    33.7429000   -118.1170000 
+    33.7396000   -118.1160000 
+    33.7379000   -118.1050000 
+    33.7346000   -118.1020000 
+    33.7346000   -118.0980000 
+    33.7387000   -118.0970000 
+    33.7362000   -118.0890000 
+    33.7321000   -118.0880000 
+    33.7342000   -118.0950000 
+    33.7295000   -118.0910000 
+    33.7087000   -118.0630000 
+    33.6779000   -118.0330000 
+    33.6526000   -118.0000000 
+    33.6526000   -118.0000000 
+    33.6452000   -117.9910000 
+    33.6194000   -117.9410000 
+    33.6057000   -117.9280000 
+    33.5930000   -117.8740000 
+    33.5823000   -117.8610000 
+    33.5749000   -117.8430000 
+    33.5657000   -117.8340000 
+    33.5605000   -117.8240000 
+    33.5530000   -117.8210000 
+    33.5516000   -117.8100000 
+    33.5466000   -117.8070000 
+    33.5417000   -117.7870000 
+    33.5142000   -117.7620000 
+    33.5096000   -117.7540000 
+    33.4964000   -117.7420000 
+    33.4853000   -117.7380000 
+    33.4820000   -117.7280000 
+    33.4591000   -117.7170000 
+    33.4593000   -117.7100000 
+    33.4626000   -117.7080000 
+    33.4600000   -117.7000000 
+    33.4608000   -117.6870000 
+    33.4448000   -117.6560000 
+    33.4117000   -117.6170000 
+    33.3995000   -117.6060000 
+    33.3842000   -117.5990000 
+    33.3784000   -117.5790000 
+    33.3641000   -117.5520000 
+    33.3321000   -117.5080000 
+    33.2543000   -117.4350000 
+    33.2121000   -117.4060000 
+    33.2090000   -117.4000000 
+    33.1655000   -117.3620000 
+    33.1277000   -117.3370000 
+    33.1250000   -117.3320000 
+    33.0359000   -117.2990000 
+    33.0088000   -117.2820000 
+    32.9539000   -117.2700000 
+    32.9256000   -117.2610000 
+    32.9142000   -117.2600000 
+    32.9021000   -117.2550000 
+    32.8801000   -117.2520000 
+    32.8564000   -117.2590000 
+    32.8508000   -117.2650000 
+    32.8535000   -117.2720000 
+    32.8486000   -117.2800000 
+    32.8443000   -117.2830000 
+    32.8318000   -117.2830000 
+    32.8224000   -117.2820000 
+    32.8007000   -117.2590000 
+    32.7833000   -117.2540000 
+    32.7659000   -117.2540000 
+    32.7590000   -117.2490000 
+    32.7449000   -117.2570000 
+    32.7263000   -117.2590000 
+    32.6990000   -117.2570000 
+    32.6730000   -117.2460000 
+    32.6675000   -117.2470000 
+    32.6648000   -117.2400000 
+    32.6666000   -117.2370000 
+    32.6824000   -117.2370000 
+    32.6860000   -117.2330000 
+    32.6891000   -117.2390000 
+    32.6962000   -117.2400000 
+    32.7048000   -117.2370000 
+    32.7183000   -117.2210000 
+    32.7209000   -117.2200000 
+    32.7216000   -117.2250000 
+    32.7250000   -117.2260000 
+    32.7223000   -117.2170000 
+    32.7282000   -117.2070000 
+    32.7277000   -117.1790000 
+    32.7250000   -117.1760000 
+    32.7098000   -117.1740000 
+    32.6899000   -117.1390000 
+    32.6869000   -117.1410000 
+    32.6873000   -117.1340000 
+    32.6736000   -117.1200000 
+    32.6699000   -117.1250000 
+    32.6677000   -117.1210000 
+    32.6397000   -117.1160000 
+    32.6294000   -117.1010000 
+    32.6152000   -117.0980000 
+    32.6015000   -117.1140000 
+    32.6037000   -117.1220000 
+    32.6130000   -117.1290000 
+    32.6210000   -117.1270000 
+    32.6246000   -117.1310000 
+    32.6314000   -117.1310000 
+    32.6346000   -117.1370000 
+    32.6534000   -117.1450000 
+    32.6716000   -117.1600000 
+    32.6807000   -117.1540000 
+    32.6826000   -117.1580000 
+    32.6774000   -117.1640000 
+    32.6788000   -117.1670000 
+    32.6989000   -117.1640000 
+    32.7084000   -117.1880000 
+    32.7147000   -117.1870000 
+    32.7166000   -117.1920000 
+    32.7158000   -117.2090000 
+    32.7083000   -117.2240000 
+    32.6964000   -117.2290000 
+    32.6872000   -117.2280000 
+    32.6831000   -117.2230000 
+    32.6891000   -117.2060000 
+    32.6891000   -117.1970000 
+    32.6820000   -117.1810000 
+    32.6608000   -117.1620000 
+    32.6209000   -117.1380000 
+    32.6030000   -117.1330000 
+    32.5683000   -117.1350000 
+    32.5358000   -117.1240000 
+    32.4869000   -117.1250000 
+    32.4689000   -117.1210000 
+    32.4487000   -117.1120000 
+    32.4397000   -117.1020000 
+    32.3940000   -117.0900000 
+    32.3742000   -117.0770000 
+    32.3466000   -117.0660000 
+    32.3289000   -117.0550000 
+    32.2834000   -117.0380000 
+    32.2687000   -117.0250000 
+    32.2682000   -117.0120000 
+    32.2642000   -117.0060000 
+    32.2573000   -116.9740000 
+    32.2482000   -116.9480000 
+    32.2403000   -116.9350000 
+    32.2264000   -116.9230000 
+    32.2029000   -116.9150000 
+    32.1673000   -116.9090000 
+    32.1635000   -116.9040000 
+    32.1297000   -116.8890000 
+    32.0854000   -116.8880000 
+    32.0779000   -116.8840000 
+    32.0329000   -116.8880000 
+    32.0179000   -116.8820000 
+    32.0027000   -116.8660000 
+    32.0000000   -116.8650000 
+    32.0000000   -116.8650000 
+    31.9921000   -116.8610000 
+    31.9774000   -116.8340000 
+    31.9799000   -116.7990000 
+    31.9757000   -116.7910000 
+    31.9749000   -116.7780000 
+    31.9595000   -116.7620000 
+    31.9109000   -116.7570000 
+    31.9024000   -116.7510000 
+    31.9006000   -116.7210000 
+    31.8948000   -116.7150000 
+    31.8951000   -116.7030000 
+    31.8598000   -116.6690000 
+    31.8626000   -116.6630000 
+    31.8583000   -116.6410000 
+    31.8459000   -116.6300000 
+    31.8579000   -116.6320000 
+    31.8592000   -116.6290000 
+    31.8560000   -116.6210000 
+    31.8527000   -116.6230000 
+    31.8430000   -116.6150000 
+    31.8165000   -116.6110000 
+    31.7799000   -116.6220000 
+    31.7707000   -116.6120000 
+    31.7657000   -116.6140000 
+    31.7632000   -116.6210000 
+    31.7501000   -116.6230000 
+    31.7222000   -116.6400000 
+    31.7137000   -116.6390000 
+    31.7092000   -116.6330000 
+    31.6981000   -116.6310000 
+    31.6992000   -116.6350000 
+    31.7065000   -116.6390000 
+    31.7168000   -116.6590000 
+    31.7254000   -116.6410000 
+    31.7496000   -116.6320000 
+    31.7529000   -116.6260000 
+    31.7651000   -116.6260000 
+    31.7723000   -116.6230000 
+    31.7694000   -116.6270000 
+    31.7384000   -116.6410000 
+    31.7248000   -116.6520000 
+    31.7183000   -116.6630000 
+    31.7183000   -116.6720000 
+    31.7284000   -116.6830000 
+    31.7326000   -116.6980000 
+    31.7490000   -116.7280000 
+    31.7490000   -116.7430000 
+    31.7442000   -116.7440000 
+    31.7423000   -116.7490000 
+    31.7398000   -116.7380000 
+    31.7327000   -116.7360000 
+    31.7310000   -116.7280000 
+    31.7205000   -116.7260000 
+    31.7234000   -116.7170000 
+    31.7150000   -116.7190000 
+    31.7123000   -116.7160000 
+    31.7098000   -116.7100000 
+    31.7146000   -116.6990000 
+    31.7054000   -116.6910000 
+    31.7026000   -116.6930000 
+    31.6977000   -116.6790000 
+    31.6932000   -116.6800000 
+    31.6640000   -116.6520000 
+    31.6454000   -116.6540000 
+    31.6146000   -116.6690000 
+    31.5998000   -116.6660000 
+    31.5905000   -116.6550000 
+    31.5827000   -116.6530000 
+    31.5791000   -116.6560000 
+    31.5791000   -116.6740000 
+    31.5707000   -116.6830000 
+    31.5714000   -116.6940000 
+    31.5590000   -116.6900000 
+    31.5528000   -116.6940000 
+    31.5490000   -116.6850000 
+    31.5534000   -116.6780000 
+    31.5488000   -116.6680000 
+    31.5346000   -116.6660000 
+    31.5338000   -116.6620000 
+    31.5272000   -116.6610000 
+    31.5171000   -116.6490000 
+    31.5132000   -116.6480000 
+    31.5159000   -116.6370000 
+    31.5141000   -116.6330000 
+    31.4951000   -116.6120000 
+    31.4610000   -116.6060000 
+    31.4593000   -116.5990000 
+    31.4641000   -116.5830000 
+    31.4633000   -116.5740000 
+    31.4514000   -116.5540000 
+    31.4442000   -116.5470000 
+    31.4347000   -116.5260000 
+    31.4143000   -116.5140000 
+    31.4090000   -116.5040000 
+    31.4057000   -116.5050000 
+    31.3767000   -116.4890000 
+    31.3686000   -116.4900000 
+    31.3616000   -116.4810000 
+    31.3601000   -116.4730000 
+    31.3515000   -116.4720000 
+    31.3452000   -116.4590000 
+    31.3341000   -116.4570000 
+    31.3298000   -116.4600000 
+    31.3291000   -116.4520000 
+    31.3226000   -116.4490000 
+    31.3214000   -116.4410000 
+    31.3098000   -116.4330000 
+    31.3029000   -116.4200000 
+    31.2917000   -116.4160000 
+    31.2905000   -116.4090000 
+    31.2840000   -116.4030000 
+    31.2821000   -116.3960000 
+    31.2664000   -116.3880000 
+    31.2569000   -116.3730000 
+    31.2520000   -116.3720000 
+    31.2405000   -116.3610000 
+    31.2249000   -116.3540000 
+    31.2132000   -116.3540000 
+    31.2070000   -116.3420000 
+    31.1896000   -116.3360000 
+    31.1528000   -116.3110000 
+    31.0935000   -116.3150000 
+    30.9766000   -116.3400000 
+    30.9642000   -116.3350000 
+    30.9562000   -116.3270000 
+    30.9546000   -116.3200000 
+    30.9612000   -116.2960000 
+    30.9687000   -116.2840000 
+    30.9653000   -116.2680000 
+    30.9321000   -116.2450000 
+    30.9329000   -116.2360000 
+    30.9180000   -116.2230000 
+    30.9133000   -116.2150000 
+    30.8867000   -116.2050000 
+    30.8754000   -116.1890000 
+    30.8613000   -116.1760000 
+    30.8596000   -116.1660000 
+    30.8620000   -116.1570000 
+    30.8587000   -116.1480000 
+    30.8229000   -116.1060000 
+    30.8187000   -116.0970000 
+    30.8212000   -116.0870000 
+    30.8196000   -116.0780000 
+    30.8025000   -116.0600000 
+    30.7724000   -116.0500000 
+    30.7175000   -116.0470000 
+    30.7000000   -116.0330000 
+    30.6633000   -116.0270000 
+    30.5725000   -116.0320000 
+    30.4991000   -116.0450000 
+    30.4933000   -116.0490000 
+    30.4725000   -116.0480000 
+    30.4633000   -116.0440000 
+    30.4566000   -116.0350000 
+    30.4358000   -116.0300000 
+    30.4329000   -116.0200000 
+    30.4242000   -116.0140000 
+    30.3891000   -116.0050000 
+    30.3759000   -116.0050000 
+    30.3733000   -116.0080000 
+    30.3650000   -116.0060000 
+    30.3593000   -116.0000000 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_shelf
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_shelf	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/BOUNDARIES/oms_shelf	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,101 @@
+    39.3839000   -124.3972000 
+    39.2226000   -124.2256000 
+    38.9718000   -124.1030000 
+    38.8464000   -123.9559000 
+    38.7030000   -123.8824000 
+    38.5776000   -123.8088000 
+    38.4343000   -123.7598000 
+    38.3447000   -123.7108000 
+    38.2372000   -123.6127000 
+    38.0939000   -123.5637000 
+    37.8968000   -123.4901000 
+    37.8251000   -123.4166000 
+    37.7713000   -123.2205000 
+    37.6818000   -123.0979000 
+    37.5026000   -123.1959000 
+    37.4130000   -123.3430000 
+    37.3234000   -123.3921000 
+    37.2338000   -123.1959000 
+    37.1622000   -123.0243000 
+    37.0905000   -122.8282000 
+    37.0188000   -122.6076000 
+    36.9472000   -122.4360000 
+    36.8934000   -122.3134000 
+    36.8397000   -122.1418000 
+    36.7322000   -122.1418000 
+    36.6067000   -122.1663000 
+    36.4455000   -122.2889000 
+    36.3021000   -122.4360000 
+    36.1767000   -122.5095000 
+    36.0692000   -122.3869000 
+    35.9438000   -122.2644000 
+    35.7826000   -122.1908000 
+    35.5855000   -122.0682000 
+    35.4780000   -121.9702000 
+    35.3884000   -121.9947000 
+    35.2450000   -121.9456000 
+    35.1555000   -121.9211000 
+    35.0300000   -121.8721000 
+    34.9046000   -121.7986000 
+    34.8329000   -121.7495000 
+    34.7613000   -121.6269000 
+    34.6717000   -121.5044000 
+    34.6000000   -121.4308000 
+    34.5463000   -121.3573000 
+    34.5104000   -121.1366000 
+    34.4209000   -121.0386000 
+    34.2775000   -121.0876000 
+    34.0983000   -121.0631000 
+    33.9192000   -120.9405000 
+    33.8117000   -120.8915000 
+    33.6863000   -120.7934000 
+    33.6146000   -120.7444000 
+    33.4354000   -120.6463000 
+    33.2921000   -120.5237000 
+    33.1308000   -120.4257000 
+    33.0054000   -120.3276000 
+    32.8800000   -120.2541000 
+    32.7366000   -120.2050000 
+    32.6291000   -120.1805000 
+    32.5037000   -120.0825000 
+    32.3604000   -119.9599000 
+    32.2350000   -119.8618000 
+    32.1096000   -119.7392000 
+    31.9841000   -119.5921000 
+    31.8766000   -119.4941000 
+    31.7512000   -119.3470000 
+    31.6258000   -119.2734000 
+    31.5720000   -119.1754000 
+    31.4287000   -119.1018000 
+    31.3391000   -118.9547000 
+    31.2674000   -118.9057000 
+    31.1779000   -118.8076000 
+    31.0704000   -118.7586000 
+    30.9987000   -118.6115000 
+    30.9270000   -118.3909000 
+    30.8374000   -118.1947000 
+    30.7479000   -118.0722000 
+    30.6403000   -117.9496000 
+    30.5149000   -117.8270000 
+    30.3895000   -117.7535000 
+    30.2641000   -117.6554000 
+    30.1387000   -117.5573000 
+    30.0312000   -117.5083000 
+    29.8878000   -117.4102000 
+    29.7445000   -117.3367000 
+    29.6012000   -117.3612000 
+    29.4578000   -117.3122000 
+    29.3682000   -117.2141000 
+    29.4399000   -117.0425000 
+    29.4757000   -116.8709000 
+    29.5116000   -116.7238000 
+    29.4399000   -116.5522000 
+    29.3503000   -116.5032000 
+    29.2249000   -116.4051000 
+    29.1353000   -116.3806000 
+    28.9741000   -116.3070000 
+    28.8307000   -116.1599000 
+    28.6874000   -116.0374000 
+    28.5620000   -115.8903000 
+    28.4724000   -115.8657000 
+    28.3649000   -115.7677000 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/COLOR_MAPS/socal_color.cpt
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/COLOR_MAPS/socal_color.cpt	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/COLOR_MAPS/socal_color.cpt	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,33 @@
+#  c0 = 3.78 km/s , % variation is -5 to 3
+#COLOR_MODEL = RGB
+#
+-5	170	0	0	-4.7	170	0	0
+-4.7	193	0	0	-4.4	193	0	0
+-4.4	216	0	0	-4.1	216	0	0
+-4.1	239	0	0	-3.8	239	0	0
+-3.8	255	7	0	-3.5	255	7	0
+-3.5	255	31	0	-3.2	255	31	0
+-3.2	255	54	0	-2.9	255	54	0
+-2.9	255	77	0	-2.6	255	77	0
+-2.6	255	100	0	-2.3	255	100	0
+-2.3	255	123	0	-2	255	123	0
+-2	255	147	0	-1.7	255	147	0
+-1.7	255	170	0	-1.4	255	170	0
+-1.4	255	193	0	-1.1	255	193	0
+-1.1	255	216	0	-0.8	255	216	0
+-0.8	255	239	0	-0.5	255	239	0
+-0.5	255	255	0	-0.2	255	255	0
+-0.2	255	255	0	0.3	255	255	0
+0.3	255	255	0	0.6	255	255	0
+0.6	189	255	12	0.9	189	255	12
+0.9	115	255	26	1.2	115	255	26
+1.2	63	250	54	1.5	63	250	54
+1.5	22	244	90	1.8	22	244	90
+1.8	0	208	139	2.1	0	208	139
+2.1	0	135	205	2.4	0	135	205
+2.4	0	72	250	2.7	0	72	250
+2.7	0	36	227	3	0	36	227
+B	170	0	0
+F	0	0	255
+N	128	128	128
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/README
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/README	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/README	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,14 @@
+Carl Tape, 25-Jan-2006
+
+Source and receiver files
+----------------------------
+
+Earthquake locations (SCEC)
+socal_quakes_N034.dat <--> socal_quakes_v01.dat
+socal_quakes_N025.dat (subset of the 34 list)
+
+Nearest GLL gridpoint (used in GJI 2006 simulations)
+socal_quakes_v02.dat
+socal_quakes_v02_pert_02.dat   ! 2km perturbed source
+socal_quakes_v02_pert_05.dat   ! 5km perturbed source
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand15
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand15	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand15	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,16 @@
+        15 
+      3.376737578491e+03      8.000000000000e+04
+      3.263451667752e+04      8.000000000000e+04
+      4.562085551749e+04      8.000000000000e+04
+      5.239972097720e+04      8.000000000000e+04
+      6.397354032236e+04      8.000000000000e+04
+      7.012916246269e+04      8.000000000000e+04
+      8.896035900808e+04      8.000000000000e+04
+      9.933964795389e+04      8.000000000000e+04
+      1.057852152799e+05      8.000000000000e+04
+      1.113319618315e+05      8.000000000000e+04
+      1.329617641086e+05      8.000000000000e+04
+      1.460335844611e+05      8.000000000000e+04
+      1.666145143866e+05      8.000000000000e+04
+      1.780007384166e+05      8.000000000000e+04
+      1.904148575688e+05      8.000000000000e+04

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand30
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand30	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand30	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,31 @@
+        30 
+      3.290283390676e+03      8.000000000000e+04
+      7.331116382681e+03      8.000000000000e+04
+      1.974172675523e+04      8.000000000000e+04
+      2.386010640208e+04      8.000000000000e+04
+      6.231860878122e+04      8.000000000000e+04
+      6.640500370320e+04      8.000000000000e+04
+      7.376437411203e+04      8.000000000000e+04
+      1.202708686441e+05      8.000000000000e+04
+      1.215762331328e+05      8.000000000000e+04
+      1.244306056866e+05      8.000000000000e+04
+      1.620207826903e+05      8.000000000000e+04
+      1.664159148572e+05      8.000000000000e+04
+      1.752139078542e+05      8.000000000000e+04
+      1.769951541683e+05      8.000000000000e+04
+      2.099371058457e+05      8.000000000000e+04
+      2.206013077919e+05      8.000000000000e+04
+      2.206090597772e+05      8.000000000000e+04
+      2.467239276127e+05      8.000000000000e+04
+      2.494761789655e+05      8.000000000000e+04
+      2.698588751494e+05      8.000000000000e+04
+      2.791701056864e+05      8.000000000000e+04
+      2.965782739162e+05      8.000000000000e+04
+      3.013147529709e+05      8.000000000000e+04
+      3.278735467135e+05      8.000000000000e+04
+      3.454666398867e+05      8.000000000000e+04
+      3.578491071014e+05      8.000000000000e+04
+      3.660646890221e+05      8.000000000000e+04
+      3.719826529417e+05      8.000000000000e+04
+      3.738816232229e+05      8.000000000000e+04
+      3.839750611328e+05      8.000000000000e+04

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand40
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand40	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATIONS_socal1D_rand40	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,41 @@
+        40 
+      2.483627261759e+05      8.000000000000e+04
+      9.566744471925e+04      8.000000000000e+04
+      1.856500542513e+05      8.000000000000e+04
+      2.884610439439e+05      8.000000000000e+04
+      3.752667039825e+05      8.000000000000e+04
+      3.550875773058e+05      8.000000000000e+04
+      5.386544492760e+04      8.000000000000e+04
+      1.933116969245e+05      8.000000000000e+04
+      3.581019707010e+05      8.000000000000e+04
+      3.936500138241e+05      8.000000000000e+04
+      1.747238243583e+04      8.000000000000e+04
+      2.893139896908e+05      8.000000000000e+04
+      1.153165479407e+05      8.000000000000e+04
+      2.832327192568e+05      8.000000000000e+04
+      3.641866047085e+05      8.000000000000e+04
+      3.762538973722e+05      8.000000000000e+04
+      3.780474441291e+04      8.000000000000e+04
+      3.070846042385e+05      8.000000000000e+04
+      3.412407901425e+05      8.000000000000e+04
+      3.703452720313e+05      8.000000000000e+04
+      2.803532074534e+04      8.000000000000e+04
+      1.528216271978e+05      8.000000000000e+04
+      1.117386799317e+05      8.000000000000e+04
+      8.903252768250e+04      8.000000000000e+04
+      2.114789083066e+05      8.000000000000e+04
+      3.381399108891e+05      8.000000000000e+04
+      2.330401392962e+05      8.000000000000e+04
+      1.229540083062e+05      8.000000000000e+04
+      3.243581204707e+05      8.000000000000e+04
+      1.131322053741e+05      8.000000000000e+04
+      2.920056725665e+05      8.000000000000e+04
+      2.310871102540e+05      8.000000000000e+04
+      6.343503288728e+04      8.000000000000e+04
+      5.528763640587e+04      8.000000000000e+04
+      2.636726370959e+05      8.000000000000e+04
+      8.527720941894e+04      8.000000000000e+04
+      7.019455522362e+04      8.000000000000e+04
+      3.120721836040e+05      8.000000000000e+04
+      2.296400095870e+05      8.000000000000e+04
+      4.332572275869e+04      8.000000000000e+04

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_005_island
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_005_island	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_005_island	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,6 @@
+   5
+-118.414 33.4019
+-119.03 33.4805
+-118.547 32.9799
+-119.635 33.9954
+-119.524 33.248
\ No newline at end of file

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_067_nobasin
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_067_nobasin	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_067_nobasin	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,68 @@
+    67
+-117.434 34.5505
+-116.401 33.6384
+-118.299 34.6871
+-119.104 35.3444
+-116.921 34.2623
+-116.981 33.921
+-115.998 34.0006
+-117.658 34.237
+-116.389 34.0695
+-116.417 33.2682
+-117.365 35.5249
+-117.598 35.8157
+-117.317 34.0928
+-115.99  33.6552
+-116.578 33.936
+-117.009 33.65
+-116.631 33.5667
+-116.942 32.9986
+-116.104 35.1426
+-116.101 32.6591
+-117.991 34.883
+-116.846 32.8908
+-115.823 33.1167
+-116.806 35.3018
+-116.335 34.8294
+-118.474 35.6628
+-116.596 33.0859
+-117.808 35.9823
+-116.613 34.3662
+-118.342 34.9906
+-117.825 34.6159
+-117.696 34.9344
+-117.682 35.4795
+-117.367 34.3656
+-116.041 34.2265
+-116.369 33.8184
+-117.489 36.058
+-116.968 33.808
+-116.558 34.7803
+-115.947 33.5561
+-116.93 32.6078
+-117.205 33.8616
+-120.546 35.4077
+-116.512 33.8244
+-116.863 33.3536
+-116.997 34.8753
+-117.327 33.9733
+-117.375 33.9935
+-115.986 33.2801
+-117.235 34.2324
+-116.942 32.7356
+-116.275 35.8995
+-117.283 35.8909
+-119.996 35.3142
+-118.811 36.1355
+-117.098 34.1065
+-115.796 32.9408
+-117.678 34.382
+-118.421 35.2913
+-119.419 35.1459
+-116.164 33.6349
+-115.924 35.4358
+-119.085 35.8409
+-117.33 34.5606
+-118.14 35.5366
+-119.027 35.0605
+-115.732 32.759

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_144_noisland
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_144_noisland	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_144_noisland	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,145 @@
+  144
+-117.434 34.5505
+-116.401 33.6384
+-118.299 34.6871
+-119.104 35.3444
+-116.921 34.2623
+-116.981 33.9214
+-115.454 33.6552
+-117.261 33.5751
+-115.998 34.0006
+-117.658 34.237
+-116.389 34.0695
+-116.417 33.2682
+-117.981 33.8078
+-115.22 33.0121
+-118.574 34.6822
+-117.195 33.3882
+-117.365 35.5249
+-117.803 36.5504
+-118.026 34.3334
+-117.68 33.9988
+-117.598 35.8157
+-117.317 34.0928
+-118.127 34.1362
+-115.99 33.6552
+-118.08 36.4399
+-115.381 34.6375
+-118.334 34.2535
+-116.578 33.936
+-117.009 33.65
+-118.455 34.1062
+-118.096 33.8482
+-116.631 33.5667
+-116.942 32.9986
+-115.447 32.8053
+-116.104 35.1426
+-116.101 32.6591
+-117.991 34.883
+-116.846 32.8908
+-115.823 33.1167
+-119.988 34.7283
+-118.294 33.7126
+-116.863 36.467
+-114.827 33.0515
+-117.229 33.1537
+-117.366 36.9961
+-116.806 35.3018
+-116.335 34.8294
+-118.36 34.1764
+-115.145 34.1574
+-118.474 35.6628
+-116.596 33.0859
+-117.808 35.9823
+-116.613 34.3662
+-118.331 33.8689
+-118.378 34.0003
+-120.28 34.7355
+-115.183 35.1302
+-118.342 34.9906
+-118.488 34.3053
+-118.149 33.9753
+-119.066 34.1082
+-118.868 34.8076
+-117.825 34.6159
+-117.943 33.6845
+-117.696 34.9344
+-117.682 35.4795
+-118.176 33.8811
+-117.367 34.3656
+-116.041 34.2265
+-116.369 33.8184
+-118.836 37.6302
+-117.562 34.0046
+-118.905 34.2808
+-119.145 34.8126
+-117.489 36.058
+-119.814 34.8885
+-116.968 33.808
+-115.553 35.4843
+-118.058 34.2236
+-116.558 34.7803
+-114.599 34.8249
+-120.177 34.5341
+-115.947 33.5561
+-117.924 33.9454
+-116.93 32.6078
+-118.724 34.6145
+-118.171 34.1484
+-118.582 34.442
+-114.142 34.3034
+-118.437 33.9627
+-117.638 34.1207
+-117.205 33.8616
+-120.546 35.4077
+-116.512 33.8244
+-116.863 33.3536
+-117.609 33.7953
+-119.244 36.3052
+-118.479 34.282
+-117.98 34.1047
+-118.404 33.7435
+-116.997 34.8753
+-117.327 33.9733
+-118.081 34.0507
+-117.375 33.9935
+-115.986 33.2801
+-119.715 34.4408
+-117.235 34.2324
+-117.662 33.5526
+-117.138 32.784
+-120.501 34.5655
+-116.942 32.7356
+-119.137 34.4369
+-116.275 35.8995
+-117.283 35.8909
+-119.996 35.3142
+-118.456 34.0144
+-118.646 34.0593
+-118.811 36.1355
+-117.789 33.8285
+-115.616 33.1775
+-119.187 34.3027
+-117.769 33.664
+-118.199 33.7903
+-117.098 34.1065
+-115.796 32.9408
+-119.978 34.5277
+-117.678 34.382
+-118.421 35.2913
+-119.419 35.1459
+-116.164 33.6349
+-118.23 37.0542
+-118.82 34.1561
+-115.924 35.4358
+-118.286 34.0192
+-118.118 34.4836
+-119.085 35.8409
+-117.33 34.5606
+-118.14 35.5366
+-119.027 35.0605
+-115.732 32.759
+-119.274 34.5108
+-117.951 34.0095
+-118.65 34.1717
+-118.255 33.9487

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_149_full
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_149_full	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/STATION_149_full	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,150 @@
+  149
+-117.434 34.5505
+-116.401 33.6384
+-118.299 34.6871
+-119.104 35.3444
+-116.921 34.2623
+-116.981 33.9214
+-115.454 33.6552
+-117.261 33.5751
+-115.998 34.0006
+-117.658 34.237
+-116.389 34.0695
+-116.417 33.2682
+-117.981 33.8078
+-115.22 33.0121
+-118.574 34.6822
+-117.195 33.3882
+-117.365 35.5249
+-117.803 36.5504
+-118.026 34.3334
+-117.68 33.9988
+-118.414 33.4019
+-117.598 35.8157
+-117.317 34.0928
+-118.127 34.1362
+-115.99 33.6552
+-118.08 36.4399
+-115.381 34.6375
+-118.334 34.2535
+-116.578 33.936
+-117.009 33.65
+-118.455 34.1062
+-118.096 33.8482
+-116.631 33.5667
+-116.942 32.9986
+-115.447 32.8053
+-116.104 35.1426
+-116.101 32.6591
+-117.991 34.883
+-116.846 32.8908
+-115.823 33.1167
+-119.988 34.7283
+-118.294 33.7126
+-116.863 36.467
+-114.827 33.0515
+-117.229 33.1537
+-117.366 36.9961
+-116.806 35.3018
+-116.335 34.8294
+-118.36 34.1764
+-115.145 34.1574
+-118.474 35.6628
+-116.596 33.0859
+-117.808 35.9823
+-116.613 34.3662
+-118.331 33.8689
+-118.378 34.0003
+-120.28 34.7355
+-115.183 35.1302
+-118.342 34.9906
+-118.488 34.3053
+-118.149 33.9753
+-119.066 34.1082
+-118.868 34.8076
+-117.825 34.6159
+-117.943 33.6845
+-117.696 34.9344
+-117.682 35.4795
+-118.176 33.8811
+-117.367 34.3656
+-116.041 34.2265
+-116.369 33.8184
+-118.836 37.6302
+-117.562 34.0046
+-118.905 34.2808
+-119.145 34.8126
+-117.489 36.058
+-119.814 34.8885
+-116.968 33.808
+-115.553 35.4843
+-118.058 34.2236
+-116.558 34.7803
+-114.599 34.8249
+-120.177 34.5341
+-115.947 33.5561
+-117.924 33.9454
+-116.93 32.6078
+-118.724 34.6145
+-118.171 34.1484
+-118.582 34.442
+-114.142 34.3034
+-118.437 33.9627
+-117.638 34.1207
+-117.205 33.8616
+-120.546 35.4077
+-116.512 33.8244
+-116.863 33.3536
+-117.609 33.7953
+-119.244 36.3052
+-118.479 34.282
+-117.98 34.1047
+-118.404 33.7435
+-116.997 34.8753
+-117.327 33.9733
+-118.081 34.0507
+-117.375 33.9935
+-115.986 33.2801
+-119.715 34.4408
+-119.03 33.4805
+-117.235 34.2324
+-118.547 32.9799
+-119.635 33.9954
+-117.662 33.5526
+-117.138 32.784
+-120.501 34.5655
+-116.942 32.7356
+-119.137 34.4369
+-116.275 35.8995
+-117.283 35.8909
+-119.996 35.3142
+-118.456 34.0144
+-119.524 33.248
+-118.646 34.0593
+-118.811 36.1355
+-117.789 33.8285
+-115.616 33.1775
+-119.187 34.3027
+-117.769 33.664
+-118.199 33.7903
+-117.098 34.1065
+-115.796 32.9408
+-119.978 34.5277
+-117.678 34.382
+-118.421 35.2913
+-119.419 35.1459
+-116.164 33.6349
+-118.23 37.0542
+-118.82 34.1561
+-115.924 35.4358
+-118.286 34.0192
+-118.118 34.4836
+-119.085 35.8409
+-117.33 34.5606
+-118.14 35.5366
+-119.027 35.0605
+-115.732 32.759
+-119.274 34.5108
+-117.951 34.0095
+-118.65 34.1717
+-118.255 33.9487

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/events_xy_pert.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/events_xy_pert.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/events_xy_pert.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,25 @@
+ -1.174545017675e+03  1.675751226860e+03 -7.313703137106e-01
+  2.585098768883e+03 -6.010675172937e+02  7.616568802021e-01
+  1.644713452302e+03 -1.251368724254e+03  2.031829261287e-01
+  1.167071653148e+03 -8.523437626213e+02  8.996227291881e-02
+  1.394980591427e+03  4.247595386009e+03 -8.290197569399e-01
+ -2.508193795569e+03  6.730614797908e+02  1.487881665851e-01
+  1.937469503378e+03  3.425472607306e+01 -2.674928904212e-01
+ -3.213944081284e+03  1.422473159499e+03  2.076055086372e-01
+ -1.505940588542e+01 -1.747094944150e+03  4.273424901773e-01
+ -1.479771546998e+03  3.132778490141e+03 -8.540124840225e-01
+  1.679024448710e+03  2.312570449441e+03  1.943853698890e-01
+  1.566176046423e+02  1.480519914822e+03 -1.081528595358e-01
+ -1.030379394831e+03 -6.005061696873e+02 -2.807222489166e-02
+ -9.172274299744e+02  1.963345883758e+03  5.432240059806e-01
+  5.871496860564e+03  2.847049981353e+01 -1.659328947054e-01
+ -1.197921277099e+03  4.995042921401e+03  5.422741350160e-01
+ -2.868035034643e+03  2.446142976820e+03 -4.402970396568e-01
+ -1.026801110554e+03 -3.590919962120e+02  1.847484562732e-02
+ -3.568982728589e+02 -1.201886091880e+03 -5.584920054983e-01
+ -1.934054324871e+03 -6.541547871593e+02 -4.028229732207e-01
+  2.380131072701e+03 -1.277405438004e+03  8.428023005820e-01
+  3.055283417230e+03  1.690259018105e+03 -5.629194352402e-01
+ -2.284788406023e+02  1.148918606089e+03 -2.855615329364e-01
+  2.357942483049e+03  2.364944728503e+03 -1.032230038045e+00
+  5.314078441729e+02 -2.425515077670e+03 -6.525802450904e-02

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/oms_shelf
===================================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/sigma_0p1_pert.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/sigma_0p1_pert.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/sigma_0p1_pert.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,10000 @@
+  5.775228847606e-02
+ -1.544216325198e-03
+  1.310562704965e-02
+ -8.000408079648e-03
+  1.232885795387e-02
+  5.047211234567e-02
+ -1.191686412338e-01
+  2.440363868092e-01
+  1.733351620112e-01
+  3.117801706342e-03
+  1.005723576431e-01
+  2.986798028788e-02
+  4.731609848469e-02
+ -1.303089728795e-01
+ -6.980780165852e-02
+  1.302726852688e-01
+ -9.818253701945e-03
+  1.149031419096e-01
+  1.842627370048e-03
+  2.234184262189e-01
+ -2.466472638025e-02
+ -9.363227053480e-02
+ -1.381339332153e-01
+  3.758211269230e-02
+ -4.493951771684e-02
+  6.565814345808e-02
+  1.968928798924e-02
+  6.554774956896e-02
+  1.720118730463e-01
+  1.264609800823e-02
+ -7.423619463512e-02
+  6.553573196091e-02
+ -1.549624018825e-01
+ -4.818504543399e-02
+  9.113995370865e-02
+ -6.617451155910e-02
+  1.308035849661e-01
+  1.117383818608e-01
+ -2.410042405173e-02
+ -2.225160149751e-01
+  5.413710897873e-02
+ -5.236424478639e-02
+  8.440534783360e-02
+ -6.169102196511e-02
+  1.224982443147e-01
+  2.265352201256e-02
+ -3.218305970410e-02
+  3.877441768487e-02
+ -4.307923014050e-02
+  4.831955067404e-02
+ -2.953671953253e-02
+  1.705368808901e-01
+ -8.731365783591e-02
+ -1.509514029899e-01
+ -1.216743220505e-01
+  1.509805714583e-01
+ -1.368005303212e-02
+  1.129547891425e-01
+  7.093157257086e-02
+  1.179601491694e-02
+ -2.224690160702e-02
+  1.268830932779e-01
+  7.492206490825e-03
+  5.369448790898e-02
+ -7.906154983244e-02
+  1.455818927005e-01
+  1.008407571672e-01
+  1.246699508558e-01
+  8.014910197525e-02
+  1.476900021326e-01
+  9.201873968398e-03
+  5.037855351908e-02
+ -1.569619265696e-01
+ -3.717843170597e-02
+  7.593838845060e-02
+  3.645731179627e-02
+  6.286254766897e-02
+  1.369640574307e-01
+  1.332425890066e-01
+ -8.653420581796e-02
+ -7.476716773511e-02
+  1.027103642028e-01
+ -5.616660508673e-02
+  9.606424300999e-02
+  4.293445752004e-02
+  1.508607381066e-01
+  1.193816043082e-01
+ -2.169595041586e-01
+  2.556888054257e-03
+  1.035744042054e-01
+ -4.595377405356e-02
+ -1.083684657941e-01
+  4.352711246650e-03
+  7.971240901922e-02
+  5.585864563772e-02
+  7.424515680582e-02
+ -8.488048924071e-02
+ -3.100911397929e-02
+ -2.349197582254e-01
+  1.223797113288e-01
+  5.725281005716e-02
+ -1.716986649945e-01
+ -2.929363301468e-04
+  9.079829511016e-02
+ -7.870795419612e-02
+  4.850357678069e-02
+  9.815026971222e-02
+ -1.295925942086e-01
+ -6.816768231840e-02
+ -1.040581983127e-01
+  5.591145444246e-02
+ -4.207818519683e-02
+ -6.427419847147e-02
+  2.013722097199e-02
+ -3.380510224926e-03
+  4.682420343601e-02
+  2.879909508354e-01
+  9.027989029621e-02
+  3.108231232796e-02
+ -1.318310495778e-01
+  2.063596149510e-01
+  7.235114140076e-02
+  3.019197357903e-03
+  9.481663463129e-02
+  2.309089083956e-01
+ -1.518884627545e-01
+ -4.228879879377e-02
+ -1.123182537680e-01
+ -8.070893978130e-02
+ -3.254200370032e-03
+ -1.574848315172e-04
+  1.323587916447e-01
+  8.809529781305e-02
+  1.468630270445e-01
+  9.951460432571e-02
+  1.350552929313e-01
+ -5.056534847098e-02
+ -7.519975297912e-02
+  1.744122517735e-02
+ -1.233920625286e-02
+ -1.826590613240e-01
+  9.905508678441e-02
+ -1.463216398476e-02
+  7.008151334948e-02
+  2.735625274235e-02
+ -3.418354412006e-02
+  1.480087549524e-01
+  3.340139245103e-02
+ -1.548882860827e-01
+ -1.454058648650e-01
+ -3.350929186705e-02
+  4.019919594755e-02
+ -8.016412877663e-02
+ -1.832017553579e-01
+ -3.578031595444e-02
+ -4.429964315106e-03
+  1.733617887858e-01
+ -5.560435351054e-02
+ -1.955193730805e-02
+ -7.192237465219e-02
+ -1.519841428623e-01
+  1.563094375333e-01
+  4.309252746671e-02
+  5.634438573077e-02
+ -1.532976700604e-02
+  1.039419631102e-01
+ -4.665288878667e-02
+ -2.788244814574e-02
+  3.610296367453e-02
+ -9.347429021670e-02
+  3.195701193513e-03
+  6.898862946912e-02
+  1.383744997559e-02
+  9.579882982152e-02
+ -9.979324794746e-02
+ -1.110189642088e-01
+ -6.982285097189e-02
+  4.420058973946e-02
+  2.350549515273e-02
+  1.720576683730e-01
+ -1.080421928084e-01
+  7.933647197015e-02
+  3.226273726893e-02
+  8.785853156684e-04
+ -1.292855964799e-01
+ -1.293089206893e-01
+ -9.703366452320e-02
+ -6.298341705144e-02
+  3.553497753465e-02
+  5.093683662300e-02
+ -3.994153291669e-02
+ -2.726921560681e-02
+  1.534387570324e-01
+  2.117831667323e-03
+ -7.373062950886e-02
+ -5.061567353989e-02
+ -2.123536354289e-02
+ -1.028550975424e-01
+ -6.665586518044e-02
+  1.201821696968e-01
+ -1.211631947610e-02
+ -1.000940518950e-02
+  2.433353430253e-02
+ -2.132295348656e-02
+  7.998414025531e-02
+  2.146000113717e-01
+ -3.792076155570e-02
+  9.748379902929e-02
+ -1.108258546134e-02
+  6.906126860735e-02
+  1.689886331569e-01
+  5.296601595919e-02
+  7.742291872137e-02
+ -1.768631527976e-01
+ -1.747574972877e-02
+  6.696208479160e-02
+ -2.870840868480e-01
+ -1.703545081333e-01
+ -9.068511799477e-02
+  3.340319640131e-02
+ -2.922761099965e-02
+  6.618959337830e-02
+  1.791507679399e-01
+ -6.350081543114e-02
+  2.365821169252e-02
+  2.313424179830e-01
+  1.917208448423e-02
+  1.970066546064e-01
+ -6.647376881465e-02
+  2.443331065833e-02
+ -4.961482632902e-02
+ -1.176995117889e-01
+  6.468993163437e-02
+ -1.274330602111e-02
+ -2.511411950955e-02
+  5.527507886007e-02
+ -4.723840311590e-03
+ -7.710806454086e-02
+  1.718600721430e-02
+  1.880826914960e-01
+  1.784530177559e-03
+ -1.409749975454e-01
+  3.579637830820e-02
+ -3.754982201126e-03
+  1.765554594553e-02
+  6.829231183322e-02
+  8.476338717848e-02
+ -4.846047626125e-02
+ -3.124712403789e-02
+ -1.015111726619e-01
+ -9.078274138326e-02
+  7.968428582378e-02
+ -9.875019569400e-02
+ -4.913067164694e-02
+ -3.132333174394e-02
+ -9.036957838852e-02
+ -4.208289056988e-02
+ -9.952077240122e-02
+ -4.031762210843e-03
+  1.727346102036e-02
+ -1.436728201515e-01
+ -2.173766674902e-02
+ -2.157958550376e-01
+ -4.568271825810e-02
+ -6.980855070850e-02
+  3.870771756678e-02
+ -3.755505423571e-02
+ -2.481271634624e-01
+ -7.389813912673e-02
+  6.642292693616e-02
+  2.196995556028e-01
+ -1.408772533264e-01
+  3.362247324829e-01
+ -1.388299025946e-01
+ -1.771329301121e-02
+  1.247141818133e-01
+  5.396578912737e-02
+ -6.975539625725e-02
+  1.865366345357e-01
+  7.134945106496e-02
+  4.378204209475e-02
+ -3.240183622764e-02
+ -8.294425007898e-02
+  2.537071241703e-01
+  3.107840591807e-02
+  2.584007254610e-01
+ -7.595339470319e-02
+ -7.595840412267e-02
+  6.370211309710e-03
+ -1.540134162843e-01
+  2.260472128589e-03
+  2.188933186234e-03
+ -1.702517092992e-02
+  1.347333002584e-01
+  1.368199668926e-01
+  1.159320294277e-01
+ -6.263644107445e-02
+  6.502613172908e-02
+ -1.377892645547e-01
+  1.747004024227e-01
+  2.016412488642e-02
+  1.040124657709e-01
+ -7.579749255722e-02
+ -4.200483416157e-02
+ -7.078474162911e-02
+ -2.536868735433e-02
+ -1.729331967605e-01
+  1.107807326091e-01
+ -8.995189383533e-02
+ -1.089061068270e-01
+  1.452877824886e-01
+  2.808266046973e-01
+ -1.048473382998e-01
+ -4.976026458163e-03
+ -1.098784977646e-01
+  7.487149068481e-03
+  7.196820350755e-02
+ -4.982954580136e-02
+ -5.078296667883e-03
+  1.679987024697e-01
+ -4.664490896203e-03
+  1.579010197564e-02
+ -1.388186007038e-01
+ -1.082368910851e-02
+ -1.817524950755e-01
+  1.683627102250e-02
+  1.235888900895e-01
+  2.725594090500e-02
+ -1.120358855610e-01
+  1.675492380316e-01
+  4.716312720694e-02
+ -2.118745379892e-01
+  6.699904193240e-02
+ -1.849942135551e-01
+  3.459241152101e-02
+  8.104361918221e-02
+  2.165887637667e-01
+  2.777580138271e-02
+ -1.002732260641e-01
+  8.018240181307e-02
+  7.622931619175e-02
+  2.882894131704e-03
+ -2.715343141624e-01
+  7.552478970959e-02
+  1.350245439169e-01
+  7.454129802408e-02
+ -7.996557362693e-02
+ -1.079842327610e-01
+ -5.886534602896e-02
+ -1.199043452993e-01
+ -1.199107857841e-01
+ -7.228766443119e-02
+ -9.028789085180e-03
+  2.911964051489e-02
+ -9.108415488615e-03
+  9.921020510873e-03
+ -3.085961899019e-01
+ -5.715648610993e-02
+ -1.019647436027e-01
+  2.998853736074e-01
+  2.029909879797e-01
+  6.435265160181e-02
+ -1.118965528230e-01
+  1.442946068281e-01
+ -1.488739228859e-01
+ -3.638386630367e-02
+  7.408789062180e-02
+  8.661716055737e-02
+  1.329713817876e-02
+  2.087350272732e-01
+  1.449253417027e-01
+  9.853085870536e-02
+  9.673258240763e-02
+  2.799632762194e-02
+ -4.337422735214e-03
+ -1.154600295329e-01
+  3.243216751591e-02
+ -2.783261997335e-03
+ -5.262014054667e-02
+ -1.496841527764e-01
+ -7.302297526851e-02
+  1.325530573219e-01
+ -1.143716899093e-02
+  6.563874314208e-02
+  1.086675006110e-01
+  6.501250456285e-02
+  1.175524766335e-01
+ -1.575813583266e-01
+  3.374259503414e-02
+  9.068404328112e-02
+ -7.976656141632e-02
+ -1.028412552587e-02
+  8.415674119706e-02
+ -4.547937279659e-02
+ -1.005251744665e-01
+  1.195719225529e-01
+ -5.589825427382e-02
+ -3.617174610764e-02
+  5.835102171570e-02
+  2.190633456754e-02
+  3.391545503988e-02
+ -1.840451121615e-01
+ -9.254365166874e-02
+ -7.360829342020e-02
+  1.695084675501e-01
+ -2.474701160286e-02
+  3.898811644847e-02
+ -1.152045271113e-01
+  3.904520502578e-02
+ -1.202659330728e-01
+  1.125264811316e-02
+  3.917497899232e-02
+  7.533464931619e-02
+  1.981617696645e-02
+ -4.552613963657e-02
+  9.085468917730e-03
+ -8.912656974633e-02
+ -1.189674108460e-01
+  4.832899114960e-03
+ -1.015776265228e-01
+  4.793434794595e-02
+  3.382634745893e-02
+  8.885056426712e-03
+  3.914930390548e-02
+  1.073569718473e-01
+ -6.251666018723e-03
+ -1.629866446336e-02
+ -5.062579677046e-03
+ -5.943378126813e-02
+ -1.625091205813e-01
+  3.421573844088e-02
+  1.015325290491e-01
+ -6.016003096153e-02
+ -1.176094459468e-01
+  1.647938521462e-03
+ -2.778910588949e-01
+  8.238057263280e-02
+  1.596487301650e-02
+ -4.619013854740e-02
+ -3.345186659048e-01
+ -3.300502671926e-02
+ -1.748888412595e-01
+  5.043043366789e-02
+  1.168395066670e-01
+ -6.722554796508e-02
+  5.446949691922e-02
+  1.375568002009e-01
+  1.361665859417e-01
+ -2.917312097095e-01
+ -1.490862068869e-01
+  4.812375406532e-02
+ -1.084654043909e-01
+ -5.766722760751e-03
+ -5.780124708514e-02
+ -1.545356438747e-01
+  5.278725042445e-03
+  6.298273412436e-02
+  2.200028342376e-02
+  1.923212867352e-02
+  1.550777668559e-01
+ -9.404361629581e-02
+  1.529945549251e-01
+  4.299899404061e-02
+ -7.010595023184e-02
+  2.227193250852e-01
+  3.739891244068e-02
+  9.955563955862e-02
+ -1.891664838422e-01
+  1.380452134828e-02
+  1.230389189622e-01
+ -6.366460889782e-02
+  8.003237339174e-02
+ -9.499055246373e-03
+  1.665572558835e-02
+ -1.320829513167e-02
+  3.286406709706e-02
+  4.594939133358e-02
+ -4.927801113988e-02
+ -1.308190465038e-01
+  6.041341575697e-02
+ -1.090101151510e-01
+  3.647205583611e-02
+ -1.335189360601e-01
+ -6.560223453331e-02
+  2.872399457903e-02
+ -1.754322036072e-03
+  1.507652351472e-01
+ -3.686757582378e-02
+  1.860200159739e-01
+  1.233260699486e-01
+ -9.972618701855e-02
+  2.272667825027e-02
+  4.681099602698e-02
+  2.311723342041e-02
+ -2.447906237999e-02
+  3.568082057627e-02
+  1.482045376261e-01
+  7.388756658156e-02
+  1.958581166658e-01
+ -1.859496124422e-02
+ -1.682070206360e-01
+ -1.639474843471e-01
+ -2.202925866145e-01
+ -1.289542106147e-01
+  3.978190910157e-02
+ -8.892820273112e-02
+ -8.461120289182e-02
+  9.065476346518e-03
+  1.913327974672e-02
+  2.654683570614e-02
+ -7.685458000970e-02
+ -1.441202207230e-01
+  4.903227193214e-02
+  4.124925083704e-02
+  1.360221741324e-01
+  9.967686364836e-03
+  6.737152231896e-02
+ -9.948540715928e-02
+  1.876857724533e-02
+  2.212425941120e-02
+  2.082163506116e-01
+ -1.778715614089e-01
+ -1.467743498283e-02
+ -9.782553558861e-03
+  2.939855342547e-02
+ -1.014680281099e-01
+  2.585170798885e-03
+ -1.979337664058e-01
+  2.631653784122e-03
+ -1.049465764343e-01
+ -2.173531406840e-02
+  2.567802839760e-02
+ -7.882574536533e-02
+  2.318199940543e-01
+ -1.023047911134e-03
+  2.223096713545e-02
+  1.321823099735e-01
+  3.815223600718e-02
+  1.874487298628e-01
+  6.061062956308e-02
+ -2.091100407687e-04
+ -1.993025106304e-02
+ -1.380922415814e-01
+  3.484772289311e-02
+ -6.159979043169e-02
+  9.688399367432e-02
+ -6.478916321908e-02
+ -5.855164830945e-02
+  1.267786080525e-02
+ -9.612968123497e-02
+  8.873779173602e-02
+  6.191898852909e-02
+ -2.472702019606e-02
+  2.665625220758e-02
+ -3.802802427993e-02
+ -1.301011573536e-01
+  1.581367942220e-01
+ -1.134546516711e-01
+ -4.497156954608e-02
+ -8.434301183913e-02
+ -9.333053623857e-02
+  1.277837030274e-01
+  5.692171406501e-02
+ -1.384824793809e-02
+ -2.913844539617e-02
+ -5.381204537411e-02
+  1.457191008041e-02
+  1.945278574380e-01
+ -9.347518655126e-02
+  1.893196736138e-01
+ -1.141673241172e-01
+ -5.419432066023e-02
+  4.843264798515e-02
+ -1.054598542146e-02
+ -1.278079089210e-01
+  9.118771024130e-02
+  1.469704814884e-02
+ -1.640920723793e-01
+  1.254596517796e-02
+ -1.152282578946e-01
+ -8.065353523608e-02
+ -2.221546317198e-01
+ -1.299846566680e-01
+ -1.410044904883e-01
+ -2.866096523936e-02
+ -7.928351367302e-02
+  1.146551305905e-01
+ -9.807669576821e-04
+  1.565345592215e-02
+  8.788231755870e-02
+ -2.182638433279e-01
+ -1.020575540430e-01
+ -6.502366281758e-02
+  1.641047567026e-01
+  1.155316627339e-02
+  1.038487553042e-01
+ -8.854802972192e-03
+ -6.385366018082e-02
+ -2.227436588456e-02
+ -1.312108612995e-01
+  4.917339187972e-02
+ -1.080307991503e-02
+ -5.527950774420e-02
+ -4.588766692037e-02
+ -1.251369652086e-01
+ -1.860528960577e-01
+  1.189404732080e-01
+ -1.215092339995e-02
+  2.631050770016e-01
+ -1.217850545138e-02
+ -7.923340666333e-03
+ -6.690869904170e-02
+  1.615688716483e-01
+  1.923839570338e-02
+  5.091258956528e-02
+ -6.749186524700e-02
+  5.238939804670e-02
+ -1.090835340586e-01
+  6.493852845360e-02
+ -3.712489088333e-02
+  5.413494360800e-03
+ -1.058619211446e-02
+ -3.490152732501e-02
+ -7.366074454303e-02
+ -2.258853208016e-01
+  5.284024007942e-02
+ -1.438638670048e-01
+ -4.241274427123e-02
+ -3.430257542244e-02
+  1.754931134890e-01
+ -7.115039753855e-02
+  2.697476594964e-02
+ -1.321390831114e-03
+ -2.151963707295e-01
+  1.163599388882e-01
+ -7.455566348474e-02
+  6.763534196826e-02
+ -2.464645245432e-01
+ -4.001081947626e-02
+  5.108672415442e-02
+ -6.144950778393e-02
+ -4.628925059831e-02
+ -1.118252382570e-01
+ -1.547314187918e-02
+ -8.618604145195e-02
+  1.507174334300e-01
+ -2.289507105384e-02
+ -1.383769649577e-02
+ -5.011573483286e-02
+ -5.312293413149e-02
+  4.349089658588e-02
+  8.258513261616e-02
+ -9.024142440059e-02
+ -7.059481969419e-02
+ -1.595224016754e-01
+  6.951554444294e-02
+ -1.272964935595e-01
+  3.076515318672e-02
+  7.989958906878e-03
+ -1.089276837161e-01
+  1.994441286171e-01
+ -3.660727559852e-02
+ -3.062398910361e-01
+ -2.638527002192e-02
+ -1.192533306111e-01
+  3.196421108617e-02
+ -1.578091306278e-01
+ -1.452598972625e-02
+ -1.868924767919e-02
+ -1.056233444214e-01
+  1.104207741247e-01
+ -3.381878993055e-02
+  1.837964070661e-02
+ -7.899534211908e-03
+ -5.032803836260e-02
+ -1.114801208026e-01
+  2.511706426649e-02
+ -5.015174065311e-02
+ -2.552824334372e-02
+  4.809669212874e-02
+ -1.382315603276e-01
+  1.251819358275e-02
+ -9.913323036750e-02
+  1.047199597113e-01
+  1.612349234999e-02
+  7.715023415324e-02
+ -5.398143483461e-03
+ -6.787418042296e-03
+ -2.417520922808e-03
+  7.718614490351e-02
+  8.010346644566e-03
+  2.183294995401e-02
+  1.889870022038e-01
+  7.718690049039e-02
+  2.592677589770e-02
+ -3.088405647078e-03
+ -1.668254311170e-01
+ -8.847391887204e-02
+  1.544610599348e-01
+ -7.019107719401e-02
+  2.943281490554e-02
+ -6.665138014660e-02
+  5.792706159570e-02
+ -1.618852074873e-01
+  1.401865497500e-01
+ -7.894368062307e-02
+ -1.419553764465e-01
+ -1.387814017591e-01
+  9.529975027128e-02
+ -6.537609954119e-02
+ -6.431222883740e-02
+ -7.657011413871e-02
+ -3.281942422858e-02
+ -1.311092482671e-01
+ -4.999868362051e-02
+  9.284772353033e-02
+ -2.684192448185e-01
+ -6.280982965653e-02
+  1.678681513152e-02
+  1.073705486846e-01
+  1.001015459016e-01
+  6.036696219415e-02
+ -1.143861639485e-01
+ -1.091052888756e-01
+ -6.161140729972e-02
+ -7.330347476782e-02
+  4.499503365728e-02
+  3.894632120144e-02
+ -3.470549254247e-02
+ -1.071195269500e-01
+  2.584977820114e-02
+ -1.885258599559e-02
+  7.279665008703e-02
+ -1.044749778995e-01
+ -1.619020846534e-01
+  5.801838325474e-02
+ -5.246122033087e-02
+ -3.923057688742e-02
+  4.064968231059e-05
+  4.893346672681e-02
+ -1.334095169158e-01
+  1.398324017276e-01
+  1.238604431562e-03
+  2.071262463350e-01
+ -4.321111359843e-03
+ -6.217713660643e-02
+ -3.976731829125e-02
+  4.900103436355e-02
+ -3.887269313343e-02
+  5.240807774248e-03
+ -5.716120547466e-02
+  1.252790957580e-01
+ -9.672655945214e-03
+ -1.313374532359e-01
+ -1.541893712543e-01
+  1.395353938834e-02
+  9.107845359257e-02
+  7.889501522955e-02
+ -6.126459087254e-02
+  6.319422948138e-02
+ -2.096379388592e-01
+  9.082496817240e-02
+  2.089394166108e-02
+  1.387451495208e-01
+ -1.202929383717e-01
+  7.997821712759e-02
+ -1.542715771452e-01
+  4.336477190650e-02
+  1.817728735119e-01
+ -1.048485009275e-01
+ -1.671928694925e-01
+  9.860308139854e-02
+  4.579017121421e-02
+ -1.312677398766e-01
+ -1.165508892979e-01
+  6.247528527570e-02
+ -1.477482526115e-01
+  7.592408531673e-02
+ -5.251062928360e-02
+ -8.927585925627e-03
+ -9.003133298666e-02
+ -2.578990556566e-02
+ -6.534177616771e-02
+  1.278276962435e-01
+  2.003037413280e-02
+ -8.886908466484e-02
+  9.566799838723e-02
+ -1.624725644806e-02
+ -5.379340786242e-02
+ -2.227458355903e-01
+  1.434439148561e-01
+ -2.274573211021e-02
+ -6.644379122837e-03
+ -2.746073806590e-02
+  6.213107305798e-02
+ -4.444174830418e-02
+  3.856675560265e-02
+ -1.699238277132e-01
+ -8.077029832749e-04
+  1.245399318697e-01
+  1.623223971955e-02
+ -1.080676496908e-01
+ -9.942226348008e-02
+ -1.446319626634e-02
+ -7.370172942282e-02
+  3.468890952768e-02
+ -8.869444360350e-02
+  3.628920230430e-02
+  5.386499726436e-02
+  2.888550873871e-03
+ -1.758893912443e-02
+  4.313719564921e-03
+  4.133839674667e-02
+ -2.226673788137e-02
+  1.704146545817e-01
+ -7.581429369915e-02
+ -2.426468808646e-01
+ -9.886006940855e-02
+  3.018782740565e-02
+  3.657850667181e-02
+  2.994128603036e-04
+ -1.348122797299e-01
+  3.096763919261e-02
+ -8.382656251369e-02
+  1.580226651418e-02
+ -1.205794701210e-01
+ -9.258588349996e-02
+ -2.510117368009e-02
+ -1.435671618464e-01
+  1.703937058596e-01
+ -1.287994718874e-01
+  9.399229845755e-02
+  4.573877083662e-02
+ -1.073236282471e-01
+ -2.345167389493e-02
+ -1.230369946109e-01
+  6.823372554954e-02
+ -1.244583719192e-01
+  3.935445053949e-02
+ -1.673585961852e-01
+  1.394930062039e-01
+  2.670195508462e-02
+  1.584140429626e-01
+  3.867743324806e-03
+  1.099142977793e-01
+ -2.828995186482e-02
+ -2.130504876131e-03
+ -2.115092381117e-02
+ -7.675925513060e-02
+ -4.156495393727e-02
+ -5.943498346215e-02
+ -2.324593378000e-01
+ -1.611290706075e-01
+  5.380728476819e-02
+  1.281936996277e-02
+  3.192920869936e-03
+ -2.995675923191e-02
+  1.848239947087e-01
+ -1.066847952108e-01
+  3.361865189875e-02
+  5.442504571305e-02
+ -1.006593866697e-01
+ -3.697715396348e-02
+  9.903879655588e-02
+  8.633920679539e-02
+ -2.161356938098e-02
+ -9.617169219715e-02
+  1.816474724025e-01
+ -1.949346290995e-01
+ -5.623453899598e-02
+ -8.334754274938e-02
+  9.156625270929e-02
+ -1.994733804394e-02
+  2.018436893919e-02
+  3.613625350989e-02
+ -6.473783807356e-03
+  6.075020709134e-02
+  6.903052148833e-02
+ -1.649064224254e-01
+  1.140636768631e-01
+  1.064327707554e-01
+ -2.198316886768e-01
+ -1.245695990884e-01
+  3.596206292885e-02
+ -3.960261189670e-02
+  2.580682088117e-01
+ -5.341615324864e-02
+ -8.282306799678e-02
+ -1.357609850022e-01
+  2.600675942333e-01
+ -3.637107849517e-02
+ -2.288007994239e-03
+  1.775426818847e-02
+ -8.130039109321e-02
+  7.648596468270e-03
+ -2.306011732855e-02
+  1.980845313623e-01
+  1.727439882046e-01
+ -1.185017608460e-01
+  1.077171974204e-02
+ -1.221028131074e-01
+ -1.212488792478e-01
+  1.700218001264e-02
+  1.289495866454e-01
+ -7.213494304710e-02
+ -7.008432671651e-02
+  4.491200909550e-02
+  1.142625406773e-01
+ -1.108321330254e-01
+  5.861289879091e-02
+  5.921518089577e-02
+ -4.245421973536e-02
+  9.358686567874e-03
+  1.355974792579e-01
+ -2.908292668227e-01
+  6.168763407858e-02
+ -2.066312734055e-02
+ -1.005627580039e-01
+  5.381161811614e-02
+ -1.707384230369e-02
+  6.466182155664e-02
+  4.920708874942e-02
+ -1.274987575961e-01
+ -2.051379026449e-01
+  2.108375574562e-02
+ -1.156060090128e-01
+ -1.833361278732e-02
+  2.727161786414e-02
+ -7.754349328248e-02
+  7.111811850391e-02
+ -1.454389537207e-01
+ -2.947039999690e-02
+  1.260678373976e-02
+ -6.971049270135e-02
+  1.499346059295e-02
+  3.230991239250e-02
+ -6.290777231336e-02
+ -4.992659588745e-02
+  6.713885983799e-02
+ -8.083071075514e-02
+  3.120649895743e-02
+  2.249947143327e-02
+ -4.130946365811e-02
+ -5.845542347729e-02
+  1.001019698399e-01
+  4.861340956127e-02
+ -6.495713768066e-02
+ -1.737481250376e-02
+ -1.147284850982e-01
+ -1.738088727204e-01
+  7.976158184455e-02
+ -8.663959743717e-02
+ -9.035987325816e-02
+  1.883920491653e-01
+  1.376212420018e-01
+  7.217904167927e-02
+  1.828906370542e-02
+ -6.181089329734e-03
+ -8.774156867926e-02
+ -1.022269815129e-01
+  1.192815662492e-01
+ -7.565668154663e-02
+  6.843893782644e-02
+  8.331768316416e-02
+  4.647167181091e-02
+ -1.342318010341e-01
+  4.142867025229e-02
+ -4.945473950878e-02
+  6.015586358803e-04
+ -3.738440093111e-02
+ -2.626429395975e-02
+  4.546368074373e-03
+  3.914847019773e-02
+  1.428858741880e-01
+  1.345935444732e-01
+  5.670944071360e-02
+  5.766773702733e-02
+  2.002016170330e-02
+ -1.296532811550e-01
+  4.129523043523e-02
+  2.813676622870e-01
+ -7.655513713199e-02
+ -7.111195268840e-02
+ -2.966637781456e-02
+ -1.575797949359e-01
+  2.080175410525e-02
+ -1.579371222342e-01
+ -1.661010202218e-01
+  1.258555163637e-02
+ -1.961040857008e-01
+  7.547092064586e-02
+ -2.547634931782e-01
+ -7.443543911048e-02
+ -9.153831984883e-03
+ -1.042715179904e-01
+  1.399302401733e-01
+ -5.511321736293e-02
+  5.334859553620e-02
+  1.330849283268e-01
+  2.813207825859e-02
+ -1.686151298193e-01
+  5.331178907203e-02
+  3.261038402309e-02
+ -6.804688886244e-02
+ -1.851687769721e-01
+ -6.743859481174e-02
+ -3.920174768989e-02
+ -2.386869618092e-03
+ -8.369346651068e-02
+  3.298173373965e-02
+ -1.363786864469e-02
+  4.356083939266e-04
+  1.520116285848e-01
+ -1.285788201952e-01
+ -1.104897562129e-01
+ -2.111695733184e-02
+ -3.060177230918e-02
+ -1.274144075905e-02
+ -2.237661009180e-01
+ -5.044407311085e-02
+  3.942216095764e-02
+ -2.486523286050e-02
+  4.553404951992e-02
+ -5.977735605577e-02
+ -6.921303078360e-02
+  7.051768873100e-02
+  6.316544611191e-02
+ -4.481621636638e-02
+ -1.073502617536e-01
+ -3.306418047092e-03
+ -8.587850338640e-02
+  2.278881746558e-01
+  6.610463394973e-02
+ -5.125371093146e-02
+ -1.014592836968e-01
+  9.016554777248e-02
+ -9.212453285722e-02
+ -2.046705751097e-02
+  9.362105484959e-02
+  1.648098883288e-01
+ -3.526092648372e-02
+  6.540683728607e-02
+ -3.563798630096e-02
+ -3.442120217805e-02
+ -8.503505993709e-03
+ -8.206461439478e-02
+ -1.146221492616e-02
+  1.845818475693e-02
+ -2.326548053061e-01
+ -1.655652003232e-03
+ -1.230327255383e-02
+  5.129970068986e-02
+  1.193884984472e-01
+ -7.938701721070e-02
+ -5.603985115612e-02
+ -9.384894041793e-02
+ -9.444838940683e-02
+ -6.131041566120e-02
+ -1.162697919703e-01
+ -9.837419860091e-03
+  2.064343807917e-01
+  4.857227513773e-02
+  5.292526167324e-02
+ -2.712558770883e-02
+ -3.574490405760e-02
+ -2.222325779882e-03
+ -8.565680984804e-02
+  3.841991014853e-03
+  3.458516521776e-02
+ -2.576794828646e-02
+  1.306933956299e-01
+  1.358455208882e-01
+ -1.496169766445e-01
+ -8.468993590787e-02
+  3.070618785757e-03
+  6.922059840435e-02
+ -2.026480425058e-01
+ -6.598554896005e-02
+  1.525696465554e-01
+ -5.190936614206e-03
+ -5.407719939872e-02
+ -9.473468355503e-02
+  1.254146008157e-02
+ -4.172779886548e-02
+ -2.418121192277e-01
+  3.838234436773e-02
+  2.902265556502e-02
+  7.547984791644e-02
+ -1.591629039143e-01
+  7.850444656719e-02
+  5.275357955477e-02
+  9.998319535146e-02
+ -9.186157721221e-02
+ -5.000880315786e-02
+ -7.758143697407e-02
+  2.115319910626e-01
+ -2.475938630574e-02
+ -1.298727287239e-01
+  1.411363846014e-01
+ -7.095785975493e-02
+  1.191033039478e-01
+  1.578717207585e-01
+  1.164189850010e-01
+  1.497925811406e-01
+ -4.693700733064e-03
+ -5.409319620011e-02
+ -5.562636364551e-02
+ -3.680957609332e-04
+  1.166411074976e-01
+ -1.864004522784e-02
+ -1.991011520836e-01
+ -1.792639645760e-03
+ -1.525356923218e-01
+ -9.602468304787e-02
+  2.199212874427e-01
+  7.696381632603e-02
+  5.136870696207e-02
+  1.669609999039e-01
+ -5.265844483870e-02
+ -8.508672993339e-02
+  1.062957243300e-01
+ -8.434320597477e-02
+  1.694982928480e-01
+  2.592519374494e-03
+  5.750401396361e-03
+ -2.317913460863e-02
+ -1.245817026190e-01
+ -1.460690461151e-01
+ -7.730537627893e-02
+  8.394523027039e-02
+ -3.581024714520e-02
+ -1.319673383799e-01
+  1.691330362786e-01
+ -1.469868319371e-01
+  1.574720020849e-02
+  2.934813778677e-02
+ -1.172402844965e-01
+ -3.391339725593e-02
+  2.470915097605e-01
+  2.388353589553e-01
+  3.182153610792e-02
+ -4.118809327344e-02
+  5.617866368888e-03
+ -7.506079068028e-02
+ -1.174776429439e-01
+ -8.139659304129e-02
+ -2.393878063032e-02
+  1.081469892911e-01
+  6.503787466713e-02
+ -1.860205776133e-01
+ -3.776581294666e-02
+  1.804972565374e-01
+  1.501457856348e-02
+  5.967019272195e-02
+  6.457347505628e-02
+ -6.144389033981e-02
+  1.115579112634e-01
+  1.370655454311e-01
+  3.898429198242e-02
+ -1.371963624874e-02
+ -3.820587178173e-02
+  2.101624643444e-01
+  4.332205787593e-02
+ -6.983434505528e-02
+ -7.253343789007e-02
+  1.894374904567e-02
+  7.621988676589e-02
+  1.298012171698e-01
+ -3.065428084086e-02
+  1.254342845440e-02
+ -9.931249882381e-02
+  1.506895988018e-01
+  1.272373625367e-01
+  2.099774762691e-02
+ -2.293904320850e-01
+  1.674723585892e-01
+  8.382658794426e-02
+  2.694341468337e-02
+  4.290472945736e-02
+  1.213738882578e-02
+  8.533464445772e-03
+ -1.566789933250e-01
+  1.046152627942e-01
+  5.226839136154e-02
+  5.809093688825e-02
+  1.429845147966e-01
+  1.698636918002e-02
+ -9.121364342087e-03
+  2.111146343833e-02
+ -1.400932306113e-01
+ -4.308625060581e-02
+  1.574083862212e-02
+  1.635448731465e-01
+ -2.125340985869e-02
+  8.220454305960e-02
+ -6.658966654235e-02
+  1.122048850062e-02
+ -1.208915578745e-01
+ -3.918603270595e-02
+  4.135240167208e-02
+ -5.515706888026e-02
+ -1.950067058286e-01
+  2.410178547781e-02
+  2.859566219094e-02
+ -2.319426193918e-02
+ -5.125077208184e-02
+ -8.792648781204e-02
+  1.811504986816e-01
+  8.361521284049e-02
+  6.459572855489e-02
+ -2.110953705476e-01
+ -1.473510801814e-01
+ -9.497421543171e-02
+  2.071756281443e-01
+  1.400110887953e-01
+ -1.396311824675e-01
+ -1.032377962033e-01
+ -5.638871946330e-02
+  1.617839722827e-01
+  1.056420653247e-01
+  4.476953818315e-02
+  5.186513293112e-02
+  4.702494387429e-05
+ -1.935216770061e-01
+ -2.255523926506e-01
+  3.436001703353e-02
+ -8.248762528899e-02
+ -3.862874258873e-02
+ -5.777609071169e-02
+ -2.841044260914e-02
+ -1.193006469664e-01
+ -9.080980100140e-02
+ -6.713518264724e-02
+ -7.908172761824e-02
+ -2.177163358056e-02
+ -4.982665474639e-02
+  4.295932994964e-02
+  1.001941620051e-01
+  1.210665425574e-01
+  2.220795748433e-02
+  2.182296189129e-02
+ -1.404641729732e-01
+ -3.140207349165e-02
+  1.095493347639e-01
+  1.146950120023e-01
+  1.474154979266e-02
+  1.146782498604e-01
+  4.516739701604e-02
+ -6.519936858389e-03
+  4.810342492463e-02
+  3.828258248043e-02
+  8.548953908570e-02
+  1.174994157953e-01
+ -5.934299010447e-02
+  1.831232083163e-01
+ -2.482845803903e-02
+  8.687105567701e-02
+ -4.138259453031e-02
+ -3.842149296473e-02
+  1.049488897918e-01
+ -3.193804806753e-02
+ -1.995172967380e-02
+ -2.638174502973e-01
+ -1.092463877911e-01
+ -9.218603570274e-03
+  1.240990064855e-01
+ -1.836363975863e-02
+  4.250599596125e-03
+  2.196095193393e-01
+  1.466119670049e-01
+  2.112092499287e-02
+ -5.962578498012e-02
+ -1.344333476027e-01
+ -9.718524749266e-02
+  5.256929699912e-02
+  5.732337850254e-02
+ -5.265263155833e-02
+  1.228180447290e-01
+ -3.260275976178e-02
+ -8.889160237339e-02
+  5.485981092150e-02
+ -6.938146550500e-02
+  1.889557075688e-01
+  8.408880766546e-02
+ -7.976999175658e-02
+  1.035304806555e-01
+ -1.182311520818e-01
+ -2.347680555227e-02
+ -1.888726432078e-01
+  1.253103569983e-01
+ -8.485080205276e-03
+ -2.697254775350e-02
+ -5.510589849627e-02
+ -8.030488930050e-02
+ -2.243922514529e-02
+ -8.508377472454e-02
+ -2.937521454491e-01
+  8.223003403255e-02
+  6.135797548561e-02
+  1.904419826648e-01
+  4.713594421359e-02
+ -1.788953977338e-01
+ -1.885008119094e-02
+  5.146366005420e-02
+  1.809685324083e-01
+  2.044391327864e-02
+ -1.782944470419e-01
+ -2.313404873046e-02
+ -7.343971066910e-02
+ -2.596137722985e-02
+ -2.216879683539e-01
+  2.819428941875e-02
+  5.480446153560e-02
+ -4.622562215037e-02
+ -5.822502874611e-02
+  3.083470782910e-02
+ -5.978405197880e-02
+  6.558029627548e-02
+ -1.245408350235e-01
+ -1.349388697690e-01
+  2.637681308399e-02
+ -2.778183618917e-02
+ -1.810889204516e-01
+ -8.367865405309e-02
+  3.740909074677e-02
+ -2.535503608698e-03
+ -1.880556055047e-01
+  8.605887478576e-02
+ -5.081214751897e-02
+ -7.978203520492e-02
+ -7.486498134356e-02
+ -8.763929987865e-02
+ -3.790951632593e-03
+  2.396815723645e-01
+  3.206290156640e-02
+  2.393874179249e-02
+  2.295481244363e-02
+  9.758891090915e-02
+  7.544009720358e-02
+  7.791277147859e-03
+  1.257171938510e-02
+  7.175349876852e-02
+  1.377927409422e-01
+ -9.696831738144e-02
+ -9.913368114993e-02
+ -1.567082207216e-01
+  2.188557006960e-01
+ -3.986374663021e-02
+ -2.643088863156e-03
+  4.238128530134e-02
+  3.033329418519e-02
+  2.364105786838e-01
+ -1.612040736793e-01
+  2.554592920752e-01
+  1.881937799604e-01
+  1.538157890954e-01
+  4.886323632976e-02
+  7.888151181317e-03
+ -1.390022226953e-01
+  6.104099140795e-02
+ -1.122935587749e-01
+ -2.932048553472e-02
+ -7.024197847839e-02
+ -6.084386657068e-02
+ -1.507882362519e-01
+  1.325139171631e-01
+ -1.244317465339e-02
+  5.364511884009e-02
+  4.703513621693e-02
+  8.702006932645e-02
+  1.273318835413e-01
+  6.483001145187e-02
+ -1.813629684878e-01
+  1.959913786046e-03
+ -3.044574077961e-02
+ -1.099900732301e-01
+ -5.446275576227e-02
+  3.402458254261e-03
+  1.629001980650e-02
+  1.219519582717e-01
+ -5.570205261748e-03
+ -7.298341975058e-03
+ -6.566543144326e-02
+ -1.017800148213e-01
+  3.028667473714e-02
+  1.291559812573e-01
+ -2.984626855799e-02
+ -9.778815144047e-02
+  1.352952309302e-03
+ -9.237703381831e-02
+ -2.711067395126e-02
+  8.843310055693e-02
+ -1.638030710666e-01
+  9.101349615624e-02
+ -1.652708105315e-01
+ -8.585909866181e-02
+ -1.099373432119e-01
+ -9.266475973226e-02
+ -9.574108548743e-02
+  2.327722891315e-01
+  6.234017166706e-02
+ -4.019608732550e-02
+ -9.387385328023e-02
+  1.217154292786e-01
+ -9.583186319300e-02
+ -2.678445386151e-02
+ -1.035917924492e-01
+ -4.397502184687e-02
+ -2.410593950604e-02
+ -1.761907158842e-01
+ -3.741933341566e-02
+  2.385559875644e-01
+ -1.909938015952e-01
+ -1.605173310184e-01
+ -1.123039974711e-01
+ -9.577078495673e-02
+ -5.477503363365e-02
+ -1.046890824198e-01
+  9.335107402823e-02
+  2.468689392410e-02
+ -1.428000971201e-01
+ -8.411100089660e-02
+  4.493924915992e-02
+  2.274270206824e-01
+  4.660120736503e-02
+ -1.528747741632e-01
+ -5.867130053594e-03
+ -4.145260646701e-02
+ -4.849821236008e-02
+ -1.528314423515e-02
+  5.602870186909e-02
+  1.619590975314e-02
+ -7.643336392503e-02
+ -7.872482526967e-02
+ -1.364292204093e-01
+ -1.195608445521e-01
+  5.162156557577e-02
+ -1.872759502054e-01
+  1.625428863089e-02
+  6.888920843793e-02
+  1.450309588294e-01
+  8.005697207974e-04
+ -3.047259424177e-02
+  1.823187199661e-01
+  7.345280188914e-02
+  4.064202353703e-02
+  4.577757543079e-02
+ -5.006923002998e-02
+  1.485352499149e-01
+ -5.077006553214e-02
+ -4.826081761990e-02
+ -3.413974043318e-02
+  8.839244429952e-02
+  1.889048005490e-01
+  1.107823185190e-01
+ -3.037477801704e-02
+ -1.368062876127e-01
+  2.140685330601e-01
+ -1.752347441507e-01
+  5.088042272797e-02
+ -9.842678425978e-02
+  1.642141266713e-02
+ -3.035958894626e-02
+  1.342334550108e-02
+  5.255929204016e-02
+  2.202786803761e-02
+ -2.923703186573e-02
+ -4.228776229692e-02
+  1.093502120867e-02
+  3.814334507031e-02
+  6.403071652782e-03
+ -1.680655966768e-01
+  1.167297551989e-01
+ -9.082037082783e-02
+  2.678775244499e-01
+ -5.913608701934e-02
+ -2.271258297930e-01
+ -1.429132860497e-02
+ -8.139222698426e-02
+  4.801792727530e-03
+  1.907396976764e-02
+ -2.480086663102e-01
+  1.264567519285e-01
+  6.628848790692e-02
+  3.211616493011e-02
+  1.383617763696e-01
+  4.451096935865e-02
+  2.141665515401e-01
+ -8.377875794810e-02
+ -5.217945933055e-02
+ -4.007314861690e-02
+ -1.230330540474e-02
+  1.897033384354e-01
+  2.276178174776e-01
+ -1.394823229655e-02
+  5.734721570661e-02
+  6.598624452622e-02
+ -9.776951035053e-02
+  9.554583105403e-02
+ -1.085584444283e-01
+ -7.261098150162e-03
+  6.203946467972e-04
+  1.799262836008e-02
+  1.190511395088e-01
+ -2.803433316278e-02
+ -1.521169473000e-02
+  1.575755376100e-01
+ -7.716791501438e-02
+ -2.320479214037e-02
+  1.358466355877e-01
+  9.089363597830e-02
+ -5.705342463823e-02
+  1.663265530115e-01
+ -9.884842786961e-02
+ -1.506103941482e-02
+  2.023930056838e-01
+  9.808641063771e-03
+ -9.500781511171e-02
+ -1.715449606319e-01
+ -1.882435208252e-01
+ -1.105774149091e-01
+  3.635068801887e-02
+ -1.500163432852e-01
+  8.344942919435e-02
+ -1.141559219433e-01
+  1.615847975571e-01
+ -5.716705632299e-02
+ -4.520207905212e-02
+  4.986109383349e-02
+  3.878850947077e-02
+  4.678417986680e-02
+ -3.277520907048e-02
+ -1.015346814924e-01
+  1.379883869073e-02
+  5.084012346271e-02
+  8.280059969140e-02
+ -1.371780103565e-01
+ -2.729395110831e-01
+ -1.202627848451e-01
+  5.767608001023e-03
+ -3.906210094863e-03
+  5.979072280615e-02
+  9.408149970576e-02
+  5.113094546862e-02
+  4.152693876639e-02
+  2.416746612537e-01
+ -1.147089896032e-01
+ -2.926963098579e-02
+  9.720082215365e-02
+ -1.721126137858e-01
+  6.581020361251e-02
+ -1.223020961310e-01
+  1.114535259199e-01
+  2.176996977366e-01
+ -1.081801177657e-01
+  8.006153265822e-03
+  4.350440005691e-02
+  1.830317499407e-05
+ -1.349655050794e-01
+ -4.980517773621e-02
+  9.999709255239e-02
+ -8.547690758088e-02
+ -1.046602189430e-01
+ -7.202670586377e-03
+ -1.331255664962e-01
+  2.944228659183e-02
+ -1.018783057886e-01
+ -1.298577034830e-01
+ -4.315492985517e-02
+ -3.269661419150e-02
+  6.298112737327e-02
+ -1.448049778588e-01
+ -1.778508810768e-01
+  7.140881951286e-02
+ -1.983047237891e-01
+  2.513434171846e-02
+ -6.602005408258e-02
+  7.823318211318e-02
+ -1.186193506787e-01
+  5.187580257920e-02
+ -2.194562103865e-02
+ -5.543237233128e-02
+  2.538612664200e-01
+  6.103850414631e-03
+ -2.050666128659e-01
+  2.064328044157e-01
+  5.064262090573e-02
+ -4.867329857029e-03
+ -2.151137528773e-02
+  6.260183034506e-02
+  9.936147496007e-02
+  5.827774188694e-02
+  3.843669299509e-02
+  7.464334774432e-02
+  3.743907902223e-02
+  6.530264579656e-02
+ -4.311844674464e-04
+ -1.085154255923e-01
+  1.770740368811e-01
+  2.245642824958e-01
+  1.708625506382e-01
+  8.505350961511e-02
+ -1.603112572195e-01
+  9.858031421467e-02
+ -2.156586482423e-01
+ -1.086096314582e-02
+ -9.356733267285e-02
+  1.212383315207e-01
+ -1.575457598519e-01
+ -1.813591531442e-01
+ -5.990651863297e-02
+ -3.203149677075e-03
+  3.051328178130e-02
+ -1.224972948262e-01
+  1.651674623448e-01
+  4.911656676861e-02
+  6.572438776332e-02
+ -3.189532088261e-02
+  1.055174484007e-01
+  3.465351851996e-02
+ -1.632209456908e-02
+ -3.885026454798e-02
+ -2.013376130892e-01
+  2.463963324183e-02
+ -6.751858368286e-02
+  1.098126362315e-01
+  2.185333070969e-02
+  1.978853939842e-02
+  9.237815002507e-02
+ -1.025265155846e-01
+  1.476926447164e-01
+ -1.920823061045e-02
+ -1.236109108356e-02
+ -1.097853084520e-01
+ -5.405967688522e-03
+ -3.289763980534e-03
+  4.714188456329e-02
+  4.104370159081e-02
+  6.392307572325e-02
+  5.347956918380e-02
+ -1.305080312109e-02
+  2.516185317858e-02
+  7.197699469331e-02
+  6.864360690835e-02
+  1.253174119517e-01
+  4.673701967817e-02
+ -4.251798303184e-02
+  9.128936954503e-02
+ -1.741240455910e-01
+  5.572795479820e-02
+ -1.034379417640e-01
+ -6.029783511451e-02
+ -8.201833541385e-02
+ -5.519633994769e-02
+ -4.817864788607e-02
+  2.901263972443e-02
+  1.619502280910e-01
+  3.312349837047e-02
+ -8.347890446585e-02
+ -1.342548303633e-01
+  1.290870242409e-01
+  9.467045980609e-02
+ -2.058346372609e-01
+  5.005617977837e-02
+ -1.054627582334e-01
+ -1.317059481369e-02
+ -9.505885026616e-02
+ -1.119458237295e-01
+  3.404376269542e-02
+  1.329733061597e-01
+ -2.631850272936e-02
+  7.605546294673e-02
+  5.130575017967e-02
+ -1.193093873235e-01
+  4.700440127182e-02
+  1.079181090669e-01
+  2.198424081234e-02
+  1.144109580782e-02
+ -7.143881242185e-02
+ -5.847828601561e-02
+ -6.091370074671e-02
+ -4.801546552936e-02
+  1.277278878291e-03
+  1.214444015822e-01
+  3.244032621315e-02
+ -2.282944548452e-01
+ -1.205428944641e-01
+ -5.181647763921e-02
+ -3.469672963552e-02
+  4.949382265862e-02
+  1.193432582379e-01
+  5.902273090126e-02
+ -8.772410449645e-02
+ -1.037525688117e-01
+ -1.452207877216e-02
+ -8.363624188336e-02
+  8.037290562237e-02
+ -2.366657358536e-02
+  1.004308008097e-01
+ -8.638598537851e-02
+  8.211985518484e-02
+  2.142515945182e-02
+  8.315652462683e-02
+ -7.479076619281e-02
+ -2.456107184681e-02
+  3.725574270996e-02
+  1.621210722195e-01
+  4.466189027703e-02
+  9.606355363512e-02
+  8.552218705130e-02
+ -1.130301120925e-01
+ -5.705240567111e-02
+  1.119335830176e-01
+ -3.034088764309e-02
+ -2.438211247541e-02
+  1.092011892021e-02
+ -8.002277692571e-02
+  1.512207956303e-01
+  7.403000094873e-02
+ -2.835857558351e-02
+ -1.190082878120e-01
+  1.111846120588e-01
+  1.492208329955e-01
+ -1.203004950885e-01
+ -9.846277373179e-02
+ -1.304608286276e-01
+ -5.482842099511e-03
+  9.705721216140e-02
+ -1.347872734972e-01
+ -7.571219539593e-02
+  3.703217309759e-02
+ -6.913186715108e-02
+  1.476103784715e-01
+  1.522079571358e-01
+ -6.691104218655e-02
+ -2.724763688372e-02
+  2.495376314750e-01
+ -1.003808607295e-01
+  5.753807480714e-02
+ -5.449331938570e-02
+ -4.242063509463e-02
+ -9.669040650422e-02
+  1.767670284635e-01
+  8.037034456907e-02
+ -8.940642395595e-02
+ -8.764928554217e-02
+  6.052913340241e-02
+ -1.634514418168e-01
+ -2.316379112733e-01
+  8.222113283813e-02
+ -1.026160303774e-01
+  1.473145379610e-01
+  1.147386686853e-01
+  1.621813920343e-02
+  2.457316894645e-02
+  4.535100682530e-02
+  1.229274612529e-01
+  5.318503322097e-02
+  9.215677443928e-03
+  1.187093903325e-02
+ -5.602109235212e-02
+  8.003233626387e-03
+  9.141246413769e-02
+  1.302741859349e-01
+  4.992496224462e-03
+ -5.182389796365e-02
+  1.116128241203e-02
+ -1.487387071172e-02
+  6.592393682406e-02
+ -8.637067434651e-02
+  9.427873825580e-02
+  4.239796288116e-02
+ -1.491364808157e-01
+ -1.265968085824e-01
+  7.280574521181e-02
+ -1.109327982186e-02
+  8.613683242397e-02
+ -2.620468143214e-01
+ -7.015793456974e-02
+  5.028786925218e-02
+ -1.150738363872e-01
+ -4.435212844595e-02
+ -8.990095200108e-02
+  3.333714044244e-02
+ -1.858629112924e-02
+ -4.037651708520e-02
+  1.887156534547e-01
+ -1.577692028692e-02
+  3.512412487409e-02
+ -8.814328828678e-02
+  1.130152695129e-01
+ -5.777169819641e-03
+  9.205801757833e-02
+  1.951965525948e-01
+  1.266278846675e-01
+ -1.226617916084e-01
+  2.606018171780e-01
+ -1.982985359816e-01
+  9.886339230943e-02
+  1.099755633993e-01
+  1.097583768227e-01
+  1.411277742923e-01
+ -1.765855416454e-01
+  1.054070907736e-01
+  9.824509990612e-02
+ -1.236529246136e-01
+  4.076974497205e-02
+  2.409625233883e-03
+  1.065870611174e-01
+  4.176394677948e-02
+  2.454319461722e-02
+  3.691552567863e-02
+  2.673863552006e-01
+ -1.210036241473e-01
+ -1.730629484875e-01
+ -1.218687465803e-03
+ -8.006513447437e-02
+  1.911963035241e-01
+  2.815409173243e-02
+ -7.814037859137e-02
+ -4.814399036539e-02
+  1.361567392310e-01
+  3.003202858360e-02
+  1.544562505539e-01
+ -9.300861853242e-02
+  5.001504983986e-03
+ -4.893670962933e-02
+  3.630978997217e-02
+ -1.215122801131e-01
+  1.099464511716e-02
+ -1.987462139577e-01
+ -8.033524162410e-03
+  4.830797842708e-02
+  3.756874473511e-02
+ -3.853679480487e-02
+  6.032922154736e-02
+  7.805648555737e-02
+  6.087395242961e-02
+  1.179669252413e-01
+  1.161650801741e-01
+ -1.369315089643e-02
+ -1.015133339461e-01
+ -8.139282256072e-02
+ -6.582029565705e-02
+  8.281392569366e-03
+  6.382307331360e-02
+ -7.894199189874e-02
+ -5.129614415959e-02
+ -1.126283039151e-01
+ -1.225681502688e-02
+ -3.077125564317e-02
+  1.733240620558e-01
+  9.749194992577e-02
+ -5.100101066992e-02
+  3.554501007287e-02
+ -1.894370879622e-02
+ -3.549301470387e-02
+ -5.841223518021e-03
+ -6.408594317177e-02
+ -3.205359465615e-02
+  1.273582481382e-01
+ -3.390897156519e-02
+  1.705481150163e-01
+  8.460975272645e-03
+ -2.188385682040e-02
+ -1.962357115650e-02
+ -1.732301221752e-02
+ -3.287650472182e-02
+  3.196061728130e-02
+  3.665038923302e-02
+ -1.017772114260e-01
+ -6.007496858668e-03
+  6.645012149961e-02
+ -2.014166595898e-01
+  2.183722370825e-01
+  4.975959862441e-02
+  1.843075563894e-01
+  1.074222601818e-01
+ -7.036706200613e-02
+  6.648447475089e-02
+  6.881271941492e-02
+  1.524513334753e-01
+  7.739426544318e-02
+ -2.292815451582e-01
+  6.396676010648e-02
+ -1.064750617238e-01
+ -6.011916763801e-02
+ -5.366382361131e-02
+  1.881888639242e-01
+ -4.448750522227e-02
+  1.197737030411e-01
+  1.005193141814e-01
+ -4.424902299410e-02
+ -6.866749872683e-02
+  1.183177999606e-02
+  9.857398915499e-02
+  1.216587636220e-01
+  1.258905749198e-01
+ -4.653862179785e-02
+  1.543222380022e-01
+  9.870118667470e-02
+ -3.961493894880e-02
+  9.723060187759e-02
+  7.116276965134e-02
+  1.471454560489e-01
+ -7.998174567785e-02
+ -1.669377802544e-01
+ -5.984309569346e-02
+ -1.191963091613e-01
+  1.459502450837e-01
+ -4.005004745773e-02
+ -9.198375709978e-02
+ -3.167283947960e-02
+ -5.556246723588e-02
+  1.120144700720e-01
+ -3.258968757127e-02
+ -7.884308816171e-02
+ -9.646246778178e-02
+ -4.756984712120e-03
+  7.219574157572e-02
+  6.957035571264e-03
+ -4.657313530765e-02
+  1.211964472387e-02
+  8.034348431316e-02
+  1.194116302543e-01
+  1.486578142645e-01
+  1.891048050982e-01
+  3.457389368102e-02
+  5.396445654026e-02
+ -3.632080698861e-03
+ -5.802971434236e-03
+ -3.739358983428e-02
+  2.418337090507e-02
+ -1.270515190767e-01
+  3.492560010853e-02
+  1.164232024578e-01
+ -7.735547167626e-02
+ -9.300918500789e-02
+  1.266805526344e-01
+ -7.636422801207e-02
+ -5.465697074373e-02
+ -6.775074918142e-02
+ -1.372394676579e-02
+ -8.230551051548e-02
+  1.354219443316e-01
+ -2.471948343597e-02
+  1.971566586456e-01
+  2.649141220416e-01
+ -2.926343523744e-02
+ -9.988831477649e-02
+ -7.866407547105e-03
+  1.083050777337e-01
+ -1.463639358587e-01
+ -2.075528351463e-02
+  3.937730577148e-02
+  9.648000698935e-04
+ -1.207428751283e-03
+ -3.509260815636e-02
+ -7.419399391421e-02
+ -8.003496658484e-02
+ -3.727161956335e-02
+  1.248995705569e-02
+ -2.005160302433e-02
+  3.930978827694e-02
+ -4.329640747929e-02
+  1.371569681623e-01
+ -1.760988940820e-01
+  6.093815722135e-02
+ -3.556225534715e-02
+  1.145394961003e-01
+ -1.195543756906e-01
+  5.128446513514e-02
+  1.298682541704e-01
+ -1.317843609313e-01
+ -4.798181246964e-03
+  7.406701620461e-02
+  7.011635604844e-02
+ -7.151102196183e-02
+ -3.113394211600e-02
+  1.351638639765e-01
+ -4.949838574512e-02
+  2.492826512069e-02
+ -6.504474912026e-02
+ -6.936416816762e-02
+  6.412158643129e-03
+  1.825884189941e-01
+  1.609683012732e-02
+ -6.132253775675e-02
+ -1.348861467284e-01
+ -1.037532805681e-01
+ -1.388031749584e-01
+ -2.239516349932e-02
+ -1.140879147001e-01
+  1.019468784609e-01
+ -6.082503636924e-02
+  1.107030194631e-01
+ -8.173288333257e-02
+  4.134291086742e-02
+  5.584522103596e-02
+ -1.378316811523e-01
+  7.133368685482e-02
+ -1.781738428309e-02
+ -1.983248667424e-03
+  2.020064379062e-01
+  8.623020628471e-02
+  9.132570391418e-02
+  6.595249264600e-03
+ -1.092786097921e-01
+  1.765084574169e-01
+  6.197673937793e-02
+  2.033403587948e-02
+  7.850866764857e-02
+  3.291786234906e-02
+ -5.507087927835e-02
+ -2.870541928034e-02
+  1.729057279192e-02
+ -1.044026083263e-01
+ -2.662041683351e-02
+  2.226879029329e-02
+ -1.828165278778e-01
+  6.090239884576e-02
+  4.020205244036e-02
+ -8.323033798667e-02
+  5.628074585426e-02
+  9.036211638024e-02
+ -8.696457832005e-02
+  1.570153534443e-01
+ -3.382082841412e-02
+  8.674113825576e-02
+  1.825218053319e-03
+ -5.876976755216e-02
+ -1.323311594589e-01
+  3.333604888628e-02
+ -6.970930096378e-02
+  2.923280893331e-02
+ -2.382331299525e-02
+  5.497948000556e-02
+ -6.161976364488e-02
+  6.260040965120e-02
+  5.631252793849e-02
+ -1.031399323423e-01
+  1.375573173394e-01
+ -9.389816493160e-02
+ -3.287998912368e-02
+  3.481304615625e-02
+ -1.053828613880e-01
+ -8.903368073380e-02
+  5.923438423606e-02
+  1.439252768458e-01
+ -1.355720732080e-01
+ -6.517027804236e-02
+ -9.677883171323e-03
+  4.301067732770e-02
+ -7.198396200373e-03
+ -1.477176312008e-02
+ -1.299815893166e-02
+ -5.263013036522e-02
+ -1.005650444911e-01
+  1.527151868250e-01
+ -3.600601690692e-03
+ -7.755320476983e-02
+  3.079471911545e-02
+ -7.559335740607e-02
+ -2.287480528389e-02
+  1.764353297296e-01
+  1.937140706238e-02
+  1.876127946054e-02
+  8.116184724646e-02
+  3.366832367457e-02
+ -3.054894948222e-02
+  6.992247612848e-02
+ -3.077316414282e-02
+ -1.195307405269e-01
+ -4.069349870360e-02
+  1.236310189416e-01
+  9.258286958731e-02
+ -2.446691408055e-01
+ -7.665011586472e-02
+ -1.093252789259e-02
+ -3.869100074140e-02
+ -4.896954027078e-02
+  5.500717161417e-02
+  5.245993539741e-02
+  1.311729175829e-01
+ -1.483945494989e-02
+  4.107617276099e-02
+ -8.140305026889e-02
+ -5.276448534183e-02
+  2.090353028467e-01
+  9.170285838575e-02
+  2.466549592067e-01
+  8.027904860828e-02
+ -3.777601699107e-03
+  2.278729611128e-01
+  1.459681393314e-03
+  1.182100079010e-01
+ -6.450713099284e-02
+ -1.328219118967e-01
+ -1.814581479024e-01
+  8.951641752573e-02
+  5.981441955808e-02
+ -1.176402077658e-02
+ -7.628150289984e-02
+ -6.585674725503e-02
+  3.017004385849e-02
+  3.752177768938e-02
+  5.625317093363e-02
+  5.003907641838e-02
+ -6.703729089739e-02
+ -1.118800684731e-01
+  1.932067592440e-01
+  2.272845561148e-02
+  1.563953053342e-01
+ -9.304950383192e-03
+  7.058691231526e-02
+  2.422056696488e-02
+ -3.538168737730e-02
+ -1.376973413956e-02
+  3.066806558979e-02
+  8.876288812745e-02
+  1.726926010567e-02
+ -6.163234127438e-02
+  7.364899894703e-02
+ -5.259267704349e-02
+ -3.362085322569e-02
+  3.417252329104e-02
+ -1.500925871872e-01
+  1.287863414923e-01
+ -2.426956291536e-01
+  1.519430993937e-01
+  1.539068008977e-01
+ -4.156492696817e-02
+  1.319651648190e-01
+ -4.448403996148e-02
+ -1.599887888020e-01
+  4.478841243504e-02
+ -1.478212116178e-01
+  1.529818754836e-01
+  1.486259404248e-01
+ -2.591038535116e-02
+ -9.045583281482e-02
+  1.900395650619e-01
+  2.064481962443e-01
+  2.781950296664e-02
+ -5.921979687641e-02
+  4.904016934524e-02
+  1.636127083454e-02
+ -5.520535411083e-03
+  1.120106959030e-01
+ -3.206658068536e-02
+  1.764862650136e-02
+  2.549836278784e-02
+  7.289833597373e-02
+  9.800201693125e-04
+ -8.516514021891e-03
+ -2.205954047391e-01
+  5.674928675604e-02
+ -1.227450398448e-01
+ -1.042482551318e-01
+ -7.068786939594e-02
+ -9.996261393794e-02
+ -6.618347608993e-02
+  2.651302024139e-01
+ -4.842318751384e-02
+  8.919728699574e-02
+  1.020393986299e-01
+  8.348985669548e-02
+ -1.024802335694e-01
+ -1.268423301385e-01
+  1.519047253559e-02
+  1.144088502903e-01
+  1.387990982050e-01
+  8.725283256204e-02
+  2.953899432428e-02
+  1.550642583431e-01
+  5.203840095948e-02
+  2.496519831466e-02
+  5.727354775615e-02
+  1.870259171687e-01
+  2.235098978788e-02
+ -1.615131969655e-01
+  1.644602613161e-01
+ -4.968179799703e-02
+  9.634444159091e-02
+  5.766876747607e-02
+  4.481910612129e-02
+  2.012923923855e-01
+  1.653616013022e-02
+  2.883625581909e-02
+  1.040497618435e-01
+ -6.072793290677e-02
+  2.601500770143e-02
+ -2.340661256037e-01
+ -6.079923087634e-02
+  1.860618689031e-01
+ -6.539058012516e-03
+  1.027821690987e-01
+ -1.147817055666e-01
+  1.818420485649e-01
+  1.398974586331e-01
+ -1.511956196925e-03
+  8.067018795285e-02
+  7.422725012039e-03
+ -3.124254140971e-02
+ -7.124124609883e-03
+ -5.020751682516e-02
+  8.861422109126e-02
+  4.085073529855e-02
+  1.781170201801e-01
+ -4.518646075107e-02
+ -2.142963710267e-01
+  4.577095439733e-02
+  7.451222286175e-02
+ -7.896715910300e-03
+  1.091552404657e-01
+  7.643977307501e-03
+  1.175656006985e-01
+  1.524615891302e-01
+ -6.918514601443e-02
+  7.763269488122e-03
+ -1.085678847045e-01
+  7.342709409507e-02
+  1.507050773384e-02
+ -2.672976553558e-02
+ -1.478235297362e-01
+  1.980573424049e-01
+ -7.662676600080e-02
+ -6.047130867514e-02
+ -5.912968805964e-02
+  6.241993263257e-02
+  5.480125734366e-02
+ -2.197029350247e-02
+  3.567789922637e-02
+  1.270888988152e-03
+ -2.045455922708e-02
+ -7.673395827491e-03
+  1.708516345299e-01
+  1.099016098144e-01
+ -9.707441428827e-02
+ -4.805337936210e-02
+  1.374607382643e-01
+  9.079135939175e-02
+ -3.898046262446e-02
+  7.227786494403e-02
+ -1.716484084860e-01
+  8.918691296497e-02
+  2.792441885041e-02
+ -6.351328567746e-03
+  9.369340526467e-02
+ -1.749338083660e-01
+ -5.380974566408e-02
+  1.425711684147e-01
+ -1.364591585482e-01
+ -1.994207470791e-01
+  1.614163286696e-02
+ -2.340315872911e-01
+  5.275282107452e-02
+  1.207708064171e-01
+  2.315314530364e-02
+  1.505479872018e-01
+ -1.400452617902e-01
+  1.214710556321e-01
+  1.214763613295e-01
+  3.391467903531e-02
+  4.250385704702e-02
+  4.579431986436e-02
+ -1.294991756061e-01
+  1.831621130182e-02
+ -1.515525349424e-01
+  3.083757115429e-02
+ -3.673105445664e-02
+ -1.626488444227e-01
+ -1.619829913253e-02
+  1.045509374215e-01
+  1.059589946682e-02
+  4.747069498026e-02
+ -1.347663884756e-01
+  1.161781483841e-01
+ -1.005962846183e-01
+ -4.400519560193e-02
+ -8.331817018830e-02
+  5.413007221931e-03
+  1.670404476330e-01
+  1.029846950090e-01
+ -1.005159577263e-01
+ -1.476509433476e-01
+ -3.972672698477e-02
+  1.520551690118e-01
+  7.373460360928e-02
+ -1.238887839482e-02
+ -1.628703240375e-01
+  1.276172202640e-01
+ -1.847420479951e-01
+ -2.083568073061e-02
+ -1.312260233502e-01
+ -6.611352627836e-02
+  5.346514967229e-02
+  7.138645495726e-02
+ -3.718323210731e-02
+ -1.401223331909e-01
+  5.111984299003e-02
+  9.176159649346e-02
+  9.037187314978e-03
+ -1.211506450252e-02
+  6.617529216295e-02
+ -9.545744412790e-02
+  4.589303543279e-02
+  1.707735867205e-01
+  6.185040820681e-02
+  1.123945196810e-01
+  3.977581227468e-02
+ -1.303251672063e-01
+ -4.107187676645e-03
+ -1.980988080785e-02
+  1.255453027204e-01
+  1.007169118303e-01
+ -9.819159251377e-02
+ -6.820318633357e-02
+  7.919799913794e-02
+ -2.777236990835e-03
+ -2.185150982966e-01
+  1.224088926340e-01
+ -2.392956056248e-02
+ -5.327619476406e-02
+  8.548552851997e-02
+  8.679880401787e-02
+  6.920945486221e-02
+ -1.198793931074e-01
+ -9.614108393476e-02
+  4.912420099766e-02
+  1.801805749569e-02
+  1.646751441616e-01
+ -1.325549152961e-01
+ -5.673285715950e-02
+  6.291040696830e-02
+  6.625092038006e-02
+  6.059030662499e-02
+  7.114332116714e-02
+  8.467767799379e-02
+  8.017351183354e-02
+ -1.510326582260e-01
+  1.493903625240e-02
+ -8.382947785734e-02
+ -8.917578555938e-02
+  1.223338337071e-02
+  2.051285543987e-02
+ -1.673070859734e-01
+  1.280305115927e-01
+ -1.046523617545e-01
+ -7.295803815485e-02
+  9.783781134593e-02
+  2.709416170627e-02
+  1.716904855429e-01
+  1.186165593212e-01
+  1.831624926935e-01
+ -4.157052337902e-02
+ -9.081252211027e-02
+  5.794115123889e-02
+ -4.862694186677e-02
+ -1.756785920820e-02
+  6.633183689330e-02
+ -1.347980594138e-01
+ -4.694727029391e-02
+ -4.904176395337e-02
+ -1.159429298055e-01
+ -6.655439075530e-02
+  5.693076834155e-02
+  3.265069391469e-02
+ -6.455435681117e-02
+  5.791262530412e-02
+ -1.402085017655e-01
+ -7.418866877685e-03
+ -3.025847978245e-02
+ -5.132209218262e-02
+  9.764991343912e-02
+  1.101704494623e-02
+ -1.013470794664e-01
+ -7.707652052866e-02
+ -5.554568232528e-02
+  5.690845234577e-02
+ -5.211687015658e-02
+ -4.529570633339e-02
+ -9.728262144546e-02
+  2.354529304695e-02
+ -4.495451584328e-02
+  9.711165011683e-02
+ -1.609040298389e-01
+  1.396376022367e-01
+ -7.828823402395e-02
+ -7.276531313742e-02
+  3.195647187020e-02
+ -8.881858933207e-02
+ -9.770769876037e-03
+  3.286383544879e-02
+  4.929448704321e-02
+  5.275696314803e-02
+ -4.567936261171e-02
+  6.800236000440e-04
+  2.301857849006e-02
+  7.328455953356e-03
+  1.223136113679e-01
+ -2.258140314611e-01
+  1.763163537943e-01
+  7.371881800487e-02
+ -4.962645782524e-02
+ -1.133134908516e-01
+ -3.789290837786e-02
+  4.112226816637e-02
+  6.457928004125e-02
+ -4.031052677895e-02
+ -7.611347401764e-02
+  1.071641549266e-01
+  2.439410512193e-01
+  1.515972428018e-01
+ -1.184120614597e-01
+  1.073794562644e-01
+ -1.337223823374e-01
+ -1.549172195211e-01
+  1.465860819305e-01
+ -2.168443876292e-03
+  5.846462190632e-02
+ -6.552185219748e-02
+  1.088386716613e-02
+  4.608496824755e-04
+  8.654182014850e-02
+  2.480858235916e-02
+  1.247220583211e-02
+ -9.652507413797e-03
+  4.527378312175e-02
+  1.835757469221e-01
+  8.584584521489e-02
+  1.231634974616e-01
+ -7.461749461505e-02
+  4.957704351866e-02
+  1.272776306165e-01
+ -5.559152624384e-02
+  9.264397370713e-02
+ -7.123751740979e-03
+ -3.019913599877e-02
+  1.333807365536e-01
+ -3.230507460983e-02
+ -2.230725632826e-01
+  1.192883802350e-01
+ -1.935061019110e-01
+  2.891098652628e-02
+  5.785213308756e-02
+ -1.532435863353e-01
+ -2.132160846428e-01
+  2.588189753368e-02
+ -1.117955830996e-01
+ -5.718482836578e-02
+  1.200869181181e-01
+ -1.167644865435e-02
+  1.248030344888e-01
+ -3.983905192094e-02
+  1.727139618223e-01
+ -2.247158410970e-01
+ -9.525985818822e-02
+ -1.266860630570e-01
+  6.652145907791e-02
+  4.484001508496e-02
+  7.921515995431e-02
+ -1.262439788879e-01
+ -7.566398673069e-02
+  1.047966668125e-01
+ -2.079557143753e-02
+  1.515482657433e-01
+ -1.456617631228e-01
+ -7.512471791462e-02
+ -2.217048904236e-02
+ -1.559792486702e-03
+ -2.291625968032e-02
+ -3.410808987698e-02
+ -6.314681598028e-02
+ -5.919452130545e-02
+ -3.363752381122e-01
+ -1.118804729878e-01
+ -1.969703222826e-01
+ -1.511842752853e-01
+ -6.387724993832e-02
+  3.646394361262e-02
+  1.422493328820e-01
+  1.507522427592e-01
+ -5.950458765885e-02
+ -5.849816122004e-02
+ -7.830836922967e-02
+ -5.986729372316e-02
+ -9.033851706517e-02
+  1.030920552005e-01
+ -1.292495997746e-01
+  2.358339813309e-02
+  2.523234006578e-02
+ -8.053002179982e-02
+ -2.165321361257e-02
+ -2.310834121806e-01
+ -1.137607450041e-01
+  1.257195115254e-01
+  8.953543407787e-02
+  1.474241363977e-01
+ -7.232878155178e-02
+  6.197583016468e-02
+ -6.596348667932e-02
+ -1.186088727279e-01
+ -3.109355110153e-02
+ -2.883735725835e-01
+  1.884522288877e-01
+ -5.099291639906e-02
+  8.945614376942e-02
+ -4.922833068905e-02
+ -4.009017488050e-02
+  7.667068963869e-02
+ -5.336774863436e-02
+ -1.880812967762e-01
+ -1.464258076778e-01
+ -8.311100071279e-04
+  8.794364322158e-02
+  5.484562253033e-02
+ -1.216382451522e-01
+ -1.165919914380e-01
+ -3.890227448858e-03
+  4.789056667680e-02
+ -8.950559877208e-02
+  1.096553029635e-01
+ -1.179993245797e-01
+  3.203762065232e-02
+  8.379689623193e-02
+ -3.754247221629e-02
+  1.707423540567e-01
+  5.239787756374e-02
+ -4.239881983970e-02
+ -1.478001467403e-01
+ -4.314864785661e-02
+  2.620578647475e-02
+  4.355815759349e-02
+  8.588501415475e-03
+  1.412648096923e-01
+  3.945415307097e-02
+  1.333628087883e-01
+  1.618674109995e-02
+  3.337619046701e-02
+  8.677853084884e-02
+ -1.219734669038e-01
+  6.026628209248e-02
+  8.831598977542e-03
+  5.440262817420e-02
+ -8.727876943518e-02
+ -7.401721188090e-02
+  6.247477855726e-02
+  7.481789375243e-02
+ -4.180722822835e-02
+  9.570064570212e-02
+  1.056211380249e-01
+ -2.634109258015e-03
+  1.213233356054e-01
+  7.737694150932e-02
+  5.604066663167e-03
+ -7.027852233817e-02
+ -1.838316452502e-01
+  2.360172934393e-01
+  1.718018670031e-01
+ -3.968931573143e-02
+  3.985797800869e-02
+  8.768249493412e-02
+ -4.779557952320e-02
+  2.381655705039e-02
+ -6.243796602663e-02
+  1.025578362597e-01
+  5.121478557913e-02
+ -1.408018150676e-02
+  1.574603952550e-01
+ -8.012379972166e-02
+  2.165798752486e-01
+ -3.175266610092e-02
+ -7.463784084228e-02
+ -8.232196087529e-03
+  9.995074189407e-02
+ -5.587316603765e-02
+ -6.795307905696e-02
+  1.604166917939e-01
+ -1.951192690602e-01
+ -3.096635588400e-02
+ -2.698655290544e-02
+  3.769101524269e-02
+  1.613100358176e-01
+  8.757328027618e-02
+ -2.094236725914e-02
+ -1.176226135249e-01
+  9.930472370441e-02
+  6.174918382840e-02
+ -1.736670517468e-02
+ -3.760593592981e-02
+  5.927318345585e-02
+ -2.482654431071e-02
+ -2.977560455291e-02
+  1.258864893473e-02
+  7.990973218675e-02
+ -4.212717187995e-02
+ -2.069602502538e-02
+  7.425167325863e-02
+  7.864239357524e-02
+  1.573011353058e-01
+  1.000682775220e-01
+ -5.854260747901e-02
+  9.806732788271e-03
+ -7.121857308883e-02
+  2.350230853887e-03
+  2.385894681154e-01
+  1.008077061775e-01
+  7.154624447306e-02
+ -7.223161004081e-02
+ -3.871251653373e-02
+ -1.147492499625e-01
+ -5.648655380452e-02
+ -5.894979232360e-02
+  3.824807498848e-02
+  8.545436217237e-02
+ -8.045821424806e-02
+ -4.137297538851e-02
+  7.905632474644e-02
+ -2.672160030575e-02
+ -4.369144503351e-02
+ -2.480713990545e-01
+  6.747523172654e-02
+ -1.392332107818e-01
+ -2.440896606768e-02
+ -8.938784037946e-03
+  9.368145640557e-02
+  1.053687873391e-01
+ -6.787054790970e-03
+ -5.178404616909e-02
+  5.628999908003e-02
+ -1.773152857008e-01
+  7.325245595943e-03
+ -1.455810336707e-01
+  8.689987195155e-02
+  4.018799893022e-02
+  7.809375258702e-02
+ -6.578017601284e-02
+ -1.444918683024e-01
+ -2.478232914033e-02
+ -3.218296615667e-02
+  6.035193307080e-02
+  4.313079579280e-04
+ -3.315850778326e-03
+  3.293371027652e-02
+  1.059910014732e-01
+  4.061892522538e-02
+  7.460715165943e-02
+ -2.346754330436e-02
+ -4.276183477300e-02
+  3.262643088478e-02
+ -2.926300483996e-02
+ -8.610774675057e-02
+  1.678183381497e-01
+ -9.566603559704e-02
+  8.217011553588e-02
+  2.533440421511e-03
+ -2.188039668276e-02
+  7.199912323028e-02
+ -1.113271502488e-01
+ -1.965090141030e-01
+ -1.434583924432e-01
+ -8.721312319287e-02
+ -8.268474493433e-02
+ -7.692998032527e-02
+ -2.071966645585e-02
+  1.004148246642e-01
+ -9.054163267009e-02
+ -4.752753939322e-02
+ -3.432645378849e-02
+  4.645636855879e-02
+ -9.425373100668e-03
+ -6.161451464353e-02
+ -9.663093556005e-02
+ -7.362733339629e-02
+ -7.738025149566e-02
+ -1.164269074289e-01
+  1.248445440863e-01
+ -2.240103271154e-03
+ -6.720344406681e-02
+ -4.950343065879e-02
+  6.818057811632e-02
+ -1.064050766121e-02
+ -7.024751696624e-02
+  8.294260415549e-02
+ -1.599394454292e-02
+  8.164588537948e-02
+  2.067529748053e-01
+  1.136682575848e-03
+ -6.533232962041e-03
+ -1.712052161652e-01
+ -5.941607876104e-02
+ -9.004886838742e-02
+  8.238909254960e-02
+  2.851003668958e-01
+ -1.465160705252e-02
+ -5.522742039469e-02
+  8.753690236872e-02
+  1.591471665114e-01
+  1.365525661043e-02
+ -2.737708337355e-02
+  1.577823774936e-01
+  5.437870141767e-02
+  7.424187809931e-02
+ -2.034932816472e-03
+ -1.085337310554e-01
+  6.352897737584e-02
+ -4.474185140597e-02
+ -6.734361248491e-02
+  8.377899367817e-02
+  4.226307118704e-02
+ -9.826173936636e-02
+ -2.085705599138e-01
+  7.879660721737e-02
+ -4.940531777279e-02
+  4.830727515275e-02
+  1.399669942451e-01
+  4.263558324064e-02
+ -3.470093211116e-02
+  5.808685338503e-02
+  1.317708084281e-01
+ -1.459494497862e-02
+  1.178183128638e-01
+  4.644853274646e-02
+  1.706044796542e-02
+  2.367293738706e-02
+ -2.673589312329e-02
+ -9.576149608596e-02
+  1.303278111089e-01
+ -1.685724893731e-02
+ -3.175007069884e-02
+ -1.287131908227e-02
+ -3.825177931596e-02
+ -2.924471736443e-02
+ -3.361123041092e-03
+ -2.319925585729e-03
+ -2.358187553755e-01
+ -1.343052230835e-01
+ -1.171112278716e-02
+ -1.198496182614e-01
+ -3.205568430394e-03
+ -2.594303199242e-02
+  1.489322025477e-01
+  1.813204341648e-02
+ -1.036011284448e-01
+ -6.979484040088e-02
+ -5.933394546948e-02
+ -8.106363492077e-02
+ -9.068875255927e-02
+  5.092579452688e-02
+ -1.835513839476e-01
+ -1.138948417900e-01
+ -7.131304465752e-02
+  1.714205131444e-01
+ -6.627805786983e-02
+ -3.093760576804e-02
+  1.151743554385e-01
+ -1.514497260311e-02
+  1.181559866272e-01
+ -8.922781517981e-03
+  1.021417100400e-01
+  2.875114255758e-01
+ -1.421411949234e-02
+ -1.618187853391e-01
+ -5.301176488913e-02
+ -9.130443491132e-02
+  4.684315297875e-02
+ -1.546950738033e-01
+ -1.627313042290e-01
+ -2.193969961979e-02
+  2.291708823198e-02
+  2.441349747521e-01
+  1.847412832788e-01
+  1.204018550739e-01
+ -4.857952731546e-02
+  1.834896036974e-01
+ -4.787633467408e-02
+ -7.581209184705e-02
+  1.871538228499e-01
+  2.435220928395e-01
+ -9.931682811492e-02
+ -9.964233067317e-03
+  1.571344276059e-01
+  1.628785137277e-01
+  1.139954609290e-02
+  1.072858465371e-01
+ -3.861854430335e-02
+ -1.449202185769e-01
+  8.513220754850e-03
+  3.473514458295e-02
+  6.485514484963e-02
+ -5.088291002928e-03
+ -1.051291550192e-01
+  1.309306145535e-01
+ -4.202423823016e-02
+ -1.907419412637e-01
+ -1.384648094230e-01
+ -1.377632376917e-01
+ -6.415312963371e-02
+ -2.314167012736e-02
+  9.593707209405e-02
+  9.711337690179e-02
+  2.022295705808e-02
+  1.208054029179e-01
+  2.378350812471e-01
+  5.112912550445e-02
+ -1.183256675930e-01
+ -5.752015187464e-03
+  1.682247770231e-01
+ -7.104252777602e-04
+ -9.606137858513e-02
+  9.699367599478e-02
+ -9.637606969148e-02
+  5.066358775122e-03
+  2.729593544256e-02
+  5.266893834161e-02
+ -3.697510890952e-02
+  2.358348779261e-03
+ -2.257696677428e-02
+  2.603305904222e-02
+  9.084403122292e-02
+  8.856921863913e-02
+  1.298682745399e-01
+ -1.871764712733e-01
+ -8.503715071397e-02
+  1.404761529730e-01
+  1.782038456081e-04
+ -1.174590624882e-01
+  2.984269734137e-01
+ -6.830626586057e-02
+ -5.475621175009e-02
+ -2.614211096984e-02
+  2.189493145562e-01
+  1.795492165129e-01
+  1.358248178626e-01
+  1.100278108842e-01
+  5.541413889597e-03
+  5.033220164747e-02
+  6.186141610628e-02
+  8.089478185669e-02
+ -2.284589312530e-02
+  2.071525010550e-01
+ -1.506766443450e-02
+ -1.791028733103e-02
+  4.510857245291e-02
+ -9.121422122889e-03
+  1.249837346473e-01
+ -3.858289283063e-02
+  1.490728123113e-02
+  3.669334180662e-02
+  1.054490843712e-01
+ -1.090560378938e-01
+ -1.452554639406e-01
+ -5.366142021509e-02
+ -1.072620263824e-01
+ -4.679006416543e-02
+  4.726904281550e-02
+ -3.873392140882e-02
+ -2.760487608253e-03
+ -1.397334806125e-02
+  1.112485076010e-01
+  6.801333829753e-02
+ -1.019162625410e-01
+ -2.032172302388e-02
+  1.141475966565e-01
+  1.946960616554e-01
+ -3.734916120035e-02
+  2.361781209634e-02
+  8.269150296353e-03
+  1.794021213730e-02
+  2.183915013573e-01
+ -1.117285730410e-01
+  2.860311651705e-02
+ -5.587750397573e-02
+ -3.365090841331e-02
+  6.276294127944e-03
+ -6.644256191971e-02
+ -1.523863953743e-01
+  7.862037306524e-02
+ -8.774128860156e-02
+  1.256655908186e-01
+ -1.043229902117e-01
+  6.348067723389e-03
+  2.691851269153e-02
+ -1.156983117090e-01
+ -9.063383510639e-02
+ -6.259034504615e-02
+  6.263477104936e-02
+  2.179269781262e-03
+ -1.130914716028e-01
+  9.939813431259e-02
+ -2.102136483577e-01
+ -3.825860882031e-02
+  1.946835498248e-01
+  1.151864733916e-01
+  1.132471124603e-01
+ -8.956120026496e-02
+ -9.863193798596e-02
+ -2.071943123670e-01
+ -1.296551761066e-01
+ -8.251852174277e-02
+  1.887060688968e-01
+ -1.556809177446e-01
+  5.479325645739e-02
+ -1.649943779205e-01
+  1.250376530928e-01
+ -2.312657483814e-02
+ -5.049589813486e-02
+ -1.540452922617e-01
+  1.488958601779e-01
+ -4.196879504989e-02
+  1.036950377563e-01
+  1.263464252460e-02
+ -5.871254902192e-02
+  2.988789599873e-02
+  2.381973499594e-01
+  1.194045543447e-01
+  9.644562134139e-02
+ -7.489814086576e-02
+  1.293161345754e-02
+  4.238264080443e-02
+  7.963669569268e-02
+  6.749824497364e-02
+  5.963185868130e-02
+ -6.489338731274e-02
+ -2.157965006082e-01
+ -3.899249937542e-04
+  1.965609819065e-03
+  2.451850059506e-02
+ -7.424385256116e-02
+  7.443567461125e-02
+  1.102182519205e-01
+  6.928738284851e-02
+  9.817628422440e-02
+  5.532353388878e-02
+ -1.680212641075e-01
+  5.223933785116e-02
+  1.254534090854e-01
+  4.894616624277e-02
+ -1.444190685166e-01
+  1.348526574789e-01
+  6.360839239185e-02
+ -3.397599781831e-02
+ -1.392236359820e-01
+  6.517207915137e-02
+  3.091262243776e-02
+  1.454049522296e-01
+ -1.551447663556e-01
+  7.969770124876e-03
+ -1.812739892248e-01
+  1.032024856213e-01
+  8.949583397517e-02
+ -8.866009474109e-02
+ -1.520464616674e-02
+  1.042859042232e-01
+ -1.768581453991e-01
+  9.446190279211e-02
+ -6.699051796427e-02
+  6.026042103858e-02
+  1.607048645212e-02
+  1.232854503957e-01
+  9.054163001570e-02
+  1.806399152641e-03
+ -1.868002063677e-01
+ -7.629924726699e-02
+  4.833269291978e-02
+ -5.610380251647e-02
+ -1.578090908989e-01
+  2.073879064567e-01
+  1.202435416640e-01
+  7.707668484284e-02
+ -2.853760490193e-01
+ -1.863017982690e-01
+  4.020715002174e-02
+ -1.543040306655e-02
+ -8.272343035087e-02
+ -1.414257815861e-01
+ -1.345904657864e-01
+ -7.711016876779e-02
+  1.296362509790e-01
+ -3.328583771239e-02
+ -8.647596682860e-02
+ -1.338202349198e-01
+  1.102016621645e-01
+ -1.329450180628e-01
+  4.432034996157e-02
+ -7.385093125271e-02
+ -1.189224141797e-01
+ -9.295028674728e-03
+  2.864653418085e-02
+ -1.348236300021e-01
+ -1.143818289953e-01
+  9.507073477028e-03
+  6.618798195804e-02
+  1.630616184616e-01
+  2.802127745008e-02
+ -1.294462056516e-02
+ -2.788482933976e-02
+  2.402871502494e-01
+ -4.985772285463e-02
+ -6.260888772607e-03
+ -2.744995399207e-02
+  7.286377581793e-02
+  1.997609525025e-02
+ -1.749061273781e-01
+  8.931726297854e-02
+ -3.047713749283e-02
+  1.437678623609e-01
+  2.843205870033e-01
+ -2.306566040563e-02
+  3.738146031532e-02
+ -3.006972570236e-02
+ -7.058221597055e-02
+  3.422246029949e-02
+ -7.443302032057e-02
+ -1.409125849623e-01
+ -4.831171263203e-02
+ -1.323235926860e-01
+ -9.168201017073e-03
+  1.052069147016e-02
+  1.047010001470e-01
+ -1.491672522221e-01
+  1.734376097952e-02
+ -1.419015870850e-02
+  1.182378047873e-01
+  6.026125631230e-02
+ -2.642259843881e-02
+ -9.131770021365e-02
+  1.696916458914e-02
+  1.177323847519e-01
+  9.501636298917e-02
+ -9.368060135056e-02
+  1.052079882782e-02
+  9.939930766653e-02
+  2.861118502666e-02
+  1.904432551794e-01
+  8.218913308937e-02
+  3.688289620839e-03
+ -3.553628968490e-02
+ -1.767508009710e-02
+ -1.436381839135e-01
+ -6.879037102917e-02
+  8.315570321303e-02
+ -5.882737962623e-03
+ -9.720868648656e-03
+ -9.082074985547e-02
+  1.406746833357e-01
+ -1.487113640078e-01
+ -1.357932914763e-02
+ -2.326697892479e-02
+ -1.640220270079e-01
+ -4.847934343688e-02
+  1.023201007194e-01
+ -2.944673402155e-02
+  5.816925850547e-02
+  1.546249670003e-01
+  6.363647942435e-02
+  2.768941779080e-02
+  8.305443458288e-03
+  1.038800030543e-01
+  2.218100990390e-02
+ -1.132326234403e-01
+ -4.070791139640e-02
+  1.423649298307e-02
+  9.885875335791e-03
+  7.224917909924e-02
+ -1.040970554326e-01
+  1.718066131823e-01
+ -1.520473432147e-01
+  3.553092031784e-02
+ -8.681553474850e-02
+  3.359970435079e-02
+  6.332168435061e-02
+  9.970996807167e-02
+  4.124130851129e-02
+  8.887673617840e-02
+  6.868039586479e-03
+ -1.171110152197e-01
+  3.410883532479e-02
+  4.216038856356e-02
+ -4.201744531903e-03
+  3.721937571120e-02
+ -4.871918409547e-02
+  1.838734926241e-01
+  5.895822114819e-02
+ -9.569568012182e-03
+  1.847506542151e-01
+  1.383593448920e-01
+ -1.167947634808e-01
+  1.623593794766e-01
+ -9.763643605517e-02
+ -3.411285645556e-02
+ -1.351586383195e-01
+ -6.405718552040e-02
+ -5.036364258340e-02
+ -1.329034640055e-01
+  7.667996802783e-03
+ -8.662005410583e-02
+  1.126742721848e-01
+  9.361353172601e-03
+ -1.934653494411e-01
+  1.589547739053e-01
+  1.718556653789e-02
+ -8.668313938301e-02
+ -1.787576311324e-01
+ -1.432765979335e-01
+ -6.413667767903e-02
+ -1.297046084629e-01
+ -3.884724001462e-02
+  2.137999602199e-01
+  8.777659791876e-02
+ -8.368537934933e-03
+  2.621369659679e-02
+  2.412997053647e-02
+ -3.957113537828e-02
+  2.650349689374e-02
+  9.028503733410e-02
+ -4.422290697567e-04
+ -2.332268758917e-01
+ -1.701435148735e-01
+ -9.046806581031e-02
+ -4.776274778270e-02
+ -4.997568700596e-02
+ -6.907725399566e-02
+  8.575539826928e-02
+  1.531436166691e-01
+  2.375546840493e-01
+  1.435858770207e-02
+ -8.199909460492e-02
+  1.724426085130e-01
+ -1.013710108246e-01
+  1.134005341076e-01
+  2.009529674142e-02
+ -4.118679937739e-02
+ -1.118598473648e-01
+ -5.984434203595e-02
+  1.536917298552e-01
+  5.290914612239e-02
+ -2.925298943149e-02
+ -5.080023819141e-03
+ -3.778052590494e-02
+ -2.921338014087e-02
+  8.177420900735e-02
+  4.532990923588e-02
+  7.921233046063e-02
+  9.227685060825e-02
+ -3.863627732284e-02
+  7.663377412006e-02
+  3.501435295963e-02
+  1.447198167167e-01
+ -8.414028244818e-02
+ -9.701516764511e-03
+  4.985811679778e-03
+ -3.897957952999e-02
+  8.301832334269e-02
+  7.719583054701e-02
+  3.732471308212e-02
+ -6.596188130543e-02
+ -2.454256138698e-01
+ -6.091314160631e-02
+  7.838549030376e-02
+  1.117618022552e-01
+  1.354337255860e-01
+  9.100584208993e-03
+  1.927936195424e-02
+  1.438727245590e-01
+  5.529853943182e-03
+  9.862154817330e-02
+  1.113443926568e-01
+ -9.407492913723e-02
+  1.258205317469e-01
+ -6.502964013493e-02
+ -4.186393056677e-02
+ -8.276687882507e-02
+  3.418532130405e-02
+  3.346736425599e-02
+  1.628457718032e-02
+ -2.182043187781e-02
+  9.873435893958e-02
+ -5.890038026925e-03
+ -1.860483324717e-01
+  1.795087783038e-01
+ -1.725279267768e-01
+  5.570484294581e-02
+ -5.675495376381e-02
+  3.715889578707e-02
+ -1.317750860307e-02
+  2.202275193669e-01
+ -1.022642172506e-01
+ -4.462619470462e-02
+ -3.120835161481e-02
+  4.413640895623e-02
+  7.618100726426e-02
+  1.069068709109e-02
+  1.387337832086e-01
+  6.241634525265e-03
+ -4.845962345877e-02
+ -2.731322227109e-02
+  5.359839271386e-02
+ -1.500605325113e-02
+  1.029784353101e-01
+ -4.747733706853e-02
+ -3.429763881673e-02
+  1.100681328050e-01
+  5.605597589745e-02
+ -7.156337016094e-02
+ -1.015027258842e-02
+  5.709834559448e-02
+  1.022415196372e-01
+  1.756822149042e-01
+ -2.904927250959e-02
+  8.390182140312e-03
+ -2.197608065805e-01
+  1.304665489399e-01
+  4.252640733455e-02
+ -1.826264307919e-01
+  1.129216290926e-02
+  8.855844479682e-02
+  5.247146355562e-02
+  5.140704272628e-02
+ -7.014138179884e-02
+  2.977182965834e-02
+  8.225448737940e-02
+ -1.409794076588e-01
+  2.679242496698e-02
+  3.982637330918e-02
+  2.354380077423e-02
+ -1.060430416286e-01
+ -1.728546888662e-02
+ -1.575209162991e-01
+  4.269589802136e-02
+  1.347683883219e-02
+  7.909356524034e-03
+  2.888883023514e-02
+  5.149206165316e-02
+  8.232583318597e-02
+  1.049450063528e-01
+ -7.384944319328e-02
+  7.753805113470e-02
+ -1.945526628498e-01
+ -1.527243782566e-01
+  6.862926457245e-02
+ -1.444153760835e-01
+ -7.405321912479e-02
+  1.424874877916e-02
+ -5.395003441492e-02
+ -1.174463307063e-01
+ -1.867300168112e-02
+ -1.614129123694e-01
+ -3.779259981400e-02
+ -7.399315172141e-02
+  1.210789277464e-01
+  2.912341538237e-02
+  3.043766113593e-02
+ -1.925510830064e-01
+ -1.817080724336e-01
+ -1.951857854984e-01
+  3.407298750369e-02
+ -1.595830531000e-01
+  1.515685025458e-01
+  2.278090076024e-02
+ -1.071738424937e-01
+  2.863187070237e-02
+  1.627145535180e-01
+  1.647891782552e-01
+  6.791953682754e-02
+ -9.736577813874e-02
+ -7.283648608931e-02
+  1.583638984954e-01
+ -1.061867081144e-01
+  6.390893790784e-02
+  1.401893302816e-01
+  7.166463053055e-03
+ -2.635605454906e-02
+ -5.924357323164e-03
+  2.018527003969e-02
+  6.347052692801e-02
+ -1.271681910844e-01
+  3.542732915729e-02
+ -3.014597259505e-03
+  8.966350977219e-02
+  1.507812983271e-03
+ -1.657693755174e-01
+  3.342899840123e-03
+  1.058489656804e-02
+ -1.288522213450e-01
+  7.887513332485e-02
+ -1.173152527812e-01
+ -1.660058906704e-01
+  2.595592196108e-02
+ -2.674089564742e-02
+  9.304293510004e-02
+  1.009350571599e-01
+ -6.047694084795e-02
+ -1.017964881929e-01
+  4.089053266467e-02
+ -6.614515209924e-02
+  2.668884146000e-03
+  1.006000920764e-01
+  6.376380866982e-02
+ -6.126197867013e-03
+ -2.443611965404e-02
+  1.487559282042e-01
+ -1.052436442439e-01
+ -3.856005339901e-03
+ -1.058326690251e-03
+  5.439282580795e-02
+ -1.357003736990e-01
+  3.157036412892e-01
+  7.526343419281e-02
+  9.731522686383e-02
+  3.122541256231e-02
+ -8.429086619682e-02
+ -1.344551241437e-01
+  2.366739892073e-02
+ -2.923096853793e-02
+  6.978367795856e-02
+  6.495627785975e-02
+ -5.808961073912e-02
+ -4.358653202285e-02
+  1.301188443874e-02
+  6.202896844569e-02
+ -1.502875549584e-01
+ -8.969768697660e-02
+ -1.023569460610e-01
+  2.281574314185e-01
+ -1.749240859472e-02
+  7.577435419514e-02
+  8.890485942959e-02
+  3.429418699793e-02
+ -1.951632976148e-01
+  1.096963763309e-01
+ -3.285622991057e-02
+ -1.526880525376e-01
+  1.996131767105e-01
+ -5.204507740486e-02
+ -1.487378225091e-01
+ -2.727700504946e-02
+  1.804506975388e-01
+ -9.707074036611e-02
+  4.397756528889e-02
+  1.921162552309e-01
+ -1.286315815298e-02
+ -1.084550114467e-01
+  6.538547228771e-02
+  4.692683093835e-02
+ -2.859954409225e-02
+ -1.155219276400e-01
+  9.342535184697e-02
+  9.286815562839e-02
+ -4.177477394789e-02
+  1.938084651127e-02
+  1.564106331713e-02
+ -5.117610240243e-02
+  4.252584581069e-02
+  2.249356733438e-03
+ -4.632728765180e-02
+ -3.126755258080e-01
+ -9.798882896538e-02
+ -8.987072387819e-02
+  2.241460579328e-01
+ -1.124408452424e-01
+ -1.729540908107e-01
+  9.226318640385e-02
+ -4.562393068944e-03
+  1.816295597429e-01
+  6.660104999412e-02
+  2.328245312555e-02
+ -4.915122422959e-02
+ -2.865812873830e-02
+ -9.754546738534e-02
+  7.153915041999e-02
+  2.094258140830e-01
+  3.942815260501e-02
+ -1.434847517155e-02
+  1.683115473642e-01
+ -8.379482254134e-02
+  9.687093929986e-02
+  1.365475901744e-02
+  1.663036980251e-02
+  3.667812861332e-02
+  2.196615764669e-03
+  7.611929940105e-02
+  2.404708047809e-01
+  1.685615879428e-02
+  2.249676073126e-01
+ -1.897290095819e-02
+  8.131673954738e-03
+  4.839058676388e-02
+ -1.184394079675e-01
+ -6.119676077846e-02
+  9.004901293075e-02
+ -7.362999790343e-04
+  1.129133580796e-01
+ -9.316726350591e-02
+ -5.439794769770e-02
+ -1.195777111866e-01
+  3.830235963481e-02
+ -6.588505789833e-02
+ -8.064687871323e-02
+  7.696691221961e-02
+  9.265022206228e-02
+  6.545838065764e-02
+  1.283636995385e-01
+  1.006246933735e-01
+  5.796533030650e-03
+  2.275133996001e-02
+ -4.740463619538e-03
+  3.616106473311e-02
+  5.031520057437e-02
+  7.331697927989e-02
+  1.364318386941e-01
+ -9.802386131922e-02
+  3.363753770353e-02
+  4.128939585534e-02
+ -1.455002915266e-01
+  1.669015332914e-01
+ -5.317972028511e-02
+  1.200605262610e-01
+ -1.609400271468e-01
+ -4.623999367231e-02
+  5.550098727040e-03
+ -8.263677296545e-02
+  4.758410130922e-02
+ -1.601410506113e-02
+ -1.188984555986e-01
+ -2.269837102342e-02
+ -6.138177230694e-02
+  1.638075260077e-01
+  1.693225067431e-01
+ -8.149021549717e-02
+ -3.688321393721e-02
+ -5.966845801073e-02
+ -2.457333232210e-02
+ -2.069021210753e-01
+ -1.224889694171e-01
+ -5.309676534095e-02
+ -1.475486880964e-01
+ -2.406871812316e-02
+ -1.110722709387e-01
+  1.333943170173e-02
+  5.506804993684e-03
+ -2.802163589256e-02
+ -5.481246538112e-02
+  1.002338755512e-01
+ -2.290244931354e-02
+ -4.996275441691e-02
+  5.661272322289e-02
+  8.745283086668e-02
+ -5.909487704683e-02
+ -1.979415914597e-01
+ -5.481427308886e-02
+  1.381849128998e-01
+ -1.939558064869e-02
+  9.070931759462e-02
+  1.441836715971e-01
+  1.058930850703e-03
+  6.784666672732e-02
+  1.004951894116e-02
+  1.588855011902e-02
+  1.167508327128e-02
+ -3.471284549521e-02
+ -1.091731548421e-01
+  7.100838766855e-02
+ -4.169252915760e-02
+ -4.725439484337e-02
+ -9.995174171656e-03
+  6.450761931501e-03
+ -5.819820903151e-02
+  3.515276283916e-02
+ -1.343544365074e-01
+ -2.076511696001e-02
+ -4.453526847804e-02
+ -8.303044063732e-02
+  8.242011886798e-02
+  9.286952763244e-02
+ -7.679815337502e-02
+  7.827251967812e-02
+ -1.429220742109e-01
+  8.576721133290e-03
+  6.790447435528e-03
+  4.749841788120e-02
+  4.158082151389e-02
+ -1.264997151913e-01
+ -2.135135940365e-01
+ -1.528808193623e-01
+  9.162379170281e-03
+ -1.105277306001e-01
+  8.404888998052e-02
+  3.778400754406e-02
+  2.941024121097e-02
+  1.478849755387e-01
+ -1.295904178947e-01
+ -1.622470085237e-01
+ -8.924053799885e-02
+  3.066067573467e-02
+ -5.590128760721e-02
+ -2.109170795450e-02
+  1.282127709126e-01
+ -1.061087068436e-01
+ -1.966079277830e-01
+  1.010887994489e-01
+  4.338900242898e-03
+ -7.187990176899e-03
+  1.002241647051e-01
+  4.526159154397e-02
+  5.140702802866e-02
+  1.795194305183e-01
+  1.659509952673e-01
+  6.528120445833e-02
+ -1.454780566334e-01
+ -6.110229987025e-02
+  1.145663408163e-01
+  2.780795464384e-02
+ -1.328569968864e-02
+  7.149903679368e-02
+ -2.449237008463e-02
+ -5.676185369389e-02
+ -3.131878767708e-02
+ -1.078430171241e-01
+  2.339830807535e-01
+  5.139804393104e-03
+  1.904436143547e-02
+ -9.055016257239e-02
+ -8.536053402110e-05
+ -1.351603841691e-01
+  4.637748511524e-02
+ -2.069066927892e-02
+  2.343333782304e-01
+ -8.429394974499e-02
+ -1.839894287317e-01
+  1.523608668175e-02
+  7.467255092538e-02
+ -1.440785648762e-01
+  8.136134759977e-02
+  1.311748044683e-02
+  1.030349608527e-01
+ -3.510872238029e-02
+  1.572454432518e-01
+  3.543852616490e-02
+ -1.628415451180e-01
+ -2.125065120646e-02
+  6.102238974518e-02
+ -1.076364947714e-02
+  3.194453869759e-01
+ -8.416066793995e-02
+ -3.435097650991e-02
+  9.904157143001e-03
+ -2.881882628577e-02
+ -5.013330155589e-02
+  9.890533836610e-02
+ -2.064364809999e-01
+ -1.349291623731e-01
+ -7.730191910632e-02
+  9.260598304947e-02
+  1.106392909153e-01
+ -1.204549236533e-01
+ -4.675145994444e-02
+ -1.825609128309e-01
+  7.977214485641e-02
+  2.758799838240e-03
+  2.260805548655e-02
+  1.125410149832e-02
+  2.083508258792e-02
+ -1.018936604092e-02
+ -2.012884452692e-01
+  8.445058751927e-02
+  1.658741191886e-01
+  1.336753481749e-01
+  1.208622913025e-02
+ -1.166498333067e-02
+ -1.379328191903e-01
+  7.177400498861e-02
+ -6.223546839858e-02
+  1.504178903873e-01
+  6.138190924998e-02
+  1.338459544840e-01
+  1.700986270736e-02
+ -1.567430268472e-02
+  5.080150175450e-02
+ -1.095356298599e-01
+ -4.022783690444e-02
+ -1.077103179469e-01
+  3.261709065983e-02
+  6.355934580820e-02
+ -1.264168167893e-01
+ -9.963602455610e-02
+  5.480212592105e-02
+ -6.802417797866e-02
+  2.665651387916e-02
+  1.000033927982e-01
+  9.625908815109e-02
+  2.985720218478e-02
+ -4.972636866197e-02
+  5.351269108798e-03
+ -1.110718657459e-01
+  1.922060688480e-01
+  1.259109381936e-01
+  7.553135578245e-02
+  1.400420954692e-02
+  5.295090244421e-02
+ -1.126644550902e-01
+  3.269563224198e-02
+ -7.934739854533e-02
+  6.924733473427e-02
+ -2.417598747989e-02
+ -2.966344003341e-02
+ -3.904715661174e-02
+ -4.050031475838e-02
+ -2.766892088231e-02
+  1.526605323803e-01
+ -9.860558324159e-02
+ -5.826772667829e-02
+ -6.795258627253e-02
+ -1.738639807440e-01
+ -4.619695385441e-02
+ -1.280970461835e-01
+  9.360026201753e-02
+  1.551822860507e-01
+  8.996621457658e-03
+ -2.208610581432e-02
+ -1.487188951148e-01
+  1.855323524821e-01
+  6.835929177601e-02
+  1.831329134496e-01
+ -1.430731551161e-01
+  5.232428106254e-02
+ -2.993897909165e-02
+ -2.330150937225e-02
+  8.109296365053e-02
+  3.346718073706e-02
+  1.289155184224e-01
+  2.729466175145e-02
+ -8.661012354592e-02
+  1.994076132533e-01
+  3.423085498599e-02
+  3.882449553333e-02
+ -1.093979559687e-01
+ -1.952505970279e-02
+ -1.117237789495e-01
+  2.343740882812e-01
+ -3.855968982868e-02
+ -9.309720926960e-03
+  7.010897870914e-02
+  3.318272003268e-02
+  5.718268083548e-02
+ -7.135448960533e-02
+ -1.264727052071e-01
+  1.357565452597e-01
+  1.737193699463e-01
+ -4.111332865668e-02
+ -2.436016020522e-02
+  1.396254649518e-02
+  4.662662687101e-02
+ -4.972442551344e-02
+  5.878586454216e-02
+ -5.803994854652e-02
+ -3.763139522534e-02
+ -1.772295204753e-01
+  2.764529929427e-02
+ -3.230889701412e-02
+  1.112659099307e-01
+  4.144166044846e-02
+ -1.204159405266e-01
+  4.133397271204e-02
+  7.529006241163e-02
+  2.895073605608e-02
+ -1.587810529652e-01
+  1.405638509446e-01
+  6.008790543350e-02
+  1.043612180191e-01
+ -1.893957968702e-03
+  4.237064744431e-02
+ -4.462031671508e-02
+  7.607638385477e-02
+  7.613678245235e-02
+  1.600172769373e-02
+ -7.067740673722e-02
+ -1.614997925139e-01
+ -3.587244828691e-02
+  1.395923297664e-01
+ -7.020956366305e-02
+ -1.500984305478e-01
+  4.914637402426e-02
+ -6.433919843803e-02
+ -1.297382947427e-01
+ -7.103663113472e-02
+ -1.216830798531e-01
+  3.212397859902e-02
+ -1.008986652829e-01
+  3.589390689535e-02
+  9.363428803559e-02
+  6.298661385927e-02
+ -1.077814321910e-01
+ -1.259765951036e-01
+  6.658022223210e-02
+  1.038840503824e-01
+ -1.881975098697e-03
+ -1.108052836252e-02
+ -2.901068569441e-02
+ -7.860772863327e-04
+ -5.694961750687e-02
+ -1.532852909528e-01
+  2.522531861118e-03
+ -1.034826368333e-02
+ -9.706236818594e-02
+ -1.072381863284e-01
+  1.854417731997e-01
+ -1.444221182702e-01
+ -8.388417536485e-02
+ -3.494431288416e-02
+ -1.125410618018e-01
+ -1.446301972014e-01
+ -5.584282536241e-02
+  1.307842515942e-01
+ -2.810143956623e-02
+ -1.442455376122e-01
+ -6.618577770395e-02
+ -1.523642870213e-01
+  3.911133853652e-02
+  9.459406531105e-02
+ -7.900840270847e-05
+ -4.469227513765e-02
+ -1.442800256104e-02
+ -9.480083475048e-02
+  7.084807112605e-02
+ -8.912965163973e-03
+  9.058415365359e-02
+ -1.231661136649e-01
+ -7.938612691948e-02
+ -1.803814215636e-01
+ -3.542683399650e-02
+  1.300445399506e-02
+ -1.730351085363e-02
+ -6.528988223471e-02
+  7.825879135090e-02
+  4.946775440638e-02
+  1.560119457826e-01
+  1.050297869656e-01
+ -7.305474160910e-02
+ -4.042333384137e-02
+  9.125757326735e-02
+  1.591654683144e-01
+ -2.761295037874e-02
+ -6.616167296529e-02
+  1.516875344515e-01
+ -6.092999693377e-02
+ -1.829196993041e-01
+  3.532632798117e-04
+ -8.768019254846e-02
+ -4.577121319873e-02
+ -8.782070065484e-02
+ -4.458071372828e-02
+ -9.013274917230e-02
+  6.361568596514e-02
+  7.791116470913e-02
+  5.199839625551e-02
+ -8.558823154070e-02
+ -6.954056037588e-02
+  8.149068162217e-02
+  1.134809422793e-01
+ -8.479339567060e-02
+  4.397782299871e-02
+ -1.796598597842e-01
+ -1.444490769535e-02
+ -1.055330698162e-01
+  2.613984351784e-02
+  4.433639274175e-02
+ -4.183898440151e-02
+ -1.080125690729e-01
+  2.285659216277e-02
+ -2.049301744785e-01
+ -1.163483760126e-01
+  6.537037539246e-04
+ -1.933979682401e-01
+  4.742385709995e-03
+ -9.955663684243e-02
+ -1.550648974338e-02
+  1.384153190514e-01
+ -2.015126292314e-01
+  2.999041294951e-02
+ -9.958429821415e-02
+ -9.245857131401e-02
+ -7.699408928188e-03
+ -1.039248757944e-01
+ -2.029490653040e-02
+  5.549471914670e-02
+  2.682332304381e-01
+ -7.692881878417e-02
+  7.995275969804e-02
+ -5.105096361658e-02
+ -1.494256233429e-01
+  8.746019320348e-02
+  2.266521439231e-02
+ -7.740029595787e-02
+  5.490463059991e-03
+  2.979386631502e-02
+  2.979406024596e-02
+ -3.326089326792e-02
+ -5.687875057356e-02
+  7.424818619941e-02
+ -1.523147676059e-01
+ -3.224380530490e-02
+ -1.181263390343e-01
+ -5.372203055663e-02
+  1.534067963055e-02
+  1.052030939186e-03
+ -2.269819295508e-02
+  6.062073732770e-02
+ -1.889927210927e-01
+ -2.344811461808e-01
+  1.732437641872e-01
+ -5.852183405984e-02
+ -2.264443884354e-01
+ -2.392247814938e-02
+ -6.572391104581e-02
+  7.961196498789e-02
+  1.325651654614e-01
+  1.091305964757e-01
+  4.445232596039e-02
+  1.046667663326e-01
+  4.758920957516e-02
+ -2.979562608343e-01
+  7.882764245195e-02
+ -1.249453794769e-01
+ -1.480321156030e-01
+  2.192001222433e-02
+ -1.109345653529e-01
+  2.890355609493e-02
+  3.323764928047e-02
+ -5.750830020822e-02
+ -5.189671170811e-02
+  2.316867269158e-02
+  2.225518561125e-02
+  1.891636172237e-01
+ -9.740017409297e-02
+ -5.991632952059e-02
+ -1.746990910978e-02
+  1.280264537685e-01
+  1.253155002466e-01
+  3.612331241279e-02
+  1.490634947219e-01
+ -6.360398488105e-02
+ -5.575051104865e-02
+  1.104085052523e-01
+  2.910217475956e-02
+ -8.651695207179e-02
+ -1.000619478634e-01
+  1.279282422503e-01
+ -7.545726359923e-02
+  6.145775885795e-02
+  5.243983812679e-02
+  1.577049157373e-01
+  4.420199125809e-02
+  1.010081208788e-01
+  4.111134243004e-03
+  9.576841197019e-02
+ -7.869865207608e-02
+  1.885186978658e-02
+  4.094494133421e-02
+ -9.019656112883e-02
+ -1.582273915198e-01
+  3.643693989913e-02
+ -5.944118556404e-02
+ -8.661910222464e-02
+  7.994171465469e-02
+ -1.041222032716e-01
+  4.298983580237e-02
+  1.816071188080e-01
+ -2.235719404812e-03
+ -1.700447416555e-01
+ -8.516174934652e-02
+ -3.942836816474e-02
+ -2.138555856071e-03
+  8.089474808116e-02
+  6.787273049403e-02
+ -1.443611765429e-02
+  1.198266704460e-01
+  2.545654023825e-02
+ -2.389938059206e-02
+  6.172092444795e-03
+ -6.794031195538e-02
+  9.823858914524e-02
+  1.511862397572e-01
+ -6.524482998881e-02
+  4.548775769786e-02
+  3.486313813613e-02
+  5.988429545837e-02
+  3.253965663849e-02
+ -1.817897945765e-02
+ -1.124513618502e-01
+  5.195691906141e-02
+ -7.673809567323e-02
+ -1.517829690824e-01
+ -3.824597112370e-02
+ -1.529487496830e-01
+  8.737656565852e-02
+ -5.040834117459e-02
+ -7.059151860180e-02
+  6.044666168238e-02
+  3.595239210396e-02
+  3.965680345462e-03
+ -4.175939271266e-02
+  4.546478600348e-02
+ -1.506241091553e-01
+  5.031003434555e-02
+ -1.716243959601e-02
+  2.805193298742e-02
+  2.625980253732e-02
+  7.657073823790e-02
+ -1.301616690385e-01
+  6.890734866484e-02
+ -1.868444910133e-02
+ -3.889887319929e-02
+  4.990055724768e-02
+ -1.426767829462e-01
+ -3.340168083088e-02
+  5.737591989894e-03
+ -8.025127736300e-02
+ -7.414760697827e-02
+  2.964116305816e-01
+ -1.934184350277e-02
+  1.750443082400e-01
+ -1.206148267018e-01
+ -2.752078885564e-02
+  8.241630755175e-02
+ -2.565246301915e-02
+  2.689115962220e-02
+ -8.904789838057e-03
+  1.157155938698e-01
+  1.098572259858e-01
+ -1.816750685273e-02
+  8.669277338467e-02
+ -3.857328169949e-02
+ -1.814832746318e-02
+ -1.380714765040e-01
+ -1.497674291412e-02
+  4.012109181883e-02
+  2.315024133794e-02
+ -1.797119411102e-01
+ -2.075063642190e-01
+  6.834959237619e-02
+ -4.632759666704e-02
+  3.940312230472e-02
+  6.492294653665e-02
+  1.576423309926e-01
+  2.182529442979e-02
+ -9.235743681178e-02
+  5.098452566410e-02
+  1.309918574042e-02
+ -6.581857121701e-02
+ -1.481470935030e-01
+ -1.278351949831e-01
+  1.429510747439e-02
+  1.368772640139e-02
+ -1.163544694647e-01
+  7.592241113144e-02
+ -9.471730591166e-02
+ -7.902918535530e-02
+  1.061035385233e-01
+  3.001099639452e-02
+  8.763224667121e-02
+ -4.553831563956e-02
+  1.705081812669e-02
+  8.268164098542e-02
+ -3.463573618751e-02
+ -7.544523679170e-02
+  1.162495824577e-01
+  9.232665990067e-03
+  4.281546909927e-02
+ -7.463988262077e-02
+ -1.373585895632e-01
+ -9.915302114479e-02
+  2.631848483123e-02
+  2.012691029232e-02
+ -1.171917676985e-01
+ -1.865022780631e-01
+ -3.975908228340e-02
+ -8.796440154331e-02
+ -2.298641160413e-01
+ -1.108833290217e-01
+  1.095963298409e-01
+ -4.469942594294e-02
+  7.124505902136e-02
+  1.574804030447e-01
+  7.901677819068e-03
+  9.065780926074e-02
+  8.171470415021e-02
+ -8.519354103248e-02
+  6.236560353373e-02
+  2.187328047619e-02
+  2.362696565862e-02
+ -7.349688168573e-02
+  4.616151573482e-02
+ -6.558966806551e-02
+ -1.203022878501e-01
+ -6.523310664284e-02
+  1.270860194738e-01
+  5.767971616163e-02
+ -1.353797987502e-01
+ -1.597969834688e-01
+ -6.572790471060e-02
+  5.227291483153e-02
+  2.161115472245e-02
+ -9.464590344922e-02
+ -4.040154835625e-02
+ -3.329056129790e-02
+  6.704745740001e-02
+ -1.393658152985e-01
+ -1.038877737669e-01
+  5.273042653683e-02
+ -1.001683363928e-02
+  9.030750303196e-02
+ -1.055058135800e-01
+  1.014487550753e-02
+  4.480430306615e-02
+  7.377898473512e-02
+  1.109183707867e-01
+ -1.549632813330e-01
+ -6.620686777850e-02
+ -5.251576849405e-02
+  2.044396493010e-01
+ -4.537876284347e-02
+  4.945190646503e-02
+ -2.150850926846e-02
+ -1.050335550396e-01
+ -4.467105997445e-02
+  2.494106236361e-01
+ -3.972888041359e-02
+ -1.000391140065e-01
+  2.639854542722e-02
+  7.631953792576e-02
+  3.339484871125e-02
+  1.817810497380e-01
+ -1.032636564801e-01
+ -7.550300023743e-02
+  1.606012255801e-01
+  1.357484243513e-01
+  3.418258892562e-02
+  1.251829610202e-01
+  8.192525147654e-02
+  1.238133869553e-01
+  2.520740963555e-02
+  1.091983052799e-01
+ -2.943243422942e-02
+ -8.820656767090e-02
+ -2.000142251539e-02
+  5.430119088693e-02
+  8.705928925833e-02
+ -2.502489418671e-02
+  1.026612881007e-01
+  3.877823773119e-02
+  1.362944014733e-01
+ -3.840377316959e-02
+ -1.678869202986e-02
+  1.522892843816e-02
+  3.880999292468e-02
+  7.733981151087e-02
+  2.163014101700e-01
+ -1.999037382321e-01
+ -3.428746507059e-02
+ -4.865776147175e-02
+  2.146599881788e-01
+ -7.001434423349e-02
+  7.839330306439e-02
+ -5.228457390262e-02
+  1.137687444975e-01
+ -1.968460755116e-01
+ -2.495795516735e-02
+ -9.684204235068e-02
+ -6.934108593021e-03
+ -8.584338582619e-02
+ -7.340403718088e-03
+  1.824708988083e-01
+  6.296957459881e-02
+  1.111612026991e-01
+ -4.805488379949e-02
+  3.515619107935e-02
+ -5.152661350757e-02
+  4.297815562455e-02
+  1.805365119036e-01
+  2.178244936770e-02
+  5.950565309594e-02
+  1.113704705889e-01
+ -1.297114121589e-01
+  1.307179709692e-02
+  1.121405886636e-01
+  2.711744044691e-02
+  7.699610441136e-02
+  8.709233344447e-02
+  9.991045834954e-02
+ -5.145243851514e-03
+ -1.057668651398e-01
+  6.641286239916e-02
+ -2.499514951770e-01
+ -2.503199208414e-02
+ -5.866357088713e-02
+ -4.426536982651e-02
+ -3.809472974205e-02
+  7.258364575133e-02
+ -1.124149212537e-02
+  1.149189870561e-01
+ -2.057981770790e-02
+  6.748830729308e-02
+  5.833144024117e-02
+  1.104530372040e-01
+  4.156545194066e-02
+  6.518446284548e-02
+  1.151147651675e-01
+ -1.444612401631e-01
+ -9.959328054540e-02
+  7.536278342449e-02
+ -3.058984699383e-01
+  1.257642816950e-01
+  5.124132987746e-02
+  1.518290685570e-01
+ -5.230539674859e-02
+ -1.081213953002e-02
+  7.997712527136e-03
+ -9.618986954015e-02
+  1.436964513724e-01
+  7.622543182180e-02
+ -3.960990940954e-02
+ -5.288106669799e-02
+  8.556573898757e-02
+  1.957305266308e-01
+ -9.622107100532e-02
+  8.888685697977e-02
+  1.023316022305e-01
+ -7.214564221263e-02
+  2.815072263400e-02
+  7.067170067130e-02
+  1.748472785066e-01
+ -5.957264628235e-02
+  1.946554827354e-02
+ -1.328540633146e-01
+ -6.470595380618e-02
+ -8.563712406560e-02
+ -9.654908478561e-02
+  9.720376889590e-02
+  1.282261257349e-02
+  1.519508602834e-01
+  1.071604261672e-01
+ -1.877087053410e-02
+  8.674961208303e-02
+ -1.543869711168e-01
+  9.456424049992e-02
+ -6.148187174793e-02
+ -3.084192598970e-01
+  3.846709995565e-02
+  4.182769336264e-02
+ -3.354449708990e-02
+  9.390913127044e-02
+ -8.269516147549e-02
+ -1.318901277445e-02
+ -2.728439615576e-02
+ -1.362309153840e-01
+ -4.605423256674e-02
+ -1.805301294071e-02
+ -1.171394320441e-01
+  1.978130936275e-01
+  1.580810829405e-01
+ -5.337316970113e-03
+  1.961658860650e-01
+ -6.666984100864e-02
+  5.395270566450e-02
+ -7.507401979522e-02
+  6.089023814390e-02
+ -9.275932876838e-02
+ -1.112207617370e-01
+  2.121243774036e-02
+  1.243241951232e-01
+ -1.148995757162e-01
+ -8.478576501328e-03
+  2.236705982714e-02
+ -4.280927254679e-02
+  5.216130435492e-04
+ -7.503289905493e-03
+  7.184920502313e-02
+ -1.733516201572e-02
+  5.050597114447e-02
+  3.878840127336e-02
+ -4.797031037758e-04
+  1.757059305945e-01
+ -8.341711592209e-02
+  5.460747583147e-02
+ -3.042036970231e-02
+ -8.571187599467e-03
+  6.903521311906e-03
+ -9.203716095234e-02
+ -2.026457303504e-02
+ -3.975694974429e-02
+ -3.847331163081e-02
+ -9.710950298929e-02
+  1.556827348119e-01
+ -4.982355751221e-02
+ -7.952877973058e-02
+ -1.162328358269e-01
+ -4.860738008380e-03
+ -1.115426427331e-02
+  2.199270809626e-01
+ -8.914959376079e-02
+  8.680899870623e-02
+ -5.518842819512e-02
+ -1.587638494147e-01
+  8.581201278843e-02
+  1.064889877348e-01
+  9.066863913285e-02
+ -1.615916955013e-01
+ -9.340105136793e-02
+  1.249013290646e-01
+ -2.224169659337e-02
+  6.611355836599e-02
+ -6.889396608343e-02
+  6.136184841204e-02
+  3.084598063774e-03
+ -1.350726865191e-01
+ -1.053882119704e-01
+ -2.991339407667e-02
+ -3.664249778469e-02
+  1.540161208619e-01
+  8.554547587224e-04
+  3.833315051330e-02
+ -1.165899571542e-01
+ -8.234560775926e-02
+  1.924859996835e-01
+  1.429098012220e-01
+ -1.286238518307e-01
+ -2.721340557813e-02
+ -6.290190673518e-02
+ -4.100784609707e-02
+ -1.922197913217e-01
+  6.627428525983e-02
+ -2.409329681527e-02
+ -3.288470141691e-02
+ -9.412713970701e-02
+  1.268299229285e-01
+  4.195036744493e-02
+  7.518564718859e-02
+  9.408812055797e-02
+ -1.095989608660e-01
+  9.858074396896e-04
+ -6.381936556084e-02
+  9.048743158084e-02
+  5.302994629521e-02
+ -7.351575033750e-02
+ -1.195483104785e-01
+ -7.130688809538e-02
+  3.167322519117e-02
+ -3.856932122315e-02
+  1.481065735852e-01
+ -5.266669722552e-02
+  1.027503565906e-01
+ -1.362549558409e-01
+ -7.477804149844e-02
+ -8.343512018106e-03
+  4.555325832165e-02
+ -2.719369480215e-02
+ -7.040993483570e-02
+ -4.064158070754e-03
+  1.543145607051e-02
+  1.756686672124e-02
+  6.591604625955e-02
+  8.964922760299e-02
+  6.609881888811e-03
+  1.495844263070e-01
+ -1.919134766921e-01
+  2.078802579130e-01
+ -1.895085395391e-01
+ -4.244466286650e-02
+  9.273330981085e-02
+  1.009558080279e-01
+  1.033794688248e-01
+ -4.445654550270e-02
+  1.844084246117e-02
+ -1.394826733476e-01
+ -3.329630483941e-02
+  1.809991514344e-02
+ -1.151394277328e-01
+  9.208595600445e-02
+ -8.809239809311e-02
+ -1.518363909699e-02
+  1.229532433496e-01
+  1.629290591346e-01
+ -1.765915180268e-01
+  6.282399659629e-02
+  1.064110824249e-02
+  6.768902034892e-02
+  8.089136503403e-02
+  1.602077222195e-02
+  1.351458842742e-01
+ -1.273876620558e-02
+ -1.063506549097e-01
+  1.988214769887e-01
+ -7.083716970719e-02
+  6.413227960870e-04
+  2.808203847243e-02
+  6.067223796191e-02
+  1.565056951828e-01
+  1.106658940853e-01
+  5.352481226685e-02
+  5.128561217739e-02
+  8.490640691315e-02
+ -1.650161834511e-01
+ -1.145514060667e-01
+ -1.881683379834e-02
+  1.966310255739e-02
+  7.780852988875e-03
+  1.766156049906e-01
+  1.656452308332e-01
+ -3.988515280960e-02
+  3.639967001702e-02
+  3.628501724035e-04
+  9.279555048198e-02
+  1.225961370653e-01
+ -6.962413711429e-02
+  8.069747345298e-02
+ -2.144815174523e-02
+ -2.096053559628e-03
+ -9.458354275224e-02
+ -1.439596700616e-01
+ -4.487092816499e-02
+  2.206104210963e-01
+ -1.529316442504e-01
+  5.725984018649e-02
+  1.016661747508e-01
+ -1.210268787025e-01
+  1.562852994479e-01
+  5.200628382431e-02
+  7.976924423294e-02
+ -1.130062131007e-01
+ -1.987019377095e-01
+ -1.084138330894e-01
+  5.665041290388e-02
+  1.437835574805e-01
+ -1.792026236310e-02
+ -3.587492511762e-02
+  4.570391408626e-02
+ -8.420083485861e-02
+ -1.933152558876e-01
+  7.909936315578e-02
+ -1.083412237247e-01
+ -2.541052185096e-02
+  3.737014632877e-02
+ -1.310184478551e-01
+ -1.310953884330e-01
+  4.647598074925e-02
+  1.521830167311e-01
+  1.426449965775e-01
+ -1.091681718098e-02
+ -6.086186220084e-02
+ -1.307406742580e-01
+  2.443952003447e-03
+  8.430963706034e-02
+  6.592780241220e-02
+  2.653815182919e-02
+  3.236121688678e-02
+  2.150878082111e-01
+ -1.892889298072e-01
+ -1.423180037203e-01
+  3.083349135511e-02
+ -5.727654026164e-02
+ -1.478410134112e-01
+ -2.091223598917e-04
+  7.954413016052e-02
+ -1.022571939791e-01
+ -1.009469303902e-01
+ -1.130902891654e-02
+  3.283615828577e-02
+ -6.432388208681e-02
+  1.467306327617e-01
+  3.245177546089e-02
+ -5.566064368642e-02
+ -6.057054025987e-02
+  1.998068515319e-02
+ -2.785943795042e-02
+ -1.639207534651e-01
+ -7.957808503391e-02
+  1.285231933810e-01
+ -4.943426502166e-02
+  9.899954477066e-03
+ -2.651805962874e-01
+ -1.568715914251e-01
+ -1.153800542143e-02
+ -5.181719645137e-02
+ -4.722602437154e-02
+ -1.179254800214e-01
+ -2.944149291709e-03
+ -6.752475372904e-02
+  4.025060610840e-03
+ -4.647139395694e-02
+ -3.265175547684e-02
+  9.576332719275e-03
+ -1.727393522463e-01
+ -7.413579392020e-02
+  2.119283303717e-02
+ -7.917087221968e-02
+ -1.247823226657e-01
+ -4.638073033925e-02
+ -7.565960509164e-02
+  9.600976262848e-02
+  1.557055356448e-01
+ -6.757822281271e-02
+ -9.669757351847e-02
+ -1.142561573644e-01
+ -1.262060618414e-01
+  4.652641434688e-02
+ -1.551058154455e-01
+ -4.045172981508e-03
+  8.838956418423e-02
+  1.217818598479e-01
+ -1.112762512637e-01
+ -1.085142056664e-01
+  1.082836956297e-01
+  3.508654311664e-02
+ -1.479893074586e-02
+ -1.430404813548e-03
+ -1.087247404236e-01
+ -8.053671932662e-02
+ -7.257496236489e-02
+  6.444259494459e-02
+ -1.197658081027e-01
+  4.273677926497e-03
+ -4.096518546346e-02
+ -2.488289692477e-03
+ -1.129261067521e-02
+ -2.343844235662e-01
+ -3.510824064078e-02
+  2.459375879533e-02
+ -2.107197666493e-01
+  1.546963143323e-01
+  1.576704616396e-01
+  9.887314531181e-02
+ -7.148005773563e-03
+  1.634640103129e-01
+ -1.098806543734e-01
+ -4.569790055705e-03
+ -3.559607519212e-02
+ -1.394330762832e-02
+  1.624873591071e-01
+ -5.429960016022e-02
+ -1.729803361824e-01
+  5.109576231531e-02
+ -3.843520374757e-02
+ -3.947619329198e-02
+ -2.590836638245e-02
+  2.616896026110e-02
+  8.336085876349e-02
+ -5.308550758197e-02
+  1.043324200259e-01
+ -4.000272141027e-03
+  4.751065678054e-02
+  2.507272197580e-02
+  1.859125508122e-02
+ -8.904936897380e-02
+ -1.387950833030e-01
+  9.425098396373e-02
+ -5.673886202323e-02
+ -2.223062111093e-02
+ -7.492630874138e-02
+ -1.197420613304e-01
+ -1.271840658099e-01
+  1.108589167538e-01
+ -2.706151589200e-02
+  3.359390663632e-02
+ -2.875985553557e-02
+  2.446295455548e-02
+  3.833654358406e-02
+ -2.566089966585e-02
+ -1.035315737516e-01
+ -5.245249333699e-02
+  6.179774485460e-02
+ -8.152007053916e-03
+ -7.337485224805e-02
+ -3.088567263543e-01
+  9.094620545646e-02
+ -2.273323520078e-02
+ -5.961371371695e-02
+  2.648385362469e-02
+ -2.308810543944e-01
+ -1.463785170058e-01
+ -5.938907983826e-02
+ -1.388754999144e-01
+  1.170944822989e-01
+  3.007665104808e-02
+  3.075691308004e-01
+ -1.396596440374e-01
+  1.103465430992e-01
+ -1.815255342381e-02
+ -1.651745309184e-01
+ -9.536509008614e-02
+ -1.302619423932e-01
+  8.099598760549e-02
+  9.455103824381e-02
+ -8.579986821419e-02
+  1.154664683133e-02
+ -6.229635533922e-02
+  5.876611027378e-02
+ -1.084444184001e-02
+ -2.647579530610e-02
+ -4.559462383407e-02
+ -3.245772070248e-02
+  1.130394143934e-01
+ -8.936366884803e-02
+  7.869850086656e-03
+ -2.191029492323e-02
+ -8.145051102677e-03
+  1.416847632228e-01
+  6.638605212065e-02
+  5.403436377687e-02
+ -2.513646894058e-02
+ -1.044893945943e-01
+ -5.068771052091e-02
+  1.781612193483e-02
+ -1.430746076691e-01
+  5.817195680023e-02
+ -6.700869005710e-03
+  3.631922907022e-02
+ -1.086948108153e-01
+  6.152455100580e-02
+ -1.681968166078e-01
+  5.417540364694e-02
+ -5.308522026762e-02
+ -5.541461018365e-02
+  2.235099318494e-01
+ -2.153413883361e-01
+  2.852567652478e-02
+ -7.817715344091e-02
+ -6.300753566917e-03
+  1.295308741367e-01
+  3.090914651265e-02
+  1.240200468439e-01
+  7.338551205931e-02
+ -1.357729405747e-01
+ -1.675544574156e-03
+  1.328579247321e-01
+ -9.584585522359e-02
+  6.745729385442e-02
+ -1.473947232153e-01
+  3.161407890616e-03
+ -5.221470491861e-03
+ -8.367835874048e-03
+  8.456875202915e-02
+  1.223695277637e-01
+  6.010697854727e-02
+ -2.315230903266e-02
+  1.150779962722e-01
+  1.082754663292e-01
+  2.433647956422e-01
+  1.694626344913e-01
+  8.428510083641e-04
+ -1.180447934822e-01
+ -2.320011073300e-02
+ -1.016112694810e-01
+  1.948013103085e-01
+  2.693936126689e-01
+  7.925745419754e-02
+ -4.527022480405e-02
+  1.183046073533e-01
+ -7.367133451085e-02
+  2.172316582721e-01
+ -1.306667677026e-01
+ -1.112147858697e-01
+  4.205598341618e-02
+  3.525071169322e-02
+ -2.741332790514e-01
+  6.169744357590e-02
+  1.862986475719e-02
+  1.485830411964e-01
+  4.917336220648e-02
+  6.520000412502e-02
+ -3.883776965894e-02
+ -1.317924030329e-01
+ -1.411625972541e-02
+  5.424162081764e-02
+ -1.177091096003e-01
+ -1.396415305473e-01
+  1.622729569283e-01
+ -9.001563092639e-02
+  7.675939258202e-02
+ -3.092413177403e-02
+  6.384457787253e-02
+ -9.389189736296e-02
+  7.665845350158e-02
+ -1.098514579779e-01
+  4.927853541305e-02
+ -2.581807144644e-01
+ -8.994009509368e-02
+  2.257478838380e-01
+ -1.613481814854e-02
+ -1.661701445489e-01
+  1.349119169724e-02
+ -1.056184085655e-01
+ -1.800701384594e-01
+  9.879226187074e-02
+ -2.272323988844e-02
+  4.569638636486e-02
+  1.014675617163e-01
+ -6.318923662020e-02
+  5.669236218893e-02
+ -6.498589758430e-02
+  2.820105918602e-02
+  9.856179481191e-02
+ -6.906488652659e-02
+ -2.787729073862e-01
+ -2.620749528901e-01
+  1.849823544680e-01
+ -2.218542720353e-02
+  1.204276929217e-01
+  1.195195861211e-01
+  4.110992956719e-02
+ -8.480118159661e-03
+ -7.127789623918e-02
+  4.382544576162e-02
+  1.283210365072e-01
+  5.775476786455e-02
+  6.465858369753e-02
+ -1.836721162619e-01
+  9.209282755248e-03
+ -3.002053745016e-02
+  7.319708771406e-02
+  5.691768808480e-03
+ -2.672250550283e-01
+  1.155241624683e-01
+ -1.059979012957e-01
+ -7.021089202096e-02
+ -1.722922492488e-02
+  2.769221661916e-02
+  2.530314977351e-02
+ -1.325643977702e-01
+ -6.586854175585e-02
+ -2.989857494020e-02
+  1.219025659484e-01
+ -1.454157096671e-01
+ -6.228083645508e-02
+ -5.322284390242e-02
+  1.021944417492e-02
+  4.294343731400e-02
+  2.778497646653e-02
+  5.517883562595e-02
+ -6.942262621894e-02
+ -9.275540323204e-02
+  6.569488614661e-02
+  5.931947784692e-02
+ -6.666642780535e-02
+  1.802573921825e-01
+ -1.803949688207e-01
+ -4.603716337739e-02
+ -1.025529924204e-01
+  1.806322183224e-02
+  1.194977715963e-01
+ -7.599154960762e-02
+ -1.272485123421e-01
+ -5.633596853198e-02
+  1.204005874185e-01
+ -5.835363970104e-02
+ -1.033362493417e-01
+ -3.094544968721e-03
+  1.562368409218e-01
+  8.780878067306e-02
+ -6.045982151815e-02
+ -3.825655541962e-02
+  8.532580188522e-02
+  2.361892561572e-01
+ -8.186791204063e-02
+  6.748214319092e-02
+  8.107945223256e-02
+ -5.447841640388e-02
+ -7.038675852264e-02
+ -1.720806260887e-01
+  5.517166996675e-02
+  2.170161133316e-03
+  1.499786851102e-01
+  1.001771865508e-02
+ -4.137325804285e-02
+  1.345611256688e-01
+  3.441695257051e-04
+  8.540619711600e-02
+  3.790849683577e-02
+  1.738411081964e-02
+  8.112581470382e-02
+  1.322450457573e-01
+ -4.731004374294e-02
+  3.058952085529e-02
+  6.738817697724e-02
+ -5.382327141148e-03
+ -6.282581866274e-02
+ -7.848342520166e-03
+ -2.757878389835e-02
+  4.944506663850e-03
+  5.799761088056e-02
+  9.135034850521e-02
+  2.513900517490e-01
+ -6.724749811533e-02
+  1.459309563965e-01
+ -7.254611806339e-02
+  4.489170715992e-02
+  1.340804364064e-01
+  2.217231988846e-02
+  2.332515448528e-02
+  2.649610590106e-02
+  1.878031655236e-01
+ -7.550951155867e-02
+ -4.087643681245e-02
+  1.173164598464e-01
+ -1.300186102099e-01
+  6.236828661698e-02
+  6.283335788656e-02
+ -7.050046479988e-02
+ -2.697576756323e-02
+ -2.672452126265e-02
+  3.345266729241e-02
+  2.624484515777e-02
+ -5.005296814823e-03
+ -8.310664513163e-03
+ -7.712583533181e-02
+  2.706187495026e-02
+ -2.737780551350e-02
+ -1.209035691436e-01
+ -3.679229312266e-02
+  7.221179034760e-02
+  2.026138030388e-02
+  1.458460754366e-02
+ -1.533159990259e-01
+ -7.615968760953e-02
+  9.271913612417e-02
+  1.031024367815e-02
+  9.667154339215e-02
+  5.497573933971e-02
+  4.680143416094e-02
+ -7.646595578971e-03
+  5.737696033355e-02
+  2.374029336543e-02
+ -9.576968572758e-02
+  5.375050739261e-02
+  2.167092280880e-02
+  1.538155340459e-01
+ -1.969207371695e-01
+ -3.047138558076e-02
+ -1.356872412191e-01
+ -1.863615173030e-01
+ -6.035016469881e-02
+ -8.027969007405e-02
+  3.092554058611e-02
+  1.373324794223e-01
+ -2.972433426333e-02
+ -1.008214418856e-02
+ -8.059544591762e-03
+ -1.801075042154e-01
+  1.720571453221e-01
+  5.132464842511e-04
+  7.972363366063e-02
+  9.021109853050e-02
+  3.049702044041e-02
+  1.810873907044e-02
+  1.018966848559e-01
+  1.737705870747e-01
+  5.780362100693e-02
+  8.427749796808e-02
+  8.144925659337e-02
+ -8.719820627808e-02
+  9.455557591532e-02
+ -9.201619908734e-03
+ -5.903992184589e-02
+ -9.848554199636e-02
+  1.216969821753e-01
+  1.510778585433e-01
+  2.631629517822e-02
+ -8.514562959198e-02
+ -7.180366978164e-02
+  1.598797491395e-02
+ -2.512812386700e-02
+  2.766717673008e-02
+ -1.496483844536e-01
+ -1.615096558476e-02
+  8.764050142516e-03
+ -1.973752053641e-02
+ -1.814821303805e-02
+  1.368615505524e-01
+ -1.822616259440e-01
+  1.042494469795e-01
+  2.192313268268e-01
+ -1.987861440542e-02
+ -1.785252926718e-01
+  7.599094287746e-03
+ -3.104080510434e-04
+  8.856530195397e-02
+ -1.033347966030e-02
+  1.310577837559e-02
+  1.547549000992e-01
+ -5.718215891756e-02
+  3.352227434282e-02
+  9.748527802367e-02
+ -1.291383887790e-01
+  1.623195572443e-01
+ -6.591430353674e-03
+  2.758439880085e-02
+ -1.261298765465e-01
+ -8.836755707938e-03
+  2.474408106781e-02
+ -2.682959669138e-02
+ -7.904846285693e-02
+  3.786194365419e-03
+  6.189896693258e-02
+ -4.425275738182e-02
+  9.858801603043e-03
+  1.341296748854e-01
+  5.593679148664e-02
+ -6.899015362593e-02
+  1.230603634516e-01
+ -1.157394711032e-01
+ -4.438393598611e-02
+  1.551466052582e-02
+  2.132682838768e-01
+ -2.448441773755e-02
+ -1.712171294901e-01
+ -4.963773147630e-02
+  3.798092905529e-02
+  1.872345522825e-01
+  2.757863360036e-01
+  2.202418132913e-01
+  5.073337478024e-02
+ -1.632518796400e-03
+  1.070253886241e-01
+  1.629395379765e-03
+ -1.806352079079e-01
+  8.127150233060e-02
+ -5.914281678743e-02
+ -6.569665734683e-02
+ -9.959223952560e-02
+ -5.449566571336e-03
+ -1.699890469445e-01
+ -1.697832888065e-02
+ -5.910026089602e-02
+  1.108284951974e-02
+ -7.528385879023e-02
+  2.527785627069e-02
+ -9.914623197651e-02
+  4.088116295412e-02
+  5.842855242880e-02
+  4.364004865893e-02
+ -4.232111074888e-02
+  2.235117776012e-01
+  1.401497248606e-01
+  3.746165325832e-02
+  1.145702923592e-01
+  2.263037323812e-02
+ -1.380613160335e-01
+  7.487800132003e-02
+  8.418310477710e-02
+ -9.383835562520e-02
+  6.302366972817e-02
+  5.564002107533e-02
+  2.980574925125e-02
+  7.381731074151e-02
+ -3.290376159718e-01
+ -1.077912234736e-02
+ -8.482595286033e-02
+ -1.184183510741e-03
+  1.488388417354e-01
+  1.327059713093e-02
+ -1.578773510253e-01
+ -6.991804116458e-02
+  1.745604339478e-01
+ -1.414700616991e-01
+  2.353670079996e-01
+ -9.396797959521e-02
+  1.205806212832e-01
+  1.435445729076e-01
+ -5.303181194926e-02
+ -1.313223092312e-01
+  7.402884840728e-02
+  3.034765161650e-02
+  6.895837583910e-03
+  6.149957264380e-02
+ -1.303100403115e-01
+ -1.471775011341e-01
+  2.201302040785e-02
+ -3.709466269974e-02
+  1.160394048299e-01
+  4.988937331747e-02
+  1.039790846968e-01
+  5.397283951943e-02
+ -2.688340114036e-03
+ -8.660984893444e-02
+  1.307642203980e-01
+ -8.583548186412e-02
+  1.062799235817e-01
+ -2.155613052459e-01
+ -4.442636010828e-02
+  1.108149905515e-01
+  4.726945364576e-02
+ -5.459132754880e-02
+  5.598453472113e-02
+ -1.473115613592e-01
+  9.275449379239e-02
+  1.976282945574e-02
+  1.343023173992e-02
+ -7.928638433742e-02
+  6.884379510270e-02
+  1.598451404494e-02
+ -2.147985761164e-02
+ -8.098974351802e-02
+  2.690064479998e-02
+  9.263355750830e-02
+ -6.854883715047e-02
+  9.877862027103e-02
+  1.113464593766e-01
+ -6.880872137388e-02
+ -3.955366670553e-02
+ -9.260055061065e-02
+ -8.422315720894e-02
+ -8.935594871031e-02
+  1.216498046397e-01
+  2.344148964419e-01
+ -1.784036938324e-01
+  2.865710857524e-02
+  1.242972816246e-01
+ -5.897533075825e-02
+  7.820098603368e-02
+ -2.618799736941e-02
+  9.033952941341e-02
+  1.619327193893e-02
+  1.575956612195e-01
+ -1.123737389882e-01
+  9.552150772950e-02
+ -1.151640379641e-01
+ -1.175066632705e-01
+ -1.481381050325e-01
+ -2.954901332936e-02
+ -4.821241023066e-02
+ -1.185807125981e-01
+ -4.836353780251e-03
+ -4.343200628997e-02
+ -9.402717993323e-02
+ -4.963308267776e-02
+  7.864936162786e-02
+  5.736134994447e-02
+ -3.532616852144e-02
+  3.002647359732e-01
+ -1.615596769538e-01
+ -2.389576884533e-01
+ -1.386758243752e-01
+  7.277942466530e-02
+ -7.229549169288e-02
+  1.974795595941e-02
+ -6.508220490769e-02
+ -1.501326987591e-02
+  8.114168613412e-02
+ -7.599085341400e-03
+  1.620540719831e-01
+  2.231563821204e-02
+ -1.800790309248e-02
+  9.627549034869e-02
+ -6.113822233995e-02
+ -2.093256349283e-02
+ -1.768929591592e-02
+ -8.810775647610e-02
+ -1.029096452481e-01
+  1.096529313629e-01
+ -4.519537505992e-02
+  6.797965028413e-02
+ -2.926186148081e-02
+  2.250335654686e-01
+  4.732035061507e-03
+  4.832386545834e-02
+ -5.481733115327e-02
+  2.579419320079e-01
+ -8.010851867464e-03
+  1.561485264869e-01
+ -1.280039558630e-01
+  9.736920230985e-03
+ -9.287204550535e-02
+ -3.632698805624e-02
+  3.258044451913e-02
+  8.370892643291e-02
+  6.807658940202e-02
+ -2.672928274661e-02
+ -6.756066157654e-02
+ -1.339523109287e-01
+ -1.306280629466e-01
+  1.242706163054e-01
+  8.972525627148e-02
+ -8.908607245356e-02
+ -5.342571346016e-02
+ -1.589865089545e-01
+  1.533749532781e-01
+  2.728665661943e-02
+  8.789215616161e-02
+  1.571302286634e-01
+  6.215670068347e-02
+ -2.322351473628e-01
+  1.215732662139e-01
+  2.209316348965e-02
+ -2.554563636926e-02
+  1.844450647780e-01
+ -2.120280610676e-01
+  3.931737241064e-03
+ -3.943540504267e-02
+ -1.080049855730e-01
+  5.551274189827e-02
+ -1.492788778112e-01
+  4.526153491523e-02
+ -5.249344023754e-02
+ -7.245016244412e-04
+  9.658742815035e-02
+ -3.645848063736e-02
+  1.511431149376e-01
+ -5.282091065008e-02
+  7.303056971985e-02
+  5.085989122018e-02
+ -1.726686763787e-01
+  1.973082562430e-01
+ -7.888777148332e-02
+ -1.965059475090e-01
+  9.483767586669e-02
+  8.242236385900e-02
+ -2.534037963095e-02
+  1.975394046732e-01
+ -4.653387349124e-02
+  1.786453286434e-01
+ -2.179913297658e-02
+ -4.688359636112e-02
+ -5.737466326376e-02
+  7.583755757600e-02
+ -2.367759469328e-02
+ -1.701629112604e-02
+ -1.516340366982e-01
+ -2.673690682443e-02
+ -1.083446656618e-01
+ -1.089575112820e-01
+  1.018639727322e-03
+  3.968495560047e-02
+  1.463879001964e-02
+  9.508669455877e-02
+  5.005384653621e-03
+  2.663057247644e-02
+  8.674276209147e-02
+  1.210495152427e-01
+  3.853675580868e-02
+ -1.975004831454e-01
+ -1.250536913422e-02
+  9.872057307644e-02
+  1.149546692475e-01
+  2.263300996210e-01
+  2.911736955157e-02
+  9.497823310211e-03
+ -1.432655084216e-01
+ -3.482433851240e-02
+  6.658772680091e-02
+ -1.905228066852e-01
+  4.475727550528e-03
+ -6.400620019827e-02
+ -3.069280145862e-02
+  2.070668602462e-01
+ -9.857353963815e-02
+  7.840835472202e-02
+ -3.890669385974e-02
+ -3.457632080707e-02
+ -1.733316025544e-01
+ -1.741922419785e-02
+  3.199317270873e-02
+ -1.391353139084e-02
+  1.188968930550e-01
+  4.363952188041e-02
+ -8.277164910938e-03
+ -1.616088053762e-01
+  1.624055963029e-02
+ -1.081848192082e-01
+  1.403682321155e-01
+ -2.072872230756e-02
+ -1.022901078909e-01
+  1.145108581705e-01
+ -1.035786453814e-01
+ -4.379730750839e-02
+  6.970511186623e-02
+ -1.114865560443e-01
+  3.215004545080e-02
+ -1.595725764403e-02
+  2.832675941567e-02
+ -1.960462930759e-02
+ -4.588138457576e-02
+  4.185451850863e-02
+ -1.329488298482e-01
+  9.635824781755e-02
+  2.858249488447e-02
+  1.041629059810e-01
+  3.854931479815e-02
+ -6.052975852062e-02
+  7.877364729622e-02
+  1.222357290569e-02
+ -2.302658877346e-01
+ -8.201274497442e-02
+ -3.230369552305e-02
+  7.844956217543e-02
+  6.441535630425e-02
+  8.825010471561e-02
+ -3.495415791934e-02
+ -3.603045652724e-02
+ -8.529428714080e-02
+ -5.303341800577e-02
+  1.564498230816e-01
+  1.490199094697e-01
+ -3.484548762230e-02
+ -1.053114482878e-01
+  1.276192309543e-01
+ -7.517311968541e-03
+ -2.251306716401e-02
+  2.793319730152e-02
+ -5.954736238011e-02
+ -6.816179640947e-03
+  1.014088749617e-01
+  5.046122099739e-03
+ -6.090561366647e-02
+ -5.363172939534e-03
+ -1.146222463446e-01
+ -2.340439984431e-03
+ -1.938146241550e-02
+ -7.823576482721e-02
+  1.476236747666e-01
+  1.601254384741e-01
+ -9.595424274107e-02
+ -1.721260468646e-02
+  1.309945587786e-01
+ -6.402397987364e-02
+ -6.133344961131e-03
+  5.209137313693e-02
+  1.242227336645e-01
+ -1.532205434821e-01
+ -1.295312915966e-01
+ -3.176063775747e-02
+  5.913052687601e-03
+ -8.319000191095e-02
+  8.496826311166e-02
+  1.760240437355e-01
+ -1.934412455444e-01
+  3.491574305987e-03
+  1.039504022227e-01
+ -1.099150071856e-01
+ -1.404555196410e-01
+  4.609475955835e-02
+ -6.476713377623e-02
+  3.048195815215e-02
+  4.225749281981e-01
+ -6.908669629578e-02
+ -7.117844972842e-02
+  8.388228087543e-02
+ -1.895248818231e-01
+  6.052546392593e-02
+ -2.430337238470e-02
+ -5.922101865184e-02
+  9.831642801889e-02
+  8.786669046571e-02
+  3.611542969368e-02
+ -6.413021791036e-02
+  1.830773486549e-02
+ -3.398220172857e-02
+ -1.602520141151e-01
+ -1.136596995132e-01
+  4.423157610818e-02
+  1.953393435827e-02
+  1.307060258490e-01
+ -7.255506807457e-02
+  2.603296457666e-02
+  3.934210249080e-02
+ -4.569746721265e-02
+  3.877506304327e-02
+ -3.334143126812e-03
+  6.974474151446e-02
+  2.209715231708e-01
+ -5.522158942447e-02
+ -1.752518989610e-01
+ -2.135022875296e-02
+ -6.420957543096e-02
+ -3.443038198337e-02
+ -5.490764491307e-02
+  1.844476420829e-01
+  4.026314444397e-02
+  4.536654339384e-02
+ -1.271673402331e-01
+ -9.784591471828e-02
+  2.032136793452e-01
+ -3.726033837208e-02
+  8.507524690900e-03
+ -2.886073320466e-02
+ -1.659518391289e-02
+ -7.477184736674e-02
+  1.720884530279e-01
+ -8.448438059190e-02
+  3.709586254837e-02
+ -1.181375357824e-02
+ -8.281677010125e-03
+ -4.126881375026e-02
+  2.788662438719e-02
+  1.033634817604e-01
+ -6.051830442178e-02
+  8.250992624023e-02
+ -3.516078317806e-02
+  9.929477626584e-02
+ -1.125581696934e-01
+  7.798833093075e-02
+ -7.303443994605e-02
+ -3.555831812334e-02
+ -5.193327149954e-02
+ -5.945576776309e-02
+ -2.843074199324e-01
+ -8.761470194314e-02
+  2.970015252448e-02
+  1.296653758149e-01
+ -5.178686428300e-02
+  2.120030545131e-01
+ -7.696283762853e-02
+  7.217745109610e-02
+ -1.236333600374e-01
+ -1.538212018313e-01
+ -1.349533151983e-01
+  1.231040887258e-01
+  8.790010528351e-02
+ -1.498344622017e-01
+  5.568867142344e-02
+ -7.050114652750e-02
+ -4.535206654787e-02
+ -9.798607782523e-02
+ -2.770924506290e-02
+  1.965972575049e-01
+ -2.083617550045e-01
+  9.469625580143e-02
+ -7.152127114846e-02
+ -1.633879789435e-01
+  3.027444046071e-02
+ -5.306006665245e-02
+ -1.863823481968e-02
+ -5.237658984718e-02
+ -3.356488613861e-02
+  3.134077343229e-02
+  2.112716940934e-01
+ -8.920642121596e-02
+  8.090214862942e-02
+ -9.334513235368e-02
+  1.011217096489e-01
+  4.124370280137e-02
+ -1.496206355707e-02
+  1.240133628714e-01
+ -5.411757107122e-02
+ -1.595745400907e-01
+ -1.093935548573e-01
+ -1.755175447990e-01
+  1.043093026657e-01
+ -2.859980521074e-02
+  4.165774940174e-02
+ -6.469873801120e-02
+ -1.556444158949e-01
+ -2.638475100627e-02
+ -6.982365497406e-02
+ -1.133065165031e-01
+  1.734133139571e-02
+ -3.223387432698e-03
+ -1.015176714204e-02
+  9.064127921473e-02
+  1.439479134664e-02
+  1.652476919882e-01
+  3.507784444914e-02
+ -5.468806109001e-02
+ -2.248592686343e-01
+ -9.725667604002e-02
+ -1.885704392768e-01
+  2.129547564588e-02
+  2.202549843478e-02
+  2.649312951821e-01
+  6.606435160717e-02
+ -6.054199470423e-02
+  6.188683108669e-02
+  4.584156659575e-02
+ -1.136938584646e-01
+ -1.264819885178e-01
+ -2.060037456382e-01
+  9.390776441629e-02
+ -2.488701187627e-02
+  6.630386513873e-02
+ -9.779457455395e-02
+  4.966048503898e-03
+  2.003819440076e-01
+ -6.717794948689e-02
+  1.781164813280e-01
+ -1.070891014944e-01
+  8.980076226156e-03
+  3.375542403250e-02
+ -1.108480889614e-01
+  7.694350182127e-02
+ -1.428343093483e-01
+ -3.183160472088e-02
+  6.464868328000e-03
+ -3.982018536076e-02
+ -8.328288963065e-02
+ -6.018920889392e-02
+  6.450244955266e-02
+  7.193646034184e-02
+  9.481936301990e-02
+ -1.043741781448e-01
+ -2.003758955024e-02
+ -3.430062928656e-02
+  1.470799330762e-01
+ -1.240895599738e-01
+ -1.117728666490e-02
+  1.401516280603e-01
+  2.977321549431e-02
+  1.493289169054e-01
+ -3.526420456285e-02
+ -5.029466173575e-02
+  3.052986367561e-02
+ -7.057692875141e-02
+  6.315555712801e-02
+  5.507028234446e-02
+ -4.402602249998e-02
+ -2.807633414496e-02
+ -1.390062475719e-02
+  3.047929801542e-02
+ -9.774992258738e-02
+  2.665256848497e-02
+  1.724686762638e-02
+ -8.152899165471e-02
+ -6.878619127618e-02
+  4.309348767817e-02
+ -9.213667038656e-02
+  2.772827782864e-02
+ -9.778941232286e-02
+ -1.678288417503e-02
+ -1.788580431309e-02
+ -2.025119512850e-02
+ -9.095127487328e-03
+  1.124524611445e-01
+  6.729488724641e-02
+ -4.772017949240e-02
+  1.191264903889e-02
+  1.377250772387e-01
+ -5.357816825901e-02
+  4.230073067601e-02
+ -7.907535516665e-02
+  8.387432104932e-02
+ -3.752202028635e-02
+  1.085937443887e-01
+  4.425468222990e-02
+  8.359045805907e-02
+  1.260833728482e-01
+ -3.483001277338e-03
+ -1.064773608092e-02
+  1.062170748356e-02
+ -9.787528722274e-02
+  1.564000128173e-01
+ -9.217963707648e-02
+ -3.153066321495e-02
+ -6.441718102963e-02
+  3.179449035328e-02
+ -6.238432780846e-03
+  4.805239027936e-02
+ -8.261622061723e-02
+  6.023813241013e-02
+  8.000299045701e-02
+ -2.292639990192e-02
+ -6.902108757372e-03
+ -5.647514303898e-02
+  9.808088967513e-03
+ -2.493395815376e-02
+  1.006016532919e-01
+  2.603162336071e-02
+  3.049454168317e-02
+ -1.407944489531e-01
+ -6.467938636029e-02
+ -7.185913933474e-02
+  1.794853605392e-02
+ -1.713454471977e-02
+  4.983624222193e-02
+ -8.900633334155e-03
+ -1.959157554266e-01
+ -2.872776742651e-02
+ -4.283135275466e-02
+  7.066507546518e-02
+ -3.886170429593e-02
+  2.687443835205e-02
+  8.973586647096e-02
+ -9.734966573041e-02
+  1.036584335628e-01
+  8.267796965622e-02
+  1.527941551133e-01
+  1.511214559806e-02
+  1.849370415875e-02
+  5.311551707812e-02
+  7.132392215382e-02
+ -1.631645306413e-01
+  6.486303384808e-02
+ -8.446210059204e-02
+ -7.337713629165e-02
+  6.362969468438e-02
+ -1.547138634172e-01
+  9.065869739740e-03
+ -1.380537743607e-02
+ -1.252081618646e-01
+ -3.048417672443e-02
+ -9.519299343608e-02
+ -9.708332070713e-03
+  6.939555767728e-02
+ -5.810595624657e-02
+ -7.256966091959e-02
+  3.768969961943e-02
+ -9.397074733774e-02
+ -4.537180709600e-02
+ -2.029649951705e-02
+ -6.017610655010e-02
+  1.109120651508e-01
+  1.576479536171e-01
+ -9.510739160465e-02
+ -9.692922074530e-02
+ -2.631937441820e-02
+  3.334946754297e-02
+ -6.213425112159e-03
+ -1.428484054654e-01
+ -2.787252527537e-02
+  9.130641130579e-03
+ -2.471709036917e-02
+  1.676790727556e-02
+  3.224295270792e-02
+  3.744156693513e-02
+  1.892589249560e-01
+ -9.482753287411e-02
+ -2.863624664564e-02
+ -4.799623887102e-02
+ -1.343608007259e-01
+  1.622068642572e-01
+ -4.340775279043e-02
+ -8.649045108690e-02
+ -2.196883732849e-02
+ -1.321176927397e-01
+  1.501568365815e-01
+  1.273420403864e-01
+ -2.498973589883e-02
+  5.078059532084e-02
+  6.325185684250e-02
+ -6.188105961860e-02
+  2.092832690835e-02
+  6.385922480468e-03
+ -8.829528198671e-02
+  9.632252645120e-02
+ -2.031215478720e-01
+ -1.690802136317e-02
+  4.518793217182e-02
+ -6.073350323096e-02
+ -1.163698905935e-01
+  6.608680218250e-02
+ -1.290004324530e-02
+  6.148058135024e-02
+  1.006881576197e-01
+  9.797493789051e-02
+  1.234343454826e-01
+ -6.734308988449e-02
+ -1.457834727146e-02
+ -1.645232827757e-01
+  4.274731100575e-03
+ -1.399345480317e-01
+  5.108998069536e-02
+  9.426893049070e-03
+  1.622366180120e-01
+ -1.792098235145e-01
+ -2.191327176305e-01
+ -1.450820117326e-02
+ -2.005921286170e-02
+ -2.045954726418e-02
+  5.015405103757e-02
+  2.079487179199e-02
+  5.375012768733e-02
+  1.415898510406e-02
+  2.270580851709e-01
+  1.166332977861e-01
+ -2.399814259376e-02
+ -6.745330937817e-02
+ -1.842481603528e-02
+  1.602533346625e-01
+ -2.307317539027e-01
+ -1.054699106626e-01
+ -4.740617865618e-04
+ -3.815723232655e-02
+ -3.410814415182e-02
+  7.594666399730e-02
+  1.360523522959e-01
+ -9.936729164230e-02
+  1.043651046175e-01
+  8.330027690369e-02
+ -2.749549853430e-02
+  1.973477356585e-01
+ -4.293271253806e-02
+ -1.235804568067e-01
+ -1.828581705706e-01
+ -1.919719790056e-02
+ -2.456157477524e-01
+  1.669444787218e-02
+ -2.522009732363e-02
+  1.137142338661e-01
+  3.131601974565e-03
+ -7.729644722375e-02
+ -1.747816735318e-01
+  1.443766299088e-01
+  9.564480608385e-02
+ -2.676477579499e-02
+  6.795044399024e-02
+  7.419637735918e-02
+  1.537559541221e-01
+  7.671651739855e-02
+  1.403718222983e-01
+  1.132330726909e-01
+ -2.711955432482e-02
+  3.773224632190e-02
+  4.046676730001e-02
+ -5.333189337917e-03
+ -1.100741862282e-01
+  2.262232787147e-01
+ -1.885956404067e-01
+ -1.086522137663e-01
+  3.540805736524e-02
+ -9.146321807686e-02
+  1.059818467320e-01
+  4.027682082713e-02
+  6.310846595642e-02
+  4.443422597300e-02
+ -1.474049809497e-01
+  5.511845659171e-03
+ -2.938213798651e-02
+ -5.203783680157e-03
+ -7.945501809089e-02
+ -9.369107112948e-02
+  1.496414809507e-02
+ -4.996543356580e-03
+ -9.238695113835e-02
+ -1.241677525465e-01
+ -4.463659868303e-02
+ -7.702706233480e-02
+ -5.559565128661e-02
+  8.677677697400e-02
+  3.362163150835e-02
+  1.824169939031e-01
+  7.093026036615e-02
+  1.035665142475e-01
+  1.637932338684e-01
+  4.201663401464e-02
+  2.301966732743e-01
+ -8.532297046725e-02
+ -2.225465480489e-02
+ -6.289879446672e-02
+ -1.765465341024e-01
+  7.040968214699e-02
+ -3.458440226707e-02
+ -7.911420700289e-02
+  3.535730894792e-02
+ -3.974788459543e-02
+  1.078131258370e-01
+  8.489734416321e-02
+  3.090500365893e-02
+  2.469229366821e-02
+ -1.509600597402e-01
+  1.324607244754e-01
+  3.131302398391e-02
+ -1.851915499478e-01
+  1.641303034804e-01
+ -1.993314565816e-02
+ -6.019419576096e-02
+  9.776376410527e-02
+ -6.687241561000e-02
+  2.267899106450e-01
+ -1.317627418551e-02
+ -2.261681650317e-02
+  1.455118890673e-01
+  6.652906747484e-02
+ -2.588466250282e-01
+ -2.014322099345e-02
+ -6.589847552394e-02
+  1.237770156328e-01
+  5.989281538391e-02
+ -1.079899382697e-01
+  1.181121498161e-01
+ -1.337766319127e-01
+  4.434528684908e-02
+ -3.512114190313e-02
+ -9.150342303011e-02
+  1.596325719652e-01
+  1.776818115473e-02
+  2.122620931241e-03
+  2.055654236037e-02
+ -1.488180529899e-01
+ -3.117241069750e-02
+  8.957555191042e-02
+ -4.295729001847e-03
+  9.123679816830e-02
+  1.453425253043e-01
+ -7.556850523180e-03
+ -1.236381735300e-03
+  4.101941003991e-02
+ -1.103949012659e-01
+  7.713045746370e-02
+ -1.525617970875e-01
+  1.016764822279e-01
+ -2.690080883249e-01
+  1.375307994398e-01
+ -8.369471545917e-02
+  6.729882608208e-02
+  1.187036768327e-01
+  9.165238398314e-02
+  2.786068019728e-02
+  1.412119013467e-01
+ -5.570864828754e-02
+ -4.042629447830e-02
+ -9.712754425887e-02
+ -1.465164200023e-01
+  3.578529943596e-03
+ -3.134962587441e-02
+  5.847236759801e-02
+ -1.302302806156e-01
+  2.784176717875e-02
+ -7.563552290212e-02
+  7.867808996944e-02
+  4.056364590268e-02
+ -4.268618825059e-02
+  1.035332957451e-01
+  5.751889857335e-02
+ -6.063794660457e-02
+  1.904771653172e-02
+ -9.826913096304e-02
+  9.998889049815e-02
+  5.886600945364e-02
+  3.513307882571e-01
+ -6.973739997085e-02
+  2.386727090049e-01
+  1.061098847330e-01
+ -7.157334416259e-02
+ -6.504389550485e-02
+ -4.116696124515e-03
+ -1.646219587153e-01
+  4.256764394519e-02
+ -2.650179703481e-02
+ -3.805858488225e-02
+ -1.185979653003e-01
+ -4.813647640885e-02
+  5.761145829498e-03
+  1.474291525783e-01
+  8.585302737187e-03
+ -8.496004020946e-02
+ -8.664497342060e-02
+ -1.033519794996e-01
+  7.014432827373e-02
+  1.850291211130e-02
+ -8.198945825326e-02
+ -2.333008279903e-02
+  9.600198243147e-02
+ -4.232138957649e-02
+ -2.221520372784e-02
+  1.025649931464e-01
+ -9.684090953054e-02
+  8.475765755344e-02
+ -2.322090448310e-02
+ -1.773218056977e-01
+  1.251592086224e-01
+ -7.293628944814e-02
+  1.213880721411e-01
+  1.487214161950e-04
+  2.624352277295e-02
+  2.113297392528e-02
+  1.409145408187e-01
+ -9.474791830135e-02
+ -1.699875220212e-02
+  5.776137535341e-02
+  1.225060122263e-01
+ -1.266936140632e-01
+ -5.632520811031e-02
+  1.311922424320e-01
+  1.069546053967e-01
+  6.236088970071e-02
+  8.169587167309e-02
+  1.817276049884e-02
+  1.560408224360e-02
+  1.776033870910e-01
+ -1.164437439669e-01
+  9.034427212275e-02
+  5.617155641185e-02
+ -9.687584644663e-02
+ -2.129551713576e-01
+  8.371457196469e-02
+  9.540422908290e-02
+ -2.548356728678e-02
+ -5.361448231183e-02
+ -1.234615357703e-01
+ -4.002389455509e-02
+ -2.226574356387e-02
+  3.599273656030e-02
+  3.389685784260e-02
+  9.819193590833e-02
+ -5.398406224001e-02
+ -5.321839182834e-02
+  1.776614983700e-01
+  2.891715755403e-02
+ -1.072165585407e-01
+  1.606169127044e-02
+  4.156809758170e-02
+ -6.111735758557e-02
+  6.206822278513e-02
+ -9.778395284815e-02
+  1.791861417884e-01
+  3.324445775656e-02
+ -3.679880676349e-02
+  1.493795545365e-01
+ -3.691837328440e-02
+ -5.886516996778e-02
+  5.986311519136e-02
+  2.610244941345e-02
+  6.568241319938e-02
+ -3.986988553821e-02
+ -2.121728132717e-02
+ -1.862969000352e-01
+ -7.372834494080e-02
+  1.136258148269e-01
+  2.153198833659e-02
+ -3.433679048145e-03
+ -3.542153318221e-02
+ -8.246872226720e-04
+ -9.882806675862e-02
+  1.003887005702e-01
+  5.290842867507e-02
+ -5.384121964295e-02
+  6.052898122839e-02
+ -1.024894193100e-02
+ -7.856068935503e-02
+  5.066717858707e-02
+  5.574776306239e-02
+ -3.929396901665e-02
+  1.183509110751e-01
+ -4.469129140970e-02
+  6.993389849305e-02
+ -8.922427928170e-02
+ -5.800612183176e-02
+  3.961500028065e-02
+ -2.106609216539e-01
+ -9.263244141160e-02
+  5.092988925887e-02
+ -9.115562238590e-02
+ -2.957682320225e-02
+  1.013180337424e-01
+ -9.863001206157e-02
+  1.445113895732e-01
+ -1.212837242549e-01
+  5.977099713455e-02
+  1.506466520923e-01
+ -6.753645192609e-02
+ -8.370808318247e-02
+ -5.903871678468e-02
+ -1.331623120639e-01
+ -3.451491610160e-02
+  7.367977000913e-03
+  3.114728321886e-02
+ -1.108145708321e-01
+ -3.030720973973e-02
+  2.576862537169e-01
+ -3.179364858114e-02
+  7.404386631480e-02
+ -9.421463199248e-02
+  1.818781257880e-01
+  5.212868858382e-02
+ -2.544770385799e-02
+  1.517020516220e-02
+ -8.914783684856e-02
+ -3.800169472839e-02
+  8.562871804105e-02
+  1.780115800331e-01
+  5.298522783372e-03
+ -1.989481737271e-02
+  2.253417362598e-01
+  7.332994304503e-03
+  1.502406814593e-01
+  1.389746705782e-01
+ -1.680998149300e-02
+  5.733603986113e-02
+ -1.337483013644e-01
+  1.227859081047e-02
+ -1.074720304741e-02
+ -3.250661513253e-02
+  7.399348914122e-02
+  8.877723955297e-02
+ -1.047754518568e-01
+ -9.724340314751e-03
+  5.374566843763e-02
+ -8.323298280788e-02
+  4.296738471366e-02
+ -9.573839322614e-02
+  5.442785525013e-02
+ -9.343290729517e-02
+  5.051742677533e-02
+ -1.217300041131e-01
+ -4.930787383320e-02
+ -5.891056486558e-02
+ -1.135805436681e-01
+ -1.309323943781e-01
+ -9.007815249872e-02
+  1.284238517240e-02
+  1.338780897172e-01
+  8.660699609337e-02
+ -5.992347712059e-02
+  6.950002859655e-04
+ -3.480777720190e-02
+ -8.398947971744e-02
+  1.298362221730e-02
+  6.813317089056e-03
+ -1.164520708372e-01
+ -1.364580111351e-01
+ -6.659776423244e-02
+  6.703614049673e-03
+ -1.115550285083e-01
+  1.765891216002e-01
+ -2.653890779153e-02
+  4.832105542311e-02
+ -1.015486175063e-01
+ -2.753889599920e-02
+  1.906671482299e-01
+  5.234348171518e-02
+  4.402691794380e-03
+  1.179940552277e-01
+ -3.933889969323e-02
+  6.650744386313e-02
+  2.587487450959e-02
+  1.451326235550e-02
+ -1.662979106762e-02
+  1.013455829554e-01
+  8.800052775135e-02
+ -6.196748779563e-02
+  6.829695160131e-02
+  2.197495178384e-02
+  2.133416224994e-02
+  2.838080161365e-02
+  4.299769680800e-02
+  2.841532338983e-02
+ -2.316236431689e-01
+  1.134714471638e-01
+  1.260720691401e-01
+ -1.536278746361e-01
+  8.410242797767e-02
+ -1.992390012495e-02
+  7.000503365624e-02
+ -1.792200831347e-02
+ -8.529019573575e-02
+ -1.252535694237e-01
+  4.460795451365e-02
+ -1.012947319803e-02
+  1.139255675143e-01
+ -3.096861360375e-01
+  4.175317943511e-02
+ -1.474504647279e-01
+  7.714256823419e-02
+ -1.244859436950e-01
+  1.843465415962e-02
+  1.410299892390e-02
+ -1.879828550057e-02
+  3.975293654430e-02
+  6.225160218193e-02
+ -5.089944440276e-02
+ -9.936424073898e-03
+  1.405650648315e-01
+  1.364703116113e-01
+  4.247656795677e-02
+ -1.021291260325e-01
+  3.855996908996e-02
+  1.081360050216e-01
+  7.306259680413e-02
+  1.574692173487e-02
+ -2.206596682794e-02
+  5.294791702023e-03
+  4.292842346790e-02
+ -1.179343547444e-01
+ -2.212112078822e-02
+  6.701779844548e-03
+  4.207749892252e-02
+ -2.051039167945e-02
+ -8.674208863584e-02
+ -9.483984228699e-02
+  9.780692944912e-02
+  8.473440539013e-02
+ -3.089819573446e-02
+  8.998921106630e-02
+  2.368865785917e-02
+  1.142910444946e-02
+  4.725003003365e-02
+  1.490022114625e-01
+ -5.278854029125e-02
+ -3.742390100700e-02
+  1.058528473318e-02
+  4.156956155560e-02
+  7.097632621385e-02
+  1.007840144697e-01
+ -1.080272203593e-01
+  6.701764382856e-02
+ -5.565013321297e-02
+ -2.254294523516e-02
+  3.821120531538e-02
+  1.790070216407e-01
+  2.406395645032e-01
+  2.004139268999e-01
+ -1.091548253574e-02
+ -5.797391796904e-02
+ -9.734866911558e-03
+  1.535034568704e-01
+  7.495156713578e-03
+  1.303746858427e-01
+  1.204890580342e-01
+  4.152203987240e-02
+  1.064020506538e-01
+  1.245796619027e-01
+ -3.346012556654e-02
+ -6.285022240376e-02
+ -1.747745729333e-01
+ -7.049760683344e-02
+ -4.988172452100e-02
+  6.819896938750e-02
+  1.327330606960e-01
+  6.491938314567e-02
+ -1.216778646136e-01
+ -1.658878757048e-01
+ -2.935644164871e-02
+  5.163715772580e-02
+ -1.370726453921e-01
+  9.669456535620e-02
+  3.384925548235e-01
+ -1.043734484493e-01
+ -4.504335293831e-02
+  1.548412011244e-01
+ -8.233237052190e-02
+  2.103383937790e-01
+ -8.999494911343e-02
+  6.580708051391e-02
+  1.102656413098e-01
+ -6.684922710697e-02
+  1.372735249795e-01
+  1.571527383392e-02
+  4.317262459570e-03
+  5.752714176106e-02
+  2.028480572052e-02
+ -1.488005616104e-01
+  2.496441304779e-02
+ -1.893619008378e-02
+ -8.688219450634e-02
+ -1.520950133727e-02
+  2.026522106391e-01
+  1.032620940715e-01
+ -1.159050666624e-01
+  9.062846617477e-02
+  4.278440314973e-02
+  9.561157526194e-02
+ -6.185789731593e-02
+  7.155213604055e-02
+ -5.722730790305e-02
+  1.047685522696e-01
+  8.090686081510e-03
+  1.104170903809e-01
+  8.824089411201e-02
+ -5.694465711881e-02
+  5.971501411524e-02
+  1.465254361231e-01
+  4.426547092032e-02
+  7.963295728417e-02
+ -1.850046075926e-01
+  4.746632667953e-02
+  1.059626921696e-01
+  1.775546900105e-01
+  4.565253352150e-03
+ -1.221043226132e-01
+ -6.700427126469e-02
+  4.112475902381e-02
+  1.306369626616e-01
+  2.273766210154e-02
+  1.996718699965e-01
+ -6.836552604318e-02
+  1.344007866987e-01
+ -8.463746194573e-02
+  8.077476852272e-02
+ -7.890208874771e-02
+  1.590271094803e-01
+  2.813031085871e-01
+ -2.297843622366e-02
+  7.541934887389e-02
+  1.270866195179e-01
+  1.952668420002e-02
+  2.376685540846e-02
+ -2.503175376459e-01
+ -7.211383467535e-02
+ -5.451816898436e-02
+  8.027064089757e-02
+  8.019348166323e-03
+  1.003441566556e-02
+ -1.846064323125e-01
+  1.308172388868e-02
+  1.835212498073e-01
+ -1.751713720861e-02
+  2.126197161603e-01
+  1.188964465084e-02
+ -8.050259238165e-03
+  1.721081956275e-01
+  1.077604887760e-01
+  1.948375093617e-01
+ -1.398177233135e-01
+  1.061222847993e-01
+  2.947485733138e-02
+ -8.702309341758e-02
+  7.077830041886e-02
+ -5.645126778243e-02
+ -5.857508307235e-02
+  2.085332773715e-02
+ -8.914302963453e-02
+ -1.083193136730e-01
+ -9.496964520649e-03
+  1.917833704767e-01
+  5.833723614416e-03
+ -3.014157959061e-02
+  9.077419969827e-03
+ -2.094824263528e-03
+  5.049181822218e-02
+  5.943889975387e-02
+ -1.437819984737e-02
+ -3.823863625252e-02
+  6.308167002237e-02
+  1.530456995547e-01
+  1.360029997526e-01
+  6.010575155803e-03
+  4.600266889492e-02
+ -2.870389693637e-02
+ -1.443164084969e-01
+  9.458160055219e-02
+ -2.674097701405e-03
+ -9.337060916196e-02
+  5.314901612317e-02
+  6.441755686104e-02
+  5.505369786461e-02
+ -3.912647073885e-02
+ -1.538641767650e-01
+  1.662380441494e-01
+ -3.707220607473e-02
+  9.966534878890e-02
+  1.630560646386e-01
+ -2.401432340827e-01
+  6.616531452765e-02
+  1.274961746496e-01
+ -2.098416216219e-01
+ -6.189127177032e-02
+  1.537637214949e-01
+ -1.627575311513e-02
+ -2.075590539010e-02
+  6.376409256801e-02
+ -1.062910942926e-01
+  4.845486263346e-02
+  4.719256403897e-02
+  6.302631652041e-02
+  8.095042428878e-02
+ -7.672821871780e-02
+ -1.759775886327e-01
+ -9.188671552244e-02
+  6.843134502165e-02
+ -1.658804148856e-02
+  9.865872072035e-02
+ -1.676157258769e-01
+ -9.916011133769e-02
+ -6.311247837451e-02
+  1.022190174141e-01
+  1.391098355523e-01
+  1.791613339737e-01
+  1.635378578032e-01
+ -1.098767819610e-01
+  1.393473434955e-02
+  1.792381943213e-02
+  4.350315543867e-02
+  1.054435592192e-01
+ -1.122356446953e-01
+  1.097040397448e-01
+ -1.470302572957e-01
+ -2.897856581970e-03
+ -2.543536337061e-03
+  1.056640324556e-01
+  1.082050224606e-01
+ -2.974113765723e-02
+  2.242872999538e-02
+  4.019634958968e-02
+  7.311798536498e-02
+  1.272969869219e-01
+ -1.105056218517e-01
+  1.602881080445e-01
+  1.786818180011e-01
+ -1.509417444586e-02
+  2.085728899208e-02
+  6.620208025466e-03
+  1.118087712102e-01
+ -2.219658295910e-01
+  8.299763706788e-02
+ -7.666803111638e-02
+ -8.445136049950e-03
+ -1.747924504893e-02
+  1.101265458539e-01
+  2.195734640977e-01
+  5.222433493772e-02
+ -4.775457198218e-02
+  5.444007556086e-02
+ -5.896919364294e-02
+  3.166867836913e-02
+  1.888108687457e-02
+  5.130232494639e-02
+  6.908807831749e-03
+  1.212301468650e-01
+  3.403334577298e-02
+ -6.464016584717e-02
+ -7.534255921419e-02
+  1.560987049037e-01
+ -3.428929057228e-02
+  1.266817797564e-01
+  8.565337704726e-02
+  2.757649715262e-02
+  1.225196440553e-02
+  1.461780778883e-01
+  2.282784769205e-02
+ -6.134127795017e-02
+  3.530492071262e-02
+ -2.050846602222e-01
+  4.768234535128e-02
+ -7.345184033701e-02
+  1.149865292185e-01
+  1.051115096351e-01
+  3.795632636384e-02
+ -4.655335824358e-02
+  1.095927308270e-01
+  1.803551979981e-02
+ -1.588731332577e-01
+ -1.243990372353e-01
+ -4.457452023239e-02
+ -4.181843495889e-02
+ -4.122831546086e-02
+  6.560603604372e-02
+ -7.740526315983e-02
+  7.999454078102e-02
+  8.458698353612e-04
+ -2.592571843474e-02
+  1.571118385883e-02
+  8.492987796314e-02
+ -7.593705703658e-02
+ -2.304453983432e-02
+ -1.204114908716e-02
+  1.151129500548e-02
+ -1.357291206350e-01
+  1.382136833491e-01
+ -1.917932156070e-01
+  1.361504482616e-01
+  1.272985531325e-01
+  6.602400659253e-02
+ -7.419551626148e-02
+ -1.879873536524e-02
+ -8.466472204511e-04
+ -1.491126751461e-01
+  1.229029362176e-02
+  3.130279153635e-02
+  5.114572273527e-02
+  1.263389943924e-02
+  5.001958053811e-02
+  7.412948318032e-02
+  2.104931270208e-01
+ -1.771286100094e-01
+  2.297918591100e-01
+  7.694172720518e-02
+ -6.079696896838e-02
+ -1.053688185184e-01
+  1.335721407806e-01
+  5.432419542103e-03
+  1.252884060352e-01
+ -2.905262655236e-02
+ -4.972383455437e-02
+ -5.734531915485e-03
+  3.027736652735e-02
+ -5.866223471071e-02
+ -1.989405024398e-02
+  1.780893731574e-01
+ -1.893013192013e-01
+  1.680305777852e-01
+  7.561165121162e-02
+  2.445607565151e-01
+ -4.366680007408e-03
+ -5.093120526100e-02
+  1.653441730409e-01
+  2.645396099178e-03
+  5.929567290805e-02
+ -8.337107266542e-02
+ -1.720007445405e-02
+  3.735014631650e-02
+ -2.820410619324e-02
+ -9.099858654350e-02
+  9.275587899062e-02
+  9.799725528723e-02
+ -4.343629921612e-02
+ -1.200263463412e-02
+ -1.528941194138e-01
+  9.612016787888e-02
+ -1.055323086262e-01
+ -1.898706690629e-01
+  6.900713667319e-02
+  1.141216963457e-01
+  2.385277965517e-02
+ -1.135347692482e-01
+ -3.593320413811e-02
+ -2.090970017267e-01
+  1.098742740964e-01
+  6.992055769932e-02
+  6.176325580572e-02
+ -3.047750756636e-02
+  1.944635241533e-02
+  6.203091107243e-02
+ -2.391883681799e-01
+ -1.994438637944e-02
+  6.674514797764e-02
+ -1.038298760179e-01
+  2.390036987452e-02
+  4.654195122547e-03
+  2.290047573490e-01
+ -9.113808919740e-02
+  9.885121082954e-04
+  6.534296188043e-02
+  9.081155857138e-02
+ -3.243677434838e-02
+ -3.024376493669e-02
+  1.130074210814e-01
+ -8.575963806154e-02
+ -8.617982971954e-02
+  7.296456126080e-02
+  1.057667962274e-01
+  3.602247100739e-02
+  5.729444642829e-02
+  1.840341552067e-01
+  1.182132853361e-01
+  1.193763528890e-02
+ -1.206553922940e-01
+ -2.630471223230e-02
+ -1.316899686078e-02
+ -2.193076487094e-02
+ -1.218321423963e-01
+  1.625981487450e-02
+ -7.292408390033e-02
+ -1.238009557070e-01
+ -8.858181917770e-05
+ -1.157436712289e-01
+ -5.033516527667e-02
+  8.762495690815e-02
+ -4.614830205611e-02
+  5.664534212158e-03
+ -1.067687708877e-01
+  8.899553743189e-02
+ -1.085921074035e-01
+ -1.198461880903e-01
+ -2.083822536621e-01
+ -6.999644887354e-02
+  6.419664039895e-03
+ -5.434735270672e-02
+ -1.091820974312e-02
+  6.835766088275e-02
+ -7.074288192207e-02
+ -1.465271170220e-01
+ -4.724028733583e-02
+  1.877214510681e-01
+  4.288720241088e-02
+ -1.003230896839e-01
+  7.051620616073e-02
+  2.723147187423e-02
+  2.539067877743e-02
+  1.524472262172e-01
+ -1.337784244129e-01
+ -1.908498648195e-01
+  6.124131811218e-03
+  3.059838358825e-02
+ -2.256114125456e-02
+  8.539402440097e-03
+  7.902351796593e-02
+  3.625672539154e-02
+ -8.903032572049e-02
+ -1.958222269041e-01
+  3.752207643912e-02
+  1.801437373289e-01
+ -4.188667829137e-02
+  3.986118529117e-02
+ -1.153522572278e-01
+  1.318025840862e-01
+  1.175738609407e-01
+  2.288822380148e-02
+  5.397452241373e-02
+  1.521468998846e-01
+ -1.762419935436e-01
+  1.301799593872e-02
+ -8.109786911330e-02
+  5.456634412094e-03
+ -1.095072198549e-01
+  2.679886669109e-02
+ -2.898173691896e-01
+ -2.509105688526e-01
+ -6.656998185819e-03
+ -8.092436873933e-03
+ -1.418502945046e-02
+ -4.825996529107e-02
+ -2.888061424341e-02
+ -2.775796076971e-02
+  7.257561742435e-02
+  3.039108192016e-02
+  1.058671696923e-01
+ -6.780619674544e-02
+ -1.778619019774e-02
+ -4.501193707714e-02
+ -8.710019617461e-02
+  2.292472861505e-01
+  4.781794988037e-02
+  6.125357303790e-02
+  2.352728695499e-02
+ -3.477877839736e-02
+ -2.567704609835e-01
+  2.095054920912e-02
+  8.130732514116e-02
+  1.395352093324e-01
+ -4.531990039510e-02
+ -4.587990530771e-02
+ -6.279565583357e-03
+ -2.554214064071e-02
+ -4.063592640853e-02
+ -4.676079561763e-02
+ -1.439688272681e-01
+ -1.123604348146e-01
+ -5.493063004318e-02
+ -6.413301150571e-02
+ -2.663677764250e-02
+  1.416317835586e-01
+ -1.110489165298e-01
+ -5.011386929566e-02
+  3.710916557217e-02
+  7.311242183935e-02
+  1.546576844453e-01
+  1.330218005716e-01
+  2.467021660903e-01
+  4.726345660482e-02
+ -4.129354492421e-02
+  1.564167767125e-01
+ -7.911669766492e-02
+ -2.693711105608e-02
+  3.221926050471e-02
+  5.533644871800e-02
+ -2.867271064977e-03
+ -2.496852064671e-02
+  3.342177375574e-02
+  2.125000105547e-02
+ -1.350138324517e-01
+  1.165530879531e-01
+ -2.988383383413e-02
+ -9.583453870452e-02
+ -4.024363142869e-02
+  1.039352995837e-01
+ -2.199094396729e-03
+  5.656024599365e-02
+  3.729164906588e-02
+  6.823070731579e-02
+ -1.736542660122e-01
+  1.030904809256e-01
+ -5.904418103370e-02
+ -2.519531332244e-02
+  3.790684912699e-02
+ -7.887192261097e-04
+  1.976618321980e-01
+  3.308301522971e-03
+  2.910031790142e-02
+ -1.628706328169e-01
+ -8.313081999011e-02
+ -9.935027754790e-02
+ -1.415883461936e-01
+  1.858794192683e-01
+ -1.465458090152e-01
+ -4.140812955764e-02
+  2.959876082418e-02
+ -1.354539130558e-01
+ -1.547250855165e-02
+ -3.671179089594e-02
+  6.279036065245e-02
+  1.487960990129e-02
+  3.716533102039e-03
+ -1.476305194607e-01
+ -2.071933110897e-01
+  1.983476712976e-01
+ -1.489748237169e-01
+  1.400013497239e-02
+ -3.098105314126e-02
+  9.326072508647e-02
+  8.488052692702e-02
+  1.434485852024e-01
+ -1.106516507377e-01
+  5.884555305626e-02
+ -1.270459936215e-02
+ -1.663481200201e-01
+  1.997470424565e-02
+  1.882992080133e-01
+ -2.172363378647e-02
+  1.201140161853e-01
+  1.172319005724e-01
+ -2.395866355825e-01
+ -1.058800222755e-01
+ -1.282722383817e-01
+ -3.631675331316e-02
+ -8.793587741551e-02
+ -1.016823298582e-01
+ -7.118284071093e-02
+  1.344494203198e-01
+ -8.014604245837e-02
+  1.607646025554e-01
+ -1.165903366614e-01
+  1.388221491793e-01
+  2.965770475121e-02
+  1.391759470089e-01
+ -7.546856271596e-02
+  5.906810706830e-02
+ -1.338893216448e-01
+  3.898339798866e-02
+ -2.988563761100e-02
+ -9.601355826593e-02
+  3.499047290260e-02
+  5.505804177131e-02
+ -2.202615348591e-01
+ -8.199683653463e-02
+  4.343217584600e-02
+  2.291399305591e-01
+  4.624219529743e-02
+  2.020316718267e-01
+ -3.244642793308e-02
+  3.378258651032e-02
+ -4.492972218794e-02
+  8.245327978472e-02
+  6.580757783930e-02
+  4.029679288552e-03
+  1.060724864011e-01
+ -9.340603235001e-03
+  5.452366173728e-02
+  9.498602335327e-02
+  2.193148323283e-01
+ -6.086663814698e-02
+ -1.232158628640e-01
+  1.688177612836e-02
+ -1.807761045456e-01
+ -5.945939321116e-02
+ -1.186054473014e-01
+ -1.587475922699e-01
+ -7.998446913672e-02
+ -5.134668127086e-02
+ -1.325209570804e-01
+ -1.458439455300e-01
+ -2.523961181789e-01
+ -6.413506204843e-02
+  1.213672609233e-01
+  2.648460361150e-02
+ -9.359897233921e-02
+ -7.918249199559e-03
+  7.929023247499e-03
+ -5.857688854687e-02
+  7.482300338772e-02
+  1.134058993218e-01
+ -5.542343260437e-02
+  3.895093086055e-02
+ -5.018151394609e-02
+ -1.175137794130e-01
+ -1.504961987250e-01
+  2.316974687966e-02
+ -4.229952542067e-02
+  2.558728551350e-02
+  2.293527996800e-01
+  8.916038155625e-02
+  2.538311000925e-01
+  5.226115498394e-02
+ -1.107224753091e-01
+  1.106674662131e-01
+ -2.740185406058e-02
+ -4.790022986857e-02
+ -1.110228842087e-01
+  1.548903894456e-01
+ -1.297599493635e-01
+  1.487287281332e-01
+ -1.147290211681e-01
+  7.670079232562e-02
+  1.861193291549e-01
+  5.270530599504e-02
+ -1.647304962487e-01
+ -3.838736958534e-02
+  4.957235069742e-02
+  9.973287184332e-02
+ -3.150722066608e-02
+ -1.641365966475e-01
+ -7.624441970889e-02
+  5.687730876246e-02
+ -4.599817507765e-02
+ -9.496021828510e-02
+  1.653059409370e-01
+ -1.946580539478e-02
+ -1.555338961777e-01
+  3.046692185766e-02
+  1.817304040183e-01
+  9.619401499443e-03
+ -1.768353447733e-02
+ -5.702990761360e-02
+ -3.872553986849e-02
+  1.609723494991e-01
+ -1.050471196530e-01
+ -1.295255471572e-01
+ -4.612645982346e-04
+ -1.524169336294e-02
+  1.245160211371e-01
+ -1.761730507847e-02
+  8.271049311456e-04
+  1.555118913877e-01
+  2.138020344210e-01
+ -6.548845209176e-02
+ -3.362533404573e-02
+ -8.593157747831e-02
+ -5.163625729307e-02
+  1.193515001799e-01
+ -1.007868722363e-01
+  1.415247920016e-02
+ -1.896379652276e-01
+  9.377566406792e-02
+ -4.544863045521e-02
+ -1.361272312071e-01
+  3.921146612583e-02
+  8.490779993297e-02
+ -4.987520494172e-03
+ -1.634926821862e-02
+ -3.851628589485e-02
+ -2.880933054684e-02
+ -2.447668856786e-02
+ -4.194787728035e-02
+  6.980953386987e-02
+ -9.485736044869e-02
+ -9.575904504604e-02
+ -9.118464894479e-02
+ -6.563551708055e-02
+  1.232769352702e-01
+  6.399043513535e-02
+  8.359411669231e-02
+  5.767195722197e-02
+  8.530343795355e-02
+ -8.738521847102e-02
+ -1.022730028221e-01
+ -5.501646665468e-03
+  5.706904743170e-02
+  8.762205647248e-02
+  1.290151182897e-01
+ -9.867169359889e-03
+ -2.675488492301e-02
+ -1.454769158626e-02
+  1.757600452222e-02
+  2.414243328841e-01
+  1.408684387268e-01
+ -1.424416041513e-01
+  6.132724808974e-02
+  2.274661044047e-02
+ -3.244163805995e-02
+ -6.146035839187e-02
+ -9.925935682108e-03
+ -5.542998996041e-02
+ -8.935239942430e-02
+  5.712326380813e-02
+ -5.197307342168e-02
+ -1.151330033411e-02
+  4.730169536616e-02
+  3.902326431405e-02
+  7.574316957360e-02
+  3.700984015395e-02
+  2.159265640367e-02
+ -1.749901811120e-01
+  5.615169865837e-02
+  3.014952552770e-02
+ -7.731260921570e-02
+  5.599207853980e-03
+  1.645424171621e-01
+ -9.154378617583e-02
+  3.894052153378e-02
+  1.571731567955e-02
+ -5.389850205840e-02
+  2.308150304614e-02
+  1.625042827454e-01
+ -7.572792196912e-02
+  5.563377581394e-02
+  1.279162181654e-01
+ -4.905020743220e-02
+ -1.021895507033e-01
+ -1.513167489354e-01
+ -1.428453364506e-01
+ -1.309485547244e-01
+  6.679208135233e-02
+ -2.400009583157e-02
+ -1.088259777286e-02
+  6.572685105025e-02
+  2.434423754249e-02
+ -6.610481834493e-02
+  1.659828960498e-01
+ -3.253090630189e-03
+  8.390401389255e-02
+ -1.834706466964e-01
+  1.356625727907e-02
+ -9.515335450757e-02
+ -7.927154891674e-02
+  1.544493571651e-01
+  4.241549967349e-02
+  5.603015337835e-02
+ -6.645064426700e-02
+ -5.937337296189e-02
+ -8.290463801539e-03
+  2.372863401836e-01
+  1.105390237268e-01
+  5.476187887438e-02
+ -4.061601618848e-02
+  1.634615942258e-01
+  1.882943492436e-01
+ -9.717852254437e-04
+ -2.200071889807e-01
+  3.374099610959e-02
+  1.449308795739e-01
+  1.309361065862e-01
+  7.130046286492e-02
+  2.447224242851e-04
+  1.294508923604e-01
+  6.941789979498e-02
+  1.774591864004e-02
+  3.307652420341e-02
+  1.157973628987e-01
+  3.951750932947e-02
+ -1.405529074906e-02
+ -1.179268575228e-02
+ -7.788274283510e-03
+ -5.816969629202e-03
+ -1.270114881832e-01
+ -1.062927139572e-01
+ -1.096966199176e-01
+ -9.534562996879e-02
+  1.466855774133e-01
+  4.530054763465e-02
+ -3.369478893049e-02
+  3.415515001121e-02
+  1.211458404296e-01
+ -1.785701978795e-01
+ -1.025160407216e-01
+  7.630060882644e-03
+  1.299902316546e-01
+  8.274103225611e-02
+  1.196148837145e-01
+  6.636134864993e-02
+  9.313919466524e-03
+  4.169826068241e-02
+  6.165480890573e-02
+  2.064159812759e-02
+  2.988550254330e-02
+  2.689819481728e-02
+ -5.275975686864e-02
+ -9.331326839190e-02
+ -1.318288389915e-01
+  4.708500308818e-02
+ -6.250857739627e-02
+  2.232178082647e-01
+ -3.189424837280e-02
+  1.089115682453e-01
+ -1.860379505119e-01
+ -1.308446608581e-01
+ -5.536051368511e-02
+  6.391521397074e-02
+  5.765475628962e-02
+  2.302886587817e-01
+  1.109525237654e-01
+  2.145348450119e-01
+  1.134424485435e-01
+  2.825310082157e-02
+  3.645676480436e-02
+ -5.264049324130e-02
+ -1.926462002040e-01
+ -1.172910745625e-02
+  4.170273759812e-02
+ -1.211095439747e-01
+  1.072640667858e-01
+  5.258465074844e-02
+  3.059399695000e-02
+  5.297738665964e-02
+ -1.153781799820e-01
+ -1.524864454299e-02
+ -3.943210008939e-02
+  1.123866872220e-01
+ -5.574791763760e-02
+ -5.836893232467e-02
+  1.055044510290e-01
+ -5.601130601048e-02
+  8.777743816584e-02
+ -1.373146008530e-01
+  3.318288784376e-02
+ -5.244095706627e-02
+  1.990389144900e-02
+ -6.506513533585e-04
+ -9.881708125717e-03
+ -1.755721334201e-01
+  1.070818895253e-01
+  1.196107553364e-01
+ -1.082246460161e-01
+  1.032369158054e-01
+  9.548438118643e-02
+  9.224887129898e-02
+ -1.047367753900e-01
+  8.644421763496e-02
+  2.090962498501e-03
+  2.323899446935e-02
+ -1.426904768512e-01
+ -6.608755096121e-02
+  3.183084977503e-02
+ -5.871562845649e-02
+  2.442599988974e-02
+ -8.407454194785e-02
+ -1.134970082118e-01
+ -4.561220709579e-03
+  9.619691768503e-02
+ -1.307317542799e-01
+  4.324094758908e-02
+ -5.993628703718e-02
+ -9.299766298669e-02
+  1.277617883483e-01
+  1.235927254924e-01
+  6.288451482229e-02
+ -1.164667253259e-01
+ -2.322373263090e-02
+  6.511411090294e-02
+  6.389744713683e-03
+  4.476690816586e-02
+  3.005198781688e-02
+ -2.272654137777e-01
+ -1.596944093663e-01
+ -1.118793096989e-01
+ -1.713626677759e-02
+  1.622238062646e-01
+ -7.690606967334e-02
+ -2.865890078981e-02
+  1.637939512629e-01
+ -1.127481204932e-01
+  6.631186218683e-03
+ -4.231597331020e-02
+ -4.202709500860e-02
+ -3.516427521172e-02
+ -1.708043220314e-01
+  1.986898705271e-01
+ -1.208055657508e-01
+ -8.878104364999e-02
+  8.721352222331e-02
+ -1.025156357488e-01
+ -5.144184913618e-02
+  1.518211519257e-01
+  1.006986506505e-01
+ -1.546440606196e-01
+  2.339767045837e-01
+  3.872367769905e-02
+  2.563550851438e-02
+ -8.100428686668e-02
+ -7.409722342727e-02
+  1.233874951933e-01
+ -8.610602459808e-02
+  8.477615652818e-02
+ -6.193884752703e-02
+ -8.819987505283e-02
+ -4.551956010472e-02
+ -1.062129204632e-01
+ -2.583279792972e-01
+  1.797980728565e-01
+  3.019553975564e-02
+  5.633709212417e-02
+ -1.484706800903e-01
+  6.457082426061e-03
+  6.960194003476e-02
+ -2.118444299833e-01
+  1.401585647258e-01
+  1.304114245197e-01
+ -9.812061714273e-02
+  4.057861952193e-02
+  1.233977956280e-01
+  5.715613076958e-02
+ -2.071875456198e-01
+ -2.813572294486e-02
+ -1.128366961626e-04
+  6.732924452834e-02
+ -3.415301621771e-02
+  1.909830988437e-02
+  2.797545581053e-01
+ -1.747877038390e-02
+  4.824905869748e-02
+ -8.232770715593e-02
+ -7.659462975931e-02
+  9.244279384990e-02
+ -4.636105777106e-02
+ -1.433502338959e-01
+ -4.416736178694e-02
+  1.036556692261e-01
+  1.544987910867e-02
+  1.707051947667e-01
+ -7.316256960883e-02
+ -4.529036148168e-02
+ -1.163871424162e-01
+  1.611576439615e-01
+  2.291868362034e-01
+  6.786547914669e-02
+ -5.135190164162e-02
+ -7.992642249325e-02
+ -1.376763258180e-02
+ -5.637531835684e-02
+ -1.193346817695e-02
+ -1.877786490668e-01
+ -1.628588013815e-02
+  2.921920005085e-02
+ -1.168357878567e-01
+  9.137875538517e-02
+  2.510401262281e-02
+  3.858913310194e-02
+ -1.591469801826e-02
+ -4.961009456484e-02
+  1.163115395797e-01
+  7.065649699170e-02
+  7.399181029442e-02
+  1.175507558218e-01
+ -4.543534177192e-02
+ -7.911787858544e-02
+  1.038523039634e-01
+  1.320272504035e-01
+ -1.346984746523e-01
+ -1.236837694010e-02
+ -1.627675588314e-01
+ -4.985113555422e-02
+  1.564505909182e-01
+ -1.150164591386e-02
+  1.157831998537e-01
+ -1.577893126412e-01
+ -2.783428817033e-02
+  1.975544713419e-01
+ -1.271011362292e-01
+  5.005104641389e-02
+ -7.869097397658e-02
+  1.139994627429e-01
+ -2.961106757837e-02
+  2.520503548649e-02
+ -1.687113806571e-01
+  2.331623451394e-02
+ -4.075053520932e-02
+ -1.709238272393e-01
+  1.326107089290e-02
+  1.028689486039e-01
+ -5.047980634994e-02
+  1.402777182146e-01
+  2.069539095527e-01
+  7.841564736544e-02
+ -1.698725194891e-01
+  4.735098247407e-02
+ -1.788285199663e-01
+  1.820864251391e-01
+  2.164325229460e-01
+  1.502848894917e-01
+  1.391911528408e-01
+  9.663372221707e-02
+  3.810820850191e-02
+ -7.019050121325e-02
+ -6.475172933963e-02
+  7.670545754960e-02
+ -1.322138180351e-01
+ -7.594394644270e-02
+ -6.361630497185e-02
+ -7.563948164411e-02
+  6.781652059736e-02
+ -1.978189450517e-02
+  1.021514066574e-01
+ -1.458969032421e-01
+  5.596839368126e-02
+  1.530994781688e-01
+ -1.365179497279e-03
+  6.490507427132e-02
+  8.332177959305e-02
+ -1.799810493743e-02
+  1.500806125094e-02
+ -5.526884912522e-02
+ -1.026196096871e-02
+ -7.890874934370e-02
+  2.534255139947e-01
+ -5.069282963858e-02
+  2.490330258074e-02
+ -4.818607399368e-02
+ -2.777858570996e-03
+  2.939093506237e-01
+ -9.712617769175e-02
+  3.332727667840e-02
+  1.026198282540e-01
+  6.333439882633e-02
+  6.784909595779e-02
+  1.760744709188e-02
+ -5.594780212567e-02
+  6.783883221213e-03
+  6.610727960715e-03
+ -2.717550112249e-02
+ -1.679514190368e-01
+ -1.926157920427e-01
+  9.905336750225e-03
+  1.186603507434e-01
+ -7.325227208668e-02
+ -1.625420658001e-01
+ -1.495484639959e-01
+ -7.122294524596e-02
+ -7.071573721051e-02
+ -1.398852176733e-01
+  6.106653643192e-02
+ -1.389694760186e-01
+  8.592736886044e-02
+  9.596883982178e-02
+  2.837795663989e-02
+  2.440416139602e-01
+  6.665045959576e-04
+ -1.493142541140e-01
+ -2.983883397065e-02
+ -2.543477702723e-03
+ -1.027755293140e-01
+ -5.325002821999e-02
+  4.073982071467e-02
+ -5.122754903252e-03
+  1.761400299148e-01
+  2.021537852412e-01
+ -3.210435295254e-02
+ -1.068365509712e-01
+  6.715499503643e-03
+  2.758626462534e-02
+  3.463762661174e-03
+ -7.950446238171e-02
+  3.979250443018e-02
+ -8.365221666428e-02
+ -1.467905869693e-02
+ -6.279988787118e-02
+ -1.561181971349e-01
+ -1.765218802412e-01
+ -1.710052607106e-01
+  2.830186440048e-02
+  2.524905395150e-02
+ -1.477263102001e-02
+  2.449748924245e-02
+  9.368881047020e-03
+ -1.742214582353e-02
+  2.031329814137e-01
+ -8.211092633584e-03
+ -1.104181991422e-01
+ -5.144572303880e-02
+  1.411605311079e-01
+  5.304935035998e-02
+ -2.048964647801e-01
+  1.188202715356e-01
+ -6.334274837849e-02
+  1.852910219229e-01
+ -1.063691515688e-01
+ -4.011940196181e-03
+ -6.966512726533e-02
+ -8.961972466926e-02
+  3.188502943381e-03
+  1.479672932930e-01
+ -3.998114295671e-04
+  1.374482999054e-01
+  5.329485431982e-02
+  2.413061375298e-02
+  6.234365448086e-02
+ -1.632694149920e-02
+ -1.108789936094e-01
+  1.379181939506e-02
+  3.712202696270e-03
+ -2.598075342432e-02
+ -1.338343728052e-01
+  2.255466712343e-02
+  1.482057707103e-01
+  4.666796421677e-03
+  4.329935796221e-02
+ -1.109512349179e-01
+  4.959481804354e-02
+  1.083797088305e-01
+  1.478222583486e-02
+  1.268677308947e-01
+  1.548371654460e-01
+ -6.968599565873e-02
+  6.727110481938e-02
+  7.289756748619e-02
+ -4.652000485937e-02
+  4.712189418938e-03
+ -1.272092104782e-02
+  1.434598959568e-01
+ -9.390530265093e-02
+  1.629980615055e-01
+ -1.617645852631e-01
+  6.399780483270e-02
+  8.831331078532e-03
+  5.185264710370e-03
+  3.129993860708e-02
+ -8.301293543005e-02
+ -1.284307419846e-01
+ -3.832741587684e-02
+  6.218197132240e-02
+ -1.805416772168e-01
+ -7.574459344107e-02
+ -1.182852252123e-01
+  1.023501717216e-01
+  4.203168558027e-02
+ -2.192532254393e-02
+  8.798431129190e-02
+  6.195991378217e-03
+ -3.853847533381e-02
+ -2.032457815329e-02
+  1.582256530238e-01
+  1.020317337171e-01
+ -7.227006632394e-02
+ -3.663614174793e-02
+  8.402851722171e-02
+  8.723058400801e-02
+  4.573833654593e-02
+  1.596456264370e-01
+ -5.496776931154e-02
+  8.862592948090e-02
+ -9.902783046139e-02
+  6.519615026423e-02
+  3.882214263857e-02
+  1.180817797158e-01
+ -1.104964013265e-02
+  9.207201625274e-03
+  5.250016530150e-02
+  7.778950640791e-02
+ -6.913829576236e-02
+  4.391275328393e-03
+ -3.759891372579e-02
+ -4.321977269349e-02
+  3.112310246579e-02
+ -5.604516691481e-02
+ -1.555276260004e-01
+ -5.711895928886e-04
+ -5.692406375165e-02
+  9.301854352723e-02
+ -1.433682629302e-02
+  4.140421247954e-02
+  6.208442735917e-02
+ -4.486012792157e-02
+ -1.444110689096e-02
+  1.157704441156e-02
+  8.576264343181e-02
+ -7.356012928179e-04
+  1.021411669376e-02
+  4.468923093203e-02
+  1.559062683663e-01
+ -7.765810355845e-02
+ -3.433906873107e-02
+ -8.991639174382e-02
+  1.002435252852e-01
+ -3.433091345287e-02
+  1.504045479024e-01
+  6.913627728227e-02
+  7.469373801620e-03
+ -1.935106699757e-01
+  2.319157781782e-02
+ -7.640201594731e-02
+ -7.170433228881e-02
+  1.101869980568e-01
+ -3.012766112298e-02
+  2.477849994347e-02
+ -3.743124914219e-02
+  1.325210065486e-01
+ -7.917988648084e-02
+  1.398907171016e-01
+  3.202252299486e-02
+  5.452566768642e-02
+  7.174415950018e-02
+ -4.645230752457e-02
+  4.011190372263e-03
+  1.170894679419e-01
+ -9.102637357728e-02
+ -1.024225312955e-02
+ -7.376894664240e-03
+ -1.417485431042e-01
+ -3.945559363621e-02
+  3.055165495926e-01
+  8.500569018110e-03
+ -8.139523144323e-02
+  1.711120309245e-02
+  1.167235396454e-01
+ -6.843985755875e-02
+  1.340354166553e-01
+  1.166355946718e-01
+ -1.375546532480e-01
+ -5.896088947045e-02
+  7.051794494576e-02
+  5.092584012110e-02
+  2.268476647933e-01
+  5.287198808218e-02
+ -4.652929468985e-02
+ -8.641011140996e-02
+  1.916829597433e-02
+ -2.106572044233e-02
+  9.736256120990e-02
+ -1.501936196257e-02
+  3.082489317654e-02
+  4.114735878241e-03
+ -1.749304850037e-01
+  4.870074539092e-02
+ -1.048160440082e-01
+  9.151291642667e-02
+  2.067820011060e-01
+ -1.046696419235e-01
+ -1.057585835991e-01
+ -2.267817593452e-01
+ -1.626948430100e-01
+ -1.891252735828e-01
+  8.168721412941e-04
+ -1.329058746868e-01
+  5.189801252801e-02
+  8.177504673818e-02
+  4.527779969797e-02
+  4.290971995202e-02
+ -1.144898617997e-01
+  1.113492955940e-01
+ -3.703572833197e-03
+ -7.243102271951e-02
+ -3.091395855330e-02
+ -1.072490734161e-01
+  5.112673936458e-02
+  1.350525798693e-01
+ -4.842628331898e-02
+ -5.351576617100e-02
+  6.781387526623e-02
+ -9.088679768356e-02
+  2.331182101694e-02
+ -8.092168624195e-02
+  5.524798681144e-03
+  5.515264338861e-02
+ -1.725350604196e-01
+ -2.216443057845e-02
+ -1.290635264147e-01
+ -3.618272885340e-02
+  4.453149922600e-03
+  1.973080663315e-02
+ -1.179063940891e-01
+  9.710511052946e-02
+ -3.546740561146e-02
+ -4.172324650891e-03
+ -1.680401478240e-01
+  1.667645973558e-01
+ -4.791713333467e-02
+ -1.136982986658e-01
+  8.580668850343e-02
+ -8.658914651359e-02
+  9.523611205592e-02
+ -9.594873503820e-02
+  1.140398720649e-01
+ -4.733044607714e-02
+ -5.695298411307e-02
+  1.122087693915e-01
+ -8.471776545627e-02
+ -3.905009526161e-02
+ -9.319958961474e-02
+ -5.090643522228e-02
+ -1.330438029639e-02
+ -1.279737981065e-01
+  8.894812453644e-02
+  9.720727351267e-02
+  2.313831119145e-02
+  1.907258044144e-02
+  3.065982394960e-02
+  9.036649511994e-02
+ -3.570033166196e-02
+  6.835389828587e-02
+  1.750749633444e-02
+  1.920544367259e-01
+  7.388125767988e-02
+  5.437932916138e-02
+ -1.753390385421e-02
+  1.242961065966e-01
+  2.471020534962e-01
+  1.469229622842e-01
+ -9.360873670447e-02
+  2.188359783677e-02
+  7.843891139659e-02
+  4.642503744047e-02
+ -6.261324773088e-02
+ -6.995965494724e-02
+ -5.664446646041e-02
+  1.113034697502e-01
+ -5.940619747352e-02
+ -9.689678799849e-02
+ -2.308637163788e-01
+  6.958189319234e-02
+ -1.083366827349e-01
+ -5.237866416336e-02
+ -7.813617617898e-02
+  2.802182777042e-03
+  6.977128266475e-02
+ -1.170126167920e-02
+ -1.084259695131e-02
+ -2.275626889983e-01
+  5.453631401545e-02
+ -1.690675684876e-01
+ -4.998664188411e-02
+  4.399309744998e-04
+ -3.680263469902e-02
+ -7.422469053782e-02
+ -2.039851849842e-02
+  5.567495844619e-02
+  1.342156634840e-01
+  1.092940108034e-02
+  2.297789219172e-01
+ -5.719713899504e-02
+  2.286073724661e-01
+ -5.198619279546e-02
+ -7.351443297404e-03
+ -1.020442716219e-01
+ -7.097720461110e-02
+  7.073742779336e-02
+ -1.036558535592e-01
+ -1.948129958506e-01
+ -3.579484722778e-01
+ -1.766531017984e-02
+  1.195912533485e-01
+ -7.902630458726e-02
+ -1.859208312583e-03
+ -5.453000386751e-02
+  6.041408528581e-02
+  1.257572304694e-01
+ -7.829898984404e-02
+ -3.528904669367e-02
+ -1.165923569539e-01
+  1.524329417577e-01
+  1.138804713123e-01
+ -4.825218233691e-02
+  1.676169556630e-01
+ -2.083088196214e-02
+ -4.727834921869e-02
+ -3.861645358380e-02
+  5.464612380058e-02
+ -4.454790570762e-02
+  1.736517980661e-01
+ -1.406603041377e-01
+  3.431305422029e-02
+  5.429418092764e-02
+ -1.447390669909e-01
+ -1.351129029943e-01
+ -1.032995261552e-01
+  1.172583016991e-01
+ -1.945166708501e-01
+  6.380949057087e-02
+  1.245858316269e-01
+  4.696959278674e-02
+ -3.742373823432e-02
+ -4.259186598503e-02
+ -5.112428265408e-02
+  9.343238990219e-02
+ -1.402904747401e-02
+  6.749290364197e-02
+ -1.803432911734e-02
+  1.166707647555e-01
+  2.827005047247e-02
+  1.224467236100e-01
+  2.569884819263e-02
+ -5.561986606039e-02
+ -1.535313787463e-01
+ -1.705669903403e-01
+  2.652490004969e-02
+ -1.759586277927e-02
+  1.328167021126e-01
+  1.224664993230e-02
+  1.558878672374e-01
+ -7.924896021823e-02
+ -1.295932705085e-01
+  1.027075656579e-01
+  3.558441529444e-02
+  2.541041839248e-02
+  7.799035061111e-02
+ -1.470804343881e-01
+  1.445823253798e-01
+  5.714546316074e-02
+ -7.526648209463e-02
+ -1.491860735473e-01
+ -1.332983028081e-01
+  2.153995608752e-02
+ -6.142874346385e-02
+ -1.154609475561e-02
+ -1.092737545412e-02
+ -8.620294420850e-02
+  1.039439698354e-01
+  4.092388634728e-02
+  8.072733195614e-02
+ -1.461392131081e-01
+  5.885518364426e-02
+  1.640545893281e-01
+  1.076867802275e-01
+ -7.070553005802e-02
+ -1.483959090100e-01
+ -6.740211364832e-02
+ -3.415279411871e-03
+ -6.495138815252e-02
+ -9.327287101129e-03
+  9.204488733393e-02
+  9.966066993039e-02
+  1.007253539239e-01
+ -1.444915974036e-01
+ -3.322088282759e-02
+ -1.420782359380e-01
+ -7.005596500796e-02
+ -5.752534482353e-02
+ -3.112186048884e-02
+  3.295856717725e-02
+ -8.890029647761e-02
+ -5.211920966609e-02
+ -1.488678781397e-02
+  4.349709638038e-02
+ -4.996678009825e-02
+ -1.281423086290e-02
+ -4.950168337640e-02
+  1.306875075266e-01
+ -1.230911129318e-01
+  1.215714492262e-01
+ -1.152526759175e-01
+  3.005853620311e-02
+ -7.369673245328e-02
+  3.290568695972e-04
+  3.885988955954e-03
+  3.894885401988e-02
+ -2.804804427456e-03
+ -5.649316623487e-02
+  2.003670278345e-01
+  5.240877012552e-02
+ -1.249872273310e-01
+ -3.610986122521e-02
+  1.639126190105e-01
+ -3.035965430087e-02
+  2.851662500085e-02
+  2.760541509863e-02
+ -1.279227289269e-01
+  6.053995817228e-02
+ -8.462694734103e-02
+ -8.110959144066e-02
+ -1.092419506892e-01
+ -1.033024764573e-01
+  1.110438397365e-01
+ -1.889537158916e-01
+  2.059315004336e-02
+ -7.741713039910e-02
+  1.746576989625e-02
+  3.179930900893e-01
+ -6.578548289474e-03
+ -2.034842260568e-02
+ -1.510477256790e-01
+ -8.282674141354e-02
+ -9.542412322131e-02
+  2.003129043598e-01
+ -2.150715489882e-02
+  9.242797975896e-03
+  1.572905135645e-01
+ -1.958095641353e-01
+  1.410558920861e-01
+  3.334515093505e-02
+ -9.911528205840e-02
+ -4.159509600580e-02
+ -8.630426290776e-02
+ -5.604070115025e-03
+ -7.763760243934e-02
+  2.992077262913e-02
+ -1.231132101858e-01
+ -2.094665253814e-02
+ -2.296878357229e-02
+ -2.115692436790e-02
+  1.234384494449e-01
+  8.981543257031e-02
+  2.801454519409e-02
+  2.092911342262e-02
+ -3.157280932790e-02
+ -5.020175956870e-02
+  4.936955563266e-02
+ -6.297700655277e-02
+  2.578633765302e-02
+  9.367665602476e-02
+ -3.841067408123e-03
+ -5.993397199398e-02
+  1.765525222044e-01
+  2.065523690749e-02
+ -8.593115789036e-02
+ -4.283892713205e-02
+  1.879452845069e-02
+ -2.101388276753e-01
+  8.082945680153e-02
+ -5.746303146606e-02
+ -8.329220636476e-02
+  3.313371699103e-02
+  7.551061010358e-03
+  7.579836640774e-02
+  1.186867499605e-01
+ -1.449706496329e-01
+ -9.409886966438e-03
+ -7.620914666448e-02
+ -2.230592723506e-03
+  2.453645647580e-02
+  1.349528772393e-01
+  1.276908173075e-02
+  8.574629039351e-02
+ -6.864000736578e-02
+ -1.155909859694e-01
+  3.272126791051e-02
+  2.260442542445e-01
+ -3.859233739391e-02
+ -5.646832511852e-02
+  2.201096613899e-03
+ -7.100826539003e-02
+ -2.010984910467e-02
+ -7.865559088980e-02
+  5.428833818441e-02
+ -2.934246751936e-02
+ -1.331995725418e-01
+  7.212339069118e-02
+ -1.333068864646e-02
+  2.664539498356e-02
+ -6.845953128169e-02
+  8.167882129387e-02
+ -4.206591935612e-02
+ -9.480534398659e-02
+  1.226192987382e-01
+ -3.623105606083e-02
+  1.542358073524e-01
+ -8.166732669442e-02
+ -2.163300154878e-01
+  1.566701635621e-02
+  8.069374034897e-02
+  2.254084046482e-02
+ -4.255249727570e-02
+ -1.613525692841e-02
+ -9.816172566097e-02
+  1.112622073432e-01
+ -3.801838163477e-02
+  6.652797268344e-02
+ -1.740530737984e-01
+ -1.068357534915e-01
+ -6.037524765155e-02
+  6.950663397242e-02
+  1.129944820542e-01
+ -1.391143756731e-01
+  3.398572030705e-02
+ -1.133681413151e-01
+  6.328492437830e-02
+ -5.557488819530e-02
+ -5.812169394273e-02
+  1.254588258806e-01
+ -8.175989273257e-02
+ -2.326923978211e-02
+  9.587181159818e-02
+  1.495398830968e-01
+  1.340302473979e-01
+ -1.783816790687e-04
+  8.183846823882e-02
+ -2.994399584153e-02
+  8.075810943613e-02
+  1.014045210618e-03
+  1.653617156528e-01
+  2.534051776160e-02
+  4.595811523708e-02
+ -3.359488880961e-02
+ -1.387131186619e-02
+ -9.395318166047e-02
+ -1.277285073819e-01
+  5.715543238460e-02
+  1.368181451450e-01
+ -6.411933025144e-02
+ -6.836065653801e-02
+  6.718469246360e-02
+  6.009563717291e-02
+  7.372665728252e-02
+  1.872905483788e-02
+ -1.061557091016e-01
+ -3.040112914065e-03
+  1.760303393507e-02
+ -2.845994285836e-02
+  5.317237976008e-02
+ -1.490458525098e-01
+ -6.916574495654e-02
+ -1.071045763640e-02
+ -1.258863211625e-01
+ -1.536461797926e-01
+ -1.120567202667e-01
+ -2.617988389374e-02
+ -7.229989604818e-02
+  1.218668431851e-02
+ -3.994863920499e-02
+  2.603104758091e-02
+  4.773777864935e-02
+  4.650103149922e-03
+ -2.445309666269e-02
+ -2.694453178293e-02
+  9.029433374481e-02
+  8.503975037920e-02
+ -2.777286417140e-02
+ -3.026550729975e-02
+ -1.222205702587e-02
+  1.369976711367e-02
+ -9.028711057440e-02
+ -1.380374343249e-01
+  7.906889087787e-02
+ -3.536761017500e-02
+ -1.515657284408e-01
+ -2.511025385244e-01
+  8.628553892574e-02
+  2.059453022388e-02
+ -1.514463841473e-04
+  1.375342460417e-01
+  8.781494827799e-02
+ -1.722884983776e-01
+  7.511566179526e-02
+  1.875422076556e-01
+ -6.399877567925e-02
+  4.313086446034e-02
+  6.956852710423e-02
+ -7.139991840584e-02
+ -1.447824871033e-01
+ -2.002230744812e-01
+  8.300046049036e-02
+  1.437527334997e-01
+ -1.046716147002e-01
+  1.996449900949e-01
+  6.873104021313e-02
+ -1.368928324898e-01
+  4.275696808340e-02
+ -1.003201095813e-01
+  1.547313472402e-01
+ -1.839242571250e-02
+  6.517866956407e-02
+ -9.638043743045e-03
+ -2.640884751679e-02
+ -2.032695270311e-01
+  3.080768741817e-02
+  7.886805731001e-04
+ -1.995742134795e-02
+  4.517036049591e-02
+ -6.140674442343e-03
+ -2.091856814298e-02
+ -2.982335105842e-02
+ -6.680417175740e-03
+ -5.278961730277e-02
+  1.630354440400e-01
+ -1.654021094420e-02
+  1.389981695707e-02
+ -5.006562172359e-02
+ -2.450755226937e-02
+  6.183782373106e-02
+  9.073530682524e-02
+  2.517907855635e-02
+ -3.885138618516e-02
+  2.971062799924e-02
+ -4.948568592373e-02
+  3.716153249966e-02
+ -3.499629158214e-02
+  8.252959650246e-02
+  1.573087424525e-01
+ -2.041628476726e-01
+ -1.944893848608e-02
+  1.847359066208e-01
+ -4.677960456981e-02
+ -8.483359290487e-02
+  7.827146070391e-03
+  1.197967976631e-01
+ -1.282448667505e-02
+ -3.280141783009e-02
+  8.709176911499e-02
+  1.139004751139e-01
+ -8.695505936521e-02
+  7.767372343486e-02
+  1.262855431832e-01
+ -2.315370162821e-02
+  1.239087028944e-01
+  9.780688325283e-02
+  2.871691427718e-03
+  4.217715223667e-02
+ -2.602188863550e-02
+  1.634699361678e-01
+ -1.254049887291e-01
+  4.578297427055e-02
+ -5.725711494253e-02
+  3.297788110625e-02
+ -6.225849447093e-02
+  9.674143119011e-02
+  7.330061074149e-02
+  7.593494627141e-04
+  4.571847547859e-02
+ -3.258905961651e-03
+  1.301558313064e-01
+ -4.804824548150e-02
+  1.670728654853e-01
+  2.405924175609e-01
+ -1.536329618814e-01
+ -1.806493334590e-01
+  9.021755549637e-03
+  5.695728263099e-02
+  1.493586840509e-01
+  4.927478269249e-02
+  1.581084882480e-01
+  3.280768812104e-02
+  1.052549402398e-01
+ -6.690639988984e-02
+  5.584617937351e-02
+  1.391896832974e-01
+  7.295181796169e-03
+ -4.213499943326e-02
+ -1.037348164447e-01
+  1.700134468647e-02
+ -1.857847689586e-01
+  3.301484142693e-02
+  1.902494854695e-04
+ -8.903731038493e-02
+  8.277718054241e-02
+ -1.348281681813e-01
+ -1.432164396595e-01
+  2.475258634801e-02
+ -3.280303725875e-01
+ -2.725880177528e-01
+ -5.722022022721e-02
+ -2.286364112765e-02
+  3.331621771861e-01
+ -3.769240798428e-02
+  1.546822269358e-02
+  1.056997051820e-01
+ -2.499791280343e-01
+  7.922965813504e-02
+  5.459023938620e-03
+ -1.160601658449e-01
+  4.740347742831e-02
+ -1.026900518589e-01
+  4.766394716686e-02
+  8.133134949500e-02
+  1.350233802643e-01
+  3.451770357851e-02
+ -4.954680061687e-02
+  1.186249719403e-01
+ -3.502819841632e-02
+ -1.242275881891e-01
+  5.466479640726e-03
+  8.664055122961e-04
+  1.210769810923e-01
+  4.449574967860e-02
+  3.743292960973e-02
+  1.384940448221e-02
+  6.524382065884e-02
+  2.539071624230e-02
+ -7.702486385826e-02
+ -2.576559213195e-02
+  3.090141425593e-02
+  1.591909949774e-02
+  1.375694207634e-02
+ -7.263527694945e-02
+  7.443188073225e-02
+ -2.057404538205e-01
+  1.028499295323e-01
+ -9.210478371635e-02
+ -1.619516404520e-02
+ -1.665308545647e-02
+ -2.296276660080e-01
+ -3.174167065611e-02
+ -1.189532578129e-01
+  3.906039692056e-02
+  2.426486566239e-02
+  1.930872290476e-01
+ -2.164088501465e-01
+ -4.567123244791e-02
+  1.431315010092e-01
+  1.464048655349e-02
+  1.188195958142e-01
+  1.786869542296e-01
+ -4.380951087632e-03
+  6.968663346504e-02
+ -1.975644949680e-02
+  6.133491488861e-02
+  4.219958343522e-02
+  5.489694329982e-02
+  4.000481298980e-02
+  6.880890637728e-02
+ -8.466025671567e-02
+  1.041232823406e-01
+  1.896620013447e-02
+  1.505195705538e-01
+ -5.844530015809e-02
+  6.753175230843e-02
+ -1.228110878457e-01
+ -2.496934244241e-02
+  2.787749119018e-01
+ -1.888666541939e-02
+  7.561909408577e-02
+  1.553619912579e-01
+  1.262893429935e-02
+ -1.003624645355e-01
+ -2.790411865269e-02
+  1.238052970621e-01
+  8.585286351592e-02
+ -3.017931537288e-03
+ -1.266332914930e-01
+ -6.556075902424e-02
+ -1.536428085516e-01
+ -3.455491920430e-02
+ -5.570691455973e-02
+ -2.188180385017e-02
+  4.156765480600e-02
+  2.509959982623e-01
+  3.397781239292e-02
+  3.438557385491e-02
+ -7.652919616772e-02
+ -1.039775876039e-01
+  1.370705803099e-02
+  1.220286158001e-02
+ -1.707012575111e-01
+  3.411302848900e-02
+ -1.938895443838e-02
+  1.139361656129e-01
+  7.741827239557e-03
+  1.076697614787e-01
+ -6.873880910288e-02
+ -2.173965714869e-02
+ -1.075711661397e-01
+ -1.718821624906e-02
+  1.119438590258e-01
+  1.053030531552e-01
+ -6.362030674951e-02
+ -4.653221201208e-02
+ -9.406202005883e-02
+  1.059850977005e-01
+  9.823130451058e-02
+ -1.500292912902e-01
+ -2.491758956650e-01
+  2.466040046046e-02
+  5.588775047377e-02
+  1.251472722573e-01
+ -2.018343231523e-01
+  7.869141483677e-02
+ -7.117725579930e-02
+ -6.197374974861e-02
+  3.651085114556e-03
+  3.826643483385e-02
+ -1.834995484846e-02
+  4.889830862373e-02
+ -6.800970207519e-02
+  3.158151435950e-01
+ -1.631234107835e-02
+  1.012966345339e-02
+  3.903269071126e-02
+  7.982960792987e-02
+ -2.090694001027e-02
+ -2.598174099793e-01
+ -2.456475193596e-02
+  7.115974104112e-02
+  1.795675472749e-01
+  3.685038268260e-02
+  5.105420020600e-02
+ -1.060733313485e-01
+  5.294210308512e-02
+ -2.796426776881e-01
+  8.787952234789e-02
+ -3.987083068346e-02
+ -8.916241194898e-02
+  9.840716389172e-02
+  2.275990389054e-01
+ -9.929674684200e-02
+  3.353096824633e-02
+ -1.953426819020e-01
+  1.540322044226e-01
+  4.014111943399e-02
+ -1.120630648786e-01
+ -4.946870975393e-02
+ -2.627628865111e-01
+ -8.856605031124e-02
+ -2.199633057041e-01
+  4.257912415641e-02
+ -2.157953635154e-02
+  1.685376004221e-01
+  4.092665561824e-02
+  8.314758753035e-02
+  7.906081023369e-02
+ -4.421647453582e-02
+ -5.834965796486e-02
+ -9.603378703960e-02
+ -1.504528053804e-01
+  1.045232305255e-01
+  1.406536318788e-01
+  6.773042997697e-02
+ -1.173918663844e-01
+ -1.608438736505e-01
+  3.393261261267e-02
+ -1.417443941716e-01
+  9.091353122185e-02
+  1.239166129220e-01
+  1.427213734110e-01
+  1.355073309202e-01
+ -5.291637308701e-02
+  4.719246118396e-02
+ -1.179426525592e-01
+  8.414747431161e-02
+  1.847651747168e-02
+  1.753574743285e-02
+  1.431599736714e-01
+  6.711379414755e-02
+  5.658351391434e-02
+ -1.760318936404e-01
+ -1.795626574293e-01
+  2.087495938486e-01
+ -3.890315913131e-02
+ -2.689243942433e-02
+ -1.523695505081e-01
+ -2.052801641494e-01
+  8.184853499671e-02
+ -1.670024798425e-02
+  1.039990372927e-01
+ -2.935771006376e-02
+  1.251176594685e-02
+ -9.215588558723e-02
+  8.426727093379e-02
+ -2.055635954343e-01
+ -1.835239627255e-02
+  1.418216410138e-02
+ -2.853156718003e-02
+ -2.296477893302e-03
+ -4.078319671905e-02
+ -2.191524284904e-01
+ -2.607242374543e-01
+  2.140326799916e-01
+ -2.142746748970e-03
+ -5.102184313526e-02
+  1.144073805814e-01
+  8.863674893123e-02
+  5.719387201731e-02
+  3.317481513599e-02
+  3.572528315159e-02
+  9.418448678296e-02
+  1.641822390771e-01
+  1.135489544408e-01
+ -2.901573678290e-02
+ -3.571580773532e-02
+ -8.800802723113e-02
+ -1.142816304194e-01
+  9.165889327855e-02
+ -1.498100772472e-01
+  1.168890708603e-01
+ -8.762694083390e-02
+ -5.068407505698e-03
+  1.085059321386e-01
+ -4.797116487579e-02
+  3.663328041564e-02
+ -5.396856757906e-02
+ -2.669679249087e-02
+  1.156736894621e-01
+  1.494205211314e-02
+ -1.429660056214e-01
+  1.826521599821e-01
+ -5.480820640394e-02
+ -9.059336858876e-03
+ -5.169350620667e-02
+ -1.009767697330e-01
+ -6.914272787638e-02
+  3.532181853031e-02
+ -7.025899399986e-02
+  7.835915496093e-03
+ -7.477001125216e-02
+  7.056817803176e-02
+ -3.787528343829e-02
+  4.031926274488e-02
+ -1.212789794741e-01
+ -8.154976020687e-02
+  1.039072261934e-01
+  8.002713149522e-02
+ -7.550304986743e-03
+ -1.005422473938e-02
+ -9.541921034406e-02
+ -7.530405435616e-02
+ -1.328133102281e-02
+  1.286539471427e-01
+  1.401233457667e-01
+  1.364797805405e-01
+  9.093615456807e-02
+  6.802839962337e-02
+  1.303597321860e-01
+  1.068996416909e-01
+ -3.675377481907e-02
+ -1.018887942901e-01
+ -1.981959148729e-01
+  8.237704247957e-03
+  9.849419487606e-02
+ -1.724488245888e-01
+ -6.165472643817e-02
+  6.033618748343e-02
+  2.902073406933e-02
+ -3.015813800940e-02
+ -6.960606643398e-03
+  2.396025177231e-02
+ -1.174109342619e-02
+ -1.389982648893e-02
+ -1.039528948223e-01
+  1.488777280558e-01
+  8.219520275751e-02
+ -6.001731555566e-02
+ -3.776274597519e-02
+  5.007959023566e-02
+ -7.942926488928e-02
+  5.825629939510e-02
+ -6.536578342691e-02
+  5.101137088464e-02
+ -4.620227928468e-02
+  3.028627514948e-02
+ -1.567588377535e-01
+ -8.994812084692e-02
+  2.143360818504e-02
+ -3.403292733343e-02
+  1.581971074806e-02
+ -3.479894140679e-02
+ -1.363443999573e-01
+ -1.607293033525e-01
+ -1.035999780883e-01
+  7.028517496403e-02
+ -1.396798553938e-01
+  1.081351665616e-01
+ -9.095392791168e-02
+  1.229870669110e-01
+ -6.705434567505e-02
+  8.783733888672e-02
+  1.711042442230e-01
+ -1.902572346243e-01
+  3.761679047823e-02
+  2.312607101640e-02
+  3.096795043624e-02
+ -3.587275201063e-02
+ -8.670204681392e-02
+ -9.611449888352e-02
+ -1.100610180017e-02
+  3.552247098187e-02
+  5.519986476702e-02
+  3.211033372954e-02
+  1.614777794354e-01
+ -1.528658688343e-01
+ -1.047354695942e-01
+  1.133800791842e-01
+ -1.063992877303e-01
+ -9.464327032929e-02
+  1.384461199082e-01
+  3.936737394104e-02
+ -3.642956790446e-02
+  7.917432095926e-02
+ -3.156127644975e-03
+  1.968594412073e-02
+ -1.554308003365e-01
+ -3.444875976223e-02
+  6.868437427101e-02
+  2.485992056394e-02
+ -4.537423183849e-02
+ -1.288936962168e-03
+  2.026908893789e-02
+  1.434381060127e-01
+ -5.488466040311e-02
+  1.058273537162e-01
+ -5.007595967661e-02
+  1.130225678157e-01
+  2.768505330266e-01
+  6.758678754706e-02
+  3.337672887528e-02
+  1.804582782932e-02
+ -1.950553386292e-01
+  4.235459410818e-02
+ -4.410048809892e-03
+ -5.954354444384e-02
+ -1.424315653663e-01
+ -1.004356800173e-02
+ -2.779282727361e-02
+ -3.890577740291e-02
+  7.641979570738e-02
+  8.122865816025e-02
+ -1.500896853476e-01
+ -1.341884149257e-01
+ -5.320267488021e-02
+ -7.286859286712e-03
+ -1.652759669956e-01
+ -6.490118637125e-02
+  3.382812580600e-02
+  1.078155446953e-01
+ -1.371987316415e-01
+ -1.120797646786e-01
+  1.156079685970e-01
+  4.923959682846e-02
+ -1.640141395877e-01
+ -6.930477064855e-02
+ -1.477387172926e-01
+ -1.500662450387e-01
+  1.394241937909e-01
+ -6.250655629614e-02
+ -1.308314184563e-01
+  3.274849781929e-02
+ -6.311389035773e-03
+  7.811442477960e-02
+  2.295995618259e-02
+ -6.720615106108e-02
+ -6.430283655220e-02
+ -9.653064825583e-02
+ -6.395546458523e-02
+ -3.989648320967e-02
+ -6.708801909372e-03
+ -2.664242205493e-02
+  9.178528454996e-02
+ -1.380841235298e-02
+ -4.739205798842e-02
+ -4.331935937913e-02
+  5.479929056545e-04
+  7.178027330364e-02
+ -2.189626692456e-01
+  3.796013324070e-02
+  7.612232862658e-02
+ -1.443880815708e-01
+ -1.130586634781e-01
+ -1.888452137647e-01
+ -1.739657663024e-01
+ -9.135722055880e-02
+ -5.802471429591e-02
+ -4.370053054748e-02
+  8.959846192900e-02
+ -2.968080242850e-02
+  3.558595371010e-02
+ -7.547931363558e-02
+ -6.401072634402e-03
+  3.534922713157e-02
+ -9.212877347593e-02
+  1.216222338968e-02
+  1.510022127142e-01
+  7.886053747636e-02
+  7.590565664746e-02
+ -1.812427862012e-01
+ -6.375645401348e-02
+ -2.302992786669e-01
+  3.254483107469e-04
+ -2.303289473889e-01
+  5.353223083366e-02
+  1.962013739508e-02
+  3.352247911852e-02
+ -3.319596434503e-02
+  6.317390072652e-02
+ -5.455636324959e-02
+ -3.621089293014e-02
+  1.013501482617e-01
+  7.269253319611e-02
+ -1.832096374491e-01
+  1.653692988946e-01
+  7.575724148237e-02
+  1.135300885772e-01
+ -1.291061220992e-01
+  7.603071540713e-02
+  4.609557573081e-02
+  1.874589758752e-01
+ -8.555555627135e-02
+ -1.179145781721e-01
+ -8.446263941655e-02
+ -1.275183115548e-01
+  2.740441562026e-03
+  1.883566847612e-01
+  4.649047005713e-02
+  2.233398598782e-01
+  3.995067012992e-02
+  1.470946037761e-02
+ -9.414387369759e-02
+ -1.209356501182e-01
+  1.441089558168e-01
+ -2.294517954491e-02
+ -4.635864767554e-02
+  4.785082382149e-02
+  8.790989298005e-02
+  7.879993095311e-02
+ -1.202046338460e-02
+  6.079742699403e-02
+  9.900850072663e-02
+ -1.385682875748e-01
+ -1.607339950157e-02
+ -7.696423864196e-03
+ -2.017067479261e-02
+ -1.104103038904e-01
+ -1.537918581815e-01
+  3.307745551617e-02
+  1.430963891072e-01
+ -4.840043215616e-02
+  1.375489323005e-01
+  1.032452159772e-01
+ -8.920737668188e-02
+  2.064617621654e-01
+ -6.557095478402e-02
+ -7.399838108733e-02
+  8.833547998268e-02
+  7.325814601320e-02
+  1.765488220838e-01
+ -6.807612973717e-02
+  1.201433770211e-01
+  1.237338164392e-02
+ -8.208925587011e-02
+  2.885453664239e-02
+ -4.770965186222e-02
+ -2.015836156343e-01
+ -8.314380800811e-02
+  1.071109576028e-01
+  8.105450214084e-03
+ -1.608592813743e-02
+  6.987586534959e-02
+  6.117515745079e-02
+ -1.414449036116e-01
+ -3.519245276391e-02
+ -4.276330186708e-02
+  3.160615950522e-02
+  1.006358046093e-01
+ -4.341349799769e-02
+  1.112214729807e-01
+  7.058007158916e-02
+ -1.064893083561e-01
+  1.318125686595e-01
+ -1.276013788788e-01
+ -7.663145686123e-03
+  8.160936404979e-02
+ -1.406437285315e-01
+  2.173773640223e-01
+  1.795170453261e-01
+ -6.364677627516e-02
+ -9.000557871431e-03
+  4.226049909494e-02
+ -1.597695719380e-02
+ -6.698849632313e-02
+  1.538964561481e-01
+ -7.125217028857e-02
+ -1.031609905376e-01
+ -6.033308325802e-02
+  3.571685844972e-02
+ -1.350105872860e-02
+ -2.347356398406e-01
+ -3.685153861881e-02
+  1.455130563306e-02
+ -2.188917705493e-03
+ -9.439805486671e-02
+ -5.801841896661e-03
+  2.225968773232e-01
+ -4.686714687776e-02
+  3.572268660462e-02
+  6.182649198384e-03
+  1.278248400089e-01
+ -9.447161986769e-02
+  4.629724671024e-02
+ -2.658573671011e-02
+  6.150939901188e-02
+ -9.208536359247e-03
+ -1.171371393097e-02
+  6.391411554479e-02
+ -4.831081028856e-02
+  6.024641830798e-03
+ -1.209816049239e-02
+ -3.933084856524e-02
+ -1.650877135843e-02
+ -1.004374060122e-01
+ -1.597954204922e-01
+ -2.322250168013e-01
+  6.077059430803e-02
+ -7.662842257076e-02
+ -1.559543883317e-02
+ -8.739341024778e-02
+ -5.734974054133e-02
+  5.590669526374e-02
+ -1.090127182002e-01
+  8.022113855438e-02
+ -1.242471911542e-01
+ -7.130260569120e-02
+  8.697279036521e-02
+  1.176440306961e-01
+  9.432585127932e-02
+ -6.561246549622e-02
+ -5.498646067546e-02
+ -3.956091542308e-02
+ -1.125434387621e-01
+ -7.160275883782e-02
+  3.311911618057e-03
+ -8.820366519806e-02
+ -4.778582884008e-02
+ -9.154377533432e-03
+  3.753791389670e-02
+  8.362311237277e-02
+  1.401543168695e-01
+ -9.824959064645e-02
+ -1.732009931927e-02
+ -1.860332400809e-01
+  8.782945941632e-02
+ -1.330689780911e-02
+ -1.793872635997e-02
+  6.145826897348e-02
+  6.704146767048e-02
+  2.233351609962e-02
+  1.871297317375e-01
+ -1.279274632981e-01
+  1.640940448259e-01
+ -1.171754465899e-01
+  8.818436528732e-02
+  8.954763780203e-02
+  7.232293424202e-02
+ -3.006582984847e-02
+  1.982796529144e-02
+  5.900229195649e-02
+  1.180875332099e-02
+ -5.973806294885e-02
+ -8.098419748662e-02
+ -2.250579837225e-02
+  1.487484885520e-01
+  5.361474717614e-02
+ -3.036289141334e-02
+ -2.269358603557e-01
+ -1.330447585381e-01
+  9.816561301225e-02
+  1.708407392525e-01
+  1.056165913976e-01
+  2.945977498261e-01
+  2.371393238920e-01
+  7.753404013750e-03
+ -7.536635541620e-02
+  8.087957256799e-02
+  3.991394222645e-02
+  2.017496953062e-01
+ -3.458036019315e-02
+ -1.516917181095e-01
+ -6.643442146503e-03
+ -1.584386456464e-01
+ -7.726215549823e-02
+  4.944822466416e-03
+  1.194280784233e-01
+ -5.132467014551e-02
+  3.104153906735e-02
+ -6.616421530948e-02
+ -7.230987894248e-02
+  3.884498553753e-02
+ -8.768708050574e-02
+ -2.048112428183e-01
+ -1.063785930866e-01
+ -2.632434476012e-02
+  9.126703890737e-02
+ -2.633566378667e-01
+  1.361253909037e-01
+  8.130679263651e-02
+  5.962498822902e-02
+  4.306456871579e-02
+ -9.945351374668e-02
+  8.717224419696e-03
+ -1.697106801159e-01
+  5.711227889162e-02
+ -8.657424236545e-02
+  7.781250557393e-02
+ -9.238655348968e-02
+  4.302231192955e-02
+ -1.003419811990e-01
+  5.892062539365e-02
+  7.462091028160e-03
+ -7.984929679120e-02
+ -5.743514088513e-02
+ -7.589566293814e-02
+ -5.893514368514e-02
+ -7.896719351928e-02
+  4.695041430963e-02
+  1.558748828435e-01
+ -7.274924469389e-02
+  7.246052568098e-02
+ -1.211396717486e-02
+  3.437109284468e-02
+  3.002251089882e-02
+  1.054075081687e-01
+  2.062017776345e-01
+  1.676186309101e-01
+ -3.387425862575e-02
+ -3.016341338563e-02
+ -1.307773678985e-01
+ -9.571730665141e-03
+  8.819031836735e-03
+ -5.494792110003e-02
+ -2.200698431048e-03
+  4.926417848645e-02
+ -1.439667882527e-01
+  5.013219051832e-02
+  1.366282409489e-01
+ -4.272747915508e-02
+  1.554009781548e-02
+  1.144654484846e-01
+ -9.861322287536e-02
+  2.133187409753e-01
+ -4.636311700126e-02
+ -5.738956138719e-02
+  5.089414893423e-02
+ -1.444280056126e-01
+  2.790010360416e-02
+ -1.500685637829e-01
+  2.185978945931e-02
+  6.088304432125e-02
+ -1.920256614368e-02
+ -2.416370495536e-02
+ -2.337955810706e-02
+  9.468717640324e-02
+ -2.061024859539e-01
+  2.204884240861e-02
+  5.860780036319e-02
+ -4.052201562402e-02
+ -1.348183932096e-01
+  1.766476887073e-02
+  1.655162352442e-02
+ -1.029759353730e-01
+ -3.237740713218e-02
+ -1.705146617349e-01
+ -3.518730582745e-02
+ -1.534219423635e-01
+  4.237244322764e-02
+  8.597471684459e-02
+ -1.891082041617e-01
+  1.480763193656e-01
+ -6.178193928670e-02
+ -1.065717778554e-01
+ -1.502127573245e-01
+  2.026462523522e-01
+  5.867055543704e-03
+  9.976561996344e-02
+  1.849814652226e-01
+ -2.351133913833e-02
+  1.024822597857e-01
+ -8.273527669427e-02
+  3.293962433763e-02
+  1.716422254084e-01
+  5.191701491900e-02
+  1.416146260393e-01
+ -1.221674971034e-02
+  4.760767529638e-02
+ -1.755235338279e-01
+ -6.197948855236e-02
+  4.957054498271e-02
+  9.989011757578e-02
+ -8.459402319394e-02
+ -3.578305543100e-02
+  1.540214325137e-01
+  1.404573144461e-02
+ -2.540420923190e-02
+  6.906757587719e-02
+ -2.494875132505e-02
+ -3.830367054768e-03
+  2.441925327843e-02
+  1.200074448663e-01
+ -2.146334291869e-01
+ -8.423240497427e-02
+  6.140876787065e-02
+  5.488773423673e-02
+  1.428742637118e-02
+ -4.892562649060e-02
+ -2.038432219778e-02
+ -2.272222990672e-02
+  1.663435601009e-02
+  9.001295941872e-02
+ -7.671247242614e-02
+  3.424144287618e-02
+  4.428918349022e-02
+  8.963719445915e-02
+  1.321582217880e-01
+  4.697640702169e-02
+  3.457634142207e-02
+ -8.985295035651e-02
+  1.128447093536e-01
+ -4.307045159208e-02
+  7.321626564310e-02
+ -2.312792711781e-01
+ -2.749983451664e-02
+ -1.242255720042e-01
+ -8.790616984802e-02
+  9.210906396741e-02
+  1.093409168859e-01
+ -1.800763441272e-01
+ -6.290994232126e-02
+ -1.582890794437e-03
+  9.633963390999e-03
+  2.700612951937e-02
+ -6.399974068438e-02
+ -1.123916318392e-01
+ -1.041067538939e-01
+ -7.597192751010e-02
+  2.106084817751e-01
+ -3.264062691271e-02
+ -1.008894728571e-01
+  3.319429004826e-02
+ -2.018712095399e-02
+  7.018679254178e-02
+  4.296794533095e-02
+ -4.827866358651e-02
+  1.055451457950e-01
+  8.052132010094e-02
+ -3.257874548774e-02
+  4.434816399568e-02
+  4.639230333266e-02
+ -1.575965381838e-01
+ -1.805103852002e-01
+  9.630405568460e-02
+ -4.547491629874e-02
+  1.208336416038e-01
+ -1.630272588486e-02
+ -8.707944718972e-02
+ -1.714454616856e-01
+ -2.639993530949e-02
+  5.363354670431e-02
+ -5.616139611361e-02
+  6.080093477062e-02
+  1.328580205312e-01
+ -6.408038923184e-02
+ -1.307243108583e-02
+ -4.623501491817e-02
+  1.276994610371e-02
+  1.330506937817e-01
+  1.503851655431e-01
+  1.856171690627e-01
+  6.152007316382e-02
+ -2.277593863519e-02
+ -4.109227326768e-03
+ -3.431957825678e-02
+  1.541172674831e-01
+  3.102406972286e-02
+ -1.212961511823e-01
+ -7.140662843620e-02
+ -5.409479878571e-03
+  1.277091074516e-01
+  4.176347321844e-02
+ -1.045779099399e-01
+ -5.874272155183e-03
+  1.676552422038e-02
+ -1.511693195238e-02
+ -7.503114809933e-02
+ -6.459223174808e-02
+ -8.445222225243e-02
+ -1.628546264754e-01
+ -1.141467921256e-01
+ -5.552146146021e-02
+ -5.357402989205e-02
+ -1.934598555161e-02
+  5.540452814472e-02
+ -4.067708366583e-02
+ -2.046478564612e-02
+  1.507791188975e-01
+  1.873808576691e-02
+  1.046733543314e-01
+ -5.101676749872e-02
+  7.668969542177e-02
+ -6.551320654120e-02
+ -8.804027192417e-02
+  4.768021692282e-02
+ -7.921318400852e-02
+ -2.356461696032e-01
+  7.294458104030e-02
+ -8.859771008143e-02
+ -1.836001679846e-03
+  1.657145081561e-01
+  1.845907370482e-01
+  1.794747579400e-02
+  6.403269355163e-02
+ -7.084667141371e-02
+ -2.570950836289e-02
+  1.698632756618e-02
+ -9.220890762638e-02
+  6.473698208259e-02
+  2.867278127318e-02
+  1.212613443981e-02
+  1.355642230063e-01
+ -1.604466267929e-01
+  2.348930827992e-02
+ -1.022220508049e-01
+ -6.055957685059e-02
+ -1.134498500250e-01
+ -5.762003446935e-02
+  2.825804557210e-02
+ -1.441633393900e-02
+  1.168025246616e-01
+  8.776185410131e-02
+  6.896990176232e-02
+  2.953802809325e-02
+  1.530953434349e-02
+ -1.766975997799e-02
+  1.614163038494e-01
+ -3.699113542899e-02
+ -6.936946945165e-02
+ -5.679879469476e-03
+  9.725944286863e-02
+ -1.697574054294e-02
+  4.632878199206e-02
+  1.788904645139e-01
+  1.530655086605e-01
+  2.238754570162e-01
+ -5.058895671048e-03
+  6.304260665443e-02
+ -1.766019826193e-01
+  1.242207914286e-01
+ -5.733729000714e-02
+ -6.580757209485e-02
+ -4.771933352043e-02
+ -7.056419711021e-02
+ -6.311726855569e-02
+ -1.261802206287e-03
+ -7.237876864627e-02
+ -7.920496313051e-02
+  3.240691816036e-02
+ -1.916964898697e-01
+  9.938305033261e-02
+  1.300777984759e-03
+  2.630208758338e-02
+ -4.128835339991e-02
+ -3.532656321223e-02
+ -1.592901886869e-02
+ -3.314927874139e-02
+  2.616885160489e-02
+  3.924677856683e-02
+  8.653540764774e-03
+ -2.560625327227e-01
+ -3.942999408993e-02
+  6.124310080535e-02
+  2.279199126716e-01
+  1.154291819913e-02
+  3.212572708487e-02
+  1.123165206508e-01
+ -2.969845452252e-02
+ -2.940734254753e-02
+ -3.853872080283e-02
+  1.120053275590e-01
+  2.021161758950e-03
+  6.661846600219e-02
+  3.185391133669e-02
+ -1.631619712694e-01
+  1.430670665327e-01
+ -5.415821468791e-02
+  1.443655969957e-01
+  5.506876981816e-02
+ -1.574783390828e-01
+ -1.948223439992e-02
+  1.127296769965e-01
+ -1.331928800849e-01
+ -8.084722634892e-02
+ -5.218339852036e-02
+  1.559135804138e-01
+  1.230043702348e-01
+ -1.739733894601e-04
+ -1.391479262529e-01
+ -1.151548581126e-01
+ -1.414496309300e-02
+  1.447903273151e-02
+  1.641884102745e-01
+  6.567866723705e-02
+  3.013968222731e-02
+  7.366407759361e-02
+  5.822771667780e-02
+  9.551041494247e-02
+  5.417884770677e-02
+  1.842249768171e-02
+  6.502228972709e-02
+ -3.881728961891e-02
+ -2.602701078994e-02
+  3.326341102422e-02
+  2.866230744235e-03
+ -1.844270695082e-02
+ -1.265362471931e-01
+ -2.411436491955e-02
+ -6.774897629355e-03
+  6.336687930025e-02
+  3.989786478256e-02
+  1.064492555624e-01
+  9.188697411594e-02
+ -1.403834707045e-02
+ -7.168855809313e-03
+  3.487573838423e-02
+ -5.874976620416e-02
+  1.666259077650e-02
+ -1.718916756768e-01
+ -1.046315141920e-01
+  3.707945071308e-02
+ -1.931510055309e-02
+  2.166292225874e-01
+  1.856566502376e-01
+  6.634230278679e-02
+ -1.938653869769e-01
+ -1.536282069794e-01
+ -9.700319544763e-02
+ -1.169281979616e-01
+ -8.672529499127e-02
+  9.218151401455e-02
+  8.965258387368e-03
+  1.281195550641e-01
+ -1.363178147488e-01
+ -6.142745580080e-02
+  5.726819060726e-02
+  1.306883695880e-03
+ -3.885670235422e-02
+  2.853060338452e-02
+ -3.785289176900e-02
+ -4.137456054508e-02
+ -8.406864687679e-02
+  1.262259673611e-01
+ -1.016764477941e-01
+ -2.052455214810e-02
+ -1.342477583192e-02
+  8.157575952804e-02
+ -5.865329912038e-02
+ -3.727631006174e-02
+ -6.723073839097e-02
+  1.288377456918e-01
+ -1.739220614162e-01
+  3.972504768477e-02
+ -2.012578215140e-02
+  1.103488117909e-01
+ -1.026544549717e-01
+ -2.119905164322e-02
+  9.855363939100e-02
+  2.385808648118e-02
+ -5.641675721608e-02
+ -5.972413910038e-02
+  3.258943234404e-02
+  9.201314633673e-02
+  2.640703110357e-02
+ -5.472590611645e-02
+  1.140319503803e-01
+ -1.113351260816e-01
+  2.576667058719e-02
+ -1.134339361479e-01
+ -9.993742700916e-02
+ -2.207648783666e-01
+  1.015251859539e-02
+  2.007136218502e-01
+ -1.817215018875e-01
+  9.386733155108e-02
+  6.220842356274e-02
+ -1.058764663261e-02
+  7.921767154594e-02
+  1.428216926851e-01
+  1.085524061756e-01
+  1.236218505658e-01
+ -1.640534882720e-01
+  7.387996189230e-02
+ -1.470453230709e-02
+  2.722339656507e-02
+ -6.574919646670e-02
+  1.529437901999e-02
+ -5.879434921584e-02
+  6.875391174393e-03
+  1.963443032935e-01
+  4.579254148532e-02
+ -1.141286547497e-01
+ -6.768070255830e-02
+ -1.263159016926e-01
+  6.683803800282e-02
+ -3.101695158238e-02
+  1.861503786506e-01
+  8.580821425977e-02
+  1.600590826782e-01
+ -1.351521093821e-01
+  2.075693856631e-02
+ -6.282035906645e-02
+ -6.759107315523e-03
+  1.618102644889e-02
+ -8.913672506775e-02
+ -4.562638172570e-02
+ -7.710834435704e-02
+ -2.456160193980e-02
+  1.607472127251e-01
+  1.462536218401e-01
+ -2.009108564285e-02
+ -5.147971652036e-02
+  1.842215071236e-01
+  7.849368914136e-02
+ -1.634311453790e-02
+ -4.060989015296e-02
+  1.283732421262e-01
+ -5.125783783345e-02
+ -1.637740254569e-01
+ -3.765153764496e-02
+  7.346726270405e-02
+ -1.094308839241e-01
+ -9.722802550554e-02
+ -2.811093392623e-02
+  4.984981686835e-02
+ -2.314032952328e-02
+  1.148208015776e-01
+  1.317265464186e-02
+  3.729454000725e-03
+ -1.424596015278e-02
+ -6.275897181529e-02
+  5.943368180960e-02
+ -1.754647556328e-01
+ -1.122246946703e-01
+  5.274983748907e-02
+  1.045483717244e-01
+  9.036128348409e-02
+ -5.428093830713e-03
+  1.574667981931e-01
+ -8.043123871437e-02
+  5.034509706524e-02
+ -1.255879692003e-01
+ -1.735296559820e-01
+ -1.911868898027e-01
+  9.113310779087e-03
+  6.493838750148e-02
+ -4.922104697622e-02
+  6.184391890820e-02
+  8.664108160304e-02
+  9.736213215200e-02
+ -6.385699559084e-02
+  8.790709666163e-02
+  6.851334505199e-02
+  1.014581489311e-01
+ -6.647260694919e-02
+  6.788519620208e-02
+ -2.301646151131e-02
+  1.169320529363e-01
+  1.492923449331e-01
+ -1.154691068486e-01
+  1.250515113720e-01
+  5.717355223825e-02
+  1.264124221771e-01
+  1.177191720499e-01
+ -1.069052678238e-02
+  1.389271718825e-01
+ -1.730299208813e-02
+ -1.880213161394e-01
+ -5.754049556676e-02
+ -1.727085595974e-01
+  4.887426275312e-02
+  1.228068454242e-01
+ -3.286536941479e-01
+  1.060820651535e-01
+  2.247929396294e-02
+  1.188288154559e-01
+  2.857328271057e-02
+ -2.403462093160e-01
+  1.302123425700e-01
+  7.429724267421e-02
+  1.339391336804e-03
+  1.095735098379e-01
+  1.129952917630e-01
+  2.674575894209e-02
+  1.348910267790e-01
+  1.743767990148e-02
+  5.605286351657e-02
+  5.078533667348e-02
+ -1.518752190439e-01
+ -4.392547176411e-02
+  2.350656359506e-01
+  6.819870893086e-02
+  1.693075023693e-01
+ -1.934520377053e-02
+ -6.714607112606e-02
+  5.520991333438e-02
+  9.508919239963e-02
+  1.980538911191e-02
+ -6.770382812296e-02
+ -4.909948147113e-02
+  1.121998553251e-01
+  7.940641111077e-02
+  2.068584931708e-01
+  1.792160498508e-01
+  1.823596686805e-01
+  7.471146555704e-02
+ -2.713624334759e-02
+  1.661266424722e-01
+  5.755356403727e-02
+ -1.144528653589e-01
+  1.067701575185e-01
+ -1.134595073387e-02
+ -1.268448165897e-01
+  9.957335993446e-03
+  3.350287722792e-02
+ -9.325744994882e-02
+  3.983362774145e-03
+  1.188099116971e-01
+ -8.271228758162e-02
+ -2.087626964138e-01
+ -1.102988776269e-02
+  8.984575872002e-02
+ -8.220078954256e-02
+  6.574053971860e-02
+  1.674010498198e-02
+  5.027967400491e-02
+  5.184858382552e-02
+  8.295756914700e-02
+ -2.190786218902e-02
+  1.621881207996e-01
+ -1.804361068771e-01
+ -1.314106918389e-02
+  7.920289625179e-02
+ -7.049826819576e-02
+  1.014755580106e-01
+ -5.175828631805e-02
+ -5.758650964314e-02
+  5.032314739109e-02
+  1.679935508878e-01
+  1.003991068589e-01
+ -2.172136959498e-02
+  9.176260121517e-02
+  1.552851564717e-01
+  6.547340502104e-02
+ -2.174641461611e-01
+ -7.590044375910e-02
+  6.352563942114e-02
+  6.118168756017e-02
+  1.050087300618e-01
+ -1.826394062660e-02
+  1.798902772209e-02
+  7.826027158159e-02
+  8.455999140165e-03
+ -9.773906601117e-02
+  1.407960880433e-02
+ -8.129618855632e-02
+  2.338495459705e-02
+  4.072159486622e-02
+ -1.167700521315e-01
+ -1.896247815433e-01
+ -7.381220971636e-02
+  1.608270753936e-01
+  1.224598765275e-01
+  1.256962322731e-02
+ -5.098260350244e-02
+  1.420225067117e-01
+ -1.170166716401e-01
+ -8.073650439764e-02
+ -2.103086702260e-01
+  1.615083183363e-01
+ -2.820554727598e-02
+  5.628529327656e-02
+  2.304508163911e-02
+ -2.638019575906e-01
+ -5.004587859608e-02
+ -4.239231705381e-02
+  1.242738257365e-02
+ -2.236927546940e-02
+ -4.152688459400e-02
+  1.938847136686e-02
+  1.267588965176e-01
+  2.036922920679e-01
+ -1.860356642894e-01
+ -8.541863235848e-02
+  1.116834159319e-01
+  2.886228204241e-02
+  2.329560190273e-02
+ -1.292001407609e-02
+  7.547533660168e-02
+  1.286842708835e-02
+  2.003304064900e-02
+ -3.739632773186e-02
+ -4.222732460883e-02
+ -1.093006545943e-01
+  4.749523263369e-02
+  4.358005022067e-02
+ -2.593231454731e-01
+  7.599591988778e-02
+ -5.663235553012e-02
+ -3.690820271882e-03
+ -8.950744672134e-02
+  9.684707998742e-02
+ -2.366177272892e-01
+  4.480127571298e-02
+ -4.458647093692e-02
+  8.746718449869e-02
+ -3.395543009910e-02
+  1.345448925273e-01
+ -7.877376611518e-02
+  1.444294211050e-01
+  1.318088580216e-01
+  1.054018896864e-01
+ -4.322703724149e-02
+ -1.937949351361e-02
+  1.008546227172e-01
+  1.146215164639e-01
+ -1.173680246094e-02
+  2.601706995037e-02
+ -4.996203111299e-02
+ -1.151468426825e-01
+  1.824478413695e-01
+  2.056163392400e-01
+  1.573818657973e-01
+  1.870956916392e-02
+  2.780609419863e-02
+ -6.652665713048e-02
+  3.818453349855e-02
+ -2.339073361135e-02
+ -4.993151994633e-02
+ -1.641819357147e-01
+ -5.134415031730e-03
+  1.260033420028e-02
+  4.098448816997e-02
+  8.780377273831e-02
+  1.555083736220e-01
+ -1.129971906391e-02
+ -1.863708857527e-03
+ -2.318836411084e-02
+  9.587166664976e-02
+ -1.400368159665e-01
+  6.960055855047e-02
+  8.685654141110e-02
+ -5.688835843655e-02
+  1.075112076682e-01
+  2.566289228153e-01
+  7.169993461476e-02
+  1.086161684557e-01
+ -1.851507668126e-02
+ -7.735200675182e-02
+  2.891660953113e-02
+ -9.221259228556e-02
+ -1.748186465619e-01
+  8.024597761517e-02
+  6.197338610740e-02
+  4.834661868590e-02
+ -3.946210235488e-02
+  3.589971792857e-02
+  9.818217186731e-02
+ -1.405891061581e-01
+ -1.686940972523e-01
+ -8.180293783249e-02
+  6.600043351017e-02
+  3.202349327801e-02
+  1.447492036083e-04
+ -1.027240168393e-01
+  1.425195128848e-01
+  2.837217851712e-02
+ -2.310798933386e-03
+ -1.388717672016e-01
+  1.493002806738e-01
+  4.738061521693e-02
+ -5.959828350622e-02
+ -1.664299136498e-01
+  8.896842046378e-02
+ -6.064112253081e-02
+ -9.808960626009e-02
+ -1.711633192234e-03
+  6.197270872677e-02
+ -2.389243770712e-01
+  1.509996605249e-01
+  4.263871807793e-02
+  3.110232440822e-02
+  2.570952699476e-02
+ -6.081796828694e-02
+ -3.526748065324e-02
+ -5.533986520942e-02
+ -1.532413383694e-03
+  7.452361312877e-02
+  1.442371216993e-01
+  1.033569037475e-01
+  7.029049249770e-02
+  1.007172770878e-01
+ -4.858789072620e-02
+  8.072951319258e-02
+  1.059496092087e-01
+  1.731931923901e-01
+ -1.073253471558e-02
+  1.563885906716e-01
+  1.613690807636e-02
+  6.248740627496e-02
+  6.199171268302e-02
+ -1.980528449169e-02
+  3.398884170651e-02
+ -9.745261611802e-03
+ -6.920487959316e-02
+  1.406871005109e-01
+ -2.131917875270e-02
+  7.853232743103e-02
+ -4.075735223842e-02
+  1.418764689424e-02
+ -1.161846633268e-02
+  6.982242982129e-02
+ -3.673658762923e-02
+ -4.102012570931e-02
+  1.430906861513e-01
+ -5.166312100875e-03
+ -1.306051743319e-01
+  2.064388181677e-01
+  4.312495344303e-02
+  1.044844450296e-01
+  4.432336019373e-02
+  1.110648030127e-01
+  5.230265709217e-02
+ -2.322207644926e-02
+ -4.632044740059e-02
+  9.601121098938e-02
+  9.265931507281e-02
+ -2.140771353888e-02
+  1.668146345817e-01
+ -1.114566793448e-01
+ -1.562407581158e-01
+  1.174495726263e-01
+ -1.560608407248e-01
+ -4.350070606029e-02
+ -1.335700795080e-01
+ -1.688180665168e-01
+  1.262974626399e-01
+  2.761532312623e-01
+  2.492809600104e-02
+  1.818473039326e-01
+  1.350178840722e-01
+  2.192006140069e-01
+ -1.581139213062e-01
+ -1.574527370827e-01
+  6.966931803750e-02
+ -1.073017490718e-01
+  7.210533477761e-02
+ -7.631455633427e-02
+ -2.345503905898e-02
+ -5.580061290438e-02
+ -1.417281342547e-01
+ -2.680480116256e-02
+ -6.625661685889e-02
+ -4.355537795266e-02
+ -1.145102135624e-01
+ -1.113957073117e-01
+  5.602741767954e-02
+  2.315373948529e-01
+ -1.319156047825e-01
+  1.693632936133e-01
+  5.576806439232e-02
+ -2.659929276524e-01
+ -1.143005290584e-01
+  1.893502277957e-02
+  3.181600648936e-02
+  1.062077223929e-02
+ -1.010462079389e-01
+ -4.292838250308e-02
+ -1.438642488291e-01
+  8.891529416497e-02
+ -1.386993588331e-01
+ -1.721854363576e-01
+  1.187216244963e-01
+ -1.040364087503e-01
+ -3.151012798790e-02
+ -1.263398672260e-01
+ -8.548032840986e-03
+  5.968506758015e-02
+ -1.356451362446e-01
+  4.983280828091e-02
+  7.909149431532e-03
+ -5.160923984375e-02
+  1.307032629154e-01
+ -5.384104127441e-02
+ -5.146757119855e-02
+  2.106060592614e-02
+ -1.262658173428e-01
+  6.127223261622e-02
+  1.588158797969e-01
+ -2.000151356077e-05
+  2.438364020302e-02
+  3.021440991951e-01
+  9.540518941819e-02
+  2.265118968074e-01
+ -6.981758210366e-02
+ -7.659837560031e-02
+ -5.194606478635e-03
+  1.238719864200e-01
+  3.352776626451e-01
+ -2.343679530298e-02
+ -1.095947740466e-01
+ -2.978042253906e-02
+ -6.879449049057e-02
+ -4.879942213604e-03
+ -9.127170534428e-02
+  1.947592166836e-02
+ -4.199160353122e-03
+ -1.613967525368e-02
+ -1.920494506066e-02
+ -1.423826142162e-01
+  3.778602467959e-02
+  2.239545048160e-02
+  1.249300346068e-01
+  2.067507352095e-02
+ -8.067724823887e-02
+ -1.332948584247e-01
+  5.581948543491e-02
+  1.469499962301e-01
+  1.646999037958e-02
+ -5.835355526210e-02
+  8.946095747395e-02
+  1.619578722768e-01
+ -8.655167572462e-02
+  3.538181363270e-02
+ -1.948336037514e-01
+  5.437473414927e-03
+ -1.144810429610e-02
+  1.712595809990e-02
+ -1.261076909482e-01
+ -3.866477201330e-02
+  2.386458424340e-02
+  8.919663209296e-02
+  8.367143988651e-03
+  1.216097646610e-01
+ -1.096585423168e-01
+ -1.224253567443e-01
+ -4.374064610114e-02
+ -1.977249808620e-01
+  8.976341921725e-02
+  1.160785007855e-01
+  2.839736933519e-02
+ -4.781488324941e-02
+  1.196808754162e-01
+ -5.223368222492e-02
+  7.989685621387e-02
+  1.561512017413e-01
+ -1.189495799188e-01
+  7.092866120974e-02
+ -1.292108770854e-01
+  1.155344030760e-01
+ -1.983361480713e-01
+ -1.083470943654e-01
+  3.808776234530e-02
+  1.210698456881e-01
+ -5.518142936937e-02
+  4.117315199067e-02
+  4.129099091574e-02
+  6.073301817127e-02
+ -4.255570332655e-02
+  3.443787516639e-03
+ -8.049586174367e-02
+  4.445953113020e-02
+  1.159496887491e-02
+  1.144980954654e-01
+ -1.036356588117e-01
+ -5.474872844488e-02
+  6.887070376316e-02
+  1.227263168732e-02
+  4.574328948223e-02
+ -5.955518913631e-02
+ -3.185317213696e-02
+  1.866474192128e-02
+  1.085729473155e-01
+ -5.939988529085e-02
+  3.107478931288e-02
+  6.189819563385e-03
+ -8.576152742111e-02
+  8.807340359521e-02
+ -1.152779295718e-01
+  1.484248920305e-01
+ -1.585367933146e-01
+ -3.156792521703e-02
+  1.076237164485e-01
+  2.029321267273e-01
+ -9.072568035000e-02
+ -9.944808517857e-02
+  3.740394428366e-02
+ -5.506070761825e-02
+  2.241451162868e-02
+  2.961304645770e-02
+  7.414483719598e-02
+ -5.634578189465e-02
+ -2.144531531017e-01
+ -7.670557888650e-02
+ -4.571512394657e-02
+  3.931338177863e-02
+  1.356493219514e-01
+ -1.225666524899e-01
+  4.286714119001e-03
+  1.279891557198e-01
+ -1.467529018196e-01
+ -4.294166461339e-02
+ -4.644975617478e-02
+ -4.443137587681e-02
+ -1.486056689563e-02
+  6.394396844436e-02
+  1.174567739157e-01
+ -4.835438334239e-02
+  1.086272821923e-01
+ -3.602819612548e-02
+ -9.136876191414e-02
+  4.753946273786e-02
+  2.055274484716e-02
+  6.946450189339e-02
+  6.746376520638e-02
+  9.878132875831e-02
+ -1.632810787793e-01
+  5.594987990414e-02
+ -6.476445482454e-02
+ -5.199230180881e-02
+  8.615214447875e-02
+  2.881685234640e-02
+ -1.797105097350e-01
+ -5.733861399779e-02
+ -1.576465535675e-02
+  1.617450633485e-01
+ -4.912827677430e-02
+  1.980638202951e-01
+  5.756932684802e-02
+  6.601904337944e-02
+ -5.361862167600e-02
+ -4.058374114901e-02
+ -7.233611576006e-02
+ -7.833199987774e-02
+  4.480604221476e-03
+ -1.113003866166e-02
+  7.599339489396e-02
+ -1.243232876067e-01
+  2.990676181393e-02
+  4.510724284658e-02
+  9.252022249163e-02
+  8.123349120922e-02
+ -3.615597897538e-02
+ -4.510282900298e-02
+  2.280591231696e-01
+  1.314689285990e-01
+ -1.610932932954e-01
+  1.064094100414e-01
+  5.704984125760e-02
+  9.018207408962e-02
+  7.325409196257e-02
+  9.998910307365e-02
+  3.619981944722e-02
+  1.694790415045e-02
+  1.114755639902e-01
+  1.058813850803e-01
+ -1.446279810024e-01
+ -6.711826821080e-02
+  1.091146133157e-01
+ -5.857767402186e-02
+  2.945572553787e-01
+ -2.393935703253e-02
+  7.686152574274e-04
+ -6.669607834793e-02
+  4.455212370610e-02
+ -1.635675746878e-01
+ -5.591399637722e-02
+ -3.476907069370e-02
+  1.319682560722e-01
+ -1.547494653402e-01
+ -8.284609498476e-02
+  3.312835798122e-02
+  1.330726910962e-02
+ -8.242884320401e-02
+  1.745461728280e-01
+  1.650590282396e-01
+ -5.118879084944e-02
+ -6.256325654926e-02
+  1.746860812248e-02
+ -8.159346477016e-02
+  4.671279653163e-02
+ -6.323253641024e-02
+  1.180584690537e-01
+  7.001715352028e-02
+  9.323325491761e-02
+  5.380551272100e-02
+ -1.438699241973e-01
+ -1.791245875582e-01
+ -1.602892871375e-01
+ -9.584150226381e-02
+  9.195669208944e-02
+ -1.475621145483e-01
+ -5.210445757838e-02
+ -1.634487650377e-02
+  1.299322999907e-01
+  1.526999332688e-01
+ -6.303120863906e-02
+  1.054398846170e-01
+ -4.899855827922e-03
+  1.623627645556e-02
+  3.577180464784e-02
+ -9.020824528559e-02
+  1.319574717053e-01
+ -4.251470548301e-03
+ -5.883878135021e-02
+  4.438739923858e-02
+ -2.195387013683e-01
+ -1.291490065549e-01
+ -4.883310618606e-02
+  2.176849947432e-02
+  2.194026611367e-02
+  9.646614995373e-02
+ -1.902237127158e-02
+  1.284962088349e-01
+  2.891841201270e-02
+  3.595837070147e-02
+  1.188702993733e-01
+  7.213164763103e-04
+ -2.932252451064e-02
+  1.432179159296e-01
+  6.031540806576e-02
+  1.458005824878e-01
+  4.792862415044e-02
+ -6.676152243168e-02
+ -2.470698989566e-01
+ -7.363222170981e-02
+ -3.988491421394e-02
+  2.484366271835e-02
+ -1.138446833482e-01
+ -1.685596153012e-01
+  2.079995189641e-01
+ -4.855009214918e-02
+ -2.048020535011e-01
+  8.346644151193e-02
+  5.927808353419e-02
+  4.044818493898e-02
+  1.497445890913e-01
+ -9.861004313036e-02
+ -7.643117268579e-02
+  5.850410404520e-03
+ -1.183674817050e-01
+  4.451166928959e-02
+ -1.567706505874e-02
+  2.813901913634e-02
+ -1.878370191469e-01
+  4.883610523598e-02
+  2.233063011629e-02
+ -1.966325902431e-01
+  1.551141561275e-01
+  1.402292838947e-01
+ -1.077069376963e-01
+ -7.291705911994e-03
+  3.275910955071e-02
+  2.617382094254e-02
+ -6.410001307483e-02
+ -1.041185052069e-02
+ -1.141982826274e-01
+  1.360615452525e-01
+  1.053723085272e-01
+  1.805450922721e-01
+ -6.700956717298e-02
+ -2.341074788855e-01
+  9.785401706978e-02
+ -2.473036015758e-01
+ -1.249528165261e-01
+ -2.160595870176e-02
+  1.256173519594e-02
+  5.814008392174e-02
+  5.675864751575e-02
+ -4.626864304619e-02
+  6.720711914280e-02
+ -1.239053381293e-01
+ -2.170304999534e-02
+ -5.638839192192e-03
+  3.315264016324e-03
+  6.751155865413e-02
+  1.653729619733e-02
+  7.721590835054e-02
+ -7.540884358942e-02
+ -1.115331484166e-01
+  3.765509637463e-02
+ -2.374161259707e-02
+ -1.165409735671e-01
+ -4.372972347214e-02
+  9.562353394072e-02
+ -7.721396385954e-02
+  9.324150982525e-03
+ -6.234405313201e-02
+ -6.475707033236e-02
+ -1.539323314444e-02
+ -9.284000547072e-02
+  7.207458239733e-02
+  1.705427447954e-03
+  1.246028251012e-01
+  1.931294580849e-01
+ -1.758549673506e-01
+  5.272280662758e-02
+ -1.049417103994e-01
+  2.735229905006e-02
+ -1.764215528590e-02
+  1.504147595735e-01
+ -2.761945294569e-01
+ -2.445955653992e-01
+  2.519609259664e-01
+  1.189538405319e-02
+ -3.367006279624e-02
+  1.075321787591e-01
+  2.064947880847e-02
+  7.247261272229e-02
+  1.123677851845e-01
+  2.083712200745e-02
+ -2.057818444558e-03
+ -5.531466518464e-02
+  7.106849543253e-02
+  2.746669657001e-02
+ -5.590119962541e-02
+ -2.156937278547e-02
+  1.306395685325e-01
+  4.182472406510e-02
+  1.088735568569e-01
+  2.662933324350e-01
+ -5.082146764844e-02
+  9.401259254169e-02
+  1.365391772116e-01
+  1.549462895192e-01
+ -4.702348753413e-03
+  9.329274104774e-02
+  1.161832928090e-01
+ -9.603255151153e-02
+ -1.129075194273e-01
+  2.054238905224e-01
+  1.297284928657e-01
+ -2.382914444438e-02
+ -1.249572060675e-02
+ -2.586882567351e-01
+  5.769308175082e-03
+  1.089802513633e-01
+  2.701805417261e-02
+  1.019532633809e-01
+  1.314326220690e-01
+ -5.137315085548e-02
+ -3.131389361968e-02
+  5.581311708093e-02
+ -1.240869713999e-01
+  7.158658608732e-02
+  4.730287421602e-02
+  1.645937642215e-01
+  1.376831356215e-01
+ -4.777324689384e-02
+  1.516628147077e-01
+ -3.825907216772e-02
+  1.037680858424e-01
+  6.673204125843e-02
+ -5.716392726429e-02
+ -1.375181957056e-01
+  5.159509543369e-03
+ -5.077249582912e-02
+  5.575820429762e-02
+ -7.960449813638e-03
+ -8.061911140806e-02
+  3.841580797753e-02
+ -1.177551195550e-01
+  1.960962698821e-01
+ -4.271807645461e-02
+  3.153653540795e-01
+  1.197947552236e-01
+  2.991736652876e-02
+ -2.537308664525e-03
+  2.273591200871e-01
+  6.661768739403e-02
+ -2.722475627564e-02
+  9.576913986000e-02
+  3.767288434809e-02
+ -1.549413479942e-01
+ -1.948165853839e-02
+ -5.607988918634e-02
+ -3.489426995629e-02
+  1.095579833972e-02
+ -2.382126179401e-02
+ -4.088153966148e-02
+  5.927616755496e-02
+ -1.361509961690e-01
+ -3.688168945271e-02
+  2.244476548006e-01
+  2.448865716977e-02
+ -1.534434182441e-01
+ -1.123644355944e-02
+ -1.081125248530e-01
+ -7.728017311735e-02
+  5.303885746331e-02
+  1.134935234616e-01
+  3.826998554755e-02
+  1.087102276321e-01
+ -1.372572497087e-01
+  8.428373197702e-02
+  2.861972062493e-03
+  5.875192619230e-02
+ -3.006992578608e-02
+ -3.842155565264e-02
+ -2.206321373878e-01
+ -2.305915480006e-02
+  6.860519489685e-02
+  1.173960031111e-01
+ -5.837779625329e-02
+  7.532593077792e-02
+ -2.017088165022e-02
+ -4.926951983723e-02
+  5.931828908561e-02
+ -2.289536695772e-01
+ -2.493311664648e-02
+  2.469632479273e-02
+  1.349756842042e-01
+ -9.642652586367e-03
+  6.005021769797e-02
+  1.819975683517e-02
+ -6.976505128945e-03
+  1.533974932477e-04
+  2.537219784107e-01
+  3.110422512422e-02
+ -4.230181652384e-02
+ -9.565827246266e-02
+  1.492177437242e-01
+  6.984023010545e-02
+  6.206853434040e-02
+ -3.011022386632e-02
+ -7.175542382242e-02
+ -7.350980823589e-02
+  8.144192455422e-02
+  1.037755392575e-01
+  3.323803471447e-02
+  3.814308229558e-02
+  2.441557568558e-02
+ -2.906850975545e-02
+ -6.388829066494e-02
+  8.925260241830e-02
+  1.592647984588e-01
+ -1.765419558493e-01
+  8.171121307118e-02
+ -3.602771804684e-02
+  1.037227486967e-01
+ -5.497524048351e-02
+  9.038670181371e-02
+ -8.164413678059e-02
+  1.808583902729e-01
+ -1.172948965545e-01
+  4.325930183485e-02
+  2.417954656271e-02
+  1.040387444408e-02
+ -1.039390330867e-02
+  1.910089114640e-01
+  7.962695246954e-02
+ -2.001049704494e-02
+  1.197075359167e-02
+ -7.635055514595e-03
+ -9.546461521851e-02
+ -1.283873938723e-01
+ -9.923418013072e-02
+  3.933449796032e-02
+ -2.117361900236e-03
+  4.011829783890e-02
+  9.934220467484e-02
+  1.406631344680e-01
+ -6.691594698303e-02
+ -1.376370020200e-01
+ -3.253461995348e-02
+  6.224323544036e-02
+ -7.305096016638e-02
+  1.997810795045e-02
+ -1.463741803022e-01
+ -5.693300325729e-02
+  1.025533936031e-02
+ -1.930733433536e-02
+  1.582484934700e-01
+ -9.636587205513e-02
+  7.653357184307e-02
+  2.008579469252e-03
+ -4.090265619989e-02
+ -1.938853453510e-01
+  2.188445774258e-01
+  5.678961104527e-02
+  1.267534084926e-01
+  4.526172988462e-02
+  1.054066333027e-01
+ -6.014429781003e-02
+  3.546904697536e-02
+  9.017644202254e-02
+  1.888907395474e-02
+  1.396747639969e-01
+  1.108138443718e-01
+ -3.346405954223e-02
+  1.997862632439e-02
+  2.397268366191e-02
+ -1.426064643857e-01
+  7.859722514477e-02
+ -2.299483080019e-02
+  7.421749280979e-02
+ -6.512408992267e-02
+ -6.865565870621e-02
+  5.553448918958e-02
+ -1.401732545781e-02
+  5.594675664263e-03
+  5.686526109279e-02
+ -4.912577832055e-02
+ -2.572608283899e-02
+  1.291498064536e-01
+  1.193836729689e-01
+ -2.018904991678e-01
+  5.737707231572e-02
+  4.927491106909e-02
+  2.542862273289e-02
+ -9.225399585874e-02
+  3.262924962738e-02
+ -2.417563870905e-02
+ -1.129710873222e-01
+ -6.844821398650e-02
+ -9.582924044326e-03
+  1.343467409876e-01
+ -1.975054606991e-02
+ -1.928476281163e-01
+  1.181683223904e-01
+  3.895343130896e-02
+ -5.012772520223e-03
+  9.754028279099e-03
+ -2.529369367126e-02
+  1.613980460046e-02
+  5.985985637240e-02
+ -4.781663812600e-02
+ -1.588431457846e-01
+  5.012974954868e-03
+ -2.947114189109e-03
+ -9.168241034703e-02
+  9.076574246441e-02
+  9.514216523813e-02
+  8.475351775525e-02
+  1.611984320590e-01
+  1.826714776804e-01
+ -2.566736142059e-01
+ -2.278986273150e-02
+ -8.118461992082e-02
+  1.475019400713e-01
+  1.983572341965e-01
+ -2.918440293597e-02
+ -3.069479385333e-02
+  1.325816210531e-01
+ -4.743927527318e-02
+  2.479858730597e-01
+ -2.042249925019e-02
+  2.087913247600e-01
+  2.857671341609e-02
+  6.731544353304e-03
+ -9.251868560852e-02
+ -1.784188028041e-01
+  9.519184177592e-02
+ -3.756715355868e-02
+ -1.444824085309e-01
+ -6.943090586971e-02
+  1.618953978785e-01
+  5.123167959411e-02
+  1.721509107410e-01
+ -5.759228051690e-02
+  1.013109005939e-02
+ -8.141963423161e-02
+ -3.632780452189e-02
+ -7.589112995433e-02
+  1.326759715564e-01
+  2.045075172326e-01
+ -9.956456459030e-03
+  1.022747816926e-01
+ -1.871039890718e-03
+  1.564955862480e-01
+ -1.071876328013e-01
+ -4.042050034810e-03
+ -9.590258974922e-02
+  7.495458249381e-02
+  1.029818576899e-01
+  2.174640448362e-01
+ -6.779985409053e-02
+ -1.027720701069e-01
+ -6.120083458994e-02
+ -1.696389057860e-01
+  3.998904268582e-02
+ -1.723484912056e-02
+  9.131883445156e-02
+ -1.733645455398e-02
+  1.209077810140e-01
+ -4.940444678661e-02
+ -8.323221727888e-02
+  4.100531992960e-02
+ -6.808984088565e-02
+ -1.005639699421e-01
+ -1.033047089313e-01
+  9.348042677080e-02
+  1.529354772272e-01
+  1.697737399846e-01
+ -2.890098804993e-02
+  9.566707284564e-02
+  1.809394166783e-01
+  1.007953342619e-01
+ -1.740901925603e-01
+ -1.913369586243e-01
+ -8.662428268845e-02
+ -1.498819081459e-01
+  1.572234928810e-01
+  2.515650162592e-01
+ -3.695618673329e-02
+ -3.665054045573e-03
+  6.161153309501e-02
+ -1.417805334510e-02
+ -4.886968433062e-02
+  7.166020493727e-02
+ -6.182249183474e-02
+ -1.952637296296e-02
+  6.832147399638e-02
+ -1.450825694131e-01
+  1.091887427213e-01
+ -1.333388603580e-01
+ -3.166946399900e-02
+  1.244686473301e-02
+ -9.961196041286e-02
+  1.043351954765e-01
+ -9.967240345593e-02
+  1.470719171327e-01
+ -5.378916030868e-02
+ -1.782791737157e-02
+ -5.187614745791e-02
+ -4.840339150180e-02
+ -1.420396920515e-02
+  9.813293153037e-02
+ -3.378942454665e-01
+ -8.732412658973e-02
+  3.754711835853e-02
+ -1.814402859844e-03
+ -8.827328309558e-02
+ -5.292655431435e-02
+  1.146133035854e-01
+ -6.223692919236e-02
+ -8.783934066568e-02
+ -5.489912705136e-02
+ -6.924422626233e-02
+  1.032823897662e-01
+  2.599595966180e-02
+  8.716535099201e-02
+  9.543440938649e-02
+ -8.341625080744e-02
+  1.518277041655e-01
+  1.979549015134e-01
+ -1.050978575106e-01
+  2.269559605073e-01
+ -3.698339643991e-03
+  8.969322980162e-03
+  9.453094116194e-02
+ -7.765985839755e-02
+  3.978478372978e-02
+ -4.410831702283e-02
+ -1.513708462982e-01
+ -2.448999277854e-01
+  2.085009746986e-02
+  1.096452156974e-02
+  7.523580240624e-02
+  1.313866575908e-01
+  1.746937954422e-01
+  6.185224214792e-02
+  4.748642138867e-02
+ -6.478829286169e-02
+  9.083341250461e-02
+  1.056533599012e-01
+  7.233221542276e-02
+  1.913287693846e-01
+  2.518453515644e-02
+  1.545009459684e-01
+  1.061981099042e-01
+ -2.269597857477e-01
+ -1.116562708666e-01
+  1.080139159694e-01
+  8.874611228269e-02
+ -1.108394629764e-02
+ -9.187258131068e-02
+ -2.042535707414e-02
+  3.291107043022e-02
+  2.393817050065e-02
+  9.759379819095e-02
+  1.032858231207e-01
+ -7.782284923603e-02
+ -1.293493061635e-03
+  1.181059726762e-02
+  5.742442869591e-02
+  3.370532868639e-02
+ -6.883838686007e-02
+  4.805078436359e-02
+  5.578695381262e-03
+  4.556714657075e-02
+ -1.286337877829e-01
+  4.110163621623e-03
+ -2.381744334716e-02
+  1.190630972266e-01
+ -8.656178722285e-02
+ -1.204681440714e-01
+  1.825367737743e-02
+ -9.990528038546e-02
+ -9.857103707720e-02
+  2.119167546510e-02
+  1.615417479941e-01
+  2.013418610991e-02
+ -5.733016530551e-02
+  5.651815637363e-02
+  6.030412614712e-02
+ -4.813438974697e-02
+  4.015032972907e-02
+  6.091554091823e-02
+ -1.045531090866e-01
+ -1.878753333013e-01
+ -1.964477298034e-01
+ -1.444666271129e-01
+ -9.470109450114e-02
+  1.211990352716e-01
+  1.515832107111e-02
+  5.792033417868e-02
+  3.730348381967e-02
+  3.110041864298e-04
+  1.147016402438e-01
+  2.105364466103e-02
+  2.330073049336e-01
+ -3.193306311398e-02
+  3.287370296461e-02
+ -8.455627657981e-02
+  4.188135342541e-02
+ -5.083510909023e-02
+  1.076857795809e-01
+ -4.233462411254e-02
+  2.128039383152e-02
+ -1.027284844340e-02
+ -1.331872589965e-01
+  6.723565017816e-03
+ -7.971696406458e-03
+ -1.149948294851e-01
+  9.124284939794e-02
+  1.407196987440e-02
+  3.172296913142e-02
+ -2.402978676346e-02
+ -1.667011117246e-01
+ -3.030626959515e-02
+ -8.018074218156e-02
+  8.804889727240e-02
+  5.831040016030e-02
+  2.319171497068e-02
+ -2.184344614905e-02
+ -6.255825142168e-02
+  2.095700667757e-02
+  1.649117277874e-01
+ -7.772071400211e-02
+  4.775875096436e-02
+ -1.488617406269e-01
+  1.680752787141e-01
+  8.075964053392e-02
+ -3.887448476264e-02
+  7.532160582156e-02
+  1.479227768416e-02
+ -1.594704958891e-01
+  1.297028311044e-01
+  5.662337011236e-02
+ -2.453349162797e-02
+  4.777609107618e-02
+ -1.176124040261e-01
+  2.062594899983e-02
+ -1.981820266108e-02
+ -2.400868729640e-01
+  3.577852643563e-02
+ -2.430836423886e-02
+ -1.323217324148e-01
+  1.801569074389e-01
+ -2.493300346099e-01
+  1.142845557337e-01
+ -1.431901733835e-02
+ -1.190069383044e-01
+ -1.027324149350e-01
+  1.689415132136e-02
+  1.014759286704e-01
+ -1.808705060932e-02
+  1.458055296954e-01
+  2.036813547509e-01
+  4.439933580256e-02
+  6.248290355233e-02
+  1.068357940367e-01
+ -3.456961126647e-02
+ -1.547051138496e-02
+ -1.027814551341e-01
+  8.075044054321e-02
+ -1.085799705621e-01
+ -1.463992899759e-01
+  2.156455098937e-02
+  8.354857181523e-02
+ -9.586527047257e-03
+  8.836654576111e-02
+  3.469514342763e-03
+ -1.556723127812e-01
+  6.735240194191e-02
+ -1.317429529347e-01
+ -1.208125039152e-01
+  2.451253468374e-02
+ -9.233293701032e-03
+ -1.940018181718e-02
+ -1.467644492299e-01
+  1.861585764840e-02
+  2.446331173790e-02
+ -1.053597568800e-02
+  2.983858959486e-03
+ -1.518979542688e-01
+ -8.940566467617e-02
+ -1.112407162884e-02
+  8.780939283268e-02
+  1.049524750991e-01
+ -1.535825286261e-01
+ -1.896598930336e-02
+  1.522746959741e-01
+  3.159014633674e-03
+ -8.365007164216e-02
+  9.093110470308e-02
+ -1.950840862380e-01
+ -8.769365158681e-03
+ -1.297931224283e-01
+  5.146190910504e-02
+ -1.302518954753e-01
+  3.472063584833e-02
+  3.861592833170e-02
+  1.005931300190e-01
+ -5.531750181599e-02
+  5.894740926315e-02
+  1.860099224449e-01
+ -3.814793620896e-02
+  2.694446766867e-02
+  1.124395869769e-01
+ -5.672566093436e-03
+ -8.836121772076e-02
+ -5.249610649021e-02
+  5.946884557902e-02
+  9.861455905856e-02
+ -1.638064318995e-01
+ -1.671535410172e-01
+  5.145495991819e-02
+ -2.489643176518e-02
+ -7.755173856200e-02
+  5.539121204842e-02
+ -1.088853559253e-01
+  1.808656872760e-01
+ -1.971455703296e-02
+ -1.020176085821e-01
+  2.006996634270e-01
+ -9.067683961280e-02
+  4.969920789124e-02
+  3.080155713463e-02
+  1.191686679745e-01
+  1.165205175269e-01
+  3.108405029974e-02
+ -1.094377289713e-01
+ -1.672726817249e-01
+  2.135619986263e-02
+ -9.737513326549e-02
+  4.769949569921e-02
+ -1.055553681580e-01
+  5.703152731554e-02
+  6.424065751471e-02
+  2.498372279845e-02
+ -3.378216727648e-02
+ -1.033640384604e-02
+  1.299137715847e-01
+  6.822152111863e-02
+ -7.668086146756e-02
+  9.115906283763e-02
+  1.881982415976e-01
+  3.368249252927e-02
+ -9.823348415993e-03
+  3.980923250982e-02
+ -1.245922152649e-01
+  2.131648304441e-01
+  5.226602003030e-02
+ -5.837861887170e-02
+ -6.487609783455e-02
+ -1.919512368348e-02
+ -8.133066104792e-02
+  3.547605252898e-03
+ -1.106720938488e-01
+ -1.871368557574e-02
+ -1.842770313120e-01
+  9.617225499114e-02
+ -2.111125425210e-01
+  9.109663047669e-03
+  5.039645323915e-03
+  2.341519322035e-02
+ -5.981676480811e-02
+  1.002463764252e-01
+ -3.276374492812e-02
+  1.643025618119e-01
+  5.653134853580e-02
+ -1.511002782842e-01
+ -8.453263558197e-02
+ -2.723949735181e-02
+  1.125836653086e-01
+ -1.523357277779e-01
+  2.070693646370e-01
+  6.835438934773e-02
+  7.881720262539e-02
+ -1.539541224663e-02
+  4.159642975053e-02
+ -1.865507298804e-02
+ -7.093764504122e-02
+ -2.662586449155e-02
+  1.414631242161e-01
+ -1.005424728690e-01
+  7.123675748921e-02
+  1.682100949696e-01
+ -3.471581338236e-02
+  5.813865987401e-02
+ -4.916153982827e-02
+ -4.880030720494e-03
+ -1.457480038069e-01
+  7.976535457810e-03
+  1.253475738580e-01
+ -5.950342013338e-02
+ -3.237094291171e-05
+  8.550981545286e-02
+ -1.463479641640e-02
+  1.986751362596e-01
+  1.192295607533e-01
+ -5.335818527091e-02
+  2.526957626835e-02
+  1.275866023333e-01
+  1.668243730899e-02
+  9.377924824886e-02
+ -1.611200796457e-02
+  1.597140836697e-01
+ -4.141881559980e-02
+ -8.653257680590e-02
+ -2.319178095602e-03
+  1.343903830695e-01
+ -2.051419853007e-02
+ -7.526375431416e-02
+ -2.264001352260e-03
+  5.789596671731e-02
+ -6.633710916853e-02
+  1.185298734461e-01
+ -7.051860296513e-02
+ -4.696696669374e-02
+ -2.596787250342e-02
+ -1.263699092101e-01
+  3.126650579816e-02
+  2.099414949546e-01
+  9.509963770454e-02
+  9.002785201110e-03
+ -8.536760418363e-03
+  8.665059822081e-02
+  3.059282746295e-02
+ -7.689204066458e-02
+  3.498608218835e-02
+ -1.118777358689e-01
+  7.054957955444e-03
+  1.093133443072e-01
+  6.792197672413e-02

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,26 @@
+        25 
+             1    32.5925700  -116.1620000     0.0000000
+             2    32.9784200  -118.7711000     0.0000000
+             3    35.7330300  -116.5285000     0.0000000
+             4    35.0276600  -119.1860000     0.0000000
+             5    34.2858000  -117.9934000     0.0000000
+             6    34.1989600  -116.4294000     0.0000000
+             7    36.0179400  -117.8815000     0.0000000
+             8    34.3608000  -117.6680000     0.0000000
+             9    32.3382000  -117.9078000     0.0000000
+            10    33.6555700  -119.3447000     0.0000000
+            11    36.0047600  -119.9012000     0.0000000
+            12    34.5769100  -116.2734000     0.0000000
+            13    32.2582100  -115.2317000     0.0000000
+            14    34.2093600  -118.5359000     0.0000000
+            15    32.9882400  -117.8280000     0.0000000
+            16    32.8926400  -115.5177000     0.0000000
+            17    35.3981500  -118.6447000     0.0000000
+            18    34.9763800  -116.8185000     0.0000000
+            19    33.4957600  -116.4987000     0.0000000
+            20    34.4965500  -118.5412000     0.0000000
+            21    35.2236200  -118.0706000     0.0000000
+            22    33.6401100  -116.7143000     0.0000000
+            23    33.0636400  -116.8003000     0.0000000
+            24    33.3087500  -115.6841000     0.0000000
+            25    34.2001600  -116.8201000     0.0000000

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand10.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand10.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand10.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,11 @@
+        10 
+         1      1.271600036571e+04      7.277134479869e+04      0.000000000000e+00
+         2      3.949267559971e+04      7.750009191186e+04      0.000000000000e+00
+         3      4.242459005946e+04      5.900025169191e+04      0.000000000000e+00
+         4      5.848059125911e+04      7.240243464565e+04      0.000000000000e+00
+         5      9.941440399737e+04      7.580609474794e+04      0.000000000000e+00
+         6      1.210003998876e+05      6.468296752360e+04      0.000000000000e+00
+         7      1.440148135122e+05      7.014320612220e+04      0.000000000000e+00
+         8      1.460159969116e+05      5.502982087177e+04      0.000000000000e+00
+         9      1.590990612849e+05      7.758604090390e+04      0.000000000000e+00
+        10      1.928376347915e+05      6.448323123412e+04      0.000000000000e+00

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand15.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand15.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand15.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,16 @@
+        15 
+         1      2.859322586925e+04      6.622404336774e+04      0.000000000000e+00
+         2      4.048924614306e+04      6.492534468750e+04      0.000000000000e+00
+         3      5.412125074712e+04      6.099245613194e+04      0.000000000000e+00
+         4      5.618043055512e+04      7.760906451514e+04      0.000000000000e+00
+         5      9.415975900106e+04      7.721105310183e+04      0.000000000000e+00
+         6      1.180473925282e+05      7.681589837724e+04      0.000000000000e+00
+         7      1.323894192896e+05      6.538961502797e+04      0.000000000000e+00
+         8      1.332550438119e+05      6.262893873051e+04      0.000000000000e+00
+         9      1.601756996992e+05      5.517846771772e+04      0.000000000000e+00
+        10      2.297928699758e+05      5.881431910943e+04      0.000000000000e+00
+        11      2.707682177358e+05      7.404783874464e+04      0.000000000000e+00
+        12      3.270701775040e+05      6.979821699378e+04      0.000000000000e+00
+        13      3.365769045473e+05      6.241232898557e+04      0.000000000000e+00
+        14      3.456478860378e+05      5.560650002378e+04      0.000000000000e+00
+        15      3.899975030743e+05      6.317518708907e+04      0.000000000000e+00

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand20.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand20.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand20.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,21 @@
+        20 
+         1      3.104472522097e+04      6.079703648838e+04      0.000000000000e+00
+         2      2.395150866684e+05      7.104061958404e+04      0.000000000000e+00
+         3      7.968881497997e+04      6.734942668749e+04      0.000000000000e+00
+         4      3.371009534081e+05      5.744926570629e+04      0.000000000000e+00
+         5      3.821858757038e+05      5.841505685385e+04      0.000000000000e+00
+         6      3.865187807492e+05      6.033451258829e+04      0.000000000000e+00
+         7      2.490147113304e+05      6.334635764830e+04      0.000000000000e+00
+         8      2.399850227775e+05      6.704797568225e+04      0.000000000000e+00
+         9      1.282038883877e+05      7.456149068043e+04      0.000000000000e+00
+        10      1.910908243585e+05      6.715844774353e+04      0.000000000000e+00
+        11      2.841463716857e+05      5.771312236034e+04      0.000000000000e+00
+        12      1.506069393427e+05      7.219563449265e+04      0.000000000000e+00
+        13      2.022193672690e+05      7.190394047522e+04      0.000000000000e+00
+        14      1.767559750135e+05      7.153249329372e+04      0.000000000000e+00
+        15      1.166443938551e+05      6.374514187531e+04      0.000000000000e+00
+        16      3.491071047360e+05      6.868878925926e+04      0.000000000000e+00
+        17      2.530517225173e+05      7.250694793697e+04      0.000000000000e+00
+        18      2.228529075336e+05      7.590105063165e+04      0.000000000000e+00
+        19      2.542870317886e+04      5.828481490287e+04      0.000000000000e+00
+        20      8.215179594613e+04      5.666913844248e+04      0.000000000000e+00

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_1D_rand25.dat
===================================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N025.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N025.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N025.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,26 @@
+        25 
+             1  -116.1620000    32.5850000     0.0000000
+             2  -118.7910000    32.9750000     0.0000000
+             3  -116.5260000    35.7470000     0.0000000
+             4  -119.1780000    35.0270000     0.0000000
+             5  -117.9930000    34.2700000     0.0000000
+             6  -116.4370000    34.2000000     0.0000000
+             7  -117.8740000    36.0160000     0.0000000
+             8  -117.6480000    34.3740000     0.0000000
+             9  -117.9180000    32.3290000     0.0000000
+            10  -119.3300000    33.6660000     0.0000000
+            11  -119.9170000    35.9990000     0.0000000
+            12  -116.2710000    34.5940000     0.0000000
+            13  -115.2330000    32.2720000     0.0000000
+            14  -118.5370000    34.2130000     0.0000000
+            15  -117.8180000    32.9850000     0.0000000
+            16  -115.5020000    32.8960000     0.0000000
+            17  -118.6240000    35.3900000     0.0000000
+            18  -116.8190000    34.9710000     0.0000000
+            19  -116.5140000    33.5080000     0.0000000
+            20  -118.5560000    34.4970000     0.0000000
+            21  -118.0670000    35.2100000     0.0000000
+            22  -116.7170000    33.6320000     0.0000000
+            23  -116.8030000    33.0700000     0.0000000
+            24  -115.7000000    33.3170000     0.0000000
+            25  -116.8270000    34.2030000     0.0000000

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N034.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N034.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_N034.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,35 @@
+        34 
+             1   -120.0220000     34.3950000      4.4000000  
+             2   -116.1620000     32.5850000      4.1500000  
+             3   -118.7910000     32.9750000      4.3000000  
+             4   -116.5260000     35.7470000      4.3400000  
+             5   -119.1780000     35.0270000      5.1500000  
+             6   -117.8740000     36.0160000      5.1000000  
+             7   -117.9930000     34.2700000      5.8000000  
+             8   -117.9180000     32.3290000      5.2700000  
+             9   -116.8190000     34.9710000      5.2600000  
+            10   -116.5140000     33.5080000      5.0900000  
+            11   -118.5370000     34.2130000      6.7000000  
+            12   -116.4370000     34.2000000      7.3000000  
+            13   -116.2710000     34.5940000      7.1000000  
+            14   -119.3300000     33.6660000      4.6000000  
+            15   -118.0670000     35.2100000      5.6700000  
+            16   -118.6240000     35.3900000      5.0400000  
+            17   -116.8030000     33.0700000      4.2700000  
+            18   -119.9170000     35.9990000      4.2300000  
+            19   -115.7000000     33.3170000      4.1100000  
+            20   -116.8270000     34.2030000      6.3000000  
+            21   -117.6480000     34.3740000      4.4000000  
+            22   -117.8180000     32.9850000      4.2700000  
+            23   -120.4760000     35.9120000      4.8800000  
+            24   -118.5560000     34.4970000      4.1300000  
+            25   -117.3840000     32.0160000      4.0600000  
+            26   -116.7170000     33.6320000      4.1500000  
+            27   -121.4520000     35.8100000      5.0100000  
+            28   -115.0100000     32.0040000      4.8900000  
+            29   -114.8840000     32.2780000      4.0600000  
+            30   -115.5020000     32.8960000      4.1100000  
+            31   -115.2330000     32.2720000      4.8000000  
+            32   -116.3350000     36.6940000      4.8700000  
+            33   -120.0740000     36.4200000      4.0300000  
+            34   -116.9030000     36.4860000      4.0400000  

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,26 @@
+        25 
+             1  -116.1620000    32.5925700     0.0000000
+             2  -118.7711000    32.9784200     0.0000000
+             3  -116.5285000    35.7330300     0.0000000
+             4  -119.1860000    35.0276600     0.0000000
+             5  -117.9934000    34.2858000     0.0000000
+             6  -116.4294000    34.1989600     0.0000000
+             7  -117.8815000    36.0179400     0.0000000
+             8  -117.6680000    34.3608000     0.0000000
+             9  -117.9078000    32.3382000     0.0000000
+            10  -119.3447000    33.6555700     0.0000000
+            11  -119.9012000    36.0047600     0.0000000
+            12  -116.2734000    34.5769100     0.0000000
+            13  -115.2317000    32.2582100     0.0000000
+            14  -118.5359000    34.2093600     0.0000000
+            15  -117.8280000    32.9882400     0.0000000
+            16  -115.5177000    32.8926400     0.0000000
+            17  -118.6447000    35.3981500     0.0000000
+            18  -116.8185000    34.9763800     0.0000000
+            19  -116.4987000    33.4957600     0.0000000
+            20  -118.5412000    34.4965500     0.0000000
+            21  -118.0706000    35.2236200     0.0000000
+            22  -116.7143000    33.6401100     0.0000000
+            23  -116.8003000    33.0636400     0.0000000
+            24  -115.6841000    33.3087500     0.0000000
+            25  -116.8201000    34.2001600     0.0000000

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_02.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_02.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_02.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,26 @@
+        25 
+             1  -116.1686627    32.6096582     0.0000000
+             2  -118.7497905    32.9804118     0.0000000
+             3  -116.5421945    35.7188909     0.0000000
+             4  -119.1839126    35.0097550     0.0000000
+             5  -118.0073952    34.2995776     0.0000000
+             6  -116.4511222    34.1998139     0.0000000
+             7  -117.8752363    36.0006820     0.0000000
+             8  -117.6652411    34.3786417     0.0000000
+             9  -117.9271659    32.3456704     0.0000000
+            10  -119.3373110    33.6386681     0.0000000
+            11  -119.8935972    35.9878580     0.0000000
+            12  -116.2840230    34.5926270     0.0000000
+            13  -115.2523707    32.2624488     0.0000000
+            14  -118.5235690    34.1945444     0.0000000
+            15  -117.8359713    33.0049378     0.0000000
+            16  -115.5281163    32.9083570     0.0000000
+            17  -118.6333677    35.3827174     0.0000000
+            18  -116.8326122    34.9901576     0.0000000
+            19  -116.4906823    33.5124578     0.0000000
+            20  -118.5238356    34.4856560     0.0000000
+            21  -118.0906299    35.2310902     0.0000000
+            22  -116.7129295    33.6580602     0.0000000
+            23  -116.7836403    33.0749803     0.0000000
+            24  -115.6635473    33.3140888     0.0000000
+            25  -116.7993325    34.2054988     0.0000000

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_05.dat
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_05.dat	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_quakes_v02_pert_05.dat	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,26 @@
+        25 
+             1  -116.1502476    32.5487082     0.0000000
+             2  -118.7861943    32.9352745     0.0000000
+             3  -116.5490987    35.7747733     0.0000000
+             4  -119.1402958    35.0027438     0.0000000
+             5  -117.9625527    34.2487586     0.0000000
+             6  -116.3780325    34.1842423     0.0000000
+             7  -117.8529567    35.9793565     0.0000000
+             8  -117.6146892    34.3515791     0.0000000
+             9  -117.8749143    32.3028500     0.0000000
+            10  -119.3464131    33.6106265     0.0000000
+            11  -119.8514093    35.9847818     0.0000000
+            12  -116.2382812    34.6113510     0.0000000
+            13  -115.2707738    32.2887139     0.0000000
+            14  -118.5324496    34.2542355     0.0000000
+            15  -117.8744147    32.9657484     0.0000000
+            16  -115.5707019    32.8862295     0.0000000
+            17  -118.5907123    35.3889286     0.0000000
+            18  -116.7637974    34.9728042     0.0000000
+            19  -116.5506640    33.4837669     0.0000000
+            20  -118.5942287    34.5071397     0.0000000
+            21  -118.0740931    35.2684955     0.0000000
+            22  -116.7057706    33.5957085     0.0000000
+            23  -116.8321254    33.0998458     0.0000000
+            24  -115.6689489    33.2656044     0.0000000
+            25  -116.8708968    34.2161973     0.0000000

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_sources.txt
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_sources.txt	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/INPUT/socal_sources.txt	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,521 @@
+1990/08/05 21:27:03.79 le 4.11 l    33.325 -116.414   5.2 A  1061283   58  261
+1990/08/31 01:05:49.03 le 4.08 l    33.244 -116.045   8.8 A  2003772   49  291
+1990/08/31 03:38:00.01 le 4.49 l    33.247 -116.049   8.1 A  2003785   56  293
+1990/12/18 16:56:43.09 le 4.25 l    35.374 -118.846   6.0 B   688784  106  257
+1991/02/04 16:38:32.31 le 4.26 l    36.107 -121.874   6.0 D  2011726   33  216
+1991/06/28 14:43:54.66 le 5.80 w    34.270 -117.993   9.2 A  2021449  157  295
+1991/06/28 17:00:55.56 le 4.30 l    34.253 -117.992   9.5 A  2021473  120  295
+1991/06/29 17:53:52.05 le 4.09 l    34.908 -116.579   6.0 C  2021565   52  295
+1991/07/05 17:41:57.12 le 4.13 l    34.497 -118.556  10.9 A  2022113  132  296
+1991/07/19 02:41:36.81 le 4.12 l    33.212 -115.968   3.1 A   697556   63  260
+1991/09/17 21:10:28.16 le 5.01 l    35.810 -121.452   6.0 D  2029412   62  294
+1991/10/12 14:39:32.10 le 4.01 l    33.890 -116.164   2.9 A   751510   71  263
+1991/12/04 07:10:57.59 le 4.27 l    33.070 -116.803  14.9 A  2036037  160  295
+1991/12/04 08:17:03.51 le 4.09 l    34.178 -117.022  10.7 A  2036038  152  295
+1991/12/20 10:38:29.38 le 4.15 l    35.535 -117.371   7.9 A  2037403   99  294
+1992/02/19 11:19:24.87 le 4.06 l    36.026 -117.889   2.9 A  2042321  103  294
+1992/03/04 19:06:26.95 le 4.30 l    32.975 -118.791   6.0 C  3007288  129  306
+1992/04/23 02:25:29.87 le 4.54 l    33.956 -116.317  11.5 A  2047709  121  292
+1992/04/23 04:50:23.23 le 6.10 w    33.960 -116.317  12.3 A  3019681  152  293
+1992/04/23 04:54:14.59 le 4.15 c    33.949 -116.320   6.8 A  3027817   49  293
+1992/04/23 05:10:10.39 le 4.56 c    34.010 -116.324   3.0 A  2047719  113  237
+1992/04/23 05:10:28.09 le 4.30 c    33.958 -116.330   3.2 A  3027826   33  237
+1992/04/23 05:23:16.19 le 4.01 c    33.943 -116.325   5.3 A  3017236   36  278
+1992/04/23 13:35:57.46 le 4.14 c    33.942 -116.312   1.1 A  3017852   65  293
+1992/04/23 18:56:03.02 le 4.24 c    33.991 -116.284   3.5 A  3027819  153  293
+1992/04/26 06:26:08.12 le 4.47 c    33.947 -116.301   3.1 A  2048693  163  310
+1992/04/26 17:21:38.01 le 4.42 c    34.049 -116.335   0.7 A  2048832  145  292
+1992/04/27 03:11:19.29 le 4.35 c    33.933 -116.302   0.0 A  2048937   87  313
+1992/04/28 11:33:26.63 le 4.09 c    33.938 -116.298   0.0 A  3020731   96  316
+1992/05/02 12:46:41.42 le 4.18 l    33.989 -116.287   4.0 A  2050243   87  325
+1992/05/02 12:46:53.29 le 4.10 h    33.994 -116.277   8.0 A 12178263   12  325
+1992/05/04 01:16:02.56 le 4.19 l    33.939 -116.341   5.8 A  2050538   97  331
+1992/05/04 16:19:49.72 le 4.98 l    33.941 -116.304  12.4 A  2050647  106  334
+1992/05/06 02:38:43.35 le 4.83 l    33.943 -116.314   6.8 A  2050937  125  335
+1992/05/12 02:31:11.01 le 4.38 l    33.981 -116.260   6.7 A  2051863   96  293
+1992/05/12 02:31:27.94 le 4.44 l    33.979 -116.259   0.2 A  3024922   23  344
+1992/05/18 15:44:17.97 le 4.96 l    33.951 -116.337   6.6 A  2052730  138  336
+1992/06/11 00:24:19.18 le 4.34 l    34.174 -116.350   0.8 A  2055346  101  294
+1992/06/28 11:57:34.13 le 7.30 w    34.200 -116.437   1.0 A  3031111  110  278
+1992/06/28 12:00:44.00 le 5.77 l    34.131 -116.408   0.0 B  3043549   13  296
+1992/06/28 12:01:16.19 le 5.70 l    34.120 -116.323   6.0 C  3043630    9  296
+1992/06/28 12:02:16.96 le 5.00 h    34.060 -116.473   6.0 C 12178451    5  296
+1992/06/28 12:02:31.08 le 5.00 h    34.103 -116.425   6.0 D 12178455    8    0
+1992/06/28 12:02:58.61 le 4.50 h    34.151 -116.355   6.0 C 12178459    7    0
+1992/06/28 12:17:49.55 le 4.64 c    34.513 -116.628   5.5 C  2056973   57  266
+1992/06/28 12:20:45.28 le 4.00 h    34.592 -116.666   0.1 B 12178467   13  266
+1992/06/28 12:25:54.89 le 4.29 c    34.937 -116.846   0.0 C  3031163   28   97
+1992/06/28 12:27:38.78 le 4.20 h    34.478 -116.639   6.0 D  3031160   21   77
+1992/06/28 12:36:40.77 le 5.49 l    34.115 -116.426   8.3 B  2056979   32  179
+1992/06/28 12:40:53.57 le 5.41 l    34.341 -116.511   6.0 C  2056980   25  171
+1992/06/28 12:43:58.99 le 4.44 l    34.113 -116.427   3.0 A  3031099   59  222
+1992/06/28 12:56:09.81 le 4.29 l    34.476 -116.520   6.0 C  2056982   12   24
+1992/06/28 13:06:40.84 le 4.00 h    34.361 -116.483   6.0 C  3031101   17  223
+1992/06/28 13:06:48.75 le 4.30 h    33.873 -116.336   9.8 C 12178475   14  223
+1992/06/28 13:10:50.21 le 4.87 l    34.418 -116.441   6.0 C  2056985   41  234
+1992/06/28 13:17:48.04 le 4.11 l    34.137 -116.415   8.0 B  3031104   19  111
+1992/06/28 13:18:15.94 le 4.50 l    34.093 -116.391   0.0 A  3055321   42  296
+1992/06/28 13:26:05.20 le 4.88 l    34.160 -116.407   6.0 C  2056989   96  237
+1992/06/28 13:28:21.60 le 4.65 l    36.587 -116.904   6.0 D  3031875   21  296
+1992/06/28 13:35:38.28 le 4.01 c    33.971 -116.512   6.0 D  3031106   12   23
+1992/06/28 13:36:00.36 le 4.24 c    34.419 -116.476   6.0 D  3031107   12   45
+1992/06/28 13:40:55.84 le 4.17 l    34.178 -116.451   6.0 C  2056995   27   89
+1992/06/28 13:50:16.34 le 4.22 l    34.084 -116.357   6.0 C  2056998  110  250
+1992/06/28 13:50:46.16 le 4.95 l    34.109 -116.403   6.0 C  3031243   36  250
+1992/06/28 13:51:43.27 le 4.00 h    34.140 -116.471   6.0 C 12178491   14  250
+1992/06/28 14:09:28.82 le 4.14 l    34.111 -116.646   6.0 C  2057003   75  185
+1992/06/28 14:29:02.39 le 4.03 l    34.610 -116.642   6.0 C  2057004   66  205
+1992/06/28 14:39:06.91 le 4.35 l    34.089 -116.425   0.2 A  2057007  129  274
+1992/06/28 14:43:21.85 le 5.53 l    34.162 -116.852  11.1 B  2057008   52   98
+1992/06/28 15:04:51.50 le 4.54 l    34.160 -116.825  13.3 A  2057011  115  294
+1992/06/28 15:05:30.73 le 6.30 w    34.203 -116.827   5.4 C  3031425   39  294
+1992/06/28 15:15:33.73 le 4.05 c    34.161 -116.853   6.0 C  3031128   23  127
+1992/06/28 15:17:10.39 le 4.00 h    34.170 -116.860   4.7 C 12178563   20  296
+1992/06/28 15:17:14.01 le 4.66 l    34.111 -116.875   4.9 C  3037203   22  296
+1992/06/28 15:18:33.19 le 4.58 l    34.203 -116.758   8.8 C  3031129   22  296
+1992/06/28 15:20:16.90 le 4.00 h    34.054 -116.401   3.8 B 12178567   13  296
+1992/06/28 15:24:29.43 le 4.76 l    34.201 -116.751   6.0 C  3031134   82  231
+1992/06/28 15:25:20.30 le 4.27 l    34.202 -116.798   6.0 C  3031248   22  231
+1992/06/28 15:45:54.73 le 4.00 c    34.108 -116.405   6.0 C  3066232   18  138
+1992/06/28 15:45:54.90 le 4.18 l    34.066 -116.401   0.1 B  3045923   60  296
+1992/06/28 15:53:14.13 le 4.15 l    34.217 -116.733   0.0 A  3031137   52  203
+1992/06/28 15:56:11.69 le 4.01 l    34.218 -116.751   1.4 A  3045876  114  296
+1992/06/28 16:01:15.21 le 4.33 l    34.035 -116.376   2.3 C  3031140   32  149
+1992/06/28 16:08:37.58 le 4.18 l    34.219 -116.754   4.9 A  3031141   85  296
+1992/06/28 16:09:53.82 le 4.21 l    34.047 -116.371   0.8 A  3031690   88  296
+1992/06/28 16:10:26.08 le 4.20 h    34.177 -116.836   2.6 A 12178595   15  296
+1992/06/28 16:17:19.34 le 4.24 l    34.208 -116.756   6.0 C  3031142   61  246
+1992/06/28 16:32:10.63 le 4.34 l    34.595 -116.622   6.0 C  3031146   73  296
+1992/06/28 16:33:08.87 le 4.12 l    34.590 -116.640   6.0 C  3031747   76  296
+1992/06/28 17:01:32.01 le 4.98 l    34.179 -116.925  10.8 A  3031154   67  296
+1992/06/28 17:05:57.56 le 5.26 l    34.255 -116.912   7.7 A  3031157  102  296
+1992/06/28 17:16:35.22 le 4.34 l    35.747 -116.526   6.0 D  3031164   22  132
+1992/06/28 17:18:30.01 le 4.19 l    34.183 -116.808   7.3 A  3031166   58  286
+1992/06/28 17:18:42.16 le 4.10 c    34.249 -116.782   0.0 B  3031289   20  286
+1992/06/28 17:21:27.31 le 4.16 l    34.225 -116.862   1.4 A  3031168   73  284
+1992/06/28 17:31:21.51 le 4.14 l    34.289 -116.444   8.8 A  3031170   66  296
+1992/06/28 17:39:52.04 le 4.04 l    34.360 -116.472   6.0 C  3031171   36  244
+1992/06/28 17:48:32.37 le 4.46 l    34.218 -116.751   1.2 A  3031176   79  296
+1992/06/28 19:26:37.56 le 4.17 l    34.183 -116.802   1.0 A  3031208   77  296
+1992/06/28 20:51:32.04 le 4.12 l    34.197 -116.782  10.0 A  3031235   59  296
+1992/06/28 21:13:16.47 le 4.67 l    34.095 -116.427   3.8 A  3031245   76  296
+1992/06/28 22:13:12.09 le 4.01 l    34.045 -116.353  10.3 A  2057138   79  294
+1992/06/28 22:48:22.85 le 4.18 l    34.138 -116.454  13.4 A  3031284   54  296
+1992/06/29 00:39:40.78 le 4.03 l    34.101 -116.377   2.9 A  3068585   74  293
+1992/06/29 01:18:13.40 le 4.67 l    35.160 -117.362   4.2 A  3040295   28  296
+1992/06/29 01:26:15.67 le 4.12 l    35.156 -117.351   5.5 C  2057196   68  214
+1992/06/29 03:01:56.47 le 4.49 l    34.223 -116.441   8.4 A  3031947   80  296
+1992/06/29 03:36:26.79 le 4.15 l    35.362 -116.800  10.8 A  3031954   53  296
+1992/06/29 04:16:42.61 le 4.12 l    35.016 -117.203   3.5 A  3031395   52  197
+1992/06/29 10:02:38.24 le 4.22 l    34.983 -116.935   0.4 A  3031965  132  296
+1992/06/29 11:07:06.57 le 4.17 l    34.498 -116.531   0.8 B  3101481   73  296
+1992/06/29 11:13:18.78 le 4.00 l    34.242 -116.731   8.4 A  3031559  119  296
+1992/06/29 11:44:56.82 le 4.47 l    34.601 -116.615   6.0 C  3101638   79  296
+1992/06/29 13:20:03.59 le 4.22 l    34.642 -116.488   6.0 C  3032289   65  296
+1992/06/29 14:08:37.73 le 5.69 l    34.105 -116.403  10.3 A  3031935   96  296
+1992/06/29 14:12:06.32 le 4.18 l    34.104 -116.400   7.1 B  3031936   66  296
+1992/06/29 14:13:38.77 le 5.08 c    34.105 -116.390  11.7 A  3031615  102  296
+1992/06/29 14:31:30.36 le 4.64 l    34.081 -116.386   4.9 A  3031618   43  296
+1992/06/29 14:41:26.04 le 4.59 l    34.111 -116.997   4.8 A  3031622   66  296
+1992/06/29 14:54:06.87 le 4.24 l    34.103 -116.418   3.7 A  3031625   51  296
+1992/06/29 16:01:42.79 le 4.83 l    33.873 -116.268   1.1 A  3031649   73  223
+1992/06/29 16:25:29.55 le 4.25 l    34.080 -116.426   1.0 A  3031661   69  296
+1992/06/29 16:41:41.93 le 4.64 l    34.249 -116.719   1.6 A  3031666   90  296
+1992/06/29 20:07:35.45 le 4.08 l    33.889 -116.289   2.5 A  3031728   81  296
+1992/06/29 20:44:25.75 le 4.36 l    34.657 -116.702   2.3 C  3031740   37  296
+1992/06/30 00:06:08.62 le 4.43 l    34.127 -116.403   3.0 A  3031817   30   72
+1992/06/30 02:32:12.22 le 4.08 l    35.165 -117.351   4.9 A  3042717   98  303
+1992/06/30 11:30:29.12 le 4.49 l    34.097 -116.404  12.9 A  3041864  184  342
+1992/06/30 12:14:49.63 le 4.27 l    34.091 -116.402  13.0 A  3032109  184  339
+1992/06/30 12:34:54.53 le 4.32 l    34.323 -116.442   7.5 A  3032116  103  339
+1992/06/30 13:05:36.49 le 4.59 l    35.679 -117.624   3.6 A  3032127   96  303
+1992/06/30 14:38:11.72 le 4.99 l    33.997 -116.356   1.9 A  3032166  101  336
+1992/06/30 15:19:05.17 le 4.21 l    34.170 -116.403   2.4 A  3032189  118  336
+1992/06/30 15:20:08.27 le 4.18 h    34.268 -116.740   0.0 A 12180487   63  336
+1992/06/30 17:14:21.51 le 4.20 l    34.068 -116.357   6.3 A  3032243  133  321
+1992/06/30 17:26:30.07 le 4.47 l    34.644 -116.656   4.3 A  3032246  104  327
+1992/06/30 20:00:25.93 le 4.29 l    34.642 -116.656   7.0 A  3032337   99  330
+1992/06/30 20:05:06.62 le 4.11 l    33.979 -116.360   0.3 A  3032338   92  315
+1992/06/30 21:22:54.43 le 4.85 l    34.130 -116.724  13.6 A  3038550  191  351
+1992/06/30 21:49:00.39 le 4.48 l    34.078 -116.987   4.6 A  3032368  148  327
+1992/07/01 06:16:56.64 le 4.51 l    35.677 -117.608   3.2 A  3032594   70  296
+1992/07/01 07:01:49.19 le 4.41 l    34.097 -116.383   0.0 A  3032618   87  330
+1992/07/01 07:40:29.90 le 5.34 l    34.330 -116.464   6.0 C  3032643  124  372
+1992/07/01 10:29:47.67 le 4.19 l    34.969 -116.939   0.3 A  3032715   91  326
+1992/07/01 10:32:52.26 le 4.33 l    34.973 -116.936   0.2 A  3032953   77  323
+1992/07/01 17:07:15.08 le 4.18 l    34.274 -116.692   4.7 A  3032928   86  342
+1992/07/01 17:45:46.85 le 4.42 l    34.280 -116.689   5.9 B  3032948  115  332
+1992/07/01 20:46:17.80 le 4.24 l    34.276 -116.729   0.7 A  3033670   95  347
+1992/07/01 20:53:56.75 le 4.03 l    34.281 -116.731   1.3 A  3033016   79  327
+1992/07/02 07:01:04.78 le 4.11 l    35.682 -117.614   4.8 A  3033295   61  296
+1992/07/02 13:59:20.98 le 4.15 c    35.615 -121.242   6.0 D  3033485   22  296
+1992/07/02 22:25:28.97 le 4.17 l    35.673 -117.619   3.8 A  3033740   59  323
+1992/07/03 04:15:50.38 le 4.08 l    34.210 -116.771  10.6 A  3033884  109  377
+1992/07/03 17:17:06.41 le 4.10 l    34.262 -116.896   7.6 A  3034125  138  353
+1992/07/05 05:49:38.16 le 4.07 l    33.945 -116.399   3.2 A  3034959  105  365
+1992/07/05 10:55:43.29 le 4.56 l    35.030 -116.968   0.8 A  3035113  113  353
+1992/07/05 20:03:03.10 le 4.06 l    34.298 -116.805   3.1 A  3035325  100  353
+1992/07/05 21:18:27.60 le 5.42 l    34.583 -116.322   6.0 C  3035348  122  374
+1992/07/05 22:33:46.04 le 4.43 l    34.585 -116.301   6.0 C  3035375   75  350
+1992/07/06 12:00:59.19 le 4.43 l    34.092 -116.370   1.7 A  3035697   94  359
+1992/07/06 18:06:36.31 le 4.26 l    34.457 -116.477   0.4 A  3036655   38  350
+1992/07/06 19:41:37.89 le 4.44 l    34.082 -116.379   3.2 A  3036688  100  353
+1992/07/07 08:21:03.14 le 4.14 l    34.069 -116.382   3.2 A  3036970   97  356
+1992/07/07 22:09:28.33 le 4.42 l    34.342 -116.468   2.5 A  3037284   83  347
+1992/07/08 02:23:11.33 le 4.91 l    34.575 -116.336   6.0 C  3038139  121  338
+1992/07/08 08:05:38.73 le 4.32 l    34.604 -116.351  10.4 A  3038252   76  296
+1992/07/09 01:43:57.61 le 4.87 l    34.239 -116.837   0.0 A  3039881  144  347
+1992/07/09 02:34:35.04 le 4.17 l    34.225 -116.844   0.5 A  3039891  111  296
+1992/07/09 02:34:36.41 le 4.50 c    34.141 -116.423   0.0 A  3040289   20  296
+1992/07/09 02:56:50.57 le 4.15 c    34.226 -116.847   0.3 A  3039899   71  296
+1992/07/09 06:05:36.76 le 4.29 c    34.233 -116.827   0.0 A  3040184   46  274
+1992/07/09 12:23:17.83 le 4.18 l    34.217 -116.809   1.2 A  3040107   38  347
+1992/07/10 01:29:39.00 le 4.22 l    34.232 -116.846   0.4 A  3040406  118  362
+1992/07/10 02:41:14.38 le 4.00 l    34.120 -116.394   3.4 A  3108718   71  364
+1992/07/11 18:14:16.16 le 5.67 l    35.210 -118.067  10.7 A  3041390   83  365
+1992/07/15 01:05:09.35 le 4.49 c    35.767 -117.720   7.8 B  3042775   15  296
+1992/07/19 10:00:20.89 le 4.76 c    33.882 -116.238   4.7 A  2194789   13   51
+1992/07/20 04:08:23.02 le 4.14 l    34.195 -116.431   6.0 C  3044893   61  371
+1992/07/20 04:48:01.51 le 4.55 l    34.970 -116.939   4.5 A  3044898   71  353
+1992/07/20 13:13:19.42 le 4.68 l    34.991 -116.948   0.0 A  3045013   90  359
+1992/07/21 21:10:29.02 le 4.00 l    34.219 -116.771   1.7 A  3045519  103  347
+1992/07/21 23:22:10.15 le 4.11 l    34.133 -116.603   1.6 A  3045548   88  356
+1992/07/24 18:14:36.25 le 4.96 l    33.901 -116.285   8.2 A  3046661  170  350
+1992/07/25 04:31:59.93 le 4.83 l    33.937 -116.306   4.7 A  3046818  139  338
+1992/07/27 20:40:08.78 le 4.03 l    32.610 -115.627  15.9 A  3047812   64  296
+1992/07/27 22:10:59.68 le 4.03 l    36.088 -117.672   1.2 A  3047839   65  296
+1992/07/28 07:30:18.19 le 4.76 c    34.915 -116.933   0.0 B  3206602   11  296
+1992/07/28 18:27:03.90 le 4.60 l    34.112 -116.415   0.0 A  3048163  143  296
+1992/08/04 19:06:12.29 le 4.00 l    34.102 -116.384   0.0 A  3050647   75  329
+1992/08/05 15:41:54.37 le 4.09 l    34.646 -116.530   4.2 A  3051552   82  338
+1992/08/05 22:22:40.82 le 4.79 l    34.979 -116.952   0.0 A  3051065  120  326
+1992/08/06 16:50:59.98 le 4.13 l    35.025 -116.968   4.8 A  3051305  109  326
+1992/08/08 15:37:43.34 le 4.57 l    34.376 -116.459   2.8 A  3052180   81  323
+1992/08/11 06:11:17.25 le 4.30 l    34.060 -116.374   0.7 A  3052987  100  326
+1992/08/12 07:37:33.93 le 4.70 n    34.420 -116.469   6.0 C  3208955    5   43
+1992/08/15 08:24:14.66 le 4.73 l    34.087 -116.403   0.4 A  3054293   76  317
+1992/08/17 20:41:52.12 le 5.23 l    34.195 -116.863  11.3 A  3055028  141  320
+1992/08/18 09:46:40.73 le 4.14 l    34.197 -116.862  12.2 A  3055197  138  317
+1992/08/20 12:36:46.73 le 4.23 d    34.569 -116.319   6.0 C  3056124   17  296
+1992/08/23 06:40:44.48 le 4.11 l    35.032 -116.990   3.9 A  3056509  146  296
+1992/08/24 13:51:46.04 le 4.29 l    34.274 -116.774   1.8 A  3056815  110  296
+1992/08/29 21:30:30.46 le 4.08 c    32.242 -115.253   6.0 C  3058674   18  296
+1992/08/31 09:25:40.63 le 4.36 l    34.455 -116.470  11.0 A  3058571   84  296
+1992/09/09 11:44:55.00 le 4.24 l    35.076 -116.997   0.4 A  3060924   94  296
+1992/09/09 12:50:45.14 le 4.32 l    33.947 -116.330   5.2 A  3060932   79  296
+1992/09/13 11:46:19.98 le 4.42 l    36.741 -116.197   6.0 D  3061997   35  296
+1992/09/15 08:47:11.29 le 5.26 l    34.064 -116.361   8.3 A  3062563  172  296
+1992/09/16 06:14:34.56 le 4.23 l    35.999 -119.917  30.0 C  3063078   79  296
+1992/09/22 18:52:33.34 le 4.06 l    35.113 -116.724   7.1 A  3065895  109  296
+1992/09/27 16:59:14.56 le 4.07 l    36.021 -119.862  10.0 C  3067045   31  296
+1992/10/02 07:19:57.34 le 4.59 l    34.601 -116.636   3.4 A  3068003   82  296
+1992/10/11 12:38:12.44 le 4.52 l    34.944 -116.797   2.7 A  3069999   78  296
+1992/10/20 05:28:09.64 le 4.30 l    35.920 -120.484  13.0 A  3071691   50  296
+1992/11/25 02:40:24.87 le 4.11 l    35.045 -116.977   3.7 A  3079533  116  296
+1992/11/26 21:41:17.23 le 4.00 l    34.979 -116.952   0.0 A  3079813   81  296
+1992/11/27 16:00:57.49 le 5.29 l    34.340 -116.900   1.4 A  3079915  164  296
+1992/11/27 18:32:24.96 le 4.15 l    34.364 -116.905   1.1 A  3080022   85  296
+1992/12/04 02:08:57.50 le 5.26 l    34.369 -116.898   3.0 A  3081404  151  296
+1992/12/04 05:25:07.44 le 4.61 c    34.373 -116.912   3.6 A  3081485   36  296
+1992/12/04 05:25:11.21 le 4.66 l    34.377 -116.918   2.7 A  3081464  157  296
+1992/12/04 12:59:42.11 le 4.24 l    34.361 -116.914   0.7 A  3081531  130  296
+1992/12/05 02:52:57.41 le 4.03 l    36.420 -120.074   6.0 C  3081642   23  296
+1992/12/07 03:33:31.47 le 4.03 l    34.362 -116.924   1.1 A  3081990   74  296
+1992/12/11 01:38:34.21 le 4.12 l    34.271 -116.404   2.7 A  3082658   76  296
+1992/12/29 05:45:32.80 le 4.01 c    33.489 -116.486  10.2 C  3085286   24  296
+1993/02/11 12:39:36.96 le 4.50 l    35.026 -116.973   3.3 A  3092017   99  330
+1993/02/15 07:59:33.17 le 4.19 l    34.405 -116.464   6.0 C  3092410   79  330
+1993/04/04 05:21:26.00 le 4.20 l    35.934 -120.507  11.8 B  3099250   55  330
+1993/05/20 20:14:14.50 le 4.52 l    36.095 -117.702   0.8 A  3106252  141  329
+1993/05/28 04:47:40.60 le 5.19 l    35.149 -119.104  21.4 A  3107503  157  329
+1993/05/31 08:55:29.99 le 4.11 l    34.120 -116.995   5.7 A  3107911   66  329
+1993/07/08 22:57:44.87 le 4.01 l    34.245 -116.429   2.4 A  3112773   78  329
+1993/08/21 01:46:38.40 le 5.00 l    34.029 -116.321   9.1 A  3118441  167  329
+1993/09/07 11:24:26.95 le 4.04 l    32.373 -115.356   6.0 C  3121053   54  329
+1993/10/11 18:59:45.03 le 4.11 l    32.365 -115.069   6.0 C  3126585   28  329
+1993/10/26 09:24:07.36 le 4.02 l    34.947 -116.652   6.0 C  3129223  117  329
+1993/11/14 12:25:35.40 le 4.64 l    35.965 -120.508  18.0 A  3131777  115  329
+1993/12/20 17:37:02.49 le 4.09 l    32.366 -115.360   6.0 C  3137057   50  329
+1994/01/11 04:20:01.41 le 4.73 c    34.798 -116.294   4.8 C  3139844    9   64
+1994/01/17 12:30:55.39 le 6.70 w    34.213 -118.537  18.4 A  3144585  160  368
+1994/01/17 12:31:58.12 le 5.89 l    34.275 -118.493   6.0 C  3149646   40  346
+1994/01/17 12:34:18.42 le 4.44 l    34.308 -118.475   6.0 C  3144599   11  346
+1994/01/17 12:39:39.80 le 4.89 l    34.265 -118.540   6.0 C  3144652  119  367
+1994/01/17 12:40:09.52 le 4.82 l    34.320 -118.507   6.0 C  3144673   28  352
+1994/01/17 12:40:36.12 le 5.20 l    34.340 -118.614   6.0 C  3144694   18  352
+1994/01/17 12:55:46.83 le 4.07 l    34.277 -118.578   6.0 C  3140674  104  364
+1994/01/17 13:06:28.34 le 4.62 l    34.251 -118.550   6.0 C  3140678  103  370
+1994/01/17 13:26:45.01 le 4.68 l    34.318 -118.456   6.0 C  3140684  112  370
+1994/01/17 13:56:02.48 le 4.44 l    34.293 -118.621   6.0 C  3140691  123  361
+1994/01/17 14:14:30.63 le 4.45 l    34.331 -118.445   6.0 C  3140870  110  370
+1994/01/17 15:07:03.17 le 4.20 l    34.304 -118.474   2.6 A  3140728  158  370
+1994/01/17 15:07:35.46 le 4.14 l    34.307 -118.467   1.6 A  2138698   80  364
+1994/01/17 15:54:10.76 le 4.85 l    34.376 -118.627  13.0 A  3140766  141  367
+1994/01/17 17:56:08.21 le 4.63 l    34.228 -118.572  19.2 A  3140853  149  370
+1994/01/17 19:43:53.38 le 4.05 l    34.368 -118.637  13.9 A  3141205  118  364
+1994/01/17 20:46:02.40 le 4.85 l    34.302 -118.565   6.0 C  3141219  153  376
+1994/01/17 22:31:53.73 le 4.12 l    34.339 -118.442   6.0 C  3141242   96  375
+1994/01/17 23:33:30.69 le 5.58 l    34.326 -118.698   9.8 A  3141273  134  376
+1994/01/18 00:39:35.02 le 4.40 l    34.379 -118.564   7.2 A  3141108  111  376
+1994/01/18 00:40:04.09 le 4.21 l    34.394 -118.543   0.0 A  2150850   45  349
+1994/01/18 00:43:08.89 le 5.24 l    34.377 -118.698  11.3 A  3141286  139  373
+1994/01/18 04:01:26.72 le 4.26 l    34.358 -118.623   0.9 A  3141180  117  376
+1994/01/18 07:23:56.02 le 4.04 l    34.333 -118.623  14.8 A  3141341  127  388
+1994/01/18 11:35:09.90 le 4.19 l    34.218 -118.607  12.1 A  3141570   90  403
+1994/01/18 13:24:44.13 le 4.32 l    34.319 -118.558   1.7 A  3141584  118  388
+1994/01/18 15:23:46.89 le 4.84 l    34.379 -118.561   7.7 A  3141597  134  388
+1994/01/19 04:40:47.00 le 4.34 l    34.361 -118.571   2.6 A  3142081  146  379
+1994/01/19 04:43:14.57 le 4.04 l    34.366 -118.709   6.0 C  3142082  126  370
+1994/01/19 09:13:10.90 le 4.05 l    34.304 -118.737  13.0 A  3142087  125  373
+1994/01/19 14:09:14.83 le 4.52 l    34.215 -118.510  17.5 A  3142198  158  394
+1994/01/19 21:09:28.61 le 5.06 l    34.379 -118.712  14.4 A  3142595  144  400
+1994/01/19 21:11:44.90 le 5.07 l    34.378 -118.619  11.3 A  3142597  104  391
+1994/01/21 18:39:15.26 le 4.53 l    34.301 -118.466  10.6 A  3145627  159  500
+1994/01/21 18:39:47.08 le 4.00 l    34.297 -118.479  11.9 A  3159009   34  428
+1994/01/21 18:42:28.77 le 4.25 l    34.310 -118.474   7.9 A  3143541   93  482
+1994/01/21 18:52:44.23 le 4.31 l    34.302 -118.452   7.6 A  3143546  146  488
+1994/01/21 18:53:44.57 le 4.32 l    34.298 -118.458   7.7 A  3143547   84  464
+1994/01/22 22:54:10.66 le 4.64 c    34.393 -118.568   7.6 A  3187383   12   81
+1994/01/23 08:55:08.66 le 4.07 l    34.300 -118.428   6.0 A  3144303  139  512
+1994/01/24 04:15:18.82 le 4.59 l    34.347 -118.552   6.5 A  3145150  174  530
+1994/01/24 05:50:24.34 le 4.30 l    34.361 -118.628  12.1 A  3145168  159  524
+1994/01/24 05:54:21.07 le 4.20 l    34.364 -118.627  10.9 A  3145171  147  518
+1994/01/27 17:19:58.83 le 4.57 l    34.273 -118.563  14.9 A  3146628  146  530
+1994/01/28 20:09:53.43 le 4.21 l    34.375 -118.494   0.7 A  3146983   81  530
+1994/01/29 11:20:35.97 le 5.06 l    34.306 -118.579   1.1 A  3147406  134  548
+1994/01/29 12:16:56.35 le 4.33 l    34.278 -118.611   2.6 A  3147259  122  539
+1994/02/04 00:10:08.56 le 4.04 l    36.486 -116.903   6.0 D  3149235   50  347
+1994/02/06 13:19:27.02 le 4.09 l    34.292 -118.476   9.3 A  3150210  154  527
+1994/02/25 12:59:12.59 le 4.03 l    34.357 -118.480   1.2 A  3155150  154  488
+1994/03/20 21:20:12.26 le 5.24 l    34.231 -118.475  13.1 A  3159411  176  347
+1994/03/31 20:00:00.08 le 4.33 l    36.183 -120.219   6.0 C  3161292   29  347
+1994/03/31 20:02:30.06 le 4.08 l    36.186 -120.219   6.0 C  3161293   30  347
+1994/04/06 19:01:04.06 le 4.78 l    34.192 -117.095   7.3 A  3162132  190  347
+1994/04/21 16:37:15.97 le 4.43 l    36.293 -120.346   6.0 C  3164331   95  347
+1994/05/25 12:56:57.05 le 4.40 l    34.312 -118.393   7.0 A  3169078  155  348
+1994/06/15 05:59:48.63 le 4.13 l    34.311 -118.398   7.4 A  3172383  160  348
+1994/06/16 16:24:27.52 le 4.97 l    34.268 -116.402   3.4 A  3172554   99  348
+1994/08/01 21:34:31.12 le 4.85 l    34.640 -116.517   9.2 A  3178681  128  349
+1994/08/11 02:22:53.52 le 4.63 l    32.342 -115.280   6.0 C  3180000   59  349
+1994/10/19 00:49:58.80 le 4.18 l    35.512 -117.494   3.4 A  3188805   78  350
+1994/11/20 04:31:43.45 le 4.21 l    34.012 -116.319   6.3 A  3193347  168  350
+1994/12/06 03:48:34.49 le 4.54 l    34.293 -118.389   9.0 A  3195727  167  350
+1994/12/20 10:27:47.79 le 4.88 l    35.912 -120.476  14.0 B  3197468  100  349
+1995/02/19 21:24:18.07 le 4.34 l    34.049 -118.915  15.6 A  3203644  163  349
+1995/05/07 11:03:33.04 le 4.77 l    33.905 -116.288  10.7 A  3212249  171  349
+1995/06/21 21:17:36.23 le 4.27 l    32.985 -117.818   6.0 C  3217139  135  349
+1995/06/26 08:40:28.94 le 5.02 l    34.394 -118.669  13.3 A  3217586  187  349
+1995/08/17 22:39:58.99 le 5.36 l    35.776 -117.662   5.6 A  3225143  156  349
+1995/08/17 22:41:10.48 le 4.32 l    35.790 -117.679   6.0 C  3225237   29  349
+1995/08/30 15:29:54.62 le 4.21 l    35.791 -117.641   5.0 A  3228523  125  349
+1995/09/05 20:27:18.42 le 4.44 l    34.199 -116.438   0.0 A  3229496   87  349
+1995/09/11 18:37:23.75 le 4.24 l    35.788 -117.663   6.6 A  3230334  124  345
+1995/09/20 23:27:36.27 le 5.75 l    35.761 -117.638   5.4 A  3231786  147  345
+1995/09/20 23:30:34.62 le 4.21 l    35.729 -117.611  10.2 A  3231937   23  343
+1995/09/20 23:32:46.86 le 4.00 l    35.755 -117.629   8.6 B  3231943   24  345
+1995/09/21 07:57:41.34 le 4.02 l    35.756 -117.633   5.4 A  3232031   57  345
+1995/09/21 23:48:39.16 le 4.01 l    35.761 -117.643   5.4 A  3232380   96  345
+1995/09/25 04:47:29.18 le 4.90 l    35.809 -117.616   9.4 A  3233618  163  345
+1995/10/18 12:42:04.80 le 4.16 l    35.742 -117.631   3.7 A  3238772  146  345
+1995/12/05 04:25:55.63 le 4.15 h    35.731 -117.622   9.8 B  3245779   16   73
+1995/12/27 09:42:58.51 le 4.20 h    34.245 -118.599   6.0 C  3247748   12   57
+1995/12/31 21:48:23.06 le 4.09 l    35.098 -118.306   7.9 A  3248154  113  345
+1996/01/07 14:32:53.02 le 5.17 l    35.761 -117.646   4.0 A  3248846  126  345
+1996/01/08 08:57:11.00 le 4.16 l    35.755 -117.620   1.9 A  3249165   77  345
+1996/01/08 10:52:28.88 le 4.36 l    35.779 -117.636   2.7 A  3249191   69  345
+1996/01/08 10:53:39.34 le 4.24 l    35.799 -117.632   2.5 A  3249318   31  345
+1996/01/11 08:46:34.56 le 4.19 l    34.994 -116.943   7.1 B  3249913   33  215
+1996/01/26 13:06:02.86 le 4.18 l    35.789 -117.664   4.7 A  3252027  108  345
+1996/03/20 07:37:59.76 le 4.11 l    34.362 -118.615  13.0 A  3258844  152  345
+1996/05/01 19:49:56.42 le 4.09 l    34.354 -118.703  14.4 A  3263467  160  345
+1996/08/14 03:05:27.10 le 4.40 l    34.593 -116.279   0.0 A  7039551   97  361
+1996/08/30 06:24:47.61 le 4.05 l    32.377 -115.379   6.0 C  3275544   34  345
+1996/10/20 00:17:33.39 le 4.16 l    34.604 -116.278   6.0 C  7046881   82  345
+1996/10/23 22:09:29.38 le 4.07 l    34.481 -119.353  14.5 A  7047275  133  345
+1996/11/27 01:42:43.82 le 4.46 l    33.953 -116.314   6.0 A  7050391  122  345
+1996/11/27 20:17:24.11 le 5.30 w    36.075 -117.650   1.2 A  7050470  131  345
+1997/03/18 15:24:47.72 le 5.26 l    34.971 -116.819   1.7 A  7062511  181  511
+1997/04/26 10:37:30.67 le 5.07 l    34.369 -118.670  16.4 A  9008753  183  595
+1997/04/27 11:09:28.38 le 4.92 l    34.377 -118.649  15.2 A  9008934  174  553
+1997/05/06 19:12:53.76 le 4.49 l    35.453 -118.431   6.0 A  9009850  152  556
+1997/06/20 04:35:40.52 le 4.76 l    32.681 -118.109   6.0 C  9013612  129  629
+1997/06/20 05:38:55.01 le 4.18 l    32.685 -118.137   6.0 C  9013626   68  558
+1997/06/20 08:04:13.62 le 4.53 l    32.626 -118.151   6.0 C  9013640  120  623
+1997/06/28 21:45:25.10 le 4.18 l    34.168 -117.336  10.0 A  9014489  177  601
+1997/07/03 17:49:37.58 le 4.25 l    35.791 -117.638   4.7 A  9014887   94  654
+1997/07/26 03:14:55.91 le 4.89 l    33.398 -116.349  12.2 A  9017527  163  709
+1997/09/12 13:36:54.94 le 4.05 l    36.887 -116.277   6.0 D  9023014   24  686
+1997/09/19 22:37:14.47 le 4.11 l    34.141 -116.856  10.2 A  9023927  169  715
+1997/09/28 15:57:22.95 le 4.42 l    34.301 -116.452   7.7 A  9024626  156  777
+1997/12/05 17:04:38.92 le 4.08 l    34.097 -116.996   4.5 A  9033757  171  818
+1997/12/09 01:10:12.62 le 4.01 l    32.337 -115.263   6.0 C  9034200   33  749
+1997/12/31 12:22:45.05 le 4.07 l    33.192 -115.608  10.2 A  9036954   70  782
+1998/01/05 18:14:06.47 le 4.29 l    33.951 -117.709  11.5 A  9038699  186  796
+1998/03/06 05:47:40.34 le 5.23 l    36.067 -117.638   1.8 A  9044494  145  729
+1998/03/06 05:49:43.76 le 4.85 l    36.061 -117.630   0.9 A  3298168   51  787
+1998/03/06 05:54:21.73 le 4.46 l    36.072 -117.625   1.1 A  3298170   55  797
+1998/03/06 07:36:35.45 le 4.44 l    36.062 -117.647   2.1 A  9044650   84  744
+1998/03/07 00:36:46.84 le 5.04 l    36.076 -117.618   1.7 A  9045109  146  680
+1998/03/07 00:37:44.40 le 4.80 l    36.074 -117.623   0.0 A  3298191   16  680
+1998/03/11 12:18:51.83 le 4.45 l    34.024 -117.230  14.9 A  3298292  193  801
+1998/07/02 03:39:50.45 le 4.75 l    36.945 -117.525   6.0 C  9058934   46  785
+1998/07/10 21:29:13.76 le 4.07 l    33.224 -116.088  12.3 A  9060065   75  804
+1998/08/16 13:34:40.23 le 4.78 l    34.121 -116.928   6.2 A  9064093  161  808
+1998/08/20 23:49:58.44 le 4.40 l    34.374 -117.648   9.0 A  9064568  209  811
+1998/10/01 18:18:15.96 le 4.63 l    34.111 -116.920   4.4 A  7112721  150  831
+1998/10/20 02:48:57.10 le 4.17 l    32.058 -115.406   6.0 D  9069505   25  814
+1998/10/27 01:08:40.65 le 4.82 l    34.323 -116.844   5.9 A  9069997  173  816
+1998/10/27 15:40:17.06 le 4.09 l    34.320 -116.850   4.3 A  9070083  108  824
+1999/01/13 13:20:55.91 le 4.38 l    32.711 -115.925  10.5 A  9075803   61  837
+1999/02/02 00:14:37.91 le 4.08 l    36.061 -117.853   1.5 A  9077335   20  197
+1999/02/19 03:08:32.29 le 4.24 l    32.591 -116.161   6.8 A  9078694   70  850
+1999/02/26 15:25:57.37 le 4.05 l    35.942 -120.499  12.7 A  9079311   37  859
+1999/03/13 13:31:20.34 le 4.27 l    32.584 -116.165   7.4 A  9080531   81  858
+1999/04/07 06:26:40.12 le 4.07 l    32.594 -116.162   8.6 A  9082683   76  876
+1999/04/18 15:53:01.01 le 4.15 l    32.585 -116.162   8.0 A  9084040   99  923
+1999/05/14 07:54:03.19 le 4.93 l    34.062 -116.366   1.9 A  9086596  134  878
+1999/05/14 10:52:35.21 le 4.15 l    34.033 -116.359   1.8 A  3317364   80  917
+1999/06/01 15:18:02.67 le 4.92 l    32.379 -115.243   6.0 C  9090222   48  949
+1999/07/11 18:20:46.89 le 4.35 l    35.731 -118.478   5.7 A  9095528   56  973
+1999/07/19 22:09:27.48 le 4.15 l    33.632 -116.717  14.1 A  9096656  148  892
+1999/08/02 02:40:44.00 le 4.09 h    33.484 -116.444   6.0 C  9098760   21   76
+1999/08/30 09:01:30.17 le 4.02 h    33.344 -116.382   6.0 C  3319961   17  185
+1999/09/02 17:45:07.40 le 4.44 h    33.792 -116.129   2.8 C  9103686   11   39
+1999/09/10 13:40:02.18 le 4.80 l    32.272 -115.233   6.0 C  9104506   49  895
+1999/09/20 07:02:49.18 le 4.12 l    34.322 -116.846   2.8 A  9105672  141  943
+1999/10/16 09:46:44.13 le 7.10 w    34.594 -116.271   0.0 A  9108652   55 2791
+1999/10/16 09:47:43.76 le 4.70 h    33.232 -115.660   6.0 D  3327063   11 1016
+1999/10/16 09:50:49.15 le 4.25 l    34.221 -116.366   6.0 C  3327068   10  270
+1999/10/16 09:51:48.33 le 4.77 l    34.445 -116.264   0.3 A  3320846   51 1032
+1999/10/16 09:52:15.80 le 4.15 l    34.609 -116.286   6.0 C  3327069   13  270
+1999/10/16 09:52:53.97 le 4.98 l    34.502 -116.203   6.0 C  3320847   22  330
+1999/10/16 09:54:54.93 le 4.25 l    34.617 -116.289   2.7 C  3327070   20  270
+1999/10/16 09:55:45.97 le 4.02 l    34.536 -116.311   6.0 C  3327071   13  270
+1999/10/16 09:56:30.32 le 4.47 l    33.286 -115.647   2.5 A  3327072   25  270
+1999/10/16 09:59:35.20 le 5.77 l    34.678 -116.292  10.8 A  3320848   56 1084
+1999/10/16 10:02:39.82 le 4.48 l    34.584 -116.262   0.0 A  3320849   42 1071
+1999/10/16 10:04:54.15 le 4.11 l    34.619 -116.296   6.0 C  3320857   21 2571
+1999/10/16 10:07:29.69 le 4.46 l    34.803 -116.320   0.0 C  9108646   53 1794
+1999/10/16 10:08:04.37 le 4.74 l    34.706 -116.341   1.6 A  9108676   38  922
+1999/10/16 10:10:48.90 le 4.36 l    34.639 -116.287   0.0 A  9108699   23  983
+1999/10/16 10:12:19.72 le 4.03 l    34.504 -116.235   1.0 B  9108647   16 1035
+1999/10/16 10:18:47.90 le 4.01 l    34.642 -116.299   6.5 C  9108649   19  753
+1999/10/16 10:20:52.66 le 4.76 l    34.362 -116.148   0.1 A  9108709   56 1005
+1999/10/16 10:21:20.96 le 4.50 h    34.540 -116.266   0.9 B  3321286   33 1005
+1999/10/16 10:31:15.79 le 4.04 l    34.648 -116.326   5.6 C  9574876   55  157
+1999/10/16 10:33:47.09 le 4.08 l    34.616 -116.329   7.0 C  9574884   79  172
+1999/10/16 11:06:38.38 le 4.33 l    34.583 -116.282   0.0 A  9108750   53  970
+1999/10/16 11:26:04.80 le 4.59 l    34.813 -116.341   0.0 B  9108775   33 1024
+1999/10/16 11:27:53.76 le 4.20 l    34.370 -116.141   1.3 A  3323814   16  505
+1999/10/16 12:03:18.39 le 4.25 l    34.722 -116.297   0.0 C  9108831   43 1020
+1999/10/16 12:55:09.65 le 4.42 l    34.505 -116.260   0.1 A  9108881   52 1003
+1999/10/16 12:57:21.06 le 5.62 l    34.441 -116.252   2.0 A  3320736   63  270
+1999/10/16 13:51:17.62 le 4.24 l    34.450 -116.233   0.0 A  9108964   84 1848
+1999/10/16 13:59:17.02 le 4.37 l    34.829 -116.345   0.0 A  9108985   66 1880
+1999/10/16 16:08:24.57 le 4.03 l    34.680 -116.309   0.8 A  9109131   43 1040
+1999/10/16 17:38:48.65 le 4.92 l    34.430 -116.252   0.0 A  9109254   92 1078
+1999/10/16 18:01:57.49 le 4.27 l    34.704 -116.294   3.6 A  9109287   42 1053
+1999/10/16 20:13:37.64 le 4.64 l    34.689 -116.280   1.3 A  9109442   75 1072
+1999/10/16 20:14:10.17 le 4.53 l    34.686 -116.269   0.0 A  3321577   21 1072
+1999/10/16 22:53:41.27 le 4.53 l    34.708 -116.356   6.0 C  9109636   82 1092
+1999/10/17 04:22:48.60 le 4.16 l    34.832 -116.361   4.4 B  9110089   30  327
+1999/10/17 16:22:48.20 le 4.23 l    34.353 -116.142   0.2 A  9110685   82 1162
+1999/10/17 16:32:40.67 le 4.09 l    34.362 -116.145   0.3 A  9110704  102 1102
+1999/10/17 16:32:53.26 le 4.18 l    34.362 -116.138   0.0 D  3320801   15  270
+1999/10/18 06:35:47.36 le 4.59 l    34.359 -116.149   0.0 A  9111353   80  425
+1999/10/18 11:02:19.91 le 4.35 l    34.856 -116.351   0.1 A  9111518   65  415
+1999/10/18 19:02:02.76 le 4.37 l    32.335 -115.177   6.0 C  9111874   23  434
+1999/10/19 10:39:18.89 le 4.14 l    34.594 -116.297   0.9 A  3326751   17  406
+1999/10/19 10:39:40.18 le 4.08 l    34.701 -116.305   0.7 A  9112663   62  569
+1999/10/19 12:20:44.27 le 4.49 l    34.710 -116.341   7.6 A  9112735   60  273
+1999/10/20 16:40:57.01 le 4.12 l    34.670 -116.358   3.2 A  9113677   56  442
+1999/10/21 01:25:42.12 le 4.25 l    34.866 -116.397   3.2 A  9113909   91 1338
+1999/10/21 01:54:06.64 le 4.46 l    34.867 -116.393   4.0 A  3320883   49 1944
+1999/10/21 01:54:29.20 le 4.91 l    34.860 -116.404   0.4 B  3321595   18 1102
+1999/10/21 01:54:34.17 le 5.06 l    34.874 -116.391   1.0 A  3321590   56 1102
+1999/10/21 01:57:38.77 le 4.96 l    34.863 -116.395   3.5 A  3320884  116 1942
+1999/10/22 12:40:52.53 le 4.18 l    34.336 -116.207   9.5 A  9114763   77 1355
+1999/10/22 16:08:48.05 le 5.02 l    34.865 -116.409   0.9 A  9114812  140 1393
+1999/10/22 16:48:23.19 le 4.06 l    34.827 -116.382   4.2 A  9114858   64 1359
+1999/10/22 20:16:01.09 le 4.06 l    34.870 -116.396   1.3 A  3320940   91 1331
+1999/10/22 20:17:30.14 le 4.18 l    34.861 -116.388   2.9 A  3320954   50 1128
+1999/10/25 18:26:00.63 le 4.63 l    34.617 -116.243   0.3 A  3321011   59  271
+1999/10/29 12:36:37.51 le 4.31 l    34.522 -116.273   0.4 A  9117942   89  589
+1999/10/30 03:32:59.22 le 4.11 l    34.848 -116.355   7.5 A  9118145   75 1591
+1999/11/07 06:47:49.70 le 4.03 l    34.790 -116.292   5.1 A  9120741   51 2234
+1999/11/14 14:20:09.41 le 4.42 l    34.836 -116.405   6.3 A  9122706   70 2602
+1999/12/23 14:30:54.38 le 4.03 l    34.592 -116.265   7.4 B  9130422   65 1598
+2000/02/14 09:57:42.02 le 4.36 l    34.803 -116.372   2.3 A  7177729  103 1732
+2000/02/21 13:49:43.13 le 4.37 l    34.050 -117.252  15.4 A  9140050  157 1630
+2000/02/28 23:08:42.01 le 4.21 l    36.072 -117.601   0.2 A  7179710   56 1664
+2000/02/29 22:08:05.78 le 4.05 l    36.085 -117.601   0.1 A  9141142   56 1627
+2000/03/28 15:16:15.81 le 4.24 l    36.019 -117.882   1.0 A  9145067  157 2897
+2000/04/09 10:48:09.71 le 4.28 l    32.704 -115.393  10.0 C  9146641   40  815
+2000/04/25 14:06:26.75 le 4.15 l    32.172 -115.108   6.0 D  9148478   30 2023
+2000/05/02 07:16:10.19 le 4.18 l    32.160 -115.149   6.0 D  9149198   42 2004
+2000/05/27 03:35:34.37 le 4.05 l    35.780 -117.651   0.8 A  9152038  122 2015
+2000/06/14 19:00:20.41 le 4.11 l    32.896 -115.502   5.2 A  9154092   46 2217
+2000/06/26 15:43:07.55 le 4.51 l    34.782 -116.297   4.3 A  9155518   92 2126
+2000/12/02 08:28:07.47 le 4.07 l    34.266 -116.777   3.4 A  9169867  150 3350
+2000/12/04 14:44:37.21 le 4.06 l    32.278 -114.884   6.0 D  9169996    7  190
+2000/12/24 01:04:21.87 le 4.42 l    34.918 -119.020  13.9 A  9171679  102 3343
+2000/12/27 00:27:14.10 le 4.00 l    32.726 -118.068   6.0 C  7210945   22 3341
+2001/01/14 02:26:14.06 le 4.26 l    34.284 -118.404   8.8 A  9173365  177  916
+2001/01/14 02:50:53.69 le 4.05 l    34.289 -118.403   8.4 A  9613261    0 2412
+2001/01/14 02:50:53.69 le 4.05 l    34.289 -118.403   8.4 A  9173374  173  829
+2001/02/10 21:05:05.78 le 5.13 l    34.289 -116.946   9.1 A  9627721  249 1432
+2001/02/11 00:39:15.97 le 4.22 l    34.288 -116.942   8.1 A  9627953  309 1434
+2001/05/17 21:53:45.57 le 4.25 l    35.799 -118.044   8.7 A  9653349  286 1552
+2001/05/17 22:56:45.85 le 4.10 l    35.796 -118.046   8.4 A  9653493   74 1559
+2001/07/17 12:07:26.10 le 5.10 l    36.016 -117.874   3.0 A  9674049  106 1491
+2001/07/17 12:25:18.95 le 4.07 l    36.043 -117.872   5.6 C  9674097  138 1492
+2001/07/17 12:59:59.17 le 4.65 l    36.017 -117.882   0.4 A  9674213  189 1492
+2001/07/20 12:53:07.53 le 4.43 l    35.995 -117.877   3.4 A 10992159   71 1529
+2001/07/28 01:09:29.11 le 4.01 l    36.058 -117.871   1.7 A  9686565  182 1528
+2001/08/16 18:04:33.77 le 4.36 l    32.760 -118.288   6.9 C  9695397   37 1592
+2001/08/16 22:06:28.05 le 4.17 l    32.733 -118.334  25.2 B  9695549   31 1572
+2001/09/09 23:59:18.04 le 4.24 l    34.059 -118.388   7.9 A  9703873  140 1531
+2001/10/31 07:56:16.63 le 5.09 l    33.508 -116.514  15.2 A  9718013  116 1559
+2001/11/13 20:43:14.95 le 4.11 l    33.317 -115.700   5.5 A  9722633   50 1636
+2001/12/09 01:42:26.45 le 4.89 l    32.004 -115.010   7.1 C  9732973   20 1593
+2002/01/02 12:11:28.68 le 4.21 l    33.379 -116.434  12.6 A  9742277   80 1587
+2002/01/29 05:53:28.93 le 4.18 l    34.361 -118.657  14.2 A  9753485  129 1596
+2002/02/22 19:32:41.75 le 5.70 w    32.319 -115.322   7.0 C 12456384   32 1609
+2002/02/22 20:33:49.14 le 4.13 l    32.304 -115.333   7.0 C 12456476   18 1608
+2002/03/16 21:33:23.82 le 4.60 l    33.666 -119.330   7.0 C 12659440   75 1616
+2002/04/05 08:02:56.05 le 4.39 l    34.524 -116.295   5.6 C  9775765   88 1662
+2002/04/29 12:24:41.10 le 4.10 l    32.053 -114.957   6.0 C 12883788   14  631
+2002/06/14 12:40:46.00 le 4.87 l    36.694 -116.335   7.0 C 13657604   12 1667
+2002/09/03 07:08:51.87 le 4.75 l    33.917 -117.776  12.9 A  9818433  245 1594
+2002/09/21 21:26:16.64 le 4.31 l    33.225 -116.113  14.6 A  9826789  102 1693
+2002/09/28 10:34:47.16 le 4.13 l    35.946 -117.303   3.7 A  9828889   64 1710
+2002/10/29 14:16:54.08 le 4.77 l    34.803 -116.266   4.6 A  9854597   57 3242
+2002/11/12 16:48:25.82 le 4.22 l    35.962 -120.568   9.4 C 13909920   39 1678
+2002/11/26 13:45:51.93 le 4.08 l    32.100 -115.007   7.0 C 13912892   21  767
+2002/12/10 21:04:00.69 le 4.84 l    32.232 -115.798   7.0 C 13917260   54 1668
+2002/12/12 21:03:43.20 le 4.21 l    32.367 -115.202   7.0 C  9869697   29  679
+2003/01/25 09:16:10.22 le 4.54 l    35.318 -118.654   5.6 C  9882329  100 1769
+2003/02/22 12:19:10.58 le 5.37 l    34.310 -116.848   1.2 A 13935988  202 1728
+2003/02/22 12:20:15.64 le 4.00 h    34.311 -116.847   4.4 A 13935992   61 1728
+2003/02/22 12:21:33.13 le 4.34 l    34.311 -116.851   4.4 A 13935996  104 1728
+2003/02/22 12:25:13.64 le 4.01 l    34.326 -116.857   9.3 C 13936076  128 1732
+2003/02/22 14:16:08.42 le 4.10 l    34.324 -116.858   4.2 A 13936432  193 1718
+2003/02/22 19:33:45.80 le 4.50 l    34.310 -116.850   3.0 A 13936812  175 1719
+2003/02/25 04:03:04.80 le 4.61 l    34.316 -116.844   2.7 A 13938812  230 1795
+2003/02/27 05:00:21.70 le 4.04 l    34.304 -116.843   4.6 A 13939856  177 1799
+2003/03/11 19:28:17.91 le 4.64 l    34.359 -116.133   3.9 A 13945908  153 1813
+2003/05/24 02:04:28.95 le 4.17 l    32.949 -115.550  16.0 A 13966396   71 1842
+2003/06/26 06:20:01.01 le 4.06 l    32.016 -117.384   6.0 C 13974072   27 1815
+2003/07/15 06:15:50.75 le 4.15 l    34.622 -116.667   7.6 A  9930549  158 1743
+2003/10/08 11:26:22.50 le 4.29 l    32.168 -115.425   6.0 C  9949793   52 1910
+2004/02/14 12:43:11.38 le 4.34 l    35.038 -119.132  11.7 A  9983429  192 1918
+2004/05/09 08:57:17.30 le 4.40 l    34.395 -120.022   4.4 A 10006857  256 1930
+2004/06/15 22:28:48.16 le 5.27 l    32.329 -117.918  10.0 C 14065544  100 1938
+2004/07/14 00:53:52.48 le 4.02 l    33.711 -116.056  12.9 A 14073800  100 1928
+2004/07/24 12:55:19.90 le 4.27 l    34.380 -119.436   3.6 A 14077668  224 1929
+2004/08/22 01:25:12.35 le 4.16 l    32.342 -115.224   6.0 C 14086684   58 1893
+2004/09/29 22:54:54.24 le 5.04 l    35.390 -118.624   3.5 A 14095628  246 1902
+2004/11/13 17:39:16.93 le 4.19 l    34.353 -116.845   9.6 A 10059745  221 1890
+2005/01/06 14:35:27.67 le 4.42 l    34.125 -117.439   4.2 A 14116972  311 1844
+2005/01/12 08:10:46.38 le 4.26 l    33.953 -116.395   7.6 A 14118096  223 1803
+2005/04/16 19:18:13.55 le 5.15 l    35.027 -119.178  10.3 A 14138080  292 1892

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/Makefile
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/Makefile	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/Makefile	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,45 @@
+F90 = ifort 
+F90_FLAGS = -O2
+#F90_FLAGS = -O2 -check all -align all     # type "man ifort" for options
+
+# first is for FFT, second is for bandpass filter
+#LIB = -L/opt/seismo-util/lib -lfftw3 -lDSacLib
+
+# libraries for the original filter.f90
+#LIB = -L/opt/seismo-util/lib -lDRWFiles -lDSacLib -lDSacio -lSacTools -lm
+
+# wave2d_solver should be LAST, since it calls wave2d_sub
+#MOD = wave2d_constants wave2d_variables wave2d_define_der_matrices wave2d_sub wave2d_sub2 wave2d_sub3 wave2d_solver
+MOD = wave2d_constants wave2d_variables wave2d_define_der_matrices wave2d_sub wave2d_sub2 wave2d_sub4 wave2d_solver
+SUB = gll_library lagrange_poly numerical_recipes
+
+SRC_DIR = src
+MOD_DIR = mod
+OBJ_DIR = obj
+BIN_DIR = .
+MAIN = wave2d wave2d_2 wave2d_3 wave2d_4 test_smooth
+MOD_FLAG = module
+
+MOD_OBJ = $(patsubst %,$(OBJ_DIR)/%.o,$(MOD))
+F90_OBJ = $(patsubst %,$(OBJ_DIR)/%.o,$(SUB))
+OBJ = $(F90_OBJ) $(MOD_OBJ)
+
+all : wave2d wave2d_2 wave2d_3 wave2d_4 test_smooth
+
+$(MAIN) : % : $(SRC_DIR)/%.f90 $(F90_OBJ) $(MOD_OBJ)
+	$(F90) -o $(BIN_DIR)/$* $(F90_FLAGS) $(SRC_DIR)/$*.f90 -$(MOD_FLAG) $(MOD_DIR) $(OBJ) $(LIB)
+
+$(F90_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.f90
+	$(F90) -o $@ $(F90_FLAGS) -c $(SRC_DIR)/$*.f90 
+
+$(MOD_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.f90
+	$(F90) -o $@ $(F90_FLAGS) -c $(SRC_DIR)/$*.f90 -$(MOD_FLAG) $(MOD_DIR) 
+
+.PHONY : clean
+
+clean:
+	\rm -f *.o *.mod *~ $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod  *.gif *.ps $(MAIN)  plot*.csh *.eps *.cpt src/*~
+cleanall:
+	\rm -f OUTPUT/* *.o *.mod *~ $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod  *.gif *.jpg *.ps $(MAIN)  plot*.csh *.eps *.cpt
+
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Example1_run_0100.pdf
===================================================================
(Binary files differ)


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Example1_run_0100.pdf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Example7_run_0700.pdf
===================================================================
(Binary files differ)


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Example7_run_0700.pdf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Examples_all.pdf
===================================================================
(Binary files differ)


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/FIGURES/Examples_all.pdf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/README
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/README	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/README	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,12 @@
+Carl Tape, 21-Nov-2008
+
+FIGURES -- run directory for figures
+DATA_FILES -- directory for data files generated from matlab
+              and used in plotting scripts
+
+Main script to run:
+
+plot_geometry.pl
+plot_surf_model.pl
+
+------------------------------

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_inversion.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_inversion.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_inversion.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,650 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  joint_inversion.pl
+#  Carl Tape
+#  21-Nov-2008
+#
+#  This script plots figures for the joint source-structure inversions
+#  produced by the 2D SEM wave propagation code.
+#  It also accomodates the structure-only and source-only inversions.
+#  The user must first have run the matlab scripts wave2d_cg_poly.m and wave2d_cg_figs.m.
+#
+#  EXAMPLES:
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 100 1 15 0    # 1 source, structure only
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 200 1  3 0    # 1 source, source only
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 300 1 10 0    # 1 source, joint
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 400 1 16 0    # 5 sources, joint
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 500 1 16 0    # 25 sources, joint
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 600 1 16 0    # 25 sources, structure only
+#    ../joint_inversion.pl -6/3.0/0/80/0.08 1 700 1  2 1    # 25 sources, structure only, SUBSPACE
+#
+#==========================================================
+
+if (@ARGV < 6) {die("Usage: plot_kernels.pl colors iker irun0 ipoly qmax HESSIAN\n");}
+($colors,$iker,$irun0,$ipoly,$qmax,$ihessian) = @ARGV;
+$iter = 0;
+
+# USER change
+$dirq = "/home/carltape/wave2d/SEM2D_iterate";
+
+# directory with the "reference" conjugate gradient simulation is
+#$irun0_cg = $irun0;
+$irun0_cg = 600;
+
+$sth = sprintf("%1i",$ihessian);
+
+# directories
+$pdir = "${dirq}/PLOTTING";
+$ddir = "${pdir}/DATA_FILES";
+$idir = "${dirq}/INPUT";
+$odir = "${dirq}/OUTPUT/run_";
+if (not -e $ddir) {die("Check if ddir $ddir exist or not\n");}
+
+$edir      = "event_005";  # event for first event (sr.txt)
+
+# misfit function variable
+$misfitvar = "\@~\143\@~";
+$misfitvar = "S";
+
+# resolution of color plots
+$interp = "-I0.5m/0.5m -S4m";   # key information
+$grdfile = "temp.grd";
+
+$mfile_dat_str = "structure_dat.dat";
+$mfile_syn_str = "structure_syn.dat";
+$mfile_dat_src = "src_dat.dat";
+$mfile_syn_src = "src_syn.dat";
+
+$cshfile = "joint_inversion.csh";
+
+#if($istructure==1){$Nfac=3}
+#if($istructure==2){$Nfac=2}
+#if($istructure==3){$Nfac=1}
+#$sNfac = sprintf("%1i",$Nfac);
+
+# boolean commands for plotting
+$icolor = 1;   # ccc
+
+$irun = $irun0_cg + $iter;
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t","9","9t","10","10t","11","11t","12","12t","13","13t","14","14t","15","15t","16","16t");
+$mod = $mods[$iter];
+$smod = "m\@+$mod\@+";
+
+# label for the type of map used to generate the data
+#$smap = sprintf("m%2.2i",$istructure);
+
+# wave2d run number
+$strun0_cg = sprintf("%4.4i",$irun0_cg);
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "$odir$strun0";
+$dir = "$odir$strun";
+
+#$stgam  = sprintf("\@~\147\@~ = %.1f km",$gamma/1000);
+#$stgam2 = sprintf("%3.3i",$gamma/1000);
+
+print "\n $dir, $edir, $mfile_dat_str, $mfile_syn_str";
+print "\n $colors, $iker, $mod\n";
+#die("testing");
+
+# colors for the kernel and misfit function
+ at cols = split("/",$colors);
+$kpwr = $cols[0];  # power for kernels
+$kmax = $cols[1];  # value for kernels
+$opwr = $cols[2];  # power for misfit maps
+$omax = $cols[3];  # value for misfit maps
+$cmax = $cols[4];  # value for phase velocity maps (percent pert)
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+#@units = ("m\@+2\@+ s","s\@+2\@+","xxx","xxx","xxx","xxx","xxx");
+ at units = ("  ","  ","xxx","xxx","xxx","xxx","xxx");
+$ktype = $titles[$iker];
+$utype = $units[$iker];
+
+$plabel = "${pdir}/joint_inversion.pl";
+
+# data files
+#$dir_gmt = "/home/carltape/gmt";
+$ishelf = 0;
+$shelf_file = "$idir/BOUNDARIES/oms_shelf";
+$plate_file = "$idir/BOUNDARIES/plate_boundaries";
+$fault_file = "$idir/BOUNDARIES/faults/jennings.xy";
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.15c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# KEY: parameters for the source error STARS
+$ref_rad = 6;
+$fac = 3;
+
+# plot symbols for sources, receivers, and shelf
+$src    = "-W0.5p -Sa${ref_rad}p";
+$rec    = "-Sc2p -G0";
+$rec0   = "-Sc10p -W0.5p";
+$src_ev = "-W0.5p -Sa12p -G255";
+$Wshelf = "-W0.5p,0/0/0,--";
+
+$coast_info = "-W1p -Na/1p -Df";
+$coast_info2 = "-W0.5p -Na/0.5p -Df";
+
+$plate_info_w = "-M -W2.5p,255/255/255";
+$plate_info_r = "-M -W2.5p,255/0/0";
+$plate_info_b = "-M -W2.5p,0/0/255";
+$plate_info_k = "-M -W2.5p";
+
+$fault_info_r = "-M -W1.5p,255/0/0";
+$fault_info_k = "-M -W1.5p,0/0/0";
+$fault_info_w = "-M -W1.5p,255/255/255";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+##-------------------------
+## color for chi (objective function)
+
+#$norm3 = "1e$opwr";
+#$ss = $omax;
+#$ds = $ss/$scale_color;
+#$bs3 = sprintf("%3.3e",0.9*$ss/3); # colorbar
+#$T3 = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+#print "T3 = $T3\n";
+
+#-------------------------
+# get reference phase velocity and period
+
+#$c0 = 3500; $per = 20;
+
+#open(IN,"$dir0/socal_vel_c0.dat");
+#@vals = <IN>;
+#$c0       = $vals[0];
+#$per      = $vals[1];
+#$lam      = $c0*$per;
+#$per_lab  = sprintf("T = %.1f s",$per);
+#$c0_lab   =  sprintf("c0 = %.2f km/s",$c0/1000);
+#$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+#print "\n$per_lab, $c0_lab, $lam_lab \n";
+
+open(IN,"$dir0/reference_values.dat"); @lines = <IN>; ($alpha0,$beta0) = split(" ",$lines[0]);
+open(IN,"$dir0/reference_period.dat"); $per = <IN>; chomp($per);
+$lam = $beta0*$per;
+$per_lab = sprintf("T = %3.3f s",$per);
+$beta0_lab  = sprintf("beta0 = %3.3f km/s",$beta0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $beta0_lab, $lam_lab\n";
+#-------------------------
+
+# write plotting scripts
+$Jwid = 2;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.8 -Y8.25";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+$B0 = "-B1:.\" \":";
+
+# axes scale for phase velocity maps: c(th, ph)
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Velocity for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Velocity for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$bs1 = $cmax;
+$bs2 = $bs1/4;
+#$Bscale1  = sprintf("-B%2.2ef1:\" \@~\045\@~ pert. from %2.2f km/s\": -E5p",$bs1,$beta0/1000);
+$Bscale1  = sprintf("-Ba%2.2ef%2.2e:\" ln(c / c0), c0 = %2.2f km/s\": -E5p",$bs1,$bs2,$beta0/1000);
+$Bscale1b = sprintf("-Ba%2.2ef%2.2e:\" \": -E5p",$bs1,$bs2);
+
+# axes scale for kernels: K(th, ph)
+# [$misfitvar] --> s
+$tp = "\@~\146\@~, \@~\161\@~";
+$Bscale2  = sprintf("-B%2.2e:\" K ( $tp )  ( 10\@+%2.2i\@+  m\@+-2\@+ s )\": -E5p",$bs2,$kpwr);
+$Bscale2b = sprintf("-B%2.2e:\" \": -E5p",$bs2);
+
+# axes scale for chi_plots: chi(th_r, ph_r)
+#$Bscale3  = sprintf("-B%2.2e:\" $misfitvar ( \@~\161\@~\@-r\@- , \@~\146\@~\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef5p",$bs3,$opwr);
+
+#-------------------------
+
+# model files from the final directory
+$file1dat_str = "$dir/${mfile_dat_str}";
+$file1syn_str = "$dir/${mfile_syn_str}";
+$file1dat_src = "$dir/${mfile_dat_src}";
+$file1syn_src = "$dir/${mfile_syn_src}";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat_str`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$J_title = "-JX${Jwid}";
+$R_title = "-R0/1/0/1";
+$x_title = 0.5;
+$z_title = 1.08;
+$fsize_title = 9;
+
+#=================================================================
+# files and parameters related to polynomial plots and misfit-vs-iteration plots
+
+$p_info_k   = "-N -Sc6p -W0.5p -G0";
+$p_info_w   = "-N -Sc6p -W0.5p -G255";
+$c_info_ks  = "-W0.5p";
+$c_info_ks2 = "-W1.5p";
+$c_info_rd  = "-W1.0p,255/0/0,--";
+$c_info_bd  = "-W1.0p,0/0/255,--";
+$c_info_kd  = "-W0.5p,0/0/0,--";
+
+if ($ipoly==1) {
+
+  # axes limits for polynomial plots
+  $axes_file = "${ddir}/axes_${strun0_cg}.dat";
+  if (not -f $axes_file) {die("Check if axes_file $axes_file exist or not\n");}
+  open(IN,"$axes_file");
+  @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]); # polynomial
+  ($a2x1,$a2x2,$a2y1,$a2y2) = split(" ",$ax_lims[1]); # chi vs iteration
+  ($a3x1,$a3x2,$a3y1,$a3y2) = split(" ",$ax_lims[2]); # var-red vs iteration
+
+  # chi-vs-iteration
+  $xming = $a2x1; $xmaxg = $a2x2; $yming = $a2y1; $ymaxg = $a2y2;
+  $chi_ran = $xmaxg - $xming;
+  $R_chi = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_chi = "-JX${Jwid}i/${Jwid}il"; # note log scale on y-axis
+
+  # text labels for chi-vs-m plots
+  $schi0 = "$misfitvar ( m\@+0\@+ )";
+  $schi1 = "$misfitvar ( m\@+1\@+ )";
+  $x0chit = 0 + 0.05*$chi_ran;
+  $x1chit = 1 + 0.05*$chi_ran;
+
+  $chi_curve = "${ddir}/chi_curve_${strun0_cg}.dat";
+  if (not -f $chi_curve) {die("Check if $chi_curve exist or not\n");}
+
+  # scale for chi-vs-m plots (a1f2g1p)
+  $iter_tick = 2;
+  #$B3a    = "-B${iter_tick}f1g2:\" k, model number \":/a1f3g3p:\" $misfitvar ( m )   ( $utype ) \":";
+  $B3a    = "-B${iter_tick}f1g2:\" k, model number \":/a1f3g3p:\" $misfitvar ( m )\":";
+  $B3b    = "-B${iter_tick}f1g2:\" k, model number \":/a1f3g3p:\" \":";
+}
+
+#===========================================================================
+# create colorpoint files
+
+open(CSH,">$cshfile");
+
+$cpt_vel_map = "../../model_files/socal_color.cpt";
+
+# phase velocity model
+$ichecker = 1;
+if ($ichecker==0) {
+  $cpt_vel = $cpt_vel_map;
+} else {
+  # make colorpoint file
+  #$T1 = "-T3/4/0.1";
+  $dc = $cmax/10;
+  $T1 = "-T-$cmax/$cmax/$dc";
+  $cpt_vel = "color0.cpt";
+  print CSH "makecpt -C$colorbar $T1 -D > $cpt_vel\n";
+  #print CSH "makecpt -C$colorbar $T1 > temp1\n";
+  #print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  #print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel\n";
+}
+
+close (CSH);
+system("csh -f $cshfile");
+#die("testing");
+
+#===========================================================================
+
+# shifting the subplots
+$xfac = 1.20;
+$yfac = 1.20;
+$dX1p = $xfac*$Jwid; $dX1m = -$xfac*$Jwid;
+$dY1p = $yfac*$Jwid; $dY1m = -$yfac*$Jwid;
+$dX2p = 2*$xfac*$Jwid; $dX2m = -2*$xfac*$Jwid;
+$dY2p = 2*$yfac*$Jwid; $dY2m = -2*$yfac*$Jwid;
+
+# colorbar
+$Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+$Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+#===============================================
+print "\nWriting CSH file...\n";
+  
+open(CSH,">$cshfile");
+print CSH "gmtset BASEMAP_TYPE plain PAPER_MEDIA letter TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+#===============================================
+
+# iteration index (subset of all possible)
+ at kvec = (0,$qmax);
+$numk = @kvec;
+$niter_max = $kvec[$numk-1];	# max iteration is the last in the list
+
+# load all possible files
+for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+  $irun = $irun0_cg + 2*$k;	# wave2d run number
+  $strun = sprintf("%4.4i",$irun);
+  $dir = "$odir$strun";
+
+  # if the simulation stopped on a test model, use it instead
+  if ( ($k == $niter_max) && (not -e $dir) ) {
+     $irun = $irun - 1;
+     $strun = sprintf("%4.4i",$irun);
+     $dir = "$odir$strun";
+   }
+
+  $file1syn_str = "$dir/$mfile_syn_str";
+  $file1syn_src = "$dir/$mfile_syn_src";
+  if (not -f $file1syn_str) {die("Check if $file1syn_str exist or not\n");}
+  if (not -f $file1syn_src) {die("Check if $file1syn_src exist or not\n");}
+  $str_files[$k] = $file1syn_str;
+  $src_files[$k] = $file1syn_src;
+
+  # load chi values
+  $chifile = "$dir/chi.dat";
+  open(IN,"$chifile");
+  $chi = <IN>; chomp($chi);
+  $it_vals[$k] = $k;
+  $chi_vals[$k] = $chi;
+  #$schi = sprintf("$misfitvar ( $smod )  =  %3.3e",$chi);
+}
+#print "\n @it_vals \n @chi_vals \n\n"; die("testing");
+
+# replace source and structure files with those from the Hessian run
+if($ihessian == 1) {
+  for ($h = 1; $h <= $qmax; $h = $h+1) {
+    $dir = sprintf("$dir0/HESSIAN/model_m%2.2i",$h);
+    $file1syn_str = "$dir/$mfile_syn_str";
+    $file1syn_src = "$dir/$mfile_syn_src";
+    if (not -f $file1syn_str) {die("Check if $file1syn_str exist or not\n");}
+    if (not -f $file1syn_src) {die("Check if $file1syn_src exist or not\n");}
+    $str_files[$h] = $file1syn_str;
+    $src_files[$h] = $file1syn_src;
+
+    # load chi values
+    $chifile = "$dir/chi.dat";
+    open(IN,"$chifile");
+    $chi = <IN>; chomp($chi);
+    $it_vals[$h] = $h;
+    $chi_vals[$h] = $chi;
+  }
+}
+
+print "\n @str_files \n @src_files \n";
+
+# get the receivers and sources
+$recfile = "$dir0/${edir}/sr.txt"; # src-rec for first event
+$evefile = "$dir0/events_dat_lonlat.dat"; # sources for DATA
+if (not -f $recfile) {die("Check if $recfile exist or not\n");}
+if (not -f $evefile) {die("Check if $evefile exist or not\n");}
+
+# file names for figures
+$name    = "joint_inversion_${strun0}_h${sth}";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+ at labs  = ("a","b","c","d","e","f","g","h","i","j");
+ at tlabs = ("Initial structure","Structure","Final structure","Misfit","Target structure");
+if ($qmax==1) {
+  @tlabs = ("Initial structure","Final structure","Misfit","Target structure");
+}
+
+#=============================================
+# TOP ROW : STRUCTURE
+
+$shift = "-X$dX1p";
+$B = "$B0".$Bopts[1];
+if($qmax > 1) { @kvec = (0,1,$qmax); $numk = @kvec; }
+
+for ($i = 0; $i < $numk; $i = $i+1) {
+    
+  $t = $i;
+  $k = $kvec[$i];
+  $mod = $mods[2*$k];
+  $smod = "m${mod}";
+  #$smod = "m\@+${mod}\@+";
+  $title = "($labs[$t])  $tlabs[$t] ${smod}";
+
+  # phase velocity map
+  if ($i == 0) {
+    print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  } else {
+    print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n"; 
+  }
+  if ($icolor==1) {
+    #print CSH "awk '{print \$1,\$2,\$6}' $str_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n";
+    print CSH "awk '{print \$1,\$2,\$7}' $str_files[$k] | nearneighbor -G$grdfile $R $interp\n";
+    print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile | psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile | psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  if ($i == 0) {
+    print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  }
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+}
+
+#---------------------------------------------
+# (2,2) subplot : misfit vs iteration
+
+if($qmax > 1) {$shift = "-X$dX1m -Y$dY1m";} else {$shift = "-Y$dY1m";}
+$Bg = "$B3b".$Bopts[8];
+$t = $t+1;
+$title = "($labs[$t])  $tlabs[$t],  $misfitvar (mk)";
+#$title = "($labs[$t])  $tlabs[$t],  $misfitvar (mk)  (s\@+2\@+)";
+
+print CSH "psbasemap $Bg $R_chi $J_chi -K -O -V $shift >> $psfile\n"; # START
+
+#if ($irun0_cg != 2500) {
+#  # plot curve for basic structure inversion
+#  print "\n plotting reference chi curve...\n";
+#  $chi_curve_ref = "chi_curve_2500.dat";
+#  if (not -f $chi_curve_ref) {
+#    die("Check if $chi_curve_ref exist or not\n");
+#  }
+#  print CSH "awk '{print \$1,\$2}' $chi_curve_ref | psxy $c_info_rd $J_chi $R_chi -K -O -V >> $psfile\n";
+#}
+
+print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -V >> $psfile\n";
+for ($k = 0; $k <= $niter_max; $k = $k+1) {
+  print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n"; # plot point
+}
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+print CSH "pstext -N $J_title $R_title -Xa-1.75 -Ya1.25 -K -O -V >>$psfile<<EOF\n 0 0 16 0 $fontno CM run_$irun0 (H-${sth}) \nEOF\n";
+
+#---------------------------------------------
+# (2,3) subplot :  target data
+$B = "$B0".$Bopts[8];
+$t = $t+1;
+$shift = "-X$dX1p";
+$title = "($labs[$t])  $tlabs[$t]";
+
+print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n"; 
+if ($icolor==1) {
+  print CSH "awk '{print \$1,\$2,\$7}' $file1dat_str | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+}
+print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+#print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=============================================
+# error in source parameters
+
+# shifting the subplots
+$yfac = 1.50;
+$dY1p = $yfac*$Jwid; $dY1m = -$yfac*$Jwid;
+$dY2p = 2*$yfac*$Jwid; $dY2m = -2*$yfac*$Jwid;
+$yfac = 1.20; $dY1mB = -$yfac*$Jwid;   # same as above
+
+$B = "$B0".$Bopts[1];
+
+# make colorpoint file (-Z for continuous; -I to invert)
+$cmax = 1;
+$dc = $cmax/40;
+$T2 = "-T-$cmax/$cmax/$dc";
+$cptfile = "color_src.cpt";
+print CSH "makecpt -Cpolar $T2 -I -D > $cptfile\n";
+
+#---------------
+
+ at tlabs = ("Error in initial source","Error in source","Error in final source","Error in target source");
+if ($qmax==1) {
+  @tlabs = ("Error in initial source","Error in final source","Error in target source");
+}
+
+#@kvec = (0,$qmax); $numk = @kvec;
+#for ($i = 0; $i < $numk; $i = $i+1) {
+for ($i = 0; $i < $numk; $i = $i+1) {
+
+  $k = $kvec[$i];
+  #$k = $i;
+
+  $mod = $mods[2*$k];
+  $smod = "m${mod}";
+  #$smod = "m\@+${mod}\@+";
+  $t = $t+1;
+  $title = "($labs[$t])  $tlabs[$i] ${smod}";
+ 
+  #-------------------
+  # KEY COMMAND -- formula to scale from mislocation to dot size
+  # THIS MUST BE REPEATED FOR THE KEY BELOW!
+
+#  $irun = $irun0_cg + 2*$k;	# wave2d run number (CG)
+#  $strun = sprintf("%4.4i",$irun);
+#  $dir = "$odir$strun";
+
+#  if ( ($k == $niter_max) && (not -e $dir) ) {
+#     $irun = $irun - 1;
+#     $strun = sprintf("%4.4i",$irun);
+#     $dir = "$odir$strun";
+#   }
+
+#  if($ihessian==0) {
+#     $source_error_file = "$dir/$mfile_syn_src";
+#  } else {
+#     $source_error_file = $src_files[$i];
+#  }
+
+  $source_error_file = $src_files[$k];
+  $dots_file = "temp";
+  print CSH "awk '{print \$1,\$2,\$6,${ref_rad} + sqrt(\$7*\$7 + \$8*\$8)*$fac/1000}' $source_error_file > $dots_file\n"; 
+  print CSH "awk '{print \$1,\$2,\$6,sqrt(\$7*\$7 + \$8*\$8)/1000}' $source_error_file > source_error\n";
+  #print "\n $source_error_file \n $dots_file \n"; die("testing");
+  #-------------------
+
+  if ($i==0) {
+     $shift = "-X$dX2m -Y$dY1m";
+  } elsif ($i==1 || $i==2) {
+     $shift = "-X$dX1p";
+  }
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info2 -K -O -V >> $psfile\n";
+
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  # plot source errors as colored and sized stars
+  $dot_info = "-W0.5p -Sap";
+  print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V >> $psfile \n";
+
+  if ($i==0) {
+    # depth scale
+    #$Dx = 0.25; $Dy = -0.2;
+    $Dx = 0.25; $Dy = 3.0;
+
+    $Dscale_otime = "-D$Dx/$Dy/0.8/0.10h";;
+    $Bscale_otime = "-B1f0.25:\"Origin time error (s)\": -E5p";
+    print CSH "psscale -C$cptfile $Dscale_otime $Bscale_otime -K -O -V >> $psfile\n";
+
+    # convert source errors to dot size
+    @misloc_dots = (0,2,4);
+    $ndot = @misloc_dots;
+    $xlon0 = -117; $dlon = 1.0;
+    for ($j = 0; $j < $ndot; $j = $j+1) {
+      $misloc = $misloc_dots[$j];
+      $misloc_size[$j] = $ref_rad + $misloc*$fac; # KEY: use same formula as above
+      $xlon[$j] = $xlon0 + $j*$dlon;
+    }
+
+    # source error scale -- symbols
+    #$origin_box = "-Xa0 -Ya0";   # location for mislocation legend
+    $origin_box = "-Xa0.0 -Ya3.25"; # location for mislocation legend
+    $yp0 = $zmin - 2.0;
+    $yp1 = $yp0 + 0.5;
+    $yp2 = $yp1 + 0.5;
+    $yp3 = $yp2 + 0.5;
+    print CSH "psxy $J $R $dot_info -N -K -V -O $origin_box >> $psfile <<EOF
+  $xlon[2] $yp3 $misloc_size[2]
+  $xlon[1] $yp3 $misloc_size[1]
+  $xlon[0] $yp3 $misloc_size[0]
+EOF\n";
+
+    # source error scale -- text
+    print CSH "pstext $J $R -N -K -V -O $origin_box >> $psfile <<EOF
+  $xlon[2] $yp2 $fsize2 0 $fontno CM 4
+  $xlon[1] $yp2 $fsize2 0 $fontno CM 2
+  $xlon[0] $yp2 $fsize2 0 $fontno CM 0
+  $xlon[1] $yp1 $fsize2 0 $fontno CM Source
+  $xlon[1] $yp0 $fsize2 0 $fontno CM mislocation (km)
+EOF\n";
+  }
+
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+}
+
+# third column is the target source
+$shift = "-Y$dY1mB";
+$title = "($labs[$i])  $tlabs[$i]";
+$source_error_file = $file1dat_src;
+print CSH "awk '{print \$1,\$2,\$6,${ref_rad} + sqrt(\$7*\$7 + \$8*\$8)*$fac/1000}' $source_error_file > $dots_file\n";
+
+print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+print CSH "pscoast $J $R $coast_info2 -K -O -V >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V >> $psfile \n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+print CSH "convert $psfile $jpgfile\n";
+print CSH "echo done with $psfile\n";
+print CSH "ghostview $psfile &\n";
+
+close (CSH);
+system("csh -f $cshfile");
+#system("xv $jpgfile &");
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_inversion.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_subspace.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_subspace.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_subspace.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,793 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  joint_subspace.pl
+#  Carl Tape
+#  22-Nov-2008
+#
+#  This script plots figures for the joint source-structure inversions
+#  produced by the 2D SEM wave propagation code.
+#
+#  EXAMPLE:
+#    ../joint_subspace.pl -6/3.0/0/80/0.08 1 700 600 1  2 0  # structure (ifig2)
+#
+#  PREVIOUS EXAMPLES:
+#    ../joint_subspace.pl -6/3.0/0/80/0.08 1 8350 8350 1  2 0  # source (ifig1)
+#    ../joint_subspace.pl -6/3.0/0/80/0.08 1 8450 8450 1  4 0  # structure (ifig2)
+#    ../joint_subspace.pl -6/3.0/0/80/0.08 1 8550 8550 1  1 0  # joint (ifig3, ifig0)
+#
+#==========================================================
+
+if (@ARGV < 7) {die("Usage: plot_kernels.pl colors iker irun0 irun0_cg ipoly qmax HESSIAN\n");}
+($colors,$iker,$irun0,$irun0_cg,$ipoly,$qmax,$ihessian) = @ARGV;
+$iter = 0;
+
+$sth = sprintf("%1i",$ihessian);
+
+# USER change
+$dirq = "/home/carltape/wave2d/SEM2D_iterate";
+
+# directories
+$pdir = "${dirq}/PLOTTING";
+$ddir = "${pdir}/DATA_FILES";
+$idir = "${dirq}/INPUT";
+$odir = "${dirq}/OUTPUT/run_";
+if (not -e $ddir) {die("Check if ddir $ddir exist or not\n");}
+$edir = "event_005";  # event for first event (sr.txt)
+
+# misfit function variable
+$misfitvar = "\@~\143\@~";
+$misfitvar = "S";
+
+# resolution of color plots
+$interp = "-I0.5m/0.5m -S4m";   # key information
+$grdfile = "temp.grd";
+
+$mfile_dat_str = "structure_dat.dat";
+$mfile_syn_str = "structure_syn.dat";
+$mfile_dat_src = "src_dat.dat";
+$mfile_syn_src = "src_syn.dat";
+
+$cshfile = "joint_subspace.csh";
+
+#if($istructure==1){$Nfac=3}
+#if($istructure==2){$Nfac=2}
+#if($istructure==3){$Nfac=1}
+#$sNfac = sprintf("%1i",$Nfac);
+
+# boolean commands for plotting
+$icolor = 1;   # ccc
+
+$irun = $irun0_cg + $iter;
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t","9","9t","10","10t","11","11t","12","12t","13","13t","14","14t","15","15t","16","16t");
+$mod = $mods[$iter];
+$smod = "m\@+$mod\@+";
+
+# label for the type of map used to generate the data
+#$smap = sprintf("m%2.2i",$istructure);
+
+# wave2d run number
+$strun0_cg = sprintf("%4.4i",$irun0_cg);
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "${odir}${strun0}";
+$dir = "${odir}${strun}";
+
+#$stgam  = sprintf("\@~\147\@~ = %.1f km",$gamma/1000);
+#$stgam2 = sprintf("%3.3i",$gamma/1000);
+
+print "\n $dir, $edir, $mfile_dat_str, $mfile_syn_str";
+print "\n $colors, $iker, $mod\n";
+#die("testing");
+
+# colors for the kernel and misfit function
+ at cols = split("/",$colors);
+$kpwr = $cols[0];  # power for kernels
+$kmax = $cols[1];  # value for kernels
+$opwr = $cols[2];  # power for misfit maps
+$omax = $cols[3];  # value for misfit maps
+$cmax = $cols[4];  # value for phase velocity maps (percent pert)
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+ at units = ("m\@+2\@+ s","s\@+2\@+","xxx","xxx","xxx","xxx","xxx");
+$ktype = $titles[$iker];
+$utype = $units[$iker];
+
+$plabel = "/home/carltape/wave2d/2d_adjoint/scripts/joint_subspace.pl";
+
+# data files
+#$dir_gmt = "/home/carltape/gmt";
+$ishelf = 0;
+$shelf_file = "$idir/BOUNDARIES/oms_shelf";
+$plate_file = "$idir/BOUNDARIES/plate_boundaries";
+$fault_file = "$idir/BOUNDARIES/faults/jennings.xy";
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.15c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# KEY: parameters for the source error STARS
+$ref_rad = 6;
+$fac = 3;
+
+# plot symbols for sources, receivers, and shelf
+$src    = "-W0.5p -Sa${ref_rad}p";
+$rec    = "-Sc2p -G0";
+$rec0   = "-Sc10p -W0.5p";
+$src_ev = "-W0.5p -Sa12p -G255";
+$Wshelf = "-W0.5p,0/0/0,--";
+
+$dot_info = "-W0.5p -Sap";
+
+$coast_info = "-W1p -Na/1p -Df";
+$coast_info2 = "-W0.5p -Na/0.5p -Df";
+
+$plate_info_w = "-M -W2.5p,255/255/255";
+$plate_info_r = "-M -W2.5p,255/0/0";
+$plate_info_b = "-M -W2.5p,0/0/255";
+$plate_info_k = "-M -W2.5p";
+
+$fault_info_r = "-M -W1.5p,255/0/0";
+$fault_info_k = "-M -W1.5p,0/0/0";
+$fault_info_w = "-M -W1.5p,255/255/255";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+open(IN,"$dir0/reference_values.dat"); @lines = <IN>; ($alpha0,$beta0) = split(" ",$lines[0]);
+open(IN,"$dir0/reference_period.dat"); @lines = <IN>; ($per) = split(" ",$lines[0]);
+$lam = $beta0*$per;
+$per_lab = sprintf("T = %3.3f s",$per);
+$beta0_lab  = sprintf("beta0 = %3.3f km/s",$beta0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $beta0_lab, $lam_lab\n";
+#-------------------------
+
+# write plotting scripts
+$Jwid = 2;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.8 -Y8.25";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+$B0 = "-B1:.\" \":";
+
+# axes scale for phase velocity maps: c(th, ph)
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Velocity for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Velocity for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$bs1 = $cmax;
+$bs2 = $bs1/4;
+#$Bscale1  = sprintf("-B%2.2ef1:\" \@~\045\@~ pert. from %2.2f km/s\": -E5p",$bs1,$beta0/1000);
+$Bscale1  = sprintf("-Ba%2.2ef%2.2e:\" ln(c / c0), c0 = %2.2f km/s\": -E5p",$bs1,$bs2,$beta0/1000);
+$Bscale1b = sprintf("-Ba%2.2ef%2.2e:\" \": -E5p",$bs1,$bs2);
+
+# axes scale for kernels: K(th, ph)
+# [$misfitvar] --> s
+$tp = "\@~\146\@~, \@~\161\@~";
+$Bscale2  = sprintf("-B%2.2e:\" K ( $tp )  ( 10\@+%2.2i\@+  m\@+-2\@+ s )\": -E5p",$bs2,$kpwr);
+$Bscale2b = sprintf("-B%2.2e:\" \": -E5p",$bs2);
+
+# axes scale for chi_plots: chi(th_r, ph_r)
+#$Bscale3  = sprintf("-B%2.2e:\" $misfitvar ( \@~\161\@~\@-r\@- , \@~\146\@~\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef5p",$bs3,$opwr);
+
+#-------------------------
+
+# model files from the final directory
+$file1dat_str = "${dir}/${mfile_dat_str}";
+$file1syn_str = "${dir}/${mfile_syn_str}";
+$file1dat_src = "${dir}/${mfile_dat_src}";
+$file1syn_src = "${dir}/${mfile_syn_src}";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat_str`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$J_title = "-JX${Jwid}";
+$R_title = "-R0/1/0/1";
+$x_title = 0.5;
+$z_title = 1.08;
+$fsize_title = 9;
+
+#=================================================================
+# files and parameters related to polynomial plots and misfit-vs-iteration plots
+
+$p_info_k   = "-N -Sc6p -W0.5p -G0";
+$p_info_w   = "-N -Sc6p -W0.5p -G255";
+$c_info_ks  = "-W0.5p";
+$c_info_ks2 = "-W1.5p";
+$c_info_rd  = "-W1.0p,255/0/0,--";
+$c_info_bd  = "-W1.0p,0/0/255,--";
+$c_info_kd  = "-W0.5p,0/0/0,--";
+
+if ($ipoly==1) {
+
+  # axes limits for polynomial plots
+  $axes_file = "${ddir}/axes_${strun0_cg}.dat";
+  if (not -f $axes_file) {die("Check if axes_file $axes_file exist or not\n");}
+  open(IN,"$axes_file");
+  @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]); # polynomial
+  ($a2x1,$a2x2,$a2y1,$a2y2) = split(" ",$ax_lims[1]); # chi vs iteration
+  ($a3x1,$a3x2,$a3y1,$a3y2) = split(" ",$ax_lims[2]); # var-red vs iteration
+
+  # chi-vs-iteration
+  $xming = $a2x1; $xmaxg = $a2x2; $yming = $a2y1; $ymaxg = $a2y2;
+  $chi_ran = $xmaxg - $xming;
+  $R_chi = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_chi = "-JX${Jwid}i/${Jwid}il"; # note log scale on y-axis
+
+  # text labels for chi-vs-m plots
+  $schi0 = "$misfitvar ( m\@+0\@+ )";
+  $schi1 = "$misfitvar ( m\@+1\@+ )";
+  $x0chit = 0 + 0.05*$chi_ran;
+  $x1chit = 1 + 0.05*$chi_ran;
+
+  $chi_curve = "${ddir}/chi_curve_${strun0_cg}.dat";
+  if (not -f $chi_curve) {die("Check if $chi_curve exist or not\n");}
+
+  # scale for chi-vs-m plots (a1f2g1p)
+  $iter_tick = 2;
+  $B3a    = "-B${iter_tick}f1g2:\" k, model number \":/a1f3g3p:\" $misfitvar ( m )   ( $utype ) \":";
+  $B3b    = "-B${iter_tick}f1g2:\" k, model number \":/a1f3g3p:\" \":";
+}
+
+#===========================================================================
+# create colorpoint files
+
+open(CSH,">$cshfile");
+
+# phase velocity maps
+$dc = $cmax/10;
+$T1 = "-T-$cmax/$cmax/$dc";
+$cpt_vel = "color0.cpt";
+print CSH "makecpt -C$colorbar $T1 -D > $cpt_vel\n";
+
+# origin time
+$cmax = 1;
+$dc = $cmax/40;
+$T2 = "-T-$cmax/$cmax/$dc";
+$cptfile = "color_src.cpt";
+print CSH "makecpt -Cpolar $T2 -I -D > $cptfile\n";
+
+close (CSH);
+system("csh -f $cshfile");
+#die("testing");
+
+#===========================================================================
+
+# shifting the subplots
+$xfac = 1.20;
+$yfac = 1.20;
+$dX1p = $xfac*$Jwid; $dX1m = -$xfac*$Jwid;
+$dY1p = $yfac*$Jwid; $dY1m = -$yfac*$Jwid;
+$dX2p = 2*$xfac*$Jwid; $dX2m = -2*$xfac*$Jwid;
+$dY2p = 2*$yfac*$Jwid; $dY2m = -2*$yfac*$Jwid;
+
+# shifting the subplots
+$yfac = 1.50;
+$dY1p = $yfac*$Jwid; $dY1m = -$yfac*$Jwid;
+$dY2p = 2*$yfac*$Jwid; $dY2m = -2*$yfac*$Jwid;
+$yfac = 1.20; $dY1mB = -$yfac*$Jwid;
+
+# colorbar
+$Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+$Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+#===============================================
+print "\nWriting CSH file...\n";
+  
+open(CSH,">$cshfile");
+print CSH "gmtset BASEMAP_TYPE plain PAPER_MEDIA letter TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+#===============================================
+
+# iteration index (subset of all possible)
+ at kvec = (0,$qmax);
+$numk = @kvec;
+$niter_max = $kvec[$numk-1];	# max iteration is the last in the list
+
+# load all possible files
+for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+  $irun = $irun0_cg + 2*$k;	# wave2d run number
+  $strun = sprintf("%4.4i",$irun);
+  $dir = "${odir}${strun}";
+
+  # if the simulation stopped on a test model, use it instead
+  if ( ($k == $niter_max) && (not -e $dir) ) {
+     $irun = $irun - 1;
+     $strun = sprintf("%4.4i",$irun);
+     $dir = "${odir}${strun}";
+   }
+
+  $file1syn_str = "${dir}/$mfile_syn_str";
+  $file1syn_src = "${dir}/$mfile_syn_src";
+  if (not -f $file1syn_str) {die("Check if file1syn_str $file1syn_str exist or not\n");}
+  if (not -f $file1syn_src) {die("Check if file1syn_src $file1syn_src exist or not\n");}
+  $str_files[$k] = $file1syn_str;
+  $src_files[$k] = $file1syn_src;
+
+  # load chi values
+  $chifile = "${dir}/chi.dat";
+  if (not -f $chifile) {die("Check if chifile $chifile exist or not\n");}
+  open(IN,"$chifile");
+  $chi = <IN>; chomp($chi);
+  $it_vals[$k] = $k;
+  $chi_vals[$k] = $chi;
+  #$schi = sprintf("$misfitvar ( $smod )  =  %3.3e",$chi);
+}
+
+# load files from Hessian run
+$it_vals_hess[0] = $it_vals[0];
+$chi_vals_hess[0] = $chi_vals[0];
+$str_files_hess[0] = $str_files[0];
+$src_files_hess[0] = $src_files[0];
+
+for ($h = 1; $h <= $qmax; $h = $h+1) {
+  $dir = sprintf("$dir0/HESSIAN/model_m%2.2i",$h);
+  $file1syn_str = "${dir}/$mfile_syn_str";
+  $file1syn_src = "${dir}/$mfile_syn_src";
+  if (not -f $file1syn_str) {die("Check if file1syn_str $file1syn_str exist or not\n")}
+  if (not -f $file1syn_src) {die("Check if file1syn_src $file1syn_src exist or not\n")}
+  $str_files_hess[$h] = $file1syn_str;
+  $src_files_hess[$h] = $file1syn_src;
+
+  # load chi values
+  $chifile = "${dir}/chi.dat";
+  if (not -f $chifile) {die("Check if chifile $chifile exist or not\n");}
+  open(IN,"$chifile");
+  $chi = <IN>; chomp($chi);
+  $it_vals_hess[$h] = $h;
+  $chi_vals_hess[$h] = $chi;
+}
+
+print "\n @str_files \n @src_files \n @str_files_hess \n @src_files_hess \n";
+
+# get the receivers and sources
+$recfile = "$dir0/${edir}/sr.txt"; # src-rec for first event
+$evefile = "$dir0/events_dat_lonlat.dat"; # sources for DATA
+if (not -f $recfile) {die("Check if $recfile exist or not\n");}
+if (not -f $evefile) {die("Check if $evefile exist or not\n");}
+
+ at labs  = ("a","b","c","d","e","f","g","h","i","j");
+
+$ifig0 = 0;    # initial and target models
+$ifig1 = 0;    # source inversion
+$ifig2 = 1;    # structure inversion
+
+#=============================================
+# INITIAL AND TARGET MODELS
+#=============================================
+
+if($ifig0 == 1) {
+
+# file names for figures
+$name    = "joint_subspace_00"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg";
+
+ at bvec = (15,9,15);
+
+# target structure
+$B = "$B0".$Bopts[9];
+$title = "(a)  Target structure";
+$str_file = $file1dat_str;
+print CSH "psbasemap $B $R $J -K -V -P $origin > $psfile\n";  # START
+if ($icolor==1) {
+  print CSH "awk '{print \$1,\$2,\$7}' $str_file | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+}
+print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+# target source
+$B = "$B0".$Bopts[15];
+$title = "(b)  Target source";
+$shift = "-X$dX1p";
+$src_file = $file1dat_src;
+$dots_file = "temp";
+print CSH "awk '{print \$1,\$2,\$8,${ref_rad} + sqrt(\$6*\$6 + \$7*\$7)*$fac/1000}' $src_file > $dots_file\n"; 
+print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+print CSH "pscoast $J $R $coast_info2 -K -O -V >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V >> $psfile \n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+# initial structure
+$B = "$B0".$Bopts[9];
+$title = "(c)  Initial structure";
+$shift = "-X$dX1m -Y$dY1mB";
+$str_file = $str_files[0];
+print CSH "psbasemap $B $R $J -K -V -O $shift >> $psfile\n";
+if ($icolor==1) {
+  print CSH "awk '{print \$1,\$2,\$7}' $str_file | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+}
+print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+
+# initial source
+$B = "$B0".$Bopts[15];
+$shift = "-X$dX1p";
+$title = "(d)  Initial source";
+$src_file = $src_files[0];
+$dots_file = "temp";
+print CSH "awk '{print \$1,\$2,\$8,${ref_rad} + sqrt(\$6*\$6 + \$7*\$7)*$fac/1000}' $src_file > $dots_file\n";
+print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+print CSH "pscoast $J $R $coast_info2 -K -O -V >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V >> $psfile \n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+# legend for sources
+$Dx = 0.2; $Dy = -0.2;
+$Dscale_otime = "-D$Dx/$Dy/0.8/0.10h";;
+$Bscale_otime = "-B1f0.25:\"Origin time error (s)\": -E5p";
+print CSH "psscale -C$cptfile $Dscale_otime $Bscale_otime -K -O -V >> $psfile\n";
+
+# convert source errors to dot size
+ at misloc_dots = (0,2,4);
+$ndot = @misloc_dots;
+$xlon0 = -117; $dlon = 1.0;
+for ($j = 0; $j < $ndot; $j = $j+1) {
+  $misloc = $misloc_dots[$j];
+  $misloc_size[$j] = $ref_rad + $misloc*$fac; # KEY: use same formula as above
+  $xlon[$j] = $xlon0 + $j*$dlon;
+}
+
+# source error scale -- symbols
+$origin_box = "-Xa0 -Ya0"; # location for mislocation legend
+$yp0 = $zmin - 2.0;
+$yp1 = $yp0 + 0.5;
+$yp2 = $yp1 + 0.5;
+$yp3 = $yp2 + 0.5;
+print CSH "psxy $J $R $dot_info -N -K -V -O $origin_box >> $psfile <<EOF
+  $xlon[2] $yp3 $misloc_size[2]
+  $xlon[1] $yp3 $misloc_size[1]
+  $xlon[0] $yp3 $misloc_size[0]
+EOF\n";
+
+# source error scale -- text
+print CSH "pstext $J $R -N -K -V -O $origin_box >> $psfile <<EOF
+  $xlon[2] $yp2 $fsize2 0 $fontno CM 4
+  $xlon[1] $yp2 $fsize2 0 $fontno CM 2
+  $xlon[0] $yp2 $fsize2 0 $fontno CM 0
+  $xlon[1] $yp1 $fsize2 0 $fontno CM Source
+  $xlon[1] $yp0 $fsize2 0 $fontno CM mislocation (km)
+EOF\n";
+
+#-----------------------------
+print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+print CSH "convert $psfile $jpgfile\n";
+print CSH "echo done with $psfile\n";
+print CSH "ghostview $psfile &\n";
+
+}
+
+#=============================================
+# SOURCE INVERSION
+#=============================================
+
+if($ifig1 == 1) {
+
+# file names for figures
+$name    = "joint_subspace_01"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg";
+
+ at tlabs = ("CG: Error in initial source","CG: Error in source","CG: Error in final source");
+ at kvec = (0,1,2); $numk = @kvec;
+ at bvec = (15,9,15);
+$t = 0;
+for ($i = 0; $i < $numk; $i = $i+1) {
+
+  $k = $kvec[$i];
+  $t = $t+1;
+  $b = $bvec[$i];
+  $B = "$B0".$Bopts[$b];
+
+  $mod = $mods[2*$k];
+  $smod = "m${mod}";
+  #$smod = "m\@+${mod}\@+";
+  $title = "($labs[$t-1])  $tlabs[$i] ${smod}";
+
+  $source_error_file = $src_files[$k];
+  $dots_file = "temp";
+  print CSH "awk '{print \$1,\$2,\$8,${ref_rad} + sqrt(\$6*\$6 + \$7*\$7)*$fac/1000}' $source_error_file > $dots_file\n"; 
+  print CSH "awk '{print \$1,\$2,\$8,sqrt(\$6*\$6 + \$7*\$7)/1000}' $source_error_file > source_error\n";
+  #print "\n $source_error_file \n $dots_file \n"; die("testing");
+  #-------------------
+
+  if ($i==0) {
+     $shift = "-X$dX2m -Y$dY1mB";
+  } elsif ($i==1 || $i==2) {
+     $shift = "-X$dX1p";
+  }
+
+  if($i==0) {
+     print CSH "psbasemap $B $R $J -K -V -P $origin > $psfile\n";  # START
+  } else {
+     print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info2 -K -O -V >> $psfile\n";
+
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  # plot source errors as colored and sized stars
+  $dot_info = "-W0.5p -Sap";
+  print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V >> $psfile \n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+}
+
+#----------------------------
+
+ at tlabs = ("Misfit,  S (mk)","Subspace: Error in source","Subspace: Error in final source");
+ at kvec = (0,1,2); $numk = @kvec;
+ at bvec = (8,1,8);
+for ($i = 0; $i < $numk; $i = $i+1) {
+
+  $k = $kvec[$i];
+  $t = $t+1;
+  $b = $bvec[$i];
+  $B = "$B0".$Bopts[$b];
+
+  $mod = $mods[2*$k];
+  $smod = "m${mod}";
+  #$smod = "m\@+${mod}\@+";
+  $title = "($labs[$t-1])  $tlabs[$i] ${smod}";
+  $source_error_file = $src_files_hess[$k];
+
+  $dots_file = "temp";
+  print CSH "awk '{print \$1,\$2,\$8,${ref_rad} + sqrt(\$6*\$6 + \$7*\$7)*$fac/1000}' $source_error_file > $dots_file\n"; 
+  print CSH "awk '{print \$1,\$2,\$8,sqrt(\$6*\$6 + \$7*\$7)/1000}' $source_error_file > source_error\n";
+  #print "\n $source_error_file \n $dots_file \n"; die("testing");
+  #-------------------
+
+  if ($i==0) {
+    $shift = "-X$dX2m -Y$dY1mB";
+  } elsif ($i==1 || $i==2) {
+    $shift = "-X$dX1p";
+  }
+
+  if ($i == 0) {
+
+    # plot the misfit function
+    $Bg = "$B3b".$Bopts[$b];
+    $title = "($labs[$t-1])  $tlabs[$i]";
+    print CSH "psbasemap $Bg $R_chi $J_chi -K -O -V $shift >> $psfile\n";
+    #print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -V >> $psfile\n";
+    for ($p = 0; $p <= $niter_max; $p = $p+1) {
+      print CSH "psxy $J_chi $R_chi $p_info_w -K -O -V >>$psfile<<EOF\n $it_vals[$p] $chi_vals[$p]\nEOF\n";
+      print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V >>$psfile<<EOF\n $it_vals_hess[$p] $chi_vals_hess[$p]\nEOF\n";
+    }
+    print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  } else {
+
+    # plot the source errors
+    print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+    print CSH "pscoast $J $R $coast_info2 -K -O -V >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+    # plot source errors as colored and sized stars
+    $dot_info = "-W0.5p -Sap";
+    print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V >> $psfile \n";
+
+    if ($i==1) {
+      # depth scale
+      $Dx = 0.3; $Dy = -0.2;
+
+      $Dscale_otime = "-D$Dx/$Dy/0.8/0.10h";;
+      $Bscale_otime = "-B1f0.25:\"Origin time error (s)\": -E5p";
+      print CSH "psscale -C$cptfile $Dscale_otime $Bscale_otime -K -O -V >> $psfile\n";
+
+      # convert source errors to dot size
+      @misloc_dots = (0,2,4);
+      $ndot = @misloc_dots;
+      $xlon0 = -117; $dlon = 1.0;
+      for ($j = 0; $j < $ndot; $j = $j+1) {
+	$misloc = $misloc_dots[$j];
+	$misloc_size[$j] = $ref_rad + $misloc*$fac; # KEY: use same formula as above
+	$xlon[$j] = $xlon0 + $j*$dlon;
+      }
+
+      # source error scale -- symbols
+      $origin_box = "-Xa0.3 -Ya-0.13"; # location for mislocation legend
+      $yp0 = $zmin - 2.0;
+      $yp1 = $yp0 + 0.5;
+      $yp2 = $yp1 + 0.5;
+      $yp3 = $yp2 + 0.5;
+      print CSH "psxy $J $R $dot_info -N -K -V -O $origin_box >> $psfile <<EOF
+  $xlon[2] $yp3 $misloc_size[2]
+  $xlon[1] $yp3 $misloc_size[1]
+  $xlon[0] $yp3 $misloc_size[0]
+EOF\n";
+
+      # source error scale -- text
+      print CSH "pstext $J $R -N -K -V -O $origin_box >> $psfile <<EOF
+  $xlon[2] $yp2 $fsize2 0 $fontno CM 4
+  $xlon[1] $yp2 $fsize2 0 $fontno CM 2
+  $xlon[0] $yp2 $fsize2 0 $fontno CM 0
+  $xlon[1] $yp1 $fsize2 0 $fontno CM Source mislocation (km)
+EOF\n";
+    }
+    print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+}
+
+
+#-----------------------------
+print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+print CSH "convert $psfile $jpgfile\n";
+print CSH "echo done with $psfile\n";
+print CSH "ghostview $psfile &\n";
+
+}
+
+#=============================================
+#  STRUCTURE INVERSION
+#=============================================
+
+if($ifig2 == 1) {
+
+# file names for figures
+$name    = "joint_subspace_02"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg";
+
+ at tlabs = ("CG: Structure","CG: Structure","CG: Final structure");
+ at kvec = (1,2,$qmax); $numk = @kvec;
+ at bvec = (15,9,15);
+$t = 0;
+for ($i = 0; $i < $numk; $i = $i+1) {
+
+  $k = $kvec[$i];
+  $t = $t+1;
+  $b = $bvec[$i];
+  $B = "$B0".$Bopts[$b];
+
+  $mod = $mods[2*$k];
+  $smod = "m${mod}";
+  #$smod = "m\@+${mod}\@+";
+  $title = "($labs[$t-1])  $tlabs[$i] ${smod}";
+  $str_file = $str_files[$k];
+
+  if ($i==0) {
+     $shift = "-X$dX2m -Y$dY1mB";
+  } elsif ($i==1 || $i==2) {
+     $shift = "-X$dX1p";
+  }
+
+  if($i==0) {
+     print CSH "psbasemap $B $R $J -K -V -P $origin > $psfile\n";  # START
+  } else {
+     print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  }
+
+ # plot the structure
+  if ($icolor==1) {
+    #print CSH "awk '{print \$1,\$2,\$6}' $str_file | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n";
+    print CSH "awk '{print \$1,\$2,\$7}' $str_file | nearneighbor -G$grdfile $R $interp\n";
+    print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+}
+
+#----------------------------
+
+ at tlabs = ("Subspace: Structure","Subspace: Structure","Subspace: Final structure");
+ at kvec = (1,2,$qmax); $numk = @kvec;
+ at bvec = (15,9,15);
+for ($i = 0; $i < $numk; $i = $i+1) {
+
+  $k = $kvec[$i];
+  $t = $t+1;
+  $b = $bvec[$i];
+  $B = "$B0".$Bopts[$b];
+
+  $mod = $mods[2*$k];
+  $smod = "m${mod}";
+  #$smod = "m\@+${mod}\@+";
+  $title = "($labs[$t-1])  $tlabs[$i] ${smod}";
+  $str_file = $str_files_hess[$k];
+
+  if ($i==0) {
+    $shift = "-X$dX2m -Y$dY1mB";
+  } elsif ($i==1 || $i==2) {
+    $shift = "-X$dX1p";
+  }
+
+  # plot the structure
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n"; 
+  if ($icolor==1) {
+    #print CSH "awk '{print \$1,\$2,\$6}' $str_file | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n";
+    print CSH "awk '{print \$1,\$2,\$7}' $str_file | nearneighbor -G$grdfile $R $interp\n";
+    print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  if ($i == 0) {
+    print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  }
+
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+ 
+}
+
+# plot the target map
+$B = "$B0".$Bopts[8];
+$t = $t+1;
+$shift = "-X$dX1m -Y$dY1mB";
+$title = "($labs[$t-1])  Target structure";
+print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n"; 
+if ($icolor==1) {
+  print CSH "awk '{print \$1,\$2,\$7}' $file1dat_str | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C${cpt_vel} $J -K -O -V -Q >> $psfile\n";
+}
+print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+# plot the misfit function
+$Bg = "$B3b".$Bopts[8];
+$t = $t+1;
+$title = "($labs[$t-1])  Misfit,  S (mk)";
+$shift = "-X$dX1p";
+print CSH "psbasemap $Bg $R_chi $J_chi -K -O -V $shift >> $psfile\n";
+#print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -V >> $psfile\n";
+for ($p = 0; $p <= $niter_max; $p = $p+1) {
+  print CSH "psxy $J_chi $R_chi $p_info_w -K -O -V >>$psfile<<EOF\n $it_vals[$p] $chi_vals[$p]\nEOF\n";
+  print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V >>$psfile<<EOF\n $it_vals_hess[$p] $chi_vals_hess[$p]\nEOF\n";
+}
+print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+
+#-----------------------------
+print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+print CSH "convert $psfile $jpgfile\n";
+print CSH "echo done with $psfile\n";
+print CSH "ghostview $psfile &\n";
+
+}
+
+#=============================================
+
+close (CSH);
+system("csh -f $cshfile");
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/joint_subspace.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/make_sac_files.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/make_sac_files.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/make_sac_files.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,101 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  make_sac_files.pl
+#  Carl Tape
+#  23-May-2006
+#
+#  This script converts ascii seismograms to sac files,
+#  and also includes the src and rec lat-lon.
+#
+#  This generates the STATIONS file, which is needed for multi_plot_rs.pl
+#
+#  EXAMPLE (execute from main directory):
+#    scripts/make_sac_files.pl OUTPUT/ dat 1 48.0
+#    scripts/make_sac_files.pl OUTPUT/ syn 1 48.0
+#    scripts/make_sac_files.pl OUTPUT/ stfadj 1 48.0
+#
+#    scripts/make_sac_files.pl OUTPUT/run_3100/event_005 dat 1 48.0
+#    scripts/make_sac_files.pl OUTPUT/run_3100/event_005 syn 1 48.0
+#    scripts/make_sac_files.pl OUTPUT/run_3100/event_005 stfadj 1 48.0
+#
+#    scripts/make_sac_files.pl OUTPUT/run_4600/event_005 stfadj 1 48.0; scripts/make_sac_files.pl OUTPUT/run_4600/event_005 syn 1 48.0; scripts/make_sac_files.pl OUTPUT/run_4600/event_005 dat 1 48.0
+#
+#    scripts/make_sac_files.pl OUTPUT_body/run_5000/event_001 dat 1 16.0
+#    scripts/make_sac_files.pl OUTPUT_body/run_5000/event_001 dat 2 16.0
+#    scripts/make_sac_files.pl OUTPUT_body/run_5000/event_001 dat 3 16.0
+#
+#    scripts/make_sac_files.pl OUTPUT_body/run_5000/event_001 dat 3 16.0
+#
+#==========================================================
+
+if (@ARGV < 3) {die("Usage: make_sac_files.pl datadir file_prefix comp tshift\n");}
+($datadir,$file_prefix,$ncomp,$tshift) = @ARGV;
+
+# origin time for records
+$mtshift = -$tshift;
+
+for($i = 1; $i <= $ncomp; $i++) {
+
+# get ascii seismograms
+ at files = glob("$datadir/${file_prefix}*$i");
+$numf = 1 + $#files;
+print "\n $numf files in $datadir with label $datafile \n";
+if (@files == 0) {die("No data files available to plot\n");}
+
+# create source and receiver lists from wave2d.f90 output file [sr.txt]
+$src_file = "src_list";
+$rec_file = "rec_list";
+system("awk '\$1 == \"S\" {print \$2,\$3}' ${datadir}/sr.txt > $src_file");
+system("awk '\$1 == \"R\" {print \$2,\$3}' ${datadir}/sr.txt > $rec_file");
+open(IN,"$src_file"); @src = <IN>;
+open(IN,"$rec_file"); @rec = <IN>;
+
+# get the (first) source
+($evlo,$evla)=split(" ",$src[0]);
+
+# make station file for plot_rs.pl
+$station_file = "STATIONS";
+open(OUT, ">$station_file");
+
+$net = "CI";
+$ref_time = 0;
+
+#foreach $file (@files) {
+for($k = 0; $k < $numf; $k++){
+
+   # labels for data files
+   $dir_file_ascii = $files[$k];
+   ($dir,$file_suffix) = split($file_prefix,$dir_file_ascii);
+   $file_ascii = $file_prefix.$file_suffix;
+   #print "\n $dir_file_ascii $file_ascii";
+
+   # extract station name (assume <1000 receivers)
+   ($lab,$sta_temp,$comp) = split("_",$file_ascii);
+   $sta = substr($sta_temp, 2, 3);
+   #@chars = split(//,$sta_temp); $sta = join("", at chars[2..4]);
+   #print "\n $file_ascii to $sta_temp to $sta. \n";
+
+   # convert ascii file to sac file
+   #$file_sac = $lab."."."$sta".".".$comp.".sac";
+   system("ascii2sac.csh $dir_file_ascii");
+   $dir_file_sac = "$datadir/$sta.$net.$comp.sac$lab";
+   system("mv $dir_file_ascii.sac $dir_file_sac");
+
+   # extract station longitude-latitude
+   # THIS IS NOT A FOOL-PROOF LINK, SINCE THE GLOB COMMAND ABOVE
+   # MUST SELECT THE FILES IN THE SAME ORDER IN WHICH THE STATION
+   # LIST WAS MADE.
+   ($stlo,$stla)=split(" ",$rec[$k]);
+
+   # update labels on the sac file
+   #system("sacch b $mtshift knetwk $net kcmpnm $comp kstnm $sta evlo $evlo evla $evla stlo $stlo stla $stla f $dir_file_sac");
+   system("sacch t0 $ref_time knetwk $net kcmpnm $comp kstnm $sta evlo $evlo evla $evla stlo $stlo stla $stla f $dir_file_sac");
+
+   print OUT "$sta\n";
+}
+close(OUT)
+
+}
+#==================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/make_sac_files.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/multi_plot_rs.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/multi_plot_rs.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/multi_plot_rs.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,157 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  multi_plot_rs.pl
+#  Carl Tape, 22-Sept-2005
+#  
+#  This script repeatedly calls plot_rs.pl to make sub record sections.
+#  It then concatenates the record sections into a single pdf document.
+#
+#  1.  Run plot_model.pl
+#  2.  Run make_sac_files.pl (generates STATIONS).
+#  3.  Run multi_plot_rs.pl
+#
+#  EXAMPLES (execute from main directory):
+#    (02-Aug-2005, waveform)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 1 sacdat sacsyn 0/150 10/280 -0.001 -0.001
+#
+#    (02-Aug-2005, traveltime, xcorr, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 1 sacdat sacsyn 0/150 10/280 -0.001 -5000
+#
+#    (02-Aug-2005, amplitude, xcorr, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 1 sacdat sacsyn 0/150 10/280 -0.001 -100
+#
+#    (02-Aug-2005, traveltime, mtm, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 1 sacdat sacsyn 0/150 10/280 -0.001 -3e6
+#
+#    (02-Aug-2005, amplitude, mtm, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 1 sacdat sacsyn 0/150 10/280 -0.001 -1e5
+#
+#    (02-Aug-2005, traveltime, xcorr, sampling)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 0 junk sacsyn 0/150 10/280 -0.001 -2000
+#
+#    (02-Aug-2005, amplitude, xcorr, sampling)
+#    scripts/multi_plot_rs.pl out01 OUTPUT 0 junk sacsyn 0/150 10/280 -0.001 -700
+#
+#-----------------------
+#
+#    (22-Sept-2005, waveform)
+#    scripts/multi_plot_rs.pl out01 OUTPUT/run_02/event_01 1 sacdat sacsyn 0/240 10/500 20/50 -0.008 -0.008
+#
+#    (22-Sept-2005, traveltime, xcorr, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT/run_01/event_01 1 sacdat sacsyn 0/240 10/500 20/50 -0.008 -20000
+#
+#    (06-Oct-2005, traveltime, xcorr, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT/run_99/event_11 1 sacdat sacsyn 0/240 10/320 20/50 -0.006 -15000
+#
+#    (27-Nov-2005, traveltime, xcorr, misfit)
+#    scripts/multi_plot_rs.pl out01 OUTPUT/run_000/event_005 1 sacdat sacsyn 0/160 0/300 20/50 -0.006 -15000
+#    scripts/multi_plot_rs.pl out01 OUTPUT/run_001/event_001 1 sacdat sacsyn 0/180 300/400 20/10 -0.001 -15000
+#
+#    (23-May-2006)
+#    scripts/multi_plot_rs.pl record_section OUTPUT/run_3100/event_005 1 sacdat sacsyn 0/160 0/300 20/50 -0.001 -5000
+#    scripts/multi_plot_rs.pl record_section OUTPUT/run_3101/event_005 1 sacdat sacsyn 0/160 0/300 20/50 -0.001 -3e6
+#
+#    (19-July-2006, traveltime, xcorr, misfit)
+#    scripts/multi_plot_rs.pl record_section_e01 OUTPUT/run_4200/event_001 1 sacdat sacsyn 0/240 0/500/100 20/10 -0.002 -15000
+#    scripts/multi_plot_rs.pl record_section_e05 OUTPUT/run_4200/event_005 1 sacdat sacsyn 0/240 0/500/100 20/10 -0.002 -15000
+#
+#    scripts/multi_plot_rs.pl record_section_e01 OUTPUT/run_4400/event_001 1 sacdat sacsyn 0/240 0/500/100 20/10 -0.002 -15000
+#    scripts/multi_plot_rs.pl record_section_e05 OUTPUT/run_4400/event_005 1 sacdat sacsyn 0/240 0/500/100 20/10 -0.002 -15000
+#    scripts/multi_plot_rs.pl record_section_e05 OUTPUT/run_4480/event_005 1 sacdat sacsyn 0/240 0/500/100 20/10 -0.002 -1e7
+#
+#  Type pssac2 for info on scaling the records:
+#      -M vertical scaling in sacfile_unit/MEASURE_UNIT = size<required>
+#          size: each trace will normalized to size (in MEASURE_UNIT)
+#              scale =  (1/size) * [data(max) - data(min)]
+#          size/alpha: plot absolute amplitude multiplied by (1/size)*r^alpha
+#              where r is the distance range in km across surface
+#              specifying alpha = 0.0 will give absolute amplitudes
+#              scale = (1/size) * r^alpha
+#          size/s: plot absolute amplitude multiplied by (1/size)*sqrt(sin(gcarc))
+#              where gcarc is the distance in degrees.
+#              scale = (1/size) * sqrt(sin(gcarc))
+#
+#==========================================================
+
+if (@ARGV < 10) {die("Usage: multi_plot_rs.pl outfile datadir idat dat_suffix syn_suffix tmin/tmax dmin/dmax/dinc ttick/dtick Msyn Madj \n");}
+($outfile,$datadir,$idat,$dat_suffix,$syn_suffix,$tran,$dran,$ticks,$Msyn,$Madj) = @ARGV;
+
+$comp = 1;
+$alpha = 0;
+
+($ttick,$dtick) = split("/",$ticks);
+($tmin,$tmax) = split("/",$tran);
+($dmin,$dmax,$dinc) = split("/",$dran);
+if(not $dinc) {$dinc = $dmax-$dmin;}
+
+$B = "$ttick/$dtick";
+
+$nump = ($dmax-$dmin)/$dinc;
+
+print "\n Range for time axis     : $tmin $tmax ($ttick)";
+print "\n Range for distance axis : $dmin $dmax ($dtick)";
+print "\n $nump separate record sections (dinc = $dinc) \n";
+
+# write the C-shell script to file
+$cfile = "multi_plot_rs.csh";
+print "\nWriting CSH file ($cfile)...\n";
+open(CSH,">$cfile");
+
+$t1 = $tmin;
+$t2 = $tmax;
+$d1 = $dmin;
+$d2 = $dmin + $dinc;
+for ($i = 1; $i <= $nump; $i = $i+1) {
+
+  $R        = "-R$t1/$t2/$d1/$d2";
+
+  $pslab    = "_${t1}_${t2}_${d1}_${d2}.ps";
+  $title1   = "socal_seis";
+  $title2   = "socal_stf_adjoint";
+  $psfile1 = $title1.$pslab;
+  $psfile2 = $title2.$pslab;
+
+  print "\n idat = $idat \n";
+
+  if ($idat == 0) {
+
+     # record section of synthetics only
+     print CSH "scripts/plot_rs.pl $R -B$B -Ekt0 -M$Msyn/$alpha -W0.5p $datadir/*$syn_suffix \n";
+
+  } else {
+
+     # record section of data + synthetics
+     print CSH "scripts/plot_rs.pl $R -B$B -m $title1 -Ekt0 -M$Msyn/$alpha -W0.5p -w0.5/255/0/0tap -S $datadir,$syn_suffix -D $datadir,$dat_suffix,1,STATIONS \n";
+  }
+
+  # record section of adjoint source time functions (NOTE: sac suffix is NOT user input)
+  print CSH "scripts/plot_rs.pl $R -B$B -m $title2 -Ekt0 -n \"Socal adjoint source time functions\" -M$Madj/$alpha -W0.5p $datadir/*sacstfadj \n";
+
+  print CSH "ps2pdf $psfile1\n";
+  print CSH "ps2pdf $psfile2\n";
+
+  $d1 = $d2;
+  $d2 = $d2 + $dinc;
+}
+
+print CSH "ps2pdf model.ps\n";
+close (CSH);
+
+#die("testing");
+
+system("csh -f -v $cfile");
+# system("csh -f $cfile");
+
+#---------------
+
+# bring it all into one pdf file
+ at files = glob("*.pdf");
+if (@files == 0){die("\n STOP: No pdf record sections available to combine\n\n"); }
+
+#print CSH "pdcat @files $outfile.pdf \n\n";
+print "\n pdcat -r @files $outfile.pdf \n\n";
+system("/home/wagholi2/lqy/local/PDF-CLE/bin/pdcat -r @files $outfile.pdf");
+
+#------------------------------------------------------


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/multi_plot_rs.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_compare_seis.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_compare_seis.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_compare_seis.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,246 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_body_compare_seis.pl
+#  Carl Tape
+#  07-Aug-2006
+#
+#
+#  EXAMPLES:
+#    scripts/plot_body_compare_seis.pl OUTPUT_body/run_5011 OUTPUT_body/run_5011_5012 events_xy.dat recs_xz.dat structure_syn.dat 3
+#    scripts/plot_body_compare_seis.pl OUTPUT_body/run_5013 OUTPUT_body/run_5013_5017 events_xz.dat recs_xz.dat structure_syn.dat 3
+#    scripts/plot_body_compare_seis.pl OUTPUT_body/run_5013 OUTPUT_body/run_5013_5017b events_xz.dat recs_xz.dat structure_syn.dat 3
+#
+#
+#==========================================================
+
+if (@ARGV < 3) {die("Usage: plot_body_compare_seis.pl basedir iopt xxx \n")}
+($dir1,$dir,$efile_syn,$rfile_syn,$mfile_syn,$ncomp) = @ARGV;
+
+$strun = sprintf("%4.4i",$irun);
+$stev  = sprintf("%3.3i",$ievent);
+
+$evefile = "$dir1/${efile_syn}";
+$recfile = "$dir1/${rfile_syn}";
+$mfile = "$dir1/${mfile_syn}";
+
+if (not -f $evefile)  { die("Check if $evefile exist or not\n") }
+if (not -f $recfile)  { die("Check if $recfile exist or not\n") }
+if (not -f $mfile) { die("Check if $mfile exist or not\n") }
+
+#$edir  = sprintf("$dir/event_%3.3i",$event);
+#print "\n $dir,$edir,$mfile_dat,$mfile_syn,$c0,$per,$ifinite,$iopt \n";
+
+$plabel = "/home/denali2/carltape/wave2d/2d_adjoint/scripts/plot_body_compare_seis.pl";
+
+#die("\ntesting\n");
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.2c";
+
+# plot symbols for sources, receivers, and shelf
+$size = 15; $hsize = $size/2;
+$src = "-Sa${size}p -W0.5p,0/0/0 -G255/255/255";
+#$rec = "-Si${size}p -W0.5p -D0/${hsize}p -G0/255/0";
+$rec = "-Si${size}p -W0.5p -G255/255/255";
+
+# bounds for plotting (we could also use the file global_mesh.dat)
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $mfile`);
+$xmin = $xmin/1000; $xmax = $xmax/1000;
+$zmin = $zmin/1000; $zmax = $zmax/1000;
+$pinc = 0.0;  # buffer around min/max
+$xran = $xmax - $xmin; $zran = $zmax - $zmin;
+$xmin = $xmin-$pinc*$xran;  $xmax = $xmax+$pinc*$xran;
+$zmin = $zmin-$pinc*$zran;  $zmax = $zmax+$pinc*$zran;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+print "\n $R \n";
+
+# write plotting scripts
+  $wid = 7;
+  $dx0 = $wid;                       # width of each subplot
+  $dy0 = $dx0*($zran/$xran);
+  $J = "-JX${dx0}i/${dy0}i";
+
+$B = "-B20:.\" \":WESn";
+
+# plot title
+$xtx = $xmin+0.5*($xmax-$xmin);
+$ztx = $zmin+1.10*($zmax-$zmin);
+
+# get sources
+if (not -f $evefile) {die("Check if $evefile exist or not\n")}
+open(IN,$evefile); @srclines = <IN>; $nsrc = @srclines;
+
+# get receivers
+open(IN,$recfile); @reclines = <IN>; $nrec = @reclines;
+
+#$nsrc = 1; $nrec = 1; $ncomp = 1;
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  $cshfile = "plot_body_compare_seis.csh";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain MEASURE_UNIT inch TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+# loop over components
+for ($icomp = 1; $icomp <= $ncomp; $icomp++) {
+
+print "\n component is $icomp \n";
+
+for ($isrc = 1; $isrc <= $nsrc; $isrc++) {
+
+for ($irec = 1; $irec <= $nrec; $irec++) {
+
+($xsrc,$zsrc,$junk1,$namesrc) = split(" ",$srclines[$isrc-1]);
+print "\n source $namesrc is at (x, z) = ($xsrc, $zsrc) \n";
+
+($xrec,$zrec,$namerec) = split(" ",$reclines[$irec-1]);
+print "\n rec $namerec is at (x, z) = ($xrec, $zrec) \n";
+
+$ftag = sprintf("%3.3i_%3.3i_%1.1i",$isrc,$irec,$icomp);
+
+$name = "$dir/seis_$ftag";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+  #$plot_title = "Model for synthetics";
+  $origin = "-X1.0 -Y8.0";
+
+  # phase velocity map
+  print CSH "psbasemap $J $R $B -K -P -V $origin > $psfile\n";  # START
+
+  # plot receivers with numbered label
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $rec_file |psxy -N $J $R -K -O -P -V $rec0 >> $psfile\n";
+  #$rec_file2 = text_rec; $angle = 0; $just = "CM";
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $rec_file > $rec_file2\n";
+
+  $xs = $xsrc/1000; $zs = $zsrc/1000;
+  $xr = $xrec/1000; $zr = $zrec/1000;
+  print CSH "psxy -N $J $R -K -O -P -V $src >> $psfile<<EOF\n $xs $zs \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -P -V $rec >> $psfile<<EOF\n $xr $zr \nEOF\n";
+
+  # plot discontinutities
+  print CSH "psxy -N $J $R -K -O -P -V -W0.5p >> $psfile<<EOF\n 0 45 \n 400 45 \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -P -V -W0.5p >> $psfile<<EOF\n 0 65 \n 400 65 \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -P -V -W0.5p >> $psfile<<EOF\n 0 75 \n 400 75 \nEOF\n";
+
+  $just = "CM"; $angle = 0;
+  print CSH "pstext -N $J $R -K -O -P -V >> $psfile<<EOF\n $xs $zs $fsize3 $angle $fontno $just $namesrc\nEOF\n";
+  print CSH "pstext -N $J $R -K -O -P -V >> $psfile<<EOF\n $xr $zr $fsize3 $angle $fontno $just $namerec\nEOF\n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $ytemp = $dy0 * 1.3;
+  $shift = "-Xa-$dX -Ya$ytemp";
+  $title = "$dir/seis_compare_${ftag}.dat";
+  print CSH "pstext -N $J $R $Utag -K -O -P -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $title \nEOF\n";
+
+  #===============================================
+
+  # file with seismograms
+  $seisfile = "$dir/seis_compare_${ftag}.dat";
+  if (not -f $seisfile)  { die("Check if $seisfile exist or not\n") }
+
+  # source time function
+  print "\n seismogram file is $seisfile\n";
+  
+  # determine the max value among the source time functions
+  ($tmin,$tmax,$junk1,$junk2,$junk3,$junk4,$rmin,$rmax) = split(" ",`minmax -C $seisfile`);
+  ($ss) = sort{$b <=> $a} (abs($rmin),abs($rmax));
+  $ss = 0.25;   # fixed residual amplitude
+
+  print "smax = $ss \n tmin = $tmin tmax = $tmax\n";
+  $ttick1 = 10;
+  $ttick2 = $ttick1/2;
+  #$ytick = (1.1*$ss)/4;
+  $rtick1 = 0.10;
+  $rtick2 = 0.05;
+
+  #@titles = ("s0 (NGLL = 7)","s0 - s1","s0 - s2","s0 - s3");
+  @titles = ("s1 (NGLL = 5)","s1 - s2","s1 - s3");
+
+  #$stf_data = "temp";
+  $Bs0 = sprintf("-Ba%3.3ff%3.3fg%3.3f:\" \":/%3.3f:\"$titles[0]\"::.\" \":WesN",$ttick1,$ttick2,$ttick2,0.5);
+  $Bs1 = sprintf("-Ba{%3.3f}f{%3.3f}g{%3.3f}:\" \":/a{%3.3f}f{%3.3f}g{%3.3f}:\"$titles[1]\"::.\" \":Wesn",
+         $ttick1,$ttick2,$ttick2,$rtick1,$rtick2,$rtick2);
+  $Bs2 = sprintf("-Ba{%3.3f}f{%3.3f}g{%3.3f}:\" \":/a{%3.3f}f{%3.3f}g{%3.3f}:\"$titles[2]\"::.\" \":Wesn",
+         $ttick1,$ttick2,$ttick2,$rtick1,$rtick2,$rtick2);
+  $Bs3 = sprintf("-Ba{%3.3f}f{%3.3f}g{%3.3f}:\"Time  (s)\":/a{%3.3f}f{%3.3f}g{%3.3f}:\"$titles[3]\"::.\" \":WeSn",
+         $ttick1,$ttick2,$ttick2,$rtick1,$rtick2,$rtick2);
+  $Rs1 = "-R$tmin/$tmax/-1/1";
+  $Rs2 = "-R$tmin/$tmax/-$ss/$ss";
+  $ywid = 1.5;
+  $Js = "-JX$wid/$ywid";
+
+  #print "\n $Bs1 $Bs2 $Rs $Js \n";
+
+  $shift1 = "-X0 -Y-2.5";
+  $shift2 = "-X0 -Y-$ywid";
+  $ytxt = 1.5; $txtinfo = "-C3p -W255o";
+
+if(0==1) {
+
+  # plot seismograms (normalized)
+  print CSH "awk '{print \$1,\$2}' $seisfile |psxy $Rs1 $Js $Bs0 -W0.5p -P -K -O -V $shift1 >> $psfile\n";
+  #print CSH "awk '{print \$1,\$3}' $seisfile |psxy $Rs1 $Js $Bs0 -W0.5p,-- -P -K -O -V >> $psfile\n";
+
+  @titles = ("s0 (NGLL=7, 32 elements)",
+             "s0 - s1a (NGLL=6, 32 el), s0 - s1b (NGLL=5, 32 el)",
+             "s0 - s2 (NGLL=5, 33 el, NOT honoring mesh)",
+             "s0 - s3 (NGLL=5, 34 el, NOT honoring mesh, but GLL pts equidistant from discontinuities)");
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[0]\nEOF\n";
+  
+  # plot residuals
+  print CSH "awk '{print \$1,\$3}' $seisfile |psxy $Rs2 $Js $Bs1 -W0.5p,0/0/255,-- -P -K -O -V $shift2 >> $psfile\n";
+  print CSH "awk '{print \$1,\$4}' $seisfile |psxy $Rs2 $Js $Bs1 -W0.5p,0/0/255 -P -K -O -V >> $psfile\n";
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[1]\nEOF\n";
+
+  print CSH "awk '{print \$1,\$5}' $seisfile |psxy $Rs2 $Js $Bs2 -W0.5p,255/0/0 -P -K -O -V $shift2 >> $psfile\n";
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[2]\nEOF\n";
+
+  print CSH "awk '{print \$1,\$6}' $seisfile |psxy $Rs2 $Js $Bs3 -W0.5p,0/255/0 -P -K -O -V $shift2 >> $psfile\n";
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[3]\nEOF\n";
+
+} else {
+
+  # plot seismograms (normalized)
+  print CSH "awk '{print \$1,\$2}' $seisfile |psxy $Rs1 $Js $Bs0 -W0.5p,0/0/255 -P -K -O -V $shift1 >> $psfile\n";
+  print CSH "awk '{print \$1,\$3}' $seisfile |psxy $Rs1 $Js $Bs0 -W0.5p,255/0/0,-- -P -K -O -V >> $psfile\n";
+
+  @titles = ("s1 (NGLL=5, honoring mesh, 32 elements)",
+             "s1 - s2 (NGLL=5, NOT honoring mesh, 33 el)",
+             "s1 - s3 (NGLL=5, NOT honoring mesh, but GLL pts equidistant from discontinuities, 34 el)");
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[0]\nEOF\n";
+  
+  # plot residuals
+  print CSH "awk '{print \$1,\$2-\$3}' $seisfile |psxy $Rs2 $Js $Bs1 -W0.5p,255/0/0 -P -K -O -V $shift2 >> $psfile\n";
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[1]\nEOF\n";
+
+  print CSH "awk '{print \$1,\$2-\$4}' $seisfile |psxy $Rs2 $Js $Bs2 -W0.5p,0/255/0 -P -K -O -V $shift2 >> $psfile\n";
+  print CSH "pstext -N -JX1 -R0/1/0/1 -K -O -P -V $txtinfo >>$psfile<<EOF\n $wid $ytxt $fsize2 0 $fontno RM $titles[2]\nEOF\n";
+
+}
+
+#-----------------------------
+  print CSH "pstext -N $J -R0/1/0/1 -O -P -V >>$psfile<<EOF\n 10 10 $fsize0 0 $fontno CM junk\nEOF\n";  # FINISH
+
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+}  # comp
+}  # src
+}  # rec
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &")
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_compare_seis.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_seis.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_seis.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_seis.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,195 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_body_seis.pl
+#  Carl Tape
+#  07-Aug-2006
+#
+#-------------------------
+#  EXAMPLES:
+#    scripts/plot_body_seis.pl OUTPUT_body 0 5000 2 parameters1.log events_xz.dat recs_xz.dat 2
+#    scripts/plot_body_seis.pl OUTPUT_body 0 5000 4 parameters1.log events_xz.dat recs_xz.dat 1/2/3
+#    scripts/plot_body_seis.pl OUTPUT_body 0 5001 2 parameters1.log events_xy.dat recs_xz.dat 1/2/3
+#    scripts/plot_body_seis.pl OUTPUT_body 0 5011 2 parameters1.log events_xy.dat recs_xz.dat 1/2/3
+#    scripts/plot_body_seis.pl OUTPUT_body 0 5016 1 parameters1.log events_xz.dat recs_xz.dat 1/2/3
+#
+#    scripts/plot_body_seis.pl OUTPUT_body 1 1 5100 1  1 14 parameters1.log events_dat_xz.dat recs_xz.dat 1/2/3
+#    scripts/plot_body_seis.pl OUTPUT_body 1 1 5100 1 16 30 parameters1.log events_dat_xz.dat recs_xz.dat 1/2/3
+#
+#    scripts/plot_body_seis.pl OUTPUT_body 1 1 5300 1  1  8 parameters1.log events_dat_xz.dat recs_xz.dat 1/2/3
+#    scripts/plot_body_seis.pl OUTPUT_body 1 1 5300 1  9 16 parameters1.log events_dat_xz.dat recs_xz.dat 1/2/3
+#
+#==========================================================
+
+if (@ARGV < 3) {die("Usage: plot_body_seis.pl basedir ievent parm_file xxx \n");}
+($odir,$idata,$isyn,$irun,$ievent,$rmin,$rmax,$pfile,$efile,$rfile,$wtemp) = @ARGV;
+
+$strun = sprintf("%4.4i",$irun);
+$stev  = sprintf("%3.3i",$ievent);
+$basedir = "$odir/run_$strun";
+$dir = "$basedir/event_$stev";
+
+$evefile = "$basedir/$efile";
+$recfile = "$basedir/$rfile";
+
+ at comps   = split("/",$wtemp);     # indices of 1 or 2 components to plot
+$ncomp = @comps;
+
+# get parameters
+$parmfile = "$basedir/$pfile";
+if (not -f $parmfile) {die("Check if $parmfile exist or not\n")}
+open(IN,"$parmfile"); @lines = <IN>;
+($first,$end,$nint) = split(" ",$lines[0]);
+($XFOR,$YFOR,$ZFOR) = split(" ",$lines[1]);
+$stsrc = "source XYZ = ${XFOR}${YFOR}${ZFOR}";
+$dt = split(" ",$lines[2]);
+$hdur = split(" ",$lines[3]);
+print "\n frame $first to $end in increment of $nint \n DT = $dt, HDUR =  $hdur \n $stsrc \n";
+
+# get event
+if (not -f $evefile) {die("Check if $evefile exist or not\n")}
+open(IN,"$evefile"); @lines = <IN>;
+($xsrc,$zsrc,$junk1,$namesrc) = split(" ",$lines[$ievent-1]);
+print "\n source $namesrc is at (x, z) = ($xsrc, $zsrc) \n";
+
+# get number of receivers
+#open(IN,$recfile); @temp = <IN>; $nrec = @temp;
+$nrec = $rmax-$rmin+1;
+$strmin = sprintf("%2.2i",$rmin);
+$strmax = sprintf("%2.2i",$rmax);
+
+$iportrait = 1;
+if($iportrait == 1){$orient = "-P"} else {$orient = " "}
+
+# plotting specifications
+$fsize0 = "18";
+$fsize1 = "10";
+$fsize2 = "8";
+$fsize3 = "4";
+if($ilabs == 0) {$fontno = "1"} else {$fontno = "4"}
+$tick   = "0.1c";
+
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+
+#=================
+$cshfile = "plot_body_seis.csh";
+open(CSH,">$cshfile");
+print CSH "gmtset BASEMAP_TYPE plain MEASURE_UNIT inch PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+
+ at clabs = ("x","y","z");
+if($ncomp==1) { $stcomp = $clabs[$comps[0]-1] }
+if($ncomp==2) { $stcomp = $clabs[$comps[0]-1].$clabs[$comps[1]-1] }
+if($ncomp==3) { $stcomp = $clabs[$comps[0]-1].$clabs[$comps[1]-1].$clabs[$comps[2]-1] }
+print "\n $ncomp $stcomp \n";
+
+#-------------------------
+
+# write plotting scripts
+$xwid = 2.5;
+$ywid = 9/$nrec;
+$J = "-JX$xwid/$ywid";
+
+$dx0 = $xwid;                      
+$dy0 = $ywid;
+$dx1 = $dx0 + 0.1;
+$dy1 = $dy0 + 0.;
+$dy2 = ($nrec-1) * $dy1;
+
+$shift1 = "-X0 -Y-$dy1";
+$shift2 = "-X$dx1 -Y$dy2";
+
+$origin = "-X0.5 -Y9.25";
+$origin = "-X0.5 -Y8.75";
+
+$Dscale = "-D$hwid/-0.40/$hwid/0.1h";            # colorbar
+
+$name = "seis_${strun}_${stev}_${stcomp}_r${strmin}_r${strmax}";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+print "\nWriting CSH file...\n";
+
+#$nrec = 1;
+
+$nplots = $nrec*$ncomp;
+
+# loop over two selected components
+for ($j = 0; $j < $ncomp; $j++) {
+   
+  $icomp = $comps[$j];
+  $comp = $clabs[$icomp-1];
+  print "\n component to plot is $comp ($icomp) \n";
+  
+  if($j==0){$locate = $origin}
+  if($j==1){$locate = $shift2}
+  if($j==2){$locate = $shift2}
+
+# loop over seismograms
+#for ($i = 0; $i < $nrec; $i++) {
+for ($i = $rmin-1; $i <= $rmax-1; $i++) {
+
+   $irec = $i+1;
+   if($i > $rmin-1){$locate = $shift1}
+   $iplot = $j*$nrec + $i+1 - ($rmin-1);
+
+   if($idata==1){
+     $seisfile = sprintf("$dir/dat_%05d_%1d",$irec,$icomp);
+     if (not -f $seisfile) {die("Check if $seisfile exist or not\n")}
+   }
+   if($isyn == 1) {
+     $seisfile2 = sprintf("$dir/syn_%05d_%1d",$irec,$icomp);
+     if (not -f $seisfile2) {die("Check if $seisfile exist or not\n")}
+   }
+
+   print CSH "echo seismogram $iplot out of $nplots, $seisfile \n";
+
+   # get the bounds for the seismogram
+   $ss = 0;
+   ($tmin,$tmax,$smin,$smax) = split(" ",`minmax -C $seisfile`);
+   ($ss) = sort{$b <=> $a} ($ss,abs($smin),abs($smax));
+   $ymax = $ss*1.1;
+   $tmin = 0;
+   $R = "-R$tmin/$tmax/-$ymax/$ymax";
+
+   $tinc1 = 20;
+   $tinc2 = 10;
+    
+   $B0 = sprintf("-Ba{%3.3f}f{%3.3f}:\" \":/%3.3f:\" \"::.\" \":wesn",$tinc1,$tinc2,$ss/2);
+   $Bfull = sprintf("-Ba{%3.3f}f{%3.3f}:\"Time  (s)\":/%3.3f:\" z, h (t) \"::.\" \":weSn",$tinc1,$tinc2,$ss/2);
+   if ($i == $rmax-1) {$B = $Bfull.$Bopts[4]} else {$B = $B0.$Bopts[15]}
+
+   if ($i == $rmin-1 && $j == 0) {print CSH "psbasemap $J $R $B -K -V $orient $locate > $psfile\n"} # START
+   else {print CSH "psbasemap $J $R $B -K -O -V $orient $locate >> $psfile\n"}
+
+   # PLOT THE SEISMOGRAMS
+   if( $isyn == 1) {print CSH "awk '{print \$1,\$2}' $seisfile2 | psxy $R $J $B -W0.5p,255/0/0,-- $orient -K -O -V >> $psfile\n"}
+   if($idata == 1) {print CSH "awk '{print \$1,\$2}' $seisfile | psxy $R $J $B -W0.5p $orient -K -O -V >> $psfile\n"}
+
+   $label = "$irec($comp)";
+   $txtinfo = "-N -C3p -W255o";
+   #print CSH "pstext -N -JX1i/1i -R0/1/0/1 -K -O -V $orient >>$psfile<<EOF\n 0.1 0.5 $fsize2 0 $fontno LM $label \nEOF\n";
+   print CSH "pstext $txtinfo $J -R0/1/0/1 -K -O -V $orient >>$psfile<<EOF\n -0.05 0.5 $fsize2 0 $fontno LM $label \nEOF\n";
+
+# plot title and GMT header
+if ($i == $rmin-1 && $j == 0) {
+  $plabel = "/home/denali2/carltape/wave2d/2d_adjoint/plot_body_seis.pl";
+  $Utag = "-U/0/0.5i/$plabel";  # GMT header
+  $shift0 = "-Xa0i -Ya${dy1}i";
+  $title = "Seismograms for $dir/, $stsrc";
+  print CSH "pstext -N -JX1i/1i -R0/1/0/1 $Utag -K -O $orient -V $shift0 >>$psfile<<EOF\n 0 0.25 $fsize1 0 $fontno LM $title\nEOF\n";
+}
+
+ }  # for $i
+
+}  # for $j
+
+#-------------------------
+print CSH "pstext $J -R0/1/0/1 -O $orient -V >>$psfile<<EOF\n 10 10 $fsize0 0 $fontno CM junk \nEOF\n";  # FINISH
+print CSH "echo done with $psfile $seisfile\n";
+if($iportrait == 0){print CSH "convert $psfile -rotate 90 $jpgfile\n"}
+if($iportrait == 1){print CSH "convert $psfile $jpgfile\n"}
+
+close (CSH);
+system("csh -f $cshfile");
+system("xv $jpgfile &");


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_seis.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_wavefield.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_wavefield.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_wavefield.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,274 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_body_wavefield.pl
+#  Carl Tape
+#  17-Jan-2007
+#
+#-------------------------
+#  EXAMPLES:
+#
+#    scripts/plot_body_wavefield.pl OUTPUT_body 1 1 5100 1 parameters1.log 1/2/3 1200/1600/2000/2400/2800/3200 3/3/3 3.0/7.0/2.0 2 events_dat_xz.dat recs_xz.dat
+#    scripts/plot_body_wavefield.pl OUTPUT_body 1 0 5100 1 parameters1.log 1/2/3 1200/1600/2400/3200/4000/6000/8000 3/3/3 3.0/7.0/2.0 2 events_dat_xz.dat recs_xz.dat
+#    scripts/plot_body_wavefield.pl OUTPUT_body 0 0 5100 1 parameters1.log 1/2/3 1200/1600/2400/3200/4000/6000/8000 3/3/3 3.0/7.0/2.0 2 events_dat_xz.dat recs_xz.dat
+#
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5011 1 parameters1.log 2 1200/1600/2000/2400/3200/5200/6400 3 10.0 2 events_xy_dat.dat recs_xz.dat
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5011 1 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 3.0/7.0/2.0 2 events_xy_dat.dat recs_xz.dat
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5011 2 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 3.0/10.0/3.0 2 events_xy_dat.dat recs_xz.dat
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5011 3 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 3.0/7.0/2.0 2 events_xy_dat.dat recs_xz.dat
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5011 4 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 2.5/7.0/1.5 2 events_xy_dat.dat recs_xz.dat
+#
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5010 1 parameters1.log 2 1200/1600/2000/2400/3200/5200/6400 3 10.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5010 1 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 3.0/7.0/2.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5010 2 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 3.0/10.0/3.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5010 3 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 3.0/7.0/2.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5010 4 parameters1.log 1/2/3 1200/1600/2000/2800/3600/4800 3/3/3 2.5/7.0/1.5 2
+#
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5000 2 parameters1.log 2 1200/1600/2000/2400/3200/5200/6400 3 10.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5000 1 parameters1.log 1/2/3 800/1200/1600/2000/2400/2800 3/3/3 4.0/10.0/3.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5000 2 parameters1.log 1/2/3 800/1200/1600/2000/2400/2800 3/3/3 4.0/10.0/3.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5000 3 parameters1.log 1/2/3 800/1200/1600/2000/2400/2800 3/3/3 4.0/10.0/3.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5001 1 parameters1.log 1/2/3 800/1200/1600/2000/2400/2800 3/3/3 3.5/10.0/7.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5001 2 parameters1.log 1/2/3 800/1200/1600/2000/2400/2800 3/3/3 3.5/10.0/7.0 2
+#    scripts/plot_body_wavefield.pl OUTPUT_body 5001 3 parameters1.log 1/2/3 800/1200/1600/2000/2400/2800 3/3/3 3.5/10.0/7.0 2
+#
+#==========================================================
+
+if (@ARGV < 3) {die("Usage: plot_body_wavefield.pl basedir ievent parm_file f1/f2/f3 pwr1/pwr2/pwr3 c1/c2/c3 \n");}
+($odir,$idata,$iportrait,$irun,$ievent,$pfile,$wtemp,$ftemp,$ptemp,$ctemp,$ilabs,$efile,$rfile) = @ARGV;
+
+$strun = sprintf("%4.4i",$irun);
+$stev  = sprintf("%3.3i",$ievent);
+
+$basedir = "$odir/run_$strun";
+$dir = "$basedir/event_$stev";
+
+$evefile = "$basedir/$efile";
+$recfile = "$basedir/$rfile";
+
+ at comps   = split("/",$wtemp);     # indices of 1 or 2 components to plot
+#($first,$end,$nint) = split("/",$range);
+ at frames  = split("/",$ftemp);
+ at pwr     = split("/",$ptemp);     # PWR  : increase (larger negative power) for more contrast
+ at cmax    = split("/",$ctemp);     # CMAX : decrease for more contrast
+$numf = @frames;
+$ncomp = @comps;
+
+# suffixes for the wavefield files
+ at labs = ("_syn","_dat");
+$suffix = $labs[$idata];
+#$suffix = "";
+
+# get parameters
+$parmfile = "$basedir/$pfile";
+if (not -f $parmfile) {die("Check if $parmfile exist or not\n");}
+open(IN,"$parmfile");
+ at lines = <IN>;
+($first,$end,$nint) = split($lines[0]);
+($XFOR,$YFOR,$ZFOR) = split(" ",$lines[1]);
+$stsrc = "source XYZ = ${XFOR}${YFOR}${ZFOR}";
+$dt = $lines[2];
+$hdur = $lines[3];
+print "\n frame $first to $end in increment of $nint \n DT = $dt, HDUR =  $hdur \n $stsrc \n";
+
+# get event
+if (not -f $evefile) {die("Check if $evefile exist or not\n")}
+open(IN,"$evefile"); @lines = <IN>;
+($xsrc,$zsrc,$junk1,$namesrc) = split(" ",$lines[$ievent-1]);
+print "\n source $namesrc is at (x, z) = ($xsrc, $zsrc) \n";
+
+# ilabs: how many labels you want on the plots
+#  [0] for talks
+#  [1] for publication
+#  [2] for notes
+
+# plot the color frames or not
+$icolor = 1;    # ccc
+
+if($iportrait == 1){
+  $orient = "-P";
+  $wid = 2.25;
+  $origin = "-X0.7 -Y8.70";
+} else {
+  $orient = " ";
+  $wid = 3.25;
+  $origin = "-X0.7 -Y6.70";
+}
+
+# plotting specifications
+$fsize0 = "18";
+$fsize1 = "10";
+$fsize2 = "8";
+$fsize3 = "4";
+if($ilabs == 0) {$fontno = "1"} else {$fontno = "4"}
+$tick   = "0.1c";
+
+# plot symbols for sources, receivers, and shelf
+if($ifinite==0) {$src = "-W0.5p -Sa0.10";} else {$src = "-Sc0.05";}
+$rec = "-Si6p -W0.5p,0/0/0";
+$src = "-Sa10p -W0.5p -G255/255/255";   # nice white source (GJI figures)
+
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+
+#=================
+$cshfile = "plot_body_wavefield.csh";
+open(CSH,">$cshfile");
+print CSH "gmtset BASEMAP_TYPE plain MEASURE_UNIT inch PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+ at norm = ("1e-$pwr[0]","1e-$pwr[1]","1e-$pwr[2]");
+
+print "@norm \n";
+
+ at clabs = ("x","y","z");
+ at wavefield=("forward${suffix}","adjoint","kernel");
+$numw = @wavefield;
+
+if($ncomp==1) { $stcomp = $clabs[$comps[0]-1] }
+if($ncomp==2) { $stcomp = $clabs[$comps[0]-1].$clabs[$comps[1]-1] }
+if($ncomp==3) { $stcomp = $clabs[$comps[0]-1].$clabs[$comps[1]-1].$clabs[$comps[2]-1] }
+
+# bounds for plotting (we could also use the file global_mesh.dat)
+$firstframe = "$dir/forward${suffix}_00000";
+if (not -f $firstframe) {die("Check if $firstframe exist or not\n");}
+#($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C -I1/1 $firstframe`);
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $firstframe`);
+$xmin = $xmin/1000; $xmax = $xmax/1000;
+$zmin = $zmin/1000; $zmax = $zmax/1000;
+$pinc = 0.0;  # buffer around min/max
+$xran = $xmax - $xmin; $zran = $zmax - $zmin;
+$xmin = $xmin-$pinc*$xran;  $xmax = $xmax+$pinc*$xran;
+$zmin = $zmin-$pinc*$zran;  $zmax = $zmax+$pinc*$zran;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+$k = 0;
+
+# loop over two selected components
+for ($j = 0; $j < $ncomp; $j++) {
+
+  $ss[$j] = $cmax[$j];
+  $ds[$j] = 2*$ss[$j]/$scale_color;
+  $bs[$j] = sprintf("%3.3e",0.9*$ss[$j]);  # colorbar
+  $Ts[$j] = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss[$j],$ss[$j],$ds[$j]);
+  print "Ts = $Ts[$j]\n";
+  print CSH "makecpt -C$colorbar $Ts[$j] -D > color_${j}.cpt\n";
+}
+
+#-------------------------
+
+# write plotting scripts
+$hwid = $wid/2;
+$dx0 = $wid;                      
+$dy0 = $dx0*($zran/$xran);
+$J = "-JX${dx0}i/${dy0}i";
+
+$dx1 = $dx0*1.05;
+$dy1 = $dy0*1.5;
+$dy2 = ($numf-1) * $dy1;
+
+$shift1 = "-X0 -Y-$dy1";
+$shift2 = "-X$dx1 -Y$dy2";
+
+$Dscale = "-D$hwid/-0.40/$hwid/0.1h";            # colorbar
+
+$name = "wavefield${suffix}_${strun}_${stev}_${stcomp}";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+print "\nWriting CSH file...\n";
+
+#$numf = 1;
+
+$nplots = $numf*$ncomp;
+
+# loop over two selected components
+for ($j = 0; $j < $ncomp; $j++) {
+   
+  $comp = $clabs[$comps[$j]-1];
+  print "\n component to plot is $comp ($comps[$j]) \n";
+  
+  if($j==0){$locate = $origin}
+  if($j==1){$locate = $shift2}
+  if($j==2){$locate = $shift2}
+ 
+  # color bar
+  $BscaleS1 = sprintf("-B%2.2e:\" s\@-$comp\@- ( x, z, t )  ( 10\@+-%2.2i\@+  m )\": -E10p",$bs[$j]/2,$pwr[$j]);
+
+# loop over time frames
+for ($i = 0; $i < $numf; $i++) {
+
+   $j1 = $frames[$i];           # forward frame
+   if($i > 0){$locate = $shift1}
+
+   $time = sprintf("%04d",$j1*$dt);
+
+   $snapshot_f = sprintf("$dir/$wavefield[0]_%05d",$j1);
+   if (not -f $snapshot_f) {die("Check if $snapshot_f exist or not\n");}
+
+   $iplot = $j*$numf + ($i+1);
+   print CSH "echo plot $iplot out of $nplots \n";
+    
+   $Bfull = "-B50/50:\"t = $time s\"::.\"  \":";
+   $B = $Bfull.$Bopts[15];
+   if ($j == 0) {$B = $Bfull.$Bopts[1]}
+   if ($i==$numf-1) {$B = $Bfull.$Bopts[4]}
+   if ($i==$numf-1 && $j==0) {$B = $Bfull.$Bopts[8]}
+
+   if ($i == 0 && $j == 0) {print CSH "psbasemap $J $R $B -K $orient -V $locate > $psfile\n"} # START
+   else {print CSH "psbasemap $J $R $B -K -O $orient -V $locate >> $psfile\n"}
+
+   # PLOT THE FORWARD WAVEFIELD
+   #if($icolor==1) {print CSH "awk '{print \$1/1000,\$2/1000,\$($comps[$j]+2) / $norm[$j]}' $snapshot_f | pscontour $J $R $B -A- -Ccolor_${j}.cpt -I -K -O $orient -V >> $psfile\n"}
+
+   if($icolor==1) {
+      $grdfile = "temp.grd";
+      $grdinfo = "-I1/1 -S2";   # key information
+      #print CSH "awk '{print \$1/1000,\$2/1000,\$($comps[$j]+2) / $norm[$j]}' $snapshot_f > test\n";
+      print CSH "awk '{print \$1/1000,\$2/1000,\$($comps[$j]+2) / $norm[$j]}' $snapshot_f | nearneighbor -G$grdfile $R $grdinfo\n";
+      print CSH "grdimage $grdfile -Ccolor_${j}.cpt $J -K -O $orient -V >> $psfile\n";
+   }
+
+  # plot discontinutities
+  print CSH "psxy -N $J $R -K -O -P -V -W0.5p >> $psfile<<EOF\n 0 45 \n 400 45 \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -P -V -W0.5p >> $psfile<<EOF\n 0 65 \n 400 65 \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -P -V -W0.5p >> $psfile<<EOF\n 0 75 \n 400 75 \nEOF\n";
+
+   if ($i == $numf-1 && $ilabs > 0) {print CSH "psscale -Ccolor_${j}.cpt $Dscale $BscaleS1 -K -O $orient -V >> $psfile \n"}
+
+   # plot source and receivers
+   $xs = $xsrc/1000; $zs = $zsrc/1000;
+   print CSH "psxy -N $J $R -K -O -V $orient $src >> $psfile<<EOF\n $xs $zs \nEOF\n";
+   print CSH "awk '{print \$1/1000,\$2/1000}' $recfile |psxy -N $J $R -K -O $orient -V $rec >> $psfile\n";
+   #print CSH "awk '\$1 == \"R\" {print \$2/1000,\$3/1000}' $dir/sr.txt |psxy -N $J $R -K -O $orient -V $rec >> $psfile\n";
+   #print CSH "awk '\$1 == \"S\" {print \$2/1000,\$3/1000}' $dir/sr.txt |psxy -N $J $R -K -O $orient -V $src >> $psfile\n";
+   
+   # plot title
+   $xtx = $xmin+0.5*($xmax-$xmin); $ztx = $zmin+1.15*($zmax-$zmin); 
+   #if ($i == $numf-1) {print CSH "pstext -N $J $R -K -O $orient -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[0]\nEOF\n";}
+
+# plot title and GMT header
+if ($ilabs == 2 && $i == 0) {
+  $plabel = "/home/denali2/carltape/wave2d/2d_adjoint/plot_body_wavefield.pl";
+  $Utag = "-U/0/0.2i/$plabel";  # GMT header
+  if($j > 0) {$Utag = " "}
+  $shift0 = "-Xa0i -Ya${dy1}i";
+  $title = "$comp comp of disp, $stsrc";
+  print CSH "pstext -N $J $R $Utag -K -O $orient -V $shift0 >>$psfile<<EOF\n 0 0 $fsize1 0 $fontno LM $title\nEOF\n";
+}
+
+ }  # for $i
+
+}  # for $j
+
+#-------------------------
+print CSH "pstext $J -R0/1/0/1 -O $orient -V >>$psfile<<EOF\n 10 10 $fsize0 0 $fontno CM junk \nEOF\n";  # FINISH
+print CSH "echo done with $psfile $snapshot_f\n";
+if($iportrait == 0){print CSH "convert $psfile -rotate 90 $jpgfile\n"}
+if($iportrait == 1){print CSH "convert $psfile $jpgfile\n"}
+
+close (CSH);
+system("csh -f $cshfile");
+system("xv $jpgfile &");


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_body_wavefield.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_geometry.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_geometry.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_geometry.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,226 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_geometry.pl
+#  Carl Tape
+#  19-Nov-2008
+#
+#  This plots the source-receiver geometry and source time function (STF) for two possible cases
+#     1.  PSV wavefield, view from side, three components of STF
+#     2.  SH wavefield, top view from surface, one component of STF
+#
+#  EXAMPLES (from /home/carltape/wave2d/2d_adjoint/PLOTTING/FIGURES):
+#    ../plot_geometry.pl 0 100 events_dat_lonlat.dat recs_lonlat.dat stf_00001 structure_syn.dat 10.0
+#    ../plot_geometry.pl 0 200 events_dat_lonlat.dat recs_lonlat.dat stf_00001 structure_syn.dat 10.0
+#    ../plot_geometry.pl 0 300 events_dat_lonlat.dat recs_lonlat.dat stf_00001 structure_syn.dat 10.0
+#    ../plot_geometry.pl 0 400 events_dat_lonlat.dat recs_lonlat.dat stf_00001 structure_syn.dat 10.0
+#    ../plot_geometry.pl 0 500 events_dat_lonlat.dat recs_lonlat.dat stf_00001 structure_syn.dat 10.0
+#
+#==========================================================
+
+if (@ARGV < 7) {die("Usage: plot_geometry.pl xxx \n");}
+($ibody,$irun,$efile_syn,$rfile_syn,$stf_tag,$mfile_syn,$hdur) = @ARGV;
+
+# directories
+$rundir = "/home/carltape/wave2d/SEM2D_iterate";    # USER change
+$plotdir = "${rundir}/PLOTTING";
+$odir = "${rundir}/OUTPUT";
+$figdir = "${plotdir}/FIGURES";
+if (not -e $figdir) {die("Check if figdir $figdir exist or not\n");}
+
+$strun = sprintf("%4.4i",$irun);
+$rdir = "run_${strun}";
+$basedir = "${odir}/${rdir}";
+$evefile = "$basedir/${efile_syn}";
+$recfile = "$basedir/${rfile_syn}";
+$file1syn = "$basedir/${mfile_syn}";
+
+# event to choose for getting source time function
+$ievent = 5;
+$stev  = sprintf("%3.3i",$ievent);
+$edir = "${basedir}/event_${stev}";
+$stffile1 = "$edir/${stf_tag}_1";
+$stffile2 = "$edir/${stf_tag}_2";
+$stffile3 = "$edir/${stf_tag}_3";
+
+if (not -f $evefile) {die("Check if evefile $evefile exist or not\n");}
+if (not -f $recfile) {die("Check if recfile $recfile exist or not\n");}
+if (not -f $file1syn) {die("Check if file1syn $file1syn exist or not\n");}
+#if (not -f $stffile1) { die("Check if $stffile1 exist or not\n") }
+#if (not -f $stffile2) { die("Check if $stffile2 exist or not\n") }
+#if (not -f $stffile3) { die("Check if $stffile3 exist or not\n") }
+
+#$edir  = sprintf("$edir/event_%3.3i",$event);
+#print "\n $dir,$edir,$mfile_dat,$mfile_syn,$c0,$per,$ifinite,$iopt \n";
+
+$plabel = "${plotdir}/plot_geometry.pl";
+
+#die("\ntesting\n");
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";			# 1 or 4
+$tick   = "0.2c";
+
+# plot symbols for sources, receivers, and shelf
+$size = 15; $hsize = $size/2;
+$src = "-Sa${size}p -W0.5p,0/0/0 -G255/255/255";
+#$rec = "-Si${size}p -W0.5p -D0/${hsize}p -G0/255/0";
+$rec = "-Si${size}p -W0.5p -G0/255/0";
+
+# write plotting scripts
+
+if ($ibody == 1) {
+  $wid = 7;
+  $dx0 = $wid;
+  $dy0 = $dx0*($zran/$xran);
+  $J = "-JX${dx0}i/${dy0}i";
+  $origin = "-X1.0 -Y6.5";
+  $nstf = 3;
+
+  ($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C -I2 $file1syn`);
+  $xmin = $xmin/1000; $xmax = $xmax/1000;
+  $zmin = $zmin/1000; $zmax = $zmax/1000;
+  $pinc = 0.0;			# buffer around min/max
+  $B = "-B20:.\" \":WESn";
+  @stflabs = ("x, h (t)","y, h (t)","z, h (t)");
+  $xtick1 = 1; $xtick2 = 1;
+  $ytick1 = $xtick1; $ytick2 = $ytick1;
+  $Bopt = "WESn";
+
+} else {
+  $wid = 6;
+  $J = "-JM${wid}i";
+  $origin = "-X1.25 -Y3.5";
+  $nstf = 1;
+  $pinc = 0.;
+  ($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1syn`);
+  @stflabs = ("h (t)","h (t)","h (t)");
+  $xtick1 = 1; $xtick2 = 0.25;
+  $ytick1 = $xtick1; $ytick2 = $ytick1;
+  $Bopt = "WESN";
+}
+$B = "-Ba${xtick1}f${xtick2}:.\" \":${Bopt}";
+
+# bounds for plotting
+$xran = $xmax - $xmin; $zran = $zmax - $zmin;
+$xmin = $xmin-$pinc*$xran;  $xmax = $xmax+$pinc*$xran;
+$zmin = $zmin-$pinc*$zran;  $zmax = $zmax+$pinc*$zran;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+print "\n $R \n";
+
+# plot title
+$xtx = $xmin+0.5*($xmax-$xmin);
+$ztx = $zmin+1.10*($zmax-$zmin);
+
+$name = "geometry_${strun}";
+$psfile  = "${name}.ps";
+$jpgfile = "${name}.jpg";
+
+#===============================================
+print "\nWriting CSH file...\n";
+$cshfile = "plot_geometry.csh";
+open(CSH,">$cshfile");
+print CSH "gmtset BASEMAP_TYPE plain PAPER_MEDIA letter MEASURE_UNIT inch TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+#===============================================
+
+#$origin = "-X1.0 -Y6.5";
+
+# make text files for plotting source and receiver
+$just = "CM"; $angle = 0;
+if ($ibody==1) {
+  print CSH "awk '{print \$1/1000,\$2/1000,$fsize3,$angle,$fontno,\"$just\",\$3}' $recfile > rectext\n";
+  print CSH "awk '{print \$1/1000,\$2/1000,$fsize3,$angle,$fontno,\"$just\",\$3}' $evefile > evetext\n";
+} else {
+  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $recfile > rectext\n";
+  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $evefile > evetext\n";
+}
+
+# phase velocity map
+print CSH "psbasemap $J $R $B -K -P -V $origin > $psfile\n"; # START
+
+# plot discontinutities
+if ($ibody==1) {
+  print CSH "psxy -N $J $R -K -O -V -W0.5p >> $psfile<<EOF\n 0 45 \n 400 45 \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -V -W0.5p >> $psfile<<EOF\n 0 65 \n 400 65 \nEOF\n";
+  print CSH "psxy -N $J $R -K -O -V -W0.5p >> $psfile<<EOF\n 0 75 \n 400 75 \nEOF\n";
+} else {
+  print CSH "pscoast $J $R $B -W1p -Na/1p -Dh -K -O -V >> $psfile\n";
+}
+
+# plot sources
+if ($ibody==1) {
+  print CSH "awk '{print \$1/1000,\$2/1000}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+} else {
+  print CSH "awk '{print \$1,\$2}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+}
+print CSH "pstext rectext -N $J $R -K -O -V >> $psfile\n";
+
+# plot receivers
+if ($ibody==1) {
+  print CSH "awk '{print \$1/1000,\$2/1000}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+} else {
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+}
+print CSH "pstext evetext -N $J $R -K -O -V >> $psfile\n";
+
+# plot title and GMT header
+$Utag = "-U/0/0.25/$plabel";
+if($ibody==1) {$ytemp = $dy0 * 1.2;} else {$ytemp = $wid*1.1}
+$dX = 0;
+$shift = "-Xa-$dX -Ya$ytemp";
+$title = "Source receiver geometry ($rdir)";
+print CSH "pstext -N $J $R $Utag -K -O -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $title \nEOF\n";
+
+#===============================================
+
+# source time function
+print "\n Source time function is $stffile1\n";
+  
+# determine the max value among the source time functions
+for ($k = 1; $k <= $nstf; $k ++ ) {
+  $sfile = "${edir}/${stf_tag}_${k}";
+  if (not -f $sfile) {die("Check if sfile $sfile exist or not\n");}
+  ($tmin,$tmax,$smin,$smax) = split(" ",`minmax -C $sfile`);
+  ($ss) = sort{$b <=> $a} (abs($smin),abs($smax));
+}
+if ($ss==0) {
+  $ss = 1;
+}				# do not normalize by zero
+print "tmin = $tmin\ntmax = $tmax\nss = $ss\n";
+$tinc = 20;
+
+#$stf_data = "temp";
+$Bs1 = sprintf("-Ba%3.3ff10:\" \":/%3.3f:\"%s\"::.\"Source time function (hdur = %3.1f s)\":WesN",$tinc,0.5,$stflabs[0],$hdur);
+$Bs2 = sprintf("-Ba%3.3ff10:\"Time  (s)\":/%3.3f:\"%s\"::.\" \":Wesn",$tinc,0.5,$stflabs[1]);
+$Bs3 = sprintf("-Ba%3.3ff10:\"Time  (s)\":/%3.3f:\"%s\"::.\" \":WeSn",$tinc,0.5,$stflabs[2]);
+$Rs = "-R$tmin/$tmax/-1/1";
+$ywid = 1.25;
+$Js = "-JX$wid/$ywid";
+
+$shift1 = "-X0 -Y-2.75";
+$shift2 = "-X0 -Y-$ywid";
+
+print CSH "awk '{print \$1,\$2/$ss}' $stffile1 | psxy $Rs $Js $Bs1 -W1p -K -O -V $shift1 >> $psfile\n";
+if ($ibody==1) {
+  print CSH "awk '{print \$1,\$2/$ss}' $stffile2 | psxy $Rs $Js $Bs2 -W1p -K -O -V $shift2 >> $psfile\n";
+  print CSH "awk '{print \$1,\$2/$ss}' $stffile3 | psxy $Rs $Js $Bs3 -W1p -K -O -V $shift2 >> $psfile\n";
+}
+
+$plot_title = "Velocity model and source time function";
+print CSH "pstext -N $J -R0/1/0/1 -O -V >>$psfile<<EOF\n 10 10 $fsize0 0 $fontno CM $plot_title\nEOF\n"; # FINISH
+
+#-----------------------------
+print CSH "convert $psfile $jpgfile\n";
+print CSH "echo done with $psfile\n";
+
+close (CSH);
+system("csh -f $cshfile");
+system("ghostview $psfile &")
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_geometry.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_image.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_image.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_image.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,288 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_image.pl
+#  Carl Tape
+#  20-Oct-2006
+#
+#  This function inputs a lon-lat-val file and plots the image.
+#  It is designed to either take a lat-lon plot ($isurf = 1) or a depth section ($isurf = 0).
+#
+#  Examples:
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5013 structure_dat.dat 1/2/3 5.5/8.0/0.50/3 SoCal_1D P_wave_speed socal_P -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5013 structure_dat.dat 1/2/4 3.0/4.5/0.25/3 SoCal_1D S_wave_speed socal_S -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5013 structure_dat.dat 1/2/5 2.4/3.0/0.10/3 SoCal_1D Density socal_d -I1 -S4
+#
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5000 structure_dat.dat 1/2/5 2.4/3.0/0.10/3 SoCal_1D Density socal_d -I1 -S4
+#
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100 structure_dat.dat 1/2/3 5.5/8.0/0.50/3 SoCal_1D P_wave_speed socal_P 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100 structure_dat.dat 1/2/4 3.0/4.5/0.25/3 SoCal_1D S_wave_speed socal_S 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100 structure_syn.dat 1/2/3 5.5/8.0/0.50/3 Homogeneous P_wave_speed socal_P_m0 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100 structure_syn.dat 1/2/4 3.0/4.5/0.25/3 Homogeneous S_wave_speed socal_S_m0 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5101 structure_syn.dat 1/2/3 5.5/8.0/0.50/3 Test_model P_wave_speed socal_P_m0t 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5101 structure_syn.dat 1/2/4 3.0/4.5/0.25/3 Test_model S_wave_speed socal_S_m0t 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5102 structure_syn.dat 1/2/3 5.5/8.0/0.50/3 model_1 P_wave_speed socal_P_m1 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5102 structure_syn.dat 1/2/4 3.0/4.5/0.25/3 model_1 S_wave_speed socal_S_m1 1 -I1 -S4
+#
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5250 structure_dat.dat 1/2/3 5.7/6.3/0.2/3 SoCal_1D P_wave_speed socal_P 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100 structure_dat.dat 1/2/4 3.3/3.7/0.2/3 SoCal_1D S_wave_speed socal_S 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5250 structure_syn.dat 1/2/3 5.7/6.3/0.2/3 Homogeneous P_wave_speed socal_P_m0 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100 structure_syn.dat 1/2/4 3.3/3.7/0.2/3 Homogeneous S_wave_speed socal_S_m0 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5106 structure_syn.dat 1/2/3 5.7/6.3/0.2/3 Homogeneous P_wave_speed socal_P_m3 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5106 structure_syn.dat 1/2/4 3.3/3.7/0.2/3 Homogeneous S_wave_speed socal_S_m3 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5118 structure_syn.dat 1/2/3 5.7/6.3/0.2/3 Homogeneous P_wave_speed socal_P_m9 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5118 structure_syn.dat 1/2/4 3.3/3.7/0.2/3 Homogeneous S_wave_speed socal_S_m9 1 -I1 -S4
+#
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5200 summed_ker.dat 1/2/3 -5/5/1/-11 SoCal_1D alpha_kernel atest 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5200 summed_ker.dat 1/2/4 -5/5/1/-10 SoCal_1D beta_kernel btest 1 -I1 -S4
+#    scripts/plot_image.pl 0 . fun_smooth.dat 1/2/5 -5/5/1/-10 Unsmoothed_event_kernel_beta K_beta unsmoothed 1 -I1 -S4
+#    scripts/plot_image.pl 0 . fun_smooth.dat 1/2/7 -5/5/1/-10 Smoothed_event_kernel_beta K_beta smoothed 1 -I1 -S4
+#
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100/event_001 kernel_basis 1/2/3 -3/3/1/-12 Kalpha Kalpha Kalpha_5100 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5100/event_001 kernel_basis 1/2/4 -3/3/1/-11 Kbeta Kbeta Kbeta_5100 1 -I1 -S4
+#
+#    scripts/plot_image.pl 0 . fun_smooth.dat 1/2/5 -1/1/1/-6 Unsmoothed_event_kernel_beta K_beta unsmoothed 1 -I1 -S4
+#    scripts/plot_image.pl 0 . fun_smooth.dat 1/2/7 -1/1/1/-6 Smoothed_event_kernel_beta K_beta smoothed 1 -I1 -S4
+#
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5300 structure_dat.dat 1/2/3 5.5/7.8/0.2/3 SoCal_1D P_wave_speed socal_P 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5300 structure_dat.dat 1/2/4 3.2/4.5/0.2/3 SoCal_1D S_wave_speed socal_S 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5300 structure_syn.dat 1/2/3 5.5/7.8/0.2/3 SoCal_1D P_wave_speed socal_P_m0 1 -I1 -S4
+#    scripts/plot_image.pl 0 OUTPUT_2/run_5300 structure_syn.dat 1/2/4 3.2/4.5/0.2/3 SoCal_1D S_wave_speed socal_S_m0 1 -I1 -S4
+#
+#-------------------------------
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4086 socal_vel_dat.dat 1/2/4 -20/20/5/-2 Phase_velocity_map Percent_Perturbation -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_0460 summed_ker.dat 1/2/3 -1.5/1.5/0.5/-6 Misfit_kernel Misfit_kernel -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_0460/event_005 kernel_basis 1/2/3 -0.5/0.5/0.25/-7 Event_kernel Event_kernel -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4480/event_005 kernel_basis 1/2/3 -5/5/2/-8 Event_kernel_TT_xcorr Event_kernel Event_kernel_TT_xcorr 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4512 socal_vel_syn.dat 1/2/4 -10/10/2/-2 Model_16 Percent_Perturbation fun 1 -I0.5m/0.5m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4512 socal_vel_dat.dat 1/2/4 -10/10/2/-2 Model_16 Percent_Perturbation fun 1 -I0.5m/0.5m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4600/event_005 kernel_basis 1/2/3 -5/5/2/-5 Event_kernel_TT_mtm Event_kernel Event_kernel_TT_mtm 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4300 summed_ker.dat 1/2/3 -1/1/1/-14 Event_kernel_IKER0 Event_kernel Event_kernel_IKER0 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4350 summed_ker.dat 1/2/3 -5/5/2/-8 Event_kernel_IKER1 Event_kernel Event_kernel_IKER1 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4400 summed_ker.dat 1/2/3 -5/5/2/-10 Event_kernel_IKER2 Event_kernel Event_kernel_IKER2 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4450 summed_ker.dat 1/2/3 -5/5/2/-5 Event_kernel_IKER3 Event_kernel Event_kernel_IKER3 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4500 summed_ker.dat 1/2/3 -5/5/2/-7 Event_kernel_IKER4 Event_kernel Event_kernel_IKER4 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4600/event_019 kernel_basis 1/2/3 -1/1/0.5/-9 BD_kernel_IKER6 BD_kernel BD_kernel_IKER6 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_0460 fun_smooth.dat 1/2/5 -1/1/0.5/-6 Unsmoothed_event_kernel kernel test0 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_0460 fun_smooth.dat 1/2/6 -3/3/1.0/-10 Gaussian_smoothing_function amplitude test1 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_0460 fun_smooth.dat 1/2/7 -1/1/0.5/-6 Smoothed_event_kernel kernel test2  1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_0460 fun_smooth.dat 1/2/8 -1/1/0.5/-6 Residual residual test3 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4950/event_001 kernel_basis 1/2/3 -5/5/1/-8 test test test_4950 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_4900/event_001 kernel_basis 1/2/3 -5/5/1/-8 test test test_4900 1 -I1 -S4
+#
+#    scripts/plot_image.pl 1 OUTPUT_1/run_5102 structure_syn.dat 1/2/4 -10/10/5/-2 Phase_velocity_map Percent_Perturbation test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_1/run_5101 structure_syn.dat 1/2/4 -10/10/5/-2 Phase_velocity_map Percent_Perturbation test_model 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5700 structure_dat.dat 1/2/4 3/4/0.5/3 Target_model S_wave_speed test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5751 structure_syn.dat 1/2/4 3/4/0.5/3 Reference_model S_wave_speed test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5752 structure_syn.dat 1/2/4 3/4/0.5/3 Reference_model S_wave_speed test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5703 structure_syn.dat 1/2/4 3/4/0.5/3 Reference_model S_wave_speed test 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5800 structure_dat.dat 1/2/4 3/4/0.5/3 Target_model S_wave_speed test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5801 structure_syn.dat 1/2/4 3/4/0.5/3 Reference_model S_wave_speed test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5806 structure_syn.dat 1/2/4 3/4/0.5/3 Reference_model S_wave_speed test 1 -I1m -S4m
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5803 structure_syn.dat 1/2/4 3/4/0.5/3 Reference_model S_wave_speed test 1 -I1m -S4m
+#
+#    scripts/plot_image.pl 1 OUTPUT_2/run_5750 summed_ker.dat 1/2/4 -1/1/1/-6 Event_kernel_IKER0 Event_kernel Event_kernel_IKER0 1 -I1m -S4m
+#
+#==========================================================
+
+if (@ARGV < 3) {die("Usage: plot_image.pl basedir xxx \n");}
+($isurf,$idir,$infile,$dcols,$colors,$title,$scale_label,$filename,$iportrait,$I,$S) = @ARGV;
+
+#print "\n $isurf\n $idir\n $infile\n $dcols\n $colors\n $title\n $scale_label\n $filename\n $I\n $S\n"; die("testing");
+#print "\n $filename\n"; die("testing");
+
+# color specifications
+ at temp  = split("/",$colors);
+$cmin  = $temp[0];
+$cmax  = $temp[1];
+$ctick = $temp[2];
+$cpwr  = $temp[3];
+$cnorm = "1e$cpwr";
+print "\n $cmin $cmax $cpwr $cnorm \n";
+
+ at icol = split("/",$dcols);
+ at plot_title = split("_",$title);
+ at scale_title = split("_",$scale_label);
+
+$datafile = "$idir/$infile";
+if (not -f $datafile) { die("Check if $datafile exist or not\n") }
+print "\n data file is $datafile\n";
+
+$nwrd = @plot_title;
+$plot_title[$nwrd] = " ($datafile)";
+
+$plabel = "/home/denali2/carltape/wave2d/2d_adjoint/scripts/plot_image.pl";
+
+#die("\ntesting\n");
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.1c";
+
+# plot symbols for sources, receivers, and shelf
+$src = "-Sc0.05";
+$rec = "-W0.5p/0/0/0 -St0.10";
+$rec0 = "-Sc10p -W0.5p";
+$Wshelf = "-W1.0/0/0/0tap";
+
+$coastinfo = "-W1p -N1/1p -N2/1p -Df -A100";   # why doesn't the border pen-width work?
+
+#-------------------------
+# color
+
+# KEY: scaling for color
+$colorinc = 21.0;
+$colorbar = "seis";
+
+#-------------------------
+
+# write plotting scripts
+if($isurf == 1) {$btick1 = 1; $btick2 = 0.25}
+if($isurf == 0) {$btick1 = 40; $btick2 = 10}
+$B = "-Ba${btick1}f${btick2}:.\" \":WESN";
+
+#$Bscale  = sprintf("-B%2.2e:\" Percent Perturbation from %3.3f  km s\@+-1\@+ \": -E10p",$ptick,$c0/1000);
+$Bscale  = sprintf("-B%2.2e:\" @scale_title  ( 10\@+%2.2i\@+ )\": -E10p",$ctick,$cpwr);
+
+#-------------------------
+
+# bounds for the plotting
+#($xmin,$xmax,$zmin,$zmax,$smin,$smax,$tmin,$tmax) = split(" ",`minmax -C $datafile`);
+#($tt) = sort{$b <=> $a} ($tt,abs($tmin),abs($tmax));
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $datafile`);
+if($isurf==0) {
+  $xmin = $xmin/1000; $xmax = $xmax/1000;
+  $zmin = $zmin/1000; $zmax = $zmax/1000;
+}
+if($isurf==1){$pinc = 0.05}
+if($isurf==0){$pinc = 0.0}
+$xran = $xmax - $xmin; $zran = $zmax - $zmin;
+$xmin = $xmin-$pinc*$xran;  $xmax = $xmax+$pinc*$xran;
+$zmin = $zmin-$pinc*$zran;  $zmax = $zmax+$pinc*$zran;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+print "\n bounds are $R \n";
+
+# projection
+$xwid = 6.0;
+$ywid = $xwid*($zran/$xran);
+if($isurf == 1) {$J = "-JM${xwid}i"; $ywid = $xwid}
+if($isurf == 0) {$J = "-JX${xwid}i/${ywid}i"}
+$origin = "-X1.0i -Y3.0i";
+print "\n projection is $J \n";
+
+# page orientation
+if($iportrait == 1){$orient = "-P"} else {$orient = " "}
+
+$Dlen = 0.7*$xwid;
+$Dx = $xwid/2;
+$Dy = -0.35;
+$Dscale = "-D$Dx/$Dy/$Dlen/0.15h";
+print "\n color bar is $Dscale \n $Bscale \n";
+
+#die("testing");
+
+# plot title
+#$xtx = $xmin+0.5*($xmax-$xmin);
+#$ztx = $zmin+1.10*($zmax-$zmin);
+
+# plot title (see plot_body_geometry.pl ?)
+$R_title = "-R0/1/0/1";
+$J_title = "-JX${xwid}i/${ywid}i";
+$x_title = 0.5;
+$y_title = 1.5;
+$p_title = 1.75 * $ywid;
+
+#$filename    = "image";
+$psfile  = "$filename.ps";
+$jpgfile = "$filename.jpg";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  $cshfile = "plot_image.csh";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain MEASURE_UNIT inch COLOR_NAN 255/255/255 TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+  # make colorpoint file
+#  $T1 = "-T3/4/0.1";
+#  $pmax = 10;
+  $cran = $cmax - $cmin;
+  $dc = $cran/$colorinc;
+  $T1 = "-T$cmin/$cmax/$dc";
+  $cptfile = "color0.cpt";
+  print CSH "makecpt -C$colorbar -D -Z $T1 > $cptfile\n";
+  print "\n $T1\n";
+
+  #------------------------
+
+  print CSH "psbasemap $J $R $B -K $orient -V $origin > $psfile\n";  # START
+
+  # generate datafile
+  $dfile = dtemp;
+  if($isurf == 1) {
+     print CSH "awk '{print \$($icol[0]),\$($icol[1]),\$($icol[2])/$cnorm }' $datafile > $dfile\n";
+  } else {
+     print CSH "awk '{print \$($icol[0])/1000,\$($icol[1])/1000,\$($icol[2])/$cnorm }' $datafile > $dfile\n";
+  }
+  
+
+  #print CSH "awk '{print \$($icol[0]),\$($icol[1]),\$($icol[2])/$cnorm }' $datafile | pscontour $R $J -A- -C$cptfile -I -K -O -V >> $psfile\n";
+  #print CSH "pscontour $dfile $R $J -A- -C$cptfile -I -K -O -V >> $psfile\n";
+
+  $grdfile = "temp.grd"; $interp = "$I $S";
+  print CSH "nearneighbor $dfile -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C$cptfile $J -K -O -V >> $psfile\n";   # -T for no interpolation
+
+  # coast-lines
+  if($isurf==1) {print CSH "pscoast $J $R $B $coastinfo -K -O -V >> $psfile\n"}
+
+  print CSH "psscale -C$cptfile $Dscale $Bscale -K -O -V >> $psfile\n";
+
+  # plot the element boundaries
+  if(0==1) {
+     $elementfile = "$idir/elements.dat";
+     if (not -f $elementfile) { die("Check if $elementfile exist or not\n") }
+     print CSH "awk '{print \$4,\$6}' $elementfile |psxy -N -Sc1p -G0/0/0 $J $R -K -O -V >> $psfile\n";
+     print CSH "awk '{print \$5,\$6}' $elementfile |psxy -N -Sc1p -G0/0/0 $J $R -K -O -V >> $psfile\n";
+     print CSH "awk '{print \$5,\$7}' $elementfile |psxy -N -Sc1p -G0/0/0 $J $R -K -O -V >> $psfile\n";
+     print CSH "awk '{print \$4,\$7}' $elementfile |psxy -N -Sc1p -G0/0/0 $J $R -K -O -V >> $psfile\n";
+  }
+
+  # plot receivers with numbered label
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $rec_file |psxy -N $J $R -K -O -V $rec0 >> $psfile\n";
+  #$rec_file2 = text_rec; $angle = 0; $just = "CM";
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $rec_file > $rec_file2\n";
+  #print CSH "pstext $rec_file2 -N $J $R -K -O -V >> $psfile\n";
+  #print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $rec_file |psxy -N $J $R -K -O -V $src >> $psfile\n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/${p_title}/$plabel";
+  #$ytemp = $ywid * 1.5;
+  #$shift = "-Xa-$dX -Ya$ytemp";
+  print CSH "pstext -N $J_title $R_title $Utag -O -V >>$psfile<<EOF\n $x_title $y_title $fsize0 0 $fontno CM @plot_title\nEOF\n";  # FINISH
+
+#-----------------------------
+  if($iportrait == 0){print CSH "convert $psfile -rotate 90 $jpgfile\n"}
+  if($iportrait == 1){print CSH "convert $psfile $jpgfile\n"}
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &")
+  #if($iopt <= 2) {system("xv $jpgfile &")}
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_image.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_kernel.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_kernel.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_kernel.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,213 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_kernel.pl
+#  Carl Tape
+#  15-Feb-2006
+#
+#  This script plots a kernel in GMT.
+#
+#  Example (no longer there):
+#    scripts/plot_kernel.pl OUTPUT/run_1200/ OUTPUT/run_1200/event_005/ 25 132 3500 20.0 sr.txt fun_test0 -7/4
+#    scripts/plot_kernel.pl OUTPUT/run_1200/ OUTPUT/run_1200/event_005/ 25 132 3500 20.0 sr.txt fun_test1 1/1
+#    scripts/plot_kernel.pl OUTPUT/run_1200/ OUTPUT/run_1200/event_005/ 25 132 3500 20.0 sr.txt fun_test2 1/1
+#    scripts/plot_kernel.pl OUTPUT/run_1200/ OUTPUT/run_1200/event_005/ 25 132 3500 20.0 sr.txt fun_test3 1/1
+#
+#    scripts/plot_kernel.pl OUTPUT 4480 5 16 1 132 3500 20.0 sr.txt fun 1/1
+#==========================================================
+
+if (@ARGV < 8) {die("Usage: plot_kernel.pl basedir iopt xxx \n");}
+($dir1,$dir,$ievent,$iter,$nsrc,$nrec,$c0,$per,$srcrec,$name,$color) = @ARGV;
+$comp = 1;
+
+# color for the kernel
+$scale_color = 21.0;
+$colorbar = "seis";
+ at scale  = split("/",$color);
+$pwr = $scale[0];
+$norm = "1e${pwr}";
+$cmax = "$scale[1]";
+$ss = $cmax;
+$ds = 2*$ss/$scale_color;
+$bs = sprintf("%3.3e",0.9*$ss);  # colorbar
+$TsK = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "$color $norm $cmax \n TsK = $TsK \n";
+$BscaleK  = sprintf("-B%2.2e:\" K\@-R\@- ( x, y, t )  ( 10\@+-%2.2i\@+  m\@+-2\@+ [\@~d\143\@~] )\":",$bs,$pwr);
+
+#die("testing");
+
+# file names
+$mfile_syn = "socal_vel_syn.dat";
+$rec_file  = "recs_lonlat.dat";
+$src_file  = "events_lonlat.dat";
+
+$file_msyn = "$dir1/$mfile_syn";
+$file_rec  = "$dir1/$rec_file";
+$file_src  = "$dir1/$src_file";
+$file_src_rec = "$dir/$srcrec";
+$file_ker  = "$dir1/$name.dat";
+
+if (not -f $file_rec) { die("Check if $file_rec exist or not\n") }
+if (not -f $file_src) { die("Check if $file_src exist or not\n") }
+if (not -f $file_src_rec) { die("Check if $file_src_rec exist or not\n") }
+if (not -f $file_ker) { die("Check if $file_ker exist or not\n") }
+if (not -f $file_msyn) { die("Check if $file_msyn exist or not\n") }
+
+$plabel = "/home/carltape/sem2d/2d_adjoint/scripts/plot_kernel.pl";
+
+#die("\ntesting\n");
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.2c";
+
+# plot symbols for sources, receivers, and shelf
+$src    = "-W1.0p/0/0/0 -Sa0.25";
+$rec    = "-Sc10p -W0.5p";
+$src0   = "-Sa0.25 -W1.0p/0/0/0 -G255";
+$rec0   = "-Sc10p  -W1.0p/0/0/0 -G255";
+#$rec    = "-W0.5p/0/0/0 -St0.10";
+$Wshelf = "-W1.0/0/0/0tap";
+
+#-------------------------
+# color
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+
+#-------------------------
+
+# write plotting scripts
+$wid = 6;
+$J1 = "-JM${wid}i";      # in lat-lon
+$origin = "-X1 -Y3.5";
+
+$B1syn = "-Ba1f0.25:.\" \":WESN";
+
+$Dlen = 0.5*$wid;
+$Dx = $wid/2;
+$Dy = -0.40;
+$Dscale1 = "-D$Dx/$Dy/$Dlen/0.20h";
+
+#$bs1 = 0.5; $Bscale1  = sprintf("-B%2.2e:\" Phase Velocity ( km s\@+-1\@+ )\": -E10p",$bs1);
+#$bs1 = 2; $Bscale1  = sprintf("-B%2.2e:\" Percent Perturbation from %3.3f  km s\@+-1\@+ \": -E10p",$bs1,$c0/1000);
+
+#-------------------------
+
+#$per = 20;
+#$c0 = 3.5;
+$per_lab = sprintf("T = %3.3f s",$per);
+$c0_lab  = sprintf("c0 = %3.3f km/s",$c0/1000);
+print "\n$per_lab, $c0_lab\n";
+
+$title = "Rayleigh Wave Phase Velocity";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax,$smin,$smax,$tmin,$tmax) = split(" ",`minmax -C $file_msyn`);
+($tt) = sort{$b <=> $a} ($tt,abs($tmin),abs($tmax));
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+print "\n $R \n $smin $smax \n -$tt $tt \n";
+
+# plot title
+$xtx = $xmin+0.5*($xmax-$xmin);
+$ztx = $zmin+1.10*($zmax-$zmin);
+
+#$name    = "kernel";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  $cshfile = "plot_kernel.csh";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+  # make colorpoint file
+  $cptfile1 = "color0.cpt";
+  print CSH "makecpt -C$colorbar $TsK > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile1\n";
+
+  $plot_title = "Model for synthetics";
+
+  print CSH "psbasemap $B1syn $R $J1 -P -K -V $origin > $psfile\n";  # START
+
+  # phase velocity map
+  #print CSH "awk '{print \$1,\$2,\$3/1000}' $file_msyn | pscontour $R $J1 -A- -C$cptfile1 -I -P -K -O -V >> $psfile\n"; 
+  print CSH "awk '{print \$1,\$2,\$3 / $norm}' $file_ker | pscontour $R $J1 -A- -C$cptfile1 -I -P -K -O -V >> $psfile\n"; 
+
+  print CSH "pscoast $J1 $R $B1syn -W1p -Na/1p -Dh -P -K -O -V >> $psfile\n";
+  #print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $BscaleK -K -P -O -V >> $psfile \n";
+
+  # plot receivers with numbered label
+  #print CSH "awk '{print \$1,\$2}' $file_rec |psxy -N $J1 $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $file_rec | tail -n $nrec > tempk\n";
+  print CSH "psxy tempk -N $J1 $R -K -O -P -V $rec >> $psfile\n";
+  $file_rec2 = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_rec | tail -n $nrec > $file_rec2\n";
+  print CSH "pstext $file_rec2 -N $J1 $R -K -O -P -V >> $psfile\n";
+
+  # plot sources with numbered label
+  print CSH "awk '{print \$1,\$2}' $file_src | tail -n $nsrc > tempv\n";
+  print CSH "psxy tempv -N $J1 $R -K -O -P -V $src >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $file_src |psxy -N $J1 $R -K -O -P -V $src >> $psfile\n";
+  $file_src2 = text_src; $angle = 0; $just = "CM";
+  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_src | tail -n $nsrc > $file_src2\n";
+  print CSH "pstext $file_src2 -N -G255/0/0 $J1 $R -K -O -P -V >> $psfile\n";
+
+#  # plot receivers with numbered label
+#  print CSH "awk '{print \$1,\$2}' $file_rec |psxy -N $J1 $R -K -O -P -V $rec >> $psfile\n";
+#  $file_rec2 = text_rec; $angle = 0; $just = "CM";
+#  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_rec > $file_rec2\n";
+#  print CSH "pstext $file_rec2 -N $J1 $R -K -O -P -V >> $psfile\n";
+
+#  # plot sources with numbered label
+#  print CSH "awk '{print \$1,\$2}' $file_src |psxy -N $J1 $R -K -O -P -V $src >> $psfile\n";
+#  $file_src2 = text_src; $angle = 0; $just = "CM";
+#  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_src > $file_src2\n";
+#  print CSH "pstext $file_src2 -N -G255/0/0 $J1 $R -K -O -P -V >> $psfile\n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $Ushift = "-Xa-$dX -Ya6.5";
+
+  $plot_title = "Kernel";
+  if (not -f $file_src_rec) { die("Check if $file_src_rec exist or not\n") }
+
+  # plot individual receiver
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $file_src_rec |psxy -N $J1 $R -K -O -P -V $rec0 >> $psfile\n";
+  $file_rec2 = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_rec | tail -n $nrec > $file_rec2\n";
+  #print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_rec > $file_rec2\n";
+  print CSH "pstext $file_rec2 -N $J1 $R -K -O -P -V >> $psfile\n";
+
+  # plot individual source
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $file_src_rec |psxy -N $J1 $R -K -O -P -V $src0 >> $psfile\n";
+  $file_src2 = text_src; $angle = 0; $just = "CM";
+  print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_src | tail -n $nsrc > $file_src2\n";
+  #print CSH "awk '{print \$1,\$2,$fsize3,$angle,$fontno,\"$just\",\$3}' $file_src > $file_src2\n";
+  print CSH "pstext $file_src2 -N $J1 $R -K -O -P -V >> $psfile\n";
+
+#-----------------------------
+  print CSH "pstext -N $J1 $R $Utag -O -P -V $Ushift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $plot_title\nEOF\n";  # FINISH
+
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &")
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_kernel.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_rs.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_rs.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_rs.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,244 @@
+#!/usr/bin/perl -w
+
+#
+#
+#  If using CMT files, you must uncomment the opt_m commands below.
+#
+#  EXAMPLES (execute from main directory):
+#  STATIONS file is produced in make_sac_files.pl
+#
+#  --> See multi_plot_rs.pl <--
+#
+#  scripts/plot_rs.pl -R0/200/0/200 -Ekt0 -M0.0003/s -W0.5p OUTPUT/*sacdat
+#
+#  scripts/plot_rs.pl -R0/200/0/200 -Ekt0 -m socal_adjoint_stf -n "Socal adjoint source time functions" -M0.0003/s -W0.5p OUTPUT/*sacstfadj
+#
+#  scripts/plot_rs.pl -R0/200/0/200 -Ekt0 -M0.0003/s -W0.5p -w0.5/255/0/0tap -S OUTPUT,sacsyn -D OUTPUT,sacdat,1,STATIONS
+#
+
+use Getopt::Std;
+use lib '/opt/seismo-util/lib/perl';
+use SACLST;
+use SAC_TOOLS;
+use CMT_TOOLS;
+use GMT_PLOT_SC;
+use GMT_PLOT;
+use FILE_TOOLS;
+use vars qw($opt_s $opt_r);
+
+sub Usage(){
+
+print STDERR <<EOF;
+ Usage: plot_rs.pl
+
+         this script plots record section for given data and synthetics,
+         limit stations by azimuth (-A) and amplitude ratio (-T)
+
+         -m : psfile label (formerly CMTSOLUTION)
+         -n : title for the plot
+         -R : default [-20/180/0/320]
+         -B : tick marks, default [20/20]
+         -C : cutting of trace, default no cutting
+         -J : projection, default [-JX6/-8]
+         -E : alignment of traces , like -Ekt5 default [-Ek8.0]
+	 -M : scale of trace, default [0.03/1]
+         -W : data trace property
+	 -w : syn trace property
+         -d data_file, data_ext, comp
+         -D data_dir, data_ext, comp, station_file
+         -S syn_dir, syn_ext, shift_hdr
+         -A az_min/az_max
+         -s plot LA basin instead of the whole SC map
+         -r add text to the right instead of above the station in map.ps
+         -T : maximum amplitude ratio of data/syn to plot
+         data_files
+
+EOF
+exit(1);
+}
+
+ at ARGV>0 or Usage();
+if(!getopts('R:B:C:J:e:E:M:W:w:d:D:S:A:m:n:srT:')) {die("Check the input options\n");}
+if ($opt_R) {$R = "-R$opt_R";} else {$R = "-R-20/180/-10/320";}
+if ($opt_B) {$B =   "$opt_B";} else {$B = "20/20";}
+if ($opt_C) {$C = "-C$opt_C";} else {$C = "";}
+if ($opt_J) {$J = "-J$opt_J";} else {$J = "-JX6/-8";}
+if ($opt_E) {$E = "-E$opt_E";} else {$E = "-Ek8.0";}
+if ($opt_M) {$M = "-M$opt_M";} else {$M = "-M0.03/1";}
+if ($opt_W) {$W = "-W$opt_W";} else {$W = "-W5";}
+if ($opt_w) {$w = "-W$opt_w";} else {$w = "-W5/255/0/0";}
+if ($opt_d) {
+  ($data_file,$data_ext,$comp) = split(/\,/,$opt_d);
+  $data_ext = $data_ext ? ".$data_ext" : "";
+  $comp = $comp ? $comp : "BHT";
+  @tmp=list2files($data_file);
+  @data_files = ();
+  foreach $data (@tmp) {
+    (undef,$comp1) = split(" ",`saclst kcmpnm f $data`);
+    if ($comp1 ne $comp) {next;}
+    push(@data_files,"${data}${data_ext}");}}
+
+elsif ($opt_D) {
+  ($data_dir,$data_ext,$comp,$station_used) = split(/\,/,$opt_D);
+  if (not $comp ) {die("need to specfiy component to plot\n");} 
+  if (not $data_dir) {die("need to specify the data directory\n");}
+  if (not $data_ext) {die("need to specify the data extensions\n");}
+  @data_files = ();
+  if ($station_used) {
+    (@sta) = list2files($station_used);
+    foreach $sta (@sta) {
+      @files = glob("$data_dir/*$sta.*$comp*$data_ext");
+      #print "\n $sta $#files $files[0]";
+      if (@files == 1) {push(@data_files,$files[0]);}
+    }
+  }else {
+    @data_files = glob("$data_dir/*$comp*$data_ext");}
+}else {@data_files = @ARGV; $comp = "BH";}
+
+$numd = $#data_files + 1;
+print "\n $numd data files, first is $data_files[0] \n";
+
+if ($opt_A) {($min_az,$max_az) = split(/\//,$opt_A);
+ at data_files = sac_files_prune("az",$min_az,$max_az, at data_files);}
+
+if (@data_files == 0) {die("No data files available to plot\n");}
+ at data_files = sac_files_sort("dist",1, at data_files);
+
+if($opt_S) {
+  $plot_syn=1; ($syn_dir,$syn_suff,$syn_shift_hdr) = split(/\,/,$opt_S);
+  if (defined $syn_shift_hdr) {$S = "-Su$syn_shift_hdr"; }else {$S = "";}}
+else {$plot_syn = 0;}
+if($plot_syn & $M !~/\//){die "Don't use relative scale when plotting both data and synthetics -- change -M option \n";}
+
+#------------------------
+
+#if ($opt_m) {$cmt_file = $opt_m; ($evnm) = get_cmt_evnm($cmt_file);}
+#else {$evnm = "socal_seis";}
+
+if ($opt_m) {$evnm = $opt_m;}
+else {$evnm = "socal_seis";}
+
+if ($opt_n) {$title = $opt_n;}
+else {$title = "Record section for SoCal";}
+
+$B = "-B$B:.\"${title}\":WeSN";
+
+#$psfile = "${evnm}.${comp}.ps";
+
+# include the axis limits in the name of the figures
+($junk,$R5) = split("-R",$R);
+($R1,$R2,$R3,$R4) = split(/\//,$R5);
+$pslab = $R1."_".$R2."_".$R3."_".$R4;
+
+# shift y-limits by some fraction
+$frac = 0.05;
+$R3 = $R3 - $frac*($R4-$R3);
+$R4 = $R4 + $frac*($R4-$R3);
+$R  = "-R/$R1/$R2/$R3/$R4";
+
+$name1 = ${evnm}."_".$pslab;
+$psfile = $name1.".ps";
+$jpgfile = $name1.".jpg";
+
+print "\nFile labeling: \n";
+print "evnm    = $evnm \n";
+print "title   = $title \n";
+print "psfile  = $psfile \n";
+print "jpgfile = $jpgfile \n";
+
+$name2 = "socal_map";
+$psfile2 = $name2.".ps";
+$jpgfile2 = $name2.".jpg";
+$csh_file = "rs.csh";
+
+#------------------------
+
+open(CSH,">$csh_file") or die("Unable to open $csh_file\n");
+print CSH "gmtset PAPER_MEDIA letter MEASURE_UNIT inch PLOT_DEGREE_FORMAT D BASEMAP_TYPE plain HEADER_FONT_SIZE 20\n";
+
+plot_psxy(\*CSH,$psfile,"$J $R $B -P -K", "");
+
+# plot the synthetics
+# CAREFUL: LABELING SCHEME FOR DATA AND SYNTHETICS MUST FIT A REQUIRED FORMAT
+if ($plot_syn) {
+  ($temp1,$temp2) = match_data_and_syn("$syn_dir,$syn_suff","@data_files","");
+  (@data_files) = split(" ",$temp1);
+  (@syn_files)  = split(" ",$temp2);
+
+  $numd = $#data_files + 1; $nums = $#syn_files + 1;
+  print "\n loop: $numd data files";
+  print "\n loop: $nums syn files \n\n";
+
+  if ($opt_T) {
+    for ($i = 0; $i < @data_files; $i ++ ) {
+      (undef,$datamax) = split(" ",`saclst depmax f $data_files[$i]`);
+      (undef,$synmax) = split(" ",`saclst depmax f $syn_files[$i]`);
+      if ($datamax > $synmax * $opt_T or $synmax > $datamax * $opt_T) {
+	print "skip $data_files[$i] and $syn_files[$i] -- too large amp. ratio\n";}
+      else {push(@datatmp,$data_files[$i]); push(@syntmp,$syn_files[$i]);}
+    } @data_files = @datatmp; @syn_files = @syntmp;
+  }
+  if (@data_files == 0 or @syn_files == 0) {die ("No data or syn files to plot\n");}
+  plot_pssac2(\*CSH,$psfile,"$R $C $J $E $M $w $S -P ","@syn_files");
+}
+
+# plot the data
+plot_pssac2(\*CSH,$psfile,"$R $C $J $E $M $W $B -P ","@data_files");
+
+# make and plot a map of stations
+
+$station_file       = "RS_STATIONS";   open(OUT, ">$station_file");
+$station_file_basin = "RS_SOCAL";      open(OUT2,">$station_file_basin");
+$text = "";
+
+foreach $data (@data_files) {
+
+   # use saclst to extract various quantities (evel, evdp not accessible)
+  (undef,$sta,$dist,$az,$stla,$stlo,$net)=split(" ", `saclst kstnm dist az stla stlo knetwk f $data`);
+ 
+  #$text .= sprintf("$R1 %6.1f 10 0 4 BC %s\n $R2 %6.1f 10 0 4 BC %6.1f    %6.1f \n",$dist,$sta,$dist,$dist,$az);
+
+  $R2p = $R2 + 0.01*($R2-$R1);                          # x-coordinate for label at right
+
+  if($dist >= $R3 && $dist <= $R4)
+  {$text .= sprintf("$R2p $dist 8 0 1 LM %5s %12.1f km %12.1f \n",$sta,$dist,$az);}
+
+  $text2 .= "$stlo $stla\n";                            # create text for psxy call below
+
+  if ($opt_s) { if ($opt_r) {$stlo = $stlo + 0.02;} else {$stla = $stla + 0.03;}}
+  else {if ($opt_r) {$stlo = $stlo + 0.04;} else {$stla = $stla + 0.06;}}
+
+  $text3 .= "$stlo $stla 8 0 4 BC $sta\n";              # create text for pstext call below
+
+  # make output files for checking (originally for specfem3d.f90)
+  print OUT "$sta\n";                                   # print station label to file
+  print OUT2 sprintf("%5s %5s %14.6f %14.6f %14.6f %14.6f \n",$sta,$net,$stlo,$stla,0,0);  # no elevation, burial
+}
+chomp($text); chomp($text2); chomp($text3);
+close(OUT);
+
+plot_pstext(\*CSH,$psfile,"-G255/0/0 -N -JX -P",$text);            # labels at the right of the seismograms (rec.sec.)
+
+plot_psxy(\*CSH,$psfile,"-JX -P -O","");                           # wrap up (rec.sec.)
+
+if ($opt_s) {$R = "-R-119.2/-117.2/33.5/34.7";} else {$R = "";}
+
+plot_sc_all(\*CSH,$psfile2,"-K $R -W4 -w3 ", "");
+
+plot_psxy(\*CSH,$psfile2,"-St0.10 -G0/0/255 -W2",$text2);          # symbols at the stations (map)
+
+plot_pstext(\*CSH,$psfile2,"-G255/0/0", $text3);                   # labels at the stations (map)
+
+#if ($opt_m) {plot_psmeca(\*CSH,$psfile2,"-Sm0.2 -O",$cmt_file);}
+
+#------------------------------------------------------------------------
+close(CSH);
+system("csh -fv $csh_file");
+system("convert $psfile $jpgfile");
+system("convert $psfile2 $jpgfile2");
+
+#system("xv $jpgfile2 &"); # map with stations
+#system("xv $jpgfile &");  # record section
+
+#-----------------------------------------------------------------------
+


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_rs.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_16frames.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_16frames.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_16frames.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,357 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_surf_16frames.pl
+#  Carl Tape
+#  26-Aug-2006
+#
+#  Perl script to plot snapshots of the forward wavefield,
+#  adjoint wavefield, interaction field, and kernel.
+#
+#  copied from plot_oms_kernel.pl and plot_for_adj_oms.pl on 09-June-2005
+# 
+#-------------------------
+#  EXAMPLES (GJI figures):
+#    (27-Nov-2005, traveltime) -- socal kernels
+#    [000] 132 recs (checker) -- GJI Fig. 8
+#    [001] single src-rec (homogeneous) -- GJI Fig. 5
+#    [002] single src-rec (banana-doughnut)
+#    [003] 132 recs (rayleigh)
+#
+#    scripts/plot_surf_16frames.pl OUTPUT 0 5 0/4000/400 400/1200/2000/2400 3/8/7 1.0/2.5/0.5 0.06 0 1 1
+#    scripts/plot_surf_16frames.pl OUTPUT 1 1 0/4000/400 400/1200/2000/2800 3/8/7 1.0/2.5/0.5 0.06 0 1 1
+#    scripts/plot_surf_16frames.pl OUTPUT 2 1 0/4000/400 400/1200/2000/2800 3/9/9 1.0/3.0/4.0 0.06 0 5 1
+#    scripts/plot_surf_16frames.pl OUTPUT 3 5 0/4000/400 400/1200/2000/2800 3/8/7 1.0/2.5/0.5 0.06 0 1 1
+#-------------------------
+#
+#  01-Feb-2006
+#    scripts/plot_surf_16frames.pl OUTPUT/run_0012/event_001 0/4000/400 800/1600/2400/3200 3/8/7 1.0/10/1    0.06 0 1 2
+#    scripts/plot_surf_16frames.pl OUTPUT/run_1000/event_005 0/4000/400 800/1600/2400/3200 3/9/8 1.0/05/1    0.06 0 1 2
+#
+#    scripts/plot_surf_16frames.pl OUTPUT/run_3100/event_005 0/4000/400 800/1200/1600/2000 3/9/8 1.0/05/1    0.06 0 1 2
+#    scripts/plot_surf_16frames.pl OUTPUT/run_3101/event_005 0/4000/400 800/1200/1600/2000 3/5/5 1.0/01/1    0.06 0 3 2
+#
+#   AGU 2006
+#    scripts/plot_surf_16frames.pl OUTPUT 4700 1 0/4000/400 400/1200/2000/2400 3/8/8 1.0/2/5 0.06 0 1 0
+#    scripts/plot_surf_16frames.pl OUTPUT 4750 1 0/4000/400 400/1200/2000/2400 3/8/8 1.0/2/5 0.06 0 1 0
+#
+#-------------------------
+#  04-Jan-2008
+#    scripts/plot_surf_16frames.pl OUTPUT_2 6000 5 0/4000/400 400/1200/2000/2400 3/8/8 1.0/2/5 0.06 0 1 2
+#
+#=============================================================
+#
+#  WARNING: there is some plotting problem with pscontour
+#  The x-y points must have "enough" digits for it to work.
+#  This was adjusted in the output files from wave2d_solver.f90.
+#
+#==========================================================
+
+if (@ARGV < 9) {die("Usage: plot_surf_16frames.pl basedir f-first/f-last/f-inc f1/f2/f3 pwr1/pwr2/pwr3 c1/c2/c3 DT bool_finite_source IKER \n");}
+($idir,$irun,$ievent,$range,$ftemp,$ptemp,$ctemp,$dt,$ifinite,$iker,$ilabs) = @ARGV;
+($first,$end,$nint) = split("/",$range);
+ at frames  = split("/",$ftemp);
+ at pwr     = split("/",$ptemp);     # PWR  : increase (larger negative power) for more contrast
+ at cmax    = split("/",$ctemp);     # CMAX : decrease for more contrast
+$numf = @frames;
+
+# base directory
+$strun = sprintf("%4.4i",$irun);
+$stev  = sprintf("%3.3i",$ievent);
+$basedir = "$idir/run_$strun/event_$stev";
+
+# ilabs: how many labels you want on the plots
+#  [0] for talks or posters
+#  [1] for publication
+#  [2] for notes
+
+# header for the kernel column
+$col4 = "Event  Kernel";
+#$col4 = "Sensitivity  Kernel";
+#$col4 = "Kernel  K ( x, y, t )";
+
+ at fig_title = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+
+# plot the color frames or not
+$icolor = 1;    # ccc
+
+$comp = 1;  # y-component only (surface waves)
+
+# resolution of color plots
+$interp = "-I0.5m/0.5m -S4m";   # key information
+$grdfile = "temp.grd";
+
+# plotting specifications
+$fsize0 = "18";
+$fsize1 = "10";
+$fsize2 = "8";
+$fsize3 = "4";
+$fontno = "1";
+#if($ilabs == 0) {$fontno = "1"} else {$fontno = "4"}
+$tick   = "0.1c";
+
+# plot symbols for sources, receivers, and shelf
+if($ifinite==0) {$src = "-W0.5p -Sa0.10";} else {$src = "-Sc0.05";}
+$rec = "-W0.5p,0/0/0 -St0.08";
+$Wshelf = "-W1.0p,0/0/0,--";
+
+$src = "-W0.5p -Sa0.2 -G255";   # nice white source (GJI figures)
+
+$cshfile = "plot_surf_16frames.csh";
+open(CSH,">$cshfile");
+print CSH "gmtset BASEMAP_TYPE plain PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 CHAR_ENCODING Standard+\n";
+
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+ at norm = ("1e-$pwr[0]","1e-$pwr[1]","1e-$pwr[2]");
+$fac = 5;      # KEY: enhance the interaction field (increase for more contrast)
+
+print "@norm \n";
+
+#die("testing");
+
+$pt = "\@~f\@~, \@~q\@~";  # phi, theta
+#$pt = "\@~\146\@~, \@~\161\@~";  # phi, theta
+
+# NOTE the syn (or data) and abr (alpha-beta-rho; or cbr or kmr) suffixes.
+ at wavefield = ("forward_syn","adjoint","kernel_abr");
+ at titles    = ("Regular  Wavefield","Adjoint  Wavefield","Interaction  Field",$col4);
+$numw = @wavefield;
+
+for ($k = 0; $k < $numw; $k ++ ){
+  $ss = 0;
+  for ($j = $first; $j <= $end; $j = $j + $nint) {
+    $isnap = ($j - $first) / $nint + 1;
+    $snap = sprintf("%05d",$j);
+    $snapshot = "${basedir}/$wavefield[$k]_$snap";
+    if (not -f $snapshot) {die("check if snapshot $snapshot exist or not\n");}
+
+    # determine abs(max) for three fields
+    if($k < $numw-1) {
+      ($xmin,$xmax,$zmin,$zmax,$smin,$smax) = split(" ",`minmax -C $snapshot`);
+      ($ss) = sort{$b <=> $a} ($ss,abs($smin),abs($smax));
+    } else {
+      ($xmin,$xmax,$zmin,$zmax,$imin,$imax,$smin,$smax) = split(" ",`minmax -C $snapshot`);
+      ($ss) = sort{$b <=> $a} ($ss,abs($smin),abs($smax));
+    }
+  }
+  print "\n $type Wavefield : $wavefield[$k]\n";
+  print "smax of all = $ss \n";
+  print "xmin = $xmin; xmax = $xmax\n";
+  print "zmin = $zmin; zmax = $zmax\n";
+
+  $dinc = 0.25;  # buffer around min/max
+  $xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+  $zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+  $region = "-R$xmin/$xmax/$zmin/$zmax";
+  print "\nregion is $region\n";
+
+  $Rc[$k] = "-R$xmin/$xmax/$zmin/$zmax";
+  print "R = $Rc[$k]\n";
+
+  $ss[$k] = $cmax[$k];
+  $ds[$k] = 2*$ss[$k]/$scale_color;
+  $bs[$k] = sprintf("%3.3e",0.9*$ss[$k]);  # colorbar
+  $Ts[$k] = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss[$k],$ss[$k],$ds[$k]);
+  print "Ts = $Ts[$k]\n";
+
+  print CSH "makecpt -C$colorbar $Ts[$k] -D > color_${k}.cpt\n";
+  #print CSH "makecpt -C$colorbar $Ts[$k] > color.cpt\n";
+  #print CSH "sed 's/^B.*/B       170     0      0  /' color.cpt  >  color1.cpt\n";
+  #print CSH "sed 's/^F.*/F         0    34    226  /' color1.cpt >  color_${k}.cpt\n";
+}
+
+#die("testing");
+
+#-------------------------
+# color for kernels
+
+# color for the kernel
+$ss = $cmax[2];
+$ds = 2*$ss/$scale_color;
+$bs = sprintf("%3.3e",0.9*$ss);  # colorbar
+$TsK = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "TsK = $TsK\n";
+
+# color for the interaction
+$ss2 = $cmax[2] / $fac;
+$ds2 = 2*$ss2/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss2);  # colorbar
+$TsI = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss2,$ss2,$ds2);
+print "TsI = $TsI\n";
+
+print CSH "makecpt -C$colorbar $TsK -D > color_K.cpt\n";
+#print CSH "makecpt -C$colorbar $TsK > color.cpt\n";
+#print CSH "sed 's/^B.*/B       170     0      0  /' color.cpt  >  color1.cpt\n";
+#print CSH "sed 's/^F.*/F         0    34    226  /' color1.cpt >  color_K.cpt\n";
+
+print CSH "makecpt -C$colorbar $TsI -D > color_I.cpt\n";
+#print CSH "makecpt -C$colorbar $TsI > color.cpt\n";
+#print CSH "sed 's/^B.*/B       170     0      0  /' color.cpt  >  color1.cpt\n";
+#print CSH "sed 's/^F.*/F         0    34    226  /' color1.cpt >  color_I.cpt\n";
+
+# color bars
+# NOTE: there seems to be a max LENGTH of the label string for the color bars
+#$BscaleS1 = sprintf("-B%2.2e:\" s ( $pt, t )  ( 10\@+-%2.2i\@+  m )\":",$bs[0],$pwr[0]);  # $k = 0
+#$BscaleS2 = sprintf("-B%2.2e:\" s\@+\262\@+ ( $pt, t )  ( 10\@+-%2.2i\@+  kg\@+-1\@+ s  [\@~\143\@~] )\":",$bs[1],$pwr[1]);   # $k = 1
+#$BscaleI  = sprintf("-B%2.2e:\" K\@~\242\@~ ( $pt, t )  ( 10\@+-%2.2i\@+ m\@+-2\@+ s\@+-1\@+ [\@~\143\@~] )\":",$bs2,$pwr[2]);
+#$BscaleK  = sprintf("-B%2.2e:\" K ( $pt, t )  ( 10\@+-%2.2i\@+  m\@+-2\@+ [\@~\143\@~] )\":",$bs,$pwr[2]);
+$BscaleS1 = sprintf("-B%2.2e:\" s ( $pt, t )  ( 10\@+-%i\@+  m )\":",$bs[0],$pwr[0]);  # $k = 0
+$BscaleS2 = sprintf("-B%2.2e:\" s\@+\262\@+ ( $pt, t )  ( 10\@+-%i\@+ )\":",$bs[1],$pwr[1]);   # $k = 1
+$BscaleI  = sprintf("-B%2.2e:\" K\302 ( $pt, t )  ( 10\@+-%i\@+ )\":",$bs2,$pwr[2]);
+$BscaleK  = sprintf("-B%2.2e:\" K ( $pt, t )  ( 10\@+-%i\@+ )\":",$bs,$pwr[2]);
+
+#$Bscale = sprintf("-B%2.2e",$bs[$k]);
+
+#print "\n $BscaleS1 \n $BscaleS2 \n $BscaleI \n $BscaleK\n"; die("testing\n");
+
+#-------------------------
+
+# write plotting scripts
+$J = "-JM1.6i";      # in lat-lon
+
+$origin = "-X0.75 -Y2.00";
+$dX     = "-X1.9";
+$mdX    = "-X-5.7";
+$dY     = "-Y1.9";
+
+$Dscale = "-D0.85/-0.40/1.25/0.1h -E8p";            # colorbar
+
+$name = "plot_16_${strun}_${stev}_${iker}_${ilabs}";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+print "\nWriting CSH file...\n";
+
+#$numf = 1;
+
+#for ($j = $first; $j <= $end; $j = $j + $nint) {
+for ($i = 0; $i < $numf; $i++) {
+
+   $j1 = $frames[$i];           # forward frame
+   $j2 = $end + $first - $j1;   # corresponding adjoint frame
+   $snap1 = sprintf("%05d",$j1);
+   $snap2 = sprintf("%05d",$j2);
+   $time = sprintf("%04d",$j1*$dt);
+   
+   $snapshot_f = "${basedir}/$wavefield[0]_${snap1}";
+   $snapshot_a = "${basedir}/$wavefield[1]_${snap2}";
+   $snapshot_k = "${basedir}/$wavefield[2]_${snap2}";
+
+   if (not -f $snapshot_f) {die("check if snapshot_f $snapshot_f exist or not\n");}
+   if (not -f $snapshot_a) {die("check if snapshot_a $snapshot_a exist or not\n");}
+   if (not -f $snapshot_k) {die("check if snapshot_k $snapshot_k exist or not\n");}
+    
+   $k = 0;
+   $R = $Rc[$k];
+
+   print CSH "echo $psfile\n";
+   print CSH "echo $snapshot_f\n";
+    
+   $B = "-B1/1:\"t = $time s\"::.\"  \":Wsne";
+   $B_row1 = "-B1/1:\"t = $time s\"::.\"  \":WSne";
+   if ($i == 0) { $B = $B_row1;}
+   #$B = "-B2/2:.\" \":wesn";
+
+   if ($i == 0) {print CSH "psbasemap $J $R $B -K -P -V $origin > $psfile\n"} # START
+   else {print CSH "psbasemap $J $R $B -K -O -P -V $dY $mdX >> $psfile\n"}
+
+   # PLOT THE FORWARD WAVEFIELD
+   if($icolor==1) {
+      #print CSH "awk '{print \$1,\$2,\$($comp+2) / $norm[$k]}' $snapshot_f | pscontour $J $R $B -A- -Ccolor_${k}.cpt -I -K -O -P -V >> $psfile\n";
+      print CSH "awk '{print \$1,\$2,\$($comp+2) / $norm[$k]}' $snapshot_f | nearneighbor -G$grdfile $R $interp\n";
+      print CSH "grdimage $grdfile -Ccolor_${k}.cpt $J -K -O -P -V -Q >> $psfile\n";
+   }
+   print CSH "pscoast $J $R $B -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+   #print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+   if ($i == 0 && $ilabs > 0) {print CSH "psscale -Ccolor_${k}.cpt $Dscale $BscaleS1 -K -O -P -V >> $psfile \n";}
+   print CSH "awk '\$1 == \"R\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+   print CSH "awk '\$1 == \"S\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+
+   # plot the time of the snapshot (for some reason, it won't work inside the B command)
+   $xtext = $xmin-0.3*($xmax-$xmin);
+   $ztext = $zmin+0.5*($zmax-$zmin);
+   $tstr = "t = $time s";
+   print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtext $ztext $fsize1 90 $fontno CM $tstr\nEOF\n";
+      
+   # plot title
+   $xtx = $xmin+0.5*($xmax-$xmin); $ztx = $zmin+1.15*($zmax-$zmin); 
+   if ($i == $numf-1) {print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[0]\nEOF\n";}
+
+   #-------------------------
+
+   $k = 1;
+   $R = $Rc[$k];
+
+   print CSH "echo $psfile\n";
+   print CSH "echo $snapshot_a\n";
+    
+   $B = "-B1/1:.\" \":wesn";
+   $B_row1 = "-B1/1:.\" \":weSn";
+   if ($i == 0) { $B = $B_row1;}
+
+   # PLOT THE ADJOINT WAVEFIELD
+   print CSH "psbasemap $J $R $B -K -O -P -V $dX >> $psfile\n";
+   if($icolor==1) {
+      #print CSH "awk '{print \$1,\$2,\$($comp+2) / $norm[$k]}' $snapshot_a | pscontour $J $R $B -A- -Ccolor_${k}.cpt -I -K -O -P -V >> $psfile\n";
+      print CSH "awk '{print \$1,\$2,\$($comp+2) / $norm[$k]}' $snapshot_a | nearneighbor -G$grdfile $R $interp\n";
+      print CSH "grdimage $grdfile -Ccolor_${k}.cpt $J -K -O -P -V -Q >> $psfile\n";
+   }
+   print CSH "pscoast $J $R $B -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+   if ($i == 0 && $ilabs > 0) {print CSH "psscale -Ccolor_${k}.cpt $Dscale $BscaleS2 -K -O -P -V >> $psfile \n";}
+   print CSH "awk '\$1 == \"R\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+   print CSH "awk '\$1 == \"S\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+   if ($i == $numf-1) {print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[1]\nEOF\n";}
+
+   #-------------------------
+
+   $k = 2;
+
+   print CSH "echo $psfile\n";
+   print CSH "echo $snapshot_k\n";
+    
+   # PLOT THE INTERACTION FIELD
+   print CSH "psbasemap $J $R $B -K -O -P -V $dX >> $psfile\n";
+   if($icolor==1) {
+      #print CSH "awk '{print \$1,\$2,\$3 / $norm[$k]}' $snapshot_k | pscontour $J $R $B -A- -Ccolor_I.cpt -I -K -O -P -V >> $psfile\n";
+      print CSH "awk '{print \$1,\$2,\$7 / $norm[$k]}' $snapshot_k | nearneighbor -G$grdfile $R $interp\n";
+      print CSH "grdimage $grdfile -Ccolor_I.cpt $J -K -O -P -V -Q >> $psfile\n";
+   }
+   print CSH "pscoast $J $R $B -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+   if ($i == 0 && $ilabs > 0) {print CSH "psscale -Ccolor_I.cpt $Dscale $BscaleI -K -O -P -V >> $psfile \n";}
+   print CSH "awk '\$1 == \"R\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+   print CSH "awk '\$1 == \"S\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+   if ($i == $numf-1) {print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[2]\nEOF\n";}
+
+   # PLOT THE KERNEL
+   print CSH "psbasemap $J $R $B -K -O -P -V $dX >> $psfile\n";
+   if($icolor==1) {
+      print CSH "awk '{print \$1,\$2,\$4 / $norm[$k]}' $snapshot_k | nearneighbor -G$grdfile $R $interp\n";
+      print CSH "grdimage $grdfile -Ccolor_K.cpt $J -K -O -P -V -Q >> $psfile\n";
+   }
+   print CSH "pscoast $J $R $B -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+   if ($i == 0 && $ilabs > 0) {print CSH "psscale -Ccolor_K.cpt $Dscale $BscaleK -K -O -P -V >> $psfile \n";}
+   print CSH "awk '\$1 == \"R\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+   print CSH "awk '\$1 == \"S\" {print \$2,\$3}' ${basedir}/sr.txt |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+   if ($i == $numf-1) {print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[3]\nEOF\n";}
+}
+
+# plot title and GMT header
+if ($ilabs == 2) {
+  $plabel = "/home/carltape/wave2d/2d_adjoint/plot_surf_16frames.pl";
+  $Utag = "-U/-3.75/1.95/$plabel";  # GMT header
+  $shift = "-X-2.0i -Y0.7i";
+  $title = "Kernel construction -- $fig_title[$iker]";
+  print CSH "pstext -N $J $R $Utag -K -O -P -V $shift >>$psfile<<EOF\n $xmin $zmax $fsize0 0 $fontno CM $title\nEOF\n";
+}
+
+#-------------------------
+print CSH "pstext $J -R0/1/0/1 -O -P -V >>$psfile<<EOF\n 10 10 $fsize0 0 $fontno CM junk \nEOF\n";  # FINISH
+print CSH "convert $psfile $jpgfile\n";
+
+close (CSH);
+system("csh -f $cshfile");
+system("xv $jpgfile &");


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_16frames.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_ker_mod.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_ker_mod.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_ker_mod.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,560 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_ker_mod.pl
+#  Carl Tape
+#  04-Aug-2006
+#
+#  This script generates a figure with four subplots:
+#     1. target model (data)
+#     2. current model (synthetics)
+#     3. misfit map
+#     4. event kernel
+#  Option to plot event kernels (isum=0) or summed event kernels (isum=1)
+#
+#  EXAMPLES:
+#------------------
+# traveltime (irun = 600--616), Rayleigh wave, sigma = 10km
+#    scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -6/3.0/0/20 1 26 1 600 0
+#    scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -6/1.0/0/20 1 26 1 600 1
+#    scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -6/1.0/0/20 1 26 1 600 2
+#    scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -6/1.0/0/10 1 26 1 600 3
+#    scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/4.0/0/10 1 26 1 600 4
+#    scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/4.0/0/10 1 26 1 600 16
+#
+# traveltime: INDIVIDUAL kernels and summed kernel
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/80 1 5 0 700 0
+#
+# VARY THE SCALELENGTH AND SMOOTHING
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 420 16  # 1
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 800 16  # 2
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 780 16  # 3
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 460 16  # 4 -- main
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 820 16  # 5
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 900 16  # 6
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 500 16  # 7
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 840 16  # 8
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 920 14  # 9
+#
+# VARY THE NUMBER OF EVENTS (Nfac=1, gamma=30)
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1  5 1 700 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 10 1 720 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 15 1 740 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 20 1 760 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 780 16
+#
+# VARY THE NUMBER OF EVENTS (Nfac=3, gamma=30)
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1  5 1 300 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 10 1 320 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 15 1 340 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 20 1 360 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 25 1 380 16
+#
+# VARY THE SMOOTHING (Nfac=3, gamma = 15,30,45,60,75,90)
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 400 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 420 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 440 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 460 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 480 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 500 16
+# 
+# PERTURBED CONDITIONS (Rayleigh, gamma = 30)
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 280 16  # reference
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -6/1.0/1/2  1 1/25 1 520 16  # pert source
+#
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 540 16
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -7/3.0/0/10 1 1/25 1 560 16
+#
+# (wave2d_3.f90, 19-Nov-2005)
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -8/1.0/0/1 1 1 0 580 0
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -8/1.0/0/1 1 1 0 581 0
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -8/1.0/0/1 1 1 0 582 0
+#
+# GJI figure
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -8/5.0/0/8 1 5/5 0 000 0
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -8/5.0/0/8 1 1/1 0 001 0
+#
+# (31-Jan-2006, single kernel)
+# scripts/plot_ker_mod.pl OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -8/5.0/0/1 1 1/1 0 012 0
+#
+#==========================================================
+
+if (@ARGV < 11) {die("Usage: plot_kernels.pl out_dir_pre event_dir_pre modelfile_dat modelfile_syn kernelfile kpwr/kmax/oprw/omax IKER iev1/iev2 isum irun0 iter model \n");}
+($odir,$edir,$mfile_dat,$mfile_syn,$kerfile,$colors,$iker,$ievents,$isum,$irun0,$iter) = @ARGV;
+
+$irun = $irun0 + $iter;
+
+$ipvel = 0;  # use a fixed color map if useing Rayleigh wave phase velocity maps
+
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t");
+$mod = $mods[$iter];
+
+# event indices
+ at ievs = split("/",$ievents);
+$ieventmin = $ievs[0];
+$ieventmax = $ievs[1];
+$nevent = $ieventmax - $ieventmin + 1;
+$stev1 = sprintf("%3.3i",$ieventmin);     # first event dir
+print "\n $ievents, $ieventmin, $ieventmax, $nevent\n";
+
+# model iteration
+$smod = "m\@+$mod\@+";
+
+# wave2d run number
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "$odir$strun0";
+$dir = "$odir$strun";
+
+print "\n $dir, $edir, $mfile_dat, $mfile_syn, $kerfile";
+print "\n $colors, $iker, $nevent, $isum, $mod \n";
+#die("testing");
+
+ at cols = split("/",$colors);
+$kpwr = $cols[0];
+$kmax = $cols[1];
+$opwr = $cols[2];
+$omax = $cols[3];
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+$ktype = $titles[$iker];
+
+$plabel = "/home/carltape/sem2d/2d_adjoint/scripts/plot_ker_mod.pl";
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.15c";
+
+# plot symbols for sources, receivers, and shelf
+$src = "-W1.0p -Sa0.20 -G255/0/0";
+$rec = "-W0.5p/0/0/0 -St0.10";
+$rec0 = "-Sc10p -W0.5p";
+$Wshelf = "-W1.0/0/0/0tap";
+
+$shelf_file = "INPUT/oms_shelf";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+#-------------------------
+# color for chi (objective function)
+
+$norm3 = "1e$opwr";
+$ss = $omax;
+$ds = $ss/$scale_color;
+$bs3 = sprintf("%3.3e",0.9*$ss/4); # colorbar
+$T3 = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+print "T3 = $T3\n";
+
+#-------------------------
+# get reference phase velocity and period
+
+open(IN,"$dir0/socal_vel_c0.dat");
+ at vals = <IN>;
+$c0       = $vals[0];
+$per      = $vals[1];
+$lam      = $c0*$per;
+$per_lab  = sprintf("T = %.1f s",$per);
+$c0_lab   =  sprintf("c0 = %.2f km/s",$c0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $c0_lab, $lam_lab \n";
+
+#-------------------------
+
+# write plotting scripts
+$Jwid = 3.25;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.6 -Y6.25";
+
+$B1dat = "-B1:.\" \":WeSN";
+$B1syn = "-B1:.\" \":wESN";
+$B2 = "-B1:.\" \":wESN";
+$B3 = "-B1:.\" \":WeSN";
+
+$Dlen = 2.0;
+$Dx = $Jwid/2;
+$Dy = -0.35;
+
+$Dscale1 = "-D$Dx/$Dy/$Dlen/0.10h";
+$Dscale2 = "-D$Dx/$Dy/$Dlen/0.10h";
+$Dscale3 = "-D$Dx/$Dy/$Dlen/0.10h";
+
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Velocity for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Velocity for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$cmax = 9; $bs1 = 3;
+$Bscale1d  = sprintf("-B%2.2ef1:\" Structure for data  (\@~\045\@~ pert. from %2.2f km/s)\": -E10p",$bs1,$c0/1000);
+$Bscale1s  = sprintf("-B%2.2ef1:\" Structure for model $smod  (\@~\045\@~ pert from %2.2f km/s)\": -E10p",$bs1,$c0/1000);
+$Bscale2  = sprintf("-B%2.2e:\" K ( x, y )  ( 10\@+%2.2i\@+  m\@+-2\@+ [\@~d\143\@~] )\": -E10p",$bs2,$kpwr);
+$Bscale3  = sprintf("-B%2.2e:\" \@~\143\@~ ( x\@-r\@- , y\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef10p",$bs3,$opwr);
+
+#-------------------------
+# phase velocity model
+$file1dat = "$dir/$mfile_dat";
+$file1syn = "$dir/$mfile_syn";
+
+$title = "Rayleigh Wave Phase Velocity";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$xtx = $xmin+0.5*($xmax-$xmin);
+$ztx = $zmin+1.10*($zmax-$zmin);
+
+#-------------------------
+# 3-plot figure:
+#   (1) upper left : model
+#   (2) lower left : kernel
+#   (3) middle right : data misfit (chi)
+#-------------------------
+
+#===========================================================================
+if ($isum == 0) {
+print "\n Plotting event kernels...\n";
+#===========================================================================
+
+for ($k = $ieventmin-1; $k <= $ieventmax-1; $k = $k+1) {
+#for ($k = 0; $k <= $nevent-1; $k = $k+1) {
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  $cshfile = "plot_ker_mod.csh";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+  # get the kernel and chi files
+  $ev = $k+1;
+  $stev = sprintf("%3.3i",$ev);
+  $ev_dir = "$dir/$edir$stev";
+  $file2 = "$ev_dir/$kerfile";
+  $file3 = "$ev_dir/chi_r.dat";
+  $srcfile = "$ev_dir/sr.txt";
+  $chifile = "$ev_dir/single_chi_r.dat";
+  if (not -f $file2) { die("Check if $file2 exist or not\n") }
+  if (not -f $file3) { die("Check if $file3 exist or not\n") }
+  if (not -f $srcfile) { die("Check if $srcfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+
+  # file names for figures
+  $name    = "$dir/event_$stev";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  # number of receivers
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+
+  $npath = $nrec * 1;
+  $plot_title = "\"Actual\" structure, model, misfit, and summed kernel ($ktype, EVENT $stev) -- irun = $strun";
+  $plot_title2 = "1 event, $nrec receivers, $npath paths (seismograms)";
+
+#}
+#die("testing");
+#for ($k = 0; $k <= $nevent-1; $k = $k+1) {
+
+  #=============================================
+  # model for data
+
+  if($ipvel==1) {$cpt_vel = "model_files/socal_color.cpt"}
+  else {
+     # make colorpoint file
+     #$T1 = "-T3/4/0.1";
+     $dc = $cmax/10;
+     $T1 = "-T-$cmax/$cmax/$dc";
+     $cpt_vel = "color0.cpt";
+     print CSH "makecpt -C$colorbar $T1 > temp1\n";
+     print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+     print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel\n";
+  }
+
+  # phase velocity map
+  #print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -V $origin > $psfile\n"; # START
+  print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -V $origin > $psfile\n"; # START
+  print CSH "pscoast $J $R $B1dat -W1p -Na/1p -Dh -P -K -O -V >> $psfile\n";
+  #print CSH "awk '{print \$2,\$1}' ../../INPUT/oms_shelf |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+
+  # plot receivers with numbered label
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $rec0 >> $psfile\n";
+  $rec_file = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $srcfile > $rec_file\n";
+  print CSH "pstext $rec_file -N $J $R -K -O -P -V >> $psfile\n";
+
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale1 $Bscale1d -P -K -O -V >> $psfile \n"; # -I gives fancy shading
+  #print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $title\nEOF\n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $shift = "-Xa0 -Ya4";
+  $shift2 = "-Xa0 -Ya3.75";
+  print CSH "pstext -N $J $R $Utag -K -O -P -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize1 0 $fontno LM $plot_title\nEOF\n";
+  print CSH "pstext -N $J $R -K -O -P -V $shift2 >>$psfile<<EOF\n $xmin $zmin $fsize1 0 $fontno LM $plot_title2\nEOF\n";
+
+  #--------------------------------------------
+  # model for synthetics
+
+  $dX = 1.1*$Jwid;
+  $shift = "-X$dX";
+
+  # phase velocity map
+  #print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel $shift -I -P -O -K -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel $shift -I -P -O -K -V >> $psfile\n";
+  print CSH "pscoast $J $R $B1syn -W1p -Na/1p -Dh -P -K -O -V >> $psfile\n";
+  #print CSH "awk '{print \$2,\$1}' ../../INPUT/oms_shelf |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+
+  # plot source, receivers with numbered label
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $rec0 >> $psfile\n";
+  $rec_file = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $srcfile > $rec_file\n";
+  print CSH "pstext $rec_file -N $J $R -K -O -P -V >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale1 $Bscale1s -P -K -O -V >> $psfile \n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  $fac = 0.40; $dY = -(1+$fac)*$Jwid;
+  $shift = "-X-$dX -Y$dY";
+
+  #$dX = 1.1*$Jwid;
+  #$dY = $Jwid/2 + $fac/2*$Jwid;
+  #$shift = "-X$dX -Y$dY";
+
+  # total misfit for the event
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schi = sprintf("\@~\143\@~\@-$stev\@- ( $smod )  =  %3.3e",$chi);
+
+  $cptfile3 = "color_3.cpt";
+  print CSH "makecpt -Chot $T3 -I > $cptfile3\n";
+  #print CSH "sed 's/^B.*/B       170     0      0  /' color.cpt  >  color1.cpt\n";
+  #print CSH "sed 's/^F.*/F         0    34    226  /' color1.cpt > $cptfile3\n";
+
+  print CSH "psbasemap $J $R $B3 $shift -K -O -P -V >> $psfile\n";
+  if($nrec >= 10) {
+    #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 > temp\n";
+    print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R $B3 -A- -C$cptfile3 -I -K -O -P -V >> $psfile\n";
+    print CSH "psscale -C$cptfile3 $Dscale3 $Bscale3 -K -O -P -V >> $psfile \n";
+  }
+  print CSH "pscoast $J $R $B3 -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+  #print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[$k]\nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+
+  $chiloc = "-Xa$Dx -Ya-1.1";
+  print CSH "pstext -N $J $R -K -O -P -V $chiloc >>$psfile<<EOF\n $xmin $zmin $fsize1 0 $fontno CM $schi \nEOF\n";
+
+  #=============================================
+  # kernel
+
+  #$fac = 0.35;
+  #$dY = -(1+$fac)*$Jwid;
+  #$shift = "-Y$dY";
+  $shift = "-X$dX";
+
+  print CSH "\n echo here we are $shift \n";
+
+  $cptfile2 = "color_2.cpt";
+  print CSH "makecpt -C$colorbar $T2 > color.cpt\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' color.cpt  >  color1.cpt\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' color1.cpt > $cptfile2\n";
+
+  #($pwr,$cmax) = split(" ",$colors[$k]);
+  #$norm = "1e-$kpwr";
+  #print CSH "echo color parameters for $file: norm = $norm, cmax = $cmax\n";
+
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R $B2 -A- -C$cptfile2 $shift -I -K -O -P -V >> $psfile\n";
+  print CSH "pscoast $J $R $B2 -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+  print CSH "psscale -C$cptfile2 $Dscale2 $Bscale2 -K -O -P -V >> $psfile \n";
+  #print CSH "pstext -N $J $R -K -O -P -V >>$psfile<<EOF\n $xtx $ztx $fsize1 0 $fontno CM $titles[$k]\nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $srcfile |psxy -N $J $R -O -P -V $src >> $psfile\n";  # FINISH
+
+  #----------------------------
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}  # for k < nevent
+
+#=================================================================
+} else {      # summed event kernel (misfit kernel)
+#=================================================================
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  $cshfile = "plot_ker_mod.csh";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+  $src = "-W0.5p -Sa0.15";
+
+  # get the summed kernel and chi files
+  $file2 = "$dir/summed_ker.dat";
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}$stev1/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+
+  # file names for figures
+  $name    = "$dir/event_sum_$strun";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  # number of receivers
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+
+  $npath = $nrec * $nevent;
+  $plot_title = "\"Actual\" structure, model, misfit, and summed kernel ($ktype) -- irun = $strun";
+  $plot_title2 = "$nevent events, $nrec receivers, $npath paths (seismograms) -- $c0_lab,  $per_lab,  $lam_lab";
+
+  #=============================================
+  # model for the data
+
+  if($ipvel==1) {$cpt_vel = "model_files/socal_color.cpt"}
+  else {
+     # make colorpoint file
+     #$T1 = "-T3/4/0.1";
+     $dc = $cmax/10;
+     $T1 = "-T-$cmax/$cmax/$dc";
+     $cpt_vel = "color0.cpt";
+     print CSH "makecpt -C$colorbar $T1 > temp1\n";
+     print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+     print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel\n";
+  }
+
+  # phase velocity map
+  #print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -V $origin > $psfile\n"; # START
+  print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -V $origin > $psfile\n"; # START
+  print CSH "pscoast $J $R $B1dat -W1p -Na/1p -Dh -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+
+  # plot receivers with numbered label
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec0 >> $psfile\n";
+  $rec_file = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $recfile > $rec_file\n";
+  print CSH "pstext $rec_file -N $J $R -K -O -P -V >> $psfile\n";
+
+  #print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale1 $Bscale1d -P -K -O -V >> $psfile \n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $shift = "-Xa0 -Ya4";
+  $shift2 = "-Xa0 -Ya3.75";
+  print CSH "pstext -N $J $R $Utag -K -O -P -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize1 0 $fontno LM $plot_title\nEOF\n";
+  print CSH "pstext -N $J $R -K -O -P -V $shift2 >>$psfile<<EOF\n $xmin $zmin $fsize1 0 $fontno LM $plot_title2\nEOF\n";
+
+  #--------------------------------------------
+  # model for synthetics
+
+  $dX = 1.1*$Jwid;
+  $shift = "-X$dX";
+
+  # phase velocity map
+  #print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel $shift -I -P -O -K -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel $shift -I -P -O -K -V >> $psfile\n";
+  print CSH "pscoast $J $R $B1syn -W1p -Na/1p -Dh -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+
+  # plot receivers with numbered label
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec0 >> $psfile\n";
+  $rec_file = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $recfile > $rec_file\n";
+  print CSH "pstext $rec_file -N $J $R -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale1 $Bscale1s -P -K -O -V >> $psfile \n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  $fac = 0.40; $dY = -(1+$fac)*$Jwid;
+  #$shift = "-Y$dY";
+  $shift = "-X-$dX -Y$dY";
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+
+  $cptfile3 = "color_3.cpt";
+  print CSH "makecpt -Chot $T3 -I > $cptfile3\n";
+
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R $B3 -A- -C$cptfile3 $shift -I -K -O -P -V >> $psfile\n";
+  print CSH "pscoast $J $R $B3 -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+
+  print CSH "psscale -C$cptfile3 $Dscale3 $Bscale3 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  $chiloc = "-Xa$Dx -Ya-1.1";
+  print CSH "pstext -N $J $R -K -O -P -V $chiloc >>$psfile<<EOF\n $xmin $zmin $fsize1 0 $fontno CM $schi \nEOF\n";
+
+  #=============================================
+  # kernel
+
+  $shift = "-X$dX";
+
+  $cptfile2 = "color_2.cpt";
+  print CSH "makecpt -C$colorbar $T2 > color.cpt\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' color.cpt  >  color1.cpt\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' color1.cpt > $cptfile2\n";
+
+  print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R $B2 -A- -C$cptfile2 $shift -I -K -O -P -V >> $psfile\n";
+  print CSH "pscoast $J $R $B2 -W1p -Na/1p -Dh -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n";
+
+  print CSH "psscale -C$cptfile2 $Dscale2 $Bscale2 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -O -P -V $rec >> $psfile\n"; # FINISH
+
+#-----------------------------
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+  #system("rm $psfile &");
+}
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_ker_mod.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_model.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_model.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_model.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,318 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_surf_model.pl
+#  Carl Tape
+#  23-Nov-2008
+#
+#  Plot the source time function, the velocity model for the synthetics,
+#  and the velocity model for the data (optional).
+#  This program can executed from wave2d.f90.
+#
+#  iopt = 1 : reference model
+#  iopt = 2 : data model, reference model
+#  iopt = 3 : reference model with source + receivers, source time function
+#  iopt = 4 : data model and reference model with source + receivers, source time function
+#
+#  Examples:
+#    ../plot_surf_model.pl 4 100 0 0/1/5 0.1/0.05 stf_00001_1 0
+#    ../plot_surf_model.pl 4 200 0 0/1/5 0.1/0.05 stf_00001_1 0
+#    ../plot_surf_model.pl 4 300 0 0/1/5 0.1/0.05 stf_00001_1 0
+#    ../plot_surf_model.pl 4 400 0 1/0/5 0.1/0.05 stf_00001_1 0
+#    ../plot_surf_model.pl 4 500 0 1/0/5 0.1/0.05 stf_00001_1 0
+#    ../plot_surf_model.pl 4 600 0 1/0/5 0.1/0.05 stf_00001_1 0
+#    ../plot_surf_model.pl 4 700 0 1/0/5 0.1/0.05 stf_00001_1 0
+#
+#==========================================================
+
+if (@ARGV < 7) {die("Usage: plot_surf_model.pl xxx\n");}
+($iopt,$irun0,$imodel,$ievents,$pbar,$stf_file1,$ifinite) = @ARGV;
+$comp = 1;
+
+($pmax,$ptick) = split("/",$pbar);
+($ievent_all,$ievent_one,$ievent) = split("/",$ievents);
+$rec_file1 = "sr.txt";
+$efile_syn = "events_syn_lonlat.dat";
+$mfile_syn = "structure_syn.dat";
+$mfile_dat = "structure_dat.dat";
+
+# directories
+$rundir = "/home/carltape/wave2d/SEM2D_iterate";    # USER change
+$plotdir = "${rundir}/PLOTTING";
+$odir = "${rundir}/OUTPUT";
+$idir = "${rundir}/INPUT";
+$figdir = "${plotdir}/FIGURES";
+if (not -e $figdir) {die("Check if figdir $figdir exist or not\n");}
+
+$stirun0 = sprintf("%4.4i",$irun0);
+$stirun = sprintf("%4.4i",$irun0+$imodel);
+
+$dir0 = "$odir/run_${stirun0}";
+$dir1 = "$odir/run_${stirun}";
+$dir2 = sprintf("$dir1/event_%3.3i",$ievent);
+$stf_file = "$dir2/${stf_file1}";
+$rec_file = "$dir2/${rec_file1}";
+$file1dat = "$dir1/${mfile_dat}";
+$file1syn = "$dir1/${mfile_syn}";
+$evefile = "$dir0/${efile_syn}";     # event file from the base directory
+if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+if (not -f $file1syn) { die("Check if $file1syn exist or not\n") }
+if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+# read in reference values: alpha0, beta0, per
+if (1==1) {
+  $fileref1 = "$dir0/reference_values.dat";
+  $fileref2 = "$dir0/reference_period.dat";
+  open(IN,$fileref1); @lines = <IN>; ($alpha0,$beta0) = split(" ",$lines[0]);
+  open(IN,$fileref2); $per = <IN>; chomp($per);
+} else {
+  $per = 20;
+  $beta0 = 3500;
+}
+$per_lab = sprintf("T = %3.3f s",$per);
+$beta0_lab  = sprintf("beta0 = %3.3f km/s",$beta0/1000);
+#print "\n-- $per -- $per_lab -- $beta0_lab --\n"; die("testing");
+
+#$edir  = sprintf("$dir/event_%3.3i",$event);
+#print "\n $dir,$edir,$mfile_dat,$mfile_syn,$beta0,$per,$ifinite,$iopt \n";
+
+$plabel = "${plotdir}/plot_surf_model.pl";
+
+#die("\ntesting\n");
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.1c";
+
+$tinc = 50;   # tick increment (in seconds) for source time function
+
+# plot symbols for sources, receivers, and shelf
+if($ifinite==0) {$src0 = "-W0.75p -Sa0.20 -G255/0/0"} else {$src0 = "-Sc0.05"}
+$src = "-W0.75p -Sa0.20";
+$rec = "-W0.5p/0/0/0 -St0.10";
+$rec0 = "-Sc10p -W0.5p";
+$Wshelf = "-W1.0/0/0/0tap";
+
+# resolution of color plots
+$interp = "-I0.5m/0.5m -S4m";   # key information
+$grdfile = "temp.grd";
+
+#-------------------------
+# color
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+
+#-------------------------
+
+# write plotting scripts
+$wid = 3.5;
+$J1 = "-JM${wid}i";      # in lat-lon
+$origin = "-X1.5 -Y2.0";
+
+$B1dat = "-B1:.\" \":WeSN";
+$B1syn = "-B1:.\" \":wESN";
+
+$Dlen = 2.0;
+$Dx = $wid/2;
+$Dy = -0.35;
+
+$Dscale1 = "-D$Dx/$Dy/$Dlen/0.10h";
+
+#$Bscale1  = sprintf("-B%2.2e:\" Phase Velocity ( km s\@+-1\@+ )\": -E10p",$ptick);
+$Bscale1  = sprintf("-B%2.2e:\" Percent Perturbation from %3.3f  km s\@+-1\@+ \": -E10p",$ptick,$beta0/1000);
+
+#-------------------------
+
+$title = "Membrane Wave Speed";
+#$title = "Rayleigh Wave Phase Velocity";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax,$smin,$smax,$tmin,$tmax) = split(" ",`minmax -C $file1dat`);
+($tt) = sort{$b <=> $a} ($tt,abs($tmin),abs($tmax));
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+print "\n $R \n $smin $smax \n -$tt $tt \n";
+
+# plot title
+$xtx = $xmin+0.5*($xmax-$xmin);
+$ztx = $zmin+1.10*($zmax-$zmin);
+
+$name    = "model_${stirun}";
+$psfile  = "$name.ps";
+$jpgfile = "$name.jpg";
+
+  #===============================================
+  $cshfile = "plot_surf_model.csh";
+  print "\nWriting to CSH file ${cshfile}...\n";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain PAPER_MEDIA letter TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+  # make colorpoint file
+#  $T1 = "-T3/4/0.1";
+#  $pmax = 10;
+  $dc = $pmax/10;
+  $T1 = "-T-$pmax/$pmax/$dc";
+  $cptfile1 = "color0.cpt";
+  print CSH "makecpt -C$colorbar -D $T1 > $cptfile1\n";
+  #print CSH "makecpt -C$colorbar -D $T1 > temp1\n";
+  #print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+  #print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile1\n";
+
+#=============================================
+if($iopt == 1) {
+#=============================================
+
+  $plot_title = "Model for synthetics";
+  $origin = "-X1.5 -Y5.0";
+
+  # phase velocity map
+  print CSH "psbasemap $B1syn $R $J1 -P -K -V $origin > $psfile\n";  # START
+  #print CSH "awk '{print \$1,\$2,\$7}' $file1syn | pscontour $R $J1 -A- -C$cptfile1 -I -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$7}' $file1syn | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C$cptfile1 $J1 -K -O -V -Q >> $psfile\n";
+  print CSH "pscoast $J1 $R $B1syn -W1p -Na/1p -Dh -K -O -V >> $psfile\n";
+  #print CSH "awk '{print \$2,\$1}' $idir/BOUNDARIES/oms_shelf |psxy $J1 $R $Wshelf -K -O -V >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale1 -K -O -V >> $psfile \n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $shift = "-Xa-$dX -Ya4";
+  print CSH "pstext -N $J1 $R $Utag -O -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $plot_title\nEOF\n";  # FINISH
+
+#=============================================
+} if($iopt == 2) {
+#=============================================
+
+  $plot_title = "Model for data, model for synthetics";
+  $origin = "-X0.6 -Y5.0";
+
+  # phase velocity map -- data
+  print CSH "psbasemap $B1dat $R $J1 -P -K -V $origin > $psfile\n";  # START
+  #print CSH "awk '{print \$1,\$2,\$7}' $file1dat | pscontour $R $J1 -A- -C$cptfile1 -I -V -K -O >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$7}' $file1dat | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C$cptfile1 $J1 -K -O -V -Q >> $psfile\n";
+  print CSH "pscoast $J1 $R $B1dat -W1p -Na/1p -Dh -V -K -O >> $psfile\n";
+  #print CSH "awk '{print \$2,\$1}' $idir/BOUNDARIES/oms_shelf |psxy $J1 $R $Wshelf -V -K -O >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale1 -V -K -O >> $psfile \n";
+
+  $dX = 1.1*$wid; $dY = 0;
+  #$dX = 0; $dY = 4.0;
+  $shift = "-X$dX -Y$dY";
+
+  # phase velocity map -- synthetics
+  print CSH "psbasemap $B1syn $R $J1 -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$7}' $file1syn | pscontour $R $J1 -A- -C$cptfile1 -I -V -K -O >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$7}' $file1syn | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C$cptfile1 $J1 -K -O -V -Q >> $psfile\n";
+  print CSH "pscoast $J1 $R $B1syn -W1p -Na/1p -Dh -V -K -O >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale1 -V -K -O >> $psfile \n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $shift = "-Xa-$dX -Ya4";
+  print CSH "pstext -N $J1 $R $Utag -V -O $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $plot_title\nEOF\n";  # FINISH
+
+#=============================================
+} if($iopt > 2) {
+#=============================================
+
+  #$rec_file = "$edir/sr.txt";
+  if (not -f $rec_file) { die("Check if rec_file $rec_file exist or not\n") }
+
+  # source time function
+  #$stf_file = "$edir/stf_00001_$comp";
+  print "\n Source time function is $stf_file\n";
+  ($tmin,$tmax,$smin,$smax) = split(" ",`minmax -C $stf_file`);
+  ($ss) = sort{$b <=> $a} (abs($smin),abs($smax));
+
+  if ($ss==0) {$ss = 1}  # do not normalize by zero
+  print "smax = $ss \n tmin = $tmin tmax = $tmax\n";
+
+  #$stf_data = "temp";
+  $Bs = sprintf("-B%3.3f:\"Time  (s)\":/%3.3f:\" h (t) \"::.\"Source time function (hdur = %3.1f s)\":WeSn",$tinc,0.5,$per/2);
+  $Rs = "-R$tmin/$tmax/-1/1";
+  $Js = "-JX5/1.5";
+  #print CSH "awk '{print \$1,\$2/$ss}' $stf_file > $stf_data\n";
+  #print CSH "psxy $stf_data $Rs $Js $Bs -W1p -K -O -V -Y-3.5 >> $psfile\n";
+
+  print CSH "psbasemap $Rs $Js $Bs -P -K -V $origin > $psfile\n"; # START
+  print CSH "awk '{print \$1,\$2/$ss}' $stf_file | psxy $Rs $Js $Bs -W1p -K -O -V >> $psfile\n";
+
+if($iopt == 4) {
+
+  # model for data (optional)
+  $plot_title = "Target model, initial model, and source time function (run_${stirun})";
+  $shift = "-Y4.0 -X-0.9";
+
+  # phase velocity map
+  print CSH "psbasemap $B1dat $R $J1 -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$7}' $file1dat | pscontour $R $J1 -A- -C$cptfile1 -I -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$7}' $file1dat | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C$cptfile1 $J1 -K -O -V -Q >> $psfile\n";
+  print CSH "pscoast $J1 $R $B1dat -W1p -Na/1p -Dh -K -O -V >> $psfile\n";
+
+  # plot receivers with numbered label
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $rec_file | psxy -N $J1 $R -K -O -V $rec0 >> $psfile\n";
+  $rec_file2 = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $rec_file > $rec_file2\n";
+  print CSH "pstext $rec_file2 -N $J1 $R -K -O -V >> $psfile\n";
+
+  if($ievent_one) {print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $rec_file | psxy $src0 -N $J1 $R -K -O -V >> $psfile\n";}
+  if($ievent_all) {print CSH "awk '{print \$1,\$2}' $evefile | psxy $src -N $J1 $R -K -O -V >> $psfile\n";}
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale1 -K -O -V >> $psfile \n";
+
+  $dX = 1.1*$wid; $dY = 0;
+
+} else {
+
+  $plot_title = "Velocity model and source time function";
+  $dX = 0; $dY = 4.0;
+}
+
+  # model for synthetics
+  $shift = "-X$dX -Y$dY";
+
+  # phase velocity map
+  print CSH "psbasemap $B1syn  $R $J1 -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$7}' $file1syn | pscontour $R $J1 -A- -C$cptfile1 $shift -I -O -K -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2,\$7}' $file1syn | nearneighbor -G$grdfile $R $interp\n";
+  print CSH "grdimage $grdfile -C$cptfile1 $J1 -K -O -V -Q >> $psfile\n";
+  print CSH "pscoast $J1 $R $B1syn -W1p -Na/1p -Dh -K -O -V >> $psfile\n";
+
+  # plot receivers with numbered label
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $rec_file | psxy -N $J1 $R -K -O -V $rec0 >> $psfile\n";
+  $rec_file2 = text_rec; $angle = 0; $just = "CM";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $rec_file > $rec_file2\n";
+  print CSH "pstext $rec_file2 -N $J1 $R -K -O -V >> $psfile\n";
+  if($ievent_one) {print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $rec_file | psxy $src0 -N $J1 $R -K -O -V >> $psfile\n";}
+  if($ievent_all) {print CSH "awk '{print \$1,\$2}' $evefile | psxy $src -N $J1 $R -K -O -V >> $psfile\n";}
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale1 -K -O -V >> $psfile \n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $shift = "-Xa-$dX -Ya4";
+  print CSH "pstext -N $J1 $R $Utag -O -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $plot_title\nEOF\n";  # FINISH
+
+}  # $iopt > 2
+
+#-----------------------------
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("ghostview $psfile &")
+  #if($iopt <= 2) {system("xv $jpgfile &")}
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_model.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_smooth_func.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_smooth_func.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_smooth_func.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,241 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_surf_smooth_func.pl
+#  Carl Tape
+#  28-Nov-2006
+#
+# This script plots the unsmoothed and smoothed functions.
+# Smoothing is computed by convolving a function with a 2D Gaussian.
+# Copied from plot_model.pl on 16-Oct-2005.
+#
+# EXAMPLE
+#   scripts/plot_surf_smooth_func.pl . fun_smooth.dat 10000
+#
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0160 fun_smooth.dat 30000
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0220 fun_smooth.dat 25000
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0100 fun_smooth.dat 20000
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0200 fun_smooth.dat 15000
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0040 fun_smooth.dat 10000
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0240 fun_smooth.dat  5000
+#
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0700 fun_smooth.dat 30000
+#
+#   scripts/plot_surf_smooth_func.pl OUTPUT/run_0460 fun_smooth.dat 60000
+#   scripts/plot_surf_smooth_func.pl . fun_smooth.dat 30000
+#
+#==========================================================
+
+if (@ARGV < 3) {die("Usage: plot_surf_smooth_func.pl basedir xxx \n");}
+($dir,$file_smooth,$gamma) = @ARGV;
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "9";
+$fsize3 = "5";
+$fontno = "1";    # 1 or 4
+$tick   = "0.1c";
+
+# plot symbols for sources, receivers, and shelf
+if($ifinite==0) {$src = "-W1.0p -Sa0.20 -G255/0/0";} else {$src = "-Sc0.05";}
+$rec = "-W0.5p/0/0/0 -St0.10";
+$rec0 = "-Sc10p -W0.5p";
+$Wshelf = "-W1.0/0/0/0tap";
+
+$plabel = "/home/carltape/sem2d/2d_adjoint/scripts/plot_surf_smooth_func.pl";
+
+#-------------------------
+# color
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+
+#-------------------------
+
+# write plotting scripts
+$wid = 3.4;
+#$J1 = "-JM${wid}i";      # in lat-lon
+$J1 = "-JX${wid}i";
+$origin = "-X0.65 -Y6.0";
+
+$Bl = "-B50:.\" \":WeSN";
+$Br = "-B50:.\" \":wESN";
+$Bb = "-B50:.\" \":WESN";
+
+$Dlen = 2.0;
+$Dx = $wid/2;
+$Dy = -0.35;
+
+$Dscale1 = "-D$Dx/$Dy/$Dlen/0.10h";
+
+$cmax = 3e-6;
+$cmax = 5e-7;
+
+$cmax2 = 4/(3.14159*$gamma*$gamma);
+#$cmax2 = 1/(2*3.14159*$sigma*$sigma);
+
+print "\n cmax for gaussian is $cmax2\n";
+
+$bs1 = 1;
+$bs2 = 1;
+$bs4 = 1000;
+$Bscale1  = sprintf("-B%2.2e:\" Rough function, K(x, y)\":",$bs1);
+$Bscale2  = sprintf("-B%2.2e:\" Smooth function, K'(x, y)\":",$bs1);
+$Bscale3  = sprintf("-B%2.2e:\" Residual value, K - K' \":",$bs1);
+$BscaleG  = sprintf("-B%2.2e:\" Gaussian filter,  \@~\147\@~ = %3.3f km \":",$bs2,$gamma/1000);
+$Bscale4  = sprintf("-B%2.2e:\" Smooth function, g\@+\@~\141\@~\@~\142\@~\@+  \":",$bs4);
+
+#-------------------------
+
+$file = "$dir/$file_smooth";
+if (not -f $file)   { die("Check if $file exist or not\n") }
+
+# set bounds for the plotting
+$xmin = 0; $xmax = 480; $zmin = 0; $zmax = 480;
+$fac = 40;
+$xmin = $xmin - $fac; $xmax = $xmax + $fac;
+$zmin = $zmin - $fac; $zmax = $zmax + $fac;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$xtx = $xmin+0.5*($xmax-$xmin);
+$ztx = $zmin+1.10*($zmax-$zmin);
+
+$name    = "smooth";
+$psfile  = "$dir/$name.ps";
+$jpgfile = "$dir/$name.jpg";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  $cshfile = "plot_smoothed_func.csh";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+  #===============================================
+
+  # make colorpoint file
+  $dc = $cmax/10;
+  $T1 = "-T-${cmax}/${cmax}/$dc";
+  $cptfile1 = "color1.cpt";
+  print CSH "makecpt -C$colorbar $T1 -D > $cptfile1\n";
+  #print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+  #print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile1\n";
+
+  # make colorpoint file
+  $dc2 = $cmax2/10;
+  $T2  = "-T-${cmax2}/${cmax2}/$dc2";
+  $cptfile2 = "color2.cpt";
+  print CSH "makecpt -C$colorbar $T2 -D > $cptfile2\n";
+  #print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+  #print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile2\n";
+
+  # model for data (optional)
+  $plot_title = "Gaussian smoothing of a function";
+  $shift = "-Y4.0 -X-0.9";
+
+  # rough function
+  print CSH "psbasemap $Bl $J1 $R -P -K -V $origin > $psfile\n";  # START
+  print CSH "awk '{print \$3/1000,\$4/1000,\$5}' $file | pscontour $R $J1 -A- -C$cptfile1 -I -P -K -O -V >> $psfile\n";
+
+  #$grdfile = "temp.grd"; $interp = "$I $S";
+  #print CSH "nearneighbor $dfile -G$grdfile $R $interp \n";
+  #print CSH "grdimage $grdfile -C$cptfile $J -K -O -V >> $psfile\n";   # -T for no interpolation
+
+  #print CSH "pscoast $J1 $R $B1dat -W1p -Na/1p -Dl -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale1 -P -K -O -V >> $psfile \n";
+
+  # gaussian function
+  $dX = 1.1*$wid; $dY = 0;
+  $shift = "-X$dX -Y$dY";
+  print CSH "psbasemap $Br $J1 $R -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$3/1000,\$4/1000,\$6}' $file | pscontour $R $J1 -A- -C$cptfile2 -I -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+  print CSH "psscale -C$cptfile2 $Dscale1 $BscaleG -P -K -O -V >> $psfile \n";
+
+  # smooth function
+  $dX = -1.1*$wid; $dY = -1.4*$wid;
+  $shift = "-X$dX -Y$dY";
+  print CSH "psbasemap $Bl $J1 $R -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$3/1000,\$4/1000,\$7}' $file | pscontour $R $J1 -A- -C$cptfile1 -I -P -O -K -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale2 -K -P -O -V >> $psfile \n";
+
+  # residual function
+  $dX = 1.1*$wid; $dY = 0;
+  $shift = "-X$dX -Y$dY";
+  print CSH "psbasemap $Br $J1 $R -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$3/1000,\$4/1000,\$8}' $file | pscontour $R $J1 -A- -C$cptfile1 -I -P -O -K -V >> $psfile\n";
+  print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale3 -K -P -O -V >> $psfile \n";
+
+  # plot title and GMT header
+  $Utag = "-U/0/0.25/$plabel";
+  $shift = "-Xa-$dX -Ya8.75";
+  print CSH "pstext -N $J1 $R $Utag -O -P -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $plot_title\nEOF\n";  # FINISH
+
+#-----------------------------
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+#===============================================
+
+#$name    = "smooth2";
+#$psfile  = "$dir/$name.ps";
+#$jpgfile = "$dir/$name.jpg";
+
+#  #===============================================
+#  print "\nWriting CSH file...\n";
+#  $cshfile = "plot_smoothed_func.csh";
+#  open(CSH,">$cshfile");
+#  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1\n";
+#  #===============================================
+
+#  # make colorpoint file
+#  $cmax3 = 20;
+#  $dc = $cmax3/10;
+#  $T2 = "-T-${cmax3}/${cmax3}/$dc";
+#  $cptfile3 = "color3.cpt";
+#  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+#  print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+#  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile3\n";
+
+#  # model for data (optional)
+#  $plot_title = "Two representations of the misfit gradient";
+#  $shift = "-Y4.0 -X-0.9";
+
+#  # smooth function
+#  $dX = -1.1*$wid; $dY = -1.4*$wid;
+#  $shift = "-X$dX -Y$dY";
+#  print CSH "psbasemap $Bl $J1 $R -P -K -V $origin > $psfile\n";  # START
+#  print CSH "awk '{print \$3/1000,\$4/1000,\$5}' $file | pscontour $R $J1 -A- -C$cptfile1 -I -P -O -K -V >> $psfile\n";
+#  print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+#  print CSH "psscale -C$cptfile1 $Dscale1 $Bscale2 -K -P -O -V >> $psfile \n";
+
+#  # residual function
+#  $dX = 1.1*$wid; $dY = 0;
+#  $shift = "-X$dX -Y$dY";
+#  print CSH "psbasemap $Br $J1 $R -P -K -O -V $shift >> $psfile\n";
+#  print CSH "awk '{print \$3/1000,\$4/1000,\$7}' $file | pscontour $R $J1 -A- -C$cptfile3 -I -P -O -K -V >> $psfile\n";
+#  print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J1 $R $Wshelf -K -O -P -V >> $psfile\n";
+#  print CSH "psscale -C$cptfile3 $Dscale1 $Bscale4 -K -P -O -V >> $psfile \n";
+
+#  # plot title and GMT header
+#  $Utag = "-U/0/0.25/$plabel";
+#  $shift = "-Xa-$dX -Ya8.75";
+#  print CSH "pstext -N $J1 $R $Utag -O -P -V $shift >>$psfile<<EOF\n $xmin $zmin $fsize0 0 $fontno LM $plot_title\nEOF\n";  # FINISH
+
+##-----------------------------
+#  print CSH "convert $psfile $jpgfile\n";
+
+#  close (CSH);
+#  system("csh -f $cshfile");
+#  system("xv $jpgfile &");
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/PLOTTING/plot_surf_smooth_func.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/README
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/README	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/README	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,166 @@
+Carl Tape, 23-Nov-2008
+carltape at gps.caltech.edu
+
+/home/carltape/wave2d/SEM2D_iterate/README
+
+This is a developmental version of a self-contained synthetic iterative inversion using a 2D spectral-element method (SEM) code as the forward solver.  This is not a substitute for the official 2D SEM version, SPECFEM2D, which is also maintained by CIG.  This version emphasizes the details in embedding the forward solver within the inverse problem, which is not contained in SPECFEM2D.
+
+The code can run in P-SV mode as a depth cross-section (Tromp, Tape, Liu, 2005).
+Or it can run in SH mode as a membrane surface wave analogue (Tape, Liu, Tromp, 2007).
+
+There are several perl-based GMT plotting scripts.
+The user needs access to ifort, matlab, perl, and GMT, but not SAC.
+
+The best reference for the inverse method implemented here is:
+Tarantola (2005), Inverse Problem Theory and Methods for Model Parameter Estimation
+In particular, Section 6.22 on gradient-based techniques is very useful.
+
+--------------------------------
+HISTORY
+
+The original version of the 2D wave propagation code came from Jeroen Tromp
+and was modified by Carl Tape and, later, Qinya Liu.
+The original simulations were presented in Tromp, Tape, Liu (2005).
+After Qinya's modifications, Carl used the code to time-reverse
+ocean microseism (OMS) records to try to determine the source regions.
+Later, Carl used the code for the simulations presented in Tape, Liu, Tromp (2007).
+That version of the codes is in the directory
+   SEM2D_iterate/gji_paper/codes_18_06Aug2006
+
+--------------------------------
+EXAMPLES TO RUN
+
+The user is encouraged to first try to run the set of seven examples.
+The first six employ a conjugate-gradient algorithm,
+while the fifth uses a source subspace projection method.
+
+In examples 1-5, the scalelength of the checkerboard is set by Nfac=3.
+In examples 6-7, the scalelength of the checkerboard is set by Nfac=2 (more detailed).
+
+Example 1: 1 source, structure inversion only using CG algorithm
+Example 2: 1 source, source inversion only (xs, ys, ts) using CG algorithm
+Example 3: 1 source, joint inversion using CG algorithm
+Example 4: 5 sources, joint inversion using CG algorithm
+Example 5: 25 sources, joint inversion using CG algorithm
+Example 6: 25 sources, structure inversion using CG algorithm
+Example 7: 25 sources, structure inversion using subspace method
+
+To get a sense for the output from these examples, open the composite PDF files
+    /PLOTTING/FIGURES/Example1_run_0100.pdf
+    /PLOTTING/FIGURES/Examples_all.pdf
+    /PLOTTING/FIGURES/Example7_run_0700.pdf
+
+--------------------------------
+DETAILS FOR RUNNING EACH EXAMPLE
+
+EXAMPLE 1 (run_0100)
+Compile and execute:
+  make clean ; make wave2d ; wave2d
+After the simulation finishes
+  cd PLOTTING/FIGURES
+Note that the output files are in the directories beginning with OUTPUT/run_0100.
+Then execute the example lines in plot_geometry.pl and plot_surf_model.pl.
+This will require first changing the variables for the main directory (search USER).
+Then open matlab and the file wave2d_cg_poly.m and wave2d_cg_figs.m.
+Run wave2d_cg_poly.m and then wave2d_cg_figs.m, which generate data files that
+   will be used in joint_inversion.pl.
+Next execute the example line in joint_inversion.pl.
+
+EXAMPLE 2 (run_0200)
+
+Make the following modifications to src/wave2d_constants.f90
+   IRUNZ = 100         --> IRUNZ = 200
+   PERT_STRUCT = 1     --> PERT_STRUCT = 0
+   PERT_SOURCE_T = 0   --> PERT_SOURCE_T = 1
+   PERT_SOURCE_X = 0   --> PERT_SOURCE_X = 1
+   INV_STRUCT = 1      --> INV_STRUCT = 0
+   INV_SOURCE_T = 0    --> INV_SOURCE_T = 1
+   INV_SOURCE_X = 0    --> INV_SOURCE_X = 1
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+Follow steps from Example 1 to make figures.
+
+EXAMPLE 3 (run_0300)
+Make the following modifications to src/wave2d_constants.f90
+   IRUNZ = 200         --> IRUNZ = 300
+   PERT_STRUCT = 1     --> PERT_STRUCT = 1
+   INV_STRUCT = 1      --> INV_STRUCT = 1
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+Follow steps from Example 1 to make figures.
+
+EXAMPLE 4 (run_0400)
+Make the following modification to src/wave2d_constants.f90
+   IRUNZ = 300         --> IRUNZ = 400
+Make the following changes in src/wave2d.f90
+   ievent_min = 5  ; ievent_max = ievent_min   -->   ievent_min = 1 ; ievent_max = 5
+Uncomment the line beginning with "ugrad_str = 0.4247330856d6", and comment out the others.
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+Follow steps from Example 1 to make figures.
+
+EXAMPLE 5 (run_0500)
+Make the following modification to src/wave2d_constants.f90
+   IRUNZ = 400         --> IRUNZ = 500
+Make the following changes in src/wave2d.f90
+   ievent_min = 1 ; ievent_max = 5   -->  ievent_min = 1  ; ievent_max = nevent
+Uncomment the line beginning with "ugrad_str = 0.2070999127d6", and comment out the others.
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+Follow steps from Example 1 to make figures.
+
+EXAMPLE 6 (run_0600)
+Make the following modification to src/wave2d_constants.f90
+   IRUNZ = 500         --> IRUNZ = 600
+   PERT_SOURCE_T = 1   --> PERT_SOURCE_T = 0
+   PERT_SOURCE_X = 1   --> PERT_SOURCE_X = 0
+   INV_SOURCE_T = 1    --> INV_SOURCE_T = 0
+   INV_SOURCE_X = 1    --> INV_SOURCE_X = 0
+Make the following changes in src/wave2d.f90
+   Nfac = 3            --> Nfac = 2   (decrease the checkerboard scalelength)
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+Follow steps from Example 1 to make figures.
+
+EXAMPLE 7 (run_0700)
+Make the following modification to src/wave2d_constants.f90
+   IRUNZ = 600         --> IRUNZ = 700
+   NITERATION = 16     --> NITERATION = 0
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+Create a directory for the subspace update
+   mkdir OUTPUT/run_0700/HESSIAN
+Open the matlab program matlab/wave2d_subspace.m
+Enter the following values at the prompts:
+-------------------------
+ Enter irun0 : 700
+ Enter 1 to read in new event kernels (0 otherwise) : 1
+ Enter next model number (hmod) : 1
+ Enter 1 to invert for STRUCTURE : 1
+ Enter 1 to invert for SOURCE : 0
+ Enter 1 to write out files : 1
+ Enter 1 to compute the event kernels for this model : 1
+ Enter 1 to plot figures : 1
+ Enter 1 to read smoothed event kernels (0 otherwise) : 1
+ Enter 1 if this balance looks okay : 1
+ Enter 0 for GCV, 1 for OCV, 2 for L-curve : 1
+--------------------------------
+If everything has worked, you will see several sensible figures.
+You now have a model update computed using the subspace method.
+Now you want to compute the misfit function and event kernels using this model.
+Make the following modification to src/wave2d_constants.f90
+  HESSIAN = .false.    --> HESSIAN = .true.
+Then compile and execute:
+   make clean ; make wave2d ; wave2d
+After this is done, go back to wave2d_subspace.m and repeat as before.
+Only make this change
+   Enter next model number (hmod) : 2
+Then back to wave2d.f90 and modify
+   hmod = 1            --> hmod = 2
+This tells the code where to look for the new model.
+
+As you can see, it is not ideal to go back-and-forth between Matlab and Fortran.
+However, many aspects are still in development, and Matlab provides superior
+quick graphics, which are crucial for debugging, checking, and testing.
+
+==================================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/Makefile
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/Makefile	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/Makefile	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,42 @@
+F90 = ifort 
+#F90_FLAGS = -O2
+F90_FLAGS = -O2 
+# first is for FFT, second is for bandpass filter
+LIB = -L/opt/seismo-util/lib -lfftw3 -lDSacLib
+
+# libraries for the original filter.f90
+#LIB = -L/opt/seismo-util/lib -lDRWFiles -lDSacLib -lDSacio -lSacTools -lm
+
+MOD = wave2d_constants wave2d_variables wave2d_define_der_matrices wave2d_solver wave2d_sub wave2d_sub2 wave2d_sub3
+SUB = gll_library lagrange_poly  numerical_recipes
+
+SRC_DIR = src
+MOD_DIR = mod
+OBJ_DIR = obj
+BIN_DIR = .
+MAIN = wave2d wave2d_2 wave2d_3 wave2d_4
+MOD_FLAG = module
+
+MOD_OBJ = $(patsubst %,$(OBJ_DIR)/%.o,$(MOD))
+F90_OBJ = $(patsubst %,$(OBJ_DIR)/%.o,$(SUB))
+OBJ = $(F90_OBJ) $(MOD_OBJ)
+
+all : wave2d wave2d_2 wave2d_3 wave2d_4
+
+$(MAIN) : % : $(SRC_DIR)/%.f90 $(F90_OBJ) $(MOD_OBJ)
+	$(F90) -o $(BIN_DIR)/$* $(F90_FLAGS) $(SRC_DIR)/$*.f90 -$(MOD_FLAG) $(MOD_DIR) $(OBJ) $(LIB)
+
+$(F90_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.f90
+	$(F90) -o $@ $(F90_FLAGS) -c $(SRC_DIR)/$*.f90 
+
+$(MOD_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.f90
+	$(F90) -o $@ $(F90_FLAGS) -c $(SRC_DIR)/$*.f90 -$(MOD_FLAG) $(MOD_DIR) 
+
+.PHONY : clean
+
+clean:
+	\rm -f *.o *.mod *~ $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod  *.gif *.ps $(MAIN)  plot*.csh *.eps *.cpt src/*~
+cleanall:
+	\rm -f OUTPUT/* *.o *.mod *~ $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod  *.gif *.jpg *.ps $(MAIN)  plot*.csh *.eps *.cpt
+
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/gll_library.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/gll_library.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/gll_library.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,528 @@
+!=======================================================================
+!
+!  Library to compute the Gauss-Lobatto-Legendre points and weights
+!  Based on Gauss-Lobatto routines from M.I.T.
+!  Department of Mechanical Engineering
+!
+!=======================================================================
+
+  double precision function endw1(n,alpha,beta)
+
+  implicit none
+
+  integer n
+  double precision alpha,beta
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0,three=3.d0,four=4.d0
+  double precision apb,f1,fint1,fint2,f2,di,abn,abnn,a1,a2,a3,f3
+  double precision, external :: gammaf
+  integer i
+
+  f3 = zero
+  apb   = alpha+beta
+  if (n == 0) then
+   endw1 = zero
+   return
+  endif
+  f1   = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
+  f1   = f1*(apb+two)*two**(apb+two)/two
+  if (n == 1) then
+   endw1 = f1
+   return
+  endif
+  fint1 = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
+  fint1 = fint1*two**(apb+two)
+  fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
+  fint2 = fint2*two**(apb+three)
+  f2    = (-two*(beta+two)*fint1 + (apb+four)*fint2) * (apb+three)/four
+  if (n == 2) then
+   endw1 = f2
+   return
+  endif
+  do i=3,n
+   di   = dble(i-1)
+   abn  = alpha+beta+di
+   abnn = abn+di
+   a1   = -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
+   a2   =  (two*(alpha-beta))/(abnn*(abnn+two))
+   a3   =  (two*(abn+one))/((abnn+two)*(abnn+one))
+   f3   =  -(a2*f2+a1*f1)/a3
+   f1   = f2
+   f2   = f3
+  enddo
+  endw1  = f3
+
+  end function endw1
+
+!
+!=======================================================================
+!
+
+  double precision function endw2(n,alpha,beta)
+
+  implicit none
+
+  integer n
+  double precision alpha,beta
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0,three=3.d0,four=4.d0
+  double precision apb,f1,fint1,fint2,f2,di,abn,abnn,a1,a2,a3,f3
+  double precision, external :: gammaf
+  integer i
+
+  apb   = alpha+beta
+  f3 = zero
+  if (n == 0) then
+   endw2 = zero
+   return
+  endif
+  f1   = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
+  f1   = f1*(apb+two)*two**(apb+two)/two
+  if (n == 1) then
+   endw2 = f1
+   return
+  endif
+  fint1 = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
+  fint1 = fint1*two**(apb+two)
+  fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
+  fint2 = fint2*two**(apb+three)
+  f2    = (two*(alpha+two)*fint1 - (apb+four)*fint2) * (apb+three)/four
+  if (n == 2) then
+   endw2 = f2
+   return
+  endif
+  do i=3,n
+   di   = dble(i-1)
+   abn  = alpha+beta+di
+   abnn = abn+di
+   a1   =  -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
+   a2   =  (two*(alpha-beta))/(abnn*(abnn+two))
+   a3   =  (two*(abn+one))/((abnn+two)*(abnn+one))
+   f3   =  -(a2*f2+a1*f1)/a3
+   f1   = f2
+   f2   = f3
+  enddo
+  endw2  = f3
+
+  end function endw2
+
+!
+!=======================================================================
+!
+
+  double precision function gammaf (x)
+
+  implicit none
+
+  double precision, parameter :: pi = 3.141592653589793d0
+
+  double precision x
+
+  double precision, parameter :: half=0.5d0,one=1.d0,two=2.d0
+
+  gammaf = one
+
+  if (x == -half) gammaf = -two*dsqrt(pi)
+  if (x ==  half) gammaf =  dsqrt(pi)
+  if (x ==  one ) gammaf =  one
+  if (x ==  two ) gammaf =  one
+  if (x ==  1.5d0) gammaf =  dsqrt(pi)/2.d0
+  if (x ==  2.5d0) gammaf =  1.5d0*dsqrt(pi)/2.d0
+  if (x ==  3.5d0) gammaf =  2.5d0*1.5d0*dsqrt(pi)/2.d0
+  if (x ==  3.d0 ) gammaf =  2.d0
+  if (x ==  4.d0 ) gammaf = 6.d0
+  if (x ==  5.d0 ) gammaf = 24.d0
+  if (x ==  6.d0 ) gammaf = 120.d0
+
+  end function gammaf
+
+!
+!=====================================================================
+!
+
+  subroutine jacg (xjac,np,alpha,beta)
+
+!=======================================================================
+!
+! computes np Gauss points, which are the zeros of the
+! Jacobi polynomial with parameters alpha and beta
+!
+!                  .alpha = beta =  0.0  ->  Legendre points
+!                  .alpha = beta = -0.5  ->  Chebyshev points
+!
+!=======================================================================
+
+  implicit none
+
+  integer np
+  double precision alpha,beta
+  double precision xjac(np)
+
+  integer k,j,i,jmin,jm,n
+  double precision xlast,dth,x,x1,x2,recsum,delx,xmin,swap
+  double precision p,pd,pm1,pdm1,pm2,pdm2
+
+  integer, parameter :: K_MAX_ITER = 10
+  double precision, parameter :: zero = 0.d0, eps = 1.0d-12
+
+  pm1 = zero
+  pm2 = zero
+  pdm1 = zero
+  pdm2 = zero
+
+  xlast = 0.d0
+  n   = np-1
+  dth = 4.d0*datan(1.d0)/(2.d0*dble(n)+2.d0)
+  p = 0.d0
+  pd = 0.d0
+  jmin = 0
+  do j=1,np
+   if(j == 1) then
+      x = dcos((2.d0*(dble(j)-1.d0)+1.d0)*dth)
+   else
+      x1 = dcos((2.d0*(dble(j)-1.d0)+1.d0)*dth)
+      x2 = xlast
+      x  = (x1+x2)/2.d0
+   endif
+   do k=1,K_MAX_ITER
+      call jacobf (p,pd,pm1,pdm1,pm2,pdm2,np,alpha,beta,x)
+      recsum = 0.d0
+      jm = j-1
+      do i=1,jm
+         recsum = recsum+1.d0/(x-xjac(np-i+1))
+      enddo
+      delx = -p/(pd-recsum*p)
+      x    = x+delx
+      if(abs(delx) < eps) goto 31
+   enddo
+ 31      continue
+   xjac(np-j+1) = x
+   xlast        = x
+  enddo
+  do i=1,np
+   xmin = 2.d0
+   do j=i,np
+      if(xjac(j) < xmin) then
+         xmin = xjac(j)
+         jmin = j
+      endif
+   enddo
+   if(jmin /= i) then
+      swap = xjac(i)
+      xjac(i) = xjac(jmin)
+      xjac(jmin) = swap
+   endif
+  enddo
+
+  end subroutine jacg
+
+!
+!=====================================================================
+!
+
+  subroutine jacobf (poly,pder,polym1,pderm1,polym2,pderm2,n,alp,bet,x)
+
+!=======================================================================
+!
+! Computes the Jacobi polynomial of degree n and its derivative at x
+!
+!=======================================================================
+
+  implicit none
+
+  double precision poly,pder,polym1,pderm1,polym2,pderm2,alp,bet,x
+  integer n
+
+  double precision apb,polyl,pderl,dk,a1,a2,b3,a3,a4,polyn,pdern,psave,pdsave
+  integer k
+
+  apb  = alp+bet
+  poly = 1.d0
+  pder = 0.d0
+  psave = 0.d0
+  pdsave = 0.d0
+
+  if (n == 0) return
+
+  polyl = poly
+  pderl = pder
+  poly  = (alp-bet+(apb+2.d0)*x)/2.d0
+  pder  = (apb+2.d0)/2.d0
+  if (n == 1) return
+
+  do k=2,n
+    dk = dble(k)
+    a1 = 2.d0*dk*(dk+apb)*(2.d0*dk+apb-2.d0)
+    a2 = (2.d0*dk+apb-1.d0)*(alp**2-bet**2)
+    b3 = (2.d0*dk+apb-2.d0)
+    a3 = b3*(b3+1.d0)*(b3+2.d0)
+    a4 = 2.d0*(dk+alp-1.d0)*(dk+bet-1.d0)*(2.d0*dk+apb)
+    polyn  = ((a2+a3*x)*poly-a4*polyl)/a1
+    pdern  = ((a2+a3*x)*pder-a4*pderl+a3*poly)/a1
+    psave  = polyl
+    pdsave = pderl
+    polyl  = poly
+    poly   = polyn
+    pderl  = pder
+    pder   = pdern
+  enddo
+
+  polym1 = polyl
+  pderm1 = pderl
+  polym2 = psave
+  pderm2 = pdsave
+
+  end subroutine jacobf
+
+!
+!------------------------------------------------------------------------
+!
+
+  double precision FUNCTION PNDLEG (Z,N)
+
+!------------------------------------------------------------------------
+!
+!     Compute the derivative of the Nth order Legendre polynomial at Z.
+!     Based on the recursion formula for the Legendre polynomials.
+!
+!------------------------------------------------------------------------
+  implicit none
+
+  double precision z
+  integer n
+
+  double precision P1,P2,P1D,P2D,P3D,FK,P3
+  integer k
+
+  P1   = 1.d0
+  P2   = Z
+  P1D  = 0.d0
+  P2D  = 1.d0
+  P3D  = 1.d0
+
+  do K = 1, N-1
+    FK  = dble(K)
+    P3  = ((2.d0*FK+1.d0)*Z*P2 - FK*P1)/(FK+1.d0)
+    P3D = ((2.d0*FK+1.d0)*P2 + (2.d0*FK+1.d0)*Z*P2D - FK*P1D) / (FK+1.d0)
+    P1  = P2
+    P2  = P3
+    P1D = P2D
+    P2D = P3D
+  enddo
+
+  PNDLEG = P3D
+
+  end function pndleg
+
+!
+!------------------------------------------------------------------------
+!
+
+  double precision FUNCTION PNLEG (Z,N)
+
+!------------------------------------------------------------------------
+!
+!     Compute the value of the Nth order Legendre polynomial at Z.
+!     Based on the recursion formula for the Legendre polynomials.
+!
+!------------------------------------------------------------------------
+  implicit none
+
+  double precision z
+  integer n
+
+  double precision P1,P2,P3,FK
+  integer k
+
+  P1   = 1.d0
+  P2   = Z
+  P3   = P2
+
+  do K = 1, N-1
+    FK  = dble(K)
+    P3  = ((2.d0*FK+1.d0)*Z*P2 - FK*P1)/(FK+1.d0)
+    P1  = P2
+    P2  = P3
+  enddo
+
+  PNLEG = P3
+
+  end function pnleg
+
+!
+!------------------------------------------------------------------------
+!
+
+  double precision function pnormj (n,alpha,beta)
+
+  implicit none
+
+  double precision alpha,beta
+  integer n
+
+  double precision one,two,dn,const,prod,dindx,frac
+  double precision, external :: gammaf
+  integer i
+
+  one   = 1.d0
+  two   = 2.d0
+  dn    = dble(n)
+  const = alpha+beta+one
+
+  if (n <= 1) then
+    prod   = gammaf(dn+alpha)*gammaf(dn+beta)
+    prod   = prod/(gammaf(dn)*gammaf(dn+alpha+beta))
+    pnormj = prod * two**const/(two*dn+const)
+    return
+  endif
+
+  prod  = gammaf(alpha+one)*gammaf(beta+one)
+  prod  = prod/(two*(one+const)*gammaf(const+one))
+  prod  = prod*(one+alpha)*(two+alpha)
+  prod  = prod*(one+beta)*(two+beta)
+
+  do i=3,n
+    dindx = dble(i)
+    frac  = (dindx+alpha)*(dindx+beta)/(dindx*(dindx+alpha+beta))
+    prod  = prod*frac
+  enddo
+
+  pnormj = prod * two**const/(two*dn+const)
+
+  end function pnormj
+
+!
+!------------------------------------------------------------------------
+!
+
+  subroutine zwgjd(z,w,np,alpha,beta)
+
+!=======================================================================
+!
+!     Z w g j d : Generate np Gauss-Jacobi points and weights
+!                 associated with Jacobi polynomial of degree n = np-1
+!
+!     Note : Coefficients alpha and beta must be greater than -1.
+!     ----
+!=======================================================================
+
+  implicit none
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0
+
+  integer np
+  double precision z(np),w(np)
+  double precision alpha,beta
+
+  integer n,np1,np2,i
+  double precision p,pd,pm1,pdm1,pm2,pdm2
+  double precision apb,dnp1,dnp2,fac1,fac2,fac3,fnorm,rcoef
+  double precision, external :: gammaf,pnormj
+
+  pd = zero
+  pm1 = zero
+  pm2 = zero
+  pdm1 = zero
+  pdm2 = zero
+
+  n    = np-1
+  apb  = alpha+beta
+  p    = zero
+  pdm1 = zero
+
+  if (np <= 0) stop 'minimum number of Gauss points is 1'
+
+  if ((alpha <= -one) .or. (beta <= -one)) stop 'alpha and beta must be greater than -1'
+
+  if (np == 1) then
+   z(1) = (beta-alpha)/(apb+two)
+   w(1) = gammaf(alpha+one)*gammaf(beta+one)/gammaf(apb+two) * two**(apb+one)
+   return
+  endif
+
+  call jacg(z,np,alpha,beta)
+
+  np1   = n+1
+  np2   = n+2
+  dnp1  = dble(np1)
+  dnp2  = dble(np2)
+  fac1  = dnp1+alpha+beta+one
+  fac2  = fac1+dnp1
+  fac3  = fac2+one
+  fnorm = pnormj(np1,alpha,beta)
+  rcoef = (fnorm*fac2*fac3)/(two*fac1*dnp2)
+  do i=1,np
+    call jacobf(p,pd,pm1,pdm1,pm2,pdm2,np2,alpha,beta,z(i))
+    w(i) = -rcoef/(p*pdm1)
+  enddo
+
+  end subroutine zwgjd
+
+!
+!------------------------------------------------------------------------
+!
+
+  subroutine zwgljd(z,w,np,alpha,beta)
+
+!=======================================================================
+!
+!     Z w g l j d : Generate np Gauss-Lobatto-Jacobi points and the
+!     -----------   weights associated with Jacobi polynomials of degree
+!                   n = np-1.
+!
+!     Note : alpha and beta coefficients must be greater than -1.
+!            Legendre polynomials are special case of Jacobi polynomials
+!            just by setting alpha and beta to 0.
+!
+!=======================================================================
+
+  implicit none
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0
+
+  integer np
+  double precision alpha,beta
+  double precision z(np), w(np)
+
+  integer n,nm1,i
+  double precision p,pd,pm1,pdm1,pm2,pdm2
+  double precision alpg,betg
+  double precision, external :: endw1,endw2
+
+  p = zero
+  pm1 = zero
+  pm2 = zero
+  pdm1 = zero
+  pdm2 = zero
+
+  n   = np-1
+  nm1 = n-1
+  pd  = zero
+
+  if (np <= 1) stop 'minimum number of Gauss-Lobatto points is 2'
+
+! with spectral elements, use at least 3 points
+  if (np <= 2) stop 'minimum number of Gauss-Lobatto points for the SEM is 3'
+
+  if ((alpha <= -one) .or. (beta <= -one)) stop 'alpha and beta must be greater than -1'
+
+  if (nm1 > 0) then
+    alpg  = alpha+one
+    betg  = beta+one
+    call zwgjd(z(2),w(2),nm1,alpg,betg)
+  endif
+
+  z(1)  = - one
+  z(np) =  one
+
+  do i=2,np-1
+   w(i) = w(i)/(one-z(i)**2)
+  enddo
+
+  call jacobf(p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(1))
+  w(1)  = endw1(n,alpha,beta)/(two*pd)
+  call jacobf(p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(np))
+  w(np) = endw2(n,alpha,beta)/(two*pd)
+
+  end subroutine zwgljd
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/lagrange_poly.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/lagrange_poly.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/lagrange_poly.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,83 @@
+  subroutine lagrange_poly(xi,NGLL,xigll,h,hprime)
+
+! subroutine to compute the Lagrange interpolants based upon the GLL points
+! and their first derivatives at any point xi in [-1,1]
+
+  implicit none
+
+  integer NGLL
+  double precision xi,xigll(NGLL),h(NGLL),hprime(NGLL)
+
+  integer dgr,i,j
+  double precision prod1,prod2
+
+  do dgr=1,NGLL
+
+  prod1 = 1.0d0
+  prod2 = 1.0d0
+  do i=1,NGLL
+    if(i /= dgr) then
+      prod1 = prod1*(xi-xigll(i))
+      prod2 = prod2*(xigll(dgr)-xigll(i))
+    endif
+  enddo
+  h(dgr)=prod1/prod2
+
+  hprime(dgr)=0.0d0
+  do i=1,NGLL
+    if(i /= dgr) then
+      prod1=1.0d0
+      do j=1,NGLL
+        if(j /= dgr .and. j /= i) prod1 = prod1*(xi-xigll(j))
+      enddo
+      hprime(dgr) = hprime(dgr)+prod1
+    endif
+  enddo
+  hprime(dgr) = hprime(dgr)/prod2
+
+  enddo
+
+  end subroutine lagrange_poly
+
+!
+!=====================================================================
+!
+
+! subroutine to compute the derivative of the Lagrange interpolants
+! at the GLL points at any given GLL point
+
+  double precision function lagrange_deriv_GLL(I,j,ZGLL,NZ)
+
+!------------------------------------------------------------------------
+!
+!     Compute the value of the derivative of the I-th
+!     Lagrange interpolant through the
+!     NZ Gauss-Lobatto Legendre points ZGLL at point ZGLL(j)
+!
+!------------------------------------------------------------------------
+
+  implicit none
+
+  integer i,j,nz
+  double precision zgll(0:nz-1)
+
+  integer degpoly
+
+  double precision, external :: pnleg,pndleg
+
+  degpoly = nz - 1
+  if (i == 0 .and. j == 0) then
+    lagrange_deriv_GLL = - dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+  else if (i == degpoly .and. j == degpoly) then
+    lagrange_deriv_GLL = dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+  else if (i == j) then
+    lagrange_deriv_GLL = 0.d0
+  else
+    lagrange_deriv_GLL = pnleg(zgll(j),degpoly) / &
+      (pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))) &
+      + (1.d0-zgll(j)*zgll(j))*pndleg(zgll(j),degpoly) / (dble(degpoly)* &
+      (dble(degpoly)+1.d0)*pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))*(zgll(j)-zgll(i)))
+  endif
+
+  end function lagrange_deriv_GLL
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/numerical_recipes.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/numerical_recipes.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/numerical_recipes.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,234 @@
+!=====================================================================
+!
+!  Routines from "Numerical Recipes: the Art of Scientific Computing"
+!  W. H. Press et al., Cambridge University Press
+!
+!=====================================================================
+
+! double precision routines
+
+  double precision function erf(x)
+  double precision x
+
+! this routine uses routine gammp
+  double precision gammp
+
+  if(x<0.)then
+    erf=-gammp(0.5d0,x**2)
+  else
+    erf=gammp(0.5d0,x**2)
+  endif
+
+  end function erf
+
+! ---------------------------------
+
+  double precision function gammp(a,x)
+  double precision a,x
+
+! this routine uses routines gcf and gser
+  double precision gammcf,gamser,gln
+
+  if(x<0.d0 .or. a <= 0.d0) stop 'bad arguments in gammp'
+
+  if(x<a+1.d0)then
+    call gser(gamser,a,x,gln)
+    gammp=gamser
+  else
+    call gcf(gammcf,a,x,gln)
+    gammp=1.d0-gammcf
+  endif
+
+  end function gammp
+
+! ---------------------------------
+
+  subroutine gcf(gammcf,a,x,gln)
+
+  double precision a,gammcf,gln,x
+
+  double precision, parameter :: EPS=3.d-7,FPMIN=1.d-30
+  integer, parameter :: ITMAX=100
+
+! this routine uses routine gammln
+
+  integer i
+  double precision an,b,c,d,del,h
+
+  double precision, external :: gammln
+
+  gln=gammln(a)
+  b=x+1.d0-a
+  c=1.d0/FPMIN
+  d=1.d0/b
+  h=d
+  do i=1,ITMAX
+    an=-i*(i-a)
+    b=b+2.d0
+    d=an*d+b
+    if(dabs(d)<FPMIN)d=FPMIN
+    c=b+an/c
+    if(dabs(c)<FPMIN)c=FPMIN
+    d=1.d0/d
+    del=d*c
+    h=h*del
+    if(dabs(del-1.d0)<EPS) then
+      gammcf=exp(-x+a*log(x)-gln)*h
+      return
+    endif
+  enddo
+
+  stop 'a too large, ITMAX too small in gcf'
+
+  end subroutine gcf
+
+! ---------------------------------
+
+  subroutine gser(gamser,a,x,gln)
+
+  double precision a,gamser,gln,x
+
+  integer, parameter :: ITMAX=100
+  double precision, parameter :: EPS=3.d-7
+
+! this routine uses routine gammln
+
+  integer n
+  double precision ap,del,sumval
+
+  double precision, external :: gammln
+
+  gln=gammln(a)
+
+  if(x <= 0.d0)then
+    if(x<0.d0) stop 'x < 0 in gser'
+    gamser=0.d0
+    return
+  endif
+
+  ap=a
+  sumval=1.d0/a
+  del=sumval
+
+  do n=1,ITMAX
+    ap=ap+1.d0
+    del=del*x/ap
+    sumval=sumval+del
+    if(dabs(del)<dabs(sumval)*EPS) then
+      gamser=sumval*exp(-x+a*log(x)-gln)
+      return
+    endif
+  enddo
+
+  stop 'a too large, ITMAX too small in gser'
+
+  end subroutine gser
+
+! ---------------------------------
+
+  double precision function gammln(xx)
+
+  double precision xx
+
+  integer j
+  double precision ser,stp,tmp,x,y,cof(6)
+
+  cof(1) = 76.18009172947146d0
+  cof(2) = -86.50532032941677d0
+  cof(3) = 24.01409824083091d0
+  cof(4) = -1.231739572450155d0
+  cof(5) = 0.1208650973866179d-2
+  cof(6) = -0.5395239384953d-5
+
+  stp = 2.5066282746310005d0
+
+  x=xx
+  y=x
+  tmp=x+5.5d0
+  tmp=(x+0.5d0)*log(tmp)-tmp
+  ser=1.000000000190015d0
+  do j=1,6
+    y=y+1.d0
+    ser=ser+cof(j)/y
+  enddo
+  gammln=tmp+log(stp*ser/x)
+
+  end function gammln
+
+! ---------------------------------
+
+! compute spline coefficients (Numerical Recipes)
+! modified to use dynamic allocation
+
+  subroutine spline(x,y,n,yp1,ypn,y2)
+
+  implicit none
+
+  integer n
+  double precision x(n),y(n),y2(n)
+  double precision yp1,ypn
+  double precision, dimension(:), allocatable :: u
+
+  integer i,k
+  double precision sig,p,qn,un
+
+  allocate(u(n))
+
+  y2(1)=-0.5d0
+  u(1)=(3.d0/(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
+
+  do i=2,n-1
+    sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
+    p=sig*y2(i-1)+2.d0
+    y2(i)=(sig-1.d0)/p
+    u(i)=(6.d0*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1)) &
+                /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p
+  enddo
+
+  qn=0.5d0
+  un=(3.d0/(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
+  y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.d0)
+
+  do k=n-1,1,-1
+    y2(k)=y2(k)*y2(k+1)+u(k)
+  enddo
+
+  deallocate(u)
+
+  end subroutine spline
+
+! --------------
+
+! evaluate spline (Numerical Recipes)
+
+  subroutine splint(xa,ya,y2a,n,x,y)
+
+  implicit none
+
+  integer n
+  double precision XA(N),YA(N),Y2A(N)
+  double precision x,y
+
+  integer k,klo,khi
+  double precision h,a,b
+
+  KLO=1
+  KHI=N
+ 1 IF (KHI-KLO > 1) THEN
+    K=(KHI+KLO)/2
+    IF(XA(K) > X)THEN
+      KHI=K
+    ELSE
+      KLO=K
+    ENDIF
+  goto 1
+  ENDIF
+  H=XA(KHI)-XA(KLO)
+  IF (H == 0.d0) stop 'Bad input in spline evaluation'
+  A=(XA(KHI)-X)/H
+  B=(X-XA(KLO))/H
+
+  Y=A*YA(KLO)+B*YA(KHI)+((A**3-A)*Y2A(KLO) + (B**3-B)*Y2A(KHI))*(H**2)/6.d0
+
+  end subroutine splint
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,2526 @@
+program wave2d
+
+  use wave2d_variables  ! global variables
+  use wave2d_solver     ! 
+  use wave2d_sub        ! source time function, write seismograms, etc
+  use wave2d_sub2       ! UTM conversion
+  use wave2d_sub3       ! measurements, including multitaper
+
+  implicit none
+
+! wavefields and seismograms
+  double precision, dimension(:,:,:), allocatable :: samp, samp_dat, data, syn, adj_syn
+
+! source time function
+  double precision, dimension(NSTEP) :: stf_dat, stf
+
+! socal coast and shelf data
+  integer :: UTM_PROJECTION_ZONE, FINITE_SOURCE
+  integer :: nshelf,ncoast
+  double precision :: d,dmin
+  double precision, dimension(:), allocatable :: shelf_lat,shelf_lon,shelf_z,shelf_x
+  double precision, dimension(:), allocatable :: coast_lat,coast_lon,coast_z,coast_x
+  character(len=200) :: shelf_file,coast_file
+
+  integer :: itemp,itemp1,itemp2,itemp3
+
+! index vectors of the target points within the designated region (NOT gridpoint indices)
+!  integer, dimension(:), allocatable :: ifilter_src
+
+!------------------------
+! source and receiver variables (and fake receivers for spectral plots)
+  integer :: istf, nsrc, nrec, nrecf, nevent, nevent_dat, nevent_run
+  !integer, dimension(:), allocatable :: sglob, sglob_dat
+  !integer, dimension(:), allocatable :: sglob_temp, rglob_temp, fglob_temp
+
+  integer, dimension(MAX_EVENT):: ifilter_eve_dat
+  double precision, dimension(MAX_EVENT)      :: x_eve_lon0_dat, z_eve_lat0_dat, x_eve0_dat, z_eve0_dat
+  double precision, dimension(:), allocatable :: x_eve_lon_dat,  z_eve_lat_dat,  x_eve_dat,  z_eve_dat, otime_dat
+  double precision, dimension(:), allocatable :: xi_eve_dat, gamma_eve_dat
+  integer, dimension(:), allocatable          :: eglob_dat, ispec_eve_dat
+
+  integer, dimension(MAX_EVENT):: ifilter_eve
+  double precision, dimension(MAX_EVENT)      :: x_eve_lon0, z_eve_lat0, x_eve0, z_eve0
+  double precision, dimension(:), allocatable :: x_eve_lon,  z_eve_lat,  x_eve,  z_eve, otime
+  double precision, dimension(:), allocatable :: xi_eve, gamma_eve
+  integer, dimension(:), allocatable          :: eglob, ispec_eve
+
+  integer, dimension(MAX_SR):: ifilter_rec, rglob0
+  double precision, dimension(MAX_SR)         :: x_rec_lon0, z_rec_lat0, x_rec0, z_rec0
+  double precision,dimension(:), allocatable  :: x_rec_lon,  z_rec_lat,  x_rec,  z_rec
+  double precision, dimension(:), allocatable :: xi_rec, gamma_rec
+  integer, dimension(:), allocatable          :: rglob, ispec_rec
+
+  integer, dimension(MAX_SR_FAKE):: ifilter_recf
+  double precision, dimension(MAX_SR_FAKE)    :: x_recf0, z_recf0
+  double precision,dimension(:), allocatable  :: x_recf, z_recf
+  integer, dimension(:), allocatable          :: fglob
+
+  integer, dimension(MAX_SR):: ifilter_src
+  double precision, dimension(MAX_SR)         :: x_src_lon0, z_src_lat0, x_src0, z_src0
+  double precision,dimension(:), allocatable  :: x_src_lon,  z_src_lat,  x_src,  z_src
+  double precision, dimension(:), allocatable :: xi_src, gamma_src
+  integer, dimension(:), allocatable          :: sglob, ispec_src
+
+  integer, dimension(MAX_SR):: ifilter_src_dat
+  double precision, dimension(MAX_SR)         :: x_src_lon0_dat, z_src_lat0_dat, x_src0_dat, z_src0_dat
+  double precision,dimension(:), allocatable  :: x_src_lon_dat,  z_src_lat_dat,  x_src_dat,  z_src_dat
+  double precision, dimension(:), allocatable :: xi_src_dat, gamma_src_dat
+  integer, dimension(:), allocatable          :: sglob_dat, ispec_src_dat
+!------------------------
+
+! allocate Lagrange interpolators for sources and receivers
+  double precision, dimension(:,:), allocatable :: hxir_store, hxie_store, hxied_store, hxis_store, hxisd_store
+  double precision, dimension(:,:), allocatable :: hgammar_store, hgammae_store, hgammaed_store, hgammas_store, hgammasd_store
+  double precision, dimension(:), allocatable :: hxir,hpxir,hgammar,hpgammar
+  double precision, dimension(:), allocatable :: hxie,hpxie,hgammae,hpgammae
+  double precision, dimension(:), allocatable :: hxis,hpxis,hgammas,hpgammas
+  double precision, dimension(:), allocatable :: hxied,hpxied,hgammaed,hpgammaed
+  double precision, dimension(:), allocatable :: hxisd,hpxisd,hgammasd,hpgammasd
+
+  !double precision, dimension(:), allocatable :: x_src_lon, z_src_lat, x_src, z_src
+
+  double precision :: x_src_lon_i, z_src_lat_i, x_src_i, z_src_i, x_src_f, z_src_f
+  double precision :: flen,finc,src_az,xd
+  double precision :: s_radius,xcen,zcen,xcen_lon,zcen_lat
+  double precision :: dmin_trsh_s,dmin_trsh_r,dmin_trsh_f
+  character(len=200) :: quake_file
+
+! source function
+  double precision :: f0(NCOMP), ti(NSTEP)
+
+! vewlocity structure variables
+  integer :: Nfac, IMODEL
+  double precision :: w_scale, afac
+  double precision, dimension(NGLOB) :: c_glob_dat, c_glob_syn
+
+! source perturbations (01-Feb-2006)
+! presently only set up for 2D surface waves
+  logical :: ISOURCE_LOG
+  integer :: PERT_SOURCE, PERT_STRUCT, INV_SOURCE, INV_STRUCT
+  double precision :: src_pert_time, origin_time, origin_time_dat, ptmin, ptmax, ptime
+  double precision :: src_pert_dist, rand1, amin, amax, pangle, rmin, rmax, prad
+  double precision :: dx_src, dz_src, dt_src
+  double precision :: m_scale(3)
+  double precision, dimension(:,:,:,:), allocatable :: three_source_model
+  double precision, dimension(:), allocatable :: source_gradient, m_scale_src, gradient
+
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: gradient_local
+
+! socal earthquake location
+  double precision, dimension(MAX_EVENT) :: socal_events_lon, socal_events_lat, socal_events_mag
+  integer, dimension(MAX_EVENT) :: socal_events_lab
+  integer nmeas, ievent_min, ievent_max, ifirst
+
+!----------------------
+! misfit and conjugate gradient algorithm
+
+! misfit
+  double precision, dimension(MAX_EVENT) :: chi_etot
+
+! smoothing
+  integer :: igaus
+  double precision :: dist2, dtrsh2, xtar, ztar, gamma  ! sigma
+  double precision, dimension(NGLOB) :: k_rough_global, k_smooth_global
+  double precision, dimension(NGLOB) :: k_gaus_global, k_gaus_global_ex, k_gaus_int_global
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: k_temp
+  !double precision, dimension(NLOCAL) :: gk_local, m0_local, mt_local, mt2_local, da_local
+  !integer, dimension(NLOCAL) :: ibool2
+  character(len=200) :: file_smooth
+
+! conjugate gradient optimization (using line-search)
+!  double precision, dimension(NGLOB) :: pk, gk, g0, p0, m0, m0_vel, gt, mt, mt_vel, m_vel
+  double precision, dimension(:), allocatable :: pk, gk, g0, p0, m0, gt, mt
+
+  double precision, dimension(:), allocatable :: m0_vec, mt_vec
+
+!  double precision, dimension(:), allocatable :: m_vel, m0_vel, mt_vel
+  double precision, dimension(:), allocatable :: m_src, m0_src, mt_src, m_src_dat, m_src_syn
+  double precision :: beta_val, lam_0_val, lam_t_val, chi_val, chi_t_val, chi_k_val
+  double precision :: Pa,Pb,Pc,Pd,qfac,xx1,xx2,yy1,yy2,g1,g2,xmin
+  integer :: itest, nmod, nmod_src, nmod_str
+
+!----------------------
+
+! kernels
+  double precision, dimension(:), allocatable :: tstart, tend
+  character(len=200) :: last_frame_name
+  double precision, dimension(:,:,:,:,:), allocatable :: absorb_field
+  double precision, dimension(:), allocatable :: rho_kernel, mu_kernel, kappa_kernel
+
+  !double precision :: t0, ft(NCOMP), pxpf(NCOMP), f1(NCOMP), f2(NCOMP), dxdf(NCOMP)
+  !double precision :: p_1, p_2, df, phi
+  !double precision :: source_time_function
+  !character(len=200) :: snap_name, last_frame_name
+  !double precision :: xold(NCOMP), fold, gold(NCOMP), pold(NCOMP), xnew(NCOMP), fnew, gnew(NCOMP), pnew(NCOMP)
+  !double precision :: lam, beta, eps, tstart, tend, stf
+
+  double precision :: xtemp,ztemp,dx,dz,xmesh,zmesh
+  double precision :: t_target, tcen
+  double precision :: junk1,junk2,junk3
+  double precision :: temp1,temp2,temp3,temp4,temp5
+
+! corners of the grid
+  double precision, dimension(4) :: corners_utm_x, corners_utm_z, corners_lon, corners_lat
+  double precision :: sq_south, sq_east, sq_north, sq_west, sq_fac, da_mean, sda_mean, m_scale_str, mfac
+
+  character(len=20)  :: data_tag,syn_tag,stf_tag,stfadj_tag
+  character(len=200) :: srcfile,recfile,socal_map
+  character(len=200) :: socal_dir, model_dir, script_dir, out_dir3, out_dir2, out_dir1, ev_dir
+  character(len=200) :: filename, filename1, filename2, file_dat_c, file_syn_c, file_src_rec, file_stf
+  character(len=200) :: command1
+
+  integer :: i, j, k, iq, itime, iglob, irec, isrc, ipick, ievent, icomp, irunz
+  integer :: isolver, irun0, irun, idat, iopt, ispec, istep, istep_switch, imod
+
+  !double precision :: meas_pert, rand1,  meas, ppert
+
+  !********* PROGRAM STARTS HERE *********************
+ 
+  call random_seed()        ! random number generator
+
+  out_dir3   = "OUTPUT/"
+  in_dir     = "INPUT/"
+  script_dir = "scripts/"
+
+  socal_dir = '/home/carltape/socal_modes/local_modes/'
+  model_dir = 'model_files/'
+
+  ! exclude sources or receivers that are this close to THE SOCAL COAST
+  dmin_trsh_s = 0.d+03                  ! sources
+  !dmin_trsh_r = STATION_GRID_BUFFER     ! receivers
+  dmin_trsh_r = 0.d+03
+  dmin_trsh_f = 0.d+03                  ! fake receivers
+
+  UTM_PROJECTION_ZONE = 11
+
+  ! idat=1 means we run simulations for both data and synthetics (two models)
+  idat = 0
+  if(IKER <= 4) idat = 1
+  if(ISRC_SPACE==1) FINITE_SOURCE = 0
+  if(ISRC_SPACE/=1) FINITE_SOURCE = 1
+
+!--------------------------------------
+! load socal coast and shelf points
+
+  ! read in data files
+  nshelf = 101
+  ncoast = 810
+  allocate(shelf_lat(nshelf),shelf_lon(nshelf),shelf_z(nshelf),shelf_x(nshelf))
+  allocate(coast_lat(ncoast),coast_lon(ncoast),coast_z(ncoast),coast_x(ncoast))
+  shelf_file = 'oms_shelf'
+  coast_file = 'oms_coast'
+  open(77,file=trim(in_dir)//trim(shelf_file),status='unknown')
+  read(77,*) (shelf_lat(i),shelf_lon(i),i=1,nshelf)
+  close(77)
+  open(66,file=trim(in_dir)//trim(coast_file),status='unknown')
+  read(66,*) (coast_lat(i),coast_lon(i),i=1,ncoast)
+  close(66)
+
+  ! convert lat-lon to mesh coordinates
+  call mesh_geo(nshelf,shelf_lon,shelf_lat,shelf_x,shelf_z,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+  call mesh_geo(ncoast,coast_lon,coast_lat,coast_x,coast_z,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+  !write(*,'(4f16.6)') (shelf_lon(i), shelf_lat(i), shelf_x(i)/1000., shelf_z(i)/1000., i=1,nshelf)
+  !write(*,'(4f16.6)') (coast_lon(i), coast_lat(i), coast_x(i)/1000., coast_z(i)/1000., i=1,ncoast)
+
+!--------------------------------------
+
+  ! events to use (5-5 or 1-25)
+  ievent_min = 1
+  ievent_max = 25
+  nevent_run = ievent_max - ievent_min + 1
+
+  ! perturbation and inversion parameters
+  PERT_SOURCE = 0
+  PERT_STRUCT = 1
+   INV_SOURCE = 0
+   INV_STRUCT = 1
+
+  ISOURCE_LOG = .false.        ! log file showing source loactions
+
+  ! MAX source perturbations for location (lat-lon) and origin time
+  src_pert_dist = 5000.0      ! source spatial perturbation (m)
+  src_pert_time = -1.0        ! source temporal perturbation (s)
+                              ! dt0 = dt0_dat - dt0_syn (<0 for delayed synthetics)
+  origin_time_dat = tshift    ! data are unperturbed
+
+  !src_pert_dist = 0.
+  !src_pert_time = 0.
+
+  ! reference directory for the run
+  irunz = 4300
+
+!============================================
+! LOOP 1: different tomographic runs
+  do iq = 1,1
+!============================================
+
+    ! KEY COMMANDS
+    IMODEL = 2            ! (0) het map, (1) homo map, (2) checkerboard, (3) read in
+    Nfac   = 1            ! scalelength of checker
+    gamma  = 15.0d+03     ! scalelength of smoothing Gaussian
+
+    !mfac = 1. - 0.1*(iq-1)
+
+  irun0 = irunz + 20*(iq-1)
+
+  ! name and create the reference output directory for the optimization run
+  write(out_dir2,'(a,i4.4,a)') trim(out_dir3)//'run_',irun0,'/'
+  command1 = 'mkdir ' // trim(out_dir2)
+  call system(command1)
+  !open(19,file='temp.csh',status='unknown')
+  !write(19,'(2a)') 'mkdir ',out_dir2
+  !close(19)
+  !call system('chmod 755 temp.csh ; temp.csh')
+
+!--------------------------------------
+
+  print *
+  print *, ' max time-step is ', NSTEP
+  print *, '            DT is ', sngl(DT)
+  print *, '      max time is ', sngl(NSTEP*DT), ' s,', sngl(NSTEP*DT/60), ' min'
+  print *
+
+  ! copy wave2d_constants.f90 into output directory
+  command1 = 'cp ' // 'src/wave2d_constants.f90 ' // trim(out_dir2)
+  call system(command1)
+
+  !call write_parameters(trim(out_dir2)//'parameters1.log')
+
+!--------------------------------------
+! mesher
+
+  ! set up model (gets Jacobian)
+  call mesher()
+
+  ! da vector and valence vector
+  da(:) = 0.
+  valence(:) = 0
+  do ispec = 1,NSPEC
+    do j = 1,NGLLZ
+      do i = 1,NGLLX 
+        iglob     = ibool(i,j,ispec)
+        !da_local(iglob) = wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+
+        da(iglob) = da(iglob) + wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+        valence(iglob) = valence(iglob) + 1
+      enddo
+    enddo
+  enddo
+  !da(:) = da_local(:)*valence(:)
+  da_mean = sum(da)/NGLOB
+  sda_mean = sqrt(da_mean)
+
+  ! global mesh
+  open(unit=15,file = trim(out_dir2)//'global_mesh.dat',status='unknown')
+  do iglob = 1,NGLOB
+    write(15,'(2i8,3e18.8)') iglob, valence(iglob), x(iglob), z(iglob), da(iglob)
+  enddo
+  close(15)
+
+  if(0==1) then
+
+    ! corner points for each element, and centerpoint (in km)
+    open(unit=15,file='elements.dat',status='unknown')
+    do ispec = 1,nspec
+      xtemp = (x1(ispec) + x2(ispec))/2.
+      ztemp = (z1(ispec) + z2(ispec))/2.
+      write(15,'(i8,6f14.6)') ispec,xtemp/1000.,ztemp/1000,x1(ispec)/1000.,x2(ispec)/1000.,z1(ispec)/1000.,z2(ispec)/1000.
+    enddo
+    close(15)
+
+    ! GLL points for one element (in km)
+    ispec = 292  ! pick an element
+    open(unit=15,file='gll_points.dat',status='unknown')
+    do j = 1,NGLLZ
+      do i = 1,NGLLX
+        iglob = ibool(i,j,ispec)
+        write(15,'(4i10,3e18.8)') ispec, i, j, valence(iglob), da(iglob)/1e6, x(iglob)/1000., z(iglob)/1000.
+      enddo
+    enddo
+    close(15)
+
+    stop 'testing'
+  endif
+
+  print *
+  write(*,'(a,3f20.10)') '  da(min,mean,max) : ', minval(da), da_mean, maxval(da)
+  write(*,*)             '        sum [ da ] : ', sum(da)
+  write(*,*)             '   LENGTH * HEIGHT : ', LENGTH * HEIGHT
+  print *
+  write(*,*)             '             gamma : ', gamma
+  write(*,*)             '              Nfac : ', Nfac
+  write(*,*)             '             irun0 : ', irun0
+  write(*,*)             '              IKER : ', IKER
+  print *
+  print *, ' GLL weights:'
+  do i=1,NGLLX
+     print *, wxgll(i)
+  enddo
+  do i=1,NGLLZ
+     print *, wzgll(i)
+  enddo
+
+!--------------------------------------
+! determine the UTM coordinates of your origin and corners
+
+  call utm_geo(LON_MIN,LAT_MIN,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+  corners_utm_x(1) = utm_xmin
+  corners_utm_z(1) = utm_zmin
+  corners_utm_x(2) = utm_xmin + LENGTH
+  corners_utm_z(2) = utm_zmin
+  corners_utm_x(3) = utm_xmin + LENGTH
+  corners_utm_z(3) = utm_zmin + HEIGHT
+  corners_utm_x(4) = utm_xmin
+  corners_utm_z(4) = utm_zmin + HEIGHT
+
+  print *
+  print *,'origin (LON_MIN, LAT_MIN):'
+  print *, LON_MIN, LAT_MIN
+  print *, '        lon             lat           utm_x            utm_z'
+  do i=1,4
+     call utm_geo(xtemp,ztemp,corners_utm_x(i),corners_utm_z(i),UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+     corners_lon(i) = xtemp
+     corners_lat(i) = ztemp
+     write(*,'(2f16.6,2e16.6)') corners_lon(i), corners_lat(i), corners_utm_x(i), corners_utm_z(i)
+  enddo
+
+  ! convert global gridpoint mesh coordinates to lat-lon
+  x_lon(:) = 0.
+  z_lat(:) = 0. 
+  call mesh_geo(NGLOB,x_lon,z_lat,x,z,UTM_PROJECTION_ZONE,IMESH2LONLAT)
+  !write(*,'(2f16.6)') (x_lon(iglob), z_lat(iglob), iglob=1,NGLOB)
+
+  ! compute min/max lat-lon
+  sq_east  = maxval(x_lon(:))
+  sq_west  = minval(x_lon(:))
+  sq_north = maxval(z_lat(:))
+  sq_south = minval(z_lat(:))
+
+  print *
+  print *, 'grid fits within the spherical square patch with these boundaries:'
+  print *, '  west  : ', sq_west
+  print *, '  east  : ', sq_east
+  print *, '  south : ', sq_south
+  print *, '  north : ', sq_north
+
+  ! determine the UTM coordinates of your origin
+  print *
+  print *, 'UTM check for origin of mesh:'
+  print *, LON_MIN,LAT_MIN
+  call utm_geo(LON_MIN,LAT_MIN,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+  print *, utm_xmin, utm_zmin
+  call utm_geo(xtemp,ztemp,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+  print *, xtemp,ztemp   ! should match LON_MIN,LAT_MIN
+  print *
+
+!--------------------------------------
+! phase velocity model
+
+  t_target = 2*hdur     ! target period for phase velocity map
+
+  if(IMODEL <= 1) then
+
+     ! write lat-lon gridpoints to file
+     filename = trim(socal_dir) // 'socal_input.dat'
+     print *, 'Output data file is ',trim(filename)
+     open(unit=15,file=filename,status='unknown')
+     write(15,*) t_target
+     write(15,*) IMODEL       ! formerly IHOMO
+     write(15,*) UTM_PROJECTION_ZONE
+     write(15,*) NGLOB
+     write(15,*) (x_lon(iglob),z_lat(iglob),iglob=1,NGLOB)
+     close(15)
+
+     ! run wave2d_socal.f90 to create output file
+     ! KEY NOTE: must run this each time you change the grid, hdur, or IMODEL
+     call system(trim(model_dir) // 'get_socal_map.csh')
+
+     ! read in phase velocity map
+     !write(infile,'(a,a,i4.4,a)') trim(socal_dir), 'socal_T', int(100*t_target),'.dat'
+     socal_map = 'socaltest.dat'
+     open(unit=16, file = trim(model_dir)//socal_map, status='unknown')
+     read(16,*) (junk1,junk2,c_glob(iglob),junk3,iglob=1,NGLOB)
+     close(16)
+
+     ! read in reference phase velocity (km/s)
+     filename = trim(model_dir) // 'socaltest2.dat'
+     open(unit=17,file=filename,status='unknown')
+     read(17,*) c0
+     close(17)
+     
+     ! convert km/s --> m/s
+     c_glob(:) = 1000.*c_glob(:)
+     c0 = c0*1000.
+
+     c_glob_syn(:) = c0       ! c-maps for synthetics
+
+  elseif(IMODEL==2) then   ! checkerboard
+
+     c0 = 3500.    ! reference phase velocity (m/s) (should be obtained based on hdur)
+     !Nfac = 3      ! scalelength of map = N * (wavelength of surface waves for hdur)
+     afac = 10.0   ! max PERCENT variation of synthetic model  (10.0)
+
+     ! spatial frequency corresponding to scalelength
+     ! factor of 2 is because the scalelength is a 1/2 cycle
+     w_scale = 2*pi/(Nfac*2*c0*t_target)
+
+     do iglob=1,NGLOB
+        c_glob(iglob) = c0 + c0*afac/100.*(sin(x(iglob)*w_scale) * sin(z(iglob)*w_scale))
+        !c_glob(iglob) = c0 + c0*afac/100.
+     enddo
+
+     c_glob_syn(:) = c0       ! c-maps for synthetics
+
+  elseif(IMODEL==3) then   ! read c-map for synthetics and data for a 'middle' iteration
+
+     ! read in phase velocity map for data
+     open(unit=16,file=trim(model_dir)//'socal_vel_dat.dat', status='unknown')
+     read(16,*) (junk1,junk2,c_glob(iglob),junk3,iglob=1,NGLOB)
+     close(16)
+
+!!$     ! read in phase velocity map for synthetics
+!!$     open(unit=16,file=trim(model_dir)//'socal_vel_syn.dat', status='unknown')
+!!$     read(16,*) (junk1,junk2,c_glob_syn(iglob),junk3,iglob=1,NGLOB)
+!!$     close(16)
+!!$
+!!$     ! read in c0
+!!$     open(unit=16,file=trim(model_dir)//'socal_vel_c0.dat', status='unknown')
+!!$     read(16,*) c0
+!!$     close(16)
+
+     ! compute c0 by finding the average of the phase velocity map
+     c0 = 0.     
+     do iglob = 1,NGLOB
+        c0 = c0 + c_glob(iglob) * da(iglob)
+     enddo
+     c0 = c0 / (LENGTH * HEIGHT)
+
+     c_glob_syn(:) = c0
+    
+  else
+     stop 'IMODEL must be 0,1,2,3'
+  endif
+
+  ! c-maps for data
+  c_glob_dat(:) = c_glob(:)
+
+  ! UNIFORM PERTURBATION (01-Feb-2006)
+  !afac = 5.
+  !c_glob_dat(:) = c_glob_syn(:) * (1. + afac/100.)
+
+  ! unperturbed structure
+  if(PERT_STRUCT == 0) c_glob_syn(:) = c_glob_dat(:)
+
+  ! write data phase velocity map to file
+  file_dat_c = 'socal_vel_dat.dat'
+  open(unit=18,file=trim(out_dir2)//file_dat_c,status='unknown')
+  do iglob = 1,NGLOB
+     write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_dat(iglob)), sngl(c_glob_dat(iglob)/c0 - 1.)
+  enddo
+  close(18)
+
+  ! write syn phase velocity map to file
+  ! (reference model is 0% perturbation)
+  file_syn_c = 'socal_vel_syn.dat'
+  open(unit=18,file=trim(out_dir2)//file_syn_c,status='unknown')
+  do iglob = 1,NGLOB
+     write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_syn(iglob)), sngl(c_glob_syn(iglob)/c0 - 1.)
+  enddo
+  close(18)
+
+  ! write in c0 (and period) to file
+  open(unit=16,file=trim(out_dir2)//'socal_vel_c0.dat', status='unknown')
+  write(16,*) c0
+  write(16,*) 2*hdur
+  close(16)
+
+  cmin = minval(c_glob)
+  cmax = maxval(c_glob)
+
+!!$  ! plot phase velocity map for synthetics (and data)
+!!$  iopt = 1 + idat
+!!$  filename1 = 'get_model.csh'
+!!$  filename2 = trim(script_dir)//'plot_model.pl'
+!!$  open(19,file=filename1,status='unknown')
+!!$  write(19,'(4a,i5,3a,2f12.6,2a)') trim(filename2),' ', trim(out_dir2),' ', &
+!!$     iopt, ' ', trim(file_syn_c), ' ', sngl(c0), sngl(t_target),' ',trim(file_dat_c)
+!!$  close(19)
+!!$  call system('chmod 755 get_model.csh ; get_model.csh')
+
+  ! assign model parameters to gridpoints
+  ihomo = 0
+  call set_model_property()
+
+  print *, 'Velocities in km/s :'
+  print *, '  S     :', sngl(sqrt(RIGIDITY/DENSITY)/1000.)
+  print *, '  cmin  :', sngl(cmin/1000.)
+  print *, '  c0    :', sngl(c0/1000.)
+  print *, '  cmax  :', sngl(cmax/1000.)
+  print *
+  print *, ' actual  rigidity (Pa-s)       : ', sngl(RIGIDITY)
+  print *, ' desired rigidity (Pa-s), cmin : ', sngl(DENSITY * cmin**2)
+  print *, ' desired rigidity (Pa-s), c0   : ', sngl(DENSITY * c0**2)
+  print *, ' desired rigidity (Pa-s), cmax : ', sngl(DENSITY * cmax**2)
+
+!--------------------------------------
+! SoCal events
+
+  ! read in target events (socal_quakes.m)
+  ! socal events M > 4 (1990-2005), selected to get semi-uniform coverage
+  !quake_file = 'socal_quakes_v02.dat'
+  quake_file = 'socal_quakes_N025.dat'
+  open(55,file=trim(in_dir)//trim(quake_file),status='unknown')
+  read(55,*) nevent
+  if(nevent > MAX_EVENT) stop 'nevent > MAX_EVENT (so increase MAX_EVENT)'
+  print *, nevent, ' target events (for synthetics)'
+  read(55,'(i14,3f14.7)') (socal_events_lab(i),socal_events_lon(i),socal_events_lat(i),socal_events_mag(i),i=1,nevent)
+  close(55)
+
+  print *
+  print *, 'SoCal events (label, lon, lat, mag):'
+  do i=1,nevent
+     write(*,'(i14,3f14.7)') socal_events_lab(i), socal_events_lon(i), socal_events_lat(i), socal_events_mag(i)
+  enddo
+
+!--------------------------------------
+! Prior to Feb 2006, we simply assigned the source location to the nearst gridpoint.
+! But now we compute the locations such that ANY location is allowed.
+!--------------------------------------
+! events for data (eglob_dat)
+
+  ! fill a portion of the [1:MAX_EVENT] vector with the SoCal events
+  x_eve_lon0_dat(1:nevent) = socal_events_lon(:)
+  z_eve_lat0_dat(1:nevent) = socal_events_lat(:)
+
+  ! all vectors should be this length
+  nevent = MAX_EVENT
+
+  ! convert from lat-lon to mesh coordinates (in meters) -- update nevent
+  call mesh_geo(nevent,x_eve_lon0_dat,z_eve_lat0_dat,x_eve0_dat,z_eve0_dat,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+
+  ! filter target points (utm-mesh) (update nevent)
+  print *
+  print *, 'events for data:'
+  call station_filter(nevent, x_eve0_dat, z_eve0_dat, ifilter_eve_dat, SOURCE_GRID_BUFFER)
+  !call station_filter(nevent, x_eve, z_eve, dmin_trsh_s, ncoast, coast_x, coast_z)
+
+  if(nevent < 1) stop 'Must have at least one event'
+
+  ! allocate variables
+  allocate(x_eve_dat(nevent),z_eve_dat(nevent),x_eve_lon_dat(nevent),z_eve_lat_dat(nevent))
+  allocate(eglob_dat(nevent))
+  allocate(ispec_eve_dat(nevent),xi_eve_dat(nevent),gamma_eve_dat(nevent))
+  allocate(otime_dat(nevent))
+
+  ! perturbation from origin time for data
+  otime_dat(:) = origin_time_dat
+
+  ! assign allowable target events to (x_eve_dat, z_eve_dat)
+  do i=1,nevent
+    x_eve_dat(i) = x_eve0_dat(ifilter_eve_dat(i))
+    z_eve_dat(i) = z_eve0_dat(ifilter_eve_dat(i))
+  enddo
+
+  !do i=1,nevent
+  !   write(*,'(2e24.16)') x_eve_dat(i), z_eve_dat(i)
+  !enddo
+
+  ! determine the (eta, xi) corresponding to the target points
+  ! this UPDATES x_eve, z_eve; eglob_dat is the index of the closest gridpoint
+  call locate_targets(nevent, x_eve_dat, z_eve_dat, eglob_dat, ispec_eve_dat, xi_eve_dat, gamma_eve_dat)
+
+  !do i=1,nevent
+  !   write(*,'(2e24.16)') x_eve_dat(i), z_eve_dat(i)
+  !enddo
+
+  print *
+  print *, 'ievent, x, z, iglob, ispec, xi, gamma'
+  do i=1,nevent
+     write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_eve_dat(i), z_eve_dat(i), &
+        eglob_dat(i), ispec_eve_dat(i), xi_eve_dat(i), gamma_eve_dat(i)
+  enddo
+
+  ! convert from mesh to lat-lon
+  call mesh_geo(nevent, x_eve_lon_dat, z_eve_lat_dat, x_eve_dat, z_eve_dat, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+  ! display target events and final events -- and the distance between (in meters)
+  ! The distance error is due to the UTM conversion, but the lat-lon points are only
+  ! used for plotting purposes, so this is fine.
+  print *
+  print *, 'events [x_eve_lon0_dat, z_eve_lat0_dat, x_eve_lon_dat, x_eve_lat_dat, dist (m)]:'
+  do i=1,nevent
+     temp1 = x_eve_lon0_dat(ifilter_eve_dat(i))
+     temp2 = z_eve_lat0_dat(ifilter_eve_dat(i))
+     temp3 = x_eve_lon_dat(i)
+     temp4 = z_eve_lat_dat(i)
+     temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+     write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.*1000.
+  enddo
+
+  ! events : convert target points from utm to gridpoint index to lat-lon
+  !call set_glob(nsrc, x_eve, z_eve, eglob)  ! get nearest gridpoint (eglob) to (x_eve, z_eve)
+  !nevent = ns
+  !x_eve_lon(:) = 0.  ; z_eve_lat(:) = 0.  ! re-initialize
+  !do i=1,nevent
+  !   xtemp = x(eglob(i)) + utm_xmin
+  !   ztemp = z(eglob(i)) + utm_zmin
+  !   call utm_geo(x_eve_lon(i),z_eve_lat(i),xtemp,ztemp,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+  !enddo
+  !!call mesh_geo(nevent, x_eve_lon, z_eve_lat, x_eve, z_eve, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+  ! write events to file
+  open(19,file=trim(out_dir2)//'events_lonlat_dat.dat',status='unknown')
+  do ievent = ievent_min, ievent_max
+     !write(19,*) sngl(x_lon(eglob_dat(ievent))), sngl(z_lat(eglob_dat(ievent))), ievent
+     write(19,'(2f20.10,1i12)') x_eve_lon_dat(ievent), z_eve_lat_dat(ievent), ievent
+  enddo
+  close(19)
+  open(19,file=trim(out_dir2)//'events_xy_dat.dat',status='unknown')
+  do ievent = ievent_min, ievent_max
+     write(19,'(3f20.10,1i12)') x_eve_dat(ievent), z_eve_dat(ievent), otime_dat(ievent), ievent
+  enddo
+  close(19)
+
+  !do ievent=1,nevent
+  !   print *, x_eve_lon_dat(ievent),z_eve_lat_dat(ievent)
+  !enddo
+  
+!stop 'testing'
+
+!--------------------------------------
+! events for synthetics (eglob)
+
+  ! allocate variables
+  allocate(x_eve(nevent),z_eve(nevent),x_eve_lon(nevent),z_eve_lat(nevent))
+  allocate(eglob(nevent))
+  allocate(ispec_eve(nevent),xi_eve(nevent),gamma_eve(nevent))
+  allocate(otime(nevent))
+
+  if(PERT_SOURCE == 1) then  ! source perturbations
+
+    if(1==1) then   ! read in perturbed events from another file 
+
+      open(19,file='/home/store2/carltape/'//trim(out_dir3)//'run_2550/events_xy.dat',status='unknown') 
+      do ievent = 1,25
+         read(19,'(3f20.10,1i12)') x_eve(ievent), z_eve(ievent), otime(ievent), itemp1
+      enddo
+      close(19)
+
+    else
+
+       ! perturb the events to get target events for the synthetics
+       ! perturbation is described as (r,theta) polar coordinates
+       amin = 0.
+       amax = 2.*PI
+       rmin = 0.
+       rmax = src_pert_dist
+       ptmin = -abs(src_pert_time)
+       ptmax =  abs(src_pert_time)
+
+       do ievent = 1,nevent
+
+          ! origin time perturbation
+          call random_number(rand1)
+          ptime = (ptmax - ptmin)*rand1 + ptmin
+          !ptime = src_pert_time   
+
+          ! azimuthal perturbation (in radians)
+          call random_number(rand1)
+          pangle = (amax - amin)*rand1 + amin
+          !pangle = 30.*(PI/180.)               ! fix for TESTING
+
+          ! radial perturbation (in meters)
+          call random_number(rand1)
+          prad = (rmax - rmin)*rand1 + rmin
+          !prad = rmax    
+
+          ! fill vectors
+          otime(ievent) = otime_dat(ievent) - ptime                ! NOTE THE SIGN
+          x_eve(ievent) = x_eve_dat(ievent) + cos(pangle)*prad
+          z_eve(ievent) = z_eve_dat(ievent) + sin(pangle)*prad
+          temp1 = sqrt((x_eve_dat(ievent)-x_eve(ievent))**2 + (z_eve_dat(ievent)-z_eve(ievent))**2)
+
+          !write(*,'(5f18.8)') x_eve(ievent)/1000., z_eve(ievent)/1000., &
+          !     x_eve_dat(ievent)/1000., z_eve_dat(ievent)/1000., temp1/1000.
+       enddo
+
+    endif
+
+    ! determine the (eta, xi) corresponding to the target points
+    ! this UPDATES x_eve, z_eve; eglob is the index of the closest gridpoint
+    call locate_targets(nevent, x_eve, z_eve, eglob, ispec_eve, xi_eve, gamma_eve)
+
+    print *
+    print *, 'ievent, x, z, iglob, ispec, xi, gamma'
+    do i=1,nevent
+      write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_eve(i), z_eve(i), &
+         eglob(i), ispec_eve(i), xi_eve(i), gamma_eve(i)
+    enddo
+
+    ! convert from mesh to lat-lon
+    call mesh_geo(nevent, x_eve_lon, z_eve_lat, x_eve, z_eve, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+    ! display target events and perturbed events -- and the distance between (in meters)
+    print *
+    print *, 'events [x_eve_lon_dat, z_eve_lat_dat, x_eve_lon, x_eve_lat, dist (m)]:'
+    do i=1,nevent
+       temp1 = x_eve_lon_dat(i)
+       temp2 = z_eve_lat_dat(i)
+       temp3 = x_eve_lon(i)
+       temp4 = z_eve_lat(i)
+       temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+       write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.*1000.
+    enddo
+
+  else  ! no source perturbation
+
+     eglob(:) = eglob_dat(:)
+     x_eve(:) = x_eve_dat(:)
+     z_eve(:) = z_eve_dat(:)
+     x_eve_lon(:) = x_eve_lon_dat(:) 
+     z_eve_lat(:) = z_eve_lat_dat(:)
+     ispec_eve(:) = ispec_eve_dat(:)
+     xi_eve(:) = xi_eve_dat(:)
+     gamma_eve(:) = gamma_eve_dat(:) 
+
+     otime(:) = otime_dat(:)   ! origin time
+
+  endif   ! PERT_SOURCE
+
+  ! write events for synthetics to file
+  open(19,file=trim(out_dir2)//'events_lonlat.dat',status='unknown')
+  do ievent = ievent_min, ievent_max
+    write(19,'(2f20.10,1i12)') x_eve_lon(ievent), z_eve_lat(ievent), ievent
+  enddo
+  close(19)
+  open(19,file=trim(out_dir2)//'events_xy.dat',status='unknown')
+  do ievent = ievent_min, ievent_max
+     write(19,'(3f20.10,1i12)') x_eve(ievent), z_eve(ievent), otime(ievent), ievent
+  enddo
+  close(19)
+
+!stop 'testing'
+
+!--------------------------------------
+! receivers
+
+  ! allocation and initialization
+  !allocate(rglob_temp(MAX_SR))
+  !allocate(x_rec0(MAX_SR),z_rec0(MAX_SR),x_rec_lon0(MAX_SR),z_rec_lat0(MAX_SR),ifilter_rec(MAX_SR))
+  x_rec0(:) = 0.      ; z_rec0(:) = 0
+  x_rec_lon0(:) = 0.  ; z_rec_lat0(:) = 0.
+  !rglob_temp(:) = 0
+
+! get the lat-lon of the TARGET RECEIVERS
+
+if(IREC_SPACE==1) then  ! individual receivers
+
+  ! target receiver
+  !x_rec0(1) = 3 * LENGTH/4     ; z_rec0(1) = HEIGHT/2
+  x_rec_lon0(1) = -119.6        ; z_rec_lat0(1) = 34.0
+  x_rec_lon0(2) = -116.0        ; z_rec_lat0(2) = 32.5
+  x_rec_lon0(3) = -116.5        ; z_rec_lat0(3) = 35.5
+  !x_rec_lon0(1) = -116.5        ; z_rec_lat0(1) = 35.5
+
+  !x_rec_lon0(1) = -117.450717    ; z_rec_lat0(1) = 34.542814   ! 001
+  !x_rec_lon0(1) = -118.141053    ; z_rec_lat0(1) = 35.547570   ! 126
+
+  !x_rec_lon0(1) = socal_events_lon(ievent) + 1.0   ; z_rec_lat0(1) = socal_events_lat(ievent) + 1.0
+  !x_rec_lon0(2) = socal_events_lon(ievent) + 1.0   ; z_rec_lat0(2) = socal_events_lat(ievent) - 1.0
+  !x_rec_lon0(3) = socal_events_lon(ievent) - 1.0   ; z_rec_lat0(3) = socal_events_lat(ievent) + 1.0
+  !x_rec_lon0(4) = socal_events_lon(ievent) - 1.0   ; z_rec_lat0(4) = socal_events_lat(ievent) - 1.0
+
+  nrec = 3
+
+elseif(IREC_SPACE==2) then  ! actual station locations
+
+  ! read in (target) receivers
+  recfile = trim(in_dir)//'STATION_149_full'
+  !recfile = trim(in_dir)//'STATION_144_noisland'
+  !recfile = trim(in_dir)//'STATION_067_nobasin'
+
+  open(88,file=trim(recfile),status='unknown')
+  read(88,*) nrec
+  read(88,*) (x_rec_lon0(i),z_rec_lat0(i),i=1,nrec)
+  close(88)
+
+elseif(IREC_SPACE==4) then ! 'regular' mesh of receivers
+
+   ! calculate mesh spacing
+   dx = LENGTH/NMESH_REC
+   dz = dx
+   j = 0
+   do xmesh = STATION_GRID_BUFFER+1.,LENGTH,dx
+      do zmesh = STATION_GRID_BUFFER+1.,HEIGHT,dz
+            j = j+1
+            x_rec0(j) = xmesh
+            z_rec0(j) = zmesh
+      enddo
+   enddo
+   nrec = j
+
+   ! get x_rec_lon0, z_rec_lat0
+   call mesh_geo(MAX_SR,x_rec_lon0,z_rec_lat0,x_rec0,z_rec0,UTM_PROJECTION_ZONE,IMESH2LONLAT)
+
+else
+   stop 'invalid entry for IREC_SPACE'
+
+endif  ! IREC_SPACE
+
+  ! make sure that there are fewer target points than the max allowed
+  if(nrec > MAX_SR) then
+     print *
+     print *, ' IREC_SPACE = ', IREC_SPACE
+     print *, '       nrec = ', nrec
+     print *, '     MAX_SR = ', MAX_SR
+     stop 'rec > MAX_SR so increase MAX_SR'
+  endif
+
+  print *
+  print *, 'receivers (adjoint sources):'
+
+  ! all vectors should be length MAX_SR
+  nrec = MAX_SR
+
+  ! convert from lat-lon to mesh coordinates (in meters)
+  call mesh_geo(nrec,x_rec_lon0,z_rec_lat0,x_rec0,z_rec0,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+
+  ! filter target points (utm-mesh) -- update nrec
+  call station_filter(nrec, x_rec0, z_rec0, ifilter_rec, STATION_GRID_BUFFER)
+  !call station_filter(nrec, x_rec, z_rec, dmin_trsh_r, ncoast, coast_x, coast_z)
+  !call station_filter_2(nrec, x_rec, z_rec, -1)  ! -1 for left, +1 for right
+
+  if(nrec < 1) stop 'Must have at least one receiver'
+
+  ! allocate vectors
+  allocate(x_rec(nrec),z_rec(nrec),x_rec_lon(nrec),z_rec_lat(nrec))
+  allocate(rglob(nrec))
+  allocate(ispec_rec(nrec),xi_rec(nrec),gamma_rec(nrec))
+
+  ! assign allowable target receivers to (x_rec, z_rec)
+  do i=1,nrec
+    x_rec(i) = x_rec0(ifilter_rec(i))
+    z_rec(i) = z_rec0(ifilter_rec(i))
+  enddo
+
+  ! determine the (eta, xi) corresponding to the target points
+  ! this UPDATES x_rec, z_rec; rglob is the index of the closest gridpoint
+  call locate_targets(nrec, x_rec, z_rec, rglob, ispec_rec, xi_rec, gamma_rec)
+
+  print *
+  print *, 'irec, x, z, iglob, ispec, xi, gamma'
+  do i=1,nrec
+     write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_rec(i), z_rec(i), rglob(i), ispec_rec(i), xi_rec(i), gamma_rec(i)
+  enddo
+
+  ! convert from mesh to lat-lon
+  call mesh_geo(nrec, x_rec_lon, z_rec_lat, x_rec, z_rec, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+  ! display target receivers and final receivers -- and the distance between (in meters)
+  ! The distance error is due to the UTM conversion, but the lat-lon points are only
+  ! used for plotting purposes, so this is fine.
+  print *
+  print *, ' receivers [x_rec_lon0, z_rec_lat0, x_rec_lon, x_rec_lat, dist (m)] :'
+  do i=1,nrec
+     temp1 = x_rec_lon0(ifilter_rec(i))
+     temp2 = z_rec_lat0(ifilter_rec(i))
+     temp3 = x_rec_lon(i)
+     temp4 = z_rec_lat(i)
+     temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+     write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.*1000.
+  enddo
+
+  ! receiver indices for writing the misfit chi(rec), summed over all events
+  rglob0(1:nrec) = rglob(1:nrec)
+
+  !do i=1,nrec
+  !   print *, sngl(x(rglob(i))/1000.),sngl(z(rglob(i))/1000.),sngl(x_rec(i)/1000.),sngl(z_rec(i)/1000.)
+  !enddo
+
+  !stop 'testing'
+
+  ! deallocate
+  !deallocate(x_rec,z_rec)
+
+  ! write receivers to file
+  open(19,file=trim(out_dir2)//'recs_lonlat.dat',status='unknown')
+  do irec = 1,nrec
+     write(19,'(2f20.10,1i12)') x_rec_lon(irec), z_rec_lat(irec), irec
+  enddo
+  close(19)
+
+!--------------------------------------
+! allocate Lagrange interpolators for sources and receivers for both data and synthetics
+
+  ! allocate 1-D Lagrange interpolators and derivatives
+  allocate(hxied(NGLLX), hpxied(NGLLX), hgammaed(NGLLZ), hpgammaed(NGLLZ))
+  allocate(hxied_store(nevent,NGLLX), hgammaed_store(nevent,NGLLZ))
+
+  allocate(hxie(NGLLX), hpxie(NGLLX), hgammae(NGLLZ), hpgammae(NGLLZ))
+  allocate(hxie_store(nevent,NGLLX), hgammae_store(nevent,NGLLZ))
+
+  allocate(hxir(NGLLX), hpxir(NGLLX), hgammar(NGLLZ), hpgammar(NGLLZ))
+  allocate(hxir_store(nrec,NGLLX), hgammar_store(nrec,NGLLZ))
+
+  ! events for data
+  do ievent = 1,nevent
+    call lagrange_poly(xi_eve_dat(ievent),NGLLX,xigll,hxied,hpxied)
+    call lagrange_poly(gamma_eve_dat(ievent),NGLLZ,zigll,hgammaed,hpgammaed)
+    hxied_store(ievent,:)    = hxied(:)
+    hgammaed_store(ievent,:) = hgammaed(:)
+    !write(*,'(i8,5f16.10)') ievent, hxied(:)       ! NGLLX
+    !write(*,'(i8,5f16.10)') ievent, hgammaed(:)    ! NGLLZ
+  enddo
+  deallocate(hxied, hpxied, hgammaed, hpgammaed)
+
+  ! events for synthetics
+  do ievent = 1,nevent
+    call lagrange_poly(xi_eve(ievent),NGLLX,xigll,hxie,hpxie)
+    call lagrange_poly(gamma_eve(ievent),NGLLZ,zigll,hgammae,hpgammae)
+    hxie_store(ievent,:)    = hxie(:)
+    hgammae_store(ievent,:) = hgammae(:)
+    !write(*,'(i8,5f16.10)') ievent, hxie(:)       ! NGLLX
+    !write(*,'(i8,5f16.10)') ievent, hgammae(:)    ! NGLLZ
+  enddo
+  deallocate(hxie, hpxie, hgammae, hpgammae)
+
+  ! receivers
+  do irec = 1,nrec
+    call lagrange_poly(xi_rec(irec),NGLLX,xigll,hxir,hpxir)
+    call lagrange_poly(gamma_rec(irec),NGLLZ,zigll,hgammar,hpgammar)
+    hxir_store(irec,:)    = hxir(:)
+    hgammar_store(irec,:) = hgammar(:)
+    !write(*,'(i8,5f16.10)') irec, hxir(:)       ! NGLLX
+    !write(*,'(i8,5f16.10)') irec, hgammar(:)    ! NGLLZ
+  enddo
+  deallocate(hxir, hpxir, hgammar, hpgammar)
+
+!stop 'testing'
+
+!--------------------------------------
+! fake receivers for recording seismograms from the adjoint wavefield
+! (note that we do not compute lat-lon for these points)
+! THIS PORTION COULD BE REMOVED -- IT WAS FOR COMPUTING THE SPECTRAL MAP
+! FOR THE OMS SIMULATIONS.
+
+   ! mesh of target points
+   x_recf0(:) = 0.
+   z_recf0(:) = 0.
+   dx = LENGTH/9.
+   dz = dx
+   i = 0
+   do xmesh = 0.,LENGTH,dx
+      do zmesh = 0.,HEIGHT,dz
+         i = i+1
+         if(i > MAX_SR_FAKE) stop 'i > MAX_SR_FAKE so change dx, dz, or MAX_SR_FAKE'
+         x_recf0(i) = xmesh
+         z_recf0(i) = zmesh
+      enddo
+   enddo
+   !nrecf = i
+
+  print *
+  print *, 'fake receivers (for spectral maps):'
+
+  ! all vectors should be length MAX_SR_FAKE
+  nrecf = MAX_SR_FAKE
+
+  ! filter target points (utm-mesh) -- update nrecf
+  call station_filter(nrecf, x_recf0, z_recf0, ifilter_recf, STATION_GRID_BUFFER)
+
+  if(nrecf < 1) stop 'Must have at least one fake (adjoint) receiver'
+
+  ! allocate vectors
+  allocate(x_recf(nrecf),z_recf(nrecf),fglob(nrecf))
+
+  ! assign allowable target receivers to (x_rec, z_rec)
+  do i=1,nrecf
+    x_recf(i) = x_recf0(ifilter_recf(i))
+    z_recf(i) = z_recf0(ifilter_recf(i))
+    !print *, i, x_recf(i), z_recf(i)
+  enddo
+
+  ! fglob is the index of the CLOSEST GRIDPOINT
+  call locate_targets(nrecf, x_recf, z_recf, fglob)
+
+  !do i=1,nrecf
+  !  print *, sngl(x(fglob(i))/1000.),sngl(z(fglob(i))/1000.),sngl(x_recf(i)/1000.),sngl(z_recf(i)/1000.)
+  !enddo
+
+!!$  ! display target receivers and final fake receivers -- distances in km
+!!$  print *
+!!$  print *, ' fake receivers [x_rec0, z_rec0, x_rec, x_rec, dist (km)]:'
+!!$  do i=1,nrecf
+!!$     temp1 = x_recf0(ifilter_recf(i)) / 1000.
+!!$     temp2 = z_recf0(ifilter_recf(i)) / 1000.
+!!$     temp3 = x_recf(i) / 1000.
+!!$     temp4 = z_recf(i) / 1000.
+!!$     temp5 = sqrt( (temp3-temp1)**2 + (temp4-temp2)**2 )
+!!$     write(*,'(i8,5f17.10)') i, temp1, temp2, temp3, temp4, temp5
+!!$  enddo
+
+  ! deallocate: all we need is fglob
+  deallocate(x_recf,z_recf)
+
+!stop 'testing'
+
+!--------------------------------------
+! initial model vectors
+
+  nmod_str = NGLOB              ! source parameters
+  nmod_src = 3*nevent           ! structure parameters
+  nmod = nmod_str + nmod_src    ! total model parameters
+
+  ! allocate model vector
+  allocate(m0(nmod),mt(nmod),gradient(nmod))
+  allocate(m0_vec(nmod),mt_vec(nmod))
+  allocate(g0(nmod),gt(nmod),gk(nmod),p0(nmod),pk(nmod))
+
+  !allocate(m_vel(nmod_str),m0_vel(nmod_str),mt_vel(nmod_str))
+
+  m0(:) = 0.
+  mt(:) = 0.
+  m0_vec(:) = 0.
+  mt_vec(:) = 0.
+  gradient(:) = 0.
+
+  !------------------
+  ! source-related vectors
+
+  ! scaling for source model coefficients
+  allocate(source_gradient(nmod_src),m_scale_src(nmod_src))
+  allocate(m_src(nmod_src),mt_src(nmod_src),m0_src(nmod_src))
+  allocate(m_src_syn(nmod_src),m_src_dat(nmod_src))
+
+  source_gradient(:) = 0.
+  m0_src(:) = 0.           ! obsolete
+  mt_src(:) = 0.           ! obsolete
+  m_src(:) = 0.
+  m_src_dat(:) = 0.
+  m_src_syn(:) = 0.
+
+  ! fill source model vector for DATA
+  do ievent = 1,nevent
+    itemp1 = (ievent-1)*3 + 1
+    itemp2 = (ievent-1)*3 + 2
+    itemp3 = (ievent-1)*3 + 3
+
+    m_src_dat(itemp1) = x_eve_dat(ievent)
+    m_src_dat(itemp2) = z_eve_dat(ievent)
+    m_src_dat(itemp3) = otime_dat(ievent)
+  enddo
+
+  ! fill source model vector for SYNTHETICS
+  !origin_time = origin_time_dat - src_pert_time
+  do ievent = 1,nevent
+    itemp1 = (ievent-1)*3 + 1
+    itemp2 = (ievent-1)*3 + 2
+    itemp3 = (ievent-1)*3 + 3
+
+    m_src_syn(itemp1) = x_eve(ievent)
+    m_src_syn(itemp2) = z_eve(ievent)
+    m_src_syn(itemp3) = otime(ievent)
+  enddo
+
+  !m_scale_src(:) = m_src_syn(:)
+
+  m_scale(1) = 2*hdur*c0   ! dxs -- wavelength
+  m_scale(2) = 2*hdur*c0   ! dzs -- wavelength
+  m_scale(3) = 2*hdur      ! dt0 -- period
+  do ievent = 1,nevent
+    do i = 1,3
+      itemp = (ievent-1)*3 + i
+      m_scale_src(itemp) = m_scale(i)
+    enddo
+  enddo
+
+  open(88,file=trim(out_dir2)//'scale_source.dat',status='unknown')
+  do i=1,nmod_src
+    write(88,'(1e24.12)') m_scale_src(i)
+  enddo
+  close(88)
+
+  !stop 'testing'
+
+  !------------------
+  ! initial model vector (physical coordinates)
+
+  ! structure portion of initial model vector
+  !do iglob = 1,NGLOB
+  !  !m0(iglob)     = c_glob_syn(iglob) / c0 - 1.  ! fractional perturbation
+  !  m0_vec(iglob) = c_glob_syn(iglob)            ! m/s
+  !enddo
+
+  do i = 1,nmod
+    if(i <= nmod_str) then
+      m0_vec(i) = c_glob_syn(i)            ! m/s
+    else
+      m0_vec(i) = m_src_syn(i-nmod_str)    ! xs, zs, t0
+    endif
+  enddo
+
+  open(88,file=trim(out_dir2)//'initial_model_vector.dat',status='unknown')
+  do i=1,nmod
+    write(88,'(1e24.12)') m0_vec(i)
+  enddo
+  close(88)
+  !stop 'testing'
+
+  !------------------
+
+if(ISOURCE_LOG) open(91,file=trim(out_dir2)//'source_vector.log',status='unknown')
+
+itest = 0
+!============================================
+! LOOP 2: over the models in the CG optimization
+  do istep = 0,2*NITERATION
+!============================================
+
+  imod = (istep - mod(istep,2))/2          ! index into model number
+
+!!$  if( mod(imod,2) == 0 ) then
+!!$  !if(imod <= 1 .or. imod==5 .or. imod==9 .or. imod==13) then
+!!$    INV_SOURCE = 1
+!!$    INV_STRUCT = 0
+!!$  else
+!!$    INV_SOURCE = 0
+!!$    INV_STRUCT = 1
+!!$  endif
+
+  irun = irun0 + istep
+  print *,'=============================================================='
+  print *,'  istep, imod, irun : ', istep, imod, irun
+  if(INV_STRUCT==1) print *, '  inverting for structure parameters'
+  if(INV_SOURCE==1) print *, '  inverting for source parameters'
+  print *,'=============================================================='
+
+!enddo 
+!stop 'itesting'
+!do istep = 0,2*NITERATION
+
+  ! name and create the output directory
+  write(out_dir1,'(a,i4.4,a)') trim(out_dir3)//'run_',irun,'/'
+  command1 = 'mkdir ' // trim(out_dir1)
+  call system(command1)
+  !open(19,file='temp.csh',status='unknown')
+  !write(19,'(2a)') 'mkdir ',out_dir1
+  !close(19)
+  !call system('chmod 755 temp.csh ; temp.csh')
+
+  ! use the reference model or test model (source and structure)
+  ! structure is the top portion; source is the bottom portion
+  if(itest==0) then
+
+     c_glob_syn(:) = m0_vec(1:nmod_str)
+     m_src(:)      = m0_vec(nmod_str+1:nmod)
+     !m_vel(:) = m0_vel(:)
+     !m_src(:) = m0_src(:)
+
+  elseif(itest==1) then
+     c_glob_syn(:) = mt_vec(1:nmod_str)
+     m_src(:)      = mt_vec(nmod_str+1:nmod)
+
+     !m_vel(:) = mt_vel(:)
+     !m_src(:) = mt_src(:)
+  endif
+
+  ! initialize measurement vector
+  nmeas = nevent * nrec
+  allocate(measure_vec(nmeas))
+  measure_vec(:) = 0.
+  imeasure = 0
+  print *, ' nmeas = nevent * nrec = ', nmeas
+
+  ! initialize source perturbation vector
+  source_gradient(:) = 0.
+
+  ! initialize summed kernel (structure gradient)
+  kernel_basis_sum(:) = 0.
+
+  !stop 'testing'
+
+! loop over events
+!============================================
+! LOOP 3: over the events
+  ifirst = 1
+!  do ievent = ievent_min, ievent_max
+  do ievent = 5,5    ! 1,5
+!============================================
+  
+  print *,'------------------------------------'
+  print *,'  EVENT NUMBER ',ievent
+  print *,'------------------------------------'
+
+  ! NAME THE OUTPUT DIRECTORY
+  write(ev_dir,'(a,i3.3,a)') 'event_',ievent,'/'
+  out_dir = trim(out_dir1)//trim(ev_dir)
+  command1 = 'mkdir ' // trim(out_dir)
+  call system(command1)
+  !open(19,file='temp.csh',status='unknown')
+  !write(19,'(2a)') 'mkdir ',out_dir
+  !close(19)
+  !call system('chmod 755 temp.csh ; temp.csh')
+
+!--------------------------------------
+! source
+
+  ! get the lat-lon of the TARGET RECEIVERS
+
+  if(ISRC_SPACE <= 5) then  ! if you do NOT want a point source from the event list
+
+     x_src_lon0(:) = 0.  ; z_src_lat0(:) = 0.
+     x_src0(:) = 0.      ; z_src0(:) = 0.
+
+     if (ISRC_SPACE==1) then  ! point source(s)
+
+        !x_src0(1) = LENGTH/4      ; z_src0(1) = HEIGHT/2
+        !x_src_lon0(1) = -118.5370     ; z_src_lat0(1) = 34.2130   ! Northridge
+        !x_src_lon0(1) = -117.918     ; z_src_lat0(1) = 32.3290   ! 2004/06/15
+        !x_src_lon0(1) = -117.776     ; z_src_lat0(1) = 33.917    ! Yorba Linda
+
+        !x_src_lon0(1) = -119.0     ; z_src_lat0(1) = 33.0
+        !x_src_lon0(2) = -118.0     ; z_src_lat0(2) = 33.5
+        !x_src_lon0(3) = -119.5     ; z_src_lat0(3) = 34.3
+        !x_src_lon0(1) = -119.5     ; z_src_lat0(1) = 33.0          ! single kernel
+
+        x_src_lon0(1) = x_eve_lon(ievent)
+        z_src_lat0(1) = z_eve_lat(ievent)
+        nsrc = 1
+
+     elseif (ISRC_SPACE==2) then  ! finite source segment
+
+        ! specify the target starting point of the fault, the azimuth, and the length
+        x_src_lon_i = -119.    ;  z_src_lat_i = 33.   ;   flen   = 100.0d+03  ! short fault
+        !x_src_lon_i = -118.0   ;  z_src_lat_i = 32.   ;   flen   = 500.0d+03  ! long fault
+        src_az = -45.*(PI/180.)        ! azimuth (clockwise from north)
+        finc   = 1.5*dh                ! distance betwen target gridpoints (m)
+
+        ! determine the target endpoint of the fault
+        call utm_geo(x_src_lon_i, z_src_lat_i, x_src_i, z_src_i, UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+        x_src_i = x_src_i - utm_xmin
+        z_src_i = z_src_i - utm_zmin
+        x_src_f = x_src_i + sin(src_az)*flen
+        z_src_f = z_src_i + cos(src_az)*flen
+
+        ! determine the xz target points of the fault (Cartesion polar coordinates)
+        i = 0
+        do xd = 0,flen,finc
+           i = i+1
+           x_src0(i) = x_src_i + sin(src_az)*(i-1)*finc
+           z_src0(i) = z_src_i + cos(src_az)*(i-1)*finc
+           print *, x_src0(i)/1000., z_src0(i)/1000.
+        enddo
+        nsrc = i
+
+        ! get target fault points in lat-lon
+        call mesh_geo(MAX_SR,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+
+     elseif (ISRC_SPACE==3) then  ! California continental shelf (OMS)
+
+        x_src_lon0(1:nshelf) = shelf_lon(1:nshelf)
+        z_src_lat0(1:nshelf) = shelf_lat(1:nshelf)
+        nsrc = nshelf      
+
+     elseif (ISRC_SPACE==4) then  ! California coastline (OMS)
+
+        x_src_lon0(1:ncoast) = coast_lon(1:ncoast)
+        z_src_lat0(1:ncoast) = coast_lat(1:ncoast)
+        nsrc = ncoast
+
+     elseif (ISRC_SPACE==5) then  ! finite circular region
+
+        ! lat-lon of the center point
+        xcen_lon = -119.0
+        zcen_lat = 33.0
+        x_src_lon0(1) = xcen_lon
+        z_src_lat0(1) = zcen_lat
+        nsrc = 1
+
+        call mesh_geo(nsrc,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+        xcen = x_src0(1)
+        zcen = z_src0(1)
+
+        ! target points within a radius of the center point
+        s_radius = 30.0d+03
+        dx = dh/2.
+        dz = dx
+        i = 0
+        do xmesh = xcen-s_radius, xcen+s_radius, dx
+           do zmesh = zcen-s_radius, zcen+s_radius, dx
+              d = sqrt((xmesh - xcen)**2+(zmesh - zcen)**2)
+              if(d < s_radius) then
+                 i = i+1
+                 x_src0(i) = xmesh
+                 z_src0(i) = zmesh
+              endif
+           enddo
+        enddo
+        nsrc = i
+
+        ! get circle points in lat-lon
+        call mesh_geo(MAX_SR,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+
+     endif  ! ISRC_SPACE
+
+     do i=1,nsrc
+        print *, x_src_lon0(i), z_src_lat0(i)
+     enddo
+
+     ! make sure that there are fewer target points than the max allowed
+     ! (this is not ideal, since you might have a file of points that extend far outside the grid)
+     if(nsrc > MAX_SR) then
+        print *
+        print *, ' ISRC_SPACE = ', ISRC_SPACE
+        print *, '       nsrc = ', nsrc
+        print *, '     MAX_SR = ', MAX_SR
+        stop 'nsrc > MAX_SR so increase MAX_SR'
+     endif
+
+     print *
+     print *, 'source(s) for event ', ievent, ' :'
+
+     ! all vectors should be length MAX_SR
+     nsrc = MAX_SR
+
+     ! convert from lat-lon to mesh coordinates (in meters) -- get (x_src0,z_src0)
+     call mesh_geo(nsrc,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+
+     ! filter target points (utm-mesh) -- update nsrc
+     call station_filter(nsrc, x_src0, z_src0, ifilter_src, SOURCE_GRID_BUFFER)
+
+     if(nsrc < 1) stop 'Must have at least one source'
+
+     ! allocate vectors
+     allocate(x_src(nsrc),z_src(nsrc),x_src_lon(nsrc),z_src_lat(nsrc))
+     allocate(sglob(nsrc))
+     allocate(ispec_src(nsrc),xi_src(nsrc),gamma_src(nsrc))
+
+     ! assign allowable target sources to (x_src, z_src)
+     do i=1,nsrc
+        x_src(i) = x_src0(ifilter_src(i))
+        z_src(i) = z_src0(ifilter_src(i))
+     enddo
+
+     ! determine the (eta, xi) corresponding to the target points
+     ! this UPDATES x_src, z_src; sglob is the index of the closest gridpoint
+     call locate_targets(nsrc, x_src, z_src, sglob, ispec_src, xi_src, gamma_src)
+
+     print *
+     do i=1,nsrc
+        write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_src(i), z_src(i), sglob(i), ispec_src(i), xi_src(i), gamma_src(i)
+     enddo
+
+     ! convert from mesh to lat-lon
+     call mesh_geo(nsrc, x_src_lon, z_src_lat, x_src, z_src, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+     ! display target sources and final sources -- and the distance between (in meters)
+     ! The distance error is due to the UTM conversion, but the lat-lon points are only
+     ! used for plotting purposes, so this is fine.
+     print *
+     print *, 'sources [x_src_lon0, z_src_lat0, x_src_lon, x_src_lat, dist (m)]:'
+     do i=1,nsrc
+        temp1 = x_src_lon0(ifilter_src(i))
+        temp2 = z_src_lat0(ifilter_src(i))
+        temp3 = x_src_lon(i)
+        temp4 = z_src_lat(i)
+        temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+        write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.*1000.
+     enddo
+
+  else  ! select POINT SOURCE for array of events
+
+     nsrc = 1
+
+     !-----------------
+     ! sources for data (no source perturbations)
+
+     ! allocate vectors
+     allocate(x_src_dat(nsrc),z_src_dat(nsrc),x_src_lon_dat(nsrc),z_src_lat_dat(nsrc))
+     allocate(sglob_dat(nsrc))
+     allocate(ispec_src_dat(nsrc),xi_src_dat(nsrc),gamma_src_dat(nsrc))
+
+     ! allocate 1-D Lagrange interpolators and derivatives
+     allocate(hxisd_store(nsrc,NGLLX),hgammasd_store(nsrc,NGLLZ))
+
+     sglob_dat(1)     = eglob_dat(ievent)   ! closest gridpoint
+     x_src_dat(1)     = x_eve_dat(ievent)
+     z_src_dat(1)     = z_eve_dat(ievent)
+     x_src_lon_dat(1) = x_eve_lon_dat(ievent)
+     z_src_lat_dat(1) = z_eve_lat_dat(ievent)
+     ispec_src_dat(1) = ispec_eve_dat(ievent)
+     xi_src_dat(1)    = xi_eve_dat(ievent)
+     gamma_src_dat(1) = gamma_eve_dat(ievent)
+     hxisd_store(1,:) = hxied_store(ievent,:)
+     hgammasd_store(1,:) = hgammaed_store(ievent,:)
+
+     !-----------------
+     ! sources for synthetics (allows for source perturbations)
+
+     ! source perturbations for this event
+     itemp1 = (ievent-1)*3 + 1
+     itemp2 = (ievent-1)*3 + 2
+     itemp3 = (ievent-1)*3 + 3
+
+     ! allocate vectors
+     allocate(x_src(nsrc),z_src(nsrc),x_src_lon(nsrc),z_src_lat(nsrc))
+     allocate(sglob(nsrc))
+     allocate(ispec_src(nsrc),xi_src(nsrc),gamma_src(nsrc))
+
+     x_src(1) = m_src(itemp1)        ! new x position
+     z_src(1) = m_src(itemp2)        ! new z position
+     origin_time = m_src(itemp3)     ! new origin time
+
+!!$        ! perturb source location from the previous model
+!!$        ! this only changes the source if INV_SRC = 1
+!!$        if(istep==0) then  ! initial source
+!!$
+!!$           x_src(1) = x_eve(ievent)          ! x position, perturbed event
+!!$           z_src(1) = z_eve(ievent)          ! z position, perturbed event
+!!$           origin_time = origin_time_dat - src_pert_time
+!!$
+!!$           ! initial source model
+!!$           m_src(itemp1) = x_src(1)          ! x position
+!!$           m_src(itemp2) = z_src(1)          ! z position
+!!$           m_src(itemp3) = origin_time       ! origin time
+!!$
+!!$           !m_src(:) = m0_src(:)
+!!$           m0_vec(nmod_str+1:nmod) = m_src(:)
+!!$
+!!$        else
+!!$
+!!$           !origin_time = origin_time_dat     ! testing
+!!$
+!!$        endif
+ 
+!!$     ! write model vector to file
+!!$     open(unit=19,file=trim(out_dir1)//'test.dat',status='unknown')
+!!$     do i = 1,nmod
+!!$       write(19,*) m0_vec(i)
+!!$     enddo
+!!$     close(19)
+!!$     stop 'testing'
+
+     ! filter target points (utm-mesh) -- update nsrc
+     call station_filter(nsrc, x_src, z_src, ifilter_src, SOURCE_GRID_BUFFER)
+
+     if(nsrc /= 1) stop 'Must be a single point source'
+
+     ! determine the (eta, xi) corresponding to the target points
+     ! this UPDATES x_src, z_src; sglob is the index of the closest gridpoint
+     call locate_targets(nsrc, x_src, z_src, sglob, ispec_src, xi_src, gamma_src)
+
+     print *
+     do i=1,nsrc
+        write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_src(i), z_src(i), sglob(i), ispec_src(i), xi_src(i), gamma_src(i)
+        write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_src_dat(i), z_src_dat(i), &
+           sglob_dat(i), ispec_src_dat(i), xi_src_dat(i), gamma_src_dat(i)
+     enddo
+
+     ! convert from mesh to lat-lon
+     call mesh_geo(nsrc, x_src_lon, z_src_lat, x_src, z_src, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+     allocate(hxis(NGLLX), hpxis(NGLLX), hgammas(NGLLZ), hpgammas(NGLLZ))
+     allocate(hxis_store(nsrc,NGLLX), hgammas_store(nsrc,NGLLZ))
+
+     ! key variables for locating synthetic sources
+     do isrc = 1,nsrc
+       call lagrange_poly(xi_src(isrc),NGLLX,xigll,hxis,hpxis)
+       call lagrange_poly(gamma_src(isrc),NGLLZ,zigll,hgammas,hpgammas)
+       hxis_store(isrc,:)    = hxis(:)
+       hgammas_store(isrc,:) = hgammas(:)
+       !write(*,'(i8,5f16.10)') isrc, hxis(:)       ! NGLLX
+       !write(*,'(i8,5f16.10)') isrc, hgammas(:)    ! NGLLZ
+     enddo
+     deallocate(hxis, hpxis, hgammas, hpgammas)
+
+     !-------------------
+     ! source for data and source for synthetic
+     print *
+     print *, 'sources [x_src_lon_dat, z_src_lat_dat, x_src_lon, z_src_lat, dist (m)]:'
+     do i=1,nsrc
+        temp1 = x_src_lon_dat(i)
+        temp2 = z_src_lat_dat(i)
+        temp3 = x_src_lon(i)
+        temp4 = z_src_lat(i)
+        temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+        write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.*1000.
+     enddo
+
+  endif  ! ISRC_SPACE
+
+  if(ISOURCE_LOG) then
+    ! source log file
+    itemp1 = (ievent-1)*3 + 1
+    itemp2 = (ievent-1)*3 + 2
+    itemp3 = (ievent-1)*3 + 3
+    write(91,*)
+    write(91,*) '------------------------'
+    write(91,*) 'istep, imod, ievent, irun : '
+    write(91,*) istep, imod, ievent, irun
+    write(91,*) 'SOURCE MODEL (xs, ys, t0) :'
+    write(91,*) ' [m_src]:'
+    write(91,'(a12,3f18.8)') ' xs (km) : ', m_src(itemp1)/1000., &
+       x_eve_dat(ievent)/1000., (m_src(itemp1) - x_eve_dat(ievent))/1000.
+    write(91,'(a12,3f18.8)') ' zs (km) : ', m_src(itemp2)/1000., &
+       z_eve_dat(ievent)/1000., (m_src(itemp2) - z_eve_dat(ievent))/1000.
+    write(91,'(a12,3f18.8)') ' t0 (s) : ', m_src(itemp3), &
+       origin_time_dat, m_src(itemp3) - origin_time_dat
+  endif
+
+!--------------------------------------
+! source time function FOR DATA AND SYNTHETICS
+
+  ! source magnitude (same for data and synthetics)
+  if(NCOMP==3) then
+     f0(1) = 0.0    ;  f0(2) = FNORM    ; f0(3) = 0.0
+  elseif(NCOMP==1) then
+     f0(1) = FNORM
+  else
+     stop 'NCOMP must be 1 or 3'
+  endif
+
+  ! source time function for DATA
+  stf_dat(:) = 0.
+  call get_source_time_function(origin_time_dat,stf_dat,ti) 
+  !call get_source_time_function(nsrc,origin_time_dat,f0,samp_dat,ti)
+
+  ! source function for data
+  allocate(samp_dat(NSTEP,NCOMP,nsrc))
+  samp_dat(:,:,:) = 0.0 
+  do i = 1,nsrc
+    do icomp = 1,NCOMP
+       samp_dat(:, icomp, i) = stf_dat(:) * f0(icomp)
+    enddo
+  enddo
+
+  ! source time function for SYNTHETICS (allows for origin time perturbation)
+  stf(:) = 0.
+  call get_source_time_function(origin_time,stf,ti) 
+  !call get_source_time_function(nsrc,origin_time,f0,samp,ti)
+
+  ! source function for synthetics
+  allocate(samp(NSTEP,NCOMP,nsrc))
+  samp(:,:,:) = 0.0 
+  do i = 1,nsrc
+    do icomp = 1,NCOMP
+       samp(:, icomp, i) = stf(:) * f0(icomp)
+    enddo
+  enddo
+
+  ! write out source time functions for the first point source (for plot_model.pl)
+  ! other source time functions will be written in write_seismogram.f90
+  do i = 1,nsrc
+     do icomp = 1,NCOMP
+        write(file_stf,'(a,i5.5,a,i1)') trim(out_dir)//'stf_',i,'_',icomp
+        open(12,file=file_stf,status='unknown')
+        write(*,*)
+        write(*,*) 'Event #', ievent, ', Source #', i
+        write(*,*) '  actual location       : ', sngl(x_src_lon(i)), ', ', sngl(z_src_lat(i))
+        write(*,*) '  closest GLL gridpoint : ', sngl(x_lon(sglob(i))), ', ', sngl(z_lat(sglob(i)))
+        do itime=1,NSTEP
+           write(12,'(1f16.6,1e16.6)') ti(itime), samp_dat(itime,icomp,i)
+        enddo
+        close(12)
+     enddo
+  enddo
+
+!stop 'testing'
+
+!!$  deallocate(samp, sglob, sglob_dat)
+!!$  deallocate(x_src,z_src,x_src_lon,z_src_lat)
+!!$  deallocate(ispec_src, xi_src, gamma_src)
+!!$  enddo
+!!$  stop 'testing'
+!!$  do ievent = 1,nevent
+
+
+
+!!$  do itime = 1, NSTEP
+!!$    ti(itime) = dble(itime-1)*DT
+!!$    stf = source_time_function(ti(itime)-tshift, hdur, istf)  ! note time shift (constants)
+!!$    do i = 1, nsrc
+!!$      samp(itime, :, i) = stf * f0(:)  
+!!$    enddo
+!!$  enddo  
+
+!--------------------------------------
+! testing filter routines
+
+!!$print *, 'testing the fft subroutine using the source time function'
+!!$call write_spectral_map(samp, nsrc, sglob, trim(out_dir)//'test')
+!!$
+!!$print *, 'testing the bandpass filter subroutine using the source time function'
+!!$call filter(ti, samp, nsrc)
+!!$
+!!$print *, 'testing the fft subroutine using the bandpass-filtered source time function'
+!!$call write_spectral_map(samp, nsrc, sglob, trim(out_dir)//'test_f')
+!!$
+!!$stop
+
+!--------------------------------------
+  
+  ! write source and receivers to file
+  ! NOTE THAT THE RECEIVER LABELING IS SIMPLY NUMERICAL ORDER (FOR NOW)
+  !write(filename,'(a,i3.3,a)') trim(out_dir)//'sr_e',ievent,'.txt'
+  file_src_rec = trim(out_dir)//'sr.txt'
+  open(12,file=file_src_rec,status='unknown',iostat=ios)
+  if (ios /= 0) stop 'Error opening out_dir/sr.txt'
+  if(ISRC_SPACE /= 5) then
+     write(12,'(a,2f12.6,i10)') ('S ', x_lon(sglob(i)), z_lat(sglob(i)), i, i=1,nsrc)
+  else
+     ! finite area source
+     do i=1,nsrc
+        d = sqrt((x(sglob(i)) - xcen)**2+(z(sglob(i)) - zcen)**2)
+        if( d > s_radius-dh) then  ! get outermost sources
+           write(12,'(a,2f12.6,i10)') 'S ', x_lon(sglob(i)), z_lat(sglob(i)), i
+        endif
+     enddo
+  endif
+  write(12,'(a,2f12.6,i10)') ('R ', x_lon(rglob(i)), z_lat(rglob(i)), i, i=1,nrec)
+  close(12)
+
+  ! plot phase velocity map with source-receiver geometry and source time function
+  iopt = 3 + idat
+  if(ISURFACE==1) then
+     !filename1 = 'get_model.csh'
+     !filename2 = trim(script_dir)//'plot_model.pl'
+     !open(19,file=filename1,status='unknown')
+     !write(19,'(4a,i5,3a,2f12.6,7a,i5)') trim(filename2),' ', trim(out_dir1),' ', &
+     !    iopt, ' ', trim(file_syn_c), ' ', sngl(c0), sngl(t_target), &
+     !    ' ',trim(file_dat_c),' ',trim(file_stf),' ', trim(file_src_rec),' ',FINITE_SOURCE
+     !close(19)
+     !call system('chmod 755 get_model.csh ; get_model.csh')
+  endif
+
+  ! the following are not needed, since we have sglob/rglob/fglob, the index vectors
+  ! into the sources, receivers, and fake receivers
+
+  deallocate(x_src,z_src,x_src_lon,z_src_lat)
+  deallocate(x_src_dat,z_src_dat,x_src_lon_dat,z_src_lat_dat)
+
+  !stop 'testing'
+
+  !-----------------------------------------------------
+  ! write the current models to file
+
+  if(ifirst == 1) then
+
+     ! write phase velocity maps to file (data is always the same)
+     open(unit=18,file=trim(out_dir1)//file_dat_c,status='unknown')
+     do iglob = 1,NGLOB
+        write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_dat(iglob)), sngl(c_glob_dat(iglob)/c0 - 1.)
+     enddo
+     close(18)
+     open(unit=18,file=trim(out_dir1)//file_syn_c,status='unknown')
+     do iglob = 1,NGLOB
+        write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_syn(iglob)), sngl(c_glob_syn(iglob)/c0 - 1.)
+     enddo
+     close(18)
+
+     ! write source vectors to file (data is always the same) 
+     open(unit=19,file=trim(out_dir1)//'socal_src_dat.dat',status='unknown')
+     do i = 1,nevent
+        write(19,'(i8,3f20.12)') i, m_src_dat((i-1)*3 + 1)/1000., &
+                                    m_src_dat((i-1)*3 + 2)/1000., &
+                                    m_src_dat((i-1)*3 + 3)
+     enddo
+     close(19)
+     open(unit=19,file=trim(out_dir1)//'socal_src_syn.dat',status='unknown')
+     do i = 1,nevent
+        write(19,'(i8,3f20.12)') i, m_src((i-1)*3 + 1)/1000., &
+                                    m_src((i-1)*3 + 2)/1000., &
+                                    m_src((i-1)*3 + 3)
+     enddo
+     close(19)
+
+     ifirst = 0
+
+  endif  ! ifirst
+
+  !stop 'testing'
+
+!=============================================================================================
+! ******************************** WAVE SIMLUTAIONS ******************************************
+!=============================================================================================
+
+!=========================
+! DATA (forward wavefield)
+
+  if(WRITE_STF_F) call write_seismogram(samp_dat, nsrc, trim(out_dir)//'stffor_dat')
+
+  ! compute data for misfit kernels
+  allocate(data(NSTEP,NCOMP,nrec))
+  data(:,:,:) = 0.0
+  if(IKER <= 4) then
+
+     ! set velocity field for the data
+     c_glob(:) = c_glob_dat
+     call set_model_property()
+
+     ! DATA (forward wavefield)
+     ! nsrc, sglob, samp_dat  : #src, src index, source
+     ! nrec, rglob, data :      #rec, rec index, seis
+     ! NOTE THAT sglob_dat ALLOWS FOR A PERTURBED SOURCE FROM THE SOURCES USED TO COMPUTE THE SYNTHETICS
+     isolver = 1
+     call solver(isolver, nsrc, sglob_dat, ispec_src_dat, hxisd_store, hgammasd_store, samp_dat, &
+                          nrec, rglob,     ispec_rec,      hxir_store,  hgammar_store, data)
+
+     ! write out seismograms at the receivers
+     data_tag = 'dat'
+     if(WRITE_SEISMO_F) call write_seismogram(data, nrec, trim(out_dir)//data_tag)
+  endif
+
+  !stop 'testing'
+
+!=========================
+! SYNTHETICS (forward wavefield)
+  
+  if(WRITE_STF_F) call write_seismogram(samp, nsrc, trim(out_dir)//'stffor_syn')
+
+  !stop 'testing'
+
+  ! forward wavefield
+  allocate(syn(NSTEP,NCOMP,nrec))
+  syn(:,:,:) = 0.0
+
+  ! set velocity field for the synthetics (e.g., homogeneous reference model)
+  c_glob(:) = c_glob_syn(:)
+  call set_model_property()
+
+  isolver = 1
+  last_frame_name = trim(out_dir)//'last_frame.txt'
+  allocate(absorb_field(NSTEP, NCOMP, NGLL, NELE, NABSORB))
+  call solver(isolver, nsrc, sglob, ispec_src, hxis_store, hgammas_store, samp, &
+                       nrec, rglob, ispec_rec, hxir_store, hgammar_store,  syn, trim(last_frame_name), absorb_field)
+
+  ! write out seismograms at the receivers
+  syn_tag = 'syn'
+  !syn_tag = 'forward'
+  if(WRITE_SEISMO_F) call write_seismogram(syn, nrec, trim(out_dir)//syn_tag)
+
+  if(WRITE_SPECTRAL_MAP_F) then
+     print *, 'compute and write out forward spectral map '
+     call write_spectral_map(syn, nrec, rglob, trim(out_dir)//'spectral_forward',WRITE_SPECTRA_F)
+  endif
+
+  ! adjoint source function
+  allocate(adj_syn(NSTEP,NCOMP,nrec))
+  adj_syn(:,:,:) = 0.
+
+  ! initialize time window for adjoint source to be the entire record
+  allocate(tstart(nrec),tend(nrec))
+  tstart(:) = 0.
+  tend(:)   = NSTEP*DT
+
+  ! compute time windows for adjoint source function
+  ! d: distance from the FIRST SOURCE to the receivers (assuming homogeneous model)
+  ! window with should be wide enough to capture synthetic and data waveforms,
+  ! but narrow enough to exclude suprious boundary reflections
+  print *
+  print *, 'cut times for adjoint sources'
+  do i=1,nrec
+     d = sqrt( (x(sglob(1)) - x(rglob(i)))**2 + (z(sglob(1)) - z(rglob(i)))**2  )
+     tcen      = tshift + d/c0
+
+     ! wider window for data and synthetics FAR APART
+     tstart(i) = tcen - 3*hdur
+     tend(i)   = tcen + 3*hdur
+     !tstart(i) = tcen - 2*hdur
+     !tend(i)   = tcen + 2*hdur
+
+     write(*,'(i8,3f12.4)') i, tstart(i), tcen, tend(i)
+  enddo
+  print *
+
+  ! construct the adjoint source (IKER in wave2d_constants.f90)
+  !call make_adjoint_source(nrec, syn, tstart, tend, adj_syn, data)
+  call mtm_adj(IKER, ievent, nrec, syn, tstart, tend, adj_syn, data)
+
+  ! write out adjoint source time function at the receivers
+  stfadj_tag = 'stfadj'
+  if(WRITE_STF_A) call write_seismogram(adj_syn, nrec, trim(out_dir)//stfadj_tag)
+
+  !stop 'testing'
+
+  ! OUTPUT ASCII FILES --> SAC FILES (make_sac_files.pl)
+  ! (1) data, (2) synthetics, (3) adjoint source time function
+
+!!$  if(WRITE_SEISMO_F) then
+!!$     filename1 = trim(script_dir)//'make_sac_files.csh'
+!!$     filename2 = 'make_sac_files.pl'
+!!$     open(19,file=filename1,status='unknown')
+!!$         if(IKER <= 4) write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', &
+!!$             trim(out_dir),' ', trim(data_tag)  ,' ','1', tshift
+!!$                       write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', & 
+!!$             trim(out_dir),' ', trim(syn_tag)   ,' ','1', tshift
+!!$     if(WRITE_STF_A)   write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', &
+!!$             trim(out_dir),' ', trim(stfadj_tag),' ','1', tshift
+!!$     close(19)
+!!$     call system('chmod 755 scripts/make_sac_files.csh ; scripts/make_sac_files.csh')
+!!$  endif
+
+  ! misfit for each receiver for one event
+  chi_etot(ievent) = sum(chi(ievent,:,1,1))
+  print *,'---------------------------'
+  print *,'misfit for IKER = ',IKER
+  print *,'chi-tot = ', sum(chi(ievent,:,1,1))
+  print *,'---------------------------'
+  open(19,file=trim(out_dir)//'chi_r.dat',status='unknown')
+  do irec=1,nrec
+     write(19,'(3e16.6)') x_lon(rglob(irec)), z_lat(rglob(irec)), chi(ievent,irec,1,1)
+  enddo
+  close(19)
+
+  ! total misfit for one event
+  open(19,file=trim(out_dir)//'single_chi_r.dat',status='unknown')
+  write(19,*) sngl( sum(chi(ievent,:,1,1)) )
+  close(19)
+
+!!$  ! write ALL adjoint sources to file
+!!$  do ipick = 0,6
+!!$     call mtm_adj(ipick, ievent, nrec, syn, tstart, tend, adj_syn, data)
+!!$     write(stfadj_tag,'(a,i1)') 'stfadj-', ipick
+!!$     call write_source_function(nrec, ti, adj_syn, rglob, trim(out_dir)//stfadj_tag)
+!!$  enddo
+!!$
+!!$  ! plot ALL adjoint sources
+!!$  filename1 = trim(script_dir)//'make_sac_files.csh'
+!!$  filename2 = 'make_sac_files.pl'
+!!$  open(19,file=filename1,status='unknown')
+!!$  write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', trim(out_dir),' ', trim(data_tag)  ,' ',"1",tshift
+!!$  write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', trim(out_dir),' ', trim(syn_tag)   ,' ',"1",tshift
+!!$  do ipick = 0,6
+!!$     write(stfadj_tag,'(a,i1)') 'stfadj-', ipick
+!!$     write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', trim(out_dir),' ', trim(stfadj_tag),' ',"1",tshift
+!!$  enddo
+!!$  close(19)
+!!$  call system('chmod 755 scripts/make_sac_files.csh ; scripts/make_sac_files.csh')
+
+!stop 'testing adjoint sources'
+
+  !------------
+  ! we always evaluate the kernels for the present model
+  ! we only evaluate the kernel for the test model if itest==1 and POLY_ORDER==3
+
+  if(itest==0 .or. POLY_ORDER==3) then
+    print *
+    print *, 'compute the kernel via adjoint wavefield interaction'
+    print *
+
+    isolver = 3
+    allocate(rho_kernel(NGLOB), mu_kernel(NGLOB), kappa_kernel(NGLOB))
+
+    ! initialize source perturbation time series
+    allocate(three_source_model(NSTEP,NCOMP,nsrc,3))
+    three_source_model(:,:,:,:) = 0.
+
+    ! kernels
+    ! samp enters as the forward source time function,
+    ! and returns as the (time-reversed) adjoint seismograms
+    call solver(isolver, nsrc, sglob, ispec_src, hxis_store, hgammas_store, samp, &
+                         nrec, rglob, ispec_rec, hxir_store, hgammar_store, adj_syn, &
+                 trim(last_frame_name), absorb_field, &
+                 rho_kernel, mu_kernel, kappa_kernel, three_source_model, stf, f0)
+    
+      !call write_seismogram(three_source_model(:,:,:,1), nsrc, trim(out_dir)//'pert_src_m01')
+      !call write_seismogram(three_source_model(:,:,:,2), nsrc, trim(out_dir)//'pert_src_m02')
+      !call write_seismogram(three_source_model(:,:,:,3), nsrc, trim(out_dir)//'pert_src_m03')
+
+      !call write_seismogram(three_source_model(:,:,:,4), nsrc, trim(out_dir)//'pert_src_m04')
+      !call write_seismogram(three_source_model(:,:,:,5), nsrc, trim(out_dir)//'pert_src_m05')
+      !call write_seismogram(three_source_model(:,:,:,6), nsrc, trim(out_dir)//'pert_src_m06')
+      !call write_seismogram(three_source_model(:,:,:,7), nsrc, trim(out_dir)//'pert_src_m07')
+      !call write_seismogram(three_source_model(:,:,:,8), nsrc, trim(out_dir)//'pert_src_m08')
+        
+      print *
+      print *, ' to make the gradient for the source (unscaled)'
+      print *, DT*sum(three_source_model(:,1,1,1))
+      print *, DT*sum(three_source_model(:,1,1,2))
+      print *, DT*sum(three_source_model(:,1,1,3))
+
+      ! construct gradient vector
+      ! ievent controls where the values are placed
+      ! g(m) is the integrated time series times the source parameter
+      do i = 1,3    ! i = 1,2 to test mislocations only
+        itemp = (ievent-1)*3 + i
+        !source_gradient(itemp) = DT*sum(three_source_model(:,1,1,i)) * m_scale(i)
+        source_gradient(itemp) = DT*sum(three_source_model(:,1,1,i)) * m_scale_src(itemp)
+      enddo
+
+      ! summed kernel (global variable)
+      kernel_basis_sum(:) = kernel_basis_sum(:) + kernel_basis(:)
+
+    deallocate(three_source_model)
+    deallocate(rho_kernel, mu_kernel, kappa_kernel)
+
+    ! write out adjoint seismograms at the original sources
+    if(WRITE_SEISMO_A) call write_seismogram(samp, nsrc, trim(out_dir)//'synadj')
+
+  endif
+
+!stop 'testing adjoint sources'
+
+  ! deallocate variables associated with one event
+
+  deallocate(data, adj_syn, absorb_field)
+  deallocate(syn, tstart, tend)
+
+  deallocate(ispec_src_dat, xi_src_dat, gamma_src_dat)
+  deallocate(hxisd_store, hgammasd_store)
+  deallocate(samp_dat, sglob_dat)
+
+  deallocate(ispec_src, xi_src, gamma_src)
+  deallocate(hxis_store, hgammas_store)
+  deallocate(samp, sglob)
+
+  !=====================
+  enddo  ! ievent
+  !=====================
+
+  print *
+  print *, ' Done with all the events for irun =', irun
+  print *, ' Now we update the model, or compute a test model'
+
+  !  stop 'testing'
+
+  !-----------------------------------------------------
+  ! misfit values
+
+  ! summed chi value for each event (nevent by 1)
+  open(19,file=trim(out_dir1)//'summed_chi_e.dat',status='unknown')
+  do ievent=1,nevent
+     write(19,*) sngl( sum(chi(ievent,:,1,1)) )
+     !write(19,*) chi_etot(ievent)
+  enddo
+  close(19)
+
+  ! summed chi value for each receiver (nrec by 1)
+  open(19,file=trim(out_dir1)//'summed_chi_r.dat',status='unknown')
+  do irec=1,nrec
+     write(19,'(3e16.6)') x_lon(rglob0(irec)), z_lat(rglob0(irec)), sngl( sum(chi(:,irec,1,1)) )
+  enddo
+  close(19)
+
+  ! overall misfit for all events and all receivers
+  chi_val = sum(chi(:,:,1,1))
+  open(19,file=trim(out_dir1)//'summed_chi_all.dat',status='unknown')
+  write(19,*) chi_val
+  close(19)
+
+  ! write all nevent * nrec measurements to file
+  open(unit=18,file=trim(out_dir1)//'measure_vec.dat',status='unknown')
+  do i = 1,imeasure
+     write(18,'(1e20.10)') measure_vec(i)
+  enddo
+  close(18)
+  deallocate(measure_vec)
+
+  if(ISOURCE_LOG) write(91,'(a12,1f18.8)') ' chi(m) : ', chi_val
+
+  ! stopping criterion needs to be better defined (depends on misfit function --- and DT)
+  ! (We needed this for the basic source inversions.)
+  !if(chi_val <= 0.1 .and. itest==0) stop 'DONE: you have minimized chi(m) to chi(m) <= 0.1'
+
+  print *, ' Written chi values to file'
+  print *, ' Now we compute the gradient of the misfit function (using the misfit kernel)'
+
+  !-----------------------------------------------------
+  ! COMPUTE THE GRADIENT OF THE MISFIT FUNCTION, if the present model is not
+  ! a test model or if the CG polynomial is a cubic function
+  ! DO NOT smooth kernel for test model if quadratic polynomial is being used
+
+  if(itest==0 .or. POLY_ORDER==3) then
+
+     print *, ' Computing the gradient of the misfit function for a given model'
+     gradient(:) = 0.
+
+     if(INV_STRUCT == 1) then   ! smooth the kernels to remove spurious src-rec effects
+
+        ! summed kernel for all events (NGLOB by 1)
+        open(19,file=trim(out_dir1)//'summed_ker.dat',status='unknown')
+        do iglob=1,NGLOB
+           write(19,'(3e16.6)') x_lon(iglob), z_lat(iglob), sngl(kernel_basis_sum(iglob))
+        enddo
+        close(19)
+
+        !====================
+
+        k_rough_global(:) = kernel_basis_sum(:)
+
+        ! Gaussian half-width controlling the smoothing (m)
+        !dtrsh2 = (3.*sigma)**2  ! all points outside d^2 are set to zero
+        dtrsh2 = (9./8.)*gamma**2 
+
+        ! EXAMPLE gaussian smoothing function for one point
+        ! find the closest gridpoint to the target point
+        xtar = 0.5*LENGTH
+        ztar = 0.5*HEIGHT
+        dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+        do iglob = 1,NGLOB
+           d = sqrt((xtar-x(iglob))**2+(ztar-z(iglob))**2)
+           if(d < dmin) then
+              igaus = iglob
+              dmin = d
+           endif
+        enddo
+        xcen = x(igaus)
+        zcen = z(igaus)
+        k_gaus_global_ex(:) = 0.
+        do iglob = 1,NGLOB
+           dist2 = (xcen - x(iglob))**2 + (zcen - z(iglob))**2
+           if(dist2 <= dtrsh2) &
+                                !k_gaus_global_ex(iglob) = (1./(2*PI*sigma**2)) * exp(-dist2 / (2.*sigma**2))
+                k_gaus_global_ex(iglob) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+        enddo
+
+        ! compute the SMOOTHED kernel
+        k_smooth_global(:) = 0.
+        do iglob = 1,NGLOB
+
+           ! compute a Gaussian centered at the iglob point
+           ! (part of the Gaussian may be outside the grid)
+           xcen = x(iglob)
+           zcen = z(iglob)
+           k_gaus_global(:) = 0.
+           do i = 1,NGLOB
+              dist2 = (xcen - x(i))**2 + (zcen - z(i))**2
+              if(dist2 <= dtrsh2) &
+                 !k_gaus_global(i) = (1./(2.*PI*sigma**2)) * exp(-dist2 / (2.*sigma**2))
+                 k_gaus_global(i) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+           enddo
+
+!!$     ! compute the product of the Gaussian and the rough function, then sum
+!!$     k_temp(:,:,:) = 0.
+!!$     do ispec = 1,NSPEC
+!!$       do j = 1,NGLLZ
+!!$         do i = 1,NGLLX 
+!!$           itemp = ibool(i,j,ispec)
+!!$           k_temp(i,j,ispec) = k_rough_global(itemp) * k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+!!$         enddo
+!!$       enddo
+!!$     enddo
+!!$     k_smooth_global(iglob) = sum( k_temp(:,:,:) )
+
+           ! integrate the Gaussian over the grid
+           ! (this will be constant only for the interior Gaussians)
+           k_temp(:,:,:) = 0.
+           do ispec = 1,NSPEC
+              do j = 1,NGLLZ
+                 do i = 1,NGLLX 
+                    itemp = ibool(i,j,ispec)
+                    k_temp(i,j,ispec) = k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+                 enddo
+              enddo
+           enddo
+           k_gaus_int_global(iglob) = sum( k_temp(:,:,:) )
+
+           ! compute the product of the Gaussian and the rough function, then sum
+           ! normalization by k_gaus_int_global(iglob) accounts for Gaussians that are partially within the grid
+           k_temp(:,:,:) = 0.
+           do ispec = 1,NSPEC
+              do j = 1,NGLLZ
+                 do i = 1,NGLLX 
+                    itemp = ibool(i,j,ispec)
+                    k_temp(i,j,ispec) = k_rough_global(itemp) * k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+                 enddo
+              enddo
+           enddo
+           k_smooth_global(iglob) = sum( k_temp(:,:,:) ) / k_gaus_int_global(iglob)
+
+        enddo
+
+        ! write smooth-related functions to file
+        if(0==1) then
+          file_smooth = 'fun_smooth.dat'
+          open(unit=19,file=trim(out_dir1)//file_smooth,status='unknown')
+          do iglob = 1,NGLOB
+             write(19,'(8e16.6)') x_lon(iglob), z_lat(iglob), x(iglob), z(iglob), &
+                  k_rough_global(iglob), k_gaus_global_ex(iglob), &
+                  k_smooth_global(iglob), k_rough_global(iglob) - k_smooth_global(iglob)
+          enddo
+          close(19)
+        endif
+
+        ! plot rough function, Gaussian filter, smooth function, and residual
+        !filename1 = 'get_smooth.csh'
+        !filename2 = trim(script_dir)//'plot_smoothed_function.pl'
+        !open(19,file=filename1,status='unknown')
+        !write(19,'(5a,1e16.6)') trim(filename2),' ', trim(out_dir1),' ', &
+        !   trim(file_smooth), gamma
+        !close(19)
+        !call system('chmod 755 get_smooth.csh ; get_smooth.csh')
+
+     endif  ! INV_STRUCT
+
+     ! KEY: scaling parameter for structure for (joint) inversions
+     mfac = 1.0
+     if(istep==0) then
+        if(INV_SOURCE == 1 .and. INV_STRUCT == 1) then
+           ! scale structure parameters according to source
+           m_scale_str = mfac * sqrt( sum(source_gradient(:)*source_gradient(:)) )  &
+              / sqrt( sum(k_smooth_global(:)*k_smooth_global(:) *sqrt(da(:))*sqrt(da(:)) ))
+
+        else
+           ! scale model parameters to order of 0.01 variations
+           m_scale_str = sda_mean
+        endif
+     endif
+
+     print *
+     print *, ' Scaling parameter for structure gradient:'
+     print *, '   mfac = ', mfac
+     print *, '   F    = ', m_scale_str
+
+     if(INV_STRUCT == 1) then
+        ! KEY: compute gradient in 'irregular block' basis
+        ! (special case of local Lagrange polynomial basis)
+        do iglob = 1,NGLOB
+           !gradient(iglob) = k_smooth_global(iglob)
+           !gradient(iglob) = da(iglob) * k_smooth_global(iglob)
+           gradient(iglob) = k_smooth_global(iglob) * sqrt(da(iglob)) * m_scale_str  ! old version
+        enddo
+     endif  ! INV_STRUCT
+
+     ! fill the bottom of the model vector with source parameters
+     ! (dx,dy,dt) * nevent
+     if(INV_SOURCE == 1) gradient(nmod_str+1:nmod) = source_gradient(:)
+
+     ! write gradient vector to file
+     if(0==1) then
+       open(unit=19,file=trim(out_dir1)//'gradient_vec.dat',status='unknown')
+       do i = 1,nmod
+         write(19,'(1e20.10)') gradient(i)
+       enddo
+       close(19)
+     endif
+
+  endif  ! itest==0 .or. POLY_ORDER==3
+  
+  !====================
+  ! update search direction and model
+
+  print *, ' Entering CG algorithm to compute new model or test model'
+
+  if(itest==0) then      ! if the present kernel is for a REAL model
+
+     chi_k_val = chi_val
+     gk(:) = gradient(:)
+
+     ! the source model vector is always (0,0,0), since we are
+     ! looking at perturbations relative to THE LATEST source position
+     m0(:) = 0.
+
+     if(INV_STRUCT == 1) then
+
+       ! KEY: fractional pert from c0
+       do iglob = 1,nmod_str
+          !m0(iglob) = c_glob_syn(iglob) / c0 - 1.
+          !m0(iglob) = (c_glob_syn(iglob) / c0 - 1.) * da(iglob)
+          m0(iglob) = (c_glob_syn(iglob) / c0 - 1.) * sqrt(da(iglob)) / m_scale_str  ! old version
+       enddo
+     endif
+
+     if(INV_SOURCE == 1) then
+       ! scaled perturbation from initial source
+       do i = 1,nmod_src
+          m0(nmod_str+i) = (m_src(i) - m_src_syn(i)) / m_scale_src(i)
+       enddo
+     endif
+
+     ! update search direction
+     if(istep == 0) then
+        pk(:) = -gk(:)     ! initial search direction
+
+     else
+        beta_val = dot_product( gk, gk(:) - g0(:) ) / dot_product( g0, g0 )
+        pk(:) = -gk(:) + beta_val * p0(:)
+
+     endif
+
+     ! test value for line-search to get test model
+     !istep_switch = 6
+     !if(istep < istep_switch)  lam_t_val = -2.*chi_k_val / dot_product(gk, pk)    ! quadratic extrapolation
+     !if(istep >= istep_switch) lam_t_val =    -chi_k_val / dot_product(gk, pk)    ! linear extrapolation
+     lam_t_val = -2.*chi_k_val / dot_product(gk, pk) 
+     mt(:)     = m0(:) + lam_t_val * pk(:)
+     !mt(:)     = m0(:) + lam_t_val * pk(:) / da(:)    ! structure only (g = K da)
+     itest     = 1
+
+     do i=1,nmod
+       if(i <= nmod_str) then    ! structure
+
+          ! get the new (test) structure model in terms of fractional perturbation
+          if(INV_STRUCT == 0) then
+             mt_vec(i) = c_glob_syn(i)  ! use same structure always
+ 
+          else
+             !mt_vec(i) = c0 * (1. + mt(i))
+             !mt_vec(i) = c0 * (1. + mt(i)/ da(i) )
+             mt_vec(i) = c0 * (1. + mt(i)/sqrt(da(i))*m_scale_str )    ! old version
+          endif
+         
+       else                      ! source
+          ! get the new source model in terms of (xs, zs, t0)
+          if(INV_SOURCE == 0) then
+             !mt_vec(i) = m0_vec(i)   ! use same source always
+             mt_vec(i) = m_src_syn(i - nmod_str)
+
+          else
+             !mt_vec(i) = m0_vec(i) + mt(i)          
+             !mt_vec(i) = m0_vec(i) + mt(i)*m_scale_src(i - nmod_str)
+             !mt_vec(i) = m_src_syn(i - nmod_str) * (1. + mt(i))
+
+             mt_vec(i) = m_src_syn(i - nmod_str) + mt(i)*m_scale_src(i - nmod_str)
+
+          endif
+
+       endif
+     enddo
+
+     print *, 'lam_t_val = ', sngl(lam_t_val)
+
+     ! save for next run
+     g0(:) = gk(:)
+     p0(:) = pk(:)
+
+  elseif(itest==1) then  ! if present kernel is for a test model
+
+     chi_t_val = chi_val
+
+     ! a cubic or quadratic fit requires at least 5 values
+     xx1 = 0.
+     xx2 = lam_t_val
+     yy1 = chi_k_val
+     yy2 = chi_t_val
+     g1  = dot_product(g0,pk)
+
+     if(POLY_ORDER == 3) then
+        ! use cubic polynomial: six values gives an analytical minimum
+        ! see Matlab scripts cubic_min_4.m and cubic_min.m
+
+        ! compute gradient of test function (needed for cubic polynomial)
+        gt(:) = gradient(:)
+
+        ! reset source vector to zero
+        !m0(nmod_str+1:nmod) = 0.
+
+        g2 = dot_product(gt,pk)
+
+        ! coefficients of the cubic polynomial
+        Pa = ( -2.*(yy2-yy1) + (g1+g2)*(xx2-xx1) ) / (xx2-xx1)**3
+        Pb = ( 3.*(yy2-yy1) - (2.*g1 + g2)*(xx2-xx1) ) / (xx2-xx1)**2
+        Pc = g1
+        Pd = yy1
+
+        ! get the analytical minimum
+        qfac = Pb**2 - 3.*Pa*Pc;
+        if(Pa /= 0 .and. qfac >= 0) then
+           xmin = (-Pb + sqrt(qfac)) / (3.*Pa)
+        elseif(Pa == 0 .and. Pb /= 0) then
+           xmin = -Pc/(2.*Pb)
+        else
+           stop 'check the input polynomial'
+        endif
+
+        ! write cubic function parameters to file
+        open(unit=19,file=trim(out_dir1)//'cubic_poly.dat',status='unknown')
+        write(19,'(11e16.6)') xx1,xx2,yy1,yy2,g1,g2,Pa,Pb,Pc,Pd,xmin
+        close(19)
+
+     else
+        ! use quadratic polynomial: five values gives an analytical minimum
+        ! see Matlab script quad_min_4.m
+
+        ! coefficients of the quadratic polynomial (ax^2 + bx + c)
+        Pa = ((yy2 - yy1) - g1*(xx2 - xx1)) / (xx2**2 - xx1**2)
+        Pb = g1
+        Pc = yy1 - Pa*xx1**2 - Pb*xx1
+
+        ! get the analytical minimum (the vertex)
+        if(Pa /= 0) then
+           xmin = -Pb / (2.*Pa)
+        else
+           stop 'check the input polynomial'
+        endif
+
+        ! write quadratic function parameters to file
+        open(unit=19,file=trim(out_dir1)//'quad_poly.dat',status='unknown')
+        write(19,'(9e16.6)') xx1,xx2,yy1,yy2,g1,Pa,Pb,Pc,xmin
+        close(19)
+
+     endif  ! POLY_ORDER == 3
+
+     ! update model
+     lam_0_val = xmin
+     !m0(:) = m0(:) + lam_0_val * pk(:) / da(:)   ! structure only (g = K da)
+     m0(:) = m0(:) + lam_0_val * pk(:)
+     itest = 0
+
+     do i=1,nmod
+       if(i <= nmod_str) then    ! structure
+
+          ! get the new structure model in terms of fractional perturbation
+          if(INV_STRUCT == 0) then
+             m0_vec(i) = c_glob_syn(i)  ! use same structure always
+          
+          else
+             !m0_vec(i) = c0 * (1. + m0(i))
+             !m0_vec(i) = c0 * (1. + m0(i)/ da(i) )
+             m0_vec(i) = c0 * (1. + m0(i)/sqrt(da(i))*m_scale_str )    ! old version
+          endif
+         
+       else                      ! source
+          ! get the new source model in terms of (xs, zs, t0)
+          if(INV_SOURCE == 0) then
+             !m0_vec(i) = m0_vec(i)     ! use same source always
+             m0_vec(i) = m_src_syn(i - nmod_str)
+
+          else
+            !m0_vec(i) = m0_vec(i) + m0(i)
+            !m0_vec(i) = m0_vec(i) + m0(i)*m_scale_src(i - nmod_str)
+            !m0_vec(i) = m_src_syn(i - nmod_str) * (1. + m0(i))
+
+            m0_vec(i) = m_src_syn(i - nmod_str) +  m0(i)*m_scale_src(i - nmod_str)
+
+          endif
+
+       endif
+     enddo
+     
+     print *, 'lam_0_val = ', sngl(lam_0_val)
+
+  endif
+
+  !====================
+  ! write updated/test model to file (source + structure)
+
+  ! write CG vectors to file
+  if(1==1) then
+    open(unit=19,file=trim(out_dir1)//'cg_model_vectors.dat',status='unknown')
+    do i = 1,nmod
+      write(19,'(4e16.6)') m0(i), mt(i),  m0_vec(i), mt_vec(i)
+    enddo
+    close(19)
+  endif
+  if(0==1) then
+    open(unit=19,file=trim(out_dir1)//'cg_grad_vectors.dat',status='unknown')
+    do i = 1,nmod
+      write(19,'(5e16.6)') g0(i), gt(i), gk(i), p0(i), pk(i)
+    enddo
+    close(19)
+  endif
+
+  ! exit program if model values are unrealistic
+  ! NOTE: model parameters must be scaled appropriately
+  if(itest==1) then
+    if( minval(mt) < -10. .or. maxval(mt) > 10. ) stop 'test model is too extreme'
+  else
+    if( minval(m0) < -10. .or. maxval(m0) > 10. ) stop 'updated model is too extreme'
+  endif
+
+  !====================
+
+  !call system("xv model.jpg &")
+
+!==================================
+enddo  ! istep
+!==================================
+
+  if(ISOURCE_LOG) close(91)  ! source log file
+
+  ! deallocate event and receiver variables
+
+  deallocate(rglob,fglob)
+  deallocate(ispec_rec,xi_rec,gamma_rec)
+  deallocate(x_rec,z_rec,x_rec_lon,z_rec_lat)
+  deallocate(hxir_store, hgammar_store)
+
+  deallocate(eglob)
+  deallocate(ispec_eve,xi_eve,gamma_eve)
+  deallocate(x_eve,z_eve,x_eve_lon,z_eve_lat)
+  deallocate(hxie_store,hgammae_store)
+
+  deallocate(eglob_dat)
+  deallocate(ispec_eve_dat,xi_eve_dat,gamma_eve_dat)
+  deallocate(x_eve_dat,z_eve_dat,x_eve_lon_dat,z_eve_lat_dat)
+  deallocate(hxied_store, hgammaed_store)
+
+  deallocate(otime,otime_dat)
+
+  ! CG variables
+
+  deallocate(m0,mt,gradient)
+  deallocate(g0,gt,gk,p0,pk)
+  deallocate(source_gradient,m_scale_src)
+  deallocate(m0_vec,mt_vec)
+  deallocate(m_src,mt_src,m0_src,m_src_dat,m_src_syn)
+
+!=======================
+! COMMANDS FOR OMS RUNS
+!=======================
+!!$
+!!$  ! forward wavefield
+!!$  ! nsrc, sglob, samp : #src, src index, source
+!!$  ! nrec, rglob, syn  : #rec, rec index, seis
+!!$  isolver = 1
+!!$  call solver(isolver, nsrc, sglob, samp, nrec, rglob, syn)
+!!$
+!!$  ! write out seismograms at the receivers
+!!$  if(WRITE_SEISMO_F) call write_seismogram(syn, nrec, trim(out_dir)//'forward')
+!!$
+!!$  print *, 'compute and write out forward spectral map '
+!!$  call write_spectral_map(syn, nrec, rglob, trim(out_dir)//'spectral_forward',WRITE_SPECTRA_F)
+!!$
+!!$  ! bandpass filter the seismograms to create the adjoint sources
+!!$  !call filter(ti, syn, nrec)
+!!$
+!!$  ! nrecf, the number of (fake) receivers where we record the adjoint wavefield
+!!$  ! is different from the number of original sources, nsrc.
+!!$  ! this is a big memory burden -- perhaps we should write out the seismograms in blocks
+!!$  deallocate(samp)
+!!$  allocate(samp(NSTEP,NCOMP,nrecf))
+!!$  samp(:,:,:) = 0.0
+!!$
+!!$  ! adjoint receiver = fake receivers
+!!$  ! nrecf, fglob, samp : #a-rec, a-rec index, a-seis
+!!$  ! nrec,  rglob, syn  : #a-src, a-src index, source
+!!$  isolver = 2
+!!$  call solver(isolver, nrecf, fglob, samp, nrec, rglob, syn)
+!!$
+!!$  ! write out adjoint seismograms at the fake receivers
+!!$  if(WRITE_SEISMO_A) call write_seismogram(samp, nrecf, trim(out_dir)//'adjoint')
+!!$
+!!$  print *, 'compute and write out adjoint spectral map '
+!!$  call write_spectral_map(samp, nrecf, fglob, trim(out_dir)//'spectral_adjoint',WRITE_SPECTRA_A)
+!!$
+!!$  ! deallocate variables
+!!$  deallocate(sglob,samp,rglob,syn,fglob)
+
+!==================================
+
+!!$  ! adjoint receiver = original (forward) source
+!!$  ! nsrc, sglob, samp : #a-rec, a-rec index, a-seis
+!!$  ! nrec, rglob, syn  : #a-src, a-src index, source
+!!$  call solver(isolver, nsrc, sglob, samp, nrec, rglob, syn)
+!!$
+!!$  ! write out adjoint seismograms at the original sources
+!!$  if(WRITE_SEISMO_A) call write_seismogram(samp, nsrc, trim(out_dir)//'adjoint')
+
+!==================================
+
+  print *
+  print *, ' max time-step is ', NSTEP
+  print *, '  time-step DT is ', sngl(DT)
+  print *, '      max time is ', sngl(NSTEP*DT), ' s,', sngl(NSTEP*DT/60), ' min'
+  print *, ' space-step dh is ', sngl(dh)
+  print *
+  print *, '            c0 is ', sngl(c0)
+  print *, '          hdur is ', sngl(hdur)
+  print *, '    time shift is ', sngl(tshift)
+  print *
+
+  enddo  ! do iq
+
+end program wave2d
+ 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_cmap.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_cmap.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_cmap.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,368 @@
+program wave2d_cmap
+
+  use wave2d_variables
+  use wave2d_solver
+  use wave2d_sub
+  use wave2d_sub2
+  implicit none
+
+! wavefields and seismograms
+  double precision, dimension(:,:,:), allocatable :: samp, data, syn, adj_syn
+
+! socal coast and shelf data
+  integer :: UTM_PROJECTION_ZONE, FINITE_SOURCE
+  integer :: nshelf,ncoast,itemp
+  double precision :: d,dmin
+  double precision, dimension(:), allocatable :: shelf_lat,shelf_lon,shelf_z,shelf_x
+  double precision, dimension(:), allocatable :: coast_lat,coast_lon,coast_z,coast_x
+  character(len=200) :: shelf_file,coast_file
+
+! model variables
+  integer :: Nfac
+  double precision :: w_scale, afac
+
+! additional velocity models
+  double precision, dimension(NGLOB) :: c_glob_dat, c_glob_syn, m0, m0_vel
+
+! regular mesh for computing phase velocity
+!  integer :: ntemp, i_regular
+!  double precision, dimension(:), allocatable :: x9,z9,x_lon9,z_lat9,da9
+!  double precision, dimension(:), allocatable :: c_glob_dat9, c_glob_syn9, c_glob9
+!  double precision :: fac
+
+  double precision :: xtemp,ztemp,dx,dz,xmesh,zmesh
+  double precision :: t_target, tcen
+  double precision :: junk1,junk2,junk3
+
+  double precision :: temp1,temp2,temp3,temp4
+
+! smoothing
+  integer :: igaus
+  double precision :: dist2, dtrsh2, xtar, ztar, xcen, zcen
+  double precision, dimension(NGLOB) :: k_rough_global, k_smooth_global
+  double precision, dimension(NGLOB) :: k_gaus_global, k_gaus_global_ex, k_gaus_int_global, da
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: k_temp
+  !double precision, dimension(NLOCAL) :: gk_local, m0_local, mt_local, mt2_local, da_local
+  !integer, dimension(NLOCAL) :: ibool2
+  character(len=200) :: file_smooth
+
+  character(len=20)  :: data_tag,syn_tag,stf_tag,stfadj_tag
+  character(len=200) :: srcfile,recfile,socal_map
+  character(len=200) :: socal_dir, model_dir, script_dir, out_dir2, out_dir1, ev_dir
+  character(len=200) :: filename, filename1, filename2, file_dat_c, file_syn_c, file_src_rec, file_stf
+
+  integer :: i, j, k, itime, iglob, irec, isrc, ipick, ievent, icomp
+  integer :: isolver, irun0, irun, idat, iopt, ispec, istep
+
+  !********* PROGRAM STARTS HERE *********************
+ 
+  irun0 = 420
+
+  !out_dir2   = "OUTPUT/"
+  in_dir     = "INPUT/"
+  script_dir = "scripts/"
+
+  socal_dir = '/home/carltape/socal_modes/local_modes/'
+  model_dir = 'model_files/'
+
+  UTM_PROJECTION_ZONE = 11
+
+!--------------------------------------
+
+  print *
+  print *, ' max time-step is ', NSTEP
+  print *, '            DT is ', sngl(DT)
+  print *, '      max time is ', sngl(NSTEP*DT), ' s,', sngl(NSTEP*DT/60), ' min'
+  print *
+
+!--------------------------------------
+! mesher
+
+  ! set up model (gets Jacobian)
+  call mesher()
+
+  ! da vector
+  da(:) = 0.
+  do ispec = 1,NSPEC
+    do j = 1,NGLLZ
+      do i = 1,NGLLX 
+        iglob     = ibool(i,j,ispec)
+        da(iglob) = da(iglob) + wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+      enddo
+    enddo
+  enddo
+
+  print *
+  write(*,'(a,2f20.10)') '     da(min/max) : ', minval(da), maxval(da)
+  write(*,*)             '      sum [ da ] : ', sum(da)
+  write(*,*)             ' LENGTH * HEIGHT : ', LENGTH * HEIGHT
+  print *
+  write(*,*)             '           SIGMA : ', SIGMA
+  write(*,*)             '           irun0 : ', irun0
+  write(*,*)             '            IKER : ', IKER
+  print *
+  print *, ' GLL weights:'
+  do i=1,NGLLX
+     print *, wxgll(i)
+  enddo
+  do i=1,NGLLZ
+     print *, wzgll(i)
+  enddo
+
+  ! determine the UTM coordinates of your origin
+  print *
+  print *, 'UTM check for origin of mesh:'
+  print *, LON_MIN,LAT_MIN
+  call utm_geo(LON_MIN,LAT_MIN,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+  print *, utm_xmin, utm_zmin
+  call utm_geo(xtemp,ztemp,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+  print *, xtemp,ztemp   ! should match LON_MIN,LAT_MIN
+  print *
+
+!!$  ! regular mesh or SPECFEM mesh
+!!$  i_regular = 0
+!!$
+!!$  if(i_regular==1) then
+!!$
+!!$     ! enter new uniform mesh
+!!$     dx = 40.0d+03
+!!$     dz = dx
+!!$     fac = 10.0d+03
+!!$     k = 0
+!!$     do xtemp = -fac,LENGTH+fac,dx
+!!$        do ztemp = -fac,HEIGHT+fac,dz
+!!$           k = k+1
+!!$        enddo
+!!$     enddo
+!!$     ntemp = k
+!!$
+!!$  else
+!!$     ntemp = NGLOB
+!!$  endif
+!!$
+!!$  allocate(x9(ntemp),z9(ntemp),x_lon9(ntemp),z_lat9(ntemp))
+!!$  allocate(c_glob9(ntemp),c_glob_syn9(ntemp),c_glob_dat9(ntemp))
+!!$  allocate(da9(ntemp))
+!!$
+!!$  if(i_regular==1) then
+!!$
+!!$     k = 0
+!!$     do xtemp = -fac,LENGTH+fac,dx
+!!$        do ztemp = -fac,HEIGHT+fac,dz
+!!$     !do i=utm_xmin-fac,utm_xmin+LENGTH+fac,dx
+!!$     !   do j=utm_zmin-fac,utm_zmin+HEIGHT+fac,dz
+!!$           k = k+1
+!!$           x9(k) = xtemp
+!!$           z9(k) = ztemp
+!!$        enddo
+!!$     enddo
+!!$
+!!$     da9(:) = LENGTH*HEIGHT/ntemp
+!!$
+!!$  else
+!!$     x9(:) = x(:)
+!!$     z9(:) = z(:)
+!!$     da9(:) = da(:)
+!!$  endif
+
+  print *, NGLOB, ' gridpoints for which we compute a phase velocity'
+  print *, 'x-range is: ', minval(x), maxval(x)
+  print *, 'z-range is: ', minval(z), maxval(z)
+
+  !stop 'testing'
+
+  ! convert global gridpoint mesh coordinates to lat-lon
+  x_lon(:) = 0.
+  z_lat(:) = 0. 
+  call mesh_geo(NGLOB,x_lon,z_lat,x,z,UTM_PROJECTION_ZONE,IMESH2LONLAT)
+  !write(*,'(2f16.6)') (x_lon(iglob), z_lat(iglob), iglob=1,NGLOB)
+
+  !stop 'testing'
+
+!--------------------------------------
+! phase velocity model
+
+  t_target = 2*hdur     ! target period for phase velocity map
+
+     ! write lat-lon gridpoints to file
+     filename = trim(socal_dir) // 'socal_input.dat'
+     print *, 'Output data file is ',trim(filename)
+     open(unit=15,file=filename,status='unknown')
+     write(15,*) t_target
+     write(15,*) 0
+     write(15,*) UTM_PROJECTION_ZONE
+     write(15,*) NGLOB
+     write(15,*) (x_lon(iglob),z_lat(iglob),iglob=1,NGLOB)
+     close(15)
+
+     ! run wave2d_socal.f90 to create output file
+     ! KEY NOTE: must run this each time you change the grid, hdur, or IMODEL
+     call system(trim(model_dir) // 'get_socal_map.csh')
+
+     ! read in phase velocity map
+     !write(infile,'(a,a,i4.4,a)') trim(socal_dir), 'socal_T', int(100*t_target),'.dat'
+     socal_map = 'socaltest.dat'
+     open(unit=16, file = trim(model_dir)//socal_map, status='unknown')
+     read(16,*) (junk1,junk2,c_glob(iglob),junk3,iglob=1,NGLOB)
+     close(16)
+
+     ! read in reference phase velocity (km/s)
+     filename = trim(model_dir) // 'socaltest2.dat'
+     open(unit=17,file=filename,status='unknown')
+     read(17,*) c0
+     close(17)
+     
+     ! convert km/s --> m/s
+     c_glob(:) = 1000.*c_glob(:)
+     c0 = c0*1000.
+
+     c_glob_syn(:) = c0       ! c-maps for synthetics
+
+  !============================================
+  ! smooth the Gaussian according to SIGMA
+
+  k_rough_global(:) = c_glob(:)/c0 - 1.
+
+  ! Gaussian half-width controlling the smoothing (m)
+  dtrsh2 = (3.*SIGMA)**2  ! all points outside d^2 are set to zero
+
+  ! EXAMPLE gaussian smoothing function for one point
+  ! find the closest gridpoint to the target point
+  xtar = 0.7*LENGTH
+  ztar = 0.5*HEIGHT
+  dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+  do iglob = 1,NGLOB
+    d = sqrt((xtar-x(iglob))**2+(ztar-z(iglob))**2)
+    if(d < dmin) then
+       igaus = iglob
+       dmin = d
+    endif
+  enddo
+  xcen = x(igaus)
+  zcen = z(igaus)
+  k_gaus_global_ex(:) = 0.
+  do iglob = 1,NGLOB
+     dist2 = (xcen - x(iglob))**2 + (zcen - z(iglob))**2
+     if(dist2 <= dtrsh2) &
+        k_gaus_global_ex(iglob) = (1./(2*PI*SIGMA**2)) * exp(-dist2 / (2.*SIGMA**2))
+  enddo
+
+  ! compute the SMOOTHED kernel
+  k_smooth_global(:) = 0.
+  k_gaus_int_global(:) = 0.
+  do iglob = 1,NGLOB
+     ! compute a Gaussian centered at the iglob point
+     xcen = x(iglob)
+     zcen = z(iglob)
+     k_gaus_global(:) = 0.
+     do i = 1,NGLOB
+        dist2 = (xcen - x(i))**2 + (zcen - z(i))**2
+        if(dist2 <= dtrsh2) &
+           k_gaus_global(i) = (1./(2.*PI*SIGMA**2)) * exp(-dist2 / (2.*SIGMA**2))
+     enddo
+
+     ! integrate the Gaussian over the grid
+     ! (this will be constant only for the interior Gaussians)
+     k_temp(:,:,:) = 0.
+     do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+         do i = 1,NGLLX 
+           itemp = ibool(i,j,ispec)
+           k_temp(i,j,ispec) = k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+         enddo
+       enddo
+     enddo
+     k_gaus_int_global(iglob) = sum( k_temp(:,:,:) )
+
+
+     ! compute the product of the Gaussian and the rough function, then sum
+     k_temp(:,:,:) = 0.
+     do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+         do i = 1,NGLLX 
+           itemp = ibool(i,j,ispec)
+           k_temp(i,j,ispec) = k_rough_global(itemp) * k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+         enddo
+       enddo
+     enddo
+     k_smooth_global(iglob) = sum( k_temp(:,:,:) ) / k_gaus_int_global(iglob)
+  enddo
+
+  do i=1,NGLOB
+     print *, k_gaus_int_global(i)
+  enddo
+
+  !============================================
+  
+  !k_smooth_global(:) = c_glob(:)
+
+  ! c-maps for data
+  c_glob_dat(:) = c0*(1. + k_smooth_global(:) )
+
+  ! write data phase velocity map to file
+  file_dat_c = 'socal_vel_dat.dat'
+  open(unit=18,file=file_dat_c,status='unknown')
+  do iglob = 1,NGLOB
+     write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_dat(iglob)), sngl(c_glob_dat(iglob)/c0 - 1.)
+  enddo
+  close(18)
+
+  ! write syn phase velocity map to file
+  ! (reference model is 0% perturbation)
+  file_syn_c = 'socal_vel_syn.dat'
+  open(unit=18,file=file_syn_c,status='unknown')
+  do iglob = 1,NGLOB
+     write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_syn(iglob)), sngl(c_glob_syn(iglob)/c0 - 1.)
+  enddo
+  close(18)
+
+  cmin = minval(c_glob)
+  cmax = maxval(c_glob)
+
+!!$  ! plot phase velocity map for synthetics (and data)
+!!$  iopt = 1 + idat
+!!$  filename1 = 'get_model.csh'
+!!$  filename2 = trim(script_dir)//'plot_model.pl'
+!!$  open(19,file=filename1,status='unknown')
+!!$  write(19,'(4a,i5,3a,2f12.6,2a)') trim(filename2),' ', trim(out_dir2),' ', &
+!!$     iopt, ' ', trim(file_syn_c), ' ', sngl(c0), sngl(t_target),' ',trim(file_dat_c)
+!!$  close(19)
+!!$  call system('chmod 755 get_model.csh ; get_model.csh')
+
+  ! write smooth-related functions to file
+  file_smooth = 'fun_smooth.dat'
+  open(unit=19,file=file_smooth,status='unknown')
+  do iglob = 1,NGLOB
+     write(19,'(6e16.6)') x(iglob), z(iglob), &
+        k_rough_global(iglob), k_gaus_global_ex(iglob), &
+        k_smooth_global(iglob), k_rough_global(iglob) - k_smooth_global(iglob)
+  enddo
+  close(19)
+
+  ! plot rough function, Gaussian filter, smooth function, and residual
+  filename1 = 'get_smooth.csh'
+  filename2 = trim(script_dir)//'plot_smoothed_function.pl'
+  open(19,file=filename1,status='unknown')
+  write(19,'(5a,1e16.6)') trim(filename2),' ', '.',' ',trim(file_smooth), SIGMA
+  close(19)
+  call system('chmod 755 get_smooth.csh ; get_smooth.csh')
+
+  ! assign model parameters to gridpoints
+  ihomo = 0
+  call set_model_property()
+
+  print *, 'Velocities in km/s :'
+  print *, '  S     :', sngl(sqrt(RIGIDITY/DENSITY)/1000.)
+  print *, '  cmin  :', sngl(cmin/1000.)
+  print *, '  c0    :', sngl(c0/1000.)
+  print *, '  cmax  :', sngl(cmax/1000.)
+  print *
+  print *, ' actual  rigidity (Pa-s)       : ', sngl(RIGIDITY)
+  print *, ' desired rigidity (Pa-s), cmin : ', sngl(DENSITY * cmin**2)
+  print *, ' desired rigidity (Pa-s), c0   : ', sngl(DENSITY * c0**2)
+  print *, ' desired rigidity (Pa-s), cmax : ', sngl(DENSITY * cmax**2)
+
+  !deallocate(x,z,x_lon,z_lat,c_glob,c_glob_syn,c_glob_dat)
+
+end program wave2d_cmap
+ 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_constants.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_constants.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_constants.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,185 @@
+module wave2d_constants
+
+!
+! GRID, TIME-STEP, AND SOURCE PARAMETERS
+!
+
+! NFRAME : number of frames to save
+! NSAVE  : timestep increment to save the wavefield
+! NSTEP  : number of timesteps
+  integer, parameter :: NFRAME = 10    ! 10,12,17
+  integer, parameter :: NSAVE  = 400   ! 400
+  integer, parameter :: NSTEP  = NFRAME*NSAVE
+
+! time step in seconds
+  double precision, parameter :: DT = 6.0d-02 ! (0.02)
+
+! temporal properties of source (source time function)
+  integer, parameter :: ISRC_TIME = 1                   ! type (1)
+  double precision, parameter :: hdur = 10.0            ! HALF-duration (s)
+  double precision, parameter :: tshift = 2.*DT*NSAVE   ! time shift (s)
+  !double precision, parameter :: tshift = 8.*hdur
+  logical, parameter :: SRC_TAPER  = .true.
+
+! spatial properties of sources
+! (1) point source, (2) finite segment, (3) CA shelf boundary, (4) CA coast, (5) finite circle
+! (6) a point source EVENT
+  integer, parameter :: ISRC_SPACE = 6  ! see wave2d.f90
+
+! spatial properties of receivers
+! IREC_SPACE
+!   (1) individual station(s)
+!   (2) SoCal (used for GJI paper)
+!   (3) regular mesh on land
+!   (4) regular mesh
+! NMESH_REC : determines the number of receivers in a regular mesh (IREC_SPACE=3)
+! STATION_GRID_BUFFER : exclude stations within this distance from edge of grid
+! STATION_COAST_BUFFER : exclude stations within this distance from edge of coast
+  integer, parameter          :: IREC_SPACE = 2 ! see wave2d.f90
+  integer, parameter          :: NMESH_REC = 10
+  double precision, parameter :: SOURCE_GRID_BUFFER   = 4.0d+03  ! m 
+  double precision, parameter :: STATION_GRID_BUFFER  = 15.0d+03 ! m
+  double precision, parameter :: STATION_COAST_BUFFER = 0.0d+03  ! m
+
+! model specification for c(th,ph)
+! (0) het map, (1) homo map, (2) checkerboard, (3) read in
+  !integer, parameter          :: IMODEL = 3
+
+! bounds for bandpass filter (in seconds), see also below (fmin,etc)
+  double precision, parameter :: hwid = 3.0  ! HALF-width of window
+  double precision, parameter :: tmin = 2.*hdur-hwid
+  double precision, parameter :: tmax = 2.*hdur+hwid
+
+! mesh specifications
+  double precision, parameter :: LENGTH = 480.0d+03 ! m (200)
+  double precision, parameter :: HEIGHT = 480.0d+03 ! m (80)
+  integer, parameter :: NEX = 40 !40
+  integer, parameter :: NEZ = 40 !40
+  double precision, parameter :: LAT_MIN = 32.0d0
+  double precision, parameter :: LON_MIN = -120.d0
+
+! boolean parameters
+! IKER: (0) waveform
+!       (1) traveltime, cross-correlation, misfit
+!       (2) amplitude, cross-correlation, misfit
+!       (3) traveltime, multitaper
+!       (4) amplitude, multitaper
+!       (5) traveltime, cross-correlation, sampling
+!       (6) amplitude, cross-correlation, sampling
+  integer, parameter :: IKER = 1
+  integer, parameter :: ISURFACE = 1, NCOMP = 1, NABSORB = 4   ! surface waves
+!  integer, parameter :: ISURFACE = 0, NCOMP = 3, NABSORB = 3   ! body waves
+
+! iteration and smoothing parameters
+!  logical, parameter :: IUPDATE = .false.
+  integer, parameter :: NITERATION = 0
+  integer, parameter :: POLY_ORDER = 2             ! 2 (equally good) or 3
+  !double precision, parameter :: SIGMA = 10.0d+03 ! m
+
+! parameters controlling what to write to file
+! NOTE: for the tomography simulations, ALL of these can be .false.
+
+  logical, parameter :: WRITE_STF_F           = .false.
+  logical, parameter :: WRITE_SEISMO_F        = .false.    ! true
+  logical, parameter :: WRITE_SPECTRA_F       = .false.
+  logical, parameter :: WRITE_SPECTRAL_MAP_F  = .false.
+
+  logical, parameter :: WRITE_STF_A           = .false.
+  logical, parameter :: WRITE_SEISMO_A        = .false. 
+  logical, parameter :: WRITE_SPECTRA_A       = .false. 
+  logical, parameter :: WRITE_SPECTRAL_MAP_A  = .false.
+
+  logical, parameter :: WRITE_KERNELS = .false.    ! kernel snapshots
+  logical, parameter :: WRITE_SNAPSHOTS = .false.  ! wavefield snapshots
+  
+
+! MODEL (S.I. units)
+  double precision, parameter :: DENSITY = 2.6d+03 ! kg/m^3
+  double precision, parameter :: INCOMPRESSIBILITY = 5.2d+10 ! Pa
+  double precision, parameter :: RIGIDITY = 2.66d+10 ! Pa
+
+!---------------------------------------------------------------
+! CHT: do not change these
+
+! UTM zone for Southern California region 
+!  integer, parameter :: UTM_PROJECTION_ZONE = 11
+
+! to suppress UTM projection for SCEC benchmarks
+  logical, parameter :: SUPPRESS_UTM_PROJECTION = .false.
+
+! flag for projection from latitude/longitude to UTM, and back
+  integer, parameter :: ILONGLAT2UTM = 0, IUTM2LONGLAT = 1
+
+! flag for projection from latitude/longitude to mesh-UTM, and back
+  integer, parameter :: ILONLAT2MESH = 0, IMESH2LONLAT = 1
+
+! max number of fake receivers
+  integer, parameter :: MAX_SR_FAKE = 1000
+
+! max number of events, receivers, and phass
+  integer, parameter :: MAX_EVENT = 50
+  integer, parameter :: MAX_SR    = 1400
+  integer, parameter :: MAX_PHASE = 1
+  integer, parameter :: MAX_COMP  = NCOMP
+
+! parameter for FFTW
+  integer, parameter :: NOUT = NSTEP/2 + 1
+
+! filter parameters for bandpass
+  double precision, parameter :: fmin = 1./tmax, fmax = 1./tmin
+  double precision, parameter :: trbdndw = 0.3, a = 30.
+  integer, parameter :: passes = 2, iord = 4
+
+!---------------------------------------------------------------
+!
+! GRID AND GLL POINTS
+!
+  integer, parameter :: NELE = MAX(NEX,NEZ)
+  integer, parameter :: NSPEC = NEX*NEZ
+
+! number of GLL points (polynomial degree plus one)
+  integer, parameter :: NGLLX = 5
+  integer, parameter :: NGLLZ = 5
+  integer, parameter :: NGLL = MAX(NGLLX,NGLLZ)
+
+! number of points per surface element
+  integer, parameter :: NGLLSQUARE = NGLLX * NGLLZ
+
+! number of global points
+  integer, parameter :: NGLOB = ((NGLLX-1)*NEX + 1)*((NGLLZ-1)*NEZ +1)
+
+! number of local points
+  integer, parameter :: NLOCAL = NGLLX * NGLLZ * NSPEC
+
+! number of nodes for 2D and 3D shape functions for hexahedra
+! we use 8-node mesh bricks, which are more stable than 27-node elements
+  integer, parameter :: NGNOD = 8, NGNOD2D = 4
+  
+! number of iterations to solve the system for xi and eta
+  integer, parameter :: NUM_ITER = 1
+
+! very large and very small values
+  double precision, parameter :: HUGEVAL = 1.d+30, TINYVAL = 1.d-9
+
+! for the Gauss-Lobatto-Legendre points and weights
+  double precision, parameter :: GAUSSALPHA = 0.d0,GAUSSBETA = 0.d0
+
+!
+! CONSTANTS
+!
+! pi
+  double precision, parameter :: PI = 3.141592653589793d+00
+  double precision, parameter :: FOUR_THIRDS = 4.d0/3.d0
+  double precision, parameter :: ONE_THIRD = 1.d0/3.d0
+  double precision, parameter :: ONEOVERTWO = 0.5d0
+  double precision, parameter :: EPS = 1.0d-35
+  double precision, parameter :: DEG = 180./PI
+
+! normalization factor of point source force
+  double precision, parameter :: FNORM = 1.0d10
+
+! factors from the multitaper method
+  integer, parameter :: MAXTAPER=5, NDIM=8000*4, lnpt=14, npt=2**lnpt
+  double precision, parameter :: wtr=0.02, ZZIGN=-1.0
+
+end module wave2d_constants

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_define_der_matrices.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_define_der_matrices.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_define_der_matrices.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,65 @@
+module wave2d_define_der_matrices
+
+  use wave2d_constants
+
+contains
+
+  subroutine define_derivative_matrices(xigll,zigll,wxgll,wzgll,hprime_xx,hprime_zz,wgllwgll_xz)
+
+  implicit none
+ 
+! Gauss-Lobatto-Legendre points of integration
+  double precision, dimension(NGLLX) :: xigll
+  double precision, dimension(NGLLZ) :: zigll
+
+! weights
+  double precision, dimension(NGLLX) :: wxgll
+  double precision, dimension(NGLLZ) :: wzgll
+
+! array with derivatives of Lagrange polynomials
+  double precision, dimension(NGLLX,NGLLX) :: hprime_xx
+  double precision, dimension(NGLLZ,NGLLZ) :: hprime_zz
+  double precision, dimension(NGLLX,NGLLZ) :: wgllwgll_xz
+
+! array with all the weights in the square
+  double precision, dimension(NGLLX,NGLLZ) :: wgll_square
+
+! function for calculating derivatives of Lagrange polynomials
+  double precision, external :: lagrange_deriv_GLL
+
+  integer i1,i2,k1,k2,i,k
+
+! $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+! set up coordinates of the Gauss-Lobatto-Legendre points
+  call zwgljd(xigll,wxgll,NGLLX,GAUSSALPHA,GAUSSBETA)
+  call zwgljd(zigll,wzgll,NGLLZ,GAUSSALPHA,GAUSSBETA)
+
+! if number of points is odd, the middle abscissa is exactly zero
+  if(mod(NGLLX,2) /= 0) xigll((NGLLX-1)/2+1) = 0.d0
+  if(mod(NGLLZ,2) /= 0) zigll((NGLLZ-1)/2+1) = 0.d0
+
+! calculate derivatives of the Lagrange polynomials
+! and precalculate some products in double precision
+! hprime(i,j) = h'_i(xigll_j) by definition of the derivative matrix
+  do i1=1,NGLLX
+    do i2=1,NGLLX
+      hprime_xx(i1,i2) = lagrange_deriv_GLL(i1-1,i2-1,xigll,NGLLX)
+    enddo
+  enddo
+
+  do k1=1,NGLLZ
+    do k2=1,NGLLZ
+      hprime_zz(k1,k2) = lagrange_deriv_GLL(k1-1,k2-1,zigll,NGLLZ)
+    enddo
+  enddo
+
+  do i=1,NGLLX
+    do k=1,NGLLZ
+      wgllwgll_xz(i,k) = wxgll(i)*wzgll(k)
+    enddo
+  enddo
+
+end subroutine define_derivative_matrices
+
+end module wave2d_define_der_matrices
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_solver.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_solver.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_solver.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,1159 @@
+module wave2d_solver
+
+  use wave2d_constants
+  use wave2d_variables
+  use wave2d_define_der_matrices
+
+  implicit none
+
+contains
+
+  subroutine mesher
+
+    integer ispec,ib,i,j,k,iglob,iglob1,itime,ix,iz
+
+    ! set up grid and spectral elements
+    call define_derivative_matrices(xigll,zigll,wxgll,wzgll,hprime_xx,hprime_zz,wgllwgll_xz)
+
+    ispec = 0
+    iglob = 0
+    nspecb(:) = 0
+
+    ! loop over all elements
+    do iz = 1,NEZ
+       do ix = 1,NEX
+          ispec = ispec+1
+
+          ! evenly spaced anchors between 0 and 1
+          x1(ispec) = LENGTH*dble(ix-1)/dble(NEX)
+          x2(ispec) = LENGTH*dble(ix)/dble(NEX)
+          z1(ispec) = HEIGHT*dble(iz-1)/dble(NEZ)
+          z2(ispec) = HEIGHT*dble(iz)/dble(NEZ)
+
+          ! loop over GLL points to calculate jacobian, and set up numbering
+          !
+          ! jacobian = | dx/dxi dx/dgamma | = (z2-z1)*(x2-x1)/4  as dx/dgamma=dz/dxi = 0
+          !            | dz/dxi dz/dgamma | 
+          !
+          do j = 1,NGLLZ
+             do i = 1,NGLLX
+
+                ! jacobian, integration weight
+                dxidx(i,j,ispec) = 2. / (x2(ispec)-x1(ispec))
+                dxidz(i,j,ispec) = 0.
+                dgammadx(i,j,ispec) = 0.
+                dgammadz(i,j,ispec) = 2. / (z2(ispec)-z1(ispec))
+                jacobian(i,j,ispec) = (z2(ispec)-z1(ispec))*(x2(ispec)-x1(ispec)) / 4. 
+
+                ! set up local to global numbering
+                if ( (i.eq.1).and.(ix.gt.1) ) then
+                   ibool(i,j,ispec) = ibool(NGLLX,j,ispec-1)
+                else if ( (j.eq.1).and.(iz.gt.1) ) then
+                   ibool(i,j,ispec) = ibool(i,NGLLZ,ispec-NEX)
+                else
+                   iglob = iglob + 1
+                   ibool(i,j,ispec) = iglob         
+                endif
+
+                ! get the global gridpoints
+                iglob1 = ibool(i,j,ispec)
+                x(iglob1) = 0.5*(1.-xigll(i))*x1(ispec)+0.5*(1.+xigll(i))*x2(ispec)
+                z(iglob1) = 0.5*(1.-zigll(j))*z1(ispec)+0.5*(1.+zigll(j))*z2(ispec)
+
+                ! end loop over GLL points
+             end do
+          end do
+
+          ! if boundary element
+          ! 1,2,3,4 --> left, right, bottom, top
+          if (ix.eq.1) then      ! left boundary
+             nspecb(1) = nspecb(1) + 1
+             ibelm(1,nspecb(1)) = ispec
+             do j = 1,NGLLZ
+                jacobianb(1,j,nspecb(1))= (z2(ispec)-z1(ispec))/2.
+             end do
+          endif
+          if (ix.eq.NEX) then    ! right boundary
+             nspecb(2) = nspecb(2) + 1
+             ibelm(2,nspecb(2)) = ispec
+             do j = 1,NGLLZ
+                jacobianb(2,j,nspecb(2))= (z2(ispec)-z1(ispec))/2.
+             end do
+          endif
+          if (iz.eq.1) then      ! bottom boundary
+             nspecb(3) = nspecb(3) + 1
+             ibelm(3,nspecb(3)) = ispec
+             do i = 1,NGLLX
+                jacobianb(3,i,nspecb(3))= (x2(ispec)-x1(ispec))/2.
+             end do
+          endif
+          if (iz.eq.NEZ) then    ! top boundary
+             nspecb(4) = nspecb(4) + 1
+             ibelm(4,nspecb(4)) = ispec
+             do i = 1,NGLLX
+                jacobianb(4,i,nspecb(4))= (x2(ispec)-x1(ispec))/2.
+             end do
+          endif
+          ! end loop over elements
+       end do
+    end do
+
+!!$    do ibb=1,4
+!!$       print *, ibb, nspecb(ibb)
+!!$    enddo
+!!$    print *
+!!$    print *
+!!$    do ibb=1,4
+!!$       do ispec=1,nspecb(ibb)
+!!$          print *, ibb, ispec, ibelm(ibb,ispec)
+!!$       enddo
+!!$    enddo
+!!$    stop 'testing the boundary indexing'
+
+    ! estimate the time step
+    dh = HEIGHT/dble((NGLLZ-1)*NEZ)
+    if(dh > LENGTH/dble((NGLLX-1)*NEX)) dh = LENGTH/dble((NGLLX-1)*NEX)
+    c = sqrt((INCOMPRESSIBILITY+FOUR_THIRDS*RIGIDITY)/DENSITY)
+    time_step = 0.2*dh/c
+    print *
+    print *,'space step (km):', sngl(dh/1000.)
+    print *,'time step estimate from courant = 0.2: ',sngl(time_step),' seconds'
+    print *,'  actual time step: ',sngl(DT),' seconds'
+   
+  end subroutine mesher
+
+  !-------------------------------------------------------
+
+  subroutine set_model_property()
+
+    integer :: ispec, i, j, iglob
+
+    ! model properties -- globally defined (no discontinuities permitted this way)
+    do iglob = 1,NGLOB
+       rho_global(iglob)   = DENSITY
+       kappa_global(iglob) = INCOMPRESSIBILITY
+       if(ISURFACE==0) then
+          mu_global(iglob) = RIGIDITY
+       else
+          ! KEY: this means that the S velocity will be the surface wave phase velocity (m/s)
+          mu_global(iglob) = DENSITY*(c_glob(iglob))**2
+          !if(ihomo==1) mu_global(iglob) = DENSITY*c0**2
+          !if(ihomo==0) mu_global(iglob) = DENSITY*(c_glob(iglob))**2
+       endif
+    enddo
+
+    ! fill local arrays from global vectors
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX 
+             iglob = ibool(i,j,ispec)
+             rho(i,j,ispec)   = rho_global(iglob)
+             kappa(i,j,ispec) = kappa_global(iglob)
+             mu(i,j,ispec)    = mu_global(iglob)
+          end do
+       end do
+    end do
+
+!!$    ! properties
+!!$    do ispec = 1,NSPEC
+!!$       !  get center of element
+!!$       iglob = ibool(NGLLX/2,NGLLZ/2,ispec)
+!!$       do j = 1,NGLLZ
+!!$          do i = 1,NGLLX
+!!$             if(z(iglob) >= 0) then
+!!$                ! crust
+!!$                rho(i,j,ispec) = DENSITY
+!!$                kappa(i,j,ispec) = INCOMPRESSIBILITY
+!!$                mu(i,j,ispec) = RIGIDITY
+!!$             else
+!!$                ! mantle
+!!$                rho(i,j,ispec) = 3380.
+!!$                kappa(i,j,ispec) = 1.3d+11
+!!$                mu(i,j,ispec) = 6.8d+10
+!!$             endif
+!!$          end do
+!!$       end do
+!!$    end do
+
+!!$    ! create vectors from the arrays
+!!$    do ispec = 1,NSPEC
+!!$       do j = 1,NGLLZ
+!!$          do i = 1,NGLLX
+!!$             iglob = ibool(i,j,ispec)
+!!$             rho_global(iglob) = rho(i,j,ispec)
+!!$             mu_global(iglob) = mu(i,j,ispec)
+!!$             kappa_global(iglob) = kappa(i,j,ispec)
+!!$          enddo
+!!$       enddo
+!!$    enddo
+
+  end subroutine set_model_property
+
+!---------------------------------------------
+
+  subroutine solver(solver_type, nsrc, sglob, ispec_src, hxis_store, hgammas_store, samp, &
+                                 nrec, rglob, ispec_rec, hxir_store, hgammar_store, ramp,  &
+              last_frame, absorbfield, &
+              rhop_kernel, beta_kernel, alpha_kernel, &
+              three_source_model, stf, f0)
+
+    integer, intent(in) :: solver_type
+    integer, intent(in) :: nsrc, sglob(nsrc), ispec_src(nsrc)
+    integer, intent(in) :: nrec, rglob(nrec), ispec_rec(nrec)
+    double precision, intent(in) :: hxir_store(nrec,NGLLX), hgammar_store(nrec,NGLLZ)
+    double precision, intent(in) :: hxis_store(nsrc,NGLLX), hgammas_store(nsrc,NGLLZ)
+    double precision, intent(inout) :: samp(NSTEP,NCOMP,nsrc)
+    double precision, intent(inout) :: ramp(NSTEP,NCOMP,nrec)
+
+    ! if adjoint seismograms are desired while computing kernels, then we need to make sure
+    ! not to overwrite the forward source time function
+    double precision,  dimension(:,:,:), allocatable :: stf_for
+
+    ! OPTIONAL ARGUMENTS
+    character(len=*), optional :: last_frame
+    double precision, intent(inout), optional :: absorbfield(NSTEP, NCOMP, NGLL, NELE, NABSORB)
+    double precision, intent(out), optional :: three_source_model(NSTEP,NCOMP,nsrc,3)   ! 3 : deltax, deltaz, deltat
+    double precision, intent(out), dimension(NGLOB), optional :: rhop_kernel, beta_kernel, alpha_kernel
+    double precision, intent(in), optional :: stf(NSTEP), f0(NCOMP)
+
+    !double precision, dimension(NGLOB),optional :: rho_kernel, mu_kernel, kappa_kernel
+    double precision, dimension(NGLOB) :: rho_kernel, mu_kernel, kappa_kernel, beta_kernel_prime
+    double precision, dimension(NSTEP) :: stf_d
+
+    ! displacement gradients: only for SH motion (NCOMP = 1), which gives 2 gradients
+    ! only save the GLL points on the element where the source is located
+    double precision :: displ_grad(NGLLX,NGLLZ,2)
+
+    ! CHT
+    integer tlab
+    double precision xtemp, ztemp, temp1, temp2, temp3
+
+    ! Lagrange interpolation
+    double precision :: hlagrange
+
+    integer ispec,ib,i,j,k,iglob,iglob1,iglob2,itime,ix,iz,itime1,itime2,itime0
+    integer isrc, irec, icomp, isave
+    character(len=100) :: filename,filename1,filename2,filename3,filename4,filename5,filename6,fm
+    double precision, dimension(NGLOB) :: mu_k, kappa_k
+    logical :: save_forward
+
+    !--------------------------------------
+
+    if(NCOMP==3) fm = '(9e12.3)'
+    if(NCOMP==1) fm = '(3e12.3)'
+
+    ! test of input arguments
+    if (solver_type /= 1 .and. solver_type /= 2 .and. solver_type /= 3) then
+       stop 'solver_type has to be 1, 2 or 3'
+    endif
+
+    save_forward = .false.
+    if (solver_type == 1) then
+       if (present(last_frame) .and. present(absorbfield)) save_forward = .true.
+    endif
+    
+    if (solver_type == 3) then
+       if (.not. (present(last_frame) .and. present(absorbfield)  &
+            .and. present(rhop_kernel) .and. present(beta_kernel) .and. present(alpha_kernel))) &
+            stop 'For kernel calculation, last_frame, absorbfield and all kernel are in the argument'
+       rho_kernel = 0.
+       mu_kernel = 0.
+       kappa_kernel = 0.
+
+       ! allocate a new array for the forward source function (note: includes amplitude)
+       allocate(stf_for(NSTEP,NCOMP,nsrc))
+       stf_for(:,:,:) = samp(:,:,:)
+
+       ! compute the derivative of the source time function
+       stf_d(:) = 0.
+       do i = 2, NSTEP-1
+         stf_d(i) =  (stf(i+1) - stf(i-1)) / (2.*DT)
+       enddo
+       stf_d(1) = (stf(2) - stf(1)) / DT
+       stf_d(NSTEP) = (stf(NSTEP) - stf(NSTEP-1)) / DT
+
+       ! initialize adjoint seismograms
+       samp(:,:,:) = 0.
+
+    endif
+  
+    ! gridpoints per wavelength estimation 
+    print *
+    print *, 'space step (km):', sngl(dh/1000.)
+    if(ISURFACE) then
+       print *, 'wavelength-min (km):', sngl(2*hdur*cmin/1000.)
+       print *, 'wavelength-max (km):', sngl(2*hdur*cmax/1000.)
+       print *, 'number of gridpoints per wavelength for S:'
+       print *, '  min (cmin) : ', floor(2*hdur*cmin/dh)
+       print *, '  max (cmax) : ', floor(2*hdur*cmax/dh)
+
+    else
+       c = sqrt((INCOMPRESSIBILITY+FOUR_THIRDS*RIGIDITY)/DENSITY)
+       print *, 'number of gridpoints per wavelength for P: ', floor(hdur*c/dh)
+       c = sqrt(RIGIDITY/DENSITY)
+       print *, 'number of gridpoints per wavelength for S:', floor(hdur*c/dh)
+    endif
+    
+    NINT = NSTEP/NSAVE
+    if (NINT * NSAVE > NSTEP) stop 'NSTEP should equal to NINT * NSAVE'
+
+    ! calculate the global mass matrix once and for all
+    ! note that the density variation is included here
+    mass_global(:) = 0.
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX
+             mass_local = wxgll(i)*wzgll(j)*rho(i,j,ispec)*jacobian(i,j,ispec)
+             iglob = ibool(i,j,ispec)
+             mass_global(iglob) = mass_global(iglob) + mass_local
+          end do
+       end do
+    end do
+
+    ! time marching parameters
+    deltat = DT
+    deltatover2 = deltat/2.
+    deltatsqover2 = deltat*deltat/2.
+
+    if (solver_type == 3) then
+       b_deltat = -DT
+       b_deltatover2 = b_deltat/2.
+       b_deltatsqover2 = b_deltat*b_deltat/2.
+    endif
+
+    ! initialize
+    displ(:,:) = 0.
+    veloc(:,:) = 0.
+    accel(:,:) = 0.
+
+    if (solver_type == 3) then
+       open(11,file = trim(last_frame),status='old',iostat=ios)
+       if (ios /= 0) stop 'Error reading the last frame'
+       do i = 1, NGLOB
+          !read(11,*) b_displ(1,i), b_displ(2,i), b_displ(3,i), & 
+          !           b_veloc(1,i), b_veloc(2,i), b_veloc(3,i), &
+          !           b_accel(1,i), b_accel(2,i), b_accel(3,i)
+          read(11,fm) (b_displ(j,i), j = 1,NCOMP), &
+                       (b_veloc(j,i), j = 1,NCOMP), & 
+                       (b_accel(j,i), j = 1,NCOMP)
+       enddo
+       close(11)
+    endif
+
+    !
+    ! START TIME MARCHING
+    !
+    do itime = 1, NSTEP
+
+       if (mod(itime,200) == 0) write(*,*) itime, ' out of ', NSTEP
+
+       ! 'predictor' update displacement using finite-difference time scheme (Newmark)
+       do i = 1,NCOMP
+          displ(i,:) = displ(i,:) + deltat*veloc(i,:) + deltatsqover2*accel(i,:)
+          veloc(i,:) = veloc(i,:) + deltatover2*accel(i,:)
+          accel(i,:) = 0.
+          if (solver_type == 3) then
+             b_displ(i,:) = b_displ(i,:) + b_deltat*b_veloc(i,:) + b_deltatsqover2*b_accel(i,:)
+             b_veloc(i,:) = b_veloc(i,:) + b_deltatover2*b_accel(i,:)
+             b_accel(i,:) = 0.
+          endif
+       enddo
+
+ if(NCOMP==1) then    ! SH, or surface waves only
+
+       !
+       !   INTEGRATION OVER SPECTRAL ELEMENTS
+       !
+       do ispec = 1,NSPEC
+
+          ! first double loop over GLL 
+          ! compute and store gradients
+          do j = 1,NGLLZ
+             do i = 1,NGLLX
+
+                iglob2 = ibool(i,j,ispec)
+
+                ! derivative along x
+                tempy1l = 0.
+                if (solver_type == 3) b_tempy1l = 0.
+                do k = 1,NGLLX
+                   hp1 = hprime_xx(k,i)
+                   iglob = ibool(k,j,ispec)
+                   tempy1l = tempy1l + displ(1,iglob)*hp1
+                   if (solver_type == 3) then
+                      b_tempy1l = b_tempy1l + b_displ(1,iglob)*hp1
+                   endif
+                end do
+
+                ! derivative along z
+                tempy2l = 0.
+                if (solver_type == 3) b_tempy2l = 0.
+                do k = 1,NGLLZ
+                   hp2 = hprime_zz(k,j)
+                   iglob = ibool(i,k,ispec)
+                   tempy2l = tempy2l + displ(1,iglob)*hp2
+                   if (solver_type == 3) then
+                      b_tempy2l = b_tempy2l + b_displ(1,iglob)*hp2
+                   endif
+                end do
+
+                ! from mesher
+                dxidxl = dxidx(i,j,ispec)
+                dxidzl = dxidz(i,j,ispec)
+                dgammadxl = dgammadx(i,j,ispec)
+                dgammadzl = dgammadz(i,j,ispec)
+
+                ! spatial gradients
+                dsydxl = tempy1l*dxidxl + tempy2l*dgammadxl
+                dsydzl = tempy1l*dxidzl + tempy2l*dgammadzl
+              
+                ! save spatial gradient for (point) source perturbations
+                if(solver_type == 3 .and. ispec == ispec_src(1)) then
+                   displ_grad(i,j,1) = dsydxl
+                   displ_grad(i,j,2) = dsydzl
+                endif
+
+                ! strain tensor
+                ds(:,:) = 0.
+                ds(1,2) = oneovertwo * dsydxl
+                ds(2,3) = oneovertwo * dsydzl
+                ds(2,1) = ds(1,2)
+                ds(3,2) = ds(2,3)
+
+                if (solver_type == 3) then
+                   b_dsydxl = b_tempy1l*dxidxl + b_tempy2l*dgammadxl
+                   b_dsydzl = b_tempy1l*dxidzl + b_tempy2l*dgammadzl
+
+                   b_ds(:,:) = 0.
+                   b_ds(1,2) = oneovertwo * b_dsydxl
+                   b_ds(2,3) = oneovertwo * b_dsydzl
+                   b_ds(2,1) = b_ds(1,2)
+                   b_ds(3,2) = b_ds(2,3)
+
+                   ! mu kernel
+                   !mu_k(iglob2) = sum(ds * b_ds) - ONE_THIRD * kappa_k(iglob2)   ! (12-July-2006)
+                   mu_k(iglob2) = sum(ds * b_ds)
+                endif
+ 
+                mul = mu(i,j,ispec)      ! model heterogeneity
+                sigma_xy = mul*dsydxl
+                sigma_zy = mul*dsydzl
+
+                if (solver_type == 3) then
+                   b_sigma_xy = mul* b_dsydxl
+                   b_sigma_zy = mul* b_dsydzl
+                endif
+
+                jacobianl = jacobian(i,j,ispec)
+
+                ! non-symmetric form (first Piola-Kirchhoff stress)
+                tempy1(i,j) = jacobianl*(sigma_xy*dxidxl+sigma_zy*dxidzl)
+                tempy2(i,j) = jacobianl*(sigma_xy*dgammadxl+sigma_zy*dgammadzl)
+                if (solver_type == 3) then
+                   b_tempy1(i,j) = jacobianl*(b_sigma_xy*dxidxl+ b_sigma_zy*dxidzl)
+                   b_tempy2(i,j) = jacobianl*(b_sigma_xy*dgammadxl+b_sigma_zy*dgammadzl)
+                endif
+
+             enddo
+          enddo
+          !
+          ! second double-loop over GLL
+          ! compute all rhs terms
+          !
+          do j = 1,NGLLZ
+             do i = 1,NGLLX
+
+                ! along x direction
+                tempy1l = 0.
+                if (solver_type == 3) b_tempy1l = 0.
+                do k = 1,NGLLX
+                   fac1 = wxgll(k)*hprime_xx(i,k)
+                   tempy1l = tempy1l + tempy1(k,j)*fac1
+                   if (solver_type == 3) then
+                      b_tempy1l = b_tempy1l + b_tempy1(k,j)*fac1
+                   endif
+                end do
+
+                ! along z direction
+                tempy2l = 0.
+                if (solver_type == 3) b_tempy2l = 0.
+                do k = 1,NGLLZ
+                   fac2 = wzgll(k)*hprime_zz(j,k)
+                   tempy2l = tempy2l + tempy2(i,k)*fac2
+                   if (solver_type == 3) then
+                      b_tempy2l = b_tempy2l + b_tempy2(i,k)*fac2
+                   endif
+                end do
+
+                fac1 = wzgll(j)
+                fac2 = wxgll(i)
+
+                iglob = ibool(i,j,ispec)
+                accel(1,iglob) = accel(1,iglob) - (fac1*tempy1l + fac2*tempy2l)
+                if (solver_type == 3) then
+                   b_accel(1,iglob) = b_accel(1,iglob) - (fac1* b_tempy1l + fac2* b_tempy2l)
+                endif
+
+             end do ! second loop over the GLL points
+          end do
+
+       end do ! end loop over all spectral elements
+
+       !
+       ! boundary conditions
+       !
+       ! forward propagation
+
+       ! modifications by CHT are made to make the top boundary absorbing
+       ! if this is used in other options (e.g., kernels), then those
+       ! sections need to be adjusted as well
+
+       do ibb = 1,NABSORB  ! index of grid boundary
+          if(ibb == 1) then
+             i = 1
+          elseif(ibb == 2) then
+             i = NGLLX
+          elseif(ibb == 3) then
+             i = 1
+          elseif(ibb == 4) then
+             i = NGLLZ
+          endif
+
+          do ib = 1,nspecb(ibb)     ! elements on each grid boundary
+             ispec = ibelm(ibb,ib)  ! (global) index of boundary element
+
+             if (ibb == 1 .or. ibb == 2) then ! left or right boundary element
+                j1 = 1; j2 = NGLLZ
+             else if (ib == 1) then           ! top left corner element
+                j1 = 2; j2 = NGLLX 
+             else if (ib == nspecb(ibb)) then ! top right corner element
+                j1 = 1; j2 = NGLLX-1  
+             else                             ! top or bottom boundary (excluding corner elements)
+                j1 = 1; j2 = NGLLX
+             endif
+
+             do j = j1, j2
+                if (ibb == 1 .or. ibb == 2) then  ! left or right boundary
+                   iglob = ibool(i,j,ispec)
+                   rho_vs = dsqrt(rho(i,j,ispec)*mu(i,j,ispec))
+                else                              ! top or bottom boundary
+                   iglob = ibool(j,i,ispec)
+                   rho_vs = dsqrt(rho(j,i,ispec)*mu(j,i,ispec))
+                endif
+
+                vy = veloc(1,iglob)
+                ty = rho_vs*vy
+                weight = jacobianb(ibb,j,ib)*wzgll(j)
+                accel(1,iglob) = accel(1,iglob) - ty*weight
+                if (save_forward) then
+                   absorbfield(itime,1,j,ib,ibb) = ty*weight
+                endif
+              end do
+            end do
+          enddo
+
+else  ! NCOMP==3
+
+       !
+       !   INTEGRATION OVER SPECTRAL ELEMENTS
+       !
+       do ispec = 1,NSPEC
+
+          ! first double loop over GLL 
+          ! compute and store gradients
+          do j = 1,NGLLZ
+             do i = 1,NGLLX
+
+                iglob2 = ibool(i,j,ispec)
+
+                ! derivative along x
+                tempx1l = 0.
+                tempy1l = 0.
+                tempz1l = 0.
+                if (solver_type == 3) then
+                   b_tempx1l = 0.
+                   b_tempy1l = 0.
+                   b_tempz1l = 0.
+                endif
+                do k = 1,NGLLX
+                   hp1 = hprime_xx(k,i)
+                   iglob = ibool(k,j,ispec)
+                   tempx1l = tempx1l + displ(1,iglob)*hp1
+                   tempy1l = tempy1l + displ(2,iglob)*hp1
+                   tempz1l = tempz1l + displ(3,iglob)*hp1
+                   if (solver_type == 3) then
+                      b_tempx1l = b_tempx1l + b_displ(1,iglob)*hp1
+                      b_tempy1l = b_tempy1l + b_displ(2,iglob)*hp1
+                      b_tempz1l = b_tempz1l + b_displ(3,iglob)*hp1
+                   endif
+                end do
+
+                ! derivative along z
+                tempx2l = 0.
+                tempy2l = 0.
+                tempz2l = 0.
+                if (solver_type == 3) then
+                   b_tempx2l = 0.
+                   b_tempy2l = 0.
+                   b_tempz2l = 0.
+                endif
+                do k = 1,NGLLZ
+                   hp2 = hprime_zz(k,j)
+                   iglob = ibool(i,k,ispec)
+                   tempx2l = tempx2l + displ(1,iglob)*hp2
+                   tempy2l = tempy2l + displ(2,iglob)*hp2
+                   tempz2l = tempz2l + displ(3,iglob)*hp2
+                   if (solver_type == 3) then
+                      b_tempx2l = b_tempx2l + b_displ(1,iglob)*hp2
+                      b_tempy2l = b_tempy2l + b_displ(2,iglob)*hp2
+                      b_tempz2l = b_tempz2l + b_displ(3,iglob)*hp2
+                   endif
+                end do
+
+                dxidxl = dxidx(i,j,ispec)
+                dxidzl = dxidz(i,j,ispec)
+                dgammadxl = dgammadx(i,j,ispec)
+                dgammadzl = dgammadz(i,j,ispec)
+
+                dsxdxl = tempx1l*dxidxl+tempx2l*dgammadxl
+                dsxdzl = tempx1l*dxidzl+tempx2l*dgammadzl
+
+                dsydxl = tempy1l*dxidxl+tempy2l*dgammadxl
+                dsydzl = tempy1l*dxidzl+tempy2l*dgammadzl
+
+                dszdxl = tempz1l*dxidxl+tempz2l*dgammadxl
+                dszdzl = tempz1l*dxidzl+tempz2l*dgammadzl
+
+                ds(1,1) = dsxdxl
+                ds(1,2) = oneovertwo * dsydxl
+                ds(1,3) = oneovertwo * (dszdxl + dsxdzl)
+                ds(2,2) = 0
+                ds(2,3) = oneovertwo * dsydzl
+                ds(3,3) = dszdzl
+                ds(2,1) = ds(1,2)
+                ds(3,1) = ds(1,3)
+                ds(3,2) = ds(2,3)
+
+                if (solver_type == 3) then
+                   b_dsxdxl = b_tempx1l*dxidxl+ b_tempx2l*dgammadxl
+                   b_dsxdzl = b_tempx1l*dxidzl+ b_tempx2l*dgammadzl
+
+                   b_dsydxl = b_tempy1l*dxidxl+ b_tempy2l*dgammadxl
+                   b_dsydzl = b_tempy1l*dxidzl+ b_tempy2l*dgammadzl
+
+                   b_dszdxl = b_tempz1l*dxidxl+ b_tempz2l*dgammadxl
+                   b_dszdzl = b_tempz1l*dxidzl+ b_tempz2l*dgammadzl
+
+                   b_ds(1,1) = b_dsxdxl
+                   b_ds(1,2) = oneovertwo * b_dsydxl
+                   b_ds(1,3) = oneovertwo * (b_dszdxl + b_dsxdzl)
+                   b_ds(2,2) = 0
+                   b_ds(2,3) = oneovertwo * b_dsydzl
+                   b_ds(3,3) = b_dszdzl
+                   b_ds(2,1) = b_ds(1,2)
+                   b_ds(3,1) = b_ds(1,3)
+                   b_ds(3,2) = b_ds(2,3)
+
+                   ! kappa and mu kernels
+                   kappa_k(iglob2) = (dsxdxl + dszdzl) * (b_dsxdxl + b_dszdzl)     ! product of div_s
+                   mu_k(iglob2)    = sum(ds * b_ds) - ONE_THIRD * kappa_k(iglob2)  ! double-dot-product of deviatoric strains
+                endif
+
+                ! variation in kappa and mu
+                kappal = kappa(i,j,ispec)
+                mul = mu(i,j,ispec)
+                lambdalplus2mul = kappal + FOUR_THIRDS * mul
+                lambdal = lambdalplus2mul - 2.*mul
+
+                sigma_xx = lambdalplus2mul*dsxdxl + lambdal*dszdzl
+                sigma_xy = mul*dsydxl
+                sigma_xz = mul*(dszdxl + dsxdzl)
+                sigma_zx = sigma_xz
+                sigma_zy = mul*dsydzl
+                sigma_zz = lambdalplus2mul*dszdzl + lambdal*dsxdxl
+
+                if (solver_type == 3) then
+                   b_sigma_xx = lambdalplus2mul* b_dsxdxl + lambdal* b_dszdzl
+                   b_sigma_xy = mul* b_dsydxl
+                   b_sigma_xz = mul*(b_dszdxl + b_dsxdzl)
+                   b_sigma_zx = b_sigma_xz
+                   b_sigma_zy = mul* b_dsydzl
+                   b_sigma_zz = lambdalplus2mul* b_dszdzl + lambdal* b_dsxdxl
+                endif
+
+                jacobianl = jacobian(i,j,ispec)
+
+                ! non-symmetric form (first Piola-Kirchhoff stress)
+                tempx1(i,j) = jacobianl*(sigma_xx*dxidxl+sigma_zx*dxidzl)
+                tempy1(i,j) = jacobianl*(sigma_xy*dxidxl+sigma_zy*dxidzl)
+                tempz1(i,j) = jacobianl*(sigma_xz*dxidxl+sigma_zz*dxidzl)
+
+                tempx2(i,j) = jacobianl*(sigma_xx*dgammadxl+sigma_zx*dgammadzl)
+                tempy2(i,j) = jacobianl*(sigma_xy*dgammadxl+sigma_zy*dgammadzl)
+                tempz2(i,j) = jacobianl*(sigma_xz*dgammadxl+sigma_zz*dgammadzl)
+
+                if (solver_type == 3) then
+                   b_tempx1(i,j) = jacobianl*(b_sigma_xx*dxidxl+ b_sigma_zx*dxidzl)
+                   b_tempy1(i,j) = jacobianl*(b_sigma_xy*dxidxl+ b_sigma_zy*dxidzl)
+                   b_tempz1(i,j) = jacobianl*(b_sigma_xz*dxidxl+ b_sigma_zz*dxidzl)
+
+                   b_tempx2(i,j) = jacobianl*(b_sigma_xx*dgammadxl+b_sigma_zx*dgammadzl)
+                   b_tempy2(i,j) = jacobianl*(b_sigma_xy*dgammadxl+b_sigma_zy*dgammadzl)
+                   b_tempz2(i,j) = jacobianl*(b_sigma_xz*dgammadxl+b_sigma_zz*dgammadzl)
+                endif
+
+             end do
+          end do
+          !
+          ! second double-loop over GLL
+          ! compute all rhs terms
+          !
+          do j = 1,NGLLZ
+             do i = 1,NGLLX
+
+                ! along x direction
+                tempx1l = 0.
+                tempy1l = 0.
+                tempz1l = 0.
+                if (solver_type == 3) then
+                   b_tempx1l = 0.
+                   b_tempy1l = 0.
+                   b_tempz1l = 0.
+                endif
+                do k = 1,NGLLX
+                   fac1 = wxgll(k)*hprime_xx(i,k)
+                   tempx1l = tempx1l + tempx1(k,j)*fac1
+                   tempy1l = tempy1l + tempy1(k,j)*fac1
+                   tempz1l = tempz1l + tempz1(k,j)*fac1
+                   if (solver_type == 3) then
+                      b_tempx1l = b_tempx1l + b_tempx1(k,j)*fac1
+                      b_tempy1l = b_tempy1l + b_tempy1(k,j)*fac1
+                      b_tempz1l = b_tempz1l + b_tempz1(k,j)*fac1
+                   endif
+                end do
+
+                ! along z direction
+                tempx2l = 0.
+                tempy2l = 0.
+                tempz2l = 0.
+                if (solver_type == 3) then
+                   b_tempx2l = 0.
+                   b_tempy2l = 0.
+                   b_tempz2l = 0.
+                endif
+                do k = 1,NGLLZ
+                   fac2 = wzgll(k)*hprime_zz(j,k)
+                   tempx2l = tempx2l + tempx2(i,k)*fac2
+                   tempy2l = tempy2l + tempy2(i,k)*fac2
+                   tempz2l = tempz2l + tempz2(i,k)*fac2 
+                   if (solver_type == 3) then
+                      b_tempx2l = b_tempx2l + b_tempx2(i,k)*fac2
+                      b_tempy2l = b_tempy2l + b_tempy2(i,k)*fac2
+                      b_tempz2l = b_tempz2l + b_tempz2(i,k)*fac2 
+                   endif
+                end do
+
+                fac1 = wzgll(j)
+                fac2 = wxgll(i)
+
+                ! key computation
+                iglob = ibool(i,j,ispec)
+                accel(1,iglob) = accel(1,iglob) - (fac1*tempx1l + fac2*tempx2l)
+                accel(2,iglob) = accel(2,iglob) - (fac1*tempy1l + fac2*tempy2l)
+                accel(3,iglob) = accel(3,iglob) - (fac1*tempz1l + fac2*tempz2l)
+
+                if (solver_type == 3) then
+                   b_accel(1,iglob) = b_accel(1,iglob) - (fac1* b_tempx1l + fac2* b_tempx2l)
+                   b_accel(2,iglob) = b_accel(2,iglob) - (fac1* b_tempy1l + fac2* b_tempy2l)
+                   b_accel(3,iglob) = b_accel(3,iglob) - (fac1* b_tempz1l + fac2* b_tempz2l)
+                endif
+
+             end do ! second loop over the GLL points
+          end do
+
+       end do ! end loop over all spectral elements
+
+       !
+       ! boundary conditions
+       !
+       ! forward propagation
+
+       !do ibb = 1, 3
+       do ibb = 1,NABSORB  ! index of grid boundary (CHT)
+          if (ibb == 1) then
+             i = 1; nx = -1.; nz = 0.
+          elseif (ibb == 2) then
+             i = NGLLX; nx = 1.; nz = 0.
+          elseif (ibb == 3) then
+             i = 1; nx = 0.; nz = -1.
+          elseif (ibb == 4) then       ! CHT
+             i = NGLLZ; nx = 0.; nz = 1.
+          endif
+
+          do ib = 1,nspecb(ibb)     ! elements on each grid boundary
+             ispec = ibelm(ibb,ib)  ! (global) index of boundary element
+
+             if (ibb == 1 .or. ibb == 2) then ! left or right boundary element
+                j1 = 1; j2 = NGLLZ
+             else if (ib == 1) then           ! top left corner element
+                j1 = 2; j2 = NGLLX 
+             else if (ib == nspecb(ibb)) then ! top right corner element
+                j1 = 1; j2 = NGLLX-1  
+             else                             ! top or bottom boundary (excluding corner elements)
+                j1 = 1; j2 = NGLLX
+             endif
+
+             do j = j1, j2
+                if (ibb == 1 .or. ibb == 2) then  ! left or right boundary
+                   iglob = ibool(i,j,ispec)
+                   rho_vp = dsqrt(rho(i,j,ispec)*(kappa(i,j,ispec)+FOUR_THIRDS*mu(i,j,ispec)))
+                   rho_vs = dsqrt(rho(i,j,ispec)*mu(i,j,ispec))
+                else                              ! top or bottom boundary
+                   iglob = ibool(j,i,ispec)
+                   rho_vp = dsqrt(rho(j,i,ispec)*(kappa(j,i,ispec)+FOUR_THIRDS*mu(j,i,ispec)))
+                   rho_vs = dsqrt(rho(j,i,ispec)*mu(j,i,ispec))
+                endif
+
+                vx = veloc(1,iglob)
+                vy = veloc(2,iglob)
+                vz = veloc(3,iglob)
+
+                vn = nx*vx+nz*vz
+
+                tx = rho_vp*vn*nx+rho_vs*(vx-vn*nx)
+                ty = rho_vs*vy
+                tz = rho_vp*vn*nz+rho_vs*(vz-vn*nz)
+
+                weight = jacobianb(ibb,j,ib)*wzgll(j)
+
+                accel(1,iglob) = accel(1,iglob) - tx*weight
+                accel(2,iglob) = accel(2,iglob) - ty*weight
+                accel(3,iglob) = accel(3,iglob) - tz*weight
+                if (save_forward) then
+                   absorbfield(itime,1,j,ib,ibb) = tx*weight
+                   absorbfield(itime,2,j,ib,ibb) = ty*weight
+                   absorbfield(itime,3,j,ib,ibb) = tz*weight
+                endif
+              end do
+            end do
+          enddo
+
+endif  ! NCOMP
+
+       ! backward propogation boundary condition
+       if (solver_type == 3) then
+          do ibb = 1,NABSORB     ! CHT : add 4th boundary
+             if (ibb == 1) then
+                i = 1
+             elseif (ibb == 2) then
+                i = NGLLX
+             elseif (ibb == 3) then
+                i = 1
+             elseif (ibb == 4) then
+                i = NGLLZ
+             end if
+
+             ! see comments above
+             do ib = 1,nspecb(ibb)
+                if (ibb == 1 .or. ibb == 2) then
+                   j1 = 1; j2 = NGLLZ
+                elseif (ib == 1) then
+                   j1 = 2; j2 = NGLLX 
+                elseif (ib == nspecb(ibb)) then
+                   j1 = 1; j2 = NGLLX-1  
+                else
+                   j1 = 1; j2 = NGLLX
+                endif
+                ispec = ibelm(ibb,ib)
+                do j = j1, j2
+                   if (ibb == 1 .or. ibb == 2) then
+                      iglob = ibool(i,j,ispec)
+                   else
+                      iglob = ibool(j,i,ispec)
+                   endif
+                   b_accel(:,iglob) = b_accel(:,iglob) - absorbfield(NSTEP-itime+1,:,j,ib,ibb)
+                enddo
+             enddo
+          enddo
+       endif
+
+       ! KEY: add source
+       if (solver_type == 1) then
+         ! forward wavefield
+         do isrc = 1,nsrc
+
+           ! perform the general interpolation using Lagrange polynomials -- NEW METHOD
+           do j = 1,NGLLZ
+             do i = 1,NGLLX
+               iglob = ibool(i,j,ispec_src(isrc))
+               hlagrange = hxis_store(isrc,i) * hgammas_store(isrc,j)
+
+               accel(:,iglob) = accel(:,iglob) + samp(itime,:,isrc)*hlagrange
+             enddo
+           enddo
+
+           ! take the value at the closest gridpoint -- OLD METHOD
+           !iglob = sglob(isrc)
+           !accel(:,iglob) = accel(:,iglob) + samp(itime,:,isrc) 
+
+         enddo  ! isrc
+
+       else
+         ! adjoint wavefield
+         do irec = 1,nrec
+           do j = 1,NGLLZ
+             do i = 1,NGLLX
+               iglob = ibool(i,j,ispec_rec(irec))
+               hlagrange = hxir_store(irec,i) * hgammar_store(irec,j)
+
+               accel(:,iglob) = accel(:,iglob) + ramp(NSTEP-itime+1,:,irec)*hlagrange
+             enddo
+           enddo
+           !iglob = rglob(irec)
+           !accel(:,iglob) = accel(:,iglob) + ramp(NSTEP-itime+1,:,irec) 
+         enddo
+  
+         ! forward wavefield, but computed in reverse
+         if (solver_type == 3) then
+           do isrc = 1,nsrc
+             do j = 1,NGLLZ
+               do i = 1,NGLLX
+                 iglob = ibool(i,j,ispec_src(isrc))
+                 hlagrange = hxis_store(isrc,i) * hgammas_store(isrc,j)
+
+                 !b_accel(:,iglob) = b_accel(:,iglob) + samp(NSTEP-itime+1,:,isrc)*hlagrange
+                 b_accel(:,iglob) = b_accel(:,iglob) + stf_for(NSTEP-itime+1,:,isrc)*hlagrange
+               enddo
+             enddo
+             !iglob = sglob(isrc)
+             !b_accel(:,iglob) = b_accel(:,iglob) + samp(NSTEP-itime+1,:,isrc) 
+           enddo
+         endif
+
+       endif
+       
+       ! above here, accel(:) are actually the RHS!
+       ! divide by the mass matrix
+       do i = 1,NGLOB
+          accel(:,i) = accel(:,i)/mass_global(i)
+
+          if(solver_type == 3) &
+             b_accel(:,i) = b_accel(:,i)/mass_global(i)
+       enddo
+
+       ! `corrector' update velocity
+       do i = 1,NCOMP
+          veloc(i,:) = veloc(i,:) + deltatover2*accel(i,:)
+          if (solver_type == 3) then
+             b_veloc(i,:) = b_veloc(i,:) + b_deltatover2 * b_accel(i,:)
+          endif
+       enddo
+
+       !--------------------------------
+       ! save this time-step into seismograms and/or calculate kernels
+       ! NEW METHOD -- perform the general interpolation using Lagrange polynomials
+       ! OLD METHOD -- closest gridpoint
+
+       if (solver_type == 1) then         ! forward seismograms
+
+         do irec = 1,nrec
+
+           ! perform the general interpolation using Lagrange polynomials -- NEW METHOD
+           do j = 1,NGLLZ
+             do i = 1,NGLLX
+               iglob = ibool(i,j,ispec_rec(irec))
+               hlagrange = hxir_store(irec,i) * hgammar_store(irec,j)
+
+               ! equivalent to using closest gridpoint -- OLD METHOD
+               !hlagrange = 0.
+               !if(iglob == rglob(irec)) hlagrange = 1.
+
+               ramp(itime,:,irec) = ramp(itime,:,irec) + displ(:,iglob)*hlagrange
+             enddo
+           enddo
+
+           ! take the value at the closest gridpoint -- OLD METHOD
+           !ramp(itime,:,irec) = displ(:,rglob(irec))
+
+         enddo  ! irec
+
+
+       ! adjoint seismograms
+       ! note that samp above is copied to stf_for
+       ! we fill the record 'in reverse' so that the max arrival will coincide
+       ! with the forward source time function pulse
+       elseif (solver_type==2 .or. solver_type==3) then
+
+         do isrc = 1,nsrc
+           temp1 = 0; temp2 = 0. ; temp3 = 0.
+           do j = 1,NGLLZ      ! loop over NGLLX by NGLLZ points for each source
+             do i = 1,NGLLX
+               iglob = ibool(i,j,ispec_src(isrc))
+               hlagrange = hxis_store(isrc,i) * hgammas_store(isrc,j)
+
+               ! assume one component only for now
+               temp1 = temp1 + displ(1,iglob)*hlagrange        ! sdag
+               temp2 = temp2 + displ_grad(i,j,1)*hlagrange     ! d/dx(sdag)
+               temp3 = temp3 + displ_grad(i,j,2)*hlagrange     ! d/dz(sdag)
+             enddo
+           enddo
+
+           !samp(NSTEP-itime+1,:,isrc) = displ(:,sglob(isrc))
+
+           ! adjoint seismograms (time-reversed)
+           samp(NSTEP-itime+1,1,isrc) = temp1
+
+           ! source perturbation time series
+           ! (assume one component for now)
+           three_source_model(NSTEP-itime+1,1,nsrc,1) =  temp2 * f0(1) * stf(NSTEP-itime+1)   ! dx
+           three_source_model(NSTEP-itime+1,1,nsrc,2) =  temp3 * f0(1) * stf(NSTEP-itime+1)   ! dz
+           three_source_model(NSTEP-itime+1,1,nsrc,3) = -temp1 * f0(1) * stf_d(NSTEP-itime+1) ! dt0
+
+           ! additional time series for checking
+           !three_source_model(NSTEP-itime+1,1,nsrc,4) = temp1
+           !three_source_model(NSTEP-itime+1,1,nsrc,5) = temp2
+           !three_source_model(NSTEP-itime+1,1,nsrc,6) = temp3
+           !three_source_model(itime,1,nsrc,7) = stf_d(itime)
+           !three_source_model(itime,1,nsrc,8) = stf(itime)
+
+         enddo  ! isrc
+
+
+         if(solver_type==3) then
+
+           ! CALCULATE SIX KERNELS -- notice the time integration
+           do iglob = 1, NGLOB
+             ! note the minus sign in these expressions (TTL,2005)
+             rho_kernel(iglob) = rho_kernel(iglob) - &
+                  rho_global(iglob) * dot_product(accel(:,iglob),b_displ(:,iglob)) * DT
+             mu_kernel(iglob) = mu_kernel(iglob) - &
+                  2 * mu_global(iglob) * mu_k(iglob) * DT
+             kappa_kernel(iglob) = kappa_kernel(iglob) - &
+                  kappa_global(iglob) * kappa_k(iglob) * DT
+
+             rhop_kernel(iglob) = rho_kernel(iglob) + kappa_kernel(iglob) + mu_kernel(iglob)
+             beta_kernel(iglob) = 2 * (mu_kernel(iglob) - &
+                  (4.0 * mu_global(iglob))/(3.0 * kappa_global(iglob)) * kappa_kernel(iglob))
+             alpha_kernel(iglob) = 2 * (3 * kappa_global(iglob) + 4 * mu_global(iglob)) &
+                  / (3 * kappa_global(iglob)) * kappa_kernel(iglob)
+
+             ! SH beta-kernel INTERACTION field (for membrane surface waves)
+             beta_kernel_prime(iglob) = -2. * (2. * mu_global(iglob) * mu_k(iglob) )
+             !beta_kernel(iglob) = beta_kernel(iglob) + beta_kernel_prime(iglob) * DT
+           enddo
+         endif  ! solver_type = 3
+
+       endif  ! solver_type
+
+       ! save last frame
+       if (mod(itime, NSAVE) == 0) then      
+
+          if (save_forward) then
+             open(11,file = trim(last_frame),status='unknown',iostat=ios)
+             if (ios /= 0) stop 'Error reading the last frame'
+             do i = 1,NGLOB
+                write(11,fm) (sngl(displ(j,i)), j = 1,NCOMP), & 
+                             (sngl(veloc(j,i)), j = 1,NCOMP), &
+                             (sngl(accel(j,i)), j = 1,NCOMP)
+             enddo
+             close(11)
+          endif
+ 
+          ! ONE KERNEL: for basis function analysis
+          ! take the integrated kernel at the FINAL TIME STEP
+          if (solver_type == 3 .and. itime == NSTEP) then
+             filename5 = trim(out_dir)//'kernel_basis'
+             open(unit = 13, file = trim(filename5), status = 'unknown',iostat=ios) 
+             if (ios /= 0) stop 'Error writing snapshot to disk'
+             do iglob = 1, NGLOB
+                write(13,'(3e16.6)') x_lon(iglob), z_lat(iglob), sngl(beta_kernel(iglob))
+                !write(13,'(5e16.6)') x(iglob), z(iglob), x_lon(iglob), z_lat(iglob), sngl(beta_kernel(iglob))
+             enddo
+             close(13)
+
+             ! sum these in wave2d.f90
+             kernel_basis(:) = beta_kernel(:)
+          endif  ! solver_type == 3
+
+       endif
+ 
+       !stop 'testing'
+
+       !===================================
+
+       ! write snapshots or kernels
+       if (itime == 1 .or. mod(itime, NSAVE) == 0) then   ! save the initial frame
+          if (itime == 1) tlab = 0
+          if (itime /= 1) tlab = itime
+       !if (mod(itime, NSAVE) == 0) then
+          if (solver_type == 1) then
+             write(filename1,'(a,i5.5)') trim(out_dir)//'forward_',tlab
+          elseif (solver_type == 2) then
+             write(filename1,'(a,i5.5)') trim(out_dir)//'adjoint_',tlab
+          else
+             write(filename1,'(a,i5.5)') trim(out_dir)//'adjoint_',tlab      ! adjoint wavefield
+             write(filename2,'(a,i5.5)') trim(out_dir)//'backward_',tlab
+             write(filename3,'(a,i5.5)') trim(out_dir)//'kernel0_',tlab      ! kernels rho-kappa-mu
+             write(filename4,'(a,i5.5)') trim(out_dir)//'kernel_',tlab       ! kernels rho'-alpha-beta
+             !write(filename6,'(a,i5.5)') trim(out_dir)//'interaction_',tlab  ! interaction
+          endif
+
+          ! x-z coordinates for plotting
+          !!xtemp = x(iglob)/LENGTH ; ztemp = z(iglob)/LENGTH
+          !xtemp = x(iglob)/1000. ; ztemp = z(iglob)/1000.
+
+          if(WRITE_SNAPSHOTS) then      ! wavefield snapshots
+             open(unit=11, file=trim(filename1), status='unknown', iostat=ios)
+             if (ios /= 0) stop 'Error writing snapshot to disk'
+             do iglob = 1, NGLOB
+                xtemp = x_lon(iglob) ; ztemp = z_lat(iglob)
+                write(11,'(5e16.6)') sngl(xtemp), sngl(ztemp), (sngl(displ(j,iglob)),j=1,NCOMP) 
+             enddo
+             close(11)
+          endif
+
+          if(WRITE_KERNELS) then        ! kernel snapshots
+          if (solver_type == 3) then
+             open(unit=11, file=trim(filename2), status='unknown', iostat=ios)
+             if (ios /= 0) stop 'Error writing snapshot to disk'
+             do iglob = 1, NGLOB
+                xtemp = x_lon(iglob) ; ztemp = z_lat(iglob)
+                write(11,'(5e16.6)') sngl(xtemp), sngl(ztemp), (sngl(b_displ(j,iglob)),j=1,NCOMP) 
+             enddo
+             close(11)
+             open(unit = 11, file = trim(filename3), status = 'unknown',iostat=ios)
+             open(unit = 12, file = trim(filename4), status = 'unknown',iostat=ios)
+             if (ios /= 0) stop 'Error writing snapshot to disk'
+
+             do iglob = 1, NGLOB
+
+                xtemp = x_lon(iglob) ; ztemp = z_lat(iglob)
+
+                if(ISURFACE==0) then
+                   ! six kernels into two files
+                   write(11,'(5e16.6)') sngl(xtemp), sngl(ztemp), sngl(rho_kernel(iglob)), &
+                              sngl(mu_kernel(iglob)), sngl(kappa_kernel(iglob))
+                   write(12,'(5e16.6)') sngl(xtemp), sngl(ztemp), sngl(rhop_kernel(iglob)), &
+                              sngl(beta_kernel(iglob)), sngl(alpha_kernel(iglob))
+                else
+                   ! x, z, interaction, beta
+                   write(12,'(4e16.6)') sngl(xtemp), sngl(ztemp), &
+                              sngl(beta_kernel_prime(iglob)), sngl(beta_kernel(iglob))
+                endif
+             enddo
+             close(11)
+             close(12)
+
+          endif  ! solver_type == 3
+          endif  ! WRITE_KERNELS
+
+       endif  ! write snapshots or kernels
+
+    enddo ! end time loop
+
+    if(solver_type == 3) deallocate(stf_for)
+
+  end subroutine solver
+!---------------------------------------------
+
+end module wave2d_solver

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,601 @@
+module wave2d_sub
+
+  use wave2d_constants
+  use wave2d_variables
+
+  implicit none
+
+contains
+
+  !-----------------------------------------------------  
+
+  subroutine write_parameters(filename)
+
+    character(len=*),intent(in) :: filename
+
+    print *, 'writing out parameters'
+
+    open(unit=12, file=filename, status='unknown', iostat=ios)
+        
+    write(12,*) 'hey you'
+
+    close(12)
+
+  end subroutine write_parameters
+
+  !-----------------------------------------------------  
+
+!!$  subroutine get_source_function(nsrc,origin_time,f0,samp,ti)
+!!$
+!!$  ! compute the source time function for each source
+!!$  ! in general, we use a point source
+!!$  ! note that we do not need to know WHERE the source is located
+!!$
+!!$    ! input
+!!$    integer, intent(in) :: nsrc
+!!$    double precision, intent(in) :: f0(NCOMP)
+!!$    double precision, intent(in) :: origin_time
+!!$
+!!$    double precision, intent(inout) :: samp(NSTEP,NCOMP,nsrc)
+!!$    double precision, intent(out) :: ti(NSTEP)
+!!$    integer :: i,icomp
+!!$
+!!$  ! fill each source index with the source time function
+!!$  ! multiplied by the magnitude and direction of the source
+!!$  do i = 1,nsrc
+!!$    do icomp = 1,NCOMP
+!!$       samp(:, icomp, i) = stf(:) * f0(icomp)
+!!$    enddo
+!!$  enddo
+!!$
+!!$  end subroutine get_source_function
+
+  !-----------------------------------------------------  
+
+  subroutine get_source_time_function(origin_time,stf_vec,ti)
+
+  ! compute the source time function for each source
+  ! in general, we use a point source
+  ! note that we do not need to know WHERE the source is located
+
+    double precision, intent(in) :: origin_time
+    double precision, intent(out) :: ti(NSTEP), stf_vec(NSTEP)
+
+    ! source decay rate (also change in source spectrum if needed)
+    double precision, parameter :: decay_rate = 2.628d0
+    !double precision, external :: erf
+
+    integer :: itime,i,cyc,icomp,nsrc_plot
+    double precision :: alpha, per, t, t1, t2, amp, stf, fgaus, dgaus, tmp
+    double precision :: az,kx,ky,c_source
+    double precision, dimension(:), allocatable :: d_vec
+    character(len=200) :: filename
+
+!-------------------------------------
+
+  print *
+  print *, 'compute the forward source time function in get_source_time_function.f90'
+  print *, 'hdur = ',sngl(hdur),' s, ISRC_TIME = ', ISRC_TIME
+  print *, 'origin time is = ', sngl(origin_time),' s'
+
+  ! parameters for source time function
+  ! the non-zero Gaussian is needed for plotting the source time function (perl)
+  alpha = decay_rate/hdur
+  fgaus = 1.d-8                  ! fraction of amplitude at edge of gaussian
+  dgaus = sqrt(-log(fgaus)) / alpha
+
+  if(ISRC_TIME==1) then ! Ricker
+     amp = -2.*(alpha**3)/dsqrt(PI)
+
+  elseif(ISRC_TIME==2) then ! Gaussian
+     amp = alpha/dsqrt(PI)
+
+  elseif(ISRC_TIME==3) then ! truncated sine
+     cyc = 3
+     per = 2.*hdur
+     !t1 = -0.50*per
+     t1 = 0.
+     t2 = t1 + per*dble(cyc)
+     amp = alpha**2*dsqrt(2./PI)*exp(-0.5d0)
+
+  elseif(ISRC_TIME==4) then ! sine
+     per = 2.*hdur
+     amp = alpha**2*dsqrt(2./PI)*exp(-0.5d0)
+
+!!$  elseif(ISRC_TIME==5) then ! plane wave field
+!!$
+!!$     amp = alpha**2*dsqrt(2./PI)*exp(-0.5d0)   ! amplitude
+!!$     az = 25.*PI/180.                          ! azimuth of vector (from north)
+!!$     kx = sin(az) ; ky = cos(az)               ! directional unit vector k
+!!$     per = 2.*hdur                             ! period of wavefield (s)
+!!$
+!!$     ! phase velocity of source wavefield (m/s)
+!!$     ! NOTE: this signal will be ALIASED if the wavelength is too short
+!!$     ! this is based on the Airy dispersion for gravity waves (Bromirski+Duennebier, 5-3)
+!!$     ! probably the speed should be based on the slope of the seafloor
+!!$     !c_source = 9.81*per/(2*PI)  ! T=16s, c=25 m/s
+!!$     c_source = c0
+!!$   
+!!$     ! projection of each source point vector onto the directional vector k
+!!$     allocate(d_vec(nsrc))
+!!$     d_vec(:) = 0.
+!!$     print *
+!!$     print *, 'Plane wave source:'
+!!$     print *, '   azimuth        : ', sngl(az*180/PI)
+!!$     print *, '   period         : ', sngl(per), ' s'
+!!$     print *, '   phase velocity : ', sngl(c_source/1000.), ' km/s'
+!!$     print *, '   wavelength     : ', sngl(c_source*per/1000.), ' km'
+!!$     print *, 'relative distance from plane wave wavefront to each source point:' 
+!!$     do i=1,nsrc
+!!$        d_vec(i) = kx*x(sglob(i)) + ky*z(sglob(i))
+!!$        write(*,'(i6,3f12.3)') i, x(sglob(i))/1000., z(sglob(i))/1000., d_vec(i)/1000.
+!!$     enddo
+!!$     print *
+  endif
+
+    do itime = 1, NSTEP
+       ti(itime) = dble(itime-1)*DT
+
+       t = ti(itime) - origin_time  ! time shift
+    
+       if(ISRC_TIME==1) then
+          ! d/dt[Gaussian] wavelet
+          if(t >= -dgaus .and. t <= dgaus) then
+             stf = amp*t*exp(-alpha*alpha*t*t)
+          else
+             stf = 0.
+          endif
+
+       elseif(ISRC_TIME==2) then
+          ! Error function
+          ! source_time_function = 0.5d0*(1.0d0+erf(decay_rate*t/hdur))
+
+          ! Gaussian (this one causes static offset at stations)
+          if(t >= -dgaus .and. t <= dgaus) then
+             stf = amp*exp(-alpha*alpha*t*t)
+          else
+             stf = 0.
+          endif
+
+       elseif(ISRC_TIME==3) then
+          ! truncated sine function (duration is cyc*per seconds)
+          if(t >= t1 .and. t <= t2) then
+             stf = amp*sin(2*PI*(t-t1)/per)
+          else
+             stf = 0.
+          endif
+
+       elseif(ISRC_TIME==4) then
+          ! sine function
+          stf = amp*sin(2*PI*t/per)
+          !stf = amp/2.*sin(2*PI*t/per) + amp/2.*sin(2*PI*t/(1.1*per))
+
+       !elseif(ISRC_TIME==5) then
+       !   ! plane wavefield, dependant on source position
+       !   tmp = t - d_vec(i)/c_source
+       !   !stf = amp*sin( 2*PI/per*tmp )
+       !   stf = amp/2.*sin(2*PI*tmp/per) + amp/2.*sin(2*PI*tmp/(1.1*per))
+
+       endif
+  
+       ! fill source time function
+       stf_vec(itime) = stf
+    
+    enddo
+
+
+  ! taper time series
+  ! DO WE WANT TO SIMPLY DETREND THE TIME SERIES?
+  if(SRC_TAPER) call taper_series(stf_vec(:),NSTEP)
+
+  end subroutine get_source_time_function
+
+  !-----------------------------------------------------  
+
+  subroutine taper_series(x,nt)
+
+  integer, intent(in) :: nt
+  double precision, intent(inout) :: x(nt)
+
+  double precision :: ntemp,jtemp,wtemp,cfac
+  integer :: i,pwr
+ 
+  ntemp = dble(nt)/2.0
+
+  ! KEY COMMAND: power of polynomial taper
+  ! higher power means affecting only the ends of the series
+  pwr = 10   ! Welch : pwr=2
+
+  ! Welch taper (in time)
+  do i = 1,nt
+     
+     jtemp = dble(i-1)
+     wtemp = (jtemp - ntemp) / ntemp
+     cfac = 1. - wtemp**pwr
+     !cfac = 1 - (2*(i - 1)/(nt - 1) - 1) ** pwr  ! see Qinya code below
+ 
+     x(i) = cfac*x(i)
+  enddo 
+
+  end subroutine taper_series
+
+  !-----------------------------------------------------  
+
+  subroutine write_snapshot(disp, filename)
+
+    double precision,intent(in) :: disp(NCOMP,NGLOB)
+    character(len=200),intent(in) :: filename
+
+    integer :: icomp, iglob, ios
+
+    open(unit = 11, file = trim(filename), status = 'unknown',iostat=ios)
+    if (ios /= 0) stop 'Error writing snapshot to disk'
+    do iglob = 1, NGLOB
+       if(NCOMP==3) then
+          write(11,'(5e12.3)') x(iglob)/LENGTH, z(iglob)/LENGTH, &
+                  sngl(disp(1,iglob)),sngl(disp(2,iglob)),sngl(disp(3,iglob))
+       else
+          write(11,'(5e12.3)') x(iglob)/LENGTH, z(iglob)/LENGTH, sngl(disp(1,iglob))
+       endif
+    enddo
+    close(11)
+
+  end subroutine write_snapshot
+
+  !-----------------------------------------------------   
+
+!!$  subroutine write_source_function(nsrc, ti, seis, sglob, seis_name)
+!!$
+!!$    integer, intent(in) :: nsrc
+!!$    integer, intent(in) :: sglob(nsrc)
+!!$    double precision, intent(in) ::  seis(NSTEP,NCOMP,nsrc)
+!!$    double precision, intent(in) ::  ti(NSTEP)
+!!$    character(len=*),intent(in) :: seis_name
+!!$
+!!$    character(len=200) :: filename
+!!$    integer :: i,icomp,itime
+!!$
+!!$    print *, 'writing out source time function'
+!!$
+!!$   ! write out source time functions for each point source
+!!$   do i = 1,nsrc
+!!$      do icomp = 1,NCOMP
+!!$
+!!$         write(filename,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_', i, '_', icomp
+!!$
+!!$         open(12,file=filename,status='unknown')
+!!$         write(*,*) 'Source #', i, ' at ', sngl(x_lon(sglob(i))), ', ', sngl(z_lat(sglob(i)))
+!!$         do itime=1,NSTEP
+!!$            write(12,'(f16.6,e16.6)') ti(itime), seis(itime,icomp,i)
+!!$            !write(12,'(f16.6,e16.6)') ti(itime), seis(itime,icomp,nsrc)/maxval(seis(:,icomp,nsrc))
+!!$         enddo
+!!$         close(12)
+!!$      enddo
+!!$   enddo
+!!$
+!!$  end subroutine write_source_function
+
+  !-----------------------------------------------------   
+
+  subroutine write_seismogram(seis, nrec, seis_name)
+
+    integer, intent(in) :: nrec
+    double precision, intent(in) ::  seis(NSTEP,NCOMP,nrec)
+    character(len=*),intent(in) :: seis_name
+
+    character(len=200) :: filename
+    integer :: irec, icomp, itime
+
+    print *, 'writing out time series (source time function or seismogram)'
+
+    do irec = 1,nrec
+       do icomp = 1,NCOMP
+          write(filename,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_', irec, '_', icomp
+          open(unit = 12, file = filename, status = 'unknown', iostat=ios)
+          if (ios /= 0) stop 'Error opening seismogram to write'
+
+          do itime = 1,NSTEP
+             write(12,*) DT*itime, seis(itime, icomp, irec)
+          enddo
+
+          close(12)
+       enddo
+    enddo
+
+  end subroutine write_seismogram
+
+  !-----------------------------------------------------   
+
+  subroutine write_spectral_map(seis, nrec, rglob, seis_name, write_spectra)
+
+    integer, intent(in) :: nrec
+    integer, intent(in) :: rglob(nrec)
+    double precision, intent(in) ::  seis(NSTEP,NCOMP,nrec)
+    character(len=*),intent(in) :: seis_name
+    logical, intent(in) :: write_spectra
+
+    character(len=200) :: filename,filename1,filename2
+    integer :: i, irec, icomp, itime
+
+    ! frequency domain
+    integer, parameter :: FFTW_FORWARD=-1, FFTW_ESTIMATE=0
+    complex*16 :: out(NOUT)
+    double precision :: in(NSTEP),ti(NSTEP)
+    integer :: plan
+    double precision :: wmax,w,re,im,abs_val,ph_val,dw,abs_int
+    double precision :: wmin_win, wmax_win
+
+    !------------------------------------
+
+    wmax = PI/DT        ! Nyquist frequency
+
+    ! window for computing integrated power spectrum
+    ! fmin,fmax are parameters (constants.f90)
+    wmin_win = 2*PI*fmin
+    wmax_win = 2*PI*fmax
+
+    do icomp = 1,NCOMP
+
+       ! open spectral map file
+       write(filename1,'(a,a,i1.1)') trim(seis_name), '_map_', icomp
+       open(unit=99, file=filename1, status='unknown', iostat=ios)
+       if (ios /= 0) stop 'Error opening spectral map file to write'
+
+       do irec = 1, nrec
+
+          call dfftw_plan_dft_r2c_1d(plan,NSTEP,in,out,FFTW_ESTIMATE)
+
+          ! specify input time series
+          in(:) = seis(:,icomp,irec)
+
+          if(0==1) then
+            ! write input data to file
+            write(filename,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_in_', irec, '_', icomp
+            open(unit=10, file=filename, status='unknown', iostat=ios)
+            if (ios /= 0) stop 'Error opening seismogram to write'
+            do itime = 1,NSTEP
+               write(10,'(2e16.6)') DT*itime , in(itime)
+            enddo
+            close(10)
+          endif
+
+          call dfftw_execute(plan)
+
+          if(write_spectra) then
+             write(filename2,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_', irec, '_', icomp
+             open(unit=12, file=filename2, status='unknown', iostat=ios)
+             if (ios /= 0) stop 'Error opening seismogram spectra to write'
+          endif
+
+          dw = wmax/dble(NOUT)
+          abs_int = 0.
+          do i = 1,NOUT
+             !w = (i-1)/dble(NOUT) * wmax
+             w = (i-1)*dw
+             re = real(out(i))
+             im = aimag(out(i))
+             abs_val = sqrt(re*re+im*im)
+             !ph_val = atan2(im,re)
+
+             ! if within the frequency band
+             if(w >= wmin_win .and. w <= wmax_win) abs_int = abs_int + abs_val
+
+             if(write_spectra) write(12,'(2e16.6)') w, abs_val 
+             !if(write_spectra.and.w/=0.) write(12,'(2e16.6)') (2*PI)/w, abs_val 
+          enddo
+          if(write_spectra) close(12)
+ 
+          if(0==1) then
+            write(*,'(a,3f12.4)') ' T, s     (min/0/max) :', (2*PI)/wmax_win , 2*hdur        , (2*PI)/wmin_win
+            write(*,'(a,3f12.4)') ' f, Hz    (min/0/max) :', wmin_win/(2*PI) , 1/(2*hdur)    , wmax_win/(2*PI)
+            write(*,'(a,3f12.4)') ' w, rad/s (min/0/max) :', wmin_win        , 2*PI/(2*hdur) , wmax_win
+            write(*,'(a,e24.8)')  '     integrated power :', dw*abs_int
+            print * 
+          endif   
+
+          call dfftw_destroy_plan(plan)
+
+          ! write the spectral amplitude to file
+          write(99,'(3e16.6)') x_lon(rglob(irec)), z_lat(rglob(irec)), dw*abs_int
+          !write(99,'(3e16.6)') x(rglob(irec)), z(rglob(irec)), dw*abs_int
+
+       enddo  ! irec
+       close(99)  ! spectral map file for one component
+    enddo  ! icomp
+
+  end subroutine write_spectral_map
+
+  !-----------------------------------------------------   
+
+  subroutine filter(ti, seis, nrec)
+
+    integer, intent(in) :: nrec
+    double precision, intent(in) :: ti(NSTEP)
+    double precision, intent(inout) :: seis(NSTEP,NCOMP,nrec)
+    
+    character(len=200) :: filename
+    double precision :: data(NSTEP)
+    double precision :: dt
+    integer irec,itime,icomp,npts
+
+    npts = NSTEP
+    dt = ti(2) - ti(1)
+
+    do irec = 1, nrec
+       do icomp = 1,NCOMP
+          data(:) = 0.
+          data(:) = seis(:,icomp,irec)
+
+!!$          write(filename,'(a,i5.5,a,i1.1)') trim(out_dir)//'bpass_in_', irec, '_', icomp
+!!$          open(unit=11, file=filename, status='unknown')
+!!$          write(11,'(2e16.6)') (ti(itime), data(itime), itime=1,NSTEP)
+!!$          close(11)
+
+          ! bandpass filter the records (see constants.f90 for parameter values)
+          call rmean(data,npts)
+          call rtrend(data,npts)
+          call xapiir(data,npts,'BU',trbdndw,a,iord,'BP',fmin, fmax, dt, passes)
+
+!!$          write(filename,'(a,i5.5,a,i1.1)') trim(out_dir)//'bpass_out_', irec, '_', icomp
+!!$          open(unit=12, file=filename, status='unknown')
+!!$          write(12,'(2e16.6)') (ti(itime), data(itime), itime=1,NSTEP)
+!!$          close(12)
+
+          ! replace the unfiltered record by the filtered record
+          seis(:,icomp,irec) = data(:)
+
+       enddo
+    enddo
+
+  end subroutine filter
+
+  !----------------------------------------------------
+
+  subroutine make_adjoint_source(nrec, syn, tstart, tend, adj_syn, data)
+
+  integer, intent(in) :: nrec
+  double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+  double precision, dimension(nrec), intent(in) :: tstart, tend
+  double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+
+  double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+
+  integer itime, icomp, istart, iend, nstart, nend, i, j, irec
+  double precision, dimension(NSTEP) :: time_window
+  double precision, dimension(NSTEP,NCOMP,nrec) :: syn_veloc, syn_accel
+  double precision :: norm_mat(nrec,NCOMP)
+  double precision :: norm, junk, ntemp
+
+  !----------------------------------------
+
+  adj_syn(:,:,:) = 0.
+  norm_mat(:,:) = 0.
+
+  do irec = 1,nrec
+
+    ! time window function
+
+    istart = max(floor(tstart(irec) / DT), 1)
+    iend = min(floor(tend(irec) / DT), NSTEP)
+    if (istart >= iend) stop 'Check if istart < iend'
+
+    write(*,'(a,i6,a,f12.6,a,f12.6)') ' Receiver ', irec, ' : time window is from ', tstart(irec), ' to', tend(irec)
+    write(*,*) '       index ', istart, ' to ', iend
+
+    time_window(:) = 0.
+
+    ! welch taper
+    ntemp = (iend - istart + 1)/2.
+    do i = istart, iend
+      !time_window(i) = 1 - (2 * (i - istart)/(iend - istart) - 1) ** 2
+
+      time_window(i) = 1 - ( (i - istart + 1 - ntemp) / ntemp  ) ** 2
+    enddo
+
+    !---------------------------
+
+    ! calculate velocity and acceleration from syn (traveltime adjoint source only)
+    if(IKER >= 1) then
+       do itime = 2, NSTEP-1
+          syn_veloc(itime,:,irec) =  (syn(itime+1,:,irec) - syn(itime-1,:,irec)) / (2 * DT)
+       enddo
+       syn_veloc(1,:,irec) = (syn(2,:,irec) - syn(1,:,irec)) / DT
+       syn_veloc(NSTEP,:,irec) = (syn(NSTEP,:,irec) - syn(NSTEP-1,:,irec)) /DT
+
+       do itime = 2, NSTEP-1
+          syn_accel(itime,:,irec) =  (syn_veloc(itime+1,:,irec) - syn_veloc(itime-1,:,irec)) / (2 * DT)
+       enddo
+       syn_accel(1,:,irec) = (syn_veloc(2,:,irec) - syn_veloc(1,:,irec)) / DT
+       syn_accel(NSTEP,:,irec) = (syn_veloc(NSTEP,:,irec) - syn_veloc(NSTEP-1,:,irec)) /DT
+    endif
+
+    ! assign adjoint force
+
+    do i = 1,NCOMP
+
+       if(IKER==0) then       ! waveform
+
+          adj_syn(:,i,irec) = ( syn(:,i,irec) -  data(:,i,irec) ) * time_window(:)
+
+       elseif(IKER==5) then   ! traveltime
+
+          ! minus sign is shifted from norm to adj_syn, in comparison with Tromp et al (2005)
+          ! thus, norm is ensured to be POSITIVE (N > 0)
+          norm = -DT * sum( time_window(:) * syn(:,i,irec) * syn_accel(:,i,irec) )
+          if (abs(norm) > EPS) adj_syn(:,i,irec) = -syn_veloc(:,i,irec) * time_window(:) / norm
+
+       elseif(IKER==6) then  ! amplitude
+
+          ! norm is ensured to be POSITIVE (M > 0)
+          norm = DT * sum( time_window(:) * syn(:,i,irec) * syn(:,i,irec) )
+          if (abs(norm) > EPS) adj_syn(:,i,irec) = syn(:,i,irec) * time_window(:) / norm
+
+       endif
+
+       norm_mat(irec,i) = norm  ! could be either nothing or traveltime or amplitude
+
+       !adj_syn(:,i,irec) = time_window(:) ! test
+       !adj_syn(:,i,irec) = syn(:,i,irec) ! test
+    enddo
+
+  enddo ! loop over all receivers
+
+  ! write normalizations to file
+  open(15,file=trim(out_dir)//'Nbanana.dat',status='unknown')
+  do irec = 1,nrec
+     do i = 1,NCOMP
+        write(15,'(2i12,1e18.6)') irec, i, norm_mat(irec,i)
+     enddo
+  enddo
+  close(15)
+
+  end subroutine make_adjoint_source
+
+  !-----------------------------------------------------
+
+!!$  subroutine waveform_adjoint_source(nrec, syn, data, tstart, tend, adj_syn)
+!!$
+!!$    integer, intent(in) :: nrec
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn, data
+!!$    double precision, dimension(nrec), intent(in) :: tstart, tend
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+!!$
+!!$    integer itime, icomp, istart, iend, nstart, nend, i, j, irec
+!!$    double precision, dimension(NSTEP) :: time_window
+!!$    double precision :: ntemp
+!!$
+!!$    !----------------------------------------
+!!$
+!!$    adj_syn(:,:,:) = 0.
+!!$
+!!$    do irec = 1,nrec
+!!$
+!!$       ! time window function
+!!$
+!!$       istart = max(floor(tstart(irec) / DT), 1)
+!!$       iend = min(floor(tend(irec) / DT), NSTEP)
+!!$       if (istart >= iend) stop 'Check if istart < iend'
+!!$
+!!$       write(*,'(a,i6,a,f12.6,a,f12.6)') ' Receiver ', irec, ' : time window is from ', tstart(irec), ' to', tend(irec)
+!!$       write(*,*) '       index ', istart, ' to ', iend
+!!$
+!!$       time_window(:) = 0.
+!!$
+!!$       ! welch taper
+!!$       ntemp = (iend - istart + 1)/2.
+!!$       do i = istart, iend
+!!$         time_window(i) = 1 - ( (i - istart + 1 - ntemp) / ntemp  ) ** 2
+!!$       enddo
+!!$
+!!$      ! assign adjoint force
+!!$      do i = 1,NCOMP
+!!$       
+!!$         adj_syn(:,i,irec) = ( syn(:,i,irec) -  data(:,i,irec) ) * time_window(:)
+!!$
+!!$      enddo
+!!$
+!!$    enddo ! loop over all receivers
+!!$
+!!$  end subroutine waveform_adjoint_source
+
+end module wave2d_sub

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub2.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub2.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub2.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,809 @@
+module wave2d_sub2
+ 
+  use wave2d_constants
+  use wave2d_variables
+ 
+  implicit none
+ 
+! this module contains subroutines pertaining to filtering gridpoints
+! and converting amoung UTM, mesh, and index coordinates
+
+contains
+
+!=====================================================================
+
+  subroutine locate_targets(nrec, x_target, z_target, &
+       iglob_selected_rec, ispec_selected_rec, xi_receiver, gamma_receiver)
+
+    ! adapted from locate_receivers.f90 (3D code)
+    ! This does NOT remove redundant closest gridpoints, like in set_glob.f90
+
+    ! input
+    integer, intent(inout) :: nrec
+    double precision, intent(inout) :: x_target(nrec), z_target(nrec)
+
+    ! output -- note that (ispec, xi, gamma) are optional output
+    integer,          dimension(nrec), intent(out)           :: iglob_selected_rec
+    integer,          dimension(nrec), intent(out), optional :: ispec_selected_rec
+    double precision, dimension(nrec), intent(out), optional :: xi_receiver, gamma_receiver
+
+    ! local
+    double precision, dimension(nrec) :: x_found, z_found, final_distance, dmin_selected_rec
+    integer, dimension(nrec) :: ix_initial_guess, iz_initial_guess
+    double precision :: dmin, dist
+    double precision :: xtemp, ztemp, xi, gamma, dx, dz, dxi, dgamma
+    double precision :: xix,xiz,gammax,gammaz
+    integer :: irec, ispec, i, j, iglob, iter_loop, ispec_iterate
+    logical :: i_xi_gamma
+
+    ! control points of the surface element
+    !integer iax, iaz, ia
+    !integer iaddx(NGNOD2D), iaddz(NGNOD2D)
+    !double precision xelm(NGNOD2D),zelm(NGNOD2D)
+
+  !----------------------------------
+
+  print *, nrec,' input target points into locate_targets.f90'
+  print *, ' all target points should now lie within the mesh (station_filter.f90)'
+
+  ! boolean: whether the (ispec, xi, gamma) are in the subroutine call
+  i_xi_gamma = present(ispec_selected_rec) .and. present(xi_receiver) .and. present(gamma_receiver)
+
+  ! loop over target points to get the (xi,gamma) for the closest gridpoint
+  do irec=1,nrec
+
+      dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+
+      do ispec=1,NSPEC
+
+        ! loop only on points inside the element
+        ! exclude edges to ensure this point is not shared with other elements
+        do j = 2,NGLLZ-1
+          do i = 2,NGLLX-1
+
+            iglob = ibool(i,j,ispec)
+            dist = sqrt((x_target(irec) - x(iglob))**2 + (z_target(irec) - z(iglob))**2)
+
+            ! keep this point if it is closer to the receiver
+            if(dist < dmin) then
+              dmin = dist
+              dmin_selected_rec(irec) = dmin
+              iglob_selected_rec(irec) = iglob  ! closest gridpoint
+              if(i_xi_gamma) then
+                ispec_selected_rec(irec) = ispec
+                ix_initial_guess(irec) = i
+                iz_initial_guess(irec) = j
+              endif
+            endif
+
+          enddo
+        enddo
+      enddo  ! ispec
+   enddo  ! irec
+
+   ! TESTING ONLY (01-Feb-2006)
+   ! If the GLL points are your target points, then this should give the same
+   ! "interpolated" seismograms as if you simply saved the wavefield at the GLL point.
+   !x_target(:) = x(iglob_selected_rec(:))
+   !z_target(:) = z(iglob_selected_rec(:))
+
+  ! ****************************************
+  ! find the best (xi,gamma) for each target point
+  ! ****************************************
+
+  ! if the (xi, gamma) are desired
+  if(i_xi_gamma) then
+
+     do irec = 1,nrec
+
+        ! element that contains the target point
+        ispec_iterate = ispec_selected_rec(irec)
+
+        ! use initial guess in xi and gamma
+        xi    = xigll(ix_initial_guess(irec))
+        gamma = zigll(iz_initial_guess(irec))
+
+!!$    ! define coordinates of the control points of the element
+!!$    ! (ordering of these four points shouldn't matter)
+!!$    ! We could also access the vectors x1,x2,z1,z2 instead.
+!!$    do ia = 1,NGNOD2D    ! (NGNOD2D = 4)
+!!$
+!!$       if(ia==1) then
+!!$          iax = 1
+!!$          iaz = 1
+!!$       elseif(ia==2) then
+!!$          iax = NGLLX
+!!$          iaz = 1
+!!$       elseif(ia==3) then
+!!$          iax = NGLLX
+!!$          iaz = NGLLZ
+!!$       elseif(ia==4) then
+!!$          iax = 1
+!!$          iaz = NGLLZ
+!!$       endif
+!!$       iglob = ibool(iax,iaz,ispec_iterate)
+!!$       xelm(ia) = x(iglob)
+!!$       zelm(ia) = z(iglob)
+!!$    enddo  ! ia
+
+        ! iterate to solve the non linear system (it seems we only need one iteration for 2D)
+        do iter_loop = 1,NUM_ITER
+
+           ! recompute jacobian for the new point
+           ! INPUT:  xelm,zelm,xi,gamma
+           ! OUTPUT: xtemp,ztemp,xix,xiz,gammax,gammaz
+
+           !call recompute_jacobian(xelm,yelm,zelm,xi,eta,gamma,xtemp,ytemp,ztemp, &
+           !   xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz)
+           call recompute_jacobian_2d(ispec_iterate,xi,gamma,xtemp,ztemp,xix,xiz,gammax,gammaz)
+
+           ! compute distance to target location
+           dx = -(xtemp - x_target(irec))
+           dz = -(ztemp - z_target(irec))
+
+           ! compute increments
+           ! gamma does not change since we know the receiver is exactly on the surface
+           dxi  = xix*dx + xiz*dz
+           dgamma = gammax*dx + gammaz*dz
+
+           !print *
+           !print *, 'iteration   : ', iter_loop
+           !print *, ' (dx, dz)   : ', dx,dz
+           !print *, ' (xi,gamma) : ', xi,gamma
+           !print *, xix,xiz,gammax,gammaz
+
+           ! update values
+           xi = xi + dxi
+           gamma = gamma + dgamma
+
+           !print *, xi,gamma,dxi,dgamma
+
+           ! impose that we stay in that element
+           ! (useful if user gives a receiver outside the mesh for instance)
+           ! we can go slightly outside the [1,1] segment since with finite elements
+           ! the polynomial solution is defined everywhere
+           ! can be useful for convergence of iterative scheme with distorted elements
+           if (xi > 1.10) xi = 1.10
+           if (xi < -1.10) xi = -1.10
+           if (gamma > 1.10) gamma = 1.10
+           if (gamma < -1.10) gamma = -1.10
+
+        enddo  ! iter_loop
+
+        ! compute final coordinates of point found
+        xtemp = 0. ; ztemp = 0.  ! re-initialize
+        call recompute_jacobian_2d(ispec_iterate,xi,gamma,xtemp,ztemp,xix,xiz,gammax,gammaz)
+
+        ! store xi,gamma and x,z of point found
+        xi_receiver(irec) = xi
+        gamma_receiver(irec) = gamma
+        x_found(irec) = xtemp
+        z_found(irec) = ztemp
+
+        ! compute final distance between asked and found
+        final_distance(irec) = sqrt((x_target(irec) - x_found(irec))**2 + &
+             (z_target(irec) - z_found(irec))**2)
+     enddo  ! irec
+
+     ! display information
+     do irec=1,nrec
+
+        if(final_distance(irec) == HUGEVAL) stop 'error locating receiver'
+
+        if(0==1) then
+           print *
+           print *,                'target point # ', irec
+           write(*,'(a,1f18.8)')   '  target x (km)            : ', x_target(irec)/1000.
+           write(*,'(a,1f18.8)')   '  target z (km)            : ', z_target(irec)/1000.
+           write(*,'(a,1e18.8,a)') '  closest gridpoint found  : ', dmin_selected_rec(irec)/1000.,' km away'
+           write(*,'(a,1f18.8)')   '  closest gridpoint x (km) : ', x(iglob_selected_rec(irec))/1000.
+           write(*,'(a,1f18.8)')   '  closest gridpoint z (km) : ', z(iglob_selected_rec(irec))/1000.
+           print *,                '     element = ', ispec_selected_rec(irec)
+           print *,                '          xi = ', xigll(ix_initial_guess(irec))
+           print *,                '       gamma = ', zigll(iz_initial_guess(irec))
+           write(*,'(a,1f18.8)')   '  estimate x (km)            : ', x_found(irec)/1000.
+           write(*,'(a,1f18.8)')   '  estimate z (km)            : ', z_found(irec)/1000.
+           print *,                '  closest estimate found   : ', final_distance(irec)/1000.,' km away'
+           print *,                '     element = ', ispec_selected_rec(irec)
+           print *,                '          xi = ', xi_receiver(irec)
+           print *,                '       gamma = ', gamma_receiver(irec)
+        endif
+
+        ! add warning if estimate is poor
+        ! (usually means receiver outside the mesh given by the user)
+        if(final_distance(irec) > 5.) then
+           print *, 'station # ',irec
+           print *, '*******************************************************'
+           print *, '***** WARNING: receiver location estimate is poor *****'
+           print *, '*******************************************************'
+        endif
+
+     enddo
+
+     ! replace the input target points with the (x,z) corresponding to the (xi,gamma) values
+     x_target(:) = x_found(:)
+     z_target(:) = z_found(:)
+
+  else
+     ! replace the input target points with the (x,z) of the closest gridpoint
+     x_target(:) = x(iglob_selected_rec(:))
+     z_target(:) = z(iglob_selected_rec(:))
+
+  endif
+
+  !print *
+  !print *, nrec,' output gridpoint indices from locate_targets.f90'
+
+  end subroutine locate_targets
+
+!=====================================================================
+
+  subroutine recompute_jacobian_2d(ispec, xi, gamma, xtemp, ztemp, xix, xiz, gammax, gammaz)
+
+! subroutine recompute_jacobian(xelm,yelm,zelm,xi,eta,gamma,x,y,z, &
+!                  xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz)
+
+  ! recompute jacobian for any (xi,eta,gamma) point, not necessarily a GLL point
+  ! adapted from recompute_jacobian.f90 and mesher.f90 (above)
+  !
+  ! INPUT:  ispec,xi,gamma
+  ! OUTPUT: xtemp,ztemp,xix,xiz,gammax,gammaz
+
+  ! input
+  integer ispec
+  double precision :: xi,gamma
+  !double precision xelm(NGNOD2D),zelm(NGNOD2D)  ! coordinates of the control points
+
+  ! output
+  double precision :: xtemp,ztemp,xix,xiz,gammax,gammaz
+
+  double precision :: jacob
+
+  !---------------------------------------------
+  !
+  ! jacobian = | dx/dxi dx/dgamma | = (z2-z1)*(x2-x1)/4  as dx/dgamma=dz/dxi = 0
+  !            | dz/dxi dz/dgamma | 
+
+  ! jacobian, integration weight
+  xix = 2. / (x2(ispec)-x1(ispec))
+  xiz = 0.
+  gammax = 0.
+  gammaz = 2. / (z2(ispec)-z1(ispec))
+
+  jacob = (z2(ispec)-z1(ispec))*(x2(ispec)-x1(ispec)) / 4. 
+
+  ! find the (x,z) corresponding to (xi,gamma,ispec)
+  xtemp = 0.5*(1.-    xi)*x1(ispec) + 0.5*(1.+   xi)*x2(ispec)
+  ztemp = 0.5*(1.- gamma)*z1(ispec) + 0.5*(1.+gamma)*z2(ispec)
+
+  if(jacob <= 0.) stop '2D Jacobian undefined'
+
+  end subroutine recompute_jacobian_2d
+
+!=====================================================================
+
+  subroutine lagrange_poly(xi,NGLL,xigll,h,hprime)
+
+  ! subroutine to compute the Lagrange interpolants based upon the GLL points
+  ! and their first derivatives at any point xi in [-1,1]
+  ! copied from lagrange_poly.f90 in Qinya's original codes
+
+    integer,intent(in) :: NGLL
+    double precision,intent(in) :: xi, xigll(NGLL)
+    double precision,intent(out) :: h(NGLL), hprime(NGLL)
+
+    integer dgr,i,j
+    double precision prod1,prod2
+
+  !---------------------------------------------
+
+  do dgr=1,NGLL
+
+     prod1 = 1.0
+     prod2 = 1.0
+     do i=1,NGLL
+        if(i /= dgr) then
+           prod1 = prod1*(xi-xigll(i))
+           prod2 = prod2*(xigll(dgr)-xigll(i))
+        endif
+     enddo
+     h(dgr)=prod1/prod2
+
+     hprime(dgr)=0.0
+     do i=1,NGLL
+        if(i /= dgr) then
+           prod1=1.0
+           do j=1,NGLL
+              if(j /= dgr .and. j /= i) prod1 = prod1*(xi-xigll(j))
+           enddo
+           hprime(dgr) = hprime(dgr)+prod1
+        endif
+     enddo
+     hprime(dgr) = hprime(dgr)/prod2
+
+  enddo
+
+  end subroutine lagrange_poly
+
+!=====================================================================
+
+  double precision function lagrange_deriv_GLL(I,j,ZGLL,NZ)
+
+  ! subroutine to compute the derivative of the Lagrange interpolants
+  ! at the GLL points at any given GLL point
+  !
+  !------------------------------------------------------------------------
+  !  Compute the value of the derivative of the I-th
+  !  Lagrange interpolant through the
+  !  NZ Gauss-Lobatto Legendre points ZGLL at point ZGLL(j)
+  !------------------------------------------------------------------------
+
+    integer i,j,nz
+    double precision zgll(0:nz-1)
+    integer degpoly
+    double precision, external :: pnleg,pndleg   ! external functions
+
+  !---------------------------------------------
+
+  degpoly = nz - 1
+  if (i == 0 .and. j == 0) then
+    lagrange_deriv_GLL = - dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+
+  else if (i == degpoly .and. j == degpoly) then
+    lagrange_deriv_GLL = dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+
+  else if (i == j) then
+    lagrange_deriv_GLL = 0.d0
+
+  else
+    lagrange_deriv_GLL = pnleg(zgll(j),degpoly) / &
+      (pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))) &
+      + (1.d0-zgll(j)*zgll(j))*pndleg(zgll(j),degpoly) / (dble(degpoly)* &
+      (dble(degpoly)+1.d0)*pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))*(zgll(j)-zgll(i)))
+  endif
+
+  end function lagrange_deriv_GLL
+
+!=====================================================================
+
+  subroutine set_glob(nrec, x_rec, z_rec, rglob)
+
+    integer, intent(inout) :: nrec
+    double precision, intent(in) :: x_rec(nrec), z_rec(nrec)
+    integer, intent(out) :: rglob(nrec)
+    
+    double precision :: dmin, d
+    integer, dimension(nrec) :: rglobtemp
+    integer :: irec, ispec, i, j, k, iglob, itemp, iflag
+
+    !----------------------------------
+
+    print *, nrec,' input target points into set_glob.f90'
+
+    if(nrec/=0) then
+       
+       ! find the closest gridpoint to the target point
+       do irec = 1, nrec
+          dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+          do iglob = 1,NGLOB
+             d = sqrt((x_rec(irec)-x(iglob))**2+(z_rec(irec)-z(iglob))**2)
+             if(d < dmin) then
+                dmin  = d
+                rglob(irec) = iglob
+             endif
+          enddo
+       enddo
+
+       ! remove redundant gridpoint indices
+       ! (is there a more elegant way to do this?)
+       rglobtemp(1) = rglob(1)
+       k = 1
+       do i = 2,nrec
+          itemp = rglob(i)
+          iflag = 0
+          do j = 1,i
+             if(rglobtemp(j) == itemp) iflag = 1
+          enddo
+          if(iflag==0) then
+             k = k+1
+             rglobtemp(k) = itemp
+          endif
+       enddo
+
+       ! update nrec and rglob
+       nrec = k
+       rglob(1:nrec) = rglobtemp(1:nrec)
+       print *, nrec,' output gridpoint indices from set_glob.f90'
+
+       ! NO NEED TO LOOP OVER i,j,k -- only iglob
+!!$    do irec = 1, nrec
+!!$       d_min_rec = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+!!$       do ispec = 1,NSPEC
+!!$          do j = 1,NGLLZ
+!!$             do i = 1,NGLLX
+!!$                iglob = ibool(i,j,ispec)
+!!$                d = sqrt((x_rec(irec)-x(iglob))**2+(z_rec(irec)-z(iglob))**2)
+!!$                if(d < d_min_rec) then
+!!$                  d_min_rec  = d
+!!$                  rglob(irec) = ibool(i,j,ispec)
+!!$                endif
+!!$             enddo
+!!$          enddo
+!!$       enddo
+!!$    enddo
+
+  endif
+
+  end subroutine set_glob
+
+!=====================================================================
+
+!  subroutine station_filter(nrec, x_rec, z_rec, dmin_trsh, ncoast, coast_x, coast_z)
+  subroutine station_filter(nrec, x_rec, z_rec, ifilter, dmin_trsh)
+
+    integer, intent(inout) :: nrec
+    double precision, intent(in) :: dmin_trsh, x_rec(nrec), z_rec(nrec)   ! NOTE INPUT ONLY
+    integer, intent(out) :: ifilter(nrec)
+
+    !integer, intent(in) :: ncoast
+    !double precision, intent(in) :: dmin_trsh
+    !double precision, intent(in) :: coast_x(ncoast), coast_z(ncoast)
+
+    double precision :: dmin, d, xtar, ztar
+    integer :: ispec, irec, i, j, iglob
+
+    !---------------------------------------
+
+    print *, nrec,' input target points into station_filter.f90 (some may be zeros)'
+    print *, 'removing target points that are outside mesh or'
+    print *, sngl(dmin_trsh/1000.),' km from grid boundary'
+    !print *, 'removing target points that are ',sngl(dmin_trsh/1000.),' km from the SoCal coast'
+
+    ! (1) exclude stations outside, or close to the boundary, of the mesh
+    ! (2) exclude stations within a certain distance of the SoCal coast
+
+    j = 0
+    do irec = 1,nrec
+
+       ! target point
+       xtar = x_rec(irec)
+       ztar = z_rec(irec)
+
+       ! if target point is not near grid boundary
+       if      (xtar >= 0.+dmin_trsh      &
+          .and. xtar <= LENGTH-dmin_trsh  &
+          .and. ztar >= 0.+dmin_trsh      &
+          .and. ztar <= HEIGHT-dmin_trsh) then
+
+          j = j+1
+          !x_rec(j) = xtar
+          !z_rec(j) = ztar
+          ifilter(j) = irec
+          
+          ! obtain the coastal point closest to the target point
+          !dmin = sqrt(LENGTH**2+HEIGHT**2)
+          !do i=1,ncoast
+          !   ! distance from target point to coastal points
+          !   d = sqrt((xtar-coast_x(i))**2+(ztar-coast_z(i))**2)
+          !   if(d < dmin) then
+          !      dmin  = d
+          !   endif
+          !enddo
+
+          !! if target point is at least dmin_trsh from the coast, then keep it 
+          !if ( dmin >= dmin_trsh ) then
+          !  j = j+1
+          !  x_rec(j) = xtar
+          !  z_rec(j) = ztar
+          !endif
+          
+       endif
+    enddo
+    nrec = j
+    print *, nrec,' output target points from station_filter.f90'
+
+!!$    ! modified to exclude stations within a designated circle (CHT)
+!!$    r    = 300.d+03
+!!$    xcen = 50.d+03
+!!$    zcen = 50.d+03
+!!$    j = 0
+!!$    do irec = 1, nrec
+!!$       d = sqrt((x(rglob(irec)) - xcen)**2+(z(rglob(irec)) - zcen)**2)
+!!$       if(d > r) then
+!!$          j = j+1
+!!$          rglob(j) = rglob(irec)
+!!$       endif
+!!$    enddo
+!!$    nrec = j
+!!$    print *, nrec,' output gridpoints'
+!!$    print *
+
+  end subroutine station_filter
+
+!=====================================================================
+
+  subroutine station_filter_2(nrec, x_rec, z_rec, ieast)
+
+    integer, intent(inout) :: nrec
+    double precision, intent(inout) :: x_rec(nrec), z_rec(nrec)
+    integer, intent(in) :: ieast
+
+    double precision :: xtar,ztar,m0,b0,mp,bp,x_div,z_div
+    integer :: irec, j
+
+    !---------------------------------------
+
+    ! dividing line for stations
+    m0 = HEIGHT/LENGTH    ! slope
+    b0 = 0.d+03           ! y-intercept
+    mp = -1./m0           ! perpendicular slope
+    !ieast = -1             ! (1) for east points or (-1) for west points
+
+    print *, nrec,' input target points into station_filter_2.f90'
+    print *, 'removing a fraction of the target points'
+
+    j = 0
+    do irec = 1,nrec
+
+       ! target point
+       xtar = x_rec(irec)
+       ztar = z_rec(irec)
+
+       ! obtain the closest point on the dividing line to the target point
+       bp       = ztar - mp*xtar
+       x_div    = (bp - b0)/(m0 - mp)
+       z_div    = mp*x_div + bp
+       !write(*,'(4f16.6)') xtar/1000., ztar/1000., x_div/1000., z_div/1000
+
+       ! if target point is at least dmin_trsh from the coast, then keep it 
+       if ( 0 < dble(ieast)*(xtar - x_div) ) then
+         j = j+1
+         x_rec(j) = xtar
+         z_rec(j) = ztar
+       endif
+    enddo
+    nrec = j
+    print *, nrec,' output target points from station_filter_2.f90'
+
+  end subroutine station_filter_2
+
+!=====================================================================
+
+  subroutine mesh_geo(npt,rlon,rlat,rx,rz,UTM_PROJECTION_ZONE,iway)
+
+  integer, intent(in) :: npt, UTM_PROJECTION_ZONE, iway
+  double precision, intent(inout) :: rx(npt),rz(npt),rlon(npt),rlat(npt)
+  
+  double precision :: xtemp,ztemp
+  integer i
+
+  if (iway==ILONLAT2MESH) then  ! lon-lat to mesh coordinates
+     do i=1,npt
+        call utm_geo(rlon(i),rlat(i),xtemp,ztemp,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+        rx(i) = xtemp - utm_xmin
+        rz(i) = ztemp - utm_zmin
+     enddo
+
+  else                           ! mesh coordinates to lon-lat
+     do i=1,npt
+        xtemp = rx(i) + utm_xmin
+        ztemp = rz(i) + utm_zmin
+        call utm_geo(rlon(i),rlat(i),xtemp,ztemp,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+     enddo
+  endif
+
+  end subroutine mesh_geo
+
+  !------------------------------------------
+
+  subroutine utm_geo(rlon,rlat,rx,ry,UTM_PROJECTION_ZONE,iway)
+
+!=====================================================================
+!
+!  UTM (Universal Transverse Mercator) projection from the USGS
+!
+!=====================================================================
+!
+! convert geodetic longitude and latitude to UTM, and back
+! use iway = ILONGLAT2UTM for long/lat to UTM, IUTM2LONGLAT for UTM to lat/long
+!
+! NOTE: THIS APPEARS TO BE ONLY GOOD TO SINGLE PRECISION (25-JAN-2006)
+!
+!
+!-----CAMx v2.03
+!
+!     UTM_GEO performs UTM to geodetic (long/lat) translation, and back.
+!
+!     This is a Fortran version of the BASIC program "Transverse Mercator
+!     Conversion", Copyright 1986, Norman J. Berls (Stefan Musarra, 2/94)
+!     Based on algorithm taken from "Map Projections Used by the USGS"
+!     by John P. Snyder, Geological Survey Bulletin 1532, USDI.
+!
+!     Input/Output arguments:
+!
+!        rlon                  Longitude (deg, negative for West)
+!        rlat                  Latitude (deg)
+!        rx                    UTM easting (m)
+!        ry                    UTM northing (m)
+!        UTM_PROJECTION_ZONE  UTM zone
+!        iway                  Conversion type
+!                              ILONGLAT2UTM = geodetic to UTM
+!                              IUTM2LONGLAT = UTM to geodetic
+!
+
+  integer UTM_PROJECTION_ZONE,iway
+  double precision rx,ry,rlon,rlat
+
+  double precision, parameter :: degrad=PI/180., raddeg=180./PI
+  double precision, parameter :: semimaj=6378206.4, semimin=6356583.8
+  double precision, parameter :: scfa=.9996
+  double precision, parameter :: north=0., east=500000.
+
+  double precision e2,e4,e6,e8,ep2,xx,yy,dlat,dlon,zone,cm,cmr,delam
+  double precision f1,f2,f3,f4,rm,rn,t,c,a,e1,u,rlat1,dlat1,c1,t1,rn1,r1,d
+  double precision rx_save,ry_save,rlon_save,rlat_save
+
+!---------------------------------------------------
+
+  if(SUPPRESS_UTM_PROJECTION) then
+    if (iway == ILONGLAT2UTM) then
+      rx = rlon
+      ry = rlat
+    else
+      rlon = rx
+      rlat = ry
+    endif
+    return
+  endif
+
+  ! save original parameters
+  rlon_save = rlon
+  rlat_save = rlat
+  rx_save = rx
+  ry_save = ry
+
+  ! define parameters of reference ellipsoid
+  e2  = 1.0-(semimin/semimaj)**2.0
+  e4  = e2*e2
+  e6  = e2*e4
+  e8  = e4*e4  
+  ep2 = e2/(1.-e2)
+
+  if (iway == IUTM2LONGLAT) then
+    xx = rx
+    yy = ry
+  else
+    dlon = rlon
+    dlat = rlat
+  endif
+
+  ! set zone parameters
+  zone = dble(UTM_PROJECTION_ZONE)
+  cm   = zone*6.0 - 183.0
+  cmr  = cm*degrad
+
+  if (iway == ILONGLAT2UTM) then  ! lat-lon to UTM
+     
+     rlon = degrad*dlon
+     rlat = degrad*dlat
+
+     delam = dlon - cm
+     if (delam < -180.) delam = delam + 360.
+     if (delam > 180.) delam = delam - 360.
+     delam = delam*degrad
+
+     f1 = (1. - e2/4. - 3.*e4/64. - 5.*e6/256)*rlat
+     f2 = 3.*e2/8. + 3.*e4/32. + 45.*e6/1024.
+     f2 = f2*sin(2.*rlat)
+     f3 = 15.*e4/256.*45.*e6/1024.
+     f3 = f3*sin(4.*rlat)
+     f4 = 35.*e6/3072.
+     f4 = f4*sin(6.*rlat)
+     rm  = semimaj*(f1 - f2 + f3 - f4)  ! mm in other code
+
+     if (dlat == 90. .or. dlat == -90.) then
+        xx = 0.
+        yy = scfa*rm
+
+     else
+        rn = semimaj/sqrt(1. - e2*sin(rlat)**2)
+        t = tan(rlat)**2
+        c = ep2*cos(rlat)**2
+        a = cos(rlat)*delam
+
+        f1 = (1. - t + c)*a**3 / 6.
+        f2 = 5. - 18.*t + t**2 + 72.*c - 58.*ep2
+        f2 = f2*a**5 / 120.
+        xx = scfa*rn*(a + f1 + f2)
+
+        f1 = a**2 / 2.
+        f2 = 5. - t + 9.*c + 4.*c**2
+        f2 = f2*a**4 / 24.
+        f3 = 61. - 58.*t + t**2 + 600.*c - 330.*ep2
+        f3 = f3*a**6/720.
+        yy = scfa*(rm + rn*tan(rlat)*(f1 + f2 + f3))
+
+     endif
+
+     ! apply false easting and northing
+     xx = xx + east
+     yy = yy + north
+
+  else  ! UTM to lat-lon
+     
+     ! remove false easting and northing
+     xx = xx - east
+     yy = yy - north
+
+     ! calculate the footpoint latitude
+     e1 = sqrt(1. - e2)
+     e1 = (1. - e1)/(1. + e1)
+     rm = yy/scfa
+     u = 1. - e2/4. - 3.*e4/64. - 5.*e6/256.
+     u = rm / (semimaj*u)
+
+     f1 = 3.*e1/2. - 27.*e1**3./32.
+     f1 = f1*sin(2.*u)
+     f2 = 21.*e1**2 / 16. - 55.*e1**4 / 32.
+     f2 = f2*sin(4.*u)
+     f3 = 151.*e1**3. / 96.
+     f3 = f3*sin(6.*u)
+     f4 = 1097.*e1**4. / 512.  ! added term (CHT)
+     f4 = f4*sin(8.*u)         ! added term (CHT)
+
+     rlat1 = u + f1 + f2 + f3 + f4
+     dlat1 = rlat1*raddeg
+
+     if (dlat1 >= 90. .or. dlat1 <= -90.) then
+        dlat1 = dmin1(dlat1,dble(90.) )
+        dlat1 = dmax1(dlat1,dble(-90.) )
+        dlon = cm
+
+     else
+        c1 = ep2*cos(rlat1)**2.
+        t1 = tan(rlat1)**2.
+        f1 = 1. - e2*sin(rlat1)**2.
+        rn1 = semimaj/sqrt(f1)
+        r1 = semimaj*(1. - e2)/sqrt(f1**3)
+        d = xx / (rn1*scfa)
+
+        ! latitude
+        f1 = rn1*tan(rlat1) / r1
+        f2 = d**2 / 2.
+        f3 = 5.*3.*t1 + 10.*c1 - 4.*c1**2 - 9.*ep2
+        f3 = f3*d**2*d**2 / 24.
+        f4 = 61. + 90.*t1 + 298.*c1 + 45.*t1**2. - 252.*ep2 - 3.*c1**2
+        f4 = f4*(d**2)**3 / 720.
+        rlat = rlat1 - f1*(f2 - f3 + f4)
+        dlat = rlat*raddeg
+
+        ! longitude
+        f1 = 1. + 2.*t1 + c1
+        f1 = f1*d**2*d/6.
+        f2 = 5. - 2.*c1 + 28.*t1 - 3.*c1**2 + 8.*ep2 + 24.*t1**2
+        f2 = f2*(d**2)**2*d/120.
+        rlon = cmr + (d - f1 + f2)/cos(rlat1)
+        dlon = rlon*raddeg
+        if (dlon < -180.) dlon = dlon + 360.
+        if (dlon >  180.) dlon = dlon - 360.
+      endif
+
+    endif
+
+    if (iway == IUTM2LONGLAT) then
+      rlon = dlon
+      rlat = dlat
+      rx = rx_save
+      ry = ry_save
+    else
+      rx = xx
+      ry = yy
+      rlon = rlon_save
+      rlat = rlat_save
+    endif
+
+  end subroutine utm_geo
+
+!=====================================================================
+
+end module wave2d_sub2

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub3.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub3.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_sub3.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,968 @@
+module wave2d_sub3
+ 
+  use wave2d_constants
+  use wave2d_variables
+ 
+  implicit none
+
+! this module contains subroutines pertaining to filtering gridpoints
+! and converting amoung UTM, mesh, and index coordinates
+ 
+contains
+
+  !------------------------------------------
+
+  subroutine mtm_adj(ipick, ievent, nrec, syn, tstart, tend, adj_syn, data)
+
+  ! PARAMETERS ARE INCLUDED IN wave2d_constants.f90
+  !parameter(NDIM=8000*4,NDIM2=16000*4,lnpt=14,npt=2**lnpt)
+  !parameter(MAXTAPER=5,wtr=0.02,ZZIGN=-1.0)
+  !implicit real(a-h,o-z)
+
+  double precision :: tas(NDIM,MAXTAPER), ey1(NDIM), ey2(NDIM), wpi
+  !double precision, dimension(NDIM,MAXTAPER) :: phi_mul, dt_mul, abs_mul, abs2_mul
+  double precision, dimension(NDIM) :: dzr, dzr2, phi, fr
+  double precision, dimension(NDIM) :: dzr_win, dzr2_win, dzr3_win, dzr0_win, dzr30_win, tseis_rec
+  !double precision, dimension(NDIM) :: dt_mtm, phi_mtm, abs_mtm, abs2_mtm
+  !double precision, dimension(NDIM) :: err_phi, err_dt, err_abs, err_abs2
+
+  ! variables for adjoint sources (p(w) and q(w), etc)
+  complex*16, dimension(NDIM,MAXTAPER) :: top_p_ntaper
+  complex*16, dimension(NDIM) :: pwc_adj, qwc_adj, top_p, bot_p, ctemp, dtemp, dtau_pj_wc, dlnA_qj_wc
+  double precision, dimension(NDIM,MAXTAPER) :: pw_adj, qw_adj, pt_adj, qt_adj, dtau_pj_t, dlnA_qj_t
+  double precision, dimension(NDIM) :: fvec, tvec, dlnA_w, dtau_w, fp, fq, w_taper
+  double precision :: nw
+
+  ! cross-correlation sources
+  double precision, dimension(NDIM) :: datt, synt, syn_veloc, syn_accel, ft_bar_t, fa_bar_t
+  double precision :: Nnorm, Mnorm, dlna
+
+  complex*16, dimension(NDIM) :: wseis1, wseis, wseis3, wseis_rec
+  complex*16, dimension(NDIM) :: trans, trans_mtm, top_mtm, bot_mtm
+  complex*16 :: wtr_use, wtr_use_unw, cci
+  character*20 hfmt
+
+  ! -----------------
+  integer, intent(in) :: nrec
+  double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+  double precision, dimension(nrec), intent(in) :: tstart, tend
+  double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+
+  double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+
+  integer itime, icomp, istart, iend, nlen
+  double precision, dimension(NSTEP) :: time_window
+  double precision :: norm, junk, ntemp
+  ! -----------------
+
+  double precision :: twopi, wtr_mtm, fac, cr_shift, cc, cc_max, sfac
+  double precision :: tshift_xc, ampmax, ampmax_unw, omega
+  double precision :: t_stop, t_start, df, df_new, temp
+  integer :: ipwr, ishift, n_left, n_right, ntaper, fnum, ipick, i1
+  integer :: i_right, i_right_stop, i_amp_max, i_amp_max_unw, idf_new
+
+  ! error associated with measurement
+  double precision :: meas_pert, rand1, ppert
+
+  integer :: i,j,ik,n,ictaper,irec,ievent
+
+!=======================================================
+
+  twopi = 2.*PI
+  cci = cmplx(0.,1.)
+  wtr_mtm = 1.e-10
+
+  adj_syn(:,:,:) = 0.
+  icomp = 1
+
+  print *, ' (mtm_adj.f90) ipick = ', ipick
+
+  ! loop over receivers -- tstart and tend are nrec x 1 arrays
+  do irec = 1,nrec
+
+    istart = max(floor(tstart(irec) / DT), 1)
+    iend = min(floor(tend(irec) / DT), NSTEP)
+    !print *, istart, iend
+    if (istart >= iend) stop 'Check if istart < istop'
+    nlen = iend - istart
+
+    ! create the time-windowed records for which the measurement is made
+    do itime=1,NSTEP
+      dzr(itime) = syn(itime,icomp,irec)      ! synthetic
+      dzr2(itime) = data(itime,icomp,irec)    ! data
+    enddo
+
+    t_start = tstart(irec)
+    t_stop = tend(irec)
+
+    ! initialise windowed arrays
+    do i = 1, npt
+      dzr_win(i) = 0
+      dzr2_win(i) = 0
+    enddo
+
+    sfac = (2./dble(nlen))**2  ! for Welch window
+    ipwr = 10                  ! for cosine window
+    time_window(:) = 0.        ! post-processing taper
+
+    do i = 1, nlen
+      !fac = 1.                                       ! boxcar window
+      !fac = 1 - sfac*((i-1) - dble(nlen)/2.)**2      ! welch window
+      fac = 1. - cos(PI*(i-1)/(nlen+1))**ipwr        ! cosine window
+      !print *, fac
+
+      time_window(i) = fac
+
+      fac = 1.
+      dzr_win(i)  = dzr(i+istart) * fac
+      dzr0_win(i) = dzr(i+istart) * fac
+      dzr2_win(i) = dzr2(i+istart)* fac
+    enddo
+
+    !------------------------------------------------------------------
+    ! Shift observed seismogram to maximise alignment prior to measure
+    !------------------------------------------------------------------
+
+    cr_shift = 300.0
+
+    n_left = ceiling( (-1.0) * cr_shift / DT )
+    n_right = floor( cr_shift / DT )
+    ishift = 0
+    cc_max = 0
+    do i = n_left, n_right, 1
+      cc = 0
+      do j = 1, nlen
+        if((j+i) > 1 .and. (j+i) < nlen) cc = cc + dzr_win(j) * dzr2_win(j+i)
+      enddo
+      if( cc > cc_max) then 
+        cc_max = cc
+        ishift = i
+        endif
+    enddo   
+    tshift_xc = ishift*DT  ! KEY: cross-correlation time shift
+ 
+    !===================================================
+    ! if you want a MTM measurement, then go here
+    if(IKER==3 .or. IKER==4) then
+
+    ! apply time shift to observed seismogram
+    write(*,*) 'shift obs seismogram by ', tshift_xc, 'seconds, irec = ', irec
+    do i = 1, nlen
+      dzr3_win(i) = 0
+      if( (ishift+i) > 1 .and. (ishift+i) < nlen ) dzr3_win(i) = dzr2_win(i+ishift)
+      dzr30_win(i) = dzr3_win(i) 
+    enddo
+
+    ! create complex synthetic seismogram
+    do i = 1,npt
+      if (i <= nlen) then 
+        wseis1(i) = cmplx(dzr0_win(i),0)
+      else 
+        wseis1(i) = 0
+      endif
+    enddo
+
+    ! apply f.t. to get spectrum
+    call clogc(lnpt,wseis1,ZZIGN,DT)
+
+    ! multi-taper measurement
+    ntaper = 5
+    wpi = 2.5
+    call staper(nlen, wpi, ntaper, tas, NDIM, ey1, ey2)
+
+    ! might be a problem here
+    write(hfmt,'(a,i2.2,a)') '(', ntaper,'e18.6)'
+
+    !------------------------------------------------------------------
+
+    ! initialize transfer function terms
+    top_mtm(:) = cmplx(0,0)
+    bot_mtm(:) = cmplx(0,0)
+    trans_mtm(:) = cmplx(0,0)
+
+    do ictaper = 1, ntaper  ! loop over tapers
+
+      ! apply taper ictaper to synth and obs windowed seismograms 
+      do i = 1, nlen
+        dzr_win(i) = dzr0_win(i) * tas(i,ictaper)
+        dzr3_win(i) = dzr30_win(i) * tas(i,ictaper)
+      enddo
+
+      ! create complex seismograms
+      do i = 1,npt
+        if (i <= nlen) then 
+          wseis(i) = cmplx(dzr_win(i),0)
+          wseis3(i) = cmplx(dzr3_win(i),0)
+        else 
+          wseis(i) = 0
+          wseis3(i) = 0
+        endif
+      enddo
+
+      ! apply f.t. to get complex spectra
+      call clogc(lnpt,wseis,ZZIGN,DT)
+      call clogc(lnpt,wseis3,ZZIGN,DT)
+
+      ! calculate frequency step and number of frequencies
+      df = 1/(npt*DT)
+      fnum = npt/2 + 1
+
+      ! find water level for single taper measurement
+      ampmax = 0
+      ampmax_unw = 0
+      do i = 1, fnum
+        if( abs(wseis(i)) > ampmax) then 
+          ampmax =  abs(wseis(i))
+          i_amp_max = i
+        endif         
+        if( abs(wseis1(i)) > ampmax_unw) then 
+          ampmax_unw =  abs(wseis1(i))
+          i_amp_max_unw = i
+        endif         
+      enddo
+      wtr_use = cmplx(ampmax * wtr, 0)
+      wtr_use_unw = cmplx(ampmax_unw * wtr, 0)
+
+      ! these variables define maximum frequency for measurement
+      ! i_right_stop = 1 --> stop at frequency i_right, not fnum
+      i_right = fnum 
+      i_right_stop = 0 
+
+      ! loop over frequencies
+      do i = 1, fnum
+
+        ! calculate top and bottom of transfer function for multitapers
+        ! NOTE THAT THESE QUANTITIES ARE SUMMED OVER THE TAPERS AS WELL
+        top_mtm(i) = top_mtm(i) +  wseis3(i) * conjg(wseis(i))
+        bot_mtm(i) = bot_mtm(i) +  wseis(i) * conjg(wseis(i))
+
+        ! calculate transfer function for single taper measurement using water level
+        if(abs(wseis(i))  >  abs(wtr_use))  trans(i) = wseis3(i) / wseis(i)
+        if(abs(wseis(i))  <=  abs(wtr_use))  trans(i) = wseis3(i) / (wseis(i)+wtr_use)
+
+        ! determine i_right values using the power in the un-tapered synthetic 
+        if(abs(wseis1(i)) <= abs(wtr_use_unw) .and. i_right_stop == 0 .and. i > i_amp_max_unw) then 
+          i_right_stop = 1
+          i_right = i
+        endif        
+        if(abs(wseis1(i))  >=  10*abs(wtr_use_unw) .and. i_right_stop == 1 .and. i > i_amp_max_unw) then 
+          i_right_stop = 0 
+          i_right = i
+        endif 
+
+      enddo  ! loop over frequencies (i=1,fnum)
+
+      print *, ' taper number ', ictaper, ' out of ', ntaper
+
+    enddo  ! end loop over tapers (ictaper=1,ntaper)
+
+    !------------------------------------------------------------------
+
+    ! calculate frequency spacing of sampling points
+    df_new = 1.0 / (t_stop-t_start)
+    idf_new = df_new / df
+
+    print *, ' measurement spacing df_new is ', sngl(df_new)
+    print *, ' fnum is', fnum
+
+    !------------------------------------------------------------------
+    ! Multi-taper measurement, calculation and output
+    !------------------------------------------------------------------
+
+    ! find water level for multi taper measurement
+    ampmax = 0
+    do i = 1, fnum
+      if( abs(bot_mtm(i)) > ampmax) then 
+        ampmax =  abs(bot_mtm(i))
+        i_amp_max = i
+      endif         
+    enddo
+    wtr_use = cmplx(ampmax * wtr_mtm**2, 0)
+
+    ! calculate transfer function using water level
+    do i = 1, fnum
+      if(abs(bot_mtm(i)) > abs(wtr_use)) trans_mtm(i) = top_mtm(i) / bot_mtm(i)
+      if(abs(bot_mtm(i)) <= abs(wtr_use)) trans_mtm(i) = top_mtm(i) / (bot_mtm(i)+wtr_use)
+    enddo
+
+    !=======================================================
+    ! construct time series : tau(omega), dlnA(omega)
+ 
+    ! taper function for the freq domain
+    nw = dble(i_right - 1)
+
+    ! loop to calculate phase and amplitude
+    ! NOTE: here we include the time shift
+    dtau_w(:) = 0.
+    dlnA_w(:) = 0.
+    w_taper(:) = 0.
+    open(91,file='transfer_freq.dat',status='unknown')
+    do i = 1, i_right 
+
+      fvec(i)     = df*i     ! do not divide by zero
+      !dtau_w(i)   = -atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) - ZZIGN*tshift_xc
+      dtau_w(i)   = -(1./fvec(i))*atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) - ZZIGN*tshift_xc
+      dlnA_w(i)   = abs(trans_mtm(i))-1
+
+      ! type of filter in the freq domain : boxcar, welch, cosine
+      !w_taper(i) = 1.
+      !w_taper(i) = 1. - (2./nw)**2 * ((i-1) - nw/2.)**2
+      w_taper(i) = 1. - cos(PI*(i-1)/(nw+1))**ipwr
+
+      write(91,'(4e18.8)') fvec(i), dtau_w(i), dlnA_w(i), w_taper(i)
+    enddo
+    close(91)
+
+    ! Reconstruct mtm fit seismograms : syn*tran
+    ! d(w) = s(w) T(w) exp[-i w dT]
+    ! trans_mtm is for syn --> SHIFTED data
+    wseis_rec(:) = cmplx(0,0)
+    do i = 1,i_right
+      omega = twopi * (i-1) * df
+      !wseis_rec(i) = wseis1(i)*exp(-cci*omega*tshift_xc)*trans_mtm(i)  ! sign
+      wseis_rec(i) = wseis1(i) * exp(-cci*omega*dtau_w(i)) * (1.+ dlnA_w(i))
+      !wseis_rec(i) = wseis1(i) * exp(-cci*omega*dtau_w(i)*w_taper(i)) * (1.+ dlnA_w(i)*w_taper(i))
+    enddo
+
+    ! inverse FFT into time domain
+    call ftinv(lnpt,wseis_rec,ZZIGN,DT,tseis_rec)
+
+    open(17,file='recovered_seis.dat',status='unknown')
+    do i = 1,nlen
+      write(17,'(2e18.8)') DT*i, tseis_rec(i)
+    enddo
+    close(17)
+
+    endif  ! IKER==3,4
+
+    !==================================================================
+    !     compute cross-correlation adjoint sources
+    !==================================================================
+
+    synt(:) = dzr0_win(:)   ! synthetics
+    datt(:) = dzr2_win(:)   ! data, unshifted
+
+    ! calculate velocity and acceleration from syn
+    do i = 2, nlen-1
+      syn_veloc(i) =  (synt(i+1) - synt(i-1)) / (2 * DT)
+    enddo
+    syn_veloc(1) = (synt(2) - synt(1)) / DT
+    syn_veloc(nlen) = (synt(nlen) - synt(nlen-1)) /DT
+
+    do i = 2, nlen-1
+      syn_accel(i) =  (syn_veloc(i+1) - syn_veloc(i-1)) / (2 * DT)
+    enddo
+    syn_accel(1) = (syn_veloc(2) - syn_veloc(1)) / DT
+    syn_accel(nlen) = (syn_veloc(nlen) - syn_veloc(nlen-1)) /DT
+
+    ! cross-correlation traveltime adjoint source (normalized velocity)
+    ! NOTE sign convention (Qinya, not GJI paper)
+    Nnorm = -DT * sum( synt(:) * syn_accel(:) )
+    ft_bar_t(:) = -syn_veloc(:) / Nnorm
+
+    ! cross-correlation amplitude adjoint source (normalized displacement)
+    Mnorm = DT * sum( synt(:) * synt(:) )
+    fa_bar_t(:) = synt(:) / Mnorm
+
+    ! definition of Dahlen and Baig (2002), Eq. 3,17,18 : dlnA = Aobs/Asyn - 1
+    dlna = sqrt( (DT * sum( datt(:) * datt(:) )) / (DT * sum( synt(:) * synt(:) )) ) - 1.
+
+    if(0==1) then
+      print *
+      print *, 'cross-correlation measurments:'
+      print *, '   dT = ', tshift_xc
+      print *, '   dA = ', dlna
+    else
+      write(*,'(a8,i5,a8,1f18.10,a8,1f18.10)') &
+         'irec = ', irec, ', dT = ', tshift_xc, ', dA = ', dlna
+    endif
+
+    ! additional files for checking (measure_socal_adj.m)
+    if(0==1) then
+      ! time domain : time, data-disp, syn-disp, syn-vel, syn-accel
+      open(29,file='syn_time.dat')
+      do i = 1,nlen
+        write(29,'(7e18.8)') i*DT, datt(i), synt(i), syn_veloc(i), syn_accel(i)
+      enddo
+      close(29)
+
+      ! xcorr adjoint sources : traveltime (sampling), traveltime (misfit), amplitude (sampling), amplitude (misfit)
+      open(39,file='xcorr_time.dat')
+      do i = 1,nlen
+        write(39,'(4e18.8)') ft_bar_t(i), -tshift_xc*ft_bar_t(i), fa_bar_t(i), -dlna*fa_bar_t(i)
+      enddo
+      close(39)
+    endif
+
+    !==================================================================
+    !     create MTM adjoint sources
+    !==================================================================
+
+    if(IKER==3 .or. IKER==4) then
+
+       pw_adj(:,:) = 0.      ;  qw_adj(:,:) = 0.
+       pt_adj(:,:) = 0.      ;  qt_adj(:,:) = 0.
+       dtau_pj_t(:,:) = 0.   ;  dlnA_qj_t(:,:) = 0.
+       fp(:) = 0.            ;  fq(:) = 0.
+       bot_p(:) = cmplx(0,0)
+       top_p_ntaper(:,:) = cmplx(0,0)
+
+       ! This loops to get the denominator of pj(w).
+       ! It also stores the displacement field sj(w), which is in the numerator of p(w).
+       do ictaper = 1,ntaper
+
+          ! apply TAPER ictaper to windowed synthetics 
+          do i = 1,nlen
+             dzr_win(i)  = dzr0_win(i) * tas(i,ictaper)
+          enddo
+
+          ! create complex seismograms
+          wseis(:) = cmplx(dzr_win(:),0)
+
+          ! apply f.t. to get complex spectra
+          call clogc(lnpt,wseis,ZZIGN,DT)
+
+          ! bottom of p function for multitapers
+          do i = 1, i_right
+             bot_p(i) = bot_p(i) +  wseis(i) * conjg(wseis(i))
+          enddo
+
+          ! term in numerator (sj)
+          top_p_ntaper(:,ictaper) = wseis(:)     
+
+       enddo  ! loop over tapers
+
+       do ictaper = 1,ntaper   ! loop over tapers
+          print *, ' taper number ', ictaper, ' out of ', ntaper
+
+          top_p(:) = top_p_ntaper(:,ictaper)  ! top of p function for multitapers
+          pwc_adj(:) = cmplx(0,0)
+          qwc_adj(:) = cmplx(0,0)
+
+          ! compute pj(w) and qj(w) -- j term is in top_p
+          do i=1,i_right
+             omega = twopi*df*i   ! omega not =0
+
+             ! NOTE SIGN
+             pwc_adj(i) = cmplx(0,1./omega) * top_p(i) / bot_p(i)  ! (1/w)i = (-iw)/(-w^2)
+             qwc_adj(i) = cmplx(0,omega) * pwc_adj(i)              ! d/dt <--> iw
+
+          enddo
+
+          ! NOTE THAT ftinv CHANGES THE INPUT, SO WE SAVE A COPY HERE.
+          ctemp(:) = pwc_adj(:)
+          dtemp(:) = qwc_adj(:)
+
+          ! EXTRA : ifft into the time domain : pj(w) --> pj(t) and qj(w) --> qj(t)
+          call ftinv(lnpt,pwc_adj,ZZIGN,DT,pt_adj(:,ictaper))
+          call ftinv(lnpt,qwc_adj,ZZIGN,DT,qt_adj(:,ictaper))
+
+          ! create dtau(w) pj(w) W(w) and save dtau(t) * pj(t) * W(t)
+          dtau_pj_wc(:) = ctemp(:) * cmplx(dtau_w(:),0.) * cmplx(w_taper(:),0.)
+          call ftinv(lnpt,dtau_pj_wc,ZZIGN,DT,dtau_pj_t(:,ictaper))
+
+          ! create dlnA(w) qj(w) W(w) and save dlnA(t) * qj(t) * W(t)
+          dlnA_qj_wc(:) = dtemp(:) * cmplx(dlnA_w(:),0.) * cmplx(w_taper(:),0.)
+          call ftinv(lnpt,dlnA_qj_wc,ZZIGN,DT,dlnA_qj_t(:,ictaper))
+
+          ! create adjoint source
+          fp(:) = fp(:) + tas(:,ictaper) * dtau_pj_t(:,ictaper)
+          fq(:) = fq(:) + tas(:,ictaper) * dlnA_qj_t(:,ictaper)
+
+       enddo
+
+       ! write sampling adjoint sources to file
+       open(21,file='test_fadj_t.dat',status='unknown')
+       do i = 1,nlen
+          write(21,*) sngl(fp(i)), sngl(fq(i))
+       enddo
+       close(21)
+
+       ! time domain : tapers and other time series 
+       open(18,file='test_hj_t.dat',status='unknown')
+       open(19,file='test_pj_t.dat',status='unknown')
+       open(20,file='test_Pj_t.dat',status='unknown')
+       open(21,file='test_Pj_hj_t.dat',status='unknown')
+       open(22,file='test_qj_t.dat',status='unknown')
+       open(23,file='test_Qj_t.dat',status='unknown')
+       open(24,file='test_Qj_hj_t.dat',status='unknown')
+
+       do i = 1,nlen  ! loop over time points
+          write(18,hfmt) ( sngl(tas(i,ictaper)), ictaper=1,ntaper )                         ! hj(t)
+          write(19,hfmt) ( sngl(pt_adj(i,ictaper)), ictaper=1,ntaper )                      ! pj(t)
+          write(20,hfmt) ( sngl(dtau_pj_t(i,ictaper)), ictaper=1,ntaper )                   ! Pj(t)
+          write(21,hfmt) ( sngl(dtau_pj_t(i,ictaper) * tas(i,ictaper)), ictaper=1,ntaper )  ! hj(t) Pj(t)
+
+          write(22,hfmt) ( sngl(qt_adj(i,ictaper)), ictaper=1,ntaper )                      ! qj(t)
+          write(23,hfmt) ( sngl(dlnA_qj_t(i,ictaper)), ictaper=1,ntaper )                   ! Qj(t)
+          write(24,hfmt) ( sngl(dlnA_qj_t(i,ictaper) * tas(i,ictaper)), ictaper=1,ntaper )  ! hj(t) Qj(t) 
+       enddo
+
+       close(18) ; close(19) ; close(20) ; close(21) ; close(22) ; close(23) ; close(24)
+
+    endif  ! if IKER==3,4
+
+    ! generate a random number to simulate error in the measurement
+    ! ppert determines the range over which the perturbed measurement will be
+    ppert = 0.
+    call random_number(rand1)
+    meas_pert = 1. + ppert*(2.*rand1 - 1.)
+    !meas_pert = 1. + ppert
+
+    !print *, tshift_xc, meas_pert, tshift_xc * meas_pert
+
+    ! CREATE THE ADJOINT SOURCES
+    ! HERE WE APPLY A TAPER TO FIX THE ENDPOINTS
+    do i = 1,nlen
+
+      i1 = istart - 1 + i
+
+      if(ipick==0) then
+        adj_syn(i1,icomp,irec) = ( syn(i1,icomp,irec) -  data(i1,icomp,irec) ) * time_window(i) * meas_pert
+
+      elseif(ipick==1) then
+        ! meas_pert = 1.0 for most runs
+        adj_syn(i1,icomp,irec) = -tshift_xc * ft_bar_t(i) * time_window(i) * meas_pert
+
+      elseif(ipick==2) then
+        adj_syn(i1,icomp,irec) = -dlna * fa_bar_t(i) * time_window(i) * meas_pert
+
+      elseif(ipick==3) then
+        adj_syn(i1,icomp,irec) = fp(i) * time_window(i)
+
+      elseif(ipick==4) then
+        adj_syn(i1,icomp,irec) = fq(i) * time_window(i)
+
+      elseif(ipick==5) then
+        adj_syn(i1,icomp,irec) = ft_bar_t(i) * time_window(i)
+
+      elseif(ipick==6) then
+        adj_syn(i1,icomp,irec) = fa_bar_t(i) * time_window(i)
+      endif
+
+    enddo
+
+    ! (1) COMPUTE MISFIT FUNCTION (currently only for waveform, xc-tt, xc-lnA)
+    ! (2) COMPUTE MEASUREMENT VECTOR
+
+    imeasure = imeasure + 1    ! global counter variable
+
+      if(ipick==0) then
+
+        chi(ievent,irec,icomp,1) = 0.5 * sum( adj_syn(:,icomp,irec)**2 ) * DT
+        measure_vec(imeasure)    = chi(ievent,irec,icomp,1)
+
+      elseif(ipick==1) then
+        chi(ievent,irec,icomp,1) = 0.5 * (tshift_xc * meas_pert)**2
+        measure_vec(imeasure)    = tshift_xc * meas_pert
+
+      elseif(ipick==2) then
+        chi(ievent,irec,icomp,1) = 0.5 * (dlna * meas_pert)**2
+        measure_vec(imeasure)    = dlna * meas_pert
+
+      elseif(ipick==3) then
+        chi(ievent,irec,icomp,1) = 0.
+        measure_vec(imeasure)    = 0.
+
+      elseif(ipick==4) then
+        chi(ievent,irec,icomp,1) = 0.
+        measure_vec(imeasure)    = 0.
+
+      elseif(ipick==5) then
+        chi(ievent,irec,icomp,1) = 0.
+        measure_vec(imeasure)    = 0.
+
+      elseif(ipick==6) then
+        chi(ievent,irec,icomp,1) = 0.
+        measure_vec(imeasure)    = 0.
+
+      endif
+
+
+  enddo  ! loop over receivers (irec=1,nrec)
+
+!------------------------------------------------------------------
+  end subroutine mtm_adj
+!------------------------------------------------------------------
+! END MAIN PROGRAM
+!------------------------------------------------------------------
+        
+!------------------------------------------------------------------
+  subroutine clogc(n,xi,zzign,dt)
+!------------------------------------------------------------------
+      complex*16, dimension(NDIM) :: xi
+      integer :: n
+      double precision :: dt,zzign
+
+      complex*16 :: wk, hold, q
+      double precision :: m(25)
+      double precision :: zign,flx,v
+      integer :: lblock,k,fk,jh,ii,istart
+      integer :: l,iblock,nblock,i,lbhalf,j,lx
+
+      zign=zzign
+      if(zign >= 0.) then
+        zign=1.
+      else
+        zign=-1.
+      endif
+      lx=2**n
+      do 1 i=1,n
+    1 m(i)=2**(n-i)
+      do 4 l=1,n
+      nblock=2**(l-1)
+      lblock=lx/nblock
+      lbhalf=lblock/2
+      k=0
+      do 4 iblock=1,nblock
+      fk=k
+      flx=lx
+      v=zign*2.*PI*fk/flx
+      wk=cmplx(cos(v),sin(v))
+      istart=lblock*(iblock-1)
+      do 2 i=1,lbhalf
+      j=istart+i
+      jh=j+lbhalf
+      q=xi(jh)*wk
+      xi(jh)=xi(j)-q
+      xi(j)=xi(j)+q
+    2 continue
+      do 3 i=2,n
+      ii=i
+      if(k < m(i)) go to 4
+    3 k=k-m(i)
+    4 k=k+m(ii)
+      k=0
+      do 7 j=1,lx
+      if(k < j) go to 5
+      hold=xi(j)
+      xi(j)=xi(k+1)
+      xi(k+1)=hold
+    5 do 6 i=1,n
+      ii=i
+      if(k < m(i)) go to 7
+    6 k=k-m(i)
+    7 k=k+m(ii)
+      if(zign > 0.) go to 9
+      flx=flx*dt
+      do 8 i=1,lx
+    8 xi(i)=xi(i)/flx
+      return
+    9 do 10 i=1,lx
+   10 xi(i)=xi(i)*dt
+      return
+
+  end subroutine clogc
+
+!------------------------------------------------------------------
+  subroutine ftinv(npow,s,zzign,dt,r)
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !dimension r(4096*4)
+      !complex s(4096*4)
+
+      complex*16 :: s(NDIM)
+      double precision :: r(NDIM)
+      double precision :: dt,zzign,zign
+      integer :: npow, nsmp, nhalf, i
+
+      nsmp=2**npow
+      nhalf=nsmp/2
+      call rspec(s,nhalf)
+      zign = -1.*zzign
+      call clogc(npow,s,zign,dt)
+      do 10 i=1,nsmp
+10    r(i)=real(s(i))
+      return
+ 
+  end subroutine ftinv
+
+!------------------------------------------------------------------
+  subroutine rspec(s,np2)
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !complex s(4096*4)
+
+      complex*16 :: s(NDIM)
+      integer :: np2,n,n1,i
+
+      n=2*np2
+      n1=np2+1
+
+      s(n1)=0.
+!     s(1)=0.
+      s(1)= cmplx( real(s(1)),0.)
+
+      do 20 i=1,np2
+20    s(np2+i)=conjg(s(np2+2-i))
+      return
+
+  end subroutine rspec
+
+!------------------------------------------------------------------
+  subroutine remo(ny,nm,nd)
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !dimension m(12)
+      !data m/0,31,59,90,120,151,181,212,243,273,304,334/
+
+      integer :: m(12)
+      data m/0,31,59,90,120,151,181,212,243,273,304,334/
+      integer :: ny, nm, nd, mm
+
+      if(.not.(nm==1))goto 23220
+      nm=0
+23220 continue
+      mm=nm
+      if(.not.(mm==0))goto 23222
+      return
+23222 continue
+      nm=0
+      nd=nd+m(mm)
+      if(.not.(mod(ny,4) == 0 .and. mm > 2))goto 23224
+      nd=nd+1
+23224 continue
+      return
+
+  end subroutine remo
+
+!------------------------------------------------------------------
+  subroutine staper(nt, fw, nev, v, ndim, a, w)
+!------------------------------------------------------------------
+!$$$$ calls tsturm, root
+!  Slepian - Thomson multi-taper procedure
+!  Slepian, D.     1978  Bell Sys Tech J v57 n5 1371-1430
+!  Thomson, D. J.  1982  Proc IEEE v70 n9 1055-1096
+!    nt    the number of points in the series
+!    fw    the time-bandwidth product (number of Rayleigh bins)
+!    nev   the desired number of tapers
+!    v     the eigenvectors (tapers) are returned in v(.,nev)
+!    a, w  work arrays dimensioned at least nt long (nt+1, nt odd)
+!    a(1..nev) contains bandwidth retention factors on output.
+!  The tapers are the eigenvectors of the tridiagonal matrix sigma(i,j)
+!  [see Slepian(1978) eq 14 and 25.] They are also the eigenvectors of
+!  the Toeplitz matrix eq. 18. We solve the tridiagonal system in
+!  tsturm for the tapers and use them in Slepians eq 18 to get the
+!  bandwidth retention factors (i.e. the eigenvalues) Thomson's
+!  normalisation is used with no attention to sign.
+      !implicit real*8(a-h,o-z)
+      !dimension a(*),w(*),v(ndim,*)
+      !parameter (pi=3.14159265358979d0,r2=1.414213562373095d0)
+
+      integer :: nt, nev, ndim
+      double precision :: fw
+      double precision :: v(NDIM,MAXTAPER), a(NDIM), w(NDIM)
+
+      integer :: i,j,k,m
+      integer :: nxi, lh, lp1, neven, nodd, ntot, kk, kmax, nlow, nup
+      double precision :: r2,om,com,hn,asav,rbd,dc,sm,s,sn,vmax
+
+      !-------------------------
+
+      r2 = sqrt(2.)
+
+      if(nt < 2) return
+      nxi=mod(nt,2)
+      lh=(nt/2)+nxi
+      lp1=nt+1
+      om=2.*PI*fw/nt
+      com=cos(om)
+      hn=0.5*dble(lp1)
+      do 10 i=1,lh
+        a(i)=com*(i-hn)**2
+   10   w(i)=0.5*dble(i*(nt-i))
+      if(nxi == 0) then
+        asav=a(lh)-w(lh)
+        a(lh)=a(lh)+w(lh)
+        rbd=1./(a(lh)+w(lh-1))
+      else
+        asav=w(lh-1)
+        rbd=1./(w(lh)+w(lh-1))
+        w(lh-1)=r2*w(lh-1)
+      endif
+      do 15 i=1,lh
+        a(i+lh)=w(i)*rbd
+        w(i)=a(i+lh)**2
+   15   a(i)=a(i)*rbd
+      neven=max0((nev+1)/2,1)
+      nodd=nev-neven
+!  Do the even tapers
+      call tsturm(nt,lh,a,a(lh+1),w,neven,v,ndim,w(lh+1),0)
+      do 20 i=1,neven
+        k=2*i-1
+        if(nxi == 1) v(lh,k)=r2*v(lh,k)
+          do 20 j=1,lh
+   20     v(lp1-j,k)=v(j,k)
+      if(nodd <= 0) goto 34
+!  Do the odd tapers
+      if(nxi == 0) then
+        a(lh)=asav*rbd
+      else
+        a(nt)=asav*rbd
+        w(lh-1)=asav*asav
+      endif
+      call tsturm(nt,lh-nxi,a,a(lh+1),w,nodd,v,ndim,w(lh+1),1)
+      do 30 i=1,nodd
+        k=2*i
+        if(nxi == 1) v(lh,k)=0.
+          do 30 j=1,lh
+   30     v(lp1-j,k)=-v(j,k)
+   34 ntot=neven+nodd
+!  Calculate bandwidth retention parameters
+      dc=2.*com
+      sm=0.
+      s=sin(om)
+      w(1)=om/PI
+      w(2)=s/PI
+      do 35 j=3,nt
+        sn=dc*s-sm
+        sm=s
+        s=sn
+   35   w(j)=s/(PI*(j-1))
+      do 55 m=1,ntot
+        vmax=abs(v(1,m))
+        kmax=1
+        do 40 kk=2,lh
+          if(abs(v(kk,m)) <= vmax) goto 40
+          kmax=kk
+          vmax=abs(v(kk,m))
+   40     continue
+        a(m)=0.
+        nlow=kmax-1
+          do 45 j=1,nlow
+   45     a(m)=a(m)+w(j+1)*v(nlow+1-j,m)
+        nup=nt-nlow
+          do 50 j=1,nup
+   50     a(m)=a(m)+w(j)*v(nlow+j,m)
+   55 a(m)=a(m)/v(kmax,m)
+      return
+
+  end subroutine staper
+
+!------------------------------------------------------------------
+  subroutine tsturm(nt,n,a,b,w,nev,r,ndim,ev,ipar)
+!------------------------------------------------------------------
+!$$$$ calls root
+!  Uses bisection and Sturm counting to isolate the eigenvalues of the
+!  symmetric tridiagonal matrix with main diagonal a(.) and sub/super
+!  diagonal b(.).  Newton's method is used to refine the eigenvalue in
+!  subroutine root then direct recursion is used to get the eigenvector
+!  as this is always stable.  Note  ipar=0 for even tapers   =1 for odd
+!  tapers
+      !implicit real*8(a-h,o-z)
+      !parameter (epsi=1.d-15,epsi1=5.d-15)
+      !dimension a(*),b(*),ev(*),w(*),r(ndim,*)
+
+      double precision, parameter :: epsi = 1.d-15, epsi1 = 5.d-15
+
+      double precision, dimension(NDIM) :: a, b, w, ev
+      double precision, dimension(NDIM,MAXTAPER) :: r
+      integer :: nt,n,ndim,nev,ipar
+
+      double precision, dimension(NDIM) :: bb
+      double precision :: q,el,elam,u,umeps,x,ddot,rnorm
+      integer :: i,j,ik,iag,m,jk,jm1
+
+      !-------------------------
+
+      if(n <= 0.or.nev <= 0) return
+      umeps=1.-epsi
+      do 5 i=1,nev
+    5 ev(i)=-1.
+      u=1.
+      do 1000 ik=1,nev
+      if(ik > 1) u=ev(ik-1)*umeps
+      el=min(ev(ik),u)
+   10 elam=0.5*(u+el)
+      if(abs(u-el) <= epsi1) goto 35
+      iag=0
+      q=a(1)-elam
+      if(q >= 0.) iag=iag+1
+      do 15 i=2,n
+      if(q == 0.) x=abs(b(i-1))/epsi
+      if(q /= 0.) x=w(i-1)/q
+      q=a(i)-elam-x
+      if(q >= 0.) iag=iag+1
+      if(iag > nev) goto 20
+   15 continue
+      if(iag >= ik) go to 20
+      u=elam
+      go to 10
+   20 if(iag == ik) go to 30
+      m=ik+1
+      do 25 i=m,iag
+   25 ev(i)=elam
+      el=elam
+      go to 10
+   30 el=elam
+      call root(u,el,elam,a,b,w,n,ik)
+   35 ev(ik)=elam
+      jk=2*ik+ipar-1
+      r(1,jk)=1.
+      r(2,jk)=-(a(1)-ev(ik))/b(1)
+      ddot=1.+r(2,jk)*r(2,jk)
+      jm1=2
+      do 45 j=3,n
+      r(j,jk)=-((a(jm1)-ev(ik))*r(jm1,jk)+b(j-2)*r(j-2,jk))/b(jm1)
+      ddot=ddot+r(j,jk)*r(j,jk)
+   45 jm1=j
+      rnorm=sqrt(nt/(2.*ddot))
+      do 50 j=1,n
+   50 r(j,jk)=r(j,jk)*rnorm
+ 1000 continue
+      return
+
+  end subroutine tsturm
+
+!------------------------------------------------------------------
+  subroutine root(u,el,elam,a,bb,w,n,ik)
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !parameter (epsi = 1.d-15, epsi1 = 5.d-15)
+      !dimension a(*),bb(*),w(*)
+
+      double precision, parameter :: epsi = 1.d-15, epsi1 = 5.d-15
+      double precision :: u,el,elam
+      double precision, dimension(NDIM) :: a,bb,w
+      integer :: n,ik
+
+      double precision :: an,b,bm,bn,del,x
+      integer :: i,iag
+
+      !----------------------
+
+    5 elam=0.5*(u+el)
+   10 if(abs(u-el) <= 1.5*epsi1) return
+      an=a(1)-elam
+      b=0.
+      bn=-1./an
+      iag=0
+      if(an >= 0.) iag=iag+1
+      do 20 i=2,n
+      if(an == 0.) x=abs(bb(i-1))/epsi
+      if(an /= 0.) x=w(i-1)/an
+      an=a(i)-elam-x
+      if(an == 0.) an=epsi
+      bm=b
+      b=bn
+      bn=((a(i)-elam)*b-bm*x-1.)/an
+      if(an >= 0.) iag=iag+1
+   20 continue
+      if(iag == ik) goto 25
+      u=elam
+      goto 30
+   25 el=elam
+   30 del=1./bn
+      if(abs(del) <= epsi1) del=sign(epsi1,del)
+      elam=elam-del
+      if(elam >= u.or.elam <= el) goto 5
+      goto 10
+
+  end subroutine root
+!-------------------------------------------
+
+end module wave2d_sub3

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_variables.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_variables.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/codes_18_06Aug2006/wave2d_variables.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,107 @@
+module wave2d_variables
+
+  use wave2d_constants
+
+! sound velocity
+  double precision c
+
+! material properties
+  double precision kappal,mul,lambdal,lambdalplus2mul
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: rho,kappa,mu
+
+! Gauss-Lobatto-Legendre points of integration
+  double precision, dimension(NGLLX) :: xigll
+  double precision, dimension(NGLLZ) :: zigll
+
+! weights
+  double precision, dimension(NGLLX) :: wxgll
+  double precision, dimension(NGLLZ) :: wzgll
+
+! array with derivatives of Lagrange polynomials
+  double precision, dimension(NGLLX,NGLLX) :: hprime_xx
+  double precision, dimension(NGLLZ,NGLLZ) :: hprime_zz
+  double precision, dimension(NGLLX,NGLLZ) :: wgllwgll_xz
+
+! anchors
+  double precision, dimension(NSPEC) :: z1,z2
+  double precision, dimension(NSPEC) :: x1,x2
+
+! global grid points
+  double precision, dimension(NGLOB) :: x, z, x_lon, z_lat, da
+  integer, dimension(NGLOB) :: valence
+
+! phase velocity map (CHT)
+  double precision, dimension(NGLOB) :: c_glob
+  double precision c0,cmin,cmax
+  integer ihomo
+
+! Jacobian matrix and Jacobian
+  double precision dxidxl,dxidzl,dgammadxl,dgammadzl,jacobianl
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: dxidx,dxidz,dgammadx,dgammadz,jacobian
+
+! boundary elements: 1-xmin, 2-xmax, 3-zmin, 4-zmax (1,2,3,4 --> left, right, bottom, top)
+! ibelm contains ispec indices for elements on the boundary of the grid
+  integer, dimension(4,NELE) :: ibelm
+  double precision, dimension(4,NGLL,NELE) :: jacobianb
+  integer nspecb(4)
+
+! absorbing boundary conditions
+  integer j1, j2, ib, ibb
+  double precision nx,nz,vx,vy,vz,vn,rho_vp,rho_vs,tx,ty,tz,weight
+
+! local to global numbering
+  integer, dimension(NGLLX,NGLLZ,NSPEC) :: ibool
+
+! Mass matrix
+  double precision mass_local
+  double precision, dimension(NGLOB) :: mass_global, mu_global, kappa_global, rho_global
+
+! time marching
+  double precision deltat,deltatover2,deltatsqover2
+  double precision b_deltat,b_deltatover2,b_deltatsqover2
+  double precision dh,time_step
+
+! displacement, velocity and acceleration
+  double precision, dimension(NCOMP,NGLOB) :: displ,veloc,accel
+  double precision, dimension(NCOMP,NGLOB) :: b_displ,b_veloc,b_accel
+  
+! plotting
+  double precision, dimension(NGLOB) :: norm
+
+! space derivatives
+  double precision tempx1l,tempx2l,tempy1l,tempy2l,tempz1l,tempz2l
+  double precision fac1,fac2,hp1,hp2
+  double precision dsxdxl,dszdxl,dsydxl,dsydzl,dsxdzl,dszdzl 
+  double precision sigma_xx,sigma_xy,sigma_xz,sigma_zx,sigma_zy,sigma_zz
+  double precision, dimension(NGLLX,NGLLZ) :: tempx1,tempx2,tempy1,tempy2,tempz1,tempz2
+  double precision, dimension(3,3) :: ds
+
+  double precision b_tempx1l,b_tempx2l,b_tempy1l,b_tempy2l,b_tempz1l,b_tempz2l
+  double precision b_dsxdxl,b_dszdxl,b_dsydxl,b_dsydzl,b_dsxdzl,b_dszdzl
+  double precision b_sigma_xx,b_sigma_xy,b_sigma_xz,b_sigma_zx,b_sigma_zy,b_sigma_zz
+  double precision, dimension(NGLLX,NGLLZ) :: b_tempx1,b_tempx2,b_tempy1,b_tempy2,b_tempz1,b_tempz2
+  double precision, dimension(3,3) :: b_ds
+
+  double precision :: utm_xmin, utm_zmin
+
+  integer :: imeasure
+  double precision, dimension(:), allocatable :: measure_vec
+
+! misfit function
+  double precision :: chi(MAX_EVENT, MAX_SR, MAX_COMP, MAX_PHASE)
+
+! kernel
+  double precision, dimension(NGLOB) :: kernel_basis, kernel_basis_sum
+
+! half duration of the source (put into wave2d_constants.f90)
+!  double precision hdur
+
+! file open or write status variable
+  integer ios
+
+! number of time steps to store wavefield
+  integer NINT 
+
+! input/output directory
+  character(len=100) :: in_dir,out_dir
+end module wave2d_variables

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_2wid.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_2wid.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_2wid.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,635 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_gji_2wid.pl
+#  Carl Tape
+#  15-March-2006
+#
+#    plot_gji_2wid.pl ../../OUTPUT/run_ event_ socal_vel_dat.dat socal_vel_syn.dat kernel_basis -6/3.0/0/80 1 280 0
+#
+#==========================================================
+
+if (@ARGV < 9) {die("Usage: plot_gji_2wid.pl out_dir_pre event_dir_pre modelfile_dat modelfile_syn kernelfile kpwr/kmax/oprw/omax IKER irun0 iter model \n");}
+($odir,$edir,$mfile_dat,$mfile_syn,$kerfile,$colors,$iker,$irun0,$iter) = @ARGV;
+
+$ishelf = 0;   # plot the shelf as a dashed line
+
+# boolean commands for plotting
+$icolor = 1;
+
+$ifig00 = 0;   # title page figure: SoCal topo/bath, phase speed map, faults
+$ifig01 = 0;   # SoCal topo/bath, phase speed map, faults
+$ifig02 = 1;   # GJI paper: SoCal topo/bath, phase speed map, src-rec geometry
+$ifig03 = 0;   # src-rec geometry, ray coverage
+
+$ifig04 = 0;   # topo/bath, including Baja CA (Ge161)
+
+$cshfile = "plot_gji_2wid.csh";
+
+$irun = $irun0 + $iter;
+
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t");
+$mod = $mods[$iter];
+
+# model iteration
+$smod = "m\@+$mod\@+";
+
+# topo files
+$dir_topo = "/home/datalib/Topography/Globe_Becker/data";
+$grdfile  = "$dir_topo/west_data/w140n40.Bathmetry.srtm.swap.grd";
+$gradfile = "$dir_topo/west_data/w140n40.Bathmetry.srtm.swap.grad";
+
+# boundary files
+$dir0 = "/home/carltape/gmt";
+$plate_file_nuvel   = "${dir0}/nuvel_1_plates";
+$plate_file   = "${dir0}/plate_boundaries";
+$fault_file   = "${dir0}/faults/jennings.xy";
+$kcf_file     = "${dir0}/faults/kcf.xy";
+$shelf_file = "../../INPUT/oms_shelf";
+
+# wave2d run number
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "$odir$strun0";
+$dir = "$odir$strun";
+
+print "\n $dir, $edir, $mfile_dat, $mfile_syn, $kerfile";
+print "\n $colors, $iker, $mod \n";
+#die("testing");
+
+ at cols = split("/",$colors);
+$kpwr = $cols[0];
+$kmax = $cols[1];
+$opwr = $cols[2];
+$omax = $cols[3];
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+$ktype = $titles[$iker];
+
+$plabel = "/home/carltape/sem2d/2d_adjoint/scripts/plot_ker_mod.pl";
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "10";
+$fsize3 = "5";
+$fontno = "4";    # 1 or 4
+$tick   = "0.15c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# plot symbols for sources, receivers, and shelf
+$src          = "-W1p -Sa12p";
+$src_r        = "-W1p/255/0/0 -Sa12p";
+$src_b        = "-W1p/0/0/255 -Sa12p";
+$rec          = "-Sc5p -G0";
+$rec_r        = "-W0.5p/0/0/0 -Sc5p -G255/0/0";
+$rec_w        = "-W0.5p/0/0/0 -Sc5p -G255";
+#$rec0 = "-Sc10p -W0.5p";
+$Wshelf       = "-W1.0/0/0/0tap";
+
+$plate_info_w = "-M -W2.5p/255/255/255";
+$plate_info_r = "-M -W2.5p/255/0/0";
+$plate_info_b = "-M -W2.5p/0/0/255";
+$plate_info_k = "-M -W2.5p";
+
+$coast_info_k  = "-W1p -Na/1p -Df -A10";
+$coast_info_w  = "-W1p/255/255/255 -Na/1p -Df -A10";
+$coast_info2  = "$coast_info_k -I1/1.0p";
+$coast_info3  = "$coast_info_k -S220/255/255 -C220/255/255 -G200";
+$coast_info_inset  = "-W0.5p -Dl -Na/0.5p -A1000 -S220/255/255 -C220/255/255 -G200";
+
+$fault_info_r     = "-M -W1.5p/255/0/0";
+$fault_info_k    = "-M -W1.5p/0/0/0";
+$fault_info_w    = "-M -W1.5p/255/255/255";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+#-------------------------
+# color for chi (objective function)
+
+$norm3 = "1e$opwr";
+$ss = $omax;
+$ds = $ss/$scale_color;
+$bs3 = sprintf("%3.3e",0.9*$ss/3); # colorbar
+$T3 = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+print "T3 = $T3\n";
+
+#-------------------------
+# get reference phase speed and period
+
+$dir = "/home/carltape/sem2d/2d_adjoint/OUTPUT/run_0280";
+
+open(IN,"$dir/socal_vel_c0.dat");
+ at vals = <IN>;
+$c0       = $vals[0];
+$per      = $vals[1];
+$lam      = $c0*$per;
+$per_lab  = sprintf("T = %.1f s",$per);
+$c0_lab   =  sprintf("c0 = %.2f km/s",$c0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $c0_lab, $lam_lab \n";
+
+#die("testing");
+
+#-------------------------
+
+# write plotting scripts
+$Jwid = 3.25;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.8 -Y6.25";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+$B0 = "-B1:.\" \":";
+
+## polynomial plots
+#$lpwr_x = 4;
+#$lpwr_y = 3;
+#$normgx = "1e$lpwr_x";
+#$normgy = "1e$lpwr_y";
+#$B1 = sprintf("-B0.5:\"\@~\154\@~   ( 10\@+%2.2i\@+ ) \":/1:\" \@~\143\@~\@+0\@+ [ m (\@~\154\@~) ]   ( 10\@+%2.2i\@+  s\@+2\@+ ) \":",$lpwr_x,$lpwr_y);
+#$B2 = sprintf("-B0.5:\"\@~\154\@~   ( 10\@+%2.2i\@+ ) \":/1:\" \@~\143\@~\@+1\@+ [ m (\@~\154\@~) ]   ( 10\@+%2.2i\@+  s\@+2\@+ ) \":",$lpwr_x,$lpwr_y);
+#$B3a = "-B1:\" model number (iteration) \":/a1f2p:\" \@~\143\@~ ( m )   ( s\@+2\@+ ) \":";
+#$B3b = "-B1:\" model number (iteration) \":/a1f2p:\" \":";
+#$B4  = "-B1:\" model number (iteration) \":/20:\" \":";
+
+# colorbar
+$Dlen = $Jwid*0.7;
+$Dx = $Jwid/2;
+$Dy = -0.12*$Jwid;
+$Dscale = "-D$Dx/$Dy/$Dlen/0.15h";
+
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Speed for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Speed for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$bs1 = 1; $cmax = 8;
+$Bscale1a  = sprintf("-Ba%2.2e:\" \@~\045\@~ pert. from %2.2f km/s\": -E10p -A",$bs1,$c0/1000);
+$Bscale1b  = sprintf("-Ba%2.2e:\" \": -E10p -A",$bs1,$c0/1000);
+$bs2 = 0.05;
+$Bscale1c = sprintf("-B%2.2ef1:\" Phase Speed\": -E10p",$bs2);
+$Bscale2   = sprintf("-B%2.2e:\" K ( x, y )  ( 10\@+%2.2i\@+  m\@+-2\@+ [\@~d\143\@~] )\": -E10p",$bs2,$kpwr);
+$Bscale3   = sprintf("-B%2.2e:\" \@~\143\@~ ( x\@-r\@- , y\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef10p",$bs3,$opwr);
+
+$Bscale_topo = "-B2000f500:\"Elevation (km)\":";
+
+#-------------------------
+# phase speed model
+$file1dat = "$dir/$mfile_dat";
+$file1syn = "$dir/$mfile_syn";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$J_title = "-JX${Jwid}";
+$R_title = "-R0/1/0/1";
+$x_title = 0.5;
+$z_title = 1.15;
+$fsize_title = 12;
+
+# shifting the subplots
+$xfac = 1.1;
+$yfac = 1.6;
+$dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+$dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+#===========================================================================
+# create colorpoint files
+
+  open(CSH,">$cshfile");
+
+  # phase speed model
+  if(1==1) {
+     $cpt_vel  = "../../model_files/socal_color.cpt";      # ranges from -5% to 3%
+     $cpt_vel2 = "../../model_files/socal_color_vel.cpt";
+
+  } else {
+     # make colorpoint file
+     #$T1 = "-T3/4/0.1";
+     $dc = 2*$cmax/20;
+     $T1 = "-T-$cmax/$cmax/$dc";
+     $cpt_vel = "color0.cpt";
+     print CSH "makecpt -C$colorbar $T1 > temp1\n";
+     print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+     print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel\n";
+
+     # make colorpoint file
+     $pmin = -$cmax;
+     $pmax = $cmax;
+     $cmin = ($pmin/100 + 1)*$c0 / 1000;
+     $cmax = ($pmax/100 + 1)*$c0 / 1000;
+     $dc = ($cmax-$cmin)/20;
+     $T1 = "-T$cmin/$cmax/$dc";
+     $cpt_vel2 = "color0.cpt";
+     print CSH "makecpt -C$colorbar $T1 > temp1\n";
+     print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+     print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel2\n";
+  }
+
+  # topography and bathymetry
+  $cpt_topo = "color.cpt";
+  $cmax = 5000; $dc = 2*$cmax/20;
+  $T = "-T-$cmax/$cmax/$dc";
+  print CSH "makecpt -Cglobe $T -Z > $cpt_topo \n";
+
+#  # kernel
+#  $cpt_ker = "color1.cpt";
+#  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+#  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+#  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_ker\n";
+
+#  # misfit (as a function of receiver)
+#  $cpt_chi = "color2.cpt";
+#  print CSH "makecpt -Chot $T3 -I > $cpt_chi\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  #die("testing");
+
+#===========================================================================
+if ($ifig00 == 1 || $ifig01 == 1) {
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen \n";
+  #===============================================
+
+  # file names for figures
+  if($ifig01==1) {$name = "socal_01"} else {$name = "socal_00"}
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # topography and bathymetry
+  if($ifig01==1) {$B = "$B0".$Bopts[13]} else {$B = "$B0".$Bopts[15]}
+  $title = "Southern California";
+
+  print CSH "psbasemap $J $R $B -K -V -P $origin > $psfile\n";  # START
+  if ($icolor==1) {print CSH "grdimage $grdfile -C$cpt_topo $J $R -I$gradfile -K -O -V -P >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info_k -K -O -V -P  >> $psfile \n";
+  print CSH "psbasemap $J $R $B -K -V -P -O >> $psfile\n";
+  print CSH "psxy $plate_file $J $R $plate_info_k -K -V -O -P >> $psfile \n";
+  print CSH "psxy $fault_file $J $R $fault_info_k -K -V -O >> $psfile \n";
+  print CSH "psxy $kcf_file $J $R $fault_info_k -K -V -O >> $psfile \n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  if($ifig01 == 1) {
+    print CSH "psscale -C$cpt_topo $Dscale $Bscale_topo -V -P -K -O >> $psfile \n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+  #=============================================
+  # phase speed map
+
+  $title = "Rayleigh wave phase speed map";
+  if($ifig01==1) {$B = "$B0".$Bopts[6]} else {$B = "$B0".$Bopts[15]}
+  $shift = $shift1;
+
+  $file01 = "$dir/socal_vel_dat.dat";
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {
+    print CSH "awk '{print \$1,\$2,\$4*100}' $file01 | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info_k -P -K -O -V >> $psfile\n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+
+  print CSH "psxy $plate_file $J $R $plate_info_k -K -V -O -P >> $psfile \n";
+  print CSH "psxy $fault_file $J $R $fault_info_k -K -V -O >> $psfile \n";
+  print CSH "psxy $kcf_file $J $R $fault_info_k -K -V -O >> $psfile \n";
+
+  if($ifig01 == 1) {
+  # scale bar
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "psscale -C$cpt_vel2 $Dscale $Bscale1c -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF
+-115.2 31.42 11 0 $fontno LM \@~\045\@~
+-115.2 30.65 11 0 $fontno LM km/s
+EOF\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+}
+
+  #=============================================
+  # inset map
+  $iwid = 0.8;
+  $Jinset = "-JM$iwid";
+  $x1q = -130; $x2q = -110;
+  $y1q = 25; $y2q = 50;
+  $Rinset = "-R$x1q/$x2q/$y1q/$y2q";
+  $Binset = "-B1::wesn";
+  $origin_inset = "-Xa-0.9 -Ya1.85";
+  $coast_info_inset  = "-W0.5p -Dl -Na/0.5p -A1000 -S220/255/255 -C220/255/255 -G200";
+
+  print CSH "pscoast $Jinset $Rinset $coast_info_inset $origin_inset -K -O -V -P >> $psfile \n";
+  #print CSH "psxy $plate_file_nuvel $Jinset $Rinset -M -W1.5p/0/0/255 $origin_inset -K -V -O -P >> $psfile \n";
+  print CSH "psxy $Jinset $Rinset -W2.0p/255/0/0 -N -K -O -V -P $origin_inset >>$psfile<<EOF\n $xmin $zmin\n$xmax $zmin\n$xmax $zmax\n$xmin $zmax\n$xmin $zmin\nEOF\n";
+  #print CSH "psxy $Jinset $Rinset -W2.0p -N -K -O -V $origin_inset >>$psfile<<EOF\n $x1q $y1q\n$x2q $y1q\n$x2q $y2q\n$x1q $y2q\n$x1q $y1q\nEOF\n";
+
+  print CSH "gmtset TICK_LENGTH 0\n";
+  print CSH "psbasemap $Jinset $Rinset $Binset $origin_inset -K -O -V -P >> $psfile \n";
+  print CSH "gmtset TICK_LENGTH $tick\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+if ($ifig02 == 1) {
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen \n";
+  #===============================================
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}001/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "socal_02";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # topography and bathymetry
+
+  $B = "$B0".$Bopts[13];
+  $title = "(a)  Source-receiver geometry";
+
+  print CSH "psbasemap $J $R $B -K -V -P $origin > $psfile\n";  # START
+  if ($icolor==1) {print CSH "grdimage $grdfile -C$cpt_topo $J $R -I$gradfile -K -O -V -P >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info2 -K -O -V -P  >> $psfile \n";
+  print CSH "psscale -C$cpt_topo $Dscale $Bscale_topo -V -P -K -O >> $psfile \n";
+  print CSH "psbasemap $J $R $B -K -V -P -O >> $psfile\n";
+  #print CSH "psxy $plate_file $J $R $plate_info_r -K -V -O -P >> $psfile \n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec_w >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # phase speed map
+
+  $title = "(b)  Rayleigh wave phase speed map";
+  $shift = $shift1;
+  $B = "$B0".$Bopts[6];
+
+  $file01 = "$dir/socal_vel_dat.dat";
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {
+    print CSH "awk '{print \$1,\$2,\$4*100}' $file01 | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info_k -P -K -O -V >> $psfile\n";
+  #print CSH "psxy $plate_file $J $R $plate_info_k -K -V -O -P >> $psfile \n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec_w >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+
+  # scale bar
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "psscale -C$cpt_vel2 $Dscale $Bscale1c -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF
+-115.2 31.42 11 0 $fontno LM \@~\045\@~
+-115.2 30.65 11 0 $fontno LM km/s
+EOF\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # inset map
+  $iwid = 0.8;
+  $Jinset = "-JM$iwid";
+  $x1q = -130; $x2q = -110;
+  $y1q = 25; $y2q = 50;
+  $Rinset = "-R$x1q/$x2q/$y1q/$y2q";
+  $Binset = "-B1::wesn";
+  $origin_inset = "-Xa-0.9 -Ya1.85";
+  $coast_info_inset  = "-W0.5p -Dl -Na/0.5p -A1000 -S220/255/255 -C220/255/255 -G200";
+
+  print CSH "pscoast $Jinset $Rinset $coast_info_inset $origin_inset -K -O -V -P >> $psfile \n";
+  #print CSH "psxy $plate_file_nuvel $Jinset $Rinset -M -W1.5p/0/0/255 $origin_inset -K -V -O -P >> $psfile \n";
+  print CSH "psxy $Jinset $Rinset -W2.0p/255/0/0 -N -K -O -V -P $origin_inset >>$psfile<<EOF\n $xmin $zmin\n$xmax $zmin\n$xmax $zmax\n$xmin $zmax\n$xmin $zmin\nEOF\n";
+  #print CSH "psxy $Jinset $Rinset -W2.0p -N -K -O -V $origin_inset >>$psfile<<EOF\n $x1q $y1q\n$x2q $y1q\n$x2q $y2q\n$x1q $y2q\n$x1q $y1q\nEOF\n";
+
+  print CSH "gmtset TICK_LENGTH 0\n";
+  print CSH "psbasemap $Jinset $Rinset $Binset $origin_inset -K -O -V -P >> $psfile \n";
+  print CSH "gmtset TICK_LENGTH $tick\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+if ($ifig03 == 1) {
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}001/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "socal_03";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # source-receiver geometry
+
+  $B = "$B0".$Bopts[13];
+  $title = "Source-receiver geometry";
+
+  $Bscale = "-B2000f500:\"Elevation (km)\": -A";
+
+  print CSH "psbasemap $J $R $B -K -V -P $origin > $psfile\n";  # START
+  print CSH "pscoast $J $R $coast_info3 -K -O -V -P  >> $psfile \n";
+  print CSH "psbasemap $J $R $B -K -V -P -O >> $psfile\n";
+  #print CSH "psxy $plate_file $J $R $plate_info_r -K -V -O -P >> $psfile \n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec_r >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src_b >> $psfile\n";
+
+  # plot receivers with numbered label
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V  $rec0 >> $psfile\n";
+  #$rec_file = text_rec; $angle = 0; $just = "CM";
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3,$fsize3,$angle,$fontno,\"$just\",\$4}' $recfile > $rec_file\n";
+  #print CSH "pstext $rec_file -N $J $R -K -O -P -V >> $psfile\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # phase speed map
+
+  $shift = $shift1;
+  $B = "$B0".$Bopts[6];
+
+  $file01 = "$dir/socal_vel_dat.dat";
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {
+    print CSH "awk '{print \$1,\$2,\$4*100}' $file01 | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast)info_k -P -K -O -V >> $psfile\n";
+  #print CSH "psxy $plate_file $J $R $plate_info_k -K -V -O -P >> $psfile \n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec_w >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+
+  # plot all the possible ray paths
+  print "\n $evefile $recfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile > src_temp \n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile > rec_temp \n";
+  open(IN,"rec_temp"); @recs = <IN>; $nrec = @recs;
+  open(IN,"src_temp"); @srcs = <IN>; $nsrc = @srcs;
+  print "\n nrec = $nrec, nsrc = $nsrc \n";
+  if($icolor==1) {
+    for ($isrc = 0; $isrc <= $nsrc-1; $isrc = $isrc+1) {
+       for ($irec = 0; $irec <= $nrec-1; $irec = $irec+1) {
+          chomp($srcs[$isrc]); chomp($recs[$irec]);
+          #print "\n $isrc $irec $srcs[$isrc] $recs[$irec] ";
+          print CSH "psxy -W0.25p $J $R -K -O -V -P >>$psfile<<EOF\n $srcs[$isrc] \n $recs[$irec] \nEOF\n";
+       }
+    }
+  }  # icolor
+
+  $npath = $nsrc * $nrec;
+  $title = "$nsrc events  \@~\264\@~  $nrec receivers  =  $npath ray-paths";
+
+  #die("testing");
+
+  # scale bar
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "psscale -C$cpt_vel2 $Dscale $Bscale1c -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF
+-115.2 31.42 11 0 $fontno LM \@~\045\@~
+-115.2 30.65 11 0 $fontno LM km/s
+EOF\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#  #=============================================
+#  # inset map
+#  $iwid = 0.8;
+#  $Jinset = "-JM$iwid";
+#  $x1q = -130; $x2q = -110;
+#  $y1q = 25; $y2q = 50;
+#  $Rinset = "-R$x1q/$x2q/$y1q/$y2q";
+#  $Binset = "-B1::wesn";
+#  $origin_inset = "-Xa-0.9 -Ya1.85";
+
+#  print CSH "pscoast $Jinset $Rinset $coast_info_inset $origin_inset -K -O -V >> $psfile \n";
+#  print CSH "psxy $Jinset $Rinset -W2.0p/255/0/0 -N -K -O -V $origin_inset >>$psfile<<EOF\n $xmin $zmin\n$xmax $zmin\n$xmax $zmax\n$xmin $zmax\n$xmin $zmin\nEOF\n";
+#  #print CSH "psxy $Jinset $Rinset -W2.0p -N -K -O -V $origin_inset >>$psfile<<EOF\n $x1q $y1q\n$x2q $y1q\n$x2q $y2q\n$x1q $y2q\n$x1q $y1q\nEOF\n";
+
+#  print CSH "gmtset TICK_LENGTH 0\n";
+#  print CSH "psbasemap $Jinset $Rinset $Binset $origin_inset -K -O -V >> $psfile \n";
+#  print CSH "gmtset TICK_LENGTH $tick\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig04 == 1) {
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # file names for figures
+  $name    = "socal_04";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # source-receiver geometry
+
+  $R = "-R-123/-112/29/36.5";
+  $Jwid = 8;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $origin = "-X1 -Y1";
+
+  $B = "$B0".$Bopts[0];
+  $title = "Source-receiver geometry";
+
+  $Bscale = "-B2000f500:\"Elevation (km)\": -A";
+
+  print CSH "psbasemap $J $R $B -K -V $origin > $psfile\n";  # START
+  if ($icolor==1) {print CSH "grdimage $grdfile -C$cpt_topo $J $R -I$gradfile -K -O -V >> $psfile\n"}
+
+  #print CSH "pscoast $J $R $coast_info3 -K -O -V  >> $psfile \n";
+  print CSH "pscoast $J $R $coast_info_k -K -O -V  >> $psfile \n";
+  print CSH "psbasemap $J $R $B -K -V -O >> $psfile\n";
+  print CSH "psxy $plate_file $J $R $plate_info_k -K -V -O >> $psfile \n";
+  print CSH "psxy $fault_file $J $R $fault_info_k -K -V -O >> $psfile \n";
+  print CSH "psxy $kcf_file $J $R $fault_info_k -K -V -O >> $psfile \n";
+  if($ishelf == 1) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R -W1.5tap -K -O -V >> $psfile\n"}
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_2wid.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_3wid.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_3wid.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_3wid.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,3051 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_gji_3wid.pl
+#  Carl Tape
+#  04-Nov-2005
+#
+#  First run wave2d.f90, then model_optimize_poly.m to get axes limits, etc.
+#
+#  ISTRUCTURE:
+#    1. checker, Nfac=3
+#    2. checker, Nfac=2
+#    3. checker, Nfac=1
+#    4. rayleigh wave (T=20s, smoothed with sig=10km)
+#
+#    plot_gji_3wid.pl 25 60000 -6/3.0/0/80/08/03 1 0460 0  8 1 1 1 0   # big checker: ifig01,2,3,4
+#    plot_gji_3wid.pl 25 30000 -6/3.0/0/80/10/05 1 0780 0  8 1 1 3 0   # sm  checker: ifig02,4
+#    plot_gji_3wid.pl 25 15000 -6/3.0/0/80/20/10 1 4000 0 16 1 1 3 0   # sm  checker, 20 percent: ifig04
+#    plot_gji_3wid.pl 25 30000 -6/3.0/0/20/08/03 1 0280 0  8 0 1 4 0   # rayleigh   : ifig02,4
+#
+#    plot_gji_3wid.pl 25 30000 -6/3.0/0/20/08/03 1 0100 0  0 1 4 0 0   # rayleigh: ifig04
+#    plot_gji_3wid.pl 25 30000 -6/3.0/0/20/08/03 1 0140 0  0 1 4 0 0   # rayleigh: ifig04
+#
+#    plot_gji_3wid.pl 25 60000 -6/3.0/0/80/08/03 1 2500 0  1 1 2 0 0
+#
+#    plot_gji_3wid.pl 25 90000 -7/6.0/0/80/08/03 1 0500 1  1 0 1 0 0   # ifig04b (kernels only)
+#    plot_gji_3wid.pl 25 75000 -7/6.0/0/80/08/03 1 0480 1  1 0 1 0 0
+#    plot_gji_3wid.pl 25 60000 -7/6.0/0/80/08/03 1 0460 1  1 0 1 0 0
+#    plot_gji_3wid.pl 25 45000 -7/6.0/0/80/08/03 1 0440 1  1 0 1 0 0
+#    plot_gji_3wid.pl 25 30000 -7/6.0/0/80/08/03 1 0420 1  1 0 1 0 0
+#    plot_gji_3wid.pl 25 15000 -7/6.0/0/80/08/03 1 0400 1  1 0 1 0 0
+#
+#    plot_gji_3wid.pl 25 60000 -7/3.0/0/20/08/03 1 0460 0  8 1 1 1 0    # big checker, 04b
+#    plot_gji_3wid.pl 25 30000 -7/3.0/0/80/08/03 1 0780 0  8 1 1 3 0    # sm checker, 04b
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0280 0  8 0 1 4 0    # rayleigh, 04b
+#
+#    plot_gji_3wid.pl 25 60000 -6/2.0/0/20/08/03 1 0460 0  8 1 0 1 0   # ifig05
+#    plot_gji_3wid.pl 25 60000 -6/1.5/0/20/08/03 1 0460 0  8 1 0 1 0   # ifig07 -- big checker
+#    plot_gji_3wid.pl 25 60000 -6/3.0/0/20/08/03 1 0280 0  8 0 0 4 0   # ifig07 -- rayleigh
+#    plot_gji_3wid.pl 25 60000 -7/7.0/0/20/08/03 1 0460 0  8 1 0 1 0   # 6,8,8b,9
+#
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0280 0  8 0 0 4 0   # rayleigh, ifig10
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0520 0  8 0 0 4 0   # rayleigh, ifig10 (pert source)
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0540 0  8 0 0 4 0   # rayleigh, ifig10 (pert dT 50%)
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0560 0  8 0 0 4 0   # rayleigh, ifig10 (pert dT 20%)
+#
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0280 0  8 0 1 4 0   # rayleigh, ifig10
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0100 0 16 0 1 4 0   # rayleigh, ifig10 -- with CG cubic-quad
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/08/03 1 0100 0 16 0 1 4 0   # rayleigh, ifig10b
+#
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/09/03 1 0005 0  0 1 0 1 1   # ifig20
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/10/05 1 0010 0  0 1 0 3 1   # ifig20, 07/24/06
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/20/10 1 0011 0  0 1 0 3 1   # ifig20, 07/24/06
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/09/03 1 0020 0  0 0 0 4 1   # ifig20, 07/19/06
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/09/03 1 0021 0  0 0 0 4 1   # ifig20
+#
+#    plot_gji_3wid.pl 25 30000 -7/1.0/0/20/0.8 1  20 0  0 0 0 4 1   # ifig20b
+#
+#==========================================================
+
+if (@ARGV < 8) {die("Usage: plot_kernels.pl nevent Gamma colors iker irun0 iter niter ichecker ipoly istructure ibanana \n");}
+($nevent,$Gamma,$colors,$iker,$irun0,$iter,$niter,$ichecker,$ipoly,$istructure,$ibanana) = @ARGV;
+
+if($ibanana==1) {$odir      = "../../../2d_adjoint_banana/OUTPUT_banana/run_"}
+else            {$odir      = "../../OUTPUT/run_"}
+
+$edir      = "event_001";  # event for first event (sr.txt)
+
+$mfile_dat = "socal_vel_dat.dat";
+$mfile_syn = "socal_vel_syn.dat";
+$kerfile   = "kernel_basis";
+
+$cshfile = "plot_gji_3wid.csh";
+
+if($istructure==1){$Nfac=3}
+if($istructure==2){$Nfac=2}
+if($istructure==3){$Nfac=1}
+$sNfac = sprintf("%1i",$Nfac);
+
+# boolean commands for plotting
+$icolor = 1;   # ccc
+
+$ifig01  = 0;   # original CG 2-figure, 3x3 subplots
+$ifig02  = 0;   # modified CG 1-figure, 3x3 subplots -- THIS MUST NOT BE RUN AFTER ifig01
+$ifig03  = 0;   # phase vel models (6), 3x3 subplots
+$ifig04  = 0;   # phase vel models (8), 3x3 subplots
+$ifig04b = 0;   # kernels (9), 3x3 subplots
+$ifig05  = 0;   # smoothing process for kernels
+$ifig06  = 0;   # smoothing vs scalelength, 4x3 subplots
+$ifig07  = 1;   # event kernels --> summed event kernel, 3x3 subplots
+$ifig08  = 0;   # maps    : map vs Nevent, 4x3 subplots
+$ifig08b = 0;   # maps    : map vs Nevent, 3x1 subplots
+$ifig09  = 0;   # kernels : map vs Nevent, 4x3 subplots
+$ifig10  = 0;
+$ifig10b = 0;
+
+# L-curve plots with recovered models
+$ifig20  = 0;   # recovered images for classical tomography (hessian)
+$ifig20b = 0;   # paper
+
+$irun = $irun0 + $iter;
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t","9","9t","10","10t","11","11t","12","12t","13","13t","14","14t","15","15t","16","16t");
+$mod = $mods[$iter];
+$smod = "m\@+$mod\@+";
+
+# label for the type of map used to generate the data
+$smap = sprintf("m%2.2i",$istructure);
+
+# wave2d run number
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "$odir$strun0";
+$dir = "$odir$strun";
+
+$stGam  = sprintf("\@~\107\@~ = %.1f km",$Gamma/1000);
+$stGam2 = sprintf("%3.3i",$Gamma/1000);
+
+print "\n $dir, $edir, $mfile_dat, $mfile_syn, $kerfile";
+print "\n $colors, $iker, $mod, $stGam2 \n";
+#die("testing");
+
+# colors for the kernel and misfit function
+ at cols = split("/",$colors);
+$kpwr  = $cols[0];  # power for kernels
+$kmax  = $cols[1];  # value for kernels
+$opwr  = $cols[2];  # power for misfit maps
+$omax  = $cols[3];  # value for misfit maps
+$cmax  = $cols[4];  # value for phase speed maps (percent pert)
+$ctick = $cols[5];  # value for phase speed maps (percent pert tick)
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+ at units = ("m\@+2\@+ s","s\@+2\@+","xxx","xxx","xxx","xxx","xxx");
+$ktype = $titles[$iker];
+$utype = $units[$iker];
+
+$plabel = "/home/carltape/2d_adjoint/scripts/plot_ker_mod.pl";
+
+# data files
+$dir_gmt = "/home/carltape/gmt";
+$ishelf = 0;
+$shelf_file = "../../INPUT/oms_shelf";
+$plate_file = "${dir_gmt}/plate_boundaries";
+$fault_file = "${dir_gmt}/faults/jennings.xy";
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "8";
+$fsize3 = "5";
+$fontno = "4";    # 1 or 4
+$tick   = "0.1c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# plot symbols for sources, receivers, and shelf
+$src    = "-W0.5p -Sa8p";
+$rec    = "-Sc2p -G0";
+$rec0   = "-Sc10p -W0.5p";
+$src_ev = "-W0.5p -Sa12p -G255";
+$Wshelf = "-W0.5/0/0/0tap";
+
+$coast_info = "-W1p -Na/1p -Df";
+$coast_info2 = "-W0.5p -Na/0.5p -Df";
+
+$plate_info_w = "-M -W2.5p/255/255/255";
+$plate_info_r = "-M -W2.5p/255/0/0";
+$plate_info_b = "-M -W2.5p/0/0/255";
+$plate_info_k = "-M -W2.5p";
+
+$fault_info_r = "-M -W1.5p/255/0/0";
+$fault_info_k = "-M -W1.5p/0/0/0";
+$fault_info_w = "-M -W1.5p/255/255/255";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+#-------------------------
+# color for chi (objective function)
+
+$norm3 = "1e$opwr";
+$ss = $omax;
+$ds = $ss/$scale_color;
+$bs3 = sprintf("%3.3e",0.9*$ss/3); # colorbar
+$T3 = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+print "T3 = $T3\n";
+
+#-------------------------
+# get reference phase speed and period
+
+$c0 = 3500; $per = 20;
+
+open(IN,"$dir0/socal_vel_c0.dat");
+ at vals = <IN>;
+$c0       = $vals[0];
+$per      = $vals[1];
+$lam      = $c0*$per;
+$per_lab  = sprintf("T = %.1f s",$per);
+$c0_lab   =  sprintf("c0 = %.2f km/s",$c0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $c0_lab, $lam_lab \n";
+
+#-------------------------
+
+# write plotting scripts
+$Jwid = 2;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.8 -Y8.25";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+$B0 = "-B1:.\" \":";
+
+# axes scale for phase speed maps: c(th, ph)
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Speed for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Speed for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$bs1 = $ctick;
+$Bscale1  = sprintf("-B%2.2ef1:\" \@~\045\@~ pert. from %2.2f km/s\": -E7p",$bs1,$c0/1000);
+$Bscale1b = sprintf("-B%2.2ef1:\" \": -E7p",$bs1);
+
+# axes scale for kernels: K(th, ph)
+# [\@~\143\@~] --> s
+$tp = "\@~\146\@~, \@~\161\@~";
+$Bscale2  = sprintf("-B%2.2e:\" K ( $tp )  ( 10\@+%2.2i\@+  m\@+-2\@+ s )\": -E7p",$bs2,$kpwr);
+$Bscale2b = sprintf("-B%2.2e:\" \": -E7p",$bs2);
+
+# axes scale for chi_plots: chi(th_r, ph_r)
+$Bscale3  = sprintf("-B%2.2e:\" \@~\143\@~ ( \@~\161\@~\@-r\@- , \@~\146\@~\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef7p",$bs3,$opwr);
+
+#-------------------------
+# phase speed model
+$file1dat = "$dir/$mfile_dat";
+$file1syn = "$dir/$mfile_syn";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$J_title = "-JX${Jwid}";
+$R_title = "-R0/1/0/1";
+$x_title = 0.5;
+$z_title = 1.08;
+$fsize_title = 9;
+
+#=================================================================
+# files and parameters related to polynomial plots and misfit-vs-iteration plots
+
+  $p_info_k   = "-N -Sc6p -W0.5p -G0";
+  $p_info_w   = "-N -Sc6p -W0.5p -G255";
+  $c_info_ks  = "-W0.5p";
+  $c_info_ks2 = "-W1.5p";
+  $c_info_rd  = "-W1.0/255/0/0tap";
+  $c_info_bd  = "-W1.0/0/0/255tap";
+  $c_info_kd  = "-W0.5/0/0/0tap";
+
+if ($ipoly==1) {
+
+  # axes limits for polynomial plots
+  $axes_file = "axes_${strun0}.dat";
+  if (not -f $axes_file)   { die("Check if $axes_file exist or not\n") }
+  open(IN,"$axes_file");
+  @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]);  # polynomial
+  ($a2x1,$a2x2,$a2y1,$a2y2) = split(" ",$ax_lims[1]);  # chi vs iteration
+  ($a3x1,$a3x2,$a3y1,$a3y2) = split(" ",$ax_lims[2]);  # var-red vs iteration
+
+  # scale the axes
+  #$lpwr_x = 3; $xtick = 4;
+  #$lpwr_y = 2; $ytick = 2;
+  $lpwr_x = int( log($a1x2) / log(10) ); $xtick = 1;
+  $lpwr_y = int( log($a1y2) / log(10) ); $ytick = 1;
+  $normgx = "1e$lpwr_x";
+  $normgy = "1e$lpwr_y";
+
+  #die("testing");
+
+  $xming = $a1x1/$normgx;
+  $xmaxg = $a1x2/$normgx;
+  $yming = $a1y1/$normgy;
+  $ymaxg = $a1y2/$normgy;
+  $R_poly = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_poly = "-JX$Jwid";
+
+  # polynomial lines and curves
+  $poly_curve = "poly_curve_${strun0}.dat";
+  $poly_pts   = "poly_points_${strun0}.dat";
+  if (not -f ${poly_curve}) { die("Check if ${poly_curve} exist or not\n") }
+  if (not -f ${poly_pts})   { die("Check if ${poly_pts} exist or not\n") }
+  open(IN,"$poly_pts");
+  @poly_pts = <IN>;
+  ($x1t,$y1t) = split(" ",$poly_pts[0]); $x1 = $x1t/$normgx; $y1 = $y1t/$normgy;
+  ($x2t,$y2t) = split(" ",$poly_pts[1]); $x2 = $x2t/$normgx; $y2 = $y2t/$normgy;
+  ($x3t,$y3t) = split(" ",$poly_pts[2]); $x3 = $x3t/$normgx; $y3 = $y3t/$normgy;
+  ($x4t,$y4t) = split(" ",$poly_pts[3]); $x4 = $x4t/$normgx; $y4 = $y4t/$normgy;
+  ($x5t,$y5t) = split(" ",$poly_pts[4]); $x5 = $x5t/$normgx; $y5 = $y5t/$normgy;
+  ($x6t,$y6t) = split(" ",$poly_pts[5]); $x6 = $x6t/$normgx; $y6 = $y6t/$normgy;
+  ($x7t,$y7t) = split(" ",$poly_pts[6]); $x7 = $x7t/$normgx; $y7 = $y7t/$normgy;
+
+  # chi-vs-iteration
+  $xming = $a2x1;
+  $xmaxg = $a2x2;
+  $yming = $a2y1;
+  $ymaxg = $a2y2;
+  $chi_ran = $xmaxg - $xming;
+  $R_chi = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_chi = "-JX${Jwid}i/${Jwid}il";        # note log scale on y-axis
+
+  # text labels for chi-vs-m plots
+  $schi0 = "\@~\143\@~(m\@+0\@+)";
+  $schi1 = "\@~\143\@~(m\@+1\@+)";
+  $x0chit = 0 + 0.05*$chi_ran;
+  $x1chit = 1 + 0.05*$chi_ran;
+
+  $chi_curve = "chi_curve_${strun0}.dat";
+  if (not -f $chi_curve)   { die("Check if $chi_curve exist or not\n") }
+
+  # var.red-vs-iteration
+  $xming = $a3x1;
+  $xmaxg = $a3x2;
+  $yming = $a3y1;
+  $ymaxg = $a3y2;
+  $R_var = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_var = "-JX$Jwid";
+
+  $var_pts = "var_${strun0}.dat";
+  $var_fit = "var_fit_${strun0}.dat";
+  if (not -f $var_fit)   { die("Check if $var_fit exist or not\n") }
+  if (not -f $var_pts)   { die("Check if $var_pts exist or not\n") }
+
+  # scale for polynomial plots (chi0, chi1)
+  $B1 = sprintf("-B${xtick}:\"\@~\156\@~   ( 10\@+%2.2i\@+ ) \":/${ytick}:\" \@~\143\@~\@+0\@+ [ m (\@~\156\@~) ]   ( 10\@+%2.2i\@+  $utype ) \":",$lpwr_x,$lpwr_y);
+  $B2 = sprintf("-B${xtick}:\"\@~\156\@~   ( 10\@+%2.2i\@+ ) \":/${ytick}:\" \@~\143\@~\@+1\@+ [ m (\@~\156\@~) ]   ( 10\@+%2.2i\@+  $utype ) \":",$lpwr_x,$lpwr_y);
+
+  # scale for chi-vs-m plots
+  $iter_tick = 2;
+  $B3a    = "-Ba${iter_tick}f1:\" k, model number \":/a1f2g1p:\" \@~\143\@~ (m)   ( $utype ) \":";
+  $B3b    = "-Ba${iter_tick}f1:\" k, model number \":/a1f2g1p:\" \":";
+  $B4     = "-Ba${iter_tick}f1:\" k, model number \":/20:\" \":";
+
+}
+
+#===========================================================================
+# create colorpoint files
+
+  open(CSH,">$cshfile");
+
+  $cpt_vel_map = "../../model_files/socal_color.cpt";
+
+  # make uniform colorpoint file
+  #$T1 = "-T3/4/0.1";
+  $dc = $cmax/10;
+  $T1 = "-T-$cmax/$cmax/$dc";
+  $cpt_vel_uniform = "color0.cpt";
+  print CSH "makecpt -C$colorbar $T1 > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel_uniform\n";
+
+  # phase speed model
+  if($ichecker==0) {$cpt_vel = $cpt_vel_map}
+  else             {$cpt_vel = $cpt_vel_uniform}
+
+  # kernel
+  $cpt_ker = "color1.cpt";
+  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_ker\n";
+
+  # misfit (as a function of receiver)
+  $cpt_chi = "color2.cpt";
+  print CSH "makecpt -Chot $T3 -I > $cpt_chi\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  #die("testing");
+
+#===========================================================================
+if ($ifig01 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.25;
+  $yfac = 1.6;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen \n";
+  #===============================================
+
+  # get the summed kernel and chi files
+  $file2 = "$dir/summed_ker.dat";
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}/sr.txt";            # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_cg01a_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  # number of receivers
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+  # $npath = $nrec * $nevent;
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Target phase speed model (data)";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  $title = "Summed misfit : $schi";
+  $B = "$B0".$Bopts[15];
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R -A- -C$cpt_chi -I -K -O -P -V >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_chi $Dscale $Bscale3 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $title = "Plot  $schi";
+  $Bg = "$B1".$Bopts[8];
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel
+
+  $shift = $shift1;
+  $title = "Gradient for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift1;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  g\@+0\@+ = d\@~\143\@~ / dm($smod)";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Estimate test model m\@+0t\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 1);
+  $dir = "$odir$strun";
+
+  $mod = $mods[1];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "$dir/$mfile_syn";
+  $file2 = "$dir/summed_ker.dat";
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}/sr.txt";  # src-rec for first event
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  $title = "Summed misfit : $schi";
+  $B = "$B0".$Bopts[15];
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R -A- -C$cpt_chi -I -K -O -P -V >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_chi $Dscale $Bscale3 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#=================================================================
+# SECOND FIGURE
+#=================================================================
+
+#===========================================================================
+if ($ifig01 == 1) {
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # file names for figures
+  $name    = "${smap}_cg01b_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # graph
+
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  $schi";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -V $origin > $psfile\n";  # START
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel
+
+  $shift = $shift1;
+  $title = "Gradient for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift1;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  g\@+0t\@+ = d\@~\143\@~ / dm($smod)";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  #print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Cubic interpolation to get m\@+1\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$5 / $normgy}' $poly_curve | psxy $c_info_ks2 $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_kd -K -O -V -P >>$psfile<<EOF\n$x5 $a1y1 \n$x5 $y5 \n$a1x1 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \n$x4 $y4 \n$x5 $y5 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 2);
+  $dir = "$odir$strun";
+
+  $mod = $mods[2];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "$dir/$mfile_syn";
+  $file2 = "$dir/summed_ker.dat";
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}/sr.txt";  # src-rec for first event
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  $title = "Summed misfit : $schi";
+  $B = "$B0".$Bopts[15];
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R -A- -C$cpt_chi -I -K -O -P -V >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_chi $Dscale $Bscale3 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  $schi";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$5 / $normgy}' $poly_curve | psxy $c_info_ks2 $J_poly $R_poly -K -O -P -V >> $psfile\n";
+
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_kd -K -O -V -P >>$psfile<<EOF\n$x5 $a1y1 \n$x5 $y5 \n$a1x1 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x5 $a1y1 \n$x6 $y6 \n$a1x1 $y6 \nEOF\n";
+
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \n$x4 $y4 \n$x5 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3 \n $x6 $y6 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift1;
+  $Bg = "$B2".$Bopts[8];
+  $title = "New line search";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y6 \n$a1x1 $y6 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y6 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # misfit vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B3a".$Bopts[8];
+  $title = "Misfit for first two models";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n0 $y1t \n1 $y7t \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n 0.75 $y1t $fsize1 0 $fontno LM $schi0 \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n 1.75 $y7t $fsize1 0 $fontno LM $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+#===========================================================================
+if ($ifig02 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.2;
+  $yfac = 1.35;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.05*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the summed kernel and chi files
+  #$file2 = "$dir/summed_ker.dat";
+  $file2 = "$dir/fun_smooth.dat";       # smoothed kernel
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_cg02_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  # number of receivers
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "(a)  Target model (data)";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "(b)  Initial model $smod (synthetics)";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel -- SMOOTHED VERSION
+
+  $shift = $shift1;
+  $title = "(c)  Gradient (smoothed) for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2b -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "(d)  Estimate test model m\@+0t\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 1);
+  $dir = "$odir$strun";
+
+  $mod = $mods[1];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "$dir/$mfile_syn";
+  #$file2 = "$dir/summed_ker.dat";
+  $file2 = "$dir/fun_smooth.dat";
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}/sr.txt";  # src-rec for first event
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "(e)  Test model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel -- SMOOTHED VERSION
+
+  $shift = $shift1;
+  $title = "(f)  Gradient (smoothed) for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  #print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "(g)  Cubic interpolation to get m\@+1\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$5 / $normgy}' $poly_curve | psxy $c_info_ks2 $J_poly $R_poly -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V -P >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_kd -K -O -V -P >>$psfile<<EOF\n$x5 $a1y1 \n$x5 $y5 \n$a1x1 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V -P >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V -P >>$psfile<<EOF\n$x2 $a1y1 \n$x4 $y4 \n$x5 $y5 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 2);
+  $dir = "$odir$strun";
+
+  $mod = $mods[2];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "$dir/$mfile_syn";
+  $file2 = "$dir/summed_ker.dat";
+  $file3 = "$dir/summed_chi_r.dat";
+  $recfile = "$dir/${edir}/sr.txt";  # src-rec for first event
+  $chifile = "$dir/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "(h)  Updated model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # misfit vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $title = "(i)  Misfit for first two models";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n0 $y1t \n1 $y7t \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n 0.75 $y1t $fsize1 0 $fontno LM $schi0 \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n 1.75 $y7t $fsize1 0 $fontno LM $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+
+#-----------------------------
+
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig03 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $niter = 8;
+
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    $irun = $irun0 + 2*$k;              # wave2d run number
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $file1syn = "$dir/$mfile_syn";
+    $file1ker = "$dir/summed_ker.dat";
+    $ker_files[$k] = $file1ker;
+    $mod_files[$k] = $file1syn;
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+
+    # load chi values
+    $chifile = "$dir/summed_chi_all.dat";
+    open(IN,"$chifile");
+    $chi = <IN>;
+    $it_vals[$k] = $k;
+    $chi_vals[$k] = $chi;
+    #$schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  }
+
+  #die("testing");
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_cg03_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Target phase speed model (data)";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $niter_max = 4;
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+    $mod = $mods[$k*2]; $smod = "m\@+$mod\@+"; $title = "Phase speed model $smod";
+    if ($k % 3 == 2) {$shift = $shift2} else {$shift = $shift1}
+
+    # phase speed map
+    print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+    if ($icolor==1) {
+      print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+    }
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+  # plot final model
+  $shift = $shift2;
+  $mod = $mods[$niter*2]; $smod = "m\@+$mod\@+"; $title = "Phase speed model $smod";
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {
+    print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$niter] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # misfit vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $title = "Misfit,  \@~\143\@~ (m)  ( $utype )";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";
+  }
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n 1 $y1t $fsize1 0 $fontno LM $schi0 \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n 2 $y7t $fsize1 0 $fontno LM $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # var-red vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B4".$Bopts[8];
+  $title = "Variance reduction";
+
+  print CSH "psbasemap $Bg $R_var $J_var -P -K -O -V $shift >> $psfile\n";
+
+  print CSH "awk '{print \$1,\$2}' $var_fit | psxy $c_info_rd $J_var $R_var -K -O -P -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $var_pts | psxy $p_info_k $J_var $R_var -K -O -P -V >> $psfile\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig04 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX2 = -2*$dX; $dY2 = -$yfac*$Jwid; $shift2 = "-X$dX2 -Y$dY2";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # iteration index (subset of all possible)
+  #@kvec = (0,1,2,3);
+  #@kvec = (0,1,2,3,8,12,16);
+  #@kvec = (0,1,2,3,8);
+  @kvec = (1,2,3,4,8);
+  $numk = @kvec;
+  $niter_max = $kvec[$numk-1];  # max iteration is the last in the list
+
+  if($numk % 3 == 1) {$shift3 = "-X$dX"}
+  if($numk % 3 == 2) {$shift3 = "-Y$dY2"}
+  if($numk % 3 == 0) {$shift3 = "-X-$dX -Y$dY2"}
+
+  # load all possible files
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+    $irun = $irun0 + 2*$k;              # wave2d run number
+
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $file1syn = "$dir/$mfile_syn";
+    $file1ker = "$dir/summed_ker.dat";
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+    #if (not -f $file1ker)   { die("Check if $file1ker exist or not\n") }
+    $ker_files[$k] = $file1ker;
+    $mod_files[$k] = $file1syn;
+
+    # load chi values
+    $chifile = "$dir/summed_chi_all.dat";
+    open(IN,"$chifile");
+    $chi = <IN>;
+    chomp($chi);
+    $it_vals[$k] = $k;
+    $chi_vals[$k] = $chi;
+    #$schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  }
+  #print "\n @it_vals \n @chi_vals \n\n"; die("testing");
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_cg04_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  $B = "$B0".$Bopts[15];
+
+  #=============================================
+  # phase speed map for m1
+
+  #$k = 1;
+  #$mod = $mods[$k*2]; $smod = "m\@+$mod\@+"; $title = "Phase speed model $smod";
+
+  #print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  #print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  #if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  ##print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  #print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # recovered models for synthetics
+
+  @labs  = ("a","b","c","d","e","f","g","h","i","j");
+
+  #$numk = @kvec;
+  for ($i = 0; $i < $numk; $i = $i+1) {
+    $k = $kvec[$i];
+
+    $mod = $mods[2*$k]; $smod = "m\@+${mod}\@+"; $title = "($labs[$i])  Phase speed model ${smod}";
+    if ($i % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+    # phase speed map
+    if($i == 0) { print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"} # START
+    else        { print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n"}
+    if ($icolor==1) {
+      print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+    }
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+  #=============================================
+  # misfit vs iteration
+
+  # whether to plot the phase speed map for data
+  $idatamap = 0;    # =0 for GJI figure
+  if($idatamap==1) {$shift = $shift3} else {$shift = $shift1}
+
+  $Bg = "$B3b".$Bopts[8];
+  $title = "($labs[$i])  Misfit,  \@~\143\@~ (m\@+k\@+)  ($utype)";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";  # plot point
+  }
+  # labels for chi0 and chi1
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n $x0chit $y1t $fsize1 0 $fontno LM $schi0 \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n $x1chit $y7t $fsize1 0 $fontno LM $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # phase speed map for data
+
+  if($idatamap==1) {
+
+  $shift = $shift1;
+  $title = "Target phase speed model (data)";
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  }
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig04b == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $niter = 8;
+
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    $irun = $irun0 + 2*$k;              # wave2d run number
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $file1syn = "$dir/$mfile_syn";
+    $file1ker = "$dir/summed_ker.dat";
+    $ker_files[$k] = $file1ker;
+    $mod_files[$k] = $file1syn;
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+  }
+
+  #die("testing");
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_ker9_${stGam2}_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # kernels
+
+  $B = "$B0".$Bopts[15];
+  $niter_max = $niter;
+
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+    $mod = $mods[$k*2]; $smod = "m\@+$mod\@+"; $title = "Kernel for $smod";
+    if ($k % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+    # phase speed map
+    if ($k == 0) {print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"}
+    else         {print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n"}
+
+    if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $ker_files[$k] | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig05 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.45;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # file with desired functions
+  $file_smooth = "$dir0/fun_smooth.dat";
+  if (not -f $file_smooth) { die("Check if $file_smooth exist or not\n") }
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_smooth_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[8]; $title = "(a)  Unsmoothed kernel for m\@+0\@+"; $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$5 / $norm2 }' $file_smooth | pscontour $R $J -A- -C$cpt_ker -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info2 -P -K -O -V >> $psfile\n";
+  #if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #$stsig = sprintf("\@~\163\@~ = %.1f km",$sigma/1000);
+  #$stGam = sprintf("\@~\107\@~ = %.1f km",$Gamma/1000);
+  $B = "$B0".$Bopts[15]; $title = "(b)  Smoothed kernel,  $stGam"; $shift = $shift1;
+
+  # smooth function
+  print CSH "psbasemap $B $J $R -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2}' $file_smooth | pscontour $R $J -A- -C$cpt_ker -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info2 -P -K -O -V >> $psfile\n";
+  #if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #------------------------------------------
+  # make colorpoint file for Gaussian
+  #$cmax2 = 1/(2*3.14159*$sigma*$sigma);
+  $cmax2 = 4/(3.14159*$Gamma*$Gamma);
+  $dc2 = $cmax2/10;
+  $T2  = "-T-${cmax2}/${cmax2}/$dc2";
+  $cpt_gaus = "color_g1.cpt";
+  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_gaus\n";
+
+  # gaussian function bounds
+  # BE CAREFUL THAT THE GAUSSIAN IS SCALED PROPERLY
+  $xmin0 = 0; $xmax0 = 480; $zmin0 = 0; $zmax0 = 480;
+  $xceng = ($xmax0-$xmin0)/2;
+  $zceng = ($zmax0-$zmin0)/2;
+  $wfac = 130;   # width of inset box
+  $xmin = $xceng - $wfac/2; $xmax = $xceng + $wfac/2;
+  $zmin = $zceng - $wfac/2; $zmax = $zceng + $wfac/2;
+  $Rgaus = "-R$xmin/$xmax/$zmin/$zmax";
+  $Jwid_gaus = $wfac/($xmax0-$xmin0) * $Jwid;
+  $Jgaus = "-JX${Jwid_gaus}i";
+  #print "\n $Jgaus $Rgaus \n $J $R \n"; die("testing");
+
+  print CSH "gmtset TICK_LENGTH 0\n";
+  print CSH "awk '{print \$3/1000,\$4/1000,\$6}' $file_smooth | pscontour $Rgaus $Jgaus -A- -C$cpt_gaus -I -P -K -O -V  >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$6}' $file_smooth | pscontour $Rgaus $Jgaus -A- -C$cpt_gaus -I -P -K -O -V  >> $psfile\n";
+
+  # plot a scale bar that is sfac times sigma in length
+  $zsig1 = $zceng - $Gamma/1000 / 2;
+  $zsig2 = $zceng + $Gamma/1000 / 2;
+  $xsig  = $xceng - $wfac/2 * 0.7;
+  print CSH "psxy $Jgaus $Rgaus -W1.0p -K -O -V -P >>$psfile<<EOF\n$xsig $zsig1 \n$xsig $zsig2 \nEOF\n";
+
+  print CSH "psbasemap -B $Jgaus $Rgaus -P -K -O -V >> $psfile\n";
+  print CSH "gmtset TICK_LENGTH $tick\n";
+  #------------------------------------------
+
+  $B = "$B0".$Bopts[15]; $title = "(c)  Residual  =  (a) - (b)"; $shift = $shift1;
+
+  # residual function
+  print CSH "psbasemap $B $J $R -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$8 / $norm2}' $file_smooth | pscontour $R $J -A- -C$cpt_ker -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info2 -P -K -O -V >> $psfile\n";
+  #if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #-----------------------------
+
+  # wave2d run number
+  $irun = 400; $strun = sprintf("%4.4i",$irun); $dir = "$odir$strun";
+  $file_smooth = "$dir/fun_smooth.dat";
+  if (not -f $file_smooth) { die("Check if $file_smooth exist or not\n") }
+
+  $Gamma = 15000;
+  #$stsig = sprintf("\@~\163\@~ = %.1f km",$sigma/1000);
+  $stGam = sprintf("\@~\107\@~ = %.1f km",$Gamma/1000);
+  $B = "$B0".$Bopts[15]; $title = "(d)  Smoothed kernel,  $stGam"; $shift = $shift2;
+
+  # smooth function
+  print CSH "psbasemap $B $J $R -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2}' $file_smooth | pscontour $R $J -A- -C$cpt_ker -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info2 -P -K -O -V >> $psfile\n";
+  #if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  
+  #------------------------------------------
+  # make colorpoint file for Gaussian
+  #$cmax2 = 1/(2*3.14159*$sigma*$sigma);
+  $cmax2 = 4/(3.14159*$Gamma*$Gamma);
+  $dc2 = $cmax2/10;
+  $T2  = "-T-${cmax2}/${cmax2}/$dc2";
+  $cpt_gaus = "color_g2.cpt";
+  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1  >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_gaus\n";
+
+  print CSH "gmtset TICK_LENGTH 0\n";
+  print CSH "awk '{print \$3/1000,\$4/1000,\$6}' $file_smooth | pscontour $Rgaus $Jgaus -A- -C$cpt_gaus -I -P -K -O -V  >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$6}' $file_smooth | pscontour $Rgaus $Jgaus -A- -C$cpt_gaus -I -P -K -O -V  >> $psfile\n";
+
+  # plot a scale bar that is sfac times sigma in length
+  $zsig1 = $zceng - $Gamma/1000 / 2;
+  $zsig2 = $zceng + $Gamma/1000 / 2;
+  print CSH "psxy $Jgaus $Rgaus -W1.0p -K -O -V -P >>$psfile<<EOF\n$xsig $zsig1 \n$xsig $zsig2 \nEOF\n";
+
+  print CSH "psbasemap -B $Jgaus $Rgaus -P -K -O -V >> $psfile\n";
+  print CSH "gmtset TICK_LENGTH $tick\n";
+  #------------------------------------------
+
+  $B = "$B0".$Bopts[15]; $title = "(e)  Residual  =  (a) - (d)"; $shift = $shift1;
+
+  # residual function
+  print CSH "psbasemap $B $J $R -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$8 / $norm2}' $file_smooth | pscontour $R $J -A- -C$cpt_ker -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info2 -P -K -O -V >> $psfile\n";
+  #if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  #print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig06 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.45;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # all models are m8
+  $mod = $mods[16]; $smod = "m\@+$mod\@+";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "smooth_vs_scale";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # model for the data
+
+  @runs  = (420,800,780,460,820,900,500,840,920);                       # irun0
+  @ifile = (1,1,1,1,1,1,1,1,1);                                         # boolean: which runs are done
+  @imods = (8,8,8,8,8,8,8,8,7);                                         # which model to plot
+  @gams  = (30000,30000,30000,60000,60000,60000,90000,90000,90000);     # Gamma smoothing
+  @nfacs = (3,2,1,3,2,1,3,2,1);                                         # scalelength of cheker map
+  @labs  = ("a","e","i","b","f","j","c","g","k","d","h","l");
+
+  # phase speed model
+  $k = 0;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "($labs[$k]) Target phase speed model  (n = $nfacs[$k])";
+
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed model
+  $k = $k + 1;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "($labs[$k]) Target phase speed model  (n = $nfacs[$k])";  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed model
+  $k = $k + 1;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "($labs[$k]) Target phase speed model  (n = $nfacs[$k])";  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=========================
+
+  $kmax = 8;
+  for ($k = 0; $k <= $kmax; $k = $k+1) {
+
+    if ($k % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+    # recovered phase speed model
+    $irun0 = $runs[$k]; $Gam = $gams[$k];
+    #$stsig = sprintf("\@~\163\@~ = %.1f km",$sigma/1000);
+    $stGam = sprintf("\@~\107\@~ = %.1f km",$Gam/1000);
+    $strun = sprintf("%4.4i",$irun0+2*$imods[$k]); $dir = "$odir$strun"; $file1syn = "$dir/$mfile_syn";
+    $B = "$B0".$Bopts[15]; $title = "($labs[$k+3]) Recovered  (m\@+$imods[$k]\@+,  $stGam)";
+
+    print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+    if($ifile[$k]==1) {
+       if (not -f $file1syn) { die("Check if $file1syn exist or not\n") }
+       if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+     }
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+if ($ifig07 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.2;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # all models are m8
+  $mod = $mods[16]; $smod = "m\@+$mod\@+";
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_event_kernel_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+  # model for the data
+
+  # base directory
+  #$irun0 = 40;
+  $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun";
+  $B = "$B0".$Bopts[15];
+
+  #-------------------------------------
+  # color scale for EVENT kernels
+  $kpwr = -7;
+  $kmax = 2;
+  $norm_ev = "1e$kpwr";
+  $ss = $kmax;
+  $ds = 2*$ss/$scale_color;
+  $bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+  $Tev = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+  print "Tev = $Tev\n";
+
+  $Bscale_ev  = sprintf("-B%2.2e:\" K ( \@~\161\@~, \@~\146\@~ )  ( 10\@+%2.2i\@+  m\@+-2\@+ s)\": -E7p",$bs2,$kpwr);
+
+  $cpt_ev = "color5.cpt";
+  print CSH "makecpt -C$colorbar $Tev > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_ev\n";
+  #-------------------------------------
+
+# these events follow the ORIGINAL ordering of events
+#@ev_picks = (1,2,3,4,6,11,5);
+ at ev_picks = (1,2,3,4,5,6,7);
+$nevent_plot = @ev_picks;
+ at labs = ("a","b","c","d","e","f","g","h","i");
+
+# loop over events
+for ($k = 0; $k < $nevent_plot; $k = $k+1) {
+
+  # get the event kernel
+  $ev = $k+1;
+  $stev = sprintf("%2.2i",$ev);
+
+  $ev_dir = sprintf("$dir/event_%3.3i",$ev_picks[$k]);
+  $file2 = "$ev_dir/$kerfile";
+  $srcfile = "$ev_dir/sr.txt";
+  if (not -f $file2) { die("Check if $file2 exist or not\n") }
+  if (not -f $srcfile) { die("Check if $srcfile exist or not\n") }
+
+  # number of receivers
+  $file3 = "$dir0/summed_chi_r.dat";
+  if (not -f $file3) { die("Check if $file3 exist or not\n") }
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+  $npath = $nrec * 1;
+  print "\n nrec = $nrec, npath = $npath";
+
+  $title = "($labs[$k])  Event kernel  $stev / $nevent";
+  $mod = $mods[$k*2];
+  if ($k % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+  if($k==0) {print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"}
+  else      {print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm_ev }' $file2 | pscontour $J $R -A- -C$cpt_ev -I -K -O -P -V >> $psfile\n";}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $srcfile |psxy -N $J $R -K -O -P -V $src_ev >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  if($k==$nevent_plot-1) {print CSH "psscale -C$cpt_ev $Dscale $Bscale_ev -K -O -P -V >> $psfile \n"}
+
+}  # for k < nevent
+
+  # summed event kernel
+  
+  # get the summed kernel and chi files
+  $file2 = "$dir/summed_ker.dat";
+  $recfile = "$dir/${edir}/sr.txt";     # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+
+  # number of receivers
+  #open(IN,$file3); @temp = <IN>; $nrec = @temp;
+  $npath = $nrec * $nevent;
+  $title = "($labs[$k])  Misfit kernel ($nevent events)";
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -P -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+
+  # phase speed for data
+  $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $title = "($labs[$k+1])  Target phase speed model (data)"; $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig08 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.45;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # all models are m8
+  $mod = $mods[16]; $smod = "m\@+$mod\@+";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "nevent_maps";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # model for the data
+
+  @runs  = (300,700,200,340,740,240,380,780,280);                       # irun0
+  @ifile = (1,1,1,1,1,1,1,1,1);                                         # boolean: which runs are done
+  @imods = (8,8,8,8,8,8,8,8,8);                                         # which model to plot
+  @gams  = (30000,30000,30000,30000,30000,30000,30000,30000,30000);     # Gamma smoothing
+  @nev   = (5,5,5,15,15,15,25,25,25);                                   # Nevent
+
+  # phase speed model
+  $k = 0;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "Phase speed for data  (n = 3)";
+
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed model
+  $k = $k + 1;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "Phase speed for data  (n = 1)";  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed model
+  $k = $k + 1;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "Phase speed for data  (Rayleigh, T = 20s)";  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel_map -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=========================
+
+  $kmax = 8;
+  for ($k = 0; $k <= $kmax; $k = $k+1) {
+
+    if ($k % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+    if ($k % 3 == 2) {$cpt = $cpt_vel_map} else {$cpt = $cpt_vel}
+
+    # recovered phase speed model
+    $irun0 = $runs[$k]; $Gam = $gams[$k];
+    #$stsig = sprintf("\@~\163\@~ = %.1f km",$sigma/1000);
+    $stGam = sprintf("\@~\107\@~ = %.1f km",$Gam/1000);
+    $strun = sprintf("%4.4i",$irun0+2*$imods[$k]); $dir  = "$odir$strun";
+    $strun0 = sprintf("%4.4i",$irun0);             $dir0 = "$odir$strun0";
+    $file1syn = "$dir/$mfile_syn";
+    $B = "$B0".$Bopts[15];
+    $title = "Recovered  (m\@+$imods[$k]\@+,  Nevents = $nev[$k])";
+
+    print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+    if($ifile[$k]==1) {
+       if (not -f $file1syn) { die("Check if $file1syn exist or not\n") }
+       if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt -I -P -K -O -V  >> $psfile\n"}
+
+       $evefile = "$dir0/events_lonlat.dat";
+       if (not -f $evefile) {die("Check if $evefile exist or not\n")}
+     }
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+if ($ifig08b == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.45;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # all models are m8
+  $mod = $mods[16]; $smod = "m\@+$mod\@+";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "nevent_maps_red";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # model for the data
+
+  @runs  = (700,740,780);         # irun0
+  @ifile = (1,1,1);               # boolean: which runs are done
+  @imods = (8,8,8);               # which model to plot
+  @gams  = (30000,30000,30000);   # Gamma smoothing
+  @nev   = (5,15,25);             # Nevent
+  $numk = @runs;
+
+  #=========================
+
+  $kmax = $numk;
+  for ($k = 0; $k < $kmax; $k = $k+1) {
+
+    # recovered phase speed model
+    $irun0 = $runs[$k]; $Gam = $gams[$k];
+    #$stsig = sprintf("\@~\163\@~ = %.1f km",$sigma/1000);
+    $stGam = sprintf("\@~\107\@~ = %.1f km",$Gam/1000);
+    $strun = sprintf("%4.4i",$irun0+2*$imods[$k]); $dir  = "$odir$strun";
+    $strun0 = sprintf("%4.4i",$irun0);             $dir0 = "$odir$strun0";
+    $file1syn = "$dir/$mfile_syn";
+
+    # get number of sources and receivers
+    $file3 = "$dir/summed_chi_r.dat";
+    if (not -f $file3) {die("Check if $file3 exist or not\n")}
+    open(IN,$file3); @temp = <IN>; $nrec = @temp;
+    $nevent = $nev[$k];
+    $N = $nevent * $nrec;
+
+    print "\m nevent = $nevent, nrec = $nrec, N = $N \n";
+
+    # load misfit associated with model
+    $chifile = "$dir/summed_chi_all.dat";
+    if (not -f $chifile) {die("Check if $chifile exist or not\n")}
+    open(IN,"$chifile");
+    $chi = <IN>;
+    $schi = sprintf("\@~\143\@~ = %2.2e",$chi);
+    #print "\n chi is $chi, misfit function is $schi\n";
+
+    # compute average traveltime anomaly
+    $del = sqrt( 2*$chi / $N );
+    $sdel = sprintf("\@~\104\@~T = %.3f s",$del);
+    #print "\n del is $del, average traveltime anomaly is $sdel seconds\n";
+
+    $B = "$B0".$Bopts[15];
+    $title = "m\@+$imods[$k]\@+,  Nevents = $nevent,  $sdel";
+
+    if($k == 0){ print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"}
+    else       { print CSH "psbasemap $B $R $J -P -K -O -V $shift1 >> $psfile\n"}
+    if($ifile[$k]==1) {
+       if (not -f $file1syn) { die("Check if $file1syn exist or not\n") }
+       if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+
+       $evefile = "$dir0/events_lonlat.dat";
+       if (not -f $evefile) {die("Check if $evefile exist or not\n")}
+     }
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig09 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.45;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # all models are m8
+  $mod = $mods[16]; $smod = "m\@+$mod\@+";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "nevent_kernels";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # model for the data
+
+  @runs  = (300,700,200,340,740,240,380,780,280);                       # irun0
+  @ifile = (1,1,1,1,1,1,1,1,1);                                         # boolean: which runs are done
+  @imods = (0,0,0,0,0,0,0,0,0);                                         # which model to plot
+  @gams  = (30000,30000,30000,30000,30000,30000,30000,30000,30000);     # Gamma smoothing
+  @nev   = (5,5,5,15,15,15,25,25,25);                                   # Nevent
+
+  # phase speed model
+  $k = 0;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "Phase speed for data  (N = 3)";
+
+  print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed model
+  $k = $k + 1;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "Phase speed for data  (N = 1)";  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed model
+  $k = $k + 1;
+  $irun0 = $runs[$k]; $strun = sprintf("%4.4i",$irun0); $dir = "$odir$strun"; $file1dat = "$dir/$mfile_dat";
+  if (not -f $file1dat) { die("Check if $file1dat exist or not\n") }
+  $B = "$B0".$Bopts[15]; $title = "Phase speed for data  (Rayleigh, T = 20s)";  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel_map -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=========================
+
+  $kmax = 8;
+  for ($k = 0; $k <= $kmax; $k = $k+1) {
+
+    if ($k % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+    # recovered phase speed model
+    $irun0 = $runs[$k]; $Gam = $gams[$k];
+    #$stsig = sprintf("\@~\163\@~ = %.1f km",$sigma/1000);
+    $stGam = sprintf("\@~\107\@~ = %.1f km",$Gam/1000);
+    $strun = sprintf("%4.4i",$irun0+2*$imods[$k]); $dir = "$odir$strun"; $file1ker = "$dir/summed_ker.dat";
+    $B = "$B0".$Bopts[15];
+    $title = "$Ktp for m\@+$imods[$k]\@+,  Nevents = $nev[$k]";
+
+    print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+    if($ifile[$k]==1) {
+       if (not -f $file1ker) { die("Check if $file1ker exist or not\n") }
+       if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file1ker | pscontour $J $R -A- -C$cpt_ker -I -K -O -P -V >> $psfile\n"}
+
+       $evefile = "$dir/events_lonlat.dat";
+       if (not -f $evefile) {die("Check if $evefile exist or not\n")}
+     }
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  }
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+#===========================================================================
+if ($ifig10 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.50;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  $origin2 = "-X0.8 -Y7.25";
+  $x_title2 = 0.5;
+  $z_title2 = 1.3;
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # KEY: zoomed-in region
+  $R2 = "-R-119/-116/33/36";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  for ($k= 0; $k <= $niter; $k = $k+1) {
+    $irun = $irun0 + 2*$k;              # wave2d run number
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $file1syn = "$dir/$mfile_syn";
+    $mod_files[$k] = $file1syn;
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+  }
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_cg04zoom_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  $B = "$B0".$Bopts[15];
+
+  #=============================================
+  # recovered phase speed map
+
+  $niter_max = 3;
+  @kvec = (0,1,2,3,$niter);
+  @labs = ("a","b","c","d","e");
+  $numk = @kvec;
+
+  for ($i = 0; $i < $numk; $i = $i+1) {
+
+    $k = $kvec[$i];
+    $mod = $mods[$k*2]; $smod = "m\@+$mod\@+"; 
+    $title = "($labs[$i])  Phase speed model $smod";
+    if ($k== 0) {$title = "($labs[$i])  Initial phase speed model $smod"}
+    if ($k % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+    if ($k==0) {print CSH "psbasemap $B $R2 $J -P -K -V $origin2 > $psfile\n"}
+    else       {print CSH "psbasemap $B $R2 $J -P -K -O -V $shift >> $psfile\n"}
+    if ($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R2 $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+    print CSH "pscoast $J $R2 $coast_info -P -K -O -V >> $psfile\n";
+
+    if ($k==0) {
+      print CSH "psxy $plate_file $J $R2 $plate_info_k -K -V -O >> $psfile \n";
+      print CSH "psxy $fault_file $J $R2 $fault_info_k -K -V -O >> $psfile \n";
+      print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src -G255 >> $psfile\n";
+      print CSH "pstext -N $J $R2 -K -V -O >>$psfile<<EOF
+      -118.3 34.98 7  30 1 LM Garlock
+      -118.5 34.82 7 -25 1 LM San Andreas
+      -118.4 33.12 7  0 1 LM Pacific Ocean
+EOF\n";
+    } else {
+      print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src >> $psfile\n";
+    }
+
+    print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R2 $Wshelf -K -O -P -V >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R2 -K -O -P -V $rec >> $psfile\n";
+    if($i == $numk-1) {print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";}
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title2 $z_title2 $fsize_title 0 $fontno CM $title \nEOF\n";
+
+    print CSH "psbasemap $B $R2 $J -P -K -O -V >> $psfile\n";
+  }
+
+  #=============================================
+  # chi-vs-m curve
+
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $Jywid = $Jwid * 1.2;
+  $J_chi = "-JX${Jwid}i/${Jywid}il";
+  $J_title = "-JX${Jwid}i/${Jywid}i";
+  $title = "(f)  Misfit,  \@~\143\@~ (m\@+k\@+)  ($utype)";
+
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    $irun = $irun0 + 2*$k;
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $chifile = "$dir/summed_chi_all.dat";
+    open(IN,"$chifile"); $chi = <IN>; chomp($chi);
+    $it_vals[$k] = $k; $chi_vals[$k] = $chi;
+  }
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift >> $psfile\n";
+  if($irun0 != 100) {print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";}
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";  # plot point
+  }
+
+  if($irun0 == 100) {
+
+    $irun0 = 20;
+    for ($k = 0; $k <= $niter; $k = $k+1) {
+      $irun = $irun0 + 2*$k;
+      $strun = sprintf("%4.4i",$irun);
+      $dir = "$odir$strun";
+      $chifile = "$dir/summed_chi_all.dat";
+      open(IN,"$chifile"); $chi = <IN>; chomp($chi);
+      print CSH "psxy $J_chi $R_chi $p_info_w -K -O -V -P >>$psfile<<EOF\n $k $chi\nEOF\n";  # plot point
+    }
+
+ # legend
+  $origin_scale = "-Xa0.6 -Ya1.95";            # position of origin (inches)
+  $bxmin = 0; $bymin = 0;                     # location of lower left box corner
+  $bwid = 0.70;                               # width of box
+  $nrow = 2;                                  # KEY: number of rows in legend
+  $dy = 0.07;                                 # spacing for each row
+  $dx1 = 0.05;                                # spacing between left box edge and label
+  $dx2 = 0.05;                                # spacing between label and text
+  $dy1 = $dx1;                                # spacing between bottom box edge and label
+  $bxmax = $bxmin + $bwid;                    # position of right edge
+  $bymax = $bymin + 2*$dy1 + ($nrow-1)*$dy;   # position of top edge
+  $lx = $bxmin + $dx1;                        # x position of label
+  $tx = $lx + $dx2;                           # x position of text
+  $ry1 = $bymin + $dy1;                       # y position of bottom row
+  $ry2 = $bymin + $dy1 + $dy;
+  $ry3 = $bymin + $dy1 + 2*$dy;
+  $ry4 = $bymin + $dy1 + 3*$dy;
+
+  # legend labels (bottom row to top)
+  @legendlabels = ("cubic interpolation","quadratic interpolation");
+
+  print CSH "psxy -W1.0p $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n$bxmin $bymin\n$bxmax $bymin\n$bxmax $bymax\n$bxmin $bymax\n$bxmin $bymin\nEOF\n";
+  print CSH "psxy $p_info_w $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $lx $ry2 \nEOF\n";
+  print CSH "psxy $p_info_k $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $lx $ry1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $tx $ry2 9 0 $fontno LM $legendlabels[1] \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $tx $ry1 9 0 $fontno LM $legendlabels[0] \nEOF\n";
+
+  }
+
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n $x0chit $y1t $fsize1 0 $fontno BL $schi0 \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n $x1chit $y7t $fsize1 0 $fontno BL $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#  #=============================================
+#  # phase speed map for data
+
+#  #$B = "$B0".$Bopts[15];
+#  $title = "(f)  Phase speed for data";
+#  $shift = $shift1;
+
+#  print CSH "psbasemap $B $R2 $J -P -K -O -V $shift >> $psfile\n";
+#  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R2 $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+#  print CSH "pscoast $J $R2 $coast_info -P -K -O -V >> $psfile\n";
+#  print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R2 $Wshelf -K -O -P -V >> $psfile\n";
+#  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R2 -K -O -P -V $rec >> $psfile\n";
+#  print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src >> $psfile\n";
+#  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title2 $z_title2 $fsize_title 0 $fontno CM $title \nEOF\n";
+#  print CSH "psbasemap $B $R2 $J -P -K -O -V >> $psfile\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+
+#===========================================================================
+if ($ifig10b == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.50;
+  $dX1 = $xfac*$Jwid; $dY1 = 0; $shift1 = "-X$dX1 -Y$dY1";
+  $dX1b = (1+($xfac-1)*2)*$Jwid; $dY1b = 0; $shift1b = "-X$dX1b -Y$dY1b";
+  $dX2 = -2*$dX1; $dY2 = -$yfac*$Jwid; $shift2 = "-X$dX2 -Y$dY2";
+
+  $origin2 = "-X0.8 -Y7.25";
+  $x_title2 = 0.5;
+  $z_title2 = 1.3;
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # KEY: zoomed-in region
+  $R2 = "-R-119/-116/33/36";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize1 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $k = $niter;
+  $irun = $irun0 + 2*$k;
+  $strun = sprintf("%4.4i",$irun);
+  $dir = "$odir$strun";
+  $file1syn = "$dir/$mfile_syn";
+  $mod_file = $file1syn;
+  if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_zoom_gji";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  $B = "$B0".$Bopts[15];
+
+  #=============================================
+  # phase speed map for data
+
+  $B = "$B0".$Bopts[15];
+  $title = "(a)  Target model (data)";
+
+  print CSH "psbasemap $B $R2 $J -P -K -V $origin2 > $psfile\n";  # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R2 $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R2 $coast_info -P -K -O -V >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R2 -K -O -P -V $rec >> $psfile\n";
+  if(0 == 1) {
+     print CSH "psxy $plate_file $J $R2 $plate_info_k -K -V -O >> $psfile \n";
+     print CSH "psxy $fault_file $J $R2 $fault_info_k -K -V -O >> $psfile \n";
+     print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src -G255 >> $psfile\n";
+     print CSH "pstext -N $J $R2 -K -V -O >>$psfile<<EOF
+     -118.3 34.98 7  30 1 LM Garlock
+     -118.5 34.82 7 -25 1 LM San Andreas
+     -118.4 33.12 7  0 1 LM Pacific Ocean
+EOF\n";
+  } else {
+     print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src >> $psfile\n";
+  }
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title2 $z_title2 $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "psbasemap $B $R2 $J -P -K -O -V >> $psfile\n";
+
+  #=============================================
+  # phase speed map from rays
+
+  # both have the same damping value
+  $dir_hess = "/home/carltape/wave2d/2d_adjoint_banana/mat_SAVE/recovered_model_vector";
+  $stgam = sprintf("\@~\147\@~ = %.2f", 10.0);
+
+  $ray_file = "${dir_hess}/run_0020/lcurve50/m_IMODEL_3_rayleigh_id03_plot";
+  if (not -f $ray_file)   { die("Check if $ray_file exist or not\n") }
+  $title = "(b)  Model from rays, $stgam";
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R2 $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {print CSH "awk '{print \$1,\$2,\$3*100}' $ray_file | pscontour $R2 $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R2 $coast_info -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R2 -K -O -P -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title2 $z_title2 $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "psbasemap $B $R2 $J -P -K -O -V >> $psfile\n";
+
+  #=============================================
+  # phase speed map from kernels
+
+  $ker_file = "${dir_hess}/run_0020/lcurve05/m_IMODEL_3_rayleigh_id03_plot";
+  if (not -f $ker_file)   { die("Check if $ker_file exist or not\n") }
+ 
+  $title = "(c)  Model from kernels, $stgam";
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R2 $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {print CSH "awk '{print \$1,\$2,\$3*100}' $ker_file | pscontour $R2 $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R2 $coast_info -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R2 -K -O -P -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title2 $z_title2 $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "psbasemap $B $R2 $J -P -K -O -V >> $psfile\n";
+
+  #=============================================
+  # phase speed map from adjoint-CG
+
+  $mod = $mods[$k*2]; $smod = "m\@+$mod\@+";
+  $title = "(d)  Model from adjoint, $smod";
+  $shift = $shift2;
+
+  print CSH "psbasemap $B $R2 $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $mod_file | pscontour $R2 $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R2 $coast_info -P -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R2 -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R2 -K -O -P -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF\n-115.2 30.6 11 0 $fontno LM \@~\045\@~\nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title2 $z_title2 $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "psbasemap $B $R2 $J -P -K -O -V >> $psfile\n";
+
+  #=============================================
+  # chi-vs-m curve
+
+  $shift = $shift1b;
+
+  $Bg = "-Ba2f1:\" k, model number \":/a1f2p:\"  Misfit,  \@~\143\@~ (m\@+k\@+)  (s\@+2\@+)  \":".$Bopts[8];
+
+  $Jxwid = $Jwid * 2.0;
+  $Jywid = $Jwid * 1.2;
+  $J_chi = "-JX${Jxwid}i/${Jywid}il";
+  $J_title = "-JX${Jxwid}i/${Jywid}i";
+  $title = "(e)  Misfit comparison: classical vs adjoint";
+
+  # load ray chi
+  $dir_ray = "/home/store2/carltape/OUTPUT_banana/run_0023";
+  $chifile = "${dir_ray}/summed_chi_all.dat";
+  open(IN,"$chifile"); $chi_ray = <IN>; chomp($chi_ray);
+  print "\n chi_ray = ${chi_ray} \n";
+
+  # load kernel chi
+  $dir_ker = "/home/store2/carltape/OUTPUT_banana/run_0022";
+  $chifile = "${dir_ker}/summed_chi_all.dat";
+  open(IN,"$chifile"); $chi_ker = <IN>; chomp($chi_ker);
+  print "\n chi_ker = ${chi_ker} \n";
+
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    $irun = $irun0 + 2*$k;
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $chifile = "$dir/summed_chi_all.dat";
+    open(IN,"$chifile"); $chi = <IN>; chomp($chi);
+    $it_vals[$k] = $k; $chi_vals[$k] = $chi;
+  }
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift >> $psfile\n";
+
+  # rays and kernels
+  print CSH "psxy  -W1tap   $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n$a2x1 $chi_ker\n$a2x2 $chi_ker\nEOF\n";
+  print CSH "psxy  -W1p     $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n$a2x1 $chi_ray\n$a2x2 $chi_ray\nEOF\n";
+
+  # text labels
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n 0.02 0.40 10 0 $fontno LM (b) Hessian - Ray \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n 0.02 0.29 10 0 $fontno LM (c) Hessian - Kernel \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n 0.86 0.08 10 0 $fontno LM (d)  $smod  \nEOF\n";
+
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";  # plot point
+  }
+  #print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n $x0chit $y1t $fsize1 0 $fontno BL $schi0 \nEOF\n";
+  #print CSH "pstext -N $J_chi $R_chi -K -O -V -P >>$psfile<<EOF\n $x1chit $y7t $fsize1 0 $fontno BL $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+
+
+
+#===========================================================================
+if ($ifig20 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX0 = $xfac*$Jwid; $dY0 = -$yfac*$Jwid;
+  $dX1 = $dX0;         $dY1 = 0;     $shift1  = "-X$dX1  -Y$dY1";
+  $dX2 = -2*$dX1;      $dY2 = $dY0;  $shift2  = "-X$dX2  -Y$dY2";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.08*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # KEY COMMAND
+  $ilcurve = 50;   # 50-51 (rays), 5 (kernels)
+  $stil = sprintf("%2.2i",$ilcurve);
+
+  $recover_dir = "/home/carltape/wave2d/2d_adjoint_banana/mat_SAVE/recovered_model_vector/run_${strun0}/lcurve${stil}";
+  $model_lab   = "IMODEL_2_Nfac${sNfac}";
+  if($istructure==4) {$model_lab = "IMODEL_3_rayleigh"}
+
+  # find in ALL plotting files
+  @mod_files = glob("${recover_dir}/*_plot");
+  $nplot = @mod_files;
+  print "\n $nplot plotting files";
+  print "\n first file : ${mod_files[0]} \n";
+
+  # load in ALL the damping values
+  open(IN,"${recover_dir}/lamvec"); @lams = <IN>;
+  $ndamp = @lams;
+  print "\n $ndamp damping values for the recovered models \n";
+
+  # for the ray-based inversions, the no-damping case does not exist
+  $nbad = $ndamp - $nplot;
+  print "\n $nbad files that we do not use \n";
+  #die("testing");
+
+  #------------------
+  # load specs for L-curve plots
+
+  # axes limits
+  $axes_file = "${recover_dir}/lcurve_axis";
+  if (not -f ${axes_file}) { die("Check if ${axes_file} exist or not\n") }
+  open(IN,"$axes_file"); @ax0 = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax0[0]);
+
+  $normgx = 1;
+  $normgy = 1;
+  $xming = $a1x1/$normgx;
+  $xmaxg = $a1x2/$normgx;
+  $yming = $a1y1/$normgy;
+  $ymaxg = $a1y2/$normgy;
+  $R_Lcurve  = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_Lcurve  = "-JX$Jwid";
+
+  $dx = $xmaxg - $xming;
+  $dy = $ymaxg - $yming;
+  $xtick = 0.25*$dx;
+  $ytick = 0.25*$dy;
+  #$B_Lcurve  = sprintf("-B%.2f:\" log10 ( Misfit Norm ) \":/%.2f:\" log10 ( Model Norm )\":",$xtick,$ytick);
+  $B_Lcurve  = sprintf("-B%.2f:\" log10 ( Model Norm ) \":/%.2f:\" log10 ( Misfit Norm )\":",$xtick,$ytick);
+
+  # polynomial lines and curves
+  $Lcurve_file = "${recover_dir}/lcurve_pts";
+  if (not -f ${Lcurve_file}) { die("Check if ${Lcurve_file} exist or not\n") }
+  open(IN,"${Lcurve_file}"); @Lcurve_pts = <IN>;
+
+  #------------------
+
+  #for ($k = 1; $k <= $ndamp; $k = $k+1) {
+  #  $stid = sprintf("%2.2i",$k);
+  #  $file1syn = "${recover_dir}m_${model_lab}_id${stid}_plot";
+  #  $mod_files[$k-1] = $file1syn;
+  #  if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+  #}
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  # hess refers to the fact that we have used the Hessian (GtG) in the computations,
+  # following the classical tomography approach
+  $name    = "${smap}_hess01_${strun0}_ilcurve${stil}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  $B = "$B0".$Bopts[15];
+
+  #=============================================
+  # recovered phase speed map
+
+  # pick a subset of the possible figures
+  print "\n pick a subset of the models to plot \n";
+  @kvec = (0,2,4,6,8,10);
+  #@kvec = (0,4,8,12,16,20);
+  #@kvec = (0,1,2,4,6,$nplot-1);
+  #@kvec = (0,1,2,3,4,5);
+  $numk = @kvec;
+
+  for ($i = 0; $i < $numk; $i = $i+1) {
+
+    $k = $kvec[$i];
+    $stgam = sprintf("\@~\147\@~ = %.2f",$lams[$k+$nbad]);
+    $title = "Model for $stgam";
+    if ($i % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+    if (not -f $mod_files[$k]) { die("Check if $mod_files[$k] exist or not\n") }
+
+    if ($k==0) {
+       print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+    } else {
+       print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+    }
+    # note 3rd column, not 4th
+    if ($icolor==1) {print CSH "awk '{print \$1,\$2,\$3*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R -K -O -P -V $rec >> $psfile\n";
+    #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+    print CSH "psbasemap $B $R $J -P -K -O -V >> $psfile\n";
+  }
+
+  #=============================================
+  # Lcurve
+
+  $B = "$B_Lcurve".$Bopts[8];  # 15 for no axes
+  $title = "L-curve for the models";
+
+  $col = $numk % 3;
+  if($col == 1) {$shift3 = "-X$dX1 -Y$dY2"}
+  if($col == 2) {$shift3 = "-Y$dY2"}
+  if($col == 0) {$shift3 = "-X-$dX1 -Y$dY2"}
+  $shift = $shift3;
+
+  print CSH "psbasemap $B $R_Lcurve $J_Lcurve -P -K -O -V $shift >> $psfile\n";
+  print CSH "psxy $Lcurve_file $R_Lcurve $J_Lcurve $p_info_k -P -K -O -V >> $psfile\n";
+  print CSH "psxy $Lcurve_file $R_Lcurve $J_Lcurve -W0.75p/0/0/255 -P -K -O -V >> $psfile\n";
+
+  # print a couple labels
+  #@kvec2 = (0,1,4);
+  @kvec2 = @kvec;
+  $numk2 = @kvec2;
+  for ($i = 0; $i < $numk2; $i = $i+1) {
+    $k = $kvec2[$i];
+    #$stgam = sprintf("\@~\147\@~ = %.2f",$lams[$k]);
+    $stgam = sprintf("%.2f",$lams[$k]);
+    ($xpt,$ypt) = split(" ",$Lcurve_pts[$k]);
+    $xpt = $xpt + 0.03*$dx;
+    $ypt = $ypt + 0.03*$dy;
+    print CSH "pstext -N $J_Lcurve $R_Lcurve -K -O -V -P >>$psfile<<EOF\n $xpt $ypt $fsize_title 0 $fontno LM $stgam \nEOF\n";
+  }
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # phase speed map for data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Target phase speed model (data)";
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "psbasemap $B $R $J -P -K -O -V >> $psfile\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#=================================================================
+if ($ifig20b == 1) {
+
+  # shifting the subplots
+  $xfac = 1.35;
+  $yfac = 1.25;
+  $dX0 = $xfac*$Jwid; $dY0 = -$yfac*$Jwid;
+  $dX = $dX0;         $dY = 0;     $shift1  = "-X$dX  -Y$dY";
+  $dX = -2*$dX;       $dY = $dY0;  $shift2  = "-X$dX  -Y$dY";
+  $dXb = -1.5*$dX0;   $dY = $dY0;  $shift2b = "-X$dXb -Y$dY";
+  $origin = "-X0.5 -Y8";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.05*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $ilcurve = 11;
+  $stil = sprintf("%2.2i",$ilcurve);
+
+  $recover_dir = "/home/carltape/wave2d/2d_adjoint_banana/mat_SAVE/recovered_model_vector/run_${strun0}/lcurve${stil}";
+  $model_lab   = "IMODEL_2_Nfac${sNfac}";
+  if($istructure==4) {$model_lab = "IMODEL_3_rayleigh"}
+
+  # load in ALL the damping values
+  open(IN,"${recover_dir}/lamvec");
+  @lams = <IN>;
+  $ndamp = @lams;
+  print "\n $ndamp damping values for the recovered models \n";
+
+  #------------------
+  # L-curve plots
+
+  # axes limits
+  $axes_file = "${recover_dir}/lcurve_axis";
+  if (not -f $axes_file)   { die("Check if $axes_file exist or not\n") }
+  open(IN,"$axes_file");
+  @ax0 = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax0[0]);
+
+  $normgx = 1;
+  $normgy = 1;
+  $xming = $a1x1/$normgx;
+  $xmaxg = $a1x2/$normgx;
+  $yming = $a1y1/$normgy;
+  $ymaxg = $a1y2/$normgy;
+  $R_Lcurve  = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_Lcurve  = "-JX$Jwid";
+
+  $dx = $xmaxg - $xming;
+  $dy = $ymaxg - $yming;
+  $xtick = 0.25*$dx;
+  $ytick = 0.25*$dy;
+
+  $B_Lcurve  = sprintf("-B%.2f:\" log10 ( Model Norm ) \":/%.2f:\" log10 ( Misfit Norm )\":",$xtick,$ytick);
+  #$B_Lcurve  = sprintf("-B%.2f:\" log10 ( Misfit Norm ) \":/%.2f:\" log10 ( Model Norm )\":",$xtick,$ytick);
+
+  # polynomial lines and curves
+  $Lcurve_file = "${recover_dir}/lcurve_pts";
+  if (not -f $Lcurve_file)   { die("Check if $Lcurve_file exist or not\n") }
+  open(IN,"$Lcurve_file");
+     @Lcurve_pts = <IN>;
+
+  #------------------
+
+  for ($k = 1; $k <= $ndamp; $k = $k+1) {
+    $stid = sprintf("%2.2i",$k);
+    $file1syn = "${recover_dir}/m_${model_lab}_id${stid}_plot";
+    $mod_files[$k-1] = $file1syn;
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+  }
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";  # src-rec for first event
+  $evefile = "$dir0/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "${smap}_hess01_${strun0}_ilcurve${stil}_paper";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  $B = "$B0".$Bopts[15];
+
+  #=============================================
+  # recovered phase speed map
+
+  #@kvec = (0,1,2,3,4,5,5);  # pick a subset of the possible figures
+  @kvec = (0,8,12,14,16,20,20);
+  $numk = @kvec;
+  @labs = ("a","b","c","d","e","f","g","h","i","j");
+
+  for ($i = 0; $i < $numk; $i = $i+1) {
+
+    $k = $kvec[$i];
+    $stgam = sprintf("\@~\147\@~ = %.2f",$lams[$k]);
+    $title = "($labs[$i])  Model for $stgam";
+    if ($i % 3 == 0) {$shift = $shift2} else {$shift = $shift1}
+
+    if ($k==0) {
+       print CSH "psbasemap $B $R $J -P -K -V $origin > $psfile\n"; # START
+    } else {
+       print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+    }
+    # note 3rd column, not 4th
+    if ($icolor==1) {print CSH "awk '{print \$1,\$2,\$3*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n"}
+
+    if ($icolor==1 && $i==$numk-1)
+    {print CSH "awk '{print \$1,\$2,\$3*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel_uniform -I -P -O -K -V >> $psfile\n"}
+
+    print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+    if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+    print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R -K -O -P -V $src >> $psfile\n";
+    print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R -K -O -P -V $rec >> $psfile\n";
+
+    print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+    print CSH "psbasemap $B $R $J -P -K -O -V >> $psfile\n";
+
+    # colorbar for exaggerted 'gradient' map
+    if($i == $numk-1) {
+      $bs1 = 0.4;
+      $Bscaleg = sprintf("-B%2.2ef1:\" \": -E7p",$bs1);
+      print CSH "psscale -C$cpt_vel_uniform $Dscale $Bscaleg -P -K -O -V >> $psfile \n";
+      print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF\n-115.2 30.95 11 0 $fontno LM \@~\045\@~\nEOF\n";
+    }
+  }
+
+  #=============================================
+  # Lcurve
+
+  $B = "$B_Lcurve".$Bopts[8];  # 15 for no axes
+  $title = "($labs[$i])  L-curve for the models";
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R_Lcurve $J_Lcurve -P -K -O -V $shift >> $psfile\n";
+  print CSH "psxy $Lcurve_file $R_Lcurve $J_Lcurve -W0.75p/0/0/255 -P -K -O -V >> $psfile\n";
+  print CSH "psxy $Lcurve_file $R_Lcurve $J_Lcurve $p_info_w -P -K -O -V >> $psfile\n";
+
+  # print a couple labels
+  #@kvec = (0,1,2,3,4,5);   # from lowest to highest damping values
+  #$numk = @kvec;
+
+  @xshifts = (-0.035,-0.035,-0.06,-0.11,-0.11,0.04);
+  @yshifts = (-0.06,-0.06,-0.05,0.02,0.02,0.04);
+  @stgams  = ("(a)","(b)","(c)","(d)","(e)",sprintf("\@~\147\@~ = %.2f  (f, g)",$lams[$kvec[$numk-1]]));
+
+  for ($j = 0; $j < $numk; $j = $j+1) {
+    $k = $kvec[$j];
+
+    # plot gamma = xx next to the point
+    #if($j==5) {$stgam = sprintf("\@~\147\@~ = %.2f",$lams[$k])}
+    #else {$stgam = sprintf("%.2f",$lams[$k])}
+    $stgam = $stgams[$j];
+
+    ($xpt0,$ypt0) = split(" ",$Lcurve_pts[$k]);
+    $xpt = $xpt0 + $xshifts[$j]*$dx;
+    $ypt = $ypt0 + $yshifts[$j]*$dy;
+    print CSH "pstext -N $J_Lcurve $R_Lcurve -K -O -V -P >>$psfile<<EOF\n $xpt $ypt $fsize_title 0 $fontno LM $stgam \nEOF\n";
+    #print CSH "psxy -N $J_Lcurve $R_Lcurve $p_info_w -K -O -V -P >>$psfile<<EOF\n $xpt0 $ypt0\nEOF\n";
+  }
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # phase speed for data
+
+  $B = "$B0".$Bopts[15];
+  $title = "($labs[$i+1])  Target phase speed model (data)";
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -P -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF\n-115.2 30.95 11 0 $fontno LM \@~\045\@~\nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "psbasemap $B $R $J -P -K -O -V >> $psfile\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  print CSH "echo done with $psfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_3wid.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,152 @@
+#!/usr/bin/perl -w
+#==========================================================
+#
+#  plot_gji_paper.pl
+#  Carl Tape
+#  10-Jan-2006
+#
+#  Figure 1: plot of misfit vs iteration (irun0 = 100, 20)
+#
+#==========================================================
+
+$cshfile = "plot_gji_paper.csh";
+
+# boolean commands for plotting
+$ixv    = 1;
+$ieps   = 0;
+
+# plotting specifications
+$fsize0 = "24";
+$fsize1 = "18";
+$fsize2 = "16";
+$fsize3 = "12";
+$fontno = "4";    # 1 or 4
+$tick   = "0.2c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+
+#=================================================================
+# files and parameters related to polynomial plots and misfit-vs-iteration plots
+
+  $pmark      = "-Sc10p";
+  $p_info_k   = "-N $pmark -W1.0p -G0";
+  $p_info_w   = "-N $pmark -W1.0p -G255";
+  $p_info_r   = "-N $pmark -W1.0p -G255/0/0";
+  $p_info_b   = "-N $pmark -W1.0p -G0/0/255";
+  $p_info_g   = "-N $pmark -W1.0p -G0/0/255";
+
+  $c_info_ks  = "-W1.0p";
+  $c_info_ks2 = "-W2.0p";
+  $c_info_rd  = "-W1.0/255/0/0tap";
+  $c_info_bd  = "-W1.0/0/0/255tap";
+  $c_info_kd  = "-W0.5/0/0/0tap";
+
+  # input files to read
+  $chi_curve = "chi_cubic_quad.dat";
+  $axes_file = "chi_cubic_quad_axes.dat";
+  if (not -f $axes_file)   { die("Check if $axes_file exist or not\n") }
+  if (not -f $chi_curve)   { die("Check if $chi_curve exist or not\n") }
+
+  # get bounds
+  open(IN,"$axes_file"); @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]);
+
+  # chi-vs-iteration
+  $xming = $a1x1;
+  $xmaxg = $a1x2;
+  $yming = $a1y1;
+  $ymaxg = $a1y2;
+  $R_chi = "-R$xming/$xmaxg/$yming/$ymaxg";
+
+  # scale for chi-vs-m plots
+  $B3a    = "-B2:\" model number (iteration) \":/a1f2p:\" \@~\143\@~ ( m )   ( $utype ) \":";
+  $B3b    = "-B2:\" model number (iteration) \":/a1f2p:\" \":";
+  $B4     = "-B2:\" model number (iteration) \":/20:\" \":";
+
+#===========================================================================
+#===========================================================================
+
+  $origin = "-X1.25 -Y3";                   # origin
+  $Jwid = 6;                               # width of plot
+  $J_chi = "-JX${Jwid}i/${Jwid}il";        # note log scale on y-axis
+
+  # plot title
+  $J_title = "-JX${Jwid}";
+  $R_title = "-R0/1/0/1";
+  $x_title = 0.5;
+  $z_title = 1.08;
+  $z_title = 10;
+  $fsize_title = $fsize1;
+
+  # file names
+  $name = "plot_gji_paper_01";
+  $psfile = "${name}.ps"; $jpgfile = "${name}.jpg"; $epsfile = "${name}.eps";
+  $title = " test";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize1 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # misfit vs iteration
+  $shift = $shift1;
+  $Bg = "-Ba2f1:\" k, model number \":/a1f2p:\"  Misfit,  \@~\143\@~ (m\@+k\@+)  (s\@+2\@+)  \":".$Bopts[8];
+  $title = " Recovered models for classical tomography and CG methods";
+
+  $lab1 = "\@~\143\@~ (m\@+0\@+)";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -K -V -P $origin > $psfile\n";  # START
+  print CSH "awk '{print \$1,\$4}' $chi_curve | psxy -W1p $J_chi $R_chi -K -O -V -P >> $psfile\n";      # ray line
+  print CSH "awk '{print \$1,\$5}' $chi_curve | psxy -W1tap $J_chi $R_chi -K -O -V -P >> $psfile\n";    # kernel line
+  print CSH "awk '{print \$1,\$3}' $chi_curve | psxy $p_info_w $J_chi $R_chi -K -O -V -P >> $psfile\n"; # cubic points
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $p_info_r $J_chi $R_chi -K -O -V -P >> $psfile\n"; # quad points
+
+  # text labels
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n 0.08 0.38 14 0 $fontno LM Hessian - Ray \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n 0.08 0.31 14 0 $fontno LM Hessian - Kernel \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n 0.08 0.82 14 0 $fontno LM $lab1 \nEOF\n";
+
+  #----------------------------------------------------------------------------
+  # legend
+  $origin_scale = "-Xa2.8 -Ya4.8";            # position of origin (inches)
+  $bxmin = 0; $bymin = 0;                     # location of lower left box corner
+  $bwid = 0.47;                               # width of box
+  $nrow = 2;                                  # KEY: number of rows in legend
+  $dy = 0.05;                                 # spacing for each row
+  $dx1 = 0.04;                                # spacing between left box edge and label
+  $dx2 = 0.03;                                # spacing between label and text
+  $dy1 = $dx1;                                # spacing between bottom box edge and label
+  $bxmax = $bxmin + $bwid;                    # position of right edge
+  $bymax = $bymin + 2*$dy1 + ($nrow-1)*$dy;   # position of top edge
+  $lx = $bxmin + $dx1;                        # x position of label
+  $tx = $lx + $dx2;                           # x position of text
+  $ry1 = $bymin + $dy1;                       # y position of bottom row
+  $ry2 = $bymin + $dy1 + $dy;
+  $ry3 = $bymin + $dy1 + 2*$dy;
+  $ry4 = $bymin + $dy1 + 3*$dy;
+
+  # legend labels (bottom row to top)
+  @legendlabels = ("using a cubic polynomial","using a quadratic polynomial");
+
+  print CSH "psxy -W1.0p $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n$bxmin $bymin\n$bxmax $bymin\n$bxmax $bymax\n$bxmin $bymax\n$bxmin $bymin\nEOF\n";
+  print CSH "psxy $p_info_r $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $lx $ry2 \nEOF\n";
+  print CSH "psxy $p_info_w $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $lx $ry1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $tx $ry2 14 0 $fontno LM $legendlabels[1] \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P $origin_scale >>$psfile<<EOF\n $tx $ry1 14 0 $fontno LM $legendlabels[0] \nEOF\n";
+  #----------------------------------------------------------------------------
+
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";  # FINISH
+
+  print CSH "convert $psfile $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper_source.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper_source.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper_source.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,712 @@
+#!/usr/bin/perl -w
+
+#==========================================================
+#
+#  plot_gji_paper_source.pl
+#  Carl Tape
+#  27-Feb-2006
+#
+#  copied from plot_gji_3wid.pl on 27-Feb-2006
+#
+#  ISTRUCTURE:
+#    1. checker, Nfac=3
+#    2. checker, Nfac=2
+#    3. checker, Nfac=1
+#    4. rayleigh wave (T=20s, smoothed with sig=10km)
+#
+#    plot_gji_paper_source.pl 25 60000 -6/3.0/0/80/8 1 2500 0 1 1 2 0 16
+#    plot_gji_paper_source.pl 25 60000 -6/3.0/0/80/8 1 2550 0 1 1 2 0 16
+#    plot_gji_paper_source.pl 25 60000 -6/3.0/0/80/8 1 2600 0 1 1 2 0 14
+#    plot_gji_paper_source.pl 25 60000 -6/3.0/0/80/8 1 2650 0 1 1 2 0 3
+#
+#==========================================================
+
+if (@ARGV < 8) {die("Usage: plot_kernels.pl nevent gamma colors iker irun0 iter ichecker ipoly istructure ibanana qmax \n");}
+($nevent,$gamma,$colors,$iker,$irun0,$iter,$ichecker,$ipoly,$istructure,$ibanana,$qmax) = @ARGV;
+
+if($ibanana==1) {$odir      = "../../../2d_adjoint_banana/OUTPUT_banana/run_"}
+else            {$odir      = "../../OUTPUT/run_"}
+
+$edir      = "event_001";  # event for first event (sr.txt)
+
+$mfile_dat = "socal_vel_dat.dat";
+$mfile_syn = "socal_vel_syn.dat";
+$kerfile   = "kernel_basis";
+
+$cshfile = "plot_gji_paper_source.csh";
+
+if($istructure==1){$Nfac=3}
+if($istructure==2){$Nfac=2}
+if($istructure==3){$Nfac=1}
+$sNfac = sprintf("%1i",$Nfac);
+
+# boolean commands for plotting
+$icolor = 1;   # ccc
+
+$ifig01 = 0;   # chi(mk), recovered model, source error
+$ifig02 = 1;
+
+$irun = $irun0 + $iter;
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t","9","9t","10","10t","11","11t","12","12t","13","13t","14","14t","15","15t","16","16t");
+$mod = $mods[$iter];
+$smod = "m\@+$mod\@+";
+
+# label for the type of map used to generate the data
+$smap = sprintf("m%2.2i",$istructure);
+
+# wave2d run number
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "$odir$strun0";
+$dir = "$odir$strun";
+
+$stgam  = sprintf("\@~\147\@~ = %.1f km",$gamma/1000);
+$stgam2 = sprintf("%3.3i",$gamma/1000);
+
+print "\n $dir, $edir, $mfile_dat, $mfile_syn, $kerfile";
+print "\n $colors, $iker, $mod, $stgam2 \n";
+#die("testing");
+
+# colors for the kernel and misfit function
+ at cols = split("/",$colors);
+$kpwr = $cols[0];  # power for kernels
+$kmax = $cols[1];  # value for kernels
+$opwr = $cols[2];  # power for misfit maps
+$omax = $cols[3];  # value for misfit maps
+$cmax = $cols[4];  # value for phase velocity maps (percent pert)
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+ at units = ("m\@+2\@+ s","s\@+2\@+","xxx","xxx","xxx","xxx","xxx");
+$ktype = $titles[$iker];
+$utype = $units[$iker];
+
+$plabel = "/home/carltape/sem2d/2d_adjoint/scripts/plot_ker_mod.pl";
+
+# data files
+$dir_gmt = "/home/carltape/gmt";
+$ishelf = 0;
+$shelf_file = "../../INPUT/oms_shelf";
+$plate_file = "${dir_gmt}/plate_boundaries";
+$fault_file = "${dir_gmt}/faults/jennings.xy";
+
+# plotting specifications
+$fsize0 = "14";
+$fsize1 = "11";
+$fsize2 = "8";
+$fsize3 = "5";
+$fontno = "4";    # 1 or 4
+$tick   = "0.1c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# plot symbols for sources, receivers, and shelf
+$ref_rad = 6;
+$src    = "-W0.5p -Sa${ref_rad}p";
+$rec    = "-Sc2p -G0";
+$rec0   = "-Sc10p -W0.5p";
+$src_ev = "-W0.5p -Sa12p -G255";
+$Wshelf = "-W0.5/0/0/0tap";
+
+$coast_info = "-W1p -Na/1p -Df";
+$coast_info2 = "-W0.5p -Na/0.5p -Df";
+
+$plate_info_w = "-M -W2.5p/255/255/255";
+$plate_info_r = "-M -W2.5p/255/0/0";
+$plate_info_b = "-M -W2.5p/0/0/255";
+$plate_info_k = "-M -W2.5p";
+
+$fault_info_r = "-M -W1.5p/255/0/0";
+$fault_info_k = "-M -W1.5p/0/0/0";
+$fault_info_w = "-M -W1.5p/255/255/255";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 21.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%3.3e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+#-------------------------
+# color for chi (objective function)
+
+$norm3 = "1e$opwr";
+$ss = $omax;
+$ds = $ss/$scale_color;
+$bs3 = sprintf("%3.3e",0.9*$ss/3); # colorbar
+$T3 = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+print "T3 = $T3\n";
+
+#-------------------------
+# get reference phase velocity and period
+
+$c0 = 3500; $per = 20;
+
+open(IN,"$dir0/socal_vel_c0.dat");
+ at vals = <IN>;
+$c0       = $vals[0];
+$per      = $vals[1];
+$lam      = $c0*$per;
+$per_lab  = sprintf("T = %.1f s",$per);
+$c0_lab   =  sprintf("c0 = %.2f km/s",$c0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $c0_lab, $lam_lab \n";
+
+#-------------------------
+
+# write plotting scripts
+$Jwid = 2;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.8 -Y8.25";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+$B0 = "-B1:.\" \":";
+
+# axes scale for phase velocity maps: c(th, ph)
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Velocity for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Velocity for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$bs1 = 3;
+$Bscale1  = sprintf("-B%2.2ef1:\" \@~\045\@~ pert. from %2.2f km/s\": -E5p",$bs1,$c0/1000);
+$Bscale1b = sprintf("-B%2.2ef1:\" \": -E5p",$bs1);
+
+# axes scale for kernels: K(th, ph)
+# [\@~\143\@~] --> s
+$tp = "\@~\146\@~, \@~\161\@~";
+$Bscale2  = sprintf("-B%2.2e:\" K ( $tp )  ( 10\@+%2.2i\@+  m\@+-2\@+ s )\": -E5p",$bs2,$kpwr);
+$Bscale2b = sprintf("-B%2.2e:\" \": -E5p",$bs2);
+
+# axes scale for chi_plots: chi(th_r, ph_r)
+$Bscale3  = sprintf("-B%2.2e:\" \@~\143\@~ ( \@~\161\@~\@-r\@- , \@~\146\@~\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef5p",$bs3,$opwr);
+
+#-------------------------
+# phase velocity model
+$file1dat = "$dir/$mfile_dat";
+$file1syn = "$dir/$mfile_syn";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$J_title = "-JX${Jwid}";
+$R_title = "-R0/1/0/1";
+$x_title = 0.5;
+$z_title = 1.08;
+$fsize_title = 9;
+
+#=================================================================
+# files and parameters related to polynomial plots and misfit-vs-iteration plots
+
+  $p_info_k   = "-N -Sc6p -W0.5p -G0";
+  $p_info_w   = "-N -Sc6p -W0.5p -G255";
+  $c_info_ks  = "-W0.5p";
+  $c_info_ks2 = "-W1.5p";
+  $c_info_rd  = "-W1.0/255/0/0tap";
+  $c_info_bd  = "-W1.0/0/0/255tap";
+  $c_info_kd  = "-W0.5/0/0/0tap";
+
+if ($ipoly==1) {
+
+  # axes limits for polynomial plots
+  $axes_file = "axes_${strun0}.dat";
+  if (not -f $axes_file)   { die("Check if $axes_file exist or not\n") }
+  open(IN,"$axes_file");
+  @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]);  # polynomial
+  ($a2x1,$a2x2,$a2y1,$a2y2) = split(" ",$ax_lims[1]);  # chi vs iteration
+  ($a3x1,$a3x2,$a3y1,$a3y2) = split(" ",$ax_lims[2]);  # var-red vs iteration
+
+  # chi-vs-iteration
+  $xming = $a2x1; $xmaxg = $a2x2; $yming = $a2y1; $ymaxg = $a2y2;
+  $chi_ran = $xmaxg - $xming;
+  $R_chi = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_chi = "-JX${Jwid}i/${Jwid}il";        # note log scale on y-axis
+
+  # text labels for chi-vs-m plots
+  $schi0 = "\@~\143\@~ ( m\@+0\@+ )";
+  $schi1 = "\@~\143\@~ ( m\@+1\@+ )";
+  $x0chit = 0 + 0.05*$chi_ran;
+  $x1chit = 1 + 0.05*$chi_ran;
+
+  $chi_curve = "chi_curve_${strun0}.dat";
+  if (not -f $chi_curve)   { die("Check if $chi_curve exist or not\n") }
+
+  # scale for chi-vs-m plots
+  $iter_tick = 2;
+  $B3a    = "-B${iter_tick}:\" k, model number \":/a1f2g1p:\" \@~\143\@~ ( m )   ( $utype ) \":";
+  $B3b    = "-B${iter_tick}:\" k, model number \":/a1f2g1p:\" \":";
+}
+
+#===========================================================================
+# create colorpoint files
+
+  open(CSH,">$cshfile");
+
+  $cpt_vel_map = "../../model_files/socal_color.cpt";
+
+  # phase velocity model
+  if($ichecker==0) {$cpt_vel = $cpt_vel_map}
+  else {
+     # make colorpoint file
+     #$T1 = "-T3/4/0.1";
+     $dc = $cmax/10;
+     $T1 = "-T-$cmax/$cmax/$dc";
+     $cpt_vel = "color0.cpt";
+     print CSH "makecpt -C$colorbar $T1 > temp1\n";
+     print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+     print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel\n";
+  }
+
+#  # kernel
+#  $cpt_ker = "color1.cpt";
+#  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+#  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+#  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_ker\n";
+
+#  # misfit (as a function of receiver)
+#  $cpt_chi = "color2.cpt";
+#  print CSH "makecpt -Chot $T3 -I > $cpt_chi\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  #die("testing");
+
+#===========================================================================
+if ($ifig01 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX2 = -2*$dX; $dY2 = -$yfac*$Jwid; $shift2 = "-X$dX2 -Y$dY2";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # iteration index (subset of all possible)
+  @kvec = (0,$qmax);
+  $numk = @kvec;
+  $niter_max = $kvec[$numk-1];  # max iteration is the last in the list
+
+  # load all possible files
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+    $irun = $irun0 + 2*$k;              # wave2d run number
+
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $file1syn = "$dir/$mfile_syn";
+    $file1ker = "$dir/summed_ker.dat";
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+    #if (not -f $file1ker)   { die("Check if $file1ker exist or not\n") }
+    $ker_files[$k] = $file1ker;
+    $mod_files[$k] = $file1syn;
+
+    # load chi values
+    $chifile = "$dir/summed_chi_all.dat";
+    open(IN,"$chifile");
+    $chi = <IN>; chomp($chi);
+    $it_vals[$k] = $k;
+    $chi_vals[$k] = $chi;
+    #$schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  }
+  #print "\n @it_vals \n @chi_vals \n\n"; die("testing");
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";          # src-rec for first event
+  $evefile = "$dir0/events_lonlat_dat.dat";   # sources for DATA
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  # file names for figures
+  $name    = "plot_gji_paper_source_${strun0}";
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  #=============================================
+  # misfit vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $title = "(a)  Misfit,  \@~\143\@~ (m\@+k\@+)  (s\@+2\@+)";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -P -K -V $origin > $psfile\n"; # START
+
+  if($irun0 != 2500) {
+    # plot curve for basic structure inversion
+    print "\n plotting reference chi curve...\n";
+    $chi_curve_ref = "chi_curve_2500.dat";
+    if (not -f $chi_curve_ref)   { die("Check if $chi_curve_ref exist or not\n") }
+    print CSH "awk '{print \$1,\$2}' $chi_curve_ref | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  }
+
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";  # plot point
+  }
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # recovered models for synthetics
+
+  $k = $qmax;
+  $mod = $mods[2*$k]; $smod = "m\@+${mod}\@+"; $title = "(b)  Structure model ${smod}";
+  $shift = $shift1;
+  $B = "$B0".$Bopts[1];
+
+  # phase velocity map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {
+    print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # error in source parameters
+
+  $shift = $shift1;
+  $B = "$B0".$Bopts[1];
+  $title = "(c)  Error in source parameters";
+
+  # KEY COMMAND -- formula to scale from magnitude to dot size
+  # THIS MUST BE REPEATED FOR THE KEY BELOW!
+  $fac = 3;
+  $source_error_file = "gji_source_error_run_${strun0}.dat";
+  $dots_file = "temp";
+  if (not -f $source_error_file) { die("Check if $source_error_file exist or not\n") }
+  print CSH "awk '{print \$1,\$2,\$6,${ref_rad} + \$5*$fac}' $source_error_file > $dots_file\n";
+
+  # make colorpoint file (-Z for continuous; -I to invert)
+  $cmax = 1;
+  $dc = $cmax/40;
+  $T2 = "-T-$cmax/$cmax/$dc";
+  $cptfile = "color_src.cpt";
+  print CSH "makecpt -Cpolar $T2 -I > temp1\n";
+  print CSH "sed 's/^B.*/B       255     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile\n";
+
+  #---------------
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+
+  #print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src -G255 >> $psfile\n";
+
+  # plot source errors as colored and sized stars
+  $dot_info = "-W0.5p -Sap";
+  print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V -P >> $psfile \n";
+
+  # depth scale
+  $Dscale_dep = "-D0.25/-0.2/0.8/0.10h";;
+  $Bscale_dep = "-B1f0.25:\"Origin time error (s)\": -E5p";
+  print CSH "psscale -C$cptfile $Dscale_dep $Bscale_dep -K -O -V -P >> $psfile\n";
+
+  # convert source errors to dot size
+  @mag_dots = (0,2,4);
+  $ndot = @mag_dots;
+  $xlon0 = -117; $dlon = 1.0;
+  for ($k = 0; $k < $ndot; $k = $k+1) {
+    $mag = $mag_dots[$k];
+    $mag_size[$k] = $ref_rad + $mag*$fac;   # KEY: use same formula as above
+    $xlon[$k] = $xlon0 + $k*$dlon;
+  }
+
+  # source error scale -- symbols
+  $origin_box = "-Xa0 -Ya0";
+  $yp1 = $zmin - 1.6;
+  $yp2 = $yp1 + 0.3;
+  $yp3 = $yp2 + 0.5;
+  print CSH "psxy $J $R $dot_info -N -K -V -O -P $origin_box >> $psfile <<EOF
+  $xlon[2] $yp3 $mag_size[2]
+  $xlon[1] $yp3 $mag_size[1]
+  $xlon[0] $yp3 $mag_size[0]
+EOF\n";
+
+  # source error scale -- text
+  print CSH "pstext $J $R -N -K -V -O -P $origin_box >> $psfile <<EOF
+  $xlon[2] $yp2 $fsize2 0 $fontno CM 4
+  $xlon[1] $yp2 $fsize2 0 $fontno CM 2
+  $xlon[0] $yp2 $fsize2 0 $fontno CM 0
+  $xlon[1] $yp1 $fsize2 0 $fontno CM Source mislocation (km)
+EOF\n";
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+#===========================================================================
+
+if ($ifig02 == 1) {
+
+  $ipick = 2;
+
+  # file name for figure
+  $name    = sprintf("plot_gji_paper_source_f%2.2i",$ipick);
+  $psfile  = "$name.ps";
+  $jpgfile = "$name.jpg";
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.40;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX2 = -2*$dX; $dY2 = -$yfac*$Jwid; $shift2 = "-X$dX2 -Y$dY2";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  for ($ii = 0; $ii <= 1; $ii = $ii+1) {
+
+    if($ipick == 1) {
+
+      if($ii == 0) {$irun0 = 2500; $qmax = 16; @labs = ("a","b","c"); @tags = (" ","(zero)");}
+      else         {$irun0 = 2550; $qmax = 16; @labs = ("d","e","f"); @tags = (" "," "); }
+    } else {
+      @tags = ("zero"," ");
+      if($ii == 0) {$irun0 = 2600; $qmax = 14; @labs = ("a","b","c"); @tags = (" ","(fixed)");}
+      else         {$irun0 = 2650; $qmax = 3; @labs = ("d","e","f");  @tags = ("(fixed)"," "); }
+    }
+    
+    $irun = $irun0 + $iter;
+    $strun0 = sprintf("%4.4i",$irun0);
+    $strun = sprintf("%4.4i",$irun);
+    $dir0 = "$odir$strun0";
+    $dir = "$odir$strun";
+
+    print "\n irun0 = $irun0, irun = $irun \n";
+    #die("testing");
+
+    $chi_curve = "chi_curve_${strun0}.dat";
+    if (not -f $chi_curve)   { die("Check if $chi_curve exist or not\n") }
+
+  # iteration index (subset of all possible)
+  @kvec = (0,$qmax);
+  $numk = @kvec;
+  $niter_max = $kvec[$numk-1];  # max iteration is the last in the list
+
+  # load all possible files
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+
+    $irun = $irun0 + 2*$k;              # wave2d run number
+
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "$odir$strun";
+    $file1syn = "$dir/$mfile_syn";
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+    $mod_files[$k] = $file1syn;
+
+    # load chi values
+    $chifile = "$dir/summed_chi_all.dat";
+    open(IN,"$chifile");
+    $chi = <IN>; chomp($chi);
+    $it_vals[$k] = $k;
+    $chi_vals[$k] = $chi;
+    #$schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  }
+
+  # get the receivers and sources
+  $recfile = "$dir0/${edir}/sr.txt";          # src-rec for first event
+  $evefile = "$dir0/events_lonlat_dat.dat";   # sources for DATA
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  #=============================================
+  # misfit vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $title = "($labs[0])  Misfit,  \@~\143\@~ (m\@+k\@+)  (s\@+2\@+)";
+
+  if($ii == 0) {
+    print CSH "psbasemap $Bg $R_chi $J_chi -P -K -V $origin > $psfile\n"; # START
+  } else {
+    print CSH "psbasemap $Bg $R_chi $J_chi -P -K -O -V $shift2 >> $psfile\n";
+  }
+
+  if($irun0 != 2500) {
+    # plot curve for basic structure inversion
+    print "\n plotting reference chi curve...\n";
+    $chi_curve_ref = "chi_curve_2500.dat";
+    if (not -f $chi_curve_ref)   { die("Check if $chi_curve_ref exist or not\n") }
+    print CSH "awk '{print \$1,\$2}' $chi_curve_ref | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  }
+
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -P -V >> $psfile\n";
+  for ($k = 0; $k <= $niter_max; $k = $k+1) {
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V -P >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";  # plot point
+  }
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # recovered models for synthetics
+
+  $k = $qmax;
+  $mod = $mods[2*$k]; $smod = "m\@+${mod}\@+"; $title = "($labs[1])  Structure model ${smod}  $tags[0]";
+  $shift = $shift1;
+  if($ii == 0) {$B = "$B0".$Bopts[8]} else {$B = "$B0".$Bopts[1]}
+
+  # phase velocity map
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+  if ($icolor==1) {
+    print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -P -O -K -V >> $psfile\n";
+  }
+  print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  if($ii == 1) {print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -P -K -O -V >> $psfile \n";}
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # error in source parameters
+
+  $shift = $shift1;
+  if($ii == 0) {$B = "$B0".$Bopts[8]} else {$B = "$B0".$Bopts[1]}
+  $title = "($labs[2])  Error in source parameters  $tags[1]";
+
+  # KEY COMMAND -- formula to scale from magnitude to dot size
+  # THIS MUST BE REPEATED FOR THE KEY BELOW!
+  $fac = 3;
+  $source_error_file = "gji_source_error_run_${strun0}.dat";
+  $dots_file = "temp";
+  if (not -f $source_error_file) { die("Check if $source_error_file exist or not\n") }
+  print CSH "awk '{print \$1,\$2,\$6,${ref_rad} + \$5*$fac}' $source_error_file > $dots_file\n";
+
+  # make colorpoint file (-Z for continuous; -I to invert)
+  $cmax = 1;
+  $dc = $cmax/40;
+  $T2 = "-T-$cmax/$cmax/$dc";
+  $cptfile = "color_src.cpt";
+  print CSH "makecpt -Cpolar $T2 -I > temp1\n";
+  print CSH "sed 's/^B.*/B       255     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cptfile\n";
+
+  #---------------
+
+  print CSH "psbasemap $B $R $J -P -K -O -V $shift >> $psfile\n";
+
+  #print CSH "pscoast $J $R $coast_info -P -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src -G255 >> $psfile\n";
+
+  # plot source errors as colored and sized stars
+  $dot_info = "-W0.5p -Sap";
+  print CSH "psxy $dots_file $J $R $dot_info -C$cptfile -K -O -V -P >> $psfile \n";
+
+  if($ii == 1) {
+
+  # depth scale
+  $Dscale_dep = "-D0.25/-0.2/0.8/0.10h";;
+  $Bscale_dep = "-B1f0.25:\"Origin time error (s)\": -E5p";
+  print CSH "psscale -C$cptfile $Dscale_dep $Bscale_dep -K -O -V -P >> $psfile\n";
+
+  # convert source errors to dot size
+  @mag_dots = (0,2,4);
+  $ndot = @mag_dots;
+  $xlon0 = -117; $dlon = 1.0;
+  for ($k = 0; $k < $ndot; $k = $k+1) {
+    $mag = $mag_dots[$k];
+    $mag_size[$k] = $ref_rad + $mag*$fac;   # KEY: use same formula as above
+    $xlon[$k] = $xlon0 + $k*$dlon;
+  }
+
+  # source error scale -- symbols
+  $origin_box = "-Xa0 -Ya0";
+  $yp1 = $zmin - 1.6;
+  $yp2 = $yp1 + 0.3;
+  $yp3 = $yp2 + 0.5;
+  print CSH "psxy $J $R $dot_info -N -K -V -O -P $origin_box >> $psfile <<EOF
+  $xlon[2] $yp3 $mag_size[2]
+  $xlon[1] $yp3 $mag_size[1]
+  $xlon[0] $yp3 $mag_size[0]
+EOF\n";
+
+  # source error scale -- text
+  print CSH "pstext $J $R -N -K -V -O -P $origin_box >> $psfile <<EOF
+  $xlon[2] $yp2 $fsize2 0 $fontno CM 4
+  $xlon[1] $yp2 $fsize2 0 $fontno CM 2
+  $xlon[0] $yp2 $fsize2 0 $fontno CM 0
+  $xlon[1] $yp1 $fsize2 0 $fontno CM Source mislocation (km)
+EOF\n";
+
+  }
+
+  if($ii == 1 && $ipick == 1) {
+    # plot a symbol next to a particular event (GJI figure)
+    print "\n dir is $dir0 \n";
+    $evefile = "$dir0/events_lonlat_dat.dat";
+    if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+    open(IN,"$evefile"); @events = <IN>;
+    $ievent = 25;
+    ($elon,$elat,$num) = split(" ",$events[$ievent-1]);
+    print "\n $elon $elat $num \n";
+
+    $xtxt = $elon-0.05; 
+    $ytxt = $elat+0.3; 
+    print CSH "pstext -N $J $R -K -O -V -P >>$psfile<<EOF\n $xtxt $ytxt 10 0 1 CM S \nEOF\n";
+    #print CSH "psxy -N $J $R -K -O -V -P $src -G0/255/0 >>$psfile<<EOF\n $xtxt $ytxt\nEOF\n";
+  }
+
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+} # for ii
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_paper_source.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_talk.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_talk.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_talk.pl	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,2615 @@
+#!/usr/bin/perl -w
+#==========================================================
+#
+#  plot_gji_talk.pl
+#  Carl Tape
+#  01-March-2006
+#
+#  ISTRUCTURE:
+#    1. checker, Nfac=3
+#    2. checker, Nfac=2
+#    3. checker, Nfac=1
+#    4. rayleigh wave (T=20s, smoothed with sig=10km)
+#
+#    plot_gji_talk.pl 25 60000 -6/3.0/0/80/8 1 460 0 1 1 1 0   # big checker
+#    plot_gji_talk.pl 25 30000 -6/3.0/0/20/8 0 280 0 0 1 4 0   # rayleigh
+#
+#    plot_gji_talk.pl 25 60000 -9/4.0/0/80/8 1 460 0 1 1 1 0   # ifig03 (princeton kernels)
+#    plot_gji_talk.pl 25 60000 -9/4.0/0/80/8 1 460 0 1 1 1 0   # ifig03p (kernel, ray)
+#
+#    plot_gji_talk.pl  1 30000 -7/1.0/0/80/8 1 000 0 1 0 1 0   # ifig04,05 irun_000 (132 recs)
+#    plot_gji_talk.pl  1 30000 -8/4.0/0/80/8 1 001 0 1 0 1 0   # ifig04,05 irun_001 (single src-rec)
+#    plot_gji_talk.pl  1 30000 -7/0.5/0/80/8 5 002 0 1 0 1 0   # ifig05 irun_002 (single src-rec) -- no data
+#
+#    plot_gji_talk.pl   # ifig05p (seismograms)
+#    plot_gji_talk.pl   # ifig06 (hessian)
+#
+#    plot_gji_talk.pl 25 30000 -6/3.0/0/20/8 0 280 0 0 1 4 0   # ifig07 (hessian and gradient for kernels)
+#
+#
+#==========================================================
+
+#if (@ARGV < 7) {die("Usage: plot_kernels.pl out_dir_pre event_dir_pre modelfile_dat modelfile_syn kernelfile kpwr/kmax/oprw/omax IKER irun0 iter model \n");}
+#($odir,$edir,$mfile_dat,$mfile_syn,$kerfile,$colors,$iker,$irun0,$iter,$ichecker) = @ARGV;
+($nevent,$gamma,$colors,$iker,$irun0,$iter,$ichecker,$ipoly,$istructure,$ibanana) = @ARGV;
+
+if($ibanana==1) {$odir      = "../../../2d_adjoint_banana/OUTPUT_banana/run_"}
+else            {$odir      = "../../OUTPUT/run_"}
+$edir      = "event_";
+$mfile_dat = "socal_vel_dat.dat";
+$mfile_syn = "socal_vel_syn.dat";
+$kerfile   = "kernel_basis";
+
+$cshfile = "plot_gji_talk.csh";
+
+if($istructure==1){$Nfac=3}
+if($istructure==2){$Nfac=2}
+if($istructure==3){$Nfac=1}
+$sNfac = sprintf("%1i",$Nfac);
+
+# boolean commands for plotting
+$icolor = 1;   # ccc
+$ixv    = 1;
+$ieps   = 0;
+
+$ifig01  = 0;   # CG sequence 1
+$ifig02  = 0;   # CG sequence 2
+$ifig03  = 0;   # banana-doughnut kernels
+$ifig03p = 0;   # banana-doughnut kernels
+$ifig04  = 0;   # mod, mod, ker
+$ifig04p = 0;   # 
+$ifig05  = 0;   # 4x1 forward wavefield
+$ifig05p = 0;   # seismograms
+
+$ifig06  = 0;   # Hessian
+$ifig07  = 1;   # Hessian and gradient
+
+$ifig10  = 0;   # 3 x 3 CG summary
+
+$irun = $irun0 + $iter;
+ at mods = ("0","0t","1","1t","2","2t","3","3t","4","4t","5","5t","6","6t","7","7t","8","8t");
+$mod = $mods[$iter];
+$smod = "m\@+$mod\@+";
+
+# label for the type of map used to generate the data
+$smap = sprintf("m%2.2i",$istructure);
+
+# wave2d run number
+$strun0 = sprintf("%4.4i",$irun0);
+$strun = sprintf("%4.4i",$irun);
+$dir0 = "${odir}$strun0";
+$dir = "${odir}$strun";
+
+#print "\n $nevent,$gamma,$colors,$iker,$irun0,$iter,$ichecker,$ipoly,$istructure,$ibanana -- $dir0, $dir\n"; die("testing");
+
+$stgam  = sprintf("\@~\147\@~ = %.1f km",$gamma/1000);
+$stgam2 = sprintf("%3.3i",$gamma/1000);
+
+print "\n $dir, $edir, $mfile_dat, $mfile_syn, $kerfile";
+print "\n $colors, $iker, $mod, $stgam2 \n";
+#die("testing");
+
+# colors for the kernel and misfit function
+ at cols = split("/",$colors);
+$kpwr = $cols[0];  # power for kernels
+$kmax = $cols[1];  # value for kernels
+$opwr = $cols[2];  # power for misfit maps
+$omax = $cols[3];  # value for misfit maps
+$cmax = $cols[4];  # value for phase speed maps (percent pert)
+
+#@files = glob("$dir/$kerfile");
+#$numk = @files;
+
+ at titles = ("Waveform","Traveltime (xcorr), misfit","Amplitude (xcorr), misfit","Traveltime (MT), misfit","Amplitude (MT), misfit","Traveltime (xcorr), sampling","Amplitude (xcorr), sampling");
+ at units = ("m\@+2\@+ s","s\@+2\@+","xxx","xxx","xxx","xxx","xxx");
+$ktype = $titles[$iker];
+$utype = $units[$iker];
+
+$plabel = "/home/carltape/sem2d/2d_adjoint/scripts/plot_ker_mod.pl";
+
+# data files
+$ishelf = 0;
+$shelf_file = "../../INPUT/oms_shelf";
+
+# plotting specifications
+$fsize0 = "18";
+$fsize1 = "14";
+$fsize2 = "12";
+$fsize3 = "8";
+$fontno = "4";    # 1 (helvetica) or 4 (roman)
+$tick   = "0.15c";
+$fpen   = "1.5p";
+$tpen   = "1.0p";
+
+# plot symbols for sources, receivers, and shelf
+$src          = "-Sa12p -W1p";
+$src_r        = "-Sa12p -W1p/255/0/0 ";
+$src_b        = "-Sa12p -W1p/0/0/255 ";
+$rec          = "-Sc5p -W0.5p/0/0/0";
+$rec_r        = "-Sc5p -W0.5p/255/0/0";
+$rec_w        = "-Sc5p -W0.5p/255";
+
+$src_fr       = "$src -G255/0/0";
+$src_fw       = "$src -G255";
+$src_fk       = "$src -G0";
+
+$rec_fr       = "$rec -G255/0/0";
+$rec_fw       = "$rec -G255";
+$rec_fk       = "$rec -G0";
+
+$src1   = $src;
+$rec1   = "-St12p -W1p";
+
+$Wshelf = "-W0.5/0/0/0tap";
+$coast_info = "-W1p -Na/1p -Df";
+$coast_info2 = "-W0.5p -Na/0.5p -Df";
+
+#-------------------------
+# color for kernels
+
+# KEY: scaling for color
+$scale_color = 41.0;
+$colorbar = "seis";
+#open(IN,"$dir/$cfile");
+#@colors = <IN>;
+
+$norm2 = "1e$kpwr";
+$ss = $kmax;
+$kmin = -$kmax;
+$kran = $kmax-$kmin;
+$ds = $kran / ${scale_color};
+#$ds = 2*$ss/$scale_color;
+$bs2 = sprintf("%2.2e",0.9*$ss); # colorbar
+$T2 = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+print "T2 = $T2\n";
+
+#-------------------------
+# color for chi (objective function)
+
+$norm3 = "1e$opwr";
+$ss = $omax;
+$ds = $ss/$scale_color;
+$bs3 = sprintf("%3.3e",0.9*$ss/3); # colorbar
+$T3 = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+print "T3 = $T3\n";
+
+#-------------------------
+# get reference phase speed and period
+
+$c0 = 3500; $per = 20;
+
+open(IN,"${dir0}/socal_vel_c0.dat");
+ at vals = <IN>;
+$c0       = $vals[0];
+$per      = $vals[1];
+$lam      = $c0*$per;
+$per_lab  = sprintf("T = %.1f s",$per);
+$c0_lab   =  sprintf("c0 = %.2f km/s",$c0/1000);
+$lam_lab  = sprintf("\@~\154\@~ = %.0f km",$lam/1000);
+print "\n$per_lab, $c0_lab, $lam_lab \n";
+
+#-------------------------
+
+# write plotting scripts
+$Jwid = 3;
+$J = "-JM${Jwid}i";      # in lat-lon
+$origin = "-X0.5 -Y4";
+
+# which borders to plot the lat-lon
+# 1 four sides, 4 single sides, 6 two sides, 4 three sides, 1 zero sides
+ at Bopts = ("WESN","Wesn","wesN","wEsn","weSn","WesN","wEsN","wESn","WeSn","WEsn","weSN","wESN","WESn","WeSN","WEsN","wesn");
+$B0 = "-B1:.\" \":";
+
+# axes scale for phase speed maps: c(th, ph)
+
+#$bs1 = 0.5;
+#$Bscale1d  = sprintf("-B%2.2e:\" Phase Speed for data ( km s\@+-1\@+ )\":",$bs1);
+#$Bscale1s  = sprintf("-B%2.2e:\" Phase Speed for model $smod ( km s\@+-1\@+ )\":",$bs1);
+$bs1 = 3;
+$Bscale1  = sprintf("-B%2.2ef1:\" \@~\045\@~ pert. from %2.2f km/s\": -E10p",$bs1,$c0/1000);
+$Bscale1b = sprintf("-B%2.2ef1:\" \": -E10p",$bs1);
+
+$Bscale_spl  = "-B0.5:\" B ( \@~\161\@~, \@~\146\@~ )\":";
+
+# axes scale for kernels: K(th, ph)
+$tp = "\@~\146\@~, \@~\161\@~";
+$Bscale2  = sprintf("-B${bs2}:\" K ( $tp )  ( 10\@+%2.2i\@+  m\@+-2\@+ [\@~\143\@~] )\": -E10p",$kpwr);
+$Bscale2b = sprintf("-B${bs2}:\" K ( $tp )  ( 10\@+%2.2i\@+  m\@+-2\@+ s )\": -E10p",$kpwr);
+$Bscale2c = "-B${bs2}:\" \": -E10p";
+
+# axes scale for chi_plots: chi(th_r, ph_r)
+$Bscale3  = sprintf("-B%2.2e:\" \@~\143\@~ ( \@~\146\@~\@-r\@- , \@~\161\@~\@-r\@- )  ( 10\@+%2.2i\@+ )\": -Ef10p",$bs3,$opwr);
+
+#-------------------------
+# phase speed model
+$file1dat = "${dir}/$mfile_dat";
+$file1syn = "${dir}/$mfile_syn";
+
+# set bounds for the plotting
+#$xmin = -121; $xmax = -115.0; $zmin = 31.75; $zmax = 36.5;
+($xmin,$xmax,$zmin,$zmax) = split(" ",`minmax -C $file1dat`);
+$dinc = 0.25;  # buffer around min/max
+$xmin = $xmin-$dinc;  $xmax = $xmax+$dinc;
+$zmin = $zmin-$dinc;  $zmax = $zmax+$dinc;
+$R = "-R$xmin/$xmax/$zmin/$zmax";
+
+# plot title
+$J_title = "-JX${Jwid}";
+$R_title = "-R0/1/0/1";
+$x_title = 0.5;
+$z_title = 1.08;
+$fsize_title = $fsize1;
+
+#=================================================================
+# files and parameters related to polynomial plots and misfit-vs-iteration plots
+
+  $p_info_k   = "-N -Sc10p -W1.0p -G0";
+  $p_info_w   = "-N -Sc10p -W1.0p -G255";
+  $p_info_r   = "-N -Sc10p -W1.0p -G255/0/0";
+  $c_info_ks  = "-W1.0p";
+  $c_info_ks2 = "-W2.0p";
+  $c_info_rd  = "-W1.0/255/0/0tap";
+  $c_info_bd  = "-W1.0/0/0/255tap";
+  $c_info_kd  = "-W0.5/0/0/0tap";
+
+if ($ipoly==1) {
+
+  # axes limits for polynomial plots
+  $axes_file = "axes_${strun0}.dat";
+  if (not -f $axes_file)   { die("Check if $axes_file exist or not\n") }
+  open(IN,"$axes_file");
+  @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]);  # polynomial
+  ($a2x1,$a2x2,$a2y1,$a2y2) = split(" ",$ax_lims[1]);  # chi vs iteration
+  ($a3x1,$a3x2,$a3y1,$a3y2) = split(" ",$ax_lims[2]);  # var-red vs iteration
+
+  # scale the axes
+  #$lpwr_x = 3; $xtick = 4;
+  #$lpwr_y = 2; $ytick = 2;
+  $lpwr_x = int( log($a1x2) / log(10) ); $xtick = 1;
+  $lpwr_y = int( log($a1y2) / log(10) ); $ytick = 1;
+  $normgx = "1e$lpwr_x";
+  $normgy = "1e$lpwr_y";
+
+  #die("testing");
+
+  $xming = $a1x1/$normgx;
+  $xmaxg = $a1x2/$normgx;
+  $yming = $a1y1/$normgy;
+  $ymaxg = $a1y2/$normgy;
+  $R_poly = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_poly_wid = 0.7*$Jwid;
+  $J_poly = "-JX${J_poly_wid}/${Jwid}";
+
+  # polynomial lines and curves
+  $poly_curve = "poly_curve_${strun0}.dat";
+  $poly_pts   = "poly_points_${strun0}.dat";
+  if (not -f $poly_curve) { die("Check if $poly_curve exist or not\n") }
+  if (not -f $poly_pts)   { die("Check if $poly_pts exist or not\n") }
+  open(IN,"$poly_pts");
+  @poly_pts = <IN>;
+  ($x1t,$y1t) = split(" ",$poly_pts[0]); $x1 = $x1t/$normgx; $y1 = $y1t/$normgy;
+  ($x2t,$y2t) = split(" ",$poly_pts[1]); $x2 = $x2t/$normgx; $y2 = $y2t/$normgy;
+  ($x3t,$y3t) = split(" ",$poly_pts[2]); $x3 = $x3t/$normgx; $y3 = $y3t/$normgy;
+  ($x4t,$y4t) = split(" ",$poly_pts[3]); $x4 = $x4t/$normgx; $y4 = $y4t/$normgy;
+  ($x5t,$y5t) = split(" ",$poly_pts[4]); $x5 = $x5t/$normgx; $y5 = $y5t/$normgy;
+  ($x6t,$y6t) = split(" ",$poly_pts[5]); $x6 = $x6t/$normgx; $y6 = $y6t/$normgy;
+  ($x7t,$y7t) = split(" ",$poly_pts[6]); $x7 = $x7t/$normgx; $y7 = $y7t/$normgy;
+
+  # chi-vs-iteration
+  $xming = $a2x1;
+  $xmaxg = $a2x2;
+  $yming = $a2y1;
+  $ymaxg = $a2y2;
+  $R_chi = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_chi = "-JX${Jwid}i/${Jwid}il";        # note log scale on y-axis
+
+  $schi0 = "\@~\143\@~ ( m\@+0\@+ )";
+  $schi1 = "\@~\143\@~ ( m\@+1\@+ )";
+
+  $chi_curve = "chi_curve_${strun0}.dat";
+  if (not -f $chi_curve)   { die("Check if $chi_curve exist or not\n") }
+
+  # var.red-vs-iteration
+  $xming = $a3x1;
+  $xmaxg = $a3x2;
+  $yming = $a3y1;
+  $ymaxg = $a3y2;
+  $R_var = "-R$xming/$xmaxg/$yming/$ymaxg";
+  $J_var = "-JX$Jwid";
+
+  $var_pts = "var_${strun0}.dat";
+  $var_fit = "var_fit_${strun0}.dat";
+  if (not -f $var_fit)   { die("Check if $var_fit exist or not\n") }
+  if (not -f $var_pts)   { die("Check if $var_pts exist or not\n") }
+
+  # scale for polynomial plots (chi0, chi1)
+  $B1 = sprintf("-B${xtick}:\"\@~\154\@~   ( 10\@+%2.2i\@+ ) \":/${ytick}:\" \@~\143\@~\@+0\@+ [ m (\@~\154\@~) ]   ( 10\@+%2.2i\@+  $utype ) \":",$lpwr_x,$lpwr_y);
+  $B2 = sprintf("-B${xtick}:\"\@~\154\@~   ( 10\@+%2.2i\@+ ) \":/${ytick}:\" \@~\143\@~\@+1\@+ [ m (\@~\154\@~) ]   ( 10\@+%2.2i\@+  $utype ) \":",$lpwr_x,$lpwr_y);
+
+  # scale for chi-vs-m plots
+  $B3a    = "-B1:\" model number (iteration) \":/a1f2p:\" \@~\143\@~ ( m )   ( $utype ) \":";
+  $B3b    = "-B1:\" model number (iteration) \":/a1f2p:\" \":";
+  $B4     = "-B1:\" model number (iteration) \":/20:\" \":";
+
+}
+
+#===========================================================================
+# create colorpoint files
+
+  open(CSH,">$cshfile");
+
+  $cpt_vel_map = "../../model_files/socal_color.cpt";
+
+  # phase speed model
+  if($ichecker==0) {$cpt_vel = $cpt_vel_map}
+  else {
+     # make colorpoint file
+     #$T1 = "-T3/4/0.1";
+     $cmin = -$cmax;
+     $cran = $cmax - $cmin;
+     $dc = $cran/${scale_color};
+     $T1 = "-T$cmin/$cmax/$dc";
+     $cpt_vel = "color0.cpt";
+     print CSH "makecpt -C$colorbar $T1 > temp1\n";
+     print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+     print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_vel\n";
+  }
+
+  # kernel
+  $cpt_ker = "color1.cpt";
+  print CSH "makecpt -C$colorbar $T2 > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_ker\n";
+
+  # spline
+  $cpt_spl = "color5.cpt";
+  $cmin = -1; $cmax = 1;
+  $cran = $cmax - $cmin; 
+  $dc = $cran/${scale_color};
+  $T_spline = "-T$cmin/$cmax/$dc";
+  print CSH "makecpt -C$colorbar $T_spline > $cpt_spl \n";
+
+  $cpt_spl2 = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/Gik_examples/color_spline.cpt";
+
+  # misfit (as a function of receiver)
+  $cpt_chi = "color2.cpt";
+  print CSH "makecpt -Chot $T3 -I > $cpt_chi\n";
+
+  close (CSH); system("csh -f $cshfile");
+  #die("testing");
+
+  # colorbar
+  $Dlen = 0.75*${Jwid}; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.20h";
+
+#===========================================================================
+if ($ifig01 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.25;
+  $yfac = 1.6;
+  $dX = 1.15*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = 1.25*$Jwid; $dY = 0; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2  HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen \n";
+  #===============================================
+
+  # get the summed kernel and chi files
+  #$file2 = "${dir}/summed_ker.dat";
+  $file2 = "${dir}/fun_smooth.dat";       # smoothed kernel
+  $file3 = "${dir}/summed_chi_r.dat";
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $evefile = "${dir0}/events_lonlat.dat";
+  $chifile = "${dir}/summed_chi_all.dat";
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_1"; $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  # number of receivers
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+  # $npath = $nrec * $nevent;
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift1 >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # blank template
+  $shift = $shift2;
+  $title = "CG line search";
+  $Bg = "$B1".$Bopts[8];
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  #print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  #print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_2"; $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schia = "\@~\143\@~ ( $smod )";
+  $schi = sprintf("${schia}  =  %3.3e",$chi);
+  $title = "Summed misfit : $schi";
+  $B = "$B0".$Bopts[15];
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R -A- -C$cpt_chi -I -K -O -V >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_chi $Dscale $Bscale3 -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $title = "Plot  $schia";
+  $Bg = "$B1".$Bopts[8];
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_3"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel
+
+  $shift = $shift1;
+  $title = "Gradient for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  g\@+0\@+ = d\@~\143\@~ / dm($smod)";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_4"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 1);
+  $dir = "${odir}$strun";
+
+  $mod = $mods[1];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "${dir}/$mfile_syn";
+  $file2 = "${dir}/fun_smooth.dat";       # smoothed kernel
+  #$file2 = "$dir/summed_ker.dat";
+  $file3 = "${dir}/summed_chi_r.dat";
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $chifile = "${dir}/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Estimate test model m\@+0t\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_5"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schia = "\@~\143\@~ ( $smod )";
+  $schi = sprintf("${schia}  =  %3.3e",$chi);
+  $title = "Summed misfit : $schi";
+  $B = "$B0".$Bopts[15];
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R -A- -C$cpt_chi -I -K -O -V >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_chi $Dscale $Bscale3 -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  $schia";
+  $shift = $shift2;
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #-----------------------------
+  print CSH "pstext -N $J_poly $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_6"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel
+
+  $shift = $shift1;
+  $title = "Gradient for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  g\@+0t\@+ = d\@~\143\@~ / dm($smod)";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  #print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_7"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 2);
+  $dir = "${odir}$strun";
+
+  $mod = $mods[2];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "${dir}/$mfile_syn";
+  $file2 = "${dir}/fun_smooth.dat";       # smoothed kernel
+  #$file2 = "${dir}/summed_ker.dat";
+  $file3 = "${dir}/summed_chi_r.dat";
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $chifile = "${dir}/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Cubic interpolation to get m\@+1\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$5 / $normgy}' $poly_curve | psxy $c_info_ks2 $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_kd -K -O -V >>$psfile<<EOF\n$x5 $a1y1 \n$x5 $y5 \n$a1x1 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \n$x4 $y4 \n$x5 $y5 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_8"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # chi as a function of receiver
+
+  # total misfit for the model
+  open(IN,"$chifile");
+  $chi = <IN>;
+  $schia = "\@~\143\@~ ( $smod )";
+  $schi = sprintf("${schia}  =  %3.3e",$chi);
+  $title = "Summed misfit : $schi";
+  $B = "$B0".$Bopts[15];
+  $shift = $shift1;
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file > temp\n";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm3 }' $file3 | pscontour $J $R -A- -C$cpt_chi -I -K -O -V >> $psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_chi $Dscale $Bscale3 -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Plot  $schia";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$5 / $normgy}' $poly_curve | psxy $c_info_ks2 $J_poly $R_poly -K -O -V >> $psfile\n";
+
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_kd -K -O -V >>$psfile<<EOF\n$x5 $a1y1 \n$x5 $y5 \n$a1x1 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x5 $a1y1 \n$x6 $y6 \n$a1x1 $y6 \nEOF\n";
+
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \n$x4 $y4 \n$x5 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3 \n $x6 $y6 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  #=======================================================================
+  # file names for figures
+  $name = "talk_cg01_9"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B2".$Bopts[8];
+  $title = "New line search";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y6 \n$a1x1 $y6 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y6 \nEOF\n";
+  print CSH "pstext -N $J_poly $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  #-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  if($ixv==1) {system("xv $jpgfile &")}
+}
+
+
+
+#===========================================================================
+#===========================================================================
+
+if ($ifig02 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $niter = 8;
+
+  for ($k = 0; $k <= $niter; $k = $k+1) {
+    $irun = $irun0 + 2*$k;              # wave2d run number
+    $strun = sprintf("%4.4i",$irun);
+    $dir = "${odir}$strun";
+    $file1dat = "${dir}/$mfile_dat";
+    $file1syn = "${dir}/$mfile_syn";
+    $file1ker = "${dir}/summed_ker.dat";
+    $ker_files[$k] = $file1ker;
+    $mod_files[$k] = $file1syn;
+    if (not -f $file1syn)   { die("Check if $file1syn exist or not\n") }
+
+    # load chi values
+    $chifile = "${dir}/summed_chi_all.dat";
+    open(IN,"$chifile");
+    $chi = <IN>;
+    $it_vals[$k] = $k;
+    $chi_vals[$k] = $chi;
+    #$schi = sprintf("\@~\143\@~ ( $smod )  =  %3.3e",$chi);
+  }
+
+  #die("testing");
+
+  # get the receivers and sources
+  $recfile = "${dir0}/${edir}001/sr.txt";  # src-rec for first event
+  $evefile = "${dir0}/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+
+for ($k = 0; $k <= $niter; $k = $k+1) {
+
+  # file names for figures
+  $name = "talk_cg02_${k}"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+  $schi = "\@~\143\@~ ( m\@+${k}\@+ )";
+
+  chomp($it_vals[$k]); chomp($chi_vals[$k]);
+
+  # phase speed map for data
+  $title = "Phase speed for data";
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # phase speed map for synthetics
+  $mod = $mods[$k*2]; $smod = "m\@+$mod\@+"; $title = "Phase speed model $smod";
+  print CSH "psbasemap $B $R $J -K -O -V $shift1 >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $mod_files[$k] | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n"; 
+
+  # misfit vs iteration
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $title = "Misfit,  \@~\143\@~ ( m )  ( $utype )";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -V >> $psfile\n";  # red dot
+  for ($j = 0; $j <= $niter; $j = $j+1) {
+    chomp($it_vals[$j]); chomp($chi_vals[$j]);
+    print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V >>$psfile<<EOF\n $it_vals[$j] $chi_vals[$j]\nEOF\n";
+  }
+  $xpt = $it_vals[$k] + 0.5;
+  print CSH "psxy $J_chi $R_chi $p_info_r -K -O -V >>$psfile<<EOF\n $it_vals[$k] $chi_vals[$k]\nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V >>$psfile<<EOF\n $xpt $chi_vals[$k] $fsize1 0 $fontno LM $schi \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+}
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+#===========================================================================
+#===========================================================================
+
+if ($ifig03 == 1) {
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $dir = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/Gik_examples";
+  #$dir  = "/home/carltape/sem2d/2d_adjoint_banana";
+  $B = "$B0".$Bopts[15];
+
+  # load index file into sample kernels and splines
+  $index_file = "${dir}/sample_index.dat";
+  if (not -f $index_file) { die("Check if $index_file exist or not\n") }
+  open(IN,"$index_file"); @index = <IN>; $nfig = @index;
+
+  # get the splines
+  $spl_file = "${dir}/con_lonlat_q08.dat";
+  if (not -f $spl_file) { die("Check if $spl_file exist or not\n") }
+
+  # get the receivers and sources
+  $recfile = "${dir}/recs_lonlat.dat";
+  $evefile = "${dir}/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+  open(IN,"$recfile"); @recs = <IN>; $nrec = @recs;
+  open(IN,"$evefile"); @eves = <IN>; $neve = @eves;
+  $nmeas = $nrec*$neve;
+
+  print "\n $nfig figures showing Gik elements \n";
+  print "\n $nrec receivers and $neve events = $nmeas paths \n";
+
+  #$nfig = 1;                # use for testing one only
+  $shift = $shift1;
+
+  # color scaling factor
+  @facs  = (0.5,0.5,0.5,0.15,0.5,0.5);
+  $spl_fk = "-Sc3p -G0";
+
+  #for ($k = $nfig-1; $k <= $nfig-1; $k = $k+1) {
+  for ($k = 0; $k <= $nfig-1; $k = $k+1) {
+
+    ($ieve,$irec,$iker,$ispl,$Gik) = split(" ",$index[$k]);
+    $seve = sprintf("%4.4i",$ieve);
+    $srec = sprintf("%4.4i",$irec);
+    $sker = sprintf("%4.4i",$iker);
+    $sspl = sprintf("%4.4i",$ispl);
+    $sgik = sprintf("%.2f",$Gik);
+
+    $fileG = "${dir}/Aij_e${seve}_r${srec}_k${sker}_s${sspl}";
+    if (not -f $fileG) { die("Check if $fileG exist or not\n") }
+    print "\n $k, $iker, $ispl, $Gik";
+
+    # lat-lon for target source and receiver
+    #$ieve = $ieves[$k];
+    #$irec = $irecs[$k];
+    ($slon,$slat,$junk) = split(" ",$eves[$ieve-1]);
+    ($rlon,$rlat,$junk) = split(" ",$recs[$irec-1]);
+
+    # lat-lon for target spline
+    open(IN,"$spl_file");
+    @splines = <IN>;
+    ($blon,$blat) = split(" ",$splines[$ispl-1]);
+
+    #----------------------------
+    # make an enhanced color scale for the K*B plots
+
+    $fac = $facs[$k];
+    $ss = $kmax*$fac;
+    $ds = 2*$ss/$scale_color;
+    $T2b = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+    print "\nT2b = $T2b\n";
+    $bs2b = sprintf("%2.2e",0.9*$ss);
+    $Bscale2c  = sprintf("-B${bs2b}:\" K * B  ( 10\@+%2.2i\@+ ) \": -E10p",$kpwr);
+  
+    $cpt_kerb = "color1b.cpt";
+    print CSH "makecpt -C$colorbar $T2b > temp1\n";
+    print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+    print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_kerb\n";
+    #----------------------------
+
+    # file names for figures
+    $name = "talk_Gik03_${k}"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  # kernel
+  $title = "Kernel ${iker} / ${nmeas} (event ${ieve}, rec ${irec})";
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $fileG | pscontour $R $J -A- -C$cpt_ker -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V $src1 >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V $rec1 >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  #print CSH "awk '{print \$1,\$2}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # spline
+  $title = "Spline ${ispl}";
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4 }' $fileG | pscontour $R $J -A- -C$cpt_spl -I -K -O -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V $src1 >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V $rec1 >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "awk '{print \$1,\$2}' $spl_file |psxy -N $J $R -K -O -V $spl_fk >> $psfile\n";
+  print CSH "psxy $J $R -K -O -V $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  #print CSH "awk '{print \$1,\$2}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_spl $Dscale $Bscale_spl -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # kernel * spline
+  $title = "Kernel * Spline ( ${sgik} )";
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$5 / $norm2 }' $fileG | pscontour $R $J -A- -C$cpt_kerb -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V $src1 >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V $rec1 >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  #print CSH "awk '{print \$1,\$2}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_kerb $Dscale $Bscale2c -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  }
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+#===========================================================================
+if ($ifig03p == 1) {
+
+  $origin = "-X0.5 -Y4.75";
+  $Jwid = 2.25;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $J_title = "-JX${Jwid}";
+
+  # shifting the subplots
+  $xfac = 1.20;
+  $yfac = 1.20;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = 1.2*$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 0.75*$Jwid; $Dx = $Jwid/2; $Dy = -0.08*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.12h";
+
+  $fontno = 4;
+  $fsize_title = 9;
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE 9 ANOT_FONT_SIZE 9 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE 12 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $dir = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/Gik_examples";
+  #$dir  = "/home/carltape/sem2d/2d_adjoint_banana";
+
+  # load index file into sample kernels and splines
+  $index_file = "${dir}/sample_index.dat";
+  if (not -f $index_file) { die("Check if $index_file exist or not\n") }
+  open(IN,"$index_file"); @index = <IN>; $nfig = @index;
+  print "\n index of Gik examples to plot for kernels \n @index \n";
+
+  # get the splines
+  $spl_file = "${dir}/con_lonlat_q08.dat";
+  if (not -f $spl_file) { die("Check if $spl_file exist or not\n") }
+  $ngrid = 286;
+
+  # get the receivers and sources
+  $recfile = "${dir}/recs_lonlat.dat";
+  $evefile = "${dir}/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+  open(IN,"$recfile"); @recs = <IN>; $nrec = @recs;
+  open(IN,"$evefile"); @eves = <IN>; $neve = @eves;
+  $nmeas = $nrec*$neve;
+
+  print "\n $nfig figures showing Gik elements \n";
+  print "\n $nrec receivers and $neve events = $nmeas paths \n";
+
+  #$nfig = 1;                # use for testing one only
+  $shift = $shift1;
+
+  # color scaling factor
+  @facs  = (0.5,0.5,0.5,0.15,0.5,0.5);
+  $spl_fk = "-Sc3p -G0";
+
+  # KEY COMMAND: pick the spline from the index file
+  $k = $nfig-1;
+
+    ($ieve,$irec,$iker,$ispl,$Gik) = split(" ",$index[$k]);
+    $seve = sprintf("%4.4i",$ieve);
+    $srec = sprintf("%4.4i",$irec);
+    $sker = sprintf("%4.4i",$iker);
+    $sspl = sprintf("%4.4i",$ispl);
+    $sgik = sprintf("%.2f",$Gik);
+
+    $fileG = "${dir}/Aij_ker_e${seve}_r${srec}_k${sker}_s${sspl}";
+    if (not -f $fileG) { die("Check if $fileG exist or not\n") }
+    print "\n $k, $iker, $ispl, $Gik";
+
+    # lat-lon for target source and receiver
+    #$ieve = $ieves[$k];
+    #$irec = $irecs[$k];
+    ($slon,$slat,$junk) = split(" ",$eves[$ieve-1]);
+    ($rlon,$rlat,$junk) = split(" ",$recs[$irec-1]);
+
+    # lat-lon for target spline
+    open(IN,"$spl_file");
+    @splines = <IN>;
+    ($blon,$blat) = split(" ",$splines[$ispl-1]);
+
+    #----------------------------
+    # make an enhanced color scale for the K*B plots
+
+    $fac = $facs[$k];
+    $ss = $kmax*$fac;
+    $ds = 2*$ss/$scale_color;
+    $T2b = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+    print "\nT2b = $T2b\n";
+    $bs2b = sprintf("%2.2e",0.9*$ss);
+    $Bscale2c  = sprintf("-B${bs2b}:\" K * B  ( 10\@+%2.2i\@+  m\@+-2\@+ s ) \": -E10p",$kpwr);
+  
+    $cpt_kerb = "color1b.cpt";
+    print CSH "makecpt -C$colorbar $T2b > temp1\n";
+    print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+    print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_kerb\n";
+    #----------------------------
+
+    # file names for figures
+    $name = "talk_Gik03_${k}_ker_paper"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  @labs = ("d","e","f","a","b","c");
+  @Baxes = (15,15,15,7,4,99);
+
+  # kernel
+  $title = "($labs[0])  Kernel : i = ${iker} / ${nmeas} (event ${ieve}, rec ${irec})";
+  $B = "$B0".$Bopts[$Baxes[0]];
+  print CSH "psbasemap $B $R $J -K -V -P $origin > $psfile\n"; # START
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $fileG | pscontour $R $J -A- -C$cpt_ker -I -K -O -V -P  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V -P >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V -P >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V -P $src1 >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec1 >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  #print CSH "awk '{print \$1,\$2}' $recfile |psxy -N $J $R -K -O -V -P $rec >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V -P $src >> $psfile\n";
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2b -K -O -V -P >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # spline
+  $title = "($labs[1])  Spline : k = ${ispl} / $ngrid";
+  $B = "$B0".$Bopts[$Baxes[1]];
+  print CSH "psbasemap $B $R $J -K -O -V -P $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4 }' $fileG | pscontour $R $J -A- -C$cpt_spl -I -K -O -V -P >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V -P >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V -P >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V -P $src1 >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec1 >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "awk '{print \$1,\$2}' $spl_file |psxy -N $J $R -K -O -V -P $spl_fk >> $psfile\n";
+  print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  print CSH "psscale -C$cpt_spl $Dscale $Bscale_spl -K -O -V -P >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # kernel * spline
+  $title = "($labs[2])  Kernel * Spline ( G\@-ik\@- = ${sgik} )";
+  $B = "$B0".$Bopts[$Baxes[2]];
+  print CSH "psbasemap $B $R $J -K -O -V -P $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$5 / $norm2 }' $fileG | pscontour $R $J -A- -C$cpt_kerb -I -K -O -V -P  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V -P >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V -P >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V -P $src1 >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec1 >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  print CSH "psscale -C$cpt_kerb $Dscale $Bscale2c -K -O -V -P >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #-----------------------------
+  #print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  #print CSH "convert $psfile $jpgfile\n";
+  #if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  # KERNEL
+  #================================
+  # RAY PATH
+
+  # file names for figures
+    #$name = "talk_Gik03_${k}_ray_paper"; $psfile  = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+   $iextra = 0;
+  ($ieve,$irec,$iray,$ispl,$ispl2) = (1,126,126,203,111);
+
+   $seve = sprintf("%4.4i",$ieve);
+   $srec = sprintf("%4.4i",$irec);
+   $sker = sprintf("%4.4i",$iray);
+   $sspl = sprintf("%4.4i",$ispl);
+   $sspl2 = sprintf("%4.4i",$ispl2);
+
+  $ray_dir = "${dir}/rays";
+  $ray_file = "${ray_dir}/ray_path.dat";
+  $profile_file = "${ray_dir}/gaussian.dat";
+  $profile_file2 = "${ray_dir}/gaussian_extra.dat";
+  $int_file = "${ray_dir}/gaussian_int.dat";
+  $basis_file = "${ray_dir}/Aij_ray_e${seve}_r${srec}_k${sker}_s${sspl}.dat";
+  if (not -f $ray_file) { die("Check if $ray_file exist or not\n") }
+  if (not -f $profile_file) { die("Check if $profile_file exist or not\n") }
+  if (not -f $profile_file2) { die("Check if $profile_file2 exist or not\n") }
+  if (not -f $int_file) { die("Check if $int_file exist or not\n") }
+  if (not -f $basis_file) { die("Check if $basis_file exist or not\n") }
+
+  # Gik value and integral of Gaussian
+  open(IN,"$int_file"); @lims = <IN>;
+  ($int,$Gik) = split(" ",$lims[0]);
+  #print "\n $int, $Gik \n\n"; die("testing");
+  $sgik = sprintf("%.2f",$Gik);
+
+  $src_col = "-G255/0/0";
+  $rec_col = "-G0/255/255";
+
+  # lat-lon for target spline
+  ($blon,$blat) = split(" ",$splines[$ispl-1]);
+  ($blon2,$blat2) = split(" ",$splines[$ispl2-1]);
+
+  # ray path
+  $title = "($labs[3])  Ray : i = ${iray} / ${nmeas} (event ${ieve}, rec ${irec})"; 
+  $B = "$B0".$Bopts[$Baxes[3]];
+  #print CSH "psbasemap $B $R $J -K -V -P $origin > $psfile\n"; # START
+  print CSH "psbasemap $B $R $J -K -O -V -P $shift2 >> $psfile\n";
+  print CSH "psxy $ray_file $J $R -K -O -V -P -W1.0p >>$psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -V -P >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V -P >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V -P -G255/0/0 $src1 $src_col >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec1 $rec_col >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  if($iextra==1) {print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon2 $blat2 \nEOF\n"}
+  #print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -V -P >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  # spline
+  $title = "($labs[4])  Spline : k = ${ispl} / $ngrid";
+  $B = "$B0".$Bopts[$Baxes[4]];
+  print CSH "psbasemap $B $R $J -K -O -V -P $shift >> $psfile\n";
+  if($icolor==1) {print CSH "pscontour $basis_file $R $J -A- -C$cpt_spl -I -K -O -V -P >> $psfile\n"}
+  print CSH "psxy $ray_file $J $R -K -O -V -P -W1.0p >>$psfile\n";
+  print CSH "pscoast $J $R $coast_info -K -O -V -P >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V -P >> $psfile\n"}
+  print CSH "psxy $J $R -K -O -V -P $src1 $src_col >>$psfile<<EOF\n $slon $slat \nEOF\n";
+  print CSH "psxy $J $R -K -O -V -P $rec1 $rec_col >>$psfile<<EOF\n $rlon $rlat \nEOF\n";
+  print CSH "awk '{print \$1,\$2}' $spl_file |psxy -N $J $R -K -O -V -P $spl_fk >> $psfile\n";
+  print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon $blat \nEOF\n";
+  if($iextra==1) {print CSH "psxy $J $R -K -O -V -P $rec_fw >>$psfile<<EOF\n $blon2 $blat2 \nEOF\n"}
+  #print CSH "psscale -C$cpt_spl $Dscale $Bscale_spl -K -O -V -P >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+   # axes limits for gaussian plot
+  $axes_file = "${ray_dir}/axes.dat";
+  if (not -f $axes_file)   { die("Check if $axes_file exist or not\n") }
+  open(IN,"$axes_file");
+  @ax_lims = <IN>;
+  ($a1x1,$a1x2,$a1y1,$a1y2) = split(" ",$ax_lims[0]);  # inner box
+  ($a2x1,$a2x2,$a2y1,$a2y2) = split(" ",$ax_lims[1]);  # outer box
+
+  # find the power of the distance-along-ray
+  $lpwr_x = int( log($a2x2) / log(10) );
+  $normx = "1e$lpwr_x";
+
+  $xmin1 = $a1x1 / $normx;
+  $xmax1 = $a1x2 / $normx;
+  $xmin2 = $a2x1 / $normx;
+  $xmax2 = $a2x2 / $normx;
+
+  $spl_tick = 0.2;
+  $Jgaus = "-JX${Jwid}";
+  $Rgaus = "-R$xmin2/$xmax2/$a2y1/$a2y2";
+  $Bgaus = sprintf("-B1:\" Distance along ray path  (10\@+%2.2i\@+ m) \":/${spl_tick}".$Bopts[4],$lpwr_x);
+
+  $Bscale_spl  = "-B${spl_tick} -A";
+  $Dlen = 0.84 * $Jwid; $Dx = 0; $Dy = $Jwid/2;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.12";
+
+  print "\n $a2x2 $lpwr_x $normx \n $Jgaus $Rgaus \n\n";
+  #die("testing");
+
+  # ray * spline
+  $title = "($labs[5])  Spline along ray ( G\@-ik\@- = ${sgik} )";
+  print CSH "psbasemap $Bgaus $Rgaus $Jgaus -K -O -V -P $shift >> $psfile\n";
+
+  print CSH "awk '{print \$1 / $normx,\$2}' $profile_file | psxy $Jgaus $Rgaus -K -O -V -P -W1.0p >>$psfile\n";
+  if($iextra==1) {print CSH "awk '{print \$1 / $normx,\$2}' $profile_file2 | psxy $Jgaus $Rgaus -K -O -V -P -W1.0tap >>$psfile\n"}
+  print CSH "psscale -C$cpt_spl2 $Dscale $Bscale_spl -K -O -V -P >> $psfile \n";
+  print CSH "psxy $Jgaus $Rgaus -K -O -V -P $src1 $src_col >>$psfile<<EOF\n $xmin1 0 \nEOF\n";
+  print CSH "psxy $Jgaus $Rgaus -K -O -V -P $rec1 $rec_col >>$psfile<<EOF\n $xmax1 0 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V -P >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V -P >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH);
+  system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+if ($ifig04 == 1) {
+
+  $Jwid = 3;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $origin = "-X0.75 -Y3.0";
+
+  # colorbar
+  $Dlen = 0.75*${Jwid}; $Dx = $Jwid/2; $Dy = -0.10*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.20h";
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.35;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  if($irun0 == 0) { $iev = 5 } else { $iev = 1 }
+  $stev = sprintf("%3.3i",$iev);
+
+  # get the summed kernel and chi files
+  $file2 = "${dir}/summed_ker.dat";
+  #$file2 = "${dir}/fun_smooth.dat";       # smoothed kernel
+  $recfile = "${dir}/${edir}${stev}/sr.txt";  # src-rec for event 001
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+
+  # number of receivers
+  open(IN,$recfile); @temp = <IN>; $nrec = @temp - 1;
+
+  # KEY: make TWO figures, one having the event kernel
+  for ($k = 0; $k <= 1; $k = $k+1) {
+
+  if($k == 0) { $slab = "mod" } else { $slab = "mod_ker" }
+
+  # file names for figures
+  $name = "talk_${slab}_${strun0}";
+  $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec_fw >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $src_fr >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed for synthetics";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec_fw >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $src_fr >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel -- UNSMOOTHED VERSION
+
+  if ($k == 1) {
+
+  $shift = $shift1;
+  $title = "Event kernel ($nrec receivers)";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -V >> $psfile \n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $src_fr >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+}
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  }  # $k
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+
+#===========================================================================
+if ($ifig04p == 1) {
+
+  $Jwid = 3;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $origin = "-X0.75 -Y3.0";
+  $fontno = 4;
+
+  # colorbar
+  $Dlen = 0.75*${Jwid}; $Dx = $Jwid/2; $Dy = -0.08*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.12h";
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.35;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  if($irun0 == 0) { $iev = 5 } else { $iev = 1 }
+  $stev = sprintf("%3.3i",$iev);
+
+  # get the summed kernel and chi files
+  $file2 = "${dir}/summed_ker.dat";
+  #$file2 = "${dir}/fun_smooth.dat";       # smoothed kernel
+  $recfile = "${dir}/${edir}${stev}/sr.txt";  # src-rec for event 001
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+
+  # number of receivers
+  open(IN,$recfile); @temp = <IN>; $nrec = @temp - 1;
+
+  $k = 0;
+  if($k == 0) { $slab = "mod" } else { $slab = "mod_ker" }
+
+  # file names for figures
+  $name = "talk_${slab}_${strun0}_paper";
+  $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Target phase speed model (data)";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -P -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -P -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -P -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec_fw >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $src_fr >> $psfile\n";
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -P -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -P -V >>$psfile<<EOF\n $x_title $z_title $fsize2 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Initial phase speed model (synthetics)";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -P -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -P -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -P -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -P -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -P -V >> $psfile\n"}
+  #print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -P -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $rec_fw >> $psfile\n";
+  print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -P -V $src_fr >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -P -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -P -V >>$psfile<<EOF\n $x_title $z_title $fsize2 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -P -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  #print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  print CSH "convert $psfile $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+if ($ifig05 == 1) {
+
+  $Jwid = 1.5;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $origin = "-X1.5 -Y1.0";
+  $J_title = "-JX${Jwid}";
+
+  # colorbar
+  $Dlen = 0.75*${Jwid}; $Dx = $Jwid/2; $Dy = -0.15*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = 0; $dY = $yfac*$Jwid; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH 0.1c LABEL_FONT_SIZE $fsize3 ANOT_FONT_SIZE $fsize3 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize2 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  if($irun0 == 0) { $iev = 5 } else { $iev = 1 }
+  $stev = sprintf("%3.3i",$iev);
+
+  $dir1 = "${dir}/${edir}${stev}";
+
+  # get src-rec file
+  $recfile = "${dir1}/sr.txt";  # src-rec for event 001
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  open(IN,$recfile); @temp = <IN>; $nrec = @temp - 1;
+
+  # pick frames
+  $dt = 0.06;
+  @frames  = (400,1200,2000,2800);
+  $numf = @frames;
+
+  #@files = glob("${dir1}/forward*");
+  #$nfile = @files;
+
+  # file names for figures
+  $name = "talk_forward_${strun0}";
+  $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+  $title = " Regular Wavefield";
+
+  #------------------------------------
+  # color for forward wavefield
+  $pwr = 3;
+  $cmax = 1.0;
+  $norm = "1e-$pwr";
+
+  $ss  = $cmax;
+  $ds  = 2*$ss/$scale_color;
+  $bs  = sprintf("%3.3e",0.9*$ss); # colorbar
+  $T   = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+
+  $cpt_wave = "color4.cpt";
+  print CSH "makecpt -C$colorbar $T > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_wave\n";
+
+  $BscaleS1 = sprintf("-B%2.2e:\" s ( x, y, t )  ( 10\@+-%2.2i\@+  m )\": -E10p",$bs,$pwr);  # $k = 0
+  #------------------------------------
+
+for ($i = 0; $i < $numf; $i++) {
+
+   $j1 = $frames[$i];           # forward frame
+   $time = sprintf("%04d",$j1*$dt);
+   $snapshot_f = sprintf("${dir1}/forward_%05d",$j1);
+   if (not -f $snapshot_f) {die("Check if $snapshot_f exist or not\n");}
+
+   print CSH "echo $psfile\n";
+   print CSH "echo $snapshot_f\n";
+    
+   $B = "-B1/1:\"t = $time s\"::.\"  \":wsne";
+   $B_row1 = "-B1/1:\"t = $time s\"::.\"  \":wsne";
+   if ($i == 0) { $B = $B_row1}
+   #$B = "-B2/2:.\" \":wesn";
+
+   if ($i == 0) {print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"}
+   else         {print CSH "psbasemap $B $R $J -K -O -V $shift1 >> $psfile\n"}
+
+   # PLOT THE FORWARD WAVEFIELD
+   if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm}' $snapshot_f | pscontour $J $R $B -A- -C${cpt_wave} -I -K -O -V >> $psfile\n"}
+   print CSH "pscoast $J $R $B $coast_info -K -O -V >> $psfile\n";
+   if ($i == 0) {print CSH "psscale -C${cpt_wave} $Dscale $BscaleS1 -K -O -V >> $psfile \n";}
+   print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+   print CSH "awk '\$1 == \"S\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $src_fw >> $psfile\n";
+
+   # plot the time of the snapshot
+   $tstr = "t = $time s";
+   print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n -0.2 0.5 $fsize2 90 $fontno CM $tstr \nEOF\n";
+
+}
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n 0.5 1.2 $fsize2 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+
+  if($irun == 1 || $irun == 2) {      # data file generated in gji_figs.m (11-28-05)
+    
+    # get axes limits
+    $ax_file     = "${dir}/time_series_axes.dat";
+    if (not -f $ax_file) { die("Check if $ax_file exist or not\n") }
+    open(IN,$ax_file); @axlims = <IN>;
+    @pwr_vec = split(" ",$axlims[0]);
+    @cmx_vec = split(" ",$axlims[1]);
+    ($tmin,$tmax,$junk,$junk) = split(" ",$axlims[2]);
+    print "\n $tmin $tmax \n @pwr_vec \n @cmx_vec \n\n";
+    @norm = ("1e$pwr_vec[0]","1e$pwr_vec[1]","1e$pwr_vec[2]","1e$pwr_vec[3]");
+    
+    # make plot bounds
+    $R1 = "-R${tmin}/${tmax}/-${cmx_vec[0]}/${cmx_vec[0]}";
+    $R2 = "-R${tmin}/${tmax}/-${cmx_vec[1]}/${cmx_vec[1]}";
+    $R3 = "-R${tmin}/${tmax}/-${cmx_vec[2]}/${cmx_vec[2]}";
+    $R4 = "-R${tmin}/${tmax}/-${cmx_vec[3]}/${cmx_vec[3]}";
+    #print "\n $R1 \n $R2 \n $R3 \n $R4 \n";
+
+    # get time series
+    $series_file = "${dir}/time_series.dat";
+    if (not -f $series_file) { die("Check if $series_file exist or not\n") }
+
+    # get measurement
+    $meas_file = "${dir}/measure_vec.dat";
+    if (not -f $meas_file) { die("Check if $meas_file exist or not\n") }
+    open(IN,$meas_file); $meas = <IN>; chomp($meas);
+    $stmeas = sprintf(" \@~\104\@~T = %.2f s",$meas);
+
+    print "\n $stmeas \n";
+
+    # plot dimensions
+    $Jseis = "-JX4/${Jwid}";
+    $dY = -2.7*$yfac*$Jwid;
+    $shift = "-X3 -Y${dY}";
+
+    if($irun == 2) {$units = "m\@+-1\@+"} else {$units = "m\@+-1\@+ s"}
+
+    # titles (note the units)
+    $title1 = sprintf("Regular Source Function  (10\@+%2.2i\@+ kg s\@+-2\@+)",$pwr_vec[0]);
+    $title2 = sprintf("Displacement  (10\@+%2.2i\@+ m)",$pwr_vec[1]);
+    $title3 = sprintf("Velocity  (10\@+%2.2i\@+ m s\@+-1\@+)",$pwr_vec[2]);
+    $title4 = sprintf("Adjoint Source Function  (10\@+%2.2i\@+ $units)",$pwr_vec[3]);
+
+    $B1 = sprintf("-B%3.3f:\"Time  (s)\":/%3.3f:\" \":WeSn",20,2);
+    $B2 = sprintf("-B%3.3f:\"Time  (s)\":/%3.3f:\" \":Wesn",20,2);
+    $B3 = sprintf("-B%3.3f:\"Time  (s)\":/%3.3f:\" \":Wesn",20,1);
+    $B4 = sprintf("-B%3.3f:\"Time  (s)\":/%3.3f:\" \":Wesn",20,1);
+
+    $dY = 1.2 * $yfac * $Jwid;
+    $shifty = "-Y${dY}";
+    $x_tit = 1.5;
+    #$y_tit = 0.9;
+    $y_tit = 1.15;
+    print CSH "psbasemap $B1 $R1 $Jseis -K -O -V $shift >> $psfile\n";
+    print CSH "awk '{print \$1,\$2/$norm[0]}' $series_file | psxy $Jseis $R1 -K -O -V -W1p >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno CM $title1 \nEOF\n";
+
+    #print CSH "psbasemap $B2 $R2 $Jseis -K -O -V $shifty >> $psfile\n";
+    #print CSH "awk '{print \$1,\$3/$norm[1]}' $series_file | psxy $Jseis $R2 -K -O -V -W1p >> $psfile\n";
+    #print CSH "awk '{print \$1,\$4/$norm[1]}' $series_file | psxy $Jseis $R2 -K -O -V -W1/255/0/0tap >> $psfile\n";
+    #print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno CM $title2 \nEOF\n";
+    #print CSH "pstext -N $Jseis $R2 -K -O -V >>$psfile<<EOF\n 150 -3 $fsize2 0 $fontno CM $stmeas \nEOF\n";
+
+    print CSH "psbasemap $B3 $R3 $Jseis -K -O -V $shifty >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno CM $title3 \nEOF\n";
+    if($irun == 1) {
+      print CSH "awk '{print \$1,\$5/$norm[2]}' $series_file | psxy $Jseis $R3 -K -O -V -W1p >> $psfile\n";
+      print CSH "awk '{print \$1,\$6/$norm[2]}' $series_file | psxy $Jseis $R3 -K -O -V -W1/255/0/0tap >> $psfile\n";
+      print CSH "pstext -N $Jseis $R3 -K -O -V >>$psfile<<EOF\n 150 1.5 $fsize2 0 $fontno CM $stmeas \nEOF\n";
+      print CSH "pstext -N $Jseis $R3 -K -O -V           >>$psfile<<EOF\n 143 -1.5 $fsize3 0 $fontno RM DATA \nEOF\n";
+      print CSH "pstext -N $Jseis $R3 -G255/0/0 -K -O -V >>$psfile<<EOF\n 161 -1.5 $fsize3 0 $fontno LM SYN \nEOF\n";
+    } else {
+       print CSH "awk '{print \$1,\$6/$norm[2]}' $series_file | psxy $Jseis $R3 -K -O -V -W1p >> $psfile\n";
+    }
+
+    print CSH "psbasemap $B4 $R4 $Jseis -K -O -V $shifty >> $psfile\n";
+    print CSH "awk '{print \$1,\$7/$norm[3]}' $series_file | psxy $Jseis $R4 -K -O -V -W1p >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno CM $title4 \nEOF\n";
+
+  }  # $irun == 1
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+#===========================================================================
+if ($ifig06 == 1) {
+
+  $Jwid = 5;
+  $J = "-JX${Jwid}/-${Jwid}";  # flip the y-axis
+  $origin = "-X3.5 -Y2.0";
+  $origin = "-X1.5 -Y2.0";
+  $J_title = "-JX${Jwid}";
+
+  # colorbar
+  $Dlen = 0.75*${Jwid}; $Dx = $Jwid/2; $Dy = -0.1*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.15h";
+
+  # shifting the subplots
+  $xfac = 1.15;
+  $yfac = 1.15;
+  $dX = 0; $dY = $yfac*$Jwid; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH 0.2c LABEL_FONT_SIZE $fsize1 ANOT_FONT_SIZE $fsize1 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize0 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $slab = "ker";
+  $slab = "ray";
+
+  $dir = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/design_matrix/run_0000";
+  $file_hess = "${dir}/AtA_${slab}_gmt.dat";
+  if (not -f $file_hess) {die("Check if $file_hess exist or not\n")}
+
+  $ngrid = 286;
+
+  # file names for figures
+  $name = "hessian_${slab}_000";
+  $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+  $title = "The Hessian  (G\@+T\@+G)";
+
+  # find the mins and maxs of Gik
+  ($imin,$imax,$jmin,$jmax,$Gmin,$Gmax) = split(" ",`minmax -C $file_hess`);
+
+   # find the power of the max value of AtA
+  ($Gmax_abs) = sort{$b <=> $a} (abs($Gmin),abs($Gmax));
+  $pwr = int( log($Gmax_abs) / log(10) );
+  if($pwr < 0) {$pwr = -1 * ( abs($pwr)+1 )}
+
+  #------------------------------------
+  # color for hessian
+  $norm = "1e$pwr";
+  $fac = 0.5;
+  $cmax = $fac*$Gmax_abs/$norm;
+  $cmax = 1;
+
+  print "\n $imin, $imax, $jmin, $jmax \n $Gmin, $Gmax, $Gmax_abs, $pwr \n $norm $fac $cmax \n";
+  #die("testing");
+
+  $ss  = $cmax;
+  $ds  = 2*$ss/$scale_color;
+  $T   = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+
+  $cpt_hess = "color.cpt";
+  print CSH "makecpt -C$colorbar $T > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_hess\n";
+
+  $bs  = 0.5*$ss;
+  $BscaleH = sprintf("-B%.2f:\" G\@-ik\@- for $slab  ( 10\@+%2.2i\@+ )\": -Ef10p",$bs,$pwr);  # $k = 0
+  #------------------------------------
+
+  print "\n $BscaleH \n $T  \n";
+
+  $R = "-R1/${ngrid}/1/${ngrid}";
+  $B = "-B40:\" column index\":/40:\" row index\"::.\"  \":WsNe";
+
+  print CSH "psbasemap $B $R $J -K -P -V $origin > $psfile\n";
+
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm}' $file_hess | pscontour $J $R $B -A- -C${cpt_hess} -I -K -O -P -V >> $psfile\n"}
+
+  # make grd file, then plot
+  $grdfile = "temp.grd";
+  $grd_info = "-I1/1";
+  print CSH "awk '{print \$1,\$2,\$3 / $norm}' $file_hess | xyz2grd -G$grdfile $grd_info $R \n";
+  print CSH "grdimage $grdfile $R $J $B -C${cpt_hess} -T -K -O -P -V >> $psfile\n";
+
+  print CSH "psscale -C${cpt_hess} $Dscale $BscaleH -K -O -P -V >> $psfile \n";
+  print CSH "psbasemap $B $R $J -K -O -P -V >> $psfile\n";
+  #print CSH "pstext -N $J_title $R_title -K -O -P -V >>$psfile<<EOF\n 0.5 1.2 $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -P -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  #print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  print CSH "convert $psfile $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+#===========================================================================
+# Hessian plot copied from ifig06 on 07-March-2006
+
+if ($ifig07 == 1) {
+
+  $Jwid = 2.75;
+  $J = "-JM${Jwid}i";           # in lat-lon
+  $Jb = "-JX${Jwid}/-${Jwid}";  # flip the y-axis
+  $origin = "-X1.0 -Y3.0";
+  $J_title = "-JX${Jwid}";
+  $x_title = 0.05;
+  $z_title = 1.15;
+
+  # colorbar
+  $Dlen = 0.6*${Jwid}; $Dx = $Jwid/2; $Dy = -0.08*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.15h";
+
+  # shifting the subplots
+  $xfac = 1.2;
+  $yfac = 1.15;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH 0.15c LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE 10 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $slab = "ker";
+
+  # locate Hessian data file
+  $dirb = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/design_matrix/run_0000";
+  $file_hess = "${dirb}/AtA_${slab}_gmt.dat";
+  if (not -f $file_hess) {die("Check if $file_hess exist or not\n")}
+
+  # locate Hessian diagonal data file
+  $dirb = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/design_vector/run_0020";
+  $file_diag = "${dirb}/m_IMODEL_3_rayleigh_id01_plot";
+  if (not -f $file_diag) {die("Check if $file_diag exist or not\n")}
+
+  # locate gradient data file
+  $dirb = "/home/carltape/sem2d/2d_adjoint_banana/mat_SAVE/gradient_vector/run_0020";
+  $file_grad = "${dirb}/m_IMODEL_3_rayleigh_plot";
+  if (not -f $file_grad) {die("Check if $file_grad exist or not\n")}
+
+  $ngrid = 286;
+
+  # file names for figures
+  $name = "hessian_and_gradient_ker";
+  $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+  $title = "The Hessian  (G\@+T\@+G)";
+
+  # find the mins and maxs of Hij
+  ($imin,$imax,$jmin,$jmax,$Gmin,$Gmax) = split(" ",`minmax -C $file_hess`);
+
+   # find the power of the max value of AtA
+  ($Gmax_abs) = sort{$b <=> $a} (abs($Gmin),abs($Gmax));
+  $pwr = int( log($Gmax_abs) / log(10) );
+  if($pwr < 0) {$pwr = -1 * ( abs($pwr)+1 )}
+
+  #------------------------------------
+  # color for hessian
+  $normH = "1e$pwr";
+  $fac = 0.5;
+  $cmax = $fac*$Gmax_abs/$normH;
+  $cmax = 1.01;
+
+  print "\n $imin, $imax, $jmin, $jmax \n $Gmin, $Gmax, $Gmax_abs, $pwr \n $normH $fac $cmax \n";
+  #die("testing");
+
+  $ss  = $cmax;
+  $ds  = 2*$ss/$scale_color;
+  $T   = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+
+  $cpt_hess = "color.cpt";
+  print CSH "makecpt -C$colorbar $T > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_hess\n";
+
+  $bs  = 0.5;
+  #$BscaleH = sprintf("-B%.2f:\" Hessian matrix H\@-ij\@-  (10\@+%2.2i\@+ s\@+2\@+)\": -Ef10p",$bs,$pwr);  # $k = 0
+  $BscaleH = sprintf("-B%.2f:\" Hessian matrix H  (10\@+%2.2i\@+ s\@+2\@+)\": -Ef10p",$bs,$pwr);
+  print "\n $BscaleH \n $T  \n";
+
+  #------------------------------------
+  # color for gradient
+
+  $pwr = 4;
+  $normG = "1e$pwr";
+  $cmax = 1.01;
+
+  print "\n $imin, $imax, $jmin, $jmax \n $Gmin, $Gmax, $Gmax_abs, $pwr \n $normG $fac $cmax \n";
+  #die("testing");
+
+  $ss  = $cmax;
+  $ds  = 2*$ss/$scale_color;
+  $T   = sprintf("-T%3.3e/%3.3e/%3.3e",-$ss,$ss,$ds);
+
+  $cpt_grad = "color_grad.cpt";
+  print CSH "makecpt -C$colorbar $T > temp1\n";
+  print CSH "sed 's/^B.*/B       170     0      0  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F         0     0    255  /' temp2 > $cpt_grad\n";
+
+  $bs  = 0.5;
+  #$BscaleG = sprintf("-B%.2f:\" gradient vector g\@-k\@-  (10\@+%2.2i\@+ s\@+2\@+)\": -Ef10p",$bs,$pwr);  # $k = 0
+  $BscaleG = sprintf("-B%.2f:\" gradient vector g  (10\@+%2.2i\@+ s\@+2\@+)\": -Ef10p",$bs,$pwr);  # $k = 0
+  print "\n $BscaleG \n $T  \n";
+
+  #------------------------------------
+  # color for Hessian diagonal
+
+  $pwr = 4;
+  $normD = "1e$pwr";
+  $cmax = 4.01;
+
+  $ss  = $cmax;
+  $ds  = $ss/$scale_color;
+  $T   = sprintf("-T%3.3e/%3.3e/%3.3e",0,$ss,$ds);
+
+  $cpt_diag = "color_diag.cpt";
+  #print CSH "makecpt -Chot $T > $cpt_diag\n";
+  print CSH "makecpt -Crainbow $T > temp1\n";
+  #print CSH "sed 's/^B.*/B       255   255    255  /' temp1 >  temp2\n";
+  #print CSH "sed 's/^F.*/F         0     0      0  /' temp2 > $cpt_diag\n";
+  print CSH "sed 's/^B.*/B       255     0    255  /' temp1 >  temp2\n";
+  print CSH "sed 's/^F.*/F       255     0      0  /' temp2 > $cpt_diag\n";
+
+  $bs  = 1.0;
+  $BscaleD = sprintf("-B%.2f:\" Hessian diagonal H\@-ii\@-   (10\@+%2.2i\@+ s\@+2\@+)\": -Ef10p",$bs,$pwr);  # $k = 0
+  print "\n $BscaleD \n $T  \n";
+
+  #------------------------------------
+  # plot Hessian
+
+  $Rhess = "-R1/${ngrid}/1/${ngrid}";
+  $Bhess = "-B40:\" column index\":/40:\" row index\"::.\"  \":WsNe";
+  $title = "(a)";
+
+  print CSH "psbasemap $Bhess $Rhess $Jb -K -V $origin > $psfile\n";
+
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $normH}' $file_hess | pscontour $Jb $Rhess $Bhess -A- -C${cpt_hess} -I -K -O -V >> $psfile\n"}
+
+  # make grd file, then plot
+  $grdfile = "temp.grd";
+  $grd_info = "-I1/1";
+  print CSH "awk '{print \$1,\$2,\$3 / $normH}' $file_hess | xyz2grd -G$grdfile $grd_info $Rhess \n";
+  print CSH "grdimage $grdfile $Rhess $Jb $Bhess -C${cpt_hess} -T -K -O -V >> $psfile\n";
+  print CSH "psscale -C${cpt_hess} $Dscale $BscaleH -K -O -V >> $psfile \n";
+  print CSH "psbasemap $Bhess $Rhess $Jb -K -O -V >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #------------------------------------
+  # plot Hessian diagonal
+
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $evefile = "${dir0}/events_lonlat.dat";
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $evefile) { die("Check if $evefile exist or not\n") }
+
+  $B = "$B0".$Bopts[5];
+  $title = "(b)";
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift1 >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $normD}' ${file_diag} | pscontour $R $J -A- -C${cpt_diag} -I -K -O -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src -W0.5p >> $psfile\n";
+  print CSH "psscale -C${cpt_diag} $Dscale $BscaleD -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #------------------------------------
+  # plot gradient
+
+  $B = "$B0".$Bopts[5];
+  $title = "(c)";
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift1 >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $normG}' ${file_grad} | pscontour $R $J -A- -C${cpt_grad} -I -K -O -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src -W0.5p >> $psfile\n";
+  print CSH "psscale -C${cpt_grad} $Dscale $BscaleG -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  #print CSH "convert $psfile $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+#===========================================================================
+if ($ifig05p == 1) {
+
+  $Jwid = 1.5;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $origin = "-X1.5 -Y6.0";
+  $J_title = "-JX${Jwid}";
+
+  # colorbar
+  $Dlen = 0.75*${Jwid}; $Dx = $Jwid/2; $Dy = -0.15*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  # shifting the subplots
+  $xfac = 1.25;
+  $yfac = 1.45;
+  $dX = 0; $dY = -$yfac*$Jwid; $shift1 = "-X$dX -Y$dY";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH 0.1c LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize3 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  $dir = "/home/carltape/2d_adjoint/OUTPUT/run_0001";
+  $dir1 = "${dir}/event_001";
+
+  # get src-rec file
+  $recfile = "${dir1}/sr.txt";  # src-rec for event 001
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  open(IN,$recfile); @temp = <IN>; $nrec = @temp - 1;
+
+  # file names for figures
+  $name = "talk_seis_01";
+  $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps";
+  $title = " Regular Wavefield";
+
+    # get axes limits
+    $ax_file = "${dir}/time_series_axes.dat";
+    if (not -f $ax_file) { die("Check if $ax_file exist or not\n") }
+    open(IN,$ax_file); @axlims = <IN>;
+    @pwr_vec = split(" ",$axlims[0]);
+    @cmx_vec = split(" ",$axlims[1]);
+    ($tmin,$tmax,$junk,$junk) = split(" ",$axlims[2]);
+    print "\n $tmin $tmax \n @pwr_vec \n @cmx_vec \n\n";
+    @norm = ("1e$pwr_vec[0]","1e$pwr_vec[1]","1e$pwr_vec[2]","1e$pwr_vec[3]");
+    
+    # make plot bounds
+    $R1 = "-R${tmin}/${tmax}/-${cmx_vec[0]}/${cmx_vec[0]}";
+    $R2 = "-R${tmin}/${tmax}/-${cmx_vec[1]}/${cmx_vec[1]}";
+    $R3 = "-R${tmin}/${tmax}/-${cmx_vec[2]}/${cmx_vec[2]}";
+    $R4 = "-R${tmin}/${tmax}/-${cmx_vec[3]}/${cmx_vec[3]}";
+    #print "\n $R1 \n $R2 \n $R3 \n $R4 \n";
+
+    # get time series
+    $series_file = "${dir}/time_series.dat";
+    if (not -f $series_file) { die("Check if $series_file exist or not\n") }
+
+    # get measurement
+    $meas_file = "${dir}/measure_vec.dat";
+    if (not -f $meas_file) { die("Check if $meas_file exist or not\n") }
+    open(IN,$meas_file); $meas = <IN>; chomp($meas);
+    $stmeas = sprintf(" \@~\104\@~T = %.2f s",$meas);
+    print "\n $stmeas \n";
+
+    # plot dimensions
+    $Jseis = "-JX4/${Jwid}";
+    $units = "m\@+3\@+ s";
+
+    $title1 = "(a)  Regular Source";
+    #$title2 = "(b)  Displacement at Receiver";
+    $title3 = "(b)  Velocity at Receiver";
+    $title4 = "(c)  Adjoint Source";
+
+    $title1y = sprintf("Amplitude  (10\@+%2.2i\@+ kg s\@+-2\@+)",$pwr_vec[0]);
+    #$title2y = sprintf("Displacement  (10\@+%2.2i\@+ m)",$pwr_vec[1]);
+    $title3y = sprintf("Speed  (10\@+%2.2i\@+ m s\@+-1\@+)",$pwr_vec[2]);
+    $title4y = sprintf("Amplitude  (10\@+%2.2i\@+ m\@+-1\@+ s)",$pwr_vec[3]);
+
+    $B1 = sprintf("-B%3.3f:\" \":/%3.3f:\"$title1y\":WeSn",20,2);
+    #$B2 = sprintf("-B%3.3f:\" \":/%3.3f:\"$title2y\":WeSn",20,2);
+    $B3 = sprintf("-B%3.3f:\" \":/%3.3f:\"$title3y\":WeSn",20,1);
+    $B4 = sprintf("-B%3.3f:\"Time  (s)\":/%3.3f:\"$title4y\":WeSn",20,1);
+
+    $x_tit = 0.1;
+    $y_tit = 1.15;
+    $shift = $shift1;
+
+    print CSH "psbasemap $B1 $R1 $Jseis -K -P -V $origin > $psfile\n";  # START
+    print CSH "awk '{print \$1,\$2/$norm[0]}' $series_file | psxy $Jseis $R1 -K -O -P -V -W1p >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -P -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno LM $title1 \nEOF\n";
+
+    print CSH "psbasemap $B3 $R3 $Jseis -K -O -P -V $shift >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -P -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno LM $title3 \nEOF\n";
+    print CSH "awk '{print \$1,\$5/$norm[2]}' $series_file | psxy $Jseis $R3 -K -O -P -V -W1p >> $psfile\n";
+    print CSH "awk '{print \$1,\$6/$norm[2]}' $series_file | psxy $Jseis $R3 -K -O -P -V -W1/255/0/0tap >> $psfile\n";
+    print CSH "pstext -N $Jseis $R3 -K -O -P -V >>$psfile<<EOF\n 150 1.5 $fsize2 0 $fontno CM $stmeas \nEOF\n";
+    print CSH "pstext -N $Jseis $R3 -K -O -P -V           >>$psfile<<EOF\n 143 -1.5 $fsize3 0 $fontno RM DATA \nEOF\n";
+    print CSH "pstext -N $Jseis $R3 -G255/0/0 -K -O -P -V >>$psfile<<EOF\n 161 -1.5 $fsize3 0 $fontno LM SYN \nEOF\n";
+
+    print CSH "psbasemap $B4 $R4 $Jseis -K -O -P -V $shift >> $psfile\n";
+    print CSH "awk '{print \$1,\$7/$norm[3]}' $series_file | psxy $Jseis $R4 -K -O -P -V -W1p >> $psfile\n";
+    print CSH "pstext -N $J_title $R_title -K -O -P -V >>$psfile<<EOF\n $x_tit $y_tit $fsize2 0 $fontno LM $title4 \nEOF\n";
+
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -P -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  #print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  print CSH "convert $psfile $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+
+}
+
+
+#===========================================================================
+#===========================================================================
+if ($ifig10 == 1) {
+
+  $Jwid = 2;
+  $J = "-JM${Jwid}i";      # in lat-lon
+  $origin = "-X1 -Y6.0";
+
+  $J_poly_wid = $Jwid;
+  $J_poly = "-JX${J_poly_wid}/${Jwid}";
+  $J_title = "-JX${Jwid}";
+  $J_chi = "-JX${Jwid}i/${Jwid}il";        # note log scale on y-axis
+
+  $fsize_title = 10;
+
+  # shifting the subplots
+  $xfac = 1.2;
+  $yfac = 1.35;
+  $dX = $xfac*$Jwid; $dY = 0; $shift1 = "-X$dX -Y$dY";
+  $dX = -2*$dX; $dY = -$yfac*$Jwid; $shift2 = "-X$dX -Y$dY";
+
+  # colorbar
+  $Dlen = 1.2; $Dx = $Jwid/2; $Dy = -0.05*$Jwid;
+  $Dscale = "-D$Dx/$Dy/$Dlen/0.10h";
+
+  #===============================================
+  print "\nWriting CSH file...\n";
+  
+  open(CSH,">$cshfile");
+  print CSH "gmtset BASEMAP_TYPE plain TICK_LENGTH $tick LABEL_FONT_SIZE $fsize3 ANOT_FONT_SIZE $fsize3 PLOT_DEGREE_FORMAT D HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize2 FRAME_PEN $fpen TICK_PEN $tpen\n";
+  #===============================================
+
+  # get the summed kernel and chi files
+  #$file2 = "${dir}/summed_ker.dat";
+  $file2 = "${dir}/fun_smooth.dat";       # smoothed kernel
+  $file3 = "${dir}/summed_chi_r.dat";
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $evefile = "${dir0}/events_lonlat.dat";
+  $chifile = "${dir}/summed_chi_all.dat";
+
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+
+  # file names for figures
+  $name = "talk_cg10_${strun0}"; $psfile = "$name.ps"; $jpgfile = "$name.jpg"; $epsfile = "$name.eps"; 
+
+  # number of receivers
+  open(IN,$file3); @temp = <IN>; $nrec = @temp;
+
+  #=============================================
+  # model for the data
+
+  $B = "$B0".$Bopts[15];
+  $title = "Phase speed for data";
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -V $origin > $psfile\n"; # START
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1dat | pscontour $R $J -A- -C$cpt_vel -I -K -O -V  >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "psscale -C$cpt_vel $Dscale $Bscale1b -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3/1000}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel -- SMOOTHED VERSION
+
+  $shift = $shift1;
+  $title = "Gradient (smoothed) for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "psscale -C$cpt_ker $Dscale $Bscale2c -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Estimate test model m\@+0t\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$4 / $normgy}' $poly_curve | psxy $c_info_bd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 1);
+  $dir = "${odir}$strun";
+
+  $mod = $mods[1];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "${dir}/$mfile_syn";
+  #$file2 = "${dir}/summed_ker.dat";
+  $file2 = "${dir}/fun_smooth.dat";
+  $file3 = "${dir}/summed_chi_r.dat";
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $chifile = "${dir}/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # kernel -- SMOOTHED VERSION
+
+  $shift = $shift1;
+  $title = "Gradient (smoothed) for $smod";
+  $B = "$B0".$Bopts[15];
+
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  #if($icolor==1) {print CSH "awk '{print \$1,\$2,\$3 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$7 / $norm2 }' $file2 | pscontour $J $R -A- -C$cpt_ker -I -K -O -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  #print CSH "psscale -C$cpt_ker $Dscale $Bscale2 -K -O -V >> $psfile \n";
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+
+  #=============================================
+  # graph
+
+  $shift = $shift2;
+  $Bg = "$B1".$Bopts[8];
+  $title = "Cubic interpolation to get m\@+1\@+";
+
+  print CSH "psbasemap $Bg $R_poly $J_poly -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$2 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$3 / $normgy}' $poly_curve | psxy $c_info_rd $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "awk '{print \$1 / $normgx,\$5 / $normgy}' $poly_curve | psxy $c_info_ks2 $J_poly $R_poly -K -O -V >> $psfile\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x1 $a1y1 \n$x1 $y1 \n$a1x1 $y1 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_ks -K -O -V >>$psfile<<EOF\n$x3 $a1y1 \n$x3 $y3 \n$a1x1 $y3 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $c_info_kd -K -O -V >>$psfile<<EOF\n$x5 $a1y1 \n$x5 $y5 \n$a1x1 $y5 \nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_k -K -O -V >>$psfile<<EOF\n$x1 $y1 \n$x3 $y3\nEOF\n";
+  print CSH "psxy $J_poly $R_poly $p_info_w -K -O -V >>$psfile<<EOF\n$x2 $a1y1 \n$x4 $y4 \n$x5 $y5 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+#=================================================================
+# NEW MODEL
+
+  # wave2d run number
+  $strun = sprintf("%4.4i",$irun + 2);
+  $dir = "${odir}$strun";
+
+  $mod = $mods[2];
+  $smod = "m\@+$mod\@+";
+
+  # get the summed kernel and chi files
+  $file1syn = "${dir}/$mfile_syn";
+  $file2 = "${dir}/summed_ker.dat";
+  $file3 = "${dir}/summed_chi_r.dat";
+  $recfile = "${dir}/${edir}001/sr.txt";  # src-rec for first event
+  $chifile = "${dir}/summed_chi_all.dat";
+
+  if (not -f $file1syn){ die("Check if $file1syn exist or not\n") }
+  if (not -f $file2)   { die("Check if $file2 exist or not\n") }
+  if (not -f $file3)   { die("Check if $file3 exist or not\n") }
+  if (not -f $recfile) { die("Check if $recfile exist or not\n") }
+  if (not -f $chifile) { die("Check if $chifile exist or not\n") }
+#=================================================================
+
+  #=============================================
+  # model for synthetics
+
+  $title = "Phase speed model $smod";
+  $shift = $shift1;
+
+  # phase speed map
+  print CSH "psbasemap $B $R $J -K -O -V $shift >> $psfile\n";
+  if($icolor==1) {print CSH "awk '{print \$1,\$2,\$4*100}' $file1syn | pscontour $R $J -A- -C$cpt_vel -I -O -K -V >> $psfile\n"}
+  print CSH "pscoast $J $R $coast_info -K -O -V >> $psfile\n";
+  if($ishelf) {print CSH "awk '{print \$2,\$1}' $shelf_file |psxy $J $R $Wshelf -K -O -V >> $psfile\n"}
+  print CSH "awk '{print \$1,\$2}' $evefile |psxy -N $J $R -K -O -V $src >> $psfile\n";
+  print CSH "awk '\$1 == \"R\" {print \$2,\$3}' $recfile |psxy -N $J $R -K -O -V $rec >> $psfile\n";
+  #print CSH "psscale -C$cpt_vel $Dscale $Bscale1 -K -O -V >> $psfile \n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+
+  #=============================================
+  # misfit vs iteration
+
+  $shift = $shift1;
+  $Bg = "$B3b".$Bopts[8];
+  $title = "Misfit for first two models";
+
+  print CSH "psbasemap $Bg $R_chi $J_chi -K -O -V $shift >> $psfile\n";
+  print CSH "awk '{print \$1,\$2}' $chi_curve | psxy $c_info_rd $J_chi $R_chi -K -O -V >> $psfile\n";
+  print CSH "psxy $J_chi $R_chi $p_info_k -K -O -V >>$psfile<<EOF\n0 $y1t \n1 $y7t \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V >>$psfile<<EOF\n 0.75 $y1t $fsize2 0 $fontno LM $schi0 \nEOF\n";
+  print CSH "pstext -N $J_chi $R_chi -K -O -V >>$psfile<<EOF\n 1.75 $y7t $fsize2 0 $fontno LM $schi1 \nEOF\n";
+  print CSH "pstext -N $J_title $R_title -K -O -V >>$psfile<<EOF\n $x_title $z_title $fsize_title 0 $fontno CM $title \nEOF\n";
+#-----------------------------
+  print CSH "pstext -N $J_title $R_title -O -V >>$psfile<<EOF\n 10 10 $fsize_title 0 $fontno CM $title \nEOF\n"; # FINISH
+  print CSH "convert $psfile -rotate 90 $jpgfile\n";
+  if($ieps==1){print CSH "convert $psfile $epsfile\n"}
+
+  close (CSH); system("csh -f $cshfile");
+  system("xv $jpgfile &");
+}
+
+#===========================================================================
+
+
+#=================================================================


Property changes on: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/gji_paper/plot_gji_talk.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/axes_expand.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/axes_expand.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/axes_expand.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,50 @@
+%
+% function ax1 = axes_expand(ax0,fac)
+% CARL TAPE, 16-Aug-2005
+% printed xxx
+%
+% This function inputs an axes box and outputs a new axes box,
+% expanded by the factor 'fac' in all 2,4,6 dimensions.
+%
+% EXAMPLE:
+%    ax0 = [-121 -114]; ax1 = axes_expand(ax0,2)
+%    ax0 = [-121 -114 31 37]; ax1 = axes_expand(ax0,2)
+%    ax0 = [-121 -114 31 37]; ax1 = axes_expand(ax0,0.30)
+%
+% calls xxx
+% called by xxx
+%
+
+function ax1 = axes_expand(ax0,fac)
+
+% 1D, 2D, 3D
+ndim = length(ax0)/2;
+ax1 = zeros(1,ndim*2);
+
+% return original axes if new axes are non-sensical
+
+xmin = ax0(1);
+xmax = ax0(2);
+dx = xmax-xmin;
+ax1(1) = xmin - dx*(fac-1);
+ax1(2) = xmax + dx*(fac-1);
+if ax1(2) <= ax1(1), ax1 = ax0; end
+
+if ndim >= 2
+    ymin = ax0(3);
+    ymax = ax0(4);
+    dy = ymax-ymin;
+    ax1(3) = ymin - dy*(fac-1);
+    ax1(4) = ymax + dy*(fac-1);
+    if ax1(4) <= ax1(3), ax1 = ax0; end
+end
+if ndim == 3
+    zmin = ax0(3);
+    zmax = ax0(4);
+    dz = zmax-zmin;
+    ax1(5) = zmin - dz*(fac-1);
+    ax1(6) = zmax + dz*(fac-1);
+    if ax1(6) <= ax1(5), ax1 = ax0; end
+end
+
+%===================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/colors.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/colors.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/colors.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,53 @@
+% 
+% colors.m
+% Carl Tape 01-Dec-2002
+% printed xxx
+%
+% This gets the color-mapping matrices.
+%
+% calls cpt2cmap.m
+% called by trigridN.m, plotcmapsN.m, raysAGU.m, xxx
+%
+
+% blue = (0,0,1)
+% red = (1,0,0)
+% green = (0,1,0)
+% yellow = (0,1,1)
+% white = (1,1,1)
+% white = (0,0,0)
+
+numc = 65;
+white = ones(numc, 3);           % white (no good for contour plots)
+bw = gray(numc);                 % black-to-white
+wb = -gray(numc) + 1;            % white-to-black
+nw = ceil(numc/2);
+inc = 1/(nw-1);
+br = [[ones(nw,1) [0:inc:1]' [0:inc:1]']; [[1-inc:-inc:0]' [1-inc:-inc:0]' ones(nw-1,1)]];
+    % blue-to-red (top-to-bottom), with white in the middle
+br = [[ones(nw,1) [0:inc:1]' [0:inc:1]']; [[1-inc:-inc:0]' [1-inc:-inc:0]' ones(nw-1,1)]];
+    % blue-to-red (top-to-bottom), with white in the middle
+for uy = 1:numc,
+    rb(uy,:) = br(numc+1-uy, :);
+end
+
+% blue = (1,0,0)
+% red = (0,0,1)
+% green = (0,1,0)
+% yellow = (0,1,1)
+% white = (1,1,1)
+
+% values from GMT 'seis' color palette
+seis = [170	0	0;  206	0	0;  243	0	0;  255	24	0;  255	60	0;  255	97	0;
+255	133	0; 255	170	0;  255	206	0;  255	243	0;  255	255	0; 255	255	0;
+231	255	4;  161	255	17;  90	255	30;  51	249	64;  13	242	99;  0	194	152;
+0	125	214;  0	68	248;  0	34	226];
+
+% values for color palette used in TW phase velocity maps
+ana = [202 80 0; 255 90 0; 255 110 0; 255 130 0; 255 150 0; 255 170 0; 255 190 0; ...
+        255 205 0; 190 190 240; 170 170 240; 150 150 240; 130 130 240; 100 100 240; ...
+        70 70 240; 30 30 220; 30 30 140];
+
+br   = cpt2cmap(ana);
+seis = cpt2cmap(seis);
+
+%=========================================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/cpt2cmap.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/cpt2cmap.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/cpt2cmap.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,28 @@
+%
+% function outmat = cpt2cmap(inmat)
+% Carl Tape, 14-March-2005
+% printed xxx
+%
+% This function inputs a 3 column matrix of colors (RGB)
+% and outputs a matrix suitable for Matlab plots.
+%
+% calls xxx
+% called by xxx
+%
+
+function outmat = cpt2cmap(inmat)
+
+numc = 65;
+len = length(inmat);
+temp = inmat/max(max(inmat));  % normalize to 0-1 range
+rv = temp(:,1);
+gv = temp(:,2);
+bv = temp(:,3);
+
+% I don't know a better way to do this -- this interpolates to numc points.
+numc = 65;
+outmat = [  interp1(linspace(1,numc,len), rv', [1:numc])' ...
+            interp1(linspace(1,numc,len), gv', [1:numc])' ...
+            interp1(linspace(1,numc,len), bv', [1:numc])'];
+
+%==================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/curvature.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/curvature.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/curvature.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,25 @@
+% 
+% function [i0,kap] = curvature(x,y)
+% CARL TAPE, 25-July-2005
+%
+% This function compute the curvature of a 1-D function
+% and returns the computed curvature, as well as the
+% point of maximum POSITIVE curvature.
+%
+% This was written for quantifying L-curves.
+%
+% calls xxx
+% called by spline_wang_D.m, test_del2.m
+%
+
+function [i0,kap] = curvature(x,y)
+
+f1 = gradient(y,x);
+f2 = gradient(f1,x);
+kap = f2 ./ (1 + f1.^2).^(3/2);  % see Mathworld
+
+%[kap0,i0] = max(abs(kap));
+[kap0,i0] = max(kap);
+
+%============================================================
+  
\ No newline at end of file

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/fontsize.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/fontsize.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/fontsize.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,24 @@
+%
+% function function fontsize(fs,h)
+% Juliette Artru, 15-Sept-2004
+% printed xxxx
+%
+% This changes the font on an entire figure.
+%
+% fs: font size
+% h: handle graphics (optional)
+%
+
+function fontsize(fs,h);
+
+if(nargin<2);h=gcf;end
+hc=get(gcf,'child');
+hall=hc;
+for k=1:length(hc);
+    if(strcmp(get(hc(k),'Type'),'axes'))
+        hall=[hall; get(hc(k),'XLabel') ; get(hc(k),'YLabel') ; get(hc(k),'Title')];
+    end
+end
+set(hall,'fontsize',fs);
+  
+ 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/gcvfctn.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/gcvfctn.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/gcvfctn.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,47 @@
+%
+% function G = gcvfctn(h, s2, fc, rss0, dof0)
+% Carl Tape (Tapio Schneider, ACM 118)
+% 09-Nov-2004
+%
+% GCVFCTN    Evaluate generalized cross-validation function.
+%
+%    gcvfctn(h, s2, fc, rss0, dof0) is the value of the GCV function
+%    for ridge regression with regularization parameter h.
+%
+%    INPUT:
+%       h       regularization parameter
+%       s2      squared singular value of the design matrix
+%       fc      coefficients fc = U(:, 1:q)'*g
+%       rss0    the residual sum of squares of the (non-regularized)
+%                   least squares estimate
+%       dofo0   the number of residual degrees of freedom of
+%                   the (non-regularized) least squares estimate
+%
+%       U       matrix of left singular vectors
+%       g       vector of response variables
+%       q       the smaller of the numbers of rows and columns of
+%                   the design matrix, q = min(n,p)
+%
+%    Auxiliary function for GCV.
+%
+%    Adapted from GCVFUN in Per-Christian Hansen's Regularization Toolbox. 
+%
+% See Schneider (2001) for details.
+%
+% calls xxx
+% called by gcv.m
+%
+
+function G = gcvfctn(h, s2, fc, rss0, dof0)
+
+% SIMILAR TO filter factor for Tikhonov regularization:
+% 1 - f = F, where F are the filter factors
+f = h^2 ./ (s2 + h^2);
+
+RSS = norm(f.*fc)^2 + rss0;
+T2  = (dof0 + sum(f))^2;
+
+G = RSS / T2;
+
+%=============================================================
+  
\ No newline at end of file

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/genfit.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/genfit.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/genfit.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,77 @@
+%
+% function [m1, e1] = genfit(theory, m0, jogs, data, param)
+% Carl Tape, 23-Sep-2002
+% printed 23-Sep-2002
+%
+% Program by John Woodhouse, Dept. Earth Sciences, University of Oxford.
+% Non-linear least squares algorithm to fit data
+% to a model using the theory function 'theory'.
+%
+% original Oxford location =  /home/owl_data2/john/matlab/genfit.m
+%
+% theory  = a function that generates a column
+%           of predicted data given a model m and 
+%           having the call: d = theory(m, param).
+% m0      = starting model
+% jogs    = a column of perturbations to the
+%           model that genfit will use to estimate the
+%           partial derivatives of theory with respect to
+%           the model parameters. A zero value in jogs
+%           indicates that the corresponding model parameter
+%           is to be held fixed.
+% data    = vector of data
+% param   = an array of parameters associated with the data,
+%           having the same number of rows as data
+%          
+% m1      = the updated model.
+% e1      = an estimate of the uncertainties (standard errors)
+%           of the updated model.
+%
+% calls theory.m (e.g., theoryHyp.m)
+% called by testgenfitA.m, testgenfitB.m, testgenfitC.m
+%
+
+function [m1, e1] = genfit(theory, m0, jogs, data, param)
+
+numd = length(data);   % number of data points
+numm = length(m0);     % number of model parameters
+
+resid = data - feval(theory, m0, param);
+r0 = resid' * resid;
+rms_residual = sqrt(r0/numd);
+
+%disp('  ');
+%disp('  data    theory    resid');
+%disp([data feval(theory, m0, param) resid]);
+    
+% vary each model parameter in turn, to calculate partial derivatives
+a  = zeros(numd, numm);
+
+% predicted data from model m0
+f0 = feval(theory, m0, param);
+
+% Calculate partial derivatives of 'theory' with respect
+% to each model parameter, storing the results in matrix a.
+for i=1:numm
+    xx = m0;
+    dx = jogs(i);
+    if dx ~= 0,                     % check for non-vanishing dx
+        xx(i) = xx(i) + dx;         % new model
+        a(:, i) = (feval(theory, xx, param) - f0) ./ dx;
+    else
+        a(:, i) = zeros(numd, 1);
+    end
+end
+
+% Use the 'pseudo-inverse' pinv(a'*a), rather than the
+% true inverse inv(a'*a), because a'a may have zero rows and columns.
+c1 = pinv(a' * a);
+m1 = m0 + c1*(a' * resid);          % updated model
+
+c1 = c1 * rms_residual^2;
+e1 = zeros(numm, 1);
+for i = 1:numm,
+    e1(i) = sqrt(c1(i, i));         % formal standard errors in model parameters
+end
+
+%==========================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/griddataXB.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/griddataXB.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/griddataXB.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,41 @@
+%
+% function [X,Y,Z] = griddataXB(xvec,yvec,zvec,npts,stype)
+% Carl Tape, 09-July-2004
+% printed xxx
+%
+% Copied from griddataX.m on 08-May-2004
+% Converts irregular points to regular points, for mesh plotting.
+%
+% INPUT:
+%   xvec,yvec   = map coordinates of irregular points
+%   zvec        = function values at (xi,yi)
+%   npts        = number of points in horizontal interpolation
+%   stype       = type of interpolation
+%
+% 		'linear'    - Triangle-based linear interpolation (default).
+% 		'cubic'     - Triangle-based cubic interpolation.
+% 		'nearest'   - Nearest neighbor interpolation.
+% 		'v4'        - MATLAB 4 griddata method.
+%
+% OUTPUT:
+%   X,Y         = interpolated mesh
+%   Z           = interpolated function
+%
+% calls xxx
+% called by c164E.m, GPS_A.m, omsplotsF.m
+%
+
+function [X,Y,Z] = griddataXB(xvec, yvec, zvec, npts, stype)
+
+% construct mesh with UNIFORM spacing in x and y directions
+xlin  = linspace(min(xvec), max(xvec), npts);
+dx    = xlin(2) - xlin(1);
+ylin  = [min(yvec) : dx : max(yvec)+dx];
+[X,Y] = meshgrid(xlin,ylin);
+
+%zvec = zvec(:)';    % row vector
+
+% determine interpolated function using xvec,yvec input
+Z = griddata(xvec, yvec, zvec, X, Y, stype);
+
+%==================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/linefit.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/linefit.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/linefit.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,61 @@
+%
+% function [xf,yf,mf,bf,rms] = linefit(x, y)
+% CARL TAPE, 16-June-2005
+% printed xxx
+%
+% This function fits data to a line.
+% Note: With t points, rms = 0.
+% EXAMPLE is shown below.
+% 
+% calls xxx
+% called by c101D.m, c163E.m, c111C.m
+% 
+
+function [xf,yf,mf,bf,rms] = linefit(x,y)
+
+% column vectors
+x = x(:); y = y(:);
+
+% remove NaN or inf
+igood = find( ~isnan(x) .* ~isinf(x) .* ~isnan(y) .* ~isinf(y) == 1 );
+x = x(igood);
+y = y(igood);
+
+% sample xpts
+xf = linspace(min(x), max(x), 100)';
+
+% least-squares fitting
+P = polyfit(x,y,1);
+yf = polyval(P,xf);
+
+mf = P(1);
+bf = P(2);
+res = polyval(P,x) - y;
+rms = sqrt( (res' * res) / length(res) );
+
+if 0==1
+    % EXAMPLE (c101D.m)
+    Srvec = [28.8 48.8 62.3 66.6 72.5 78.6];
+    SrRatio = [0.7151 0.7130 0.7123 0.7112 0.7113 0.7111];
+    [xf,yf,mf,bf,rms] = linefit(SrRatio, 1./Srvec);
+    figure; plot(xf,yf,'r--',SrRatio,1./Srvec,'b.');
+    xlabel('^{87}Sr / ^{86}Sr');
+    ylabel('1/[Sr] (1/ppb)');
+end
+
+%-----------------------------------------------------------
+% older version which requires OPTIMIZATION toolbox
+
+% % initial guess based on the first and last points in data
+% mg = (y(end) - y(1)) / (x(end) - x(1));
+% bg = y(1) - mg*x(1);
+% 
+% ydata = mg*x + bg;
+% fun = inline('x(1)*xdata + x(2)', 'x', 'xdata');
+% F = lsqcurvefit(fun, [x(1) x(end)], x, y);
+%
+% mf = F(1);
+% bf = F(2);
+% yf = mf*xf + bf;
+
+%===============================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ocv_carl.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ocv_carl.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ocv_carl.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,87 @@
+%
+% function rss_vec = ocv_carl(g, A, lamvec)
+% Carl Tape, 30-March-2006
+%
+% Copied from gcv_carl.m on 27-March-2006.
+%
+% Returns the ordinary cross-validation (OCV) function corresponding to a
+% set of input regularization (or damping) parameters.
+%
+% TWO ALGORITHMS ARE SHOWN:
+%   (1) Brute force, which involves ndata inversions per lambda
+%   (2) Elegant formalisum, which involves one inversion per lambda
+%       --> See Latex notes
+%       /home/carltape/classes/acm118/2006_handouts/hw3/hw3sol_2006_prob3.pdf
+%
+% Using some GPS data, I checked that these approaches are identical.
+%
+% calls xxx
+% called by ridge_carl.m
+% 
+
+function rss_vec = ocv_carl(d, A, lamvec)
+
+% Size of inputs
+[ndata, nparm]  = size(A); 
+numlam          = length(lamvec);
+
+if (min(lamvec) < 0)
+    error('Impossible regularization parameter lambda.')
+end
+
+rss_vec = zeros(numlam,1);
+
+% loop over regularization parameters
+for ii=1:numlam
+    lam = lamvec(ii); 
+    disp([' ii = ' num2str(ii) '/' num2str(numlam) ', lam = ' num2str(lam)]);
+    
+    if 1==1
+        H = A*inv(A'*A + lam^2*eye(nparm))*A';
+        dhat = H*d;
+        
+        % OCV residual
+        res = (d - dhat) ./ (1 - diag(H));
+        
+        % sum the residuals
+        rss_vec(ii) = sum(res.^2);
+        
+    else
+        % loop over datapoints
+        for jj=1:ndata
+            %disp([' jj = ' num2str(jj) '/' num2str(ndata) ]);
+
+            % indices for which you compute the model parameters
+            switch jj
+                case 1,     einds = [2:ndata];
+                case ndata, einds = [1:ndata-1];
+                otherwise,  einds = [1:jj-1 jj+1:ndata];
+            end
+
+            % indices to estimate the RSS
+            oinds = jj;
+
+            % reduced matrices
+            X = A(einds,:);
+            g = d(einds);
+
+            % note: regularization matrix is identity matrix
+            f_h = inv(X'*X + lam^2*eye(nparm))*X'*g;
+
+            % estimate the model at the datapoints NOT used
+            res = A(oinds,:) * f_h - d(oinds);
+
+            % sum the residuals
+            rss_vec(ii) = rss_vec(ii) + sum(res.^2);
+        end
+    end
+    
+end
+
+rss_vec = rss_vec / ndata;  % normalization
+
+figure; loglog(lamvec, rss_vec, '.'); grid on;
+xlabel(' Regularization parameter, log (\lambda)');
+ylabel(' RSS at datapoints NOT used in computing model');
+   
+%======================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_min_4.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_min_4.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_min_4.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,123 @@
+%
+% function xmin = quad_min_4(P,x0)
+% Carl Tape, 11-Jan-2006
+% printed xxx
+%
+% This function inputs two (x,y) points and one slope, and returns a
+% quadratic fitting polynomial, along with the (analytical) minimum value.
+%
+% calls quad_shift.m
+% called by model_optimize.m
+%
+
+function [xmin,P1] = quad_min_4(x1,x2,y1,y2,g1,opts,stlabs)
+
+ifig = opts(1);     % =1 to plot figure
+isub = opts(2);     % =1 to plot as a subfigure; =0 to plot as a full figure
+
+if length([x1 x2 y1 y2 g1]) ~= 5, error('check input dimensions'); end
+
+a = ((y2 - y1) - g1*(x2 - x1)) / (x2^2 - x1^2);
+b = g1;
+c = y1 - a*x1^2 - b*x1;
+%c = y2 - a*x2^2 - b*x2;
+
+% ax^2 + bx + c
+P1 = [a b c]';
+
+% a(x-b)^2 + c
+[P2,qvert,stit] = quad_shift(P1,1);
+xmin = qvert(1);
+
+if ifig==1
+    if isub==1
+        specs = [1 6 12 10]; fac = 0.1;
+    else
+        figure;
+        specs = [2 14 18 12]; fac = 0.05;
+    end
+    
+    % step COULD be negative (source inversion)
+    temp = sort([x1 x2]);
+    x1plot = temp(1);
+    x2plot = temp(2);
+    if x1 ~= x1plot
+        iflip = 1;
+        stlabs = [stlabs(1:2) fliplr(stlabs(3:5))]
+    end
+    
+    axpoly = axes_expand([x1plot x2plot 0 max([y1 y2])],1.2);
+    axpoly(3) = 0;
+    dy = axpoly(4) - axpoly(3);
+    dx = axpoly(2) - axpoly(1);
+    ylab = axpoly(3) - fac*dy;
+    
+    ymin = polyval(P1,xmin);  % quadratic function evaluation
+
+    % base level for test-model parabola
+    K = 0.5;
+    %K = 0.0;   % no model norm term or data errors
+    
+    % initial guess is based on a quadratic fit
+    %aquad = g1^2/(4*y1);
+    aquad = -g1^2/(4*(K - y1));
+    Pquad = [aquad g1 y1]';
+    
+    % x-points for smooth curves
+    n = 100; xpts = linspace(axpoly(1),axpoly(2),n);
+    
+    % curves through (x1,y1)
+    g1_line = polyval([g1 y1-g1*x1],xpts);
+    g1_test = polyval(Pquad,xpts);
+    g1_quad = polyval(P1,xpts);
+
+    hold on;
+    
+    % plot curves
+    plot(xpts,g1_quad,'b','linewidth',specs(1));
+    plot(xpts,g1_test,'b--');
+    plot(xpts,g1_line,'r--');
+    
+    % plot black lines
+    plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+    plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+    plot([xmin xmin axpoly(1)],[0 ymin ymin],'k--');
+    
+    % plot markers
+    plot([x1 x2],[y1 y2],'ko','markersize',specs(2),'MarkerFaceColor','b');
+    plot(xmin,ymin,'bo',x2,0,'bo',xmin,0,'bo','markersize',specs(2),'MarkerFaceColor','w');
+    %plot(0.5*x2,0,'go','markersize',specs(2),'MarkerFaceColor','w');  % linear projection
+
+    axis(axpoly);
+    xlabel(stlabs{1},'fontsize',specs(3));
+    ylabel(stlabs{2},'fontsize',specs(3));
+    if isub==0
+        title({stit{1},stit{2}},'fontsize',specs(3))
+        grid on;
+    else
+        set(gca,'xtick',[x1plot x2plot],'xticklabel',{[],[]}); 
+        %set(gca,'xtick',[x1plot xmin x2plot]),'xticklabel',{'0',[],[]};
+    end
+    text(x1plot,ylab,stlabs{3},'fontsize',specs(4));
+    text(xmin,ylab,stlabs{4},'fontsize',specs(4));
+    text(x2plot,ylab,stlabs{5},'fontsize',specs(4));
+     orient tall, wysiwyg
+end
+
+if 0==1
+   x1 = 0
+   x2 = randomint(1,5,1)
+   y1 = randomint(1,5,1)
+   y2 = randomint(1,5,1)
+   g1 = randomint(-5,-1,1)
+
+   opts = [1 0];
+   stk  = num2str(0);
+   stlabs = {'\lambda',['\chi^{' stk '} ( \lambda )'],'0',['\lambda_{' stk '}'],['\lambda_{' stk 't}']};
+   
+   [xmin,P1] = quad_min_4(x1,x2,y1,y2,g1,opts,stlabs);
+   set(gca,'xtick',[-10:10],'ytick',[-10:10]);
+   axis equal;
+end
+
+%=========================================================
\ No newline at end of file

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_shift.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_shift.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/quad_shift.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,66 @@
+%
+% function [Pout,qvert,stit] = quad_shift(Pin,opts)
+% Carl Tape, 11-Jan-2006
+% printed xxx
+%
+% This function adjusts parabola (i.e., quadratic polynomial) coefficients 
+% between two representations, and also returns the vertex.
+%
+% See also cubic_shift.m
+%
+% calls xxx
+% called by test_poly.m
+%
+
+function [Pout,qvert,stit] = quad_shift(Pin,opts)
+
+iopt = opts(1);
+stx = '%.3f';
+
+P = Pin(:);
+a = Pin(1);
+b = Pin(2);
+c = Pin(3);
+
+% adjust the polynomial coefficients
+if iopt == 1
+    % ax^2 + bx + c --> a(x-b)^2 + c
+    Pout(1) = a;
+    Pout(2) = -b/(2*a);
+    Pout(3) = c - b^2/(4*a);
+    
+    qvert = [Pout(2) Pout(3)];
+    
+    stit1 = ['y = ' num2str(sprintf(stx, a)) ' x^2  +  ' ...
+                    num2str(sprintf(stx, b)) ' x  +  ' ...
+                    num2str(sprintf(stx, c)) ];  
+    stit2 = ['y = ' num2str(sprintf(stx, Pout(1))) ' (x - ' ...
+                    num2str(sprintf(stx, Pout(2))) ')^2  +  ' ...
+                    num2str(sprintf(stx, Pout(3))) ];
+    
+else
+    % a(x-b)^2 + c --> ax^2 + bx + c
+    if a==0
+        Pout(1) = 0;
+        Pout(2) = 0;
+        Pout(3) = c;
+        qvert = [NaN NaN];
+    else
+        Pout(1) = a;
+        Pout(2) = -2*a*b;
+        Pout(3) = a*b^2 + c;
+        qvert = [b c];
+    end
+    
+    stit1 = ['y = ' num2str(sprintf(stx, Pout(1))) ' x^2  +  ' ...
+                    num2str(sprintf(stx, Pout(2))) ' x  +  ' ...
+                    num2str(sprintf(stx, Pout(3))) ];
+    stit2 = ['y = ' num2str(sprintf(stx, a)) ' (x - ' ...
+                    num2str(sprintf(stx, b)) ')^2  +  ' ...
+                    num2str(sprintf(stx, c)) ];
+end
+
+Pout = Pout(:);
+stit = {stit1,stit2};
+
+%=========================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ridge_carl.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ridge_carl.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/ridge_carl.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,227 @@
+%
+% function 
+% Carl Tape (Tapio Schneider, ACM 118)
+% 06-Nov-2006
+% 
+% This function inputs a design matrix, a data vector, and a vector of
+% regularization parameters, and it returns three different curves that may
+% be used to select the best parameter:
+%    (1) L-curve and curvature
+%    (2) generalized cross-validation curve (GCV)
+%    (3) ordinary cross-validation (OCV), also known as 'leave-one-out' CV
+%
+% It is best to input a large number of regularization parameters, so that
+% the min and max of the respective functions can be easily obtained.
+%
+% This program is copied in part from ridge_tapio.m
+%
+% NOTE THE PLOTTING OPTIONS.
+% 
+%-------------------------------------------------
+% RIDGE  Ridge regression estimates.
+%
+%    Given a vector g, a design matrix X, and
+%    a regularization parameter h, 
+%           
+%           [m, rss, mss, dof] = ridge_tapio(g, X, h) 
+% 
+%    returns the ridge regression estimate of the vector f in the
+%    linear regression model
+% 
+%           g = X*f + noise.
+%
+%    Also returned are the residual sum of squares rss, the sum of
+%    squares mss of the elements of the ridge regression estimate
+%    m (the squared norm of m), and the effective number of
+%    residual degrees of freedom dof.
+%
+%    If h is a vector of regularization parameters, the i-th column
+%    m(:,i) is the ridge regression estimate for the regularization
+%    parameter h(i); the i-th elements of rss and mss are the
+%    associated residual sum of squares and estimate sum of squares.
+%
+%    If no regularization parameter h is given, generalized
+%    cross-validation is used to determine the regularization
+%    parameter. The chosen regularization parameter h and the value of
+%    the GCV function are then returned as the fifth and sixth
+%    output arguments 
+%
+%            [m, rss, mss, dof, h, G] = ridge_tapio(g, X);
+% 
+%    Adapted from various routines in Per Christian Hansen's
+%    Regularization Toolbox.
+%
+% calls gcvfctn.m, curvature.m
+% called by xxx
+% 
+
+function [m, rss, mss, Gvec, Fvec, dof, kap, iL, iGCV, iOCV] = ridge_carl(dvec, X, hvec)
+
+% Size of inputs
+[n, p]      = size(X); 
+q           = min(n, p);
+nh          = length(hvec);
+if (min(hvec) < 0)
+    error('Impossible regularization parameter h.')
+end
+
+% Initialize outputs
+m         = zeros(p, nh);
+rss         = zeros(nh, 1); 
+mss      = zeros(nh, 1);
+dof         = zeros(nh, 1);
+
+% Compute SVD of X
+[U, S, V]   = svd(X, 0);  
+s           = diag(S);      % vector of singular values
+s2          = s.^2;
+
+% Coefficients in expansion of solution in terms of right singular vectors
+fc          = U(:, 1:q)'*dvec;
+zeta        = s .* fc;
+
+% Treat each regularization parameter separately
+for j = 1:nh    
+    m(:, j) = V(:, 1:q) * (zeta ./ (s2 + hvec(j)^2));
+    mss(j)  = sum(m(:, j).^2);
+    rss(j)  = hvec(j)^4 * sum(fc.^2 ./ (s2 + hvec(j)^2).^2);
+    dof(j)  = n - sum(s2./(s2 + hvec(j)^2));
+end
+
+% In overdetermined case, add rss of least-squares problem
+if (n > p)
+    rss = rss + sum((dvec - U(:, 1:q)*fc).^2);
+end
+
+%-----------------------
+% determine the Lcurve pick (max curvature)
+
+x1 = log10(rss);
+y1 = log10(mss);
+
+% % smooth curvature interpolation to get h_L
+% num = 1000;
+% xsmooth = linspace(x1(1),x1(end),1000);
+% ysmooth = interp1(x1,y1,xsmooth,'cubic');
+% [i0,kap_smooth] = curvature(xsmooth,ysmooth);
+% rss_L = 10^xsmooth(i0);
+% mss_L = 10^ysmooth(i0);
+% h_L = 10^interp1(x1,log10(hvec),xsmooth(i0),'cubic');
+
+% curvature, based on input h values alone
+[iL,kap] = curvature(x1,y1);
+%h_L = hvec(iL);
+%rss_L = 10^x1(iL);
+%mss_L = 10^y1(iL);
+
+%-----------------------
+% obtain GCV `best' solution and GCV curve
+
+% GCV minimum -- 'exact' in the sense a minimization method is used
+% [hmin, Gmin] = gcv_tapio(U, s, dvec, 'ridge');
+
+% GCV minimum -- 'crude' in the sense that we coarsely sample the function
+dof0 = n-q;
+rss0 = sum((dvec - U(:, 1:q)*fc).^2);
+Gvec = zeros(nh,1);
+for j = 1:nh 
+    Gvec(j) = gcvfctn(hvec(j), s2, fc, rss0, dof0);
+end
+[Gmin,iGCV] = min(Gvec);
+%hmin = hvec(iGCV);
+
+% GCV best model and L-curve point for h_GCV (= hmin)
+%mod_min = inv(X'*X + hmin^2*eye(p))*X'*dvec;
+%res = X*mod_min - dvec;
+%rss_min = sum(res.^2);
+%mss_min = sum(mod_min.^2);
+
+% compute G for the Lcurve pick
+%G_L = gcvfctn(h_L, s2, fc, rss0, dof0);
+
+%-----------------------
+% ordinary (leave-one-out) cross-validation
+
+Fvec = ocv_carl(dvec, X, hvec);
+[Fmin,iOCV] = min(Fvec);
+
+%======================================================
+% PLOTTING
+
+lamL = hvec(iL);   GL = Gvec(iL);   rssL = rss(iL);   mssL = mss(iL);   kapL = kap(iL);    FL = Fvec(iL); 
+lamF = hvec(iOCV); GF = Gvec(iOCV); rssF = rss(iOCV); mssF = mss(iOCV); kapF = kap(iOCV);  FF = Fvec(iOCV);
+lamG = hvec(iGCV); GG = Gvec(iGCV); rssG = rss(iGCV); mssG = mss(iGCV); kapG = kap(iGCV);  FG = Fvec(iGCV); 
+
+x1 = log10(rss);
+y1 = log10(mss);
+x2 = log10(hvec);
+y2 = kap;
+x3 = log10(hvec);
+y3 = log10(Fvec);
+x4 = log10(hvec);
+y4 = log10(Gvec);
+
+stx1 = ' Misfit norm, log10 RSS';
+sty1 = ' Model norm, log10 MSS';
+stx2 = ' Regularization parameter, log10 \lambda';
+sty2 = ' Curvature of L-curve, \kappa(\lambda)';
+stx3 = stx2;
+sty3 = ' OCV function, log10 F(\lambda)';
+stx4 = stx2;
+sty4 = ' GCV function, log10 G(\lambda)';
+
+%stfm = '%.4f';
+stfm = '%.2e';
+stlam_L   = [' \lambda-L = ' num2str(sprintf(stfm, lamL))];
+stlam_ocv = [' \lambda-OCV = ' num2str(sprintf(stfm, lamF))];
+stlam_gcv = [' \lambda-GCV = ' num2str(sprintf(stfm, lamG))];
+
+%------------------------
+figure; nr=2; nc=2;
+msize = 8;
+nlab = 10; ilabs = round(linspace(1,nh,nlab));
+    
+subplot(nr,nc,1); hold on;
+plot(x1,y1,'.');
+plot(log10(rssL),log10(mssL),'ko','markersize',8,'MarkerFaceColor','r');
+plot(log10(rssG),log10(mssG),'kV','markersize',8,'MarkerFaceColor','g');
+plot(log10(rssF),log10(mssF),'k^','markersize',8,'MarkerFaceColor','c');
+axis tight; ax1 = axis; axis(axes_expand(ax1,1.1));
+axy = axis; dx = axy(2)-axy(1);
+for kk=1:nlab
+   ii = ilabs(kk);
+   text(x1(ii)+dx*0.02,y1(ii),[num2str(sprintf(stfm, hvec(ii)))],'fontsize',8,'color','b');
+end
+legend(' \lambda',stlam_L,stlam_gcv,stlam_ocv);
+xlabel(stx1); ylabel(sty1); grid on;
+
+subplot(nr,nc,2); hold on;
+plot(x2,y2,'.');
+plot(log10(lamL),kapL,'ko','markersize',8,'MarkerFaceColor','r');
+plot(log10(lamG),kapG,'kV','markersize',8,'MarkerFaceColor','g');
+plot(log10(lamF),kapF,'k^','markersize',8,'MarkerFaceColor','c');
+axis tight; ax1 = axis; axis(axes_expand(ax1,1.1));
+legend(' \lambda',stlam_L,stlam_gcv,stlam_ocv,'location','northwest');
+xlabel(stx2); ylabel(sty2); grid on;
+
+subplot(nr,nc,3); hold on;
+plot(x3,y3,'.');
+plot(log10(lamL),log10(FL),'ko','markersize',8,'MarkerFaceColor','r');
+plot(log10(lamG),log10(FG),'kV','markersize',8,'MarkerFaceColor','g');
+plot(log10(lamF),log10(FF),'k^','markersize',8,'MarkerFaceColor','c');
+axis tight; ax1 = axis; axis(axes_expand(ax1,1.1));
+legend(' \lambda',stlam_L,stlam_gcv,stlam_ocv,'location','northeast');
+xlabel(stx3); ylabel(sty3); grid on;
+
+subplot(nr,nc,4); hold on;
+plot(x4,y4,'.');
+plot(log10(lamL),log10(GL),'ko','markersize',8,'MarkerFaceColor','r');
+plot(log10(lamG),log10(GG),'kV','markersize',8,'MarkerFaceColor','g');
+plot(log10(lamF),log10(GF),'k^','markersize',8,'MarkerFaceColor','c');
+axis tight; ax1 = axis; axis(axes_expand(ax1,1.1));
+legend(' \lambda',stlam_L,stlam_gcv,stlam_ocv,'location','northwest');
+xlabel(stx4); ylabel(sty4); grid on;
+
+orient tall, wysiwyg, fontsize(9)
+   
+%======================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/theoryHyp.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/theoryHyp.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/theoryHyp.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,37 @@
+%
+% function y = theoryHyp(m, param)
+% CARL TAPE, 15-Nov-2003
+% printed xxx
+%
+% Output is a set of y-data based on four
+% parameters that describe the hyperbola.
+%
+% hyperbola: Ax + Bxy + Cy + D = 0
+%
+% Note that this is a LINEAR problem, Ax = b : 
+%
+%    |  x   x*y    y   1  | | A |   | 0 |
+%    |  :    :     :   :  | | B | = | : |
+%    |  :    :     :   :  | | C |   | : |
+%    |  :    :     :   :  | | D |   | : |
+%    |  :    :     :   :  |         | : |
+%
+% 
+% See /matlab/scicomp/getellipse.m
+%
+% calls xxx
+% called by c101D.m, testgenfitC.m, model_optimize2.m
+%
+
+function y = theoryHyp(m, param)
+
+% input parameters (x-coordinates of data)
+x = param(:);
+
+% model parameters that we solve for
+A = m(1); B = m(2); C = m(3); D = m(4);
+
+% hyperbola: Ax + Bxy + Cy + D = 0
+y = (-A*x - D) ./ (B*x + C);
+
+%================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_figs.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_figs.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_figs.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,431 @@
+%
+% wave2d_cg_figs.m
+% CARL TAPE, 21-Nov-2008
+% printed xxx
+%
+% This program is called following wave2d_cg_poly.m.
+%
+% calls xxx
+% called by xxx
+%
+
+%irun0 = 140;
+
+stfm = '%4.4i';
+
+% axes limits
+n1 = 0;
+n2 = 8;
+n2 = 17;
+%ax_chi = [n1-1 n2 10^0 axpoly(4)];
+%ax_chi = [n1-1 n2 10.^[0 4]];
+ax_chi = [n1-1 n2 10.^[-1 3] ];
+ax_var = [n1-1 n2 0 100];
+
+%n2 = 4; ax_chi = [n1-1 n2 10^-2 10^3];
+
+% USER: change this
+dir0 = '/home/carltape/wave2d/SEM2D_iterate/PLOTTING/DATA_FILES/';
+if ~exist(dir0), error([dir0 ' does not exist']); end
+
+%==================================================================
+
+ww = ['poly_run' num2str(sprintf(stfm,irun0))];
+if 1==1
+    save(ww,'ax_chi','ax_var','its','chis','its_smooth','chifit_smooth',...
+        'x_var_fit','var_red1_fit','x_var','var_red1',...
+        'axpoly','xpts','g1_line','g1_quad_test','g1_cube_fit','g2_line','g1_quad_fit',...
+        'x1','y1','x2','y2','xmin','ymin','chi');
+    %break
+else
+    load(ww);
+end
+
+specs = [1 6 12 10];
+xticks = [n1:n2];
+
+if 1==1    
+    % write curves to file
+    ww = ['poly_curve_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    for ii=1:length(xpts)
+        fprintf(fid,'%16.7e%16.7e%16.7e%16.7e%16.7e%16.7e\n',...
+            xpts(ii),g1_line(ii),g2_line(ii),g1_quad_test(ii),g1_cube_fit(ii),g1_quad_fit(ii) );   
+    end
+    fclose(fid);
+    
+    % write points to file
+    ww = ['poly_points_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    xptsQ = [x1 x2 x2 xmin xmin xmin   0];
+    yptsQ = [y1  0 y2    0 ymin  chi chi];
+    for ii=1:length(xptsQ)
+        fprintf(fid,'%16.7e %16.7e \n',xptsQ(ii),yptsQ(ii) );   
+    end
+    fclose(fid);
+    
+    % write chi fit to file
+    ww = ['chi_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    for ii=1:length(chis)
+        fprintf(fid,'%16.7e %16.7e \n',its(ii),chis(ii) );   
+    end
+    fclose(fid);
+    
+    % write chi fit to file
+    ww = ['chi_curve_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    for ii=1:length(chifit_smooth)
+        fprintf(fid,'%16.7e %16.7e \n',its_smooth(ii),chifit_smooth(ii) );   
+    end
+    fclose(fid);
+    
+    % write var fit to file
+    ww = ['var_fit_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    for ii=1:length(var_red1_fit)
+        fprintf(fid,'%16.7e %16.7e \n',x_var_fit(ii),var_red1_fit(ii) );   
+    end
+    fclose(fid);
+    
+    % write var to file
+    ww = ['var_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    for ii=1:length(var_red1)
+        fprintf(fid,'%16.7e %16.7e \n',x_var(ii),var_red1(ii) );   
+    end
+    fclose(fid);
+    
+    % write axes to file
+    ww = ['axes_' num2str(sprintf(stfm, irun0)) '.dat'];
+    fid = fopen([dir0 ww],'w');
+    fprintf(fid,'%16.7e %16.7e %16.7e %16.7e \n',axpoly(1),axpoly(2),axpoly(3),axpoly(4));
+    fprintf(fid,'%16.7e %16.7e %16.7e %16.7e \n',ax_chi(1),ax_chi(2),ax_chi(3),ax_chi(4));
+    fprintf(fid,'%16.7e %16.7e %16.7e %16.7e \n',ax_var(1),ax_var(2),ax_var(3),ax_var(4));
+    fclose(fid);
+end
+    
+figure; nr=5; nc=4;
+subplot(nr,nc,1);  hold on; 
+
+subplot(nr,nc,2);  hold on; 
+
+subplot(nr,nc,3);  hold on;
+
+subplot(nr,nc,4);  hold on; axis(axpoly);
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot(x1,y1,'ko','markersize',specs(2),'MarkerFaceColor','b');
+
+subplot(nr,nc,5);  hold on; 
+
+subplot(nr,nc,6);  hold on; axis(axpoly);
+plot(xpts,g1_line,'r--');
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot(x1,y1,'ko','markersize',specs(2),'MarkerFaceColor','b');
+
+subplot(nr,nc,7);  hold on; axis(axpoly);
+plot(xpts,g1_line,'r--');
+plot(xpts,g1_quad_test,'b--');
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot(x1,y1,'ko','markersize',specs(2),'MarkerFaceColor','b');
+plot(x2,0,'bo','markersize',specs(2),'MarkerFaceColor','w');
+
+subplot(nr,nc,8);  hold on; 
+
+subplot(nr,nc,9);  hold on; 
+
+subplot(nr,nc,10); hold on; axis(axpoly);
+plot(xpts,g1_line,'r--');
+plot(xpts,g1_quad_test,'b--');
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+plot(x1,y1,'ko','markersize',specs(2),'MarkerFaceColor','b');
+plot(x2,0,'bo','markersize',specs(2),'MarkerFaceColor','w');
+plot(x2,y2,'ko','markersize',specs(2),'MarkerFaceColor','b');
+
+subplot(nr,nc,11); hold on; 
+
+subplot(nr,nc,12); hold on; axis(axpoly);
+plot(xpts,g1_line,'r--',xpts,g2_line,'r--');
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+plot([x1 x2],[y1 y2],'ko','markersize',specs(2),'MarkerFaceColor','b');
+plot(x2,0,'bo','markersize',specs(2),'MarkerFaceColor','w');
+
+subplot(nr,nc,13); hold on; axis(axpoly);
+plot(xpts,g1_cube_fit,'b','linewidth',specs(1));
+plot(xpts,g1_line,'r--',xpts,g2_line,'r--');
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+plot([xmin xmin axpoly(1)],[0 ymin ymin],'k--');
+plot([x1 x2],[y1 y2],'ko','markersize',specs(2),'MarkerFaceColor','b');
+plot(xmin,ymin,'bo',xmin,0,'bo','markersize',specs(2),'MarkerFaceColor','w'); 
+
+subplot(nr,nc,14); hold on; 
+
+subplot(nr,nc,15); hold on; 
+
+subplot(nr,nc,16); hold on; axis(axpoly);
+plot(xpts,g1_cube_fit,'b','linewidth',specs(1));
+plot(xpts,g1_line,'r--',xpts,g2_line,'r--');
+plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+plot([xmin xmin axpoly(1)],[0 ymin ymin],'k--');
+plot([xmin xmin axpoly(1)],[0 chi chi],'k');
+plot([x1 x2],[y1 y2],'ko','markersize',specs(2),'MarkerFaceColor','b');
+plot(xmin,ymin,'bo',xmin,0,'bo','markersize',specs(2),'MarkerFaceColor','w'); 
+plot(xmin,chi,'ko','markersize',specs(2),'MarkerFaceColor','b');
+
+
+subplot(nr,nc,17); hold on; axis(axpoly);
+plot([x1 x1 axpoly(1)],[0 ymin ymin],'k');
+plot(x1,ymin,'ko','markersize',specs(2),'MarkerFaceColor','b');
+
+%subplot(nr,nc,18); hold on; 
+
+subplot(nr,nc,19);
+semilogy(its_smooth,chifit_smooth,'r--',its(1:2),chis(1:2),'bo',...
+    'linewidth',specs(1),'markersize',specs(2),'MarkerFaceColor','b');
+set(gca,'xtick',xticks,'ytick',[10 100 1000 2000 6000])
+xlabel(' model number (iteration)'); ylabel(' \chi(m)');
+axis(ax_chi);
+
+subplot(nr,nc,20); hold on; axis(ax_var);
+plot(x_var_fit,var_red1_fit,'r--','markersize',specs(2),'linewidth',specs(1));
+plot(x_var(1),var_red1(1),'bo','markersize',specs(2),'MarkerFaceColor','b');
+set(gca,'xtick',xticks,'ytick',[0:20:100]);
+xlabel(' model number (iteration)');
+ylabel(' variance reduction');
+
+fontsize(8); orient tall, wysiwyg
+
+%======================================================================
+
+break
+
+irun0_vec = [400:20:500];
+gam_vec  = [15:15:90]';
+nrun = length(irun0_vec);
+
+niter = 8;
+
+nr=5; nc=2;
+m1 = counter(1,5,1,2);
+for k = 0:niter
+    jj = m1(k+1);
+    if mod(jj,5)==1, fontsize(7), orient tall, wysiwyg, figure; end
+    disp([k jj jj*2-1 jj*2]);
+
+    % load the chi values for this irun0 sequence
+    stfm = '%3.3i';
+    dir0 = '/home/carltape/wave2d/2d_adjoint/OUTPUT/';
+    chi_vec = zeros(nrun,1);
+    for ii=1:nrun
+        irun = irun0_vec(ii) + k*2;
+        stf = [dir0 'run_' num2str(sprintf(stfm,irun)) '/'];
+        ww = 'summed_chi_all';
+        load([stf ww '.dat']);
+        chi = eval(ww);
+        chi_vec(ii) = chi;
+        irun_vec(ii) = irun;
+    end
+
+    subplot(nr,nc,jj*2-1); hold on;
+    plot(1./gam_vec,chi_vec,'b.-','markersize',24);
+
+    alims = axis;
+    dy = alims(4) - alims(3);
+    dx = alims(2) - alims(1);
+
+    for ii=1:nrun
+       irun = irun0_vec(ii) + k*2;
+       text(1/gam_vec(ii),chi_vec(ii)+0.05*dy,...
+           [ num2str(sprintf('%.1f', gam_vec(ii))) ' km (' num2str(irun) ')'],'fontsize',6);
+       %text(1/gam_vec(ii),chi_vec(ii)+0.05*dy,[num2str(sprintf('%.1f', gam_vec(ii))) ' km'],'fontsize',6);
+       %text(1/gam_vec(ii),chi_vec(ii)-0.05*dy,['(irun = ' num2str(irun_vec(ii)) ')'],'fontsize',6);
+    end
+    grid on;
+    %xlabel(' roughness, 1 / \gamma  (\gamma determines Gaussian width for smoothing)');
+    %ylabel(' misfit for m8');
+    ylabel(['chi-vs-(1/\gamma) for model m' num2str(k)]);
+
+    subplot(nr,nc,jj*2); hold on;
+    plot(gam_vec,chi_vec,'b.-','markersize',24);
+    for ii=1:nrun
+       irun = irun0_vec(ii) + k*2;
+       text(gam_vec(ii),chi_vec(ii)+0.05*dy,...
+           [ num2str(sprintf('%.1f', gam_vec(ii))) ' km (' num2str(irun) ')'],'fontsize',6);
+       %text(gam_vec(ii),chi_vec(ii)+0.05*dy,[num2str(sprintf('%.1f', gam_vec(ii))) ' km'],'fontsize',6);
+       %text(gam_vec(ii),chi_vec(ii)-0.05*dy,['(irun = ' num2str(irun) ')'],'fontsize',6);
+    end
+    grid on;
+    %xlabel(' smoothing, \sigma  (\sigma determines Gaussian width for smoothing)');
+    %ylabel(' misfit for m8');
+    ylabel(['chi-vs-\gamma for model m' num2str(k)]);
+end
+fontsize(7), orient tall, wysiwyg
+
+%---------------
+
+figure; hold on;
+
+stc = {'r','y','g','b','m','k'};
+
+dir0 = '/home/carltape/wave2d/2d_adjoint/gji_paper/figures/';
+for ii=1:nrun
+   irun0 = irun0_vec(ii);
+
+   % fitting curve
+   ww = ['chi_curve_' num2str(sprintf(stfm, irun0)) ];
+   load([dir0 ww '.dat']); temp = eval(ww);
+   its_smooth = temp(:,1);
+   chi_smooth = temp(:,2);
+   
+   %ww = ['chi_' num2str(sprintf(stfm, irun0)) ];
+   %load([dir0 ww '.dat']); temp = eval(ww);
+   %its = temp(:,1);
+   %chis = temp(:,2);
+   
+   plot(its_smooth,log10(chi_smooth),stc{ii});
+   %plot(its,log10(chis),[stc{ii} '.'],'markersize',16);
+end
+grid on; xlabel(' iteration'); ylabel(' log10(chi)');
+legend(['\gamma = ' num2str(gam_vec(1))],['\gamma = ' num2str(gam_vec(2))],['\gamma = ' num2str(gam_vec(3))],...
+       ['\gamma = ' num2str(gam_vec(4))],['\gamma = ' num2str(gam_vec(5))],['\gamma = ' num2str(gam_vec(6))]);
+for ii=1:nrun
+   irun0 = irun0_vec(ii);
+   ww = ['chi_' num2str(sprintf(stfm, irun0)) ];
+   load([dir0 ww '.dat']); temp = eval(ww);
+   its = temp(:,1);
+   chis = temp(:,2);
+   plot(its,log10(chis),[stc{ii} '.'],'markersize',16);
+end   
+
+
+if 0==1
+   dir0 = '/home/store2/carltape/OUTPUT/run_001/';
+   dir1 = [dir0 'event_001/'];
+   
+   % load source time function
+   ww = 'stffor_00001_1'; load([dir1 ww]); temp = eval(ww);
+   ti = temp(:,1); f = temp(:,2);
+   
+   % load data, synthetics, adjoint source
+   ww = 'dat_00001_1'; load([dir1 ww]); temp = eval(ww); s_dat = temp(:,2);
+   ww = 'syn_00001_1'; load([dir1 ww]); temp = eval(ww); s_syn = temp(:,2);
+   ww = 'stfadj_00001_1'; load([dir1 ww]); temp = eval(ww); f_adj = temp(:,2);
+   
+   % compute velocity
+   sv_dat = gradient(s_dat,ti);
+   sv_syn = gradient(s_syn,ti);
+   
+   % specify cut time for time series
+   tall = [ti f s_dat s_syn sv_dat sv_syn f_adj];
+   tmax = 175;
+   ikeep = find(ti <= tmax);
+   tall = tall(ikeep,:);
+   ti = tall(:,1);
+   tall(:,7) = flipud(tall(:,7));
+   
+   % axes limits
+   pwr_vec = [8 -4 -4 4];
+   cmx_vec = [4 5 2 2];
+   for ii=1:length(pwr_vec), max_vec(ii) = cmx_vec(ii) * 10^pwr_vec(ii); end
+   ax_mat = [0 tmax -max_vec(1) max_vec(1) 
+             0 tmax -max_vec(2) max_vec(2)
+             0 tmax -max_vec(3) max_vec(3)
+             0 tmax -max_vec(4) max_vec(4) ];
+   
+   % plot
+   figure; nr=4; nc=1;
+   subplot(nr,nc,1); plot(ti,tall(:,2),'b'); axis(ax_mat(1,:)); ylabel(' source time function');
+   subplot(nr,nc,2); plot(ti,tall(:,4),'r--',ti,tall(:,3),'b'); axis(ax_mat(2,:)); ylabel(' displacement (data, syn)');
+   subplot(nr,nc,3); plot(ti,tall(:,6),'r--',ti,tall(:,5),'b'); axis(ax_mat(3,:)); ylabel(' velocity (data, syn)');
+   subplot(nr,nc,4); plot(ti,tall(:,7),'b'); axis(ax_mat(4,:)); ylabel(' tt xcorr adjoint source');
+   fontsize(8); orient tall, wysiwyg
+   
+   % write the data to a file
+   ww = ['time_series.dat'];
+   fid = fopen([dir0 ww],'w');
+   for ii=1:length(ti)
+       fprintf(fid,'%16.7e%16.7e%16.7e%16.7e%16.7e%16.7e%16.7e\n',...
+           tall(ii,1),tall(ii,2),tall(ii,3),tall(ii,4),tall(ii,5),tall(ii,6),tall(ii,7));   
+   end
+   fclose(fid);
+   
+   % write the axes info to file
+   ww = ['time_series_axes.dat'];
+   fid = fopen([dir0 ww],'w');
+   fprintf(fid,'%16i%16i%16i%16i\n',pwr_vec(1),pwr_vec(2),pwr_vec(3),pwr_vec(4));
+   fprintf(fid,'%16i%16i%16i%16i\n',cmx_vec(1),cmx_vec(2),cmx_vec(3),cmx_vec(4));
+   for ii=1:length(ax_mat)
+       fprintf(fid,'%16.7e%16.7e%16.7e%16.7e\n',...
+           ax_mat(ii,1),ax_mat(ii,2),ax_mat(ii,3),ax_mat(ii,4));   
+   end
+   fclose(fid);
+end
+
+if 0==1
+   dir0 = '/home/store2/carltape/OUTPUT/run_002/';   % note run 002
+   dir1 = [dir0 'event_001/'];
+   
+   % load source time function, synthetics, adjoint source
+   ww = 'stffor_00001_1'; load([dir1 ww]); temp = eval(ww); ti = temp(:,1); f = temp(:,2);
+   ww = 'syn_00001_1'; load([dir1 ww]); temp = eval(ww); s_syn = temp(:,2);
+   ww = 'stfadj_00001_1'; load([dir1 ww]); temp = eval(ww); f_adj = temp(:,2);
+   
+   % compute velocity
+   sv_syn = gradient(s_syn,ti);
+   
+   % specify cut time for time series
+   tall = zeros(length(ti),7);
+   tall(:,1) = ti;
+   tall(:,2) = f;
+   tall(:,4) = s_syn;
+   tall(:,6) = sv_syn;
+   tall(:,7) = f_adj;
+   tmax = 175;
+   ikeep = find(ti <= tmax);
+   tall = tall(ikeep,:);
+   ti = tall(:,1);
+   tall(:,7) = flipud(tall(:,7));
+   
+   % axes limits
+   pwr_vec = [8 -4 -4 3];
+   cmx_vec = [4 5 1.8 2];
+   for ii=1:length(pwr_vec), max_vec(ii) = cmx_vec(ii) * 10^pwr_vec(ii); end
+   ax_mat = [0 tmax -max_vec(1) max_vec(1) 
+             0 tmax -max_vec(2) max_vec(2)
+             0 tmax -max_vec(3) max_vec(3)
+             0 tmax -max_vec(4) max_vec(4) ];
+   
+   % plot
+   figure; nr=4; nc=1;
+   subplot(nr,nc,1); plot(ti,tall(:,2),'b'); axis(ax_mat(1,:)); ylabel(' source time function');
+   subplot(nr,nc,2); plot(ti,tall(:,4),'r--'); axis(ax_mat(2,:)); ylabel(' displacement (syn)');
+   subplot(nr,nc,3); plot(ti,tall(:,6),'r--'); axis(ax_mat(3,:)); ylabel(' velocity (syn)');
+   subplot(nr,nc,4); plot(ti,tall(:,7),'b'); axis(ax_mat(4,:)); ylabel(' tt xcorr adjoint source');
+   fontsize(8); orient tall, wysiwyg
+   
+   % write the data to a file
+   ww = ['time_series.dat'];
+   fid = fopen([dir0 ww],'w');
+   for ii=1:length(ti)
+       fprintf(fid,'%16.7e%16.7e%16.7e%16.7e%16.7e%16.7e%16.7e\n',...
+           tall(ii,1),tall(ii,2),tall(ii,3),tall(ii,4),tall(ii,5),tall(ii,6),tall(ii,7));   
+   end
+   fclose(fid);
+   
+   % write the axes info to file
+   ww = ['time_series_axes.dat'];
+   fid = fopen([dir0 ww],'w');
+   fprintf(fid,'%16i%16i%16i%16i\n',pwr_vec(1),pwr_vec(2),pwr_vec(3),pwr_vec(4));
+   fprintf(fid,'%16i%16i%16i%16i\n',cmx_vec(1),cmx_vec(2),cmx_vec(3),cmx_vec(4));
+   for ii=1:length(ax_mat)
+       fprintf(fid,'%16.7e%16.7e%16.7e%16.7e\n',...
+           ax_mat(ii,1),ax_mat(ii,2),ax_mat(ii,3),ax_mat(ii,4));   
+   end
+   fclose(fid);
+end
+   
+%===============================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_poly.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_poly.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_cg_poly.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,562 @@
+%
+% wave2d_cg_poly.m
+% CARL TAPE, 21-Nov-2008
+% printed xxx
+% 
+% This program takes the output from wave2d.f90 and plots the polynomials
+% used in the line-search conjugate gradient algorithm within the code.
+%
+% For GMT plotting, we execute wave2d_cg_figs.m after this program.
+%
+% calls
+%   get_model_vec.m
+%   cubic_min_4.m
+%   genfit.m
+%   theoryHyp.m
+%   quad_shift.m
+%   linefit.m
+%   axes_expand.m, fontsize.m, colors.m, wysiwyg.m
+% called by xxx
+%
+
+format long
+format compact
+close all
+clear
+
+stf0 = '/home/carltape/wave2d/SEM2D_iterate/';
+if ~exist(stf0), error([stf0 ' does not exist']); end
+
+colors;
+npts = 100;
+stfm = '%4.4i';
+
+%---------------------------------------------------------
+% KEY COMMANDS
+
+parms = [100 0 3];    % structure inversion: 1 source, Nfac=3
+%parms = [200 0 3];    % source inversion (xs,ys,ts): single source
+%parms = [300 0 3];    % joint inversion: 1 source, Nfac=3
+%parms = [400 0 3];    % joint inversion: 5 sources, Nfac=3
+%parms = [500 0 3];    % joint inversion: 25 sources, Nfac=3
+%parms = [600 0 3];    % structure inversion: 25 sources, Nfac=2
+
+%---------------------------------------------------------
+
+irun0 = parms(1);       % irun for m0
+%niter = parms(2);       % number of iterations
+icubic = parms(2);      % cubic (=1) or quadratic (=0) fitting
+ifit = parms(3);        % function to fit chi(m): order of polynomial
+
+% bottom level for test parabola (=0 if no model norm term or data errors)
+chi_data_stop = 0.5;
+
+%---------------------------------------------------------
+
+odir = 'OUTPUT/';
+strun0  = ['irun0 = ' num2str(irun0) ];
+
+% determine the number of iterations
+k = 0;
+while k < 50
+    irun = irun0 + k;
+    chifile = [stf0 odir 'run_' sprintf(stfm,irun) '/chi.dat'];
+    iexist = exist(chifile);
+    if iexist == 2
+        chi = load(chifile);
+        chis_all(k+1) = chi;
+    else
+        break
+    end
+    k = k + 1;
+end
+istop = k - 1;
+niter = ceil(istop/2);
+
+% default is that the final model IS a test model
+ifinal_test = 0;
+irun_vec = [irun0+1 : 2 : irun0+2*niter];
+
+% if the simulation converged on a test model, then tack on a repeated
+% misfit value
+if mod(istop,2)==1
+    chis_all(istop+2) = chis_all(istop+1);
+    ifinal_test = 1;
+end
+
+chis  = chis_all([1 : 2 : 2*niter+1])';
+chits = chis_all([2 : 2 : 2*niter])';
+
+% irun_vec = [irun0+1:2:irun0+2*niter];
+% 
+% chis = zeros(niter+1,1);
+% chits = zeros(niter,1);
+% 
+% % load initial chi value
+% stf = [stf0 odir 'run_' sprintf(stfm,irun0) '/'];
+% ww = 'summed_chi_all';
+% load([stf ww '.dat']); chi = eval(ww); chis(1) = chi;
+% 
+% % load the remaining chi values
+% for ii=1:niter
+%     irun = irun_vec(ii);
+%     
+%     stft = [stf0 odir 'run_' num2str(sprintf(stfm,irun)) '/'];
+%     stf  = [stf0 odir 'run_' num2str(sprintf(stfm,irun+1)) '/'];
+%     chit = load([stft 'summed_chi_all.dat']);
+%     chi  = load([stf 'summed_chi_all.dat']);
+%     chis(ii+1) = chi;
+%     chits(ii)  = chit;
+% end
+
+%disp('         chis               chis_test');
+%disp([chis chits]);
+disp('chis :'); disp([chis]);
+disp('chis_test :'); disp([chits]);
+
+figure;
+nc=3; nr=max( ceil(niter/nc), 2);
+%nr=2; nc=2;
+stniter = ['niter = ' num2str(niter) ];
+stirun  = [strun0 '; ' stniter];
+
+for ii=1:niter
+    disp('----------------')
+    irun = irun_vec(ii);
+    stk  = num2str(ii-1);
+
+    % load polynomial values
+    % wave2d: xx1,xx2,yy1,yy2,g1,g2,Pa,Pb,Pc,Pd,xmin
+    subplot(nr,nc,ii);
+    stlabs = {'\nu',['S^{' stk '} ( \nu )'],'0',['\nu_{' stk '}'],['\nu_{' stk 't}']};
+    %if or(ifinal_test==0, ii < niter)
+    %if or(ifinal_test==1, ii < niter)
+        if icubic == 1
+            ww = 'cubic_poly';
+            stf = [stf0 odir 'run_' num2str(sprintf(stfm,irun)) '/'];
+            load([stf ww '.dat']); temp = eval(ww)';
+
+            x1 = temp(1); x2 = temp(2);
+            y1 = temp(3); y2 = temp(4);
+            g1 = temp(5); g2 = temp(6);
+        else
+            ww = 'quad_poly';
+            stf = [stf0 odir 'run_' num2str(sprintf(stfm,irun)) '/'];
+            load([stf ww '.dat']); temp = eval(ww)';
+
+            x1 = temp(1); x2 = temp(2);
+            y1 = temp(3); y2 = temp(4);
+            g1 = temp(5);
+        end
+
+        if icubic == 1
+            [lam0,P1] = cubic_min_4(x1,x2,y1,y2,g1,g2,[1 1],stlabs);
+
+            % check the Fortran output
+            temp(7:10) ./ P1 - 1
+            temp(11)/lam0 - 1
+        else
+            [lam0,P1] = quad_min_4(x1,x2,y1,y2,g1,[1 1],stlabs);
+
+            % check the Fortran output
+            temp(6:8) ./ P1 - 1
+            temp(9)/lam0 - 1
+        end
+    %end
+    
+    % load actual chi-value computed from the next run
+    % wave2d: xx1,xx2,yy1,yy2,g1,g2,Pa,Pb,Pc,Pd,xmin
+    %ww = 'summed_chi_all';
+    %stf = [stf0  odir 'run_' num2str(sprintf(stfm,irun+1)) '/'];
+    %load([stf ww '.dat']);
+    %chi = eval(ww);
+    %chis(ii+1) = chi;
+    
+    %if ii < niter
+        chi = chis(ii+1);
+        msize = 6;
+        axi = xlim;
+        plot([lam0 lam0 axi(1)],[0 chi chi],'k');
+        plot(lam0,chi,'bo','markersize',msize,'MarkerFaceColor','b');
+        if(lam0 > axi(2)), axis tight; end
+    %end
+
+end
+title(stirun);
+disp(' chis:'); disp(chis);
+
+if 0==1
+    % figure for paper (irun0 = 20, 100)
+    %save('chis','chis_quad','chis_cubic','nchi');
+    load('chis');
+    its = [0:nchi-1]';
+    
+    hess_ray = load('/home/carltape/wave2d/2d_adjoint_banana/OUTPUT_banana/run_0023/summed_chi_all.dat');
+    hess_ker = load('/home/carltape/wave2d/2d_adjoint_banana/OUTPUT_banana/run_0022/summed_chi_all.dat');
+    
+    figure; ax1 = [-1 nchi 10^-1 10^4];
+    semilogy(its,chis_quad,'r.',its,chis_cubic,'b.',...
+        its,hess_ray*ones(nchi,1),'g',its,hess_ker*ones(nchi,1),'k',...
+        'markersize',18,'linewidth',2);
+    legend(' fit with quadratic',' fit with cubic',' hessian ray',' hessian kernel');
+    axis(ax1); grid on;
+    xlabel(' model number (iteration)'); ylabel(' chi(m)');
+    orient tall, wysiwyg
+    
+    %-------------------------
+
+    % write information to file for GMT plotting
+    dir = [stf0 'gji_paper/figures/'];
+    ww = 'chi_cubic_quad.dat';
+    fid = fopen([dir ww],'w');
+    for ii=1:nchi
+        fprintf(fid,'%16.7e%16.7e%16.7e%16.7e%16.7e\n',...
+            its(ii),chis_quad(ii),chis_cubic(ii),hess_ray,hess_ker);   
+    end
+    fclose(fid);
+    
+    % write information to file for GMT plotting
+    ww = 'chi_cubic_quad_axes.dat';
+    fid = fopen([dir ww],'w');
+    fprintf(fid,'%16.7e%16.7e%16.7e%16.7e\n',ax1(1),ax1(2),ax1(3),ax1(4));   
+end
+
+if 0==1
+    % 26-July-2006, comparison of convergence curves (irun0 = 4000, 4050, 4100)
+    % save('chis2','chis_tt','chis_amp','chis_wav','nchi');
+    %
+    % 26-Oct-2006, comparison of convergence curves
+    % save('chis3','chis_wav','chis_tt_xcor','chis_lnA_xcor','chis_tt_mtm','nchi');
+    load('chis3');
+    its = [0:nchi-1]';
+    
+    chis_wav = chis_wav / chis_wav(1);
+    chis_tt_xcor = chis_tt_xcor / chis_tt_xcor(1);
+    chis_lnA_xcor = chis_lnA_xcor / chis_lnA_xcor(1);
+    chis_tt_mtm = chis_tt_mtm / chis_tt_mtm(1);
+    
+    %hess_ray = load('/home/carltape/wave2d/2d_adjoint_banana/OUTPUT_banana/run_0023/summed_chi_all.dat');
+    %hess_ker = load('/home/carltape/wave2d/2d_adjoint_banana/OUTPUT_banana/run_0022/summed_chi_all.dat');
+    
+    figure; ax1 = [-1 nchi 10^-3 10^0];
+    %semilogy(its,chis_tt_xcor,'r.',its,chis_lnA_xcor,'b.',its,chis_wav,'k.','markersize',18);
+    %legend(' tt-xcorr (4000)',' amplitude (4050)',' waveform (4100)');
+    semilogy(its,chis_wav,'k.',its,chis_tt_xcor,'r.',its,chis_lnA_xcor,'b.',its,chis_tt_mtm,'r+','markersize',18);
+    legend(' waveform (4300)',' tt-xcorr (4350)',' amplitude (4400)');
+    axis(ax1); grid on;
+    xlabel(' model number (iteration)'); ylabel(' chi(m)');
+    orient tall, wysiwyg
+end
+
+%---------------------------------------
+% plot misfit as a function of iteration
+
+nchi = length(chis);
+its = [0:nchi-1]';
+
+% x-y data to fit
+x = its;
+y = log10(chis);
+
+% threshold points to remove Inf or NaN
+igood = ~sum([isnan(y) isinf(y)],2);
+x = x(igood);
+y = y(igood);
+its = its(igood);
+chis = chis(igood);
+nchi = length(chis);
+
+% choose type of fit to log(chi) data: line(1), parabola(2), hyperbola(3)
+%ifit = 1;
+stlabs = {'line','parabola','hyperbola'};
+
+ifac1 = 0;
+ifac2 = 3;     % number of extra iterations to extrapolate
+its_smooth = linspace(0-ifac1,nchi-1+ifac2,100);
+sfm = '%.4e';
+if ifit==1
+    % fit to line for log10(chi)-its space
+    %[xf,yf,mf,bf,rms] = linefit(its(2:end), log10(chis(2:end)));
+    [xf,yf,mf,bf,rms] = linefit(x,y);
+    yfit = mf*x + bf;
+    yfit_smooth = mf * its_smooth + bf;
+    
+    stit1 = [' y = ( -' num2str(sprintf(sfm,mf)) ' x + ' num2str(sprintf(sfm,bf)) ')'];
+    stit2 = ' ';  
+    
+elseif ifit==2
+    % fit to parabola for log10(chi)-its space
+    [xf,yf,P,rms,stit] = parabolafit(x,y);
+    yfit = P(1)*x.^2 + P(2)*x + P(3);
+    yfit_smooth = P(1)*its_smooth.^2 + P(2)*its_smooth + P(3);
+    
+elseif ifit==3
+    % initial guesses based on a line
+    [xf,yf,mf,bf,rms] = linefit(x,y);
+    m0 = [-mf 0 1 -bf]';
+    y0 = theoryHyp(m0, x);
+    figure; hold on; plot(x,y,'.',x,y0,'ro');
+    
+    % perturbations
+    jogvec = [1e-8 * ones(4,1)]';
+
+    disp('  ');
+    disp('Model: A,B,C,D in equation Ax + Bxy + Cy + D = 0');
+    disp('                   ---> y = (-Ax - D) / (Bx + C)');
+    mz = m0; itmx = 5;
+    for ii=1:itmx
+        [mz e1] = genfit('theoryHyp', mz, jogvec, y, [x]);
+        mz
+        yest = theoryHyp(mz,x);
+        res = y - yest; rms = sqrt( (res' * res) / length(res) );
+        stRMS = [' RMS = ' num2str(sprintf('%.4e', rms)) ';'];
+    end
+    disp('Best-fit hyperbola:');
+    mz
+    a = mz(1); b = mz(2); c = mz(3); d = mz(4); 
+    stit1 = [' y = ( -' num2str(sprintf(sfm,a)) ' x - ' num2str(sprintf(sfm,d)) ') / (' ...
+                       num2str(sprintf(sfm,b)) ' x + ' num2str(sprintf(sfm,c)) ')'];
+    stit2 = [' y = ' num2str(sprintf(sfm,a)) ' x + ' num2str(sprintf(sfm,b)) ' xy + ' ...
+            num2str(sprintf(sfm,c)) ' y + ' num2str(sprintf(sfm,d)) ' = 0'];               
+    disp(stRMS);
+    
+    yfit = theoryHyp(mz,x);
+    yfit_smooth = theoryHyp(mz,its_smooth);
+    plot(its_smooth, yfit_smooth, 'r--');
+    legend(' data',' initial guess line',' hyperbola fit');
+end
+chifit = 10.^yfit;
+chifit_smooth = 10.^yfit_smooth;
+
+%------------------------------
+
+figure; nr=2; nc=2;
+msize = 24; lsize = 2;
+xlims = [-1 its_smooth(end)];
+xticks = [round(its_smooth(1)):round(its_smooth(end))];
+stit = {[' fitting a ' stlabs{ifit} ' to log10(chi)-vs-iteration data'],stit1,stit2};
+
+stx = ' k, model number (iteration)';
+
+subplot(nr,nc,1); hold on;
+plot(its_smooth,chifit_smooth,'r--','linewidth',lsize);
+plot(its,chis,'.','markersize',msize);
+xlim(xlims); grid on; set(gca,'xtick',xticks);
+xlabel(stx);
+ylabel(' S (m)','fontsize',18);
+title(stirun);
+
+subplot(nr,nc,2);
+if 1==1
+    plot(its_smooth,log10(chifit_smooth),'r--',its,log10(chis),'.','markersize',msize,'linewidth',lsize);
+    ylabel(' log10 [ S (m) ]','fontsize',18);
+    %set(gca,'ytick',[-10:10]);
+else
+    semilogy(its_smooth,chifit_smooth,'r--',its,chis,'.','markersize',msize,'linewidth',lsize);
+    ylabel(' S (m)','fontsize',18);
+    set(gca,'ytick',10.^[-10:10]);
+end
+grid on; xlim(xlims); set(gca,'xtick',xticks);
+xlabel(stx); title(stit);
+
+% variance reduction
+chi_before = chis(1:nchi-1);
+chi_after  = chis(2:nchi);
+var_red1   = 100 * ( 1 - ( (chi_after-chi_data_stop).^2 ./ (chi_before-chi_data_stop).^2 ) );
+var_red2   = 100 * ( 1 - ( (chi_after-chi_data_stop).^2 ./ (chi_before-chi_data_stop).^2 ) );
+
+disp('  '); disp('VARIANCE REDUCTION');
+disp([its(2:end) chi_before chi_after var_red1]);
+
+% var red corresponding to best-fitting chi-vs-its curve
+its2         = xticks;
+chifit2      = interp1(its_smooth,chifit_smooth,its2);
+var_red1_fit = 100 * ( 1 - ( chifit2(2:end).^2 ./ chifit2(1:end-1).^2 ) );
+
+x_var     = its(2:end);
+x_var_fit = its2(2:end);
+
+subplot(nr,nc,3); hold on;
+plot(x_var_fit,var_red1_fit,'r.--','markersize',msize,'linewidth',lsize);
+plot(x_var,var_red1,'b.-','markersize',msize,'linewidth',lsize);
+axis([xlims 0 100]); grid on; set(gca,'xtick',xticks);
+xlabel(stx);
+ylabel(' variance reduction');
+title(' variance reduction between successive models');
+
+% subplot(nr,nc,4); plot(its(2:end),var_red2,'.-');
+% xlim(xlims); grid on; set(gca,'xtick',its);
+% xlabel(stx);
+% ylabel(' variance reduction');
+
+lchi_smooth = log10(chifit_smooth);
+converge_fit = abs( gradient( lchi_smooth, its_smooth) );
+converge_its = 0.5+its(1:end-1);
+converge_pts = abs( diff(log10(chis)) );
+
+subplot(nr,nc,4);
+%semilogy(its_smooth,-gradient(chifit_smooth, its_smooth),'r--','linewidth',lsize);
+plot(its_smooth,converge_fit,'r--',converge_its,converge_pts,'.','markersize',msize,'linewidth',lsize);
+axis([xlims 0 0.7]); grid on; set(gca,'xtick',xticks);
+xlabel(stx);
+ylabel(' order of convergence rate, | \Delta log10(S) /  \Delta k |');
+
+fontsize(9), orient tall, wysiwyg
+
+%-----------------------------
+% This generates the initial polynomial, in order to have the values
+% of the fitting curves to write to file in gji_figs.m for GMT plotting.
+
+% specify number of iterations to plot; load initial chi
+niter = 1;
+stirun = [' irun0 = ' num2str(irun0) '; niter = ' num2str(niter) ];
+stf = [stf0 odir 'run_' num2str(sprintf(stfm,irun0)) '/'];
+ww = 'chi';
+load([stf ww '.dat']); chi = eval(ww); chis(1) = chi;
+
+%figure; %nr=3; nc=3;
+for ii=1:niter
+    irun = irun_vec(ii);
+    stk  = num2str(ii-1);
+    stlabs = {'\nu',['S^{' stk '} ( \nu )'],'0',['\nu_{' stk '}'],['\nu_{' stk 't}']};
+    
+    if icubic == 1
+        ww = 'cubic_poly';
+        stf = [stf0 odir 'run_' num2str(sprintf(stfm,irun)) '/'];
+        load([stf ww '.dat']); temp = eval(ww)';
+        x1 = temp(1); x2 = temp(2);
+        y1 = temp(3); y2 = temp(4);
+        g1 = temp(5); g2 = temp(6);
+    else
+        ww = 'quad_poly';
+        stf = [stf0 odir 'run_' num2str(sprintf(stfm,irun)) '/'];
+        load([stf ww '.dat']); temp = eval(ww)';
+        x1 = temp(1); x2 = temp(2);
+        y1 = temp(3); y2 = temp(4);
+        g1 = temp(5);
+    end
+    
+    if 0==1     % call functions for plotting
+        if icubic == 1
+            [xmin,P1] = cubic_min_4(x1,x2,y1,y2,g1,g2,[1 0],stlabs);
+        else
+            [xmin,P1] = quad_min_4(x1,x2,y1,y2,g1,[1 0],stlabs);
+        end
+        
+    else        % call functions as scripts
+        
+        % quadratic polynomial for computing test-model nu
+        aquad = g1^2/(4*y1);
+        Pquad_test = [aquad g1 y1]';
+        n = 100;
+        
+        % quadratic interpolation (only used to get chi if icubic = 1)
+        a = ((y2 - y1) - g1*(x2 - x1)) / (x2^2 - x1^2);
+        b = g1;
+        c = y1 - a*x1^2 - b*x1;
+        Pquad = [a b c]';
+        [Pquad2,qvert,stit] = quad_shift(Pquad,1);
+        
+        if icubic == 1  % copied from cubic_min_4.m on 2-14-06
+            
+            a = ( -2*(y2-y1) + (g1+g2)*(x2-x1) ) / (x2 - x1)^3;
+            b = ( 3*(y2-y1) - (2*g1 + g2)*(x2 - x1) ) / (x2 - x1)^2;
+            c = g1;
+            d = y1;
+            P2 = [a b c d]';
+            Pcubic = cubic_shift(P2,x1,0);
+            xmin = cubic_min(Pcubic,x1);
+            
+            figure; hold on;
+            specs = [2 14 18 12]; fac = 0.05;
+            axpoly = axes_expand([x1 x2 0 max([y1 y2])],1.2);
+            axpoly(3) = 0;
+            dy = axpoly(4) - axpoly(3);
+            dx = axpoly(2) - axpoly(1);
+            ylab = axpoly(3) - fac*dy;
+            ymin = polyval(Pcubic,xmin);
+            
+            xpts = linspace(axpoly(1),axpoly(2),n);    
+            g1_line = polyval([g1 y1-g1*x1],xpts);
+            g2_line = polyval([g2 y2-g2*x2],xpts);
+            g1_quad_test = polyval(Pquad_test,xpts);
+            g1_quad_fit = polyval(Pquad,xpts);
+            g1_cube_fit = polyval(Pcubic,xpts);
+            
+            plot(xpts,g1_cube_fit,'b','linewidth',specs(1));
+            plot(xpts,g1_quad_fit,'r--','linewidth',specs(1));
+            plot(xpts,g1_quad_test,'b--');
+            plot(xpts,g1_line,'r--',xpts,g2_line,'r--');
+            
+            plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+            plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+            plot([xmin xmin axpoly(1)],[0 ymin ymin],'k--');
+            
+            plot([x1 x2],[y1 y2],'ko','markersize',specs(2),'MarkerFaceColor','b');
+            plot(xmin,ymin,'bo',x2,0,'bo',xmin,0,'bo','markersize',specs(2),'MarkerFaceColor','w');
+            plot(0.5*x2,0,'go','markersize',specs(2),'MarkerFaceColor','w');  % linear projection
+            
+            axis(axpoly);
+            xlabel(stlabs{1},'fontsize',specs(3));
+            ylabel(stlabs{2},'fontsize',specs(3));
+            grid on;
+            text(xmin,ylab,stlabs{4},'fontsize',specs(4));
+            text(x2,ylab,stlabs{5},'fontsize',specs(4));
+            orient tall, wysiwyg
+            
+        else  % copied from quad_min_4.m on 2-14-06
+            
+            xmin = qvert(1);
+
+            figure; hold on;
+            specs = [2 14 18 12]; fac = 0.05;
+            axpoly = axes_expand([x1 x2 0 max([y1 y2])],1.2);
+            axpoly(3) = 0;
+            dy = axpoly(4) - axpoly(3);
+            dx = axpoly(2) - axpoly(1);
+            ylab = axpoly(3) - fac*dy;
+            ymin = polyval(Pquad,xmin);
+            
+            xpts = linspace(axpoly(1),axpoly(2),n);
+            g1_line = polyval([g1 y1-g1*x1],xpts);
+            g2_line = zeros(n,1);
+            g1_quad_test = polyval(Pquad_test,xpts);
+            g1_quad_fit = polyval(Pquad,xpts);
+            g1_cube_fit = zeros(n,1);
+            
+            plot(xpts,g1_quad_fit,'b','linewidth',specs(1));
+            plot(xpts,g1_quad_test,'b--','linewidth',specs(1));
+            plot(xpts,g1_line,'r--','linewidth',specs(1));
+            
+            plot([x1 x1 axpoly(1)],[0 y1 y1],'k');
+            plot([x2 x2 axpoly(1)],[0 y2 y2],'k');
+            plot([xmin xmin axpoly(1)],[0 ymin ymin],'k--');
+            plot([x1 x2],[y1 y2],'ko','markersize',specs(2),'MarkerFaceColor','b');
+            plot(xmin,ymin,'bo',x2,0,'bo',xmin,0,'bo','markersize',specs(2),'MarkerFaceColor','w');
+            plot(0.5*x2,0,'go','markersize',specs(2),'MarkerFaceColor','w');  % linear projection
+            axis(axpoly);
+            xlabel(stlabs{1},'fontsize',specs(3));
+            ylabel(stlabs{2},'fontsize',specs(3));
+            title({stit{1},stit{2}},'fontsize',specs(3))
+            grid on;
+            text(xmin,ylab,stlabs{4},'fontsize',specs(4));
+            text(x2,ylab,stlabs{5},'fontsize',specs(4));
+            orient tall, wysiwyg
+        end
+    end
+        
+    % load actual chi-value computed from the next run
+    % wave2d: xx1,xx2,yy1,yy2,g1,g2,Pa,Pb,Pc,Pd,xmin
+    ww = 'chi';
+    stf = [stf0 odir 'run_' num2str(sprintf(stfm,irun+1)) '/'];
+    load([stf ww '.dat']);
+    chi = eval(ww);
+    
+    msize = 14;
+    axi = xlim; plot([xmin xmin axi(1)],[0 chi chi],'k');
+    plot(xmin,chi,'bo','markersize',msize,'MarkerFaceColor','b');
+end
+title(stirun);
+orient tall, wysiwyg
+
+%=============================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_subspace.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_subspace.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wave2d_subspace.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,1039 @@
+%
+% wave2d_subspace.m
+% CARL TAPE, 16-Nov-2008
+% printed xxx
+%
+% This program implements the subspace method inversion notes developed by
+% Jeroen Tromp, Malcolm Sambridge, and Carl Tape.
+% 
+% calls xxx
+% called by xxx
+%
+
+clc, clear, close all
+format short, format compact
+%warning off
+
+colors;
+
+ax1 = [-121 -114 31 37];
+stfm = '%4.4i';
+
+% USER CHANGE
+dir_run = '/home/carltape/wave2d/SEM2D_iterate/OUTPUT/';
+
+inew = 0;       % subspace AND parameter class inversions
+
+%----------------------------------------------
+
+if 0==1
+    temp = load('/net/denali/scratch1/carltape/OUTPUT/run_7000/structure_dat.dat');
+    %temp = load('/net/denali/scratch1/carltape/OUTPUT/run_7000/HESSIAN/structure_dat.dat');
+    lon = temp(:,1); lat = temp(:,2); beta = temp(:,7);
+
+    [X,Y,Z] = griddataXB(lon,lat,beta,100,'nearest');
+    figure; cmax = 0.1; hold on;
+    pcolor(X,Y,Z); shading interp;
+    caxis([-1 1]*cmax); colormap(seis);
+end
+
+% check the relative dimensions of all the matrices we need
+if 0==1
+    S = 5;              % number of sources
+    Cstr = 1;           % number of structure parameter classes
+    Csrc = 2;           % number of source parameter classes
+    C = Cstr + Csrc;
+    Mstr1 = 20;         % number of structure parameters
+    Msrc1 = 1;          % number of source parameters in class 1 (origin time)
+    Msrc2 = 2;          % number of source parameters in class 2 (xy, ys)
+    Mstr = Mstr1;
+    Msrc = S*(Msrc1 + Msrc2);
+    M = Mstr + Msrc;    % number of rows in P
+    N = C*S;            % number of columns in P
+    
+    P = zeros(M,N);
+    P(1:Mstr1,1:S) = rand(Mstr1,S);
+    for s = 1:S
+       P(Mstr1+s,S+s) = rand; 
+       P(Mstr1+S+s,2*S+s) = rand; 
+       P(Mstr1+2*S+s,2*S+s) = rand; 
+    end
+    
+    % fill G
+    G = zeros(S,M);
+    Gstr = rand(S,Mstr);
+    Gsrc = zeros(S,Msrc);
+    if 1==1
+        Gsrc = repmat(diag(rand(S,1)),1,Msrc1+Msrc2);
+    else
+        itemp = (Msrc1 + Msrc2)*[1:S]';
+        indmat2 = [ [1 ; 1+itemp(1:end-1)] itemp ];
+        for isrc = 1:S
+            inds = indmat2(isrc,1) : indmat2(isrc,2);
+            %Gsrc(isrc,inds) = -ws(isrc) * grad_src(inds);
+            Gsrc(isrc,inds) = rand(1,length(inds));
+        end
+    end
+    G = [Gstr Gsrc];
+   
+    Cm  = diag(rand(M,1));
+    Cmi = P'*Cm*P;
+    GG  = G*Cm*P;
+    
+    d = zeros(S,1);
+    Hnew = GG'*GG + Cmi;
+    dnew = GG'*d;
+    mu = Hnew*dnew;
+    whos d Hnew dnew mu
+    
+    figure; nr=3; nc=4; msize=3;
+    subplot(nr,nc,2); spy(G,msize); title(sprintf('G is %i by %i',size(G)));
+    subplot(nr,nc,3); spy(G',msize); title(sprintf('G^T is %i by %i',size(G')));
+    subplot(nr,nc,4); spy(G*G',msize); title(sprintf('G G^T is %i by %i',size(G*G')));
+    
+    subplot(nr,nc,5); spy(P',msize); title(sprintf('P^T is %i by %i',size(P')));
+    subplot(nr,nc,6); spy(Cm,msize); title(sprintf('Cm is %i by %i',size(Cm)));
+    subplot(nr,nc,7); spy(P,msize); title(sprintf('P is %i by %i',size(P)));
+    subplot(nr,nc,8); spy(Cmi,msize); title(sprintf('P^T Cm P is %i by %i',size(Cmi)));
+    
+    subplot(nr,nc,9); spy(G,msize); title(sprintf('G is %i by %i',size(G)));
+    subplot(nr,nc,10); spy(Cm,msize); title(sprintf('Cm is %i by %i',size(Cm)));
+    subplot(nr,nc,11); spy(P,msize); title(sprintf('P is %i by %i',size(P)));
+    subplot(nr,nc,12); spy(GG,msize); title(sprintf('G Cm P is %i by %i',size(GG)));
+    orient tall, wysiwyg
+    
+    break
+end
+
+%---------------------------------------------
+
+if 0==1
+    nk = 100;
+    kvec = 10.^linspace(-4,4,nk);
+    
+    figure; nr=2; nc=1;
+    for jj=1:2
+        switch jj
+            case 1, ndata = 5; nparm = 10;
+            case 2, ndata = 10; nparm = 5;
+        end
+        Cm = diag(rand(nparm,1));
+        G = rand(ndata,nparm);
+        d = rand(ndata,1);
+        
+        norm_dm = zeros(nk,1);
+        for kk = 1:nk
+            C = Cm * kvec(kk);
+            norm_dm(kk) = norm( C * G' * inv(G*C*G') * d );
+        end
+        subplot(nr,nc,jj);
+        semilogx(kvec, norm_dm, '.');
+    end
+end
+
+%----------------------------------------------
+
+irun0 = input(' Enter irun0 : ');
+iread = input(' Enter 1 to read in new event kernels (0 otherwise) : ');
+hmod = input(' Enter next model number (hmod) : ');
+INV_STRUCT = input(' Enter 1 to invert for STRUCTURE : ');
+INV_SOURCE = input(' Enter 1 to invert for SOURCE : ');
+iwrite = input(' Enter 1 to write out files : ');
+if iwrite==1
+    COMPUTE_KERNELS = input(' Enter 1 to compute the event kernels for this model : ');
+end
+if INV_STRUCT==1
+    ifigure = input(' Enter 1 to plot figures : ');
+else
+    ifigure = 0;
+end
+
+%iwrite = 0;
+%ifigure = 1;
+%hmod = 1;   % 1, 2, 3, ...
+%irun0 = 7150;     % 6080, 6180, 7000, 7050
+
+NLOCAL = 40000;     % assume 1 source parameter only for now (beta)
+NPARM_SOURCE = 3;
+NPARM_STRUCT = 2;
+
+nsrc = 25;
+nrec = 132;
+nmeas = nsrc * nrec;
+
+nmod_str = NLOCAL;
+nmod_src = nsrc * NPARM_SOURCE;
+nmod = nmod_str + nmod_src;
+
+%SIGMA_DT = 0.20;
+%sval_cut = SIGMA_DT * sqrt(nmeas);
+sval_cut = 5;
+
+%----------------
+
+sth = sprintf('%2.2i',hmod);
+
+dir0 = [dir_run 'run_' sprintf(stfm,irun0) '/'];
+dir2 = [dir0 'HESSIAN/model_m' sth '/'];
+dir2lab = ['run-' sprintf(stfm,irun0) ', HESSIAN -- toward model m' sth ];
+
+if hmod == 1
+    dir1 = dir0;
+else
+    dir1 = [dir0 'HESSIAN/model_m' sprintf('%2.2i',hmod-1) '/'];
+end
+
+% indexing for measurements
+itemp = [nrec:nrec:nmeas]';
+indmat1 = [ [1 ; 1+itemp(1:end-1)] itemp ];
+itemp = NPARM_SOURCE*[1:25]';
+indmat2 = [ [1 ; 1+itemp(1:end-1)] itemp ];
+
+% indexing for model vector
+m_inds = load([dir1 'm_inds.dat']);
+inds_C  = [m_inds(1,1) : m_inds(1,2)];
+inds_B  = [m_inds(2,1) : m_inds(2,2)];
+inds_ts = [m_inds(3,1) : m_inds(3,2)];
+inds_xs = [m_inds(4,1) : m_inds(4,2)];
+inds_ys = [m_inds(5,1) : m_inds(5,2)];
+inds_src = [m_inds(3,1) : m_inds(5,2)];
+
+% load the source parameters
+src_syn = load([dir1 'src_syn.dat']);
+slon = src_syn(:,1);
+slat = src_syn(:,2);
+src_ts = src_syn(:,3);
+src_xs = src_syn(:,4);
+src_ys = src_syn(:,5);
+
+% load the source parameters
+src_dat = load([dir1 'src_dat.dat']);
+src_ts_dat = src_dat(:,3);
+src_xs_dat = src_dat(:,4);
+src_ys_dat = src_dat(:,5);
+
+% load the receivers
+rec_lonlat = load([dir1 'recs_lonlat.dat']);
+rlon = rec_lonlat(:,1);
+rlat = rec_lonlat(:,2);
+
+% load the data covariance matrix
+cov_data = load([dir1 'cov_data_diagonal.dat']);
+
+% load all the measurements and partition into matrix
+meas_all = load([dir1 'measure_vec.dat']);
+dT_all = meas_all(:,1);     % WITH ERRORS ADDED
+dT_all_norm = dT_all.^2 ./ cov_data;
+
+% load the covariance matrix
+% --> cov_imetric(NLOCAL+1 : nmod_str) = ( sigma_beta  )**2 / da_local_vec(:) * AREA
+%cov_model = load('/net/denali/scratch1/carltape/OUTPUT_2/run_9100/cov_imetric_diagonal.dat');
+cov_model_all = load([dir1 'cov_model_diagonal.dat']);
+cov_model = cov_model_all(:,1);
+cov_alpha = cov_model(inds_C)';
+cov_beta  = cov_model(inds_B)';
+cov_src   = cov_model(inds_src)';
+clear cov_model_all
+
+% load the reference values
+% alpha0, beta0, rho0, bulk0, kappa0, mu0
+vall = load([dir1 'reference_values.dat']);
+alpha0 = vall(1);
+beta0  = vall(2);
+rho0   = vall(3);
+bulk0  = vall(4);
+kappa0 = vall(5);
+mu0    = vall(6);
+
+% load the model vector
+mtemp = load([dir1 'cg_model_vectors.dat']);
+m_all = mtemp(:,1);
+%m_bulk = mtemp(NLOCAL+1 : 2*NLOCAL, 1)';
+%m_beta  = mtemp(NLOCAL+1 : 2*NLOCAL, 1)';
+m_src   = mtemp(inds_src)';
+
+% load the structure files
+mtemp = load([dir1 'structure_syn.dat']);
+m_str_lon   = mtemp(:,1);
+m_str_lat   = mtemp(:,2);
+m_str_kappa = mtemp(:,3);
+m_str_mu    = mtemp(:,4);
+m_str_rho   = mtemp(:,5);
+m_str_C     = mtemp(:,6);
+m_str_B     = mtemp(:,7);
+
+% load the structure files
+mtemp = load([dir1 'structure_dat.dat']);
+m_dat_str_lon   = mtemp(:,1);
+m_dat_str_lat   = mtemp(:,2);
+m_dat_str_kappa = mtemp(:,3);
+m_dat_str_mu    = mtemp(:,4);
+m_dat_str_rho   = mtemp(:,5);
+m_dat_str_C     = mtemp(:,6);
+m_dat_str_B     = mtemp(:,7);
+
+% load source files (synthetics and data)
+[m_src_lon,m_src_lat,m_src_ts,m_src_xs,m_src_ys,m_src_ts_d,m_src_xs_d,m_src_ys_d] ...
+    = textread([dir1 'src_syn.dat'],'%f%f%f%f%f%f%f%f');
+[junk1,junk2,m_src_ts_dat,m_src_xs_dat,m_src_ys_dat,junk3,junk4,junk5] ...
+    = textread([dir1 'src_dat.dat'],'%f%f%f%f%f%f%f%f');
+
+% load the gradient
+gtemp = load([dir1 'gradient_vec.dat']);
+gradient = gtemp(:,1);
+grad_bulk = gradient(inds_C)';
+grad_beta = gradient(inds_B)';
+grad_src  = gradient(inds_src)';
+disp(' check norms of structure and source GRADIENTS :');
+norm_grad_str = dot( grad_beta, cov_beta.*grad_beta )
+norm_grad_src = dot(  grad_src,  cov_src.*grad_src )
+disp(' gradient balance for the CG inversion :');
+norm_grad_src / norm_grad_str
+
+% load the source gradient and partition into matrix
+%grad_src = load([dir1 'source_gradient.dat']);
+% grad_src_mat = zeros(nsrc,NPARM_SOURCE);
+% for isrc = 1:nsrc
+%     grad_src_mat(isrc,:) = grad_src(indmat2(isrc,1) : indmat2(isrc,2));
+% end
+
+% check the misfit function value
+chi = load([dir1 'chi.dat']);
+chi_data_norm = load([dir1 'chi_data_norm.dat']);
+chi_model_norm = load([dir1 'chi_model_norm.dat']);
+
+disp('  '); disp(' CHECKING VARIOUS NORMS:');
+disp('   model norm:');
+chi_model_norm, sum( m_all.^2 ./ cov_model )
+disp('   data norm:');
+chi_data_norm, sum(dT_all_norm)
+disp('   misfit function value:');
+chi, 0.5*( sum( dT_all_norm ) + sum( m_all.^2 ./ cov_model ))
+
+%====================================================
+
+% partition DATA vector of traveltime measurements into a matrix,
+% since in this case we know that there are the same number of picks for each event
+dT_mat      = zeros(nsrc,nrec);
+dT_norm_mat = zeros(nsrc,nrec);
+for isrc = 1:nsrc
+    inds = [indmat1(isrc,1) : indmat1(isrc,2)];
+    dT_mat(isrc,:)      = dT_all(inds);
+    dT_norm_mat(isrc,:) = dT_all_norm(inds);
+end
+
+% compute the new data vector
+dnorm = sum( dT_norm_mat, 2);
+if any(dnorm==0), error(' For at least one source, there is perfect fit.'); end
+
+% compute the weights (SIGN OR NOT?)
+%ws = zeros(nsrc,1);
+%ws = 1 ./ sqrt( sum( dT_norm_mat, 2) );
+%if sum(isinf(ws)) > 0, error(' For at least one source, there is perfect fit.'); end
+% compute the new data vector
+%dnorm = 1 ./ ws;
+
+% check
+sum(sum(dT_norm_mat)), sum(dT_all_norm), sum( dnorm )
+
+if INV_STRUCT == 1
+
+    % load the jacobian for constructing the "event gradient" from the event kernel
+    lmesh_all = load([dir1 'local_mesh.dat']);
+    Ai = lmesh_all(:,9)';
+
+    % load the event kernels
+    %iread = 1;
+    efile = 'wave2d_kernel';
+    if iread==1
+        % THE SPECIFICATION FOR SMOOTHED KERNELS IS DONE IN WAVE2D.F90
+        % EITHER WAY, YOU LOAD THE FILES kernel_basis_smooth, WHICH MAY OR
+        % MAY NOT BE SMOOTHED.
+        ismooth = input(' Enter 1 to read smoothed event kernels (0 otherwise) : ');
+        disp('reading in the event kernels...');
+        Kall = zeros(nsrc,NLOCAL);
+        for isrc = 1:nsrc
+            isrc
+            dirK = [dir1 'event_' sprintf('%3.3i',isrc) '/'];
+            if ismooth == 1
+                kernel = load([dirK 'kernel_basis_smooth']); Kbeta = kernel(:,3)';
+            else
+                kernel = load([dirK 'kernel_basis']); Kbeta = kernel(:,7)';
+            end
+            lon = kernel(:,1);
+            lat = kernel(:,2);
+            Kall(isrc,:) = Kbeta;
+        end
+        save(efile,'Kall','lon','lat');
+        %break
+    else
+        load(efile);
+    end
+
+    % construct G (plot event kernels too)
+    %nsrc = 5;
+    Gstr = zeros(nsrc,NLOCAL);
+    for isrc = 1:nsrc
+        Kbeta = Kall(isrc,:);
+        %Gstr(isrc,:) = -ws(isrc) * Kbeta .* Ai;   % SIGN OR NOT?
+        Gstr(isrc,:) = -Kbeta .* Ai;
+
+        if 0==1
+            [X,Y,Z] = griddataXB(lon,lat,Kbeta,100,'nearest');
+            figure; cmax = 1e-7; hold on;
+            pcolor(X,Y,Z); shading interp;
+            caxis([-1 1]*cmax); colormap(seis);
+            plot(rlon,rlat,'k.','markersize',16)
+            for irec = 1:nrec
+               text(rlon(irec),rlat(irec),sprintf('%6.1f',dT_mat(isrc,irec)),'fontsize',12);
+            end
+            plot(slon(isrc),slat(isrc),'p','markersize',24,...
+                'markerfacecolor','w','markeredgecolor','k','linewidth',2);
+        end
+    end
+
+    % Hessian for structure parameters (from event kernels)
+    disp('constructing the Hessian...');
+    Hstr = zeros(nsrc,nsrc);
+    for ii = 1:nsrc
+        for jj = 1:nsrc
+            Hstr(ii,jj) = dot(Gstr(ii,:), cov_beta.*Gstr(jj,:));
+        end
+    end
+
+else
+    Hstr = zeros(nsrc,nsrc);
+end
+
+% Hessian and projected gradient for source parameters 
+Hsrc = zeros(nsrc,nsrc);
+%Hsrc_vec = zeros(nsrc,1);
+if INV_SOURCE == 1
+    
+    Gsrc = zeros(nsrc,nmod_src);
+    Gsrc = [diag(gradient(inds_ts)) diag(gradient(inds_xs)) diag(gradient(inds_ys))];
+    %for isrc = 1:nsrc
+    %    inds = indmat2(isrc,1) : indmat2(isrc,2);
+    %    %Gsrc(isrc,inds) = -ws(isrc) * grad_src(inds);
+    %    Gsrc(isrc,inds) = grad_src(inds);
+    %end
+    Hsrc = Gsrc * diag(cov_src) * transpose(Gsrc);
+    
+    %for isrc = 1:nsrc
+    %    inds = indmat2(isrc,1) : indmat2(isrc,2);
+    %    Hsrc_vec(isrc) = ws(isrc)^2 * dot(grad_src(inds), cov_src(inds).*grad_src(inds) );
+    %end
+    %Hsrc = diag(Hsrc_vec);
+end
+
+% overall Hessian
+H = Hstr + Hsrc + eye(nsrc,nsrc);
+
+% construct projection matrix (and assign gradient)
+if INV_STRUCT == 1
+    G = Gstr;
+    Pstr = Gstr';
+    P = Pstr;
+end
+if INV_SOURCE == 1
+    G = Gsrc;
+    Psrc = zeros(nmod_src,nsrc*2);      % 2: origin time and location
+    Psrc(1:nsrc,1:nsrc) = Gsrc(1:nsrc,1:nsrc);
+    Psrc(nsrc+1:2*nsrc,nsrc+1:2*nsrc) = Gsrc(1:nsrc,nsrc+1:2*nsrc);
+    Psrc(2*nsrc+1:3*nsrc,nsrc+1:2*nsrc) = Gsrc(1:nsrc,2*nsrc+1:3*nsrc);
+    P = Psrc;
+end
+if and(INV_STRUCT == 1, INV_SOURCE == 1)
+    G = [Gstr Gsrc];
+    P = zeros(nmod,3*nsrc);
+    P(1:nmod_str,1:nsrc) = Pstr;
+    P(nmod_str+1:nmod,nsrc+1:3*nsrc) = Psrc;
+end
+
+% construct matrices for joint inversions
+if inew == 1
+    GG = zeros(nsrc,NCLASS*nsrc);
+    CmP = P; for ii=1:nmod, CmP(ii,:) = P(ii,:) * cov_model(nmod_str+ii); end;
+    GG = G * CmP;
+    Cmi = P' * CmP;
+
+    figure; nr=3; nc=1;
+    subplot(nr,nc,1); spy(P(nmod_str-100:nmod_str,:),3); title('bottom 100 rows of P');
+    subplot(nr,nc,2); spy(GG,3); title('GG = G Cm P');
+    subplot(nr,nc,3); spy(Cmi,3); title('Cmi = P^T Cm P');
+    orient tall, wysiwyg
+end
+
+disp(' Hessian diagonal contributions from structure and source:');
+disp('  structure   source    total    source/structure');
+disp([diag(Hstr) diag(Hsrc) diag(H) diag(Hsrc)./diag(Hstr) ]);
+disp(' gradient balance for the Hessian (subspace) inversion (mean of last column) :');
+disp(mean( diag(Hsrc)./diag(Hstr) ))
+
+disp(' properties of Hessian (min, median, mean(abs), max, std):');
+stH = sprintf('min %.2e, median %.2e, mean(abs) %.2e, max %.2e, std %.2e',...
+            min(H(:)), median(H(:)), mean(abs(H(:))), max(H(:)), std(H(:)));
+disp(stH);
+
+if ~and(INV_STRUCT==1, INV_SOURCE==1)
+    figure; pcolor(H); shading flat;
+    xlabel('Row index'); ylabel('Column index');
+    title({'Hessian (symmetric matrix)',stH});
+    map = colormap('gray'); colormap(flipud(map));
+    colorbar; axis equal; axis tight; 
+else
+    figure; nr=3; nc=1;
+    subplot(nr,nc,1); pcolor(H); shading flat;
+    xlabel('Row index'); ylabel('Column index');
+    title({'Hessian (symmetric matrix)',stH});
+    map = colormap('gray'); colormap(flipud(map));
+    colorbar; axis equal; axis tight; 
+
+    subplot(nr,nc,2); pcolor(Hstr); shading flat;
+    xlabel('Row index'); ylabel('Column index');
+    title('Hessian for structure (symmetric matrix)');
+    map = colormap('gray'); colormap(flipud(map));
+    colorbar; axis equal; axis tight; 
+
+    subplot(nr,nc,3); pcolor(Hsrc); shading flat;
+    xlabel('Row index'); ylabel('Column index');
+    title('Hessian for source (diagonal matrix)');
+    map = colormap('gray'); colormap(flipud(map));
+    colorbar; axis equal; axis tight; 
+    orient tall, wysiwyg
+end
+
+if INV_SOURCE == 1
+   figure; nr=2; nc=1;
+   subplot(nr,nc,1); spy(Gsrc); title('Gsrc');
+   subplot(nr,nc,2); spy(Gsrc*Gsrc'); title('Gsrc * Gsrc^T');
+end
+
+% set of pmax TSVD values to try
+iyes = 0;
+while iyes == 0
+    iyes = input(' Enter 1 if this balance looks okay : ');
+end
+
+% check the balance of the gradients -- SAME AS CHECKING THE HESSIAN DIAGONAL
+if 0 == 1
+    cov_beta0 = cov_beta;
+    cov_src0 = cov_src;
+    
+    kvec = linspace(0.2,6,100);
+    for k = 1:length(kvec)
+        fac = kvec(k);
+        cov_beta = cov_beta0 * fac;
+        
+        for ii = 1:nsrc
+           norm_grad_str(ii) = sum( Gstr(ii,:).^2 .* cov_beta );
+           norm_grad_src(ii) = sum( Gsrc(ii,:).^2 .* cov_src );
+           norm_grad_tot(ii) = norm_grad_str(ii) + norm_grad_src(ii);
+        end
+        %disp(' Norms of the gradients and constituent parts:');
+        %disp('  structure   source    total    source/structure');
+        %disp([norm_grad_str' norm_grad_src' norm_grad_tot' norm_grad_src'./norm_grad_str']);
+        %disp(' mean of the last column :');
+        disp([fac mean( norm_grad_src'./norm_grad_str' )]);
+    end
+        
+end
+
+%------------------------------------------------------------------------
+
+% truncated singular value decomposition
+TSVD = 0;
+if TSVD == 1
+    
+    % analyze the singular values of H
+    [U,S,V] = svd(H);
+    s = diag(S);
+    
+    if 0==1
+        % analyze the singular values of H
+        % (See also tsvd.m)
+        [U,S,V] = svd(H);
+        s = diag(S);
+        p = sum( s > sval_cut );     % KEY: singular value truncation index
+        sp = s(1:p);
+        Sp = diag(sp);
+        Up = U(:,1:p);
+        Vp = V(:,1:p);
+        whos U S V
+        whos Up Sp Vp
+        Hp = Up*Sp*Vp';
+        Hinv = Vp*inv(Sp)*Up';
+        mu = Hinv * dnorm;
+        
+        if 0==1
+            Ncheck = zeros(nsrc,1);
+            for p = 1:nsrc
+                sp = s(1:p);
+                Sp = diag(sp);
+                Up = U(:,1:p);
+                Vp = V(:,1:p);
+                Hp = Up*Sp*Vp';
+
+                Hinv = Vp*inv(Sp)*Up';
+                mu = Hinv * dnorm;
+                dm_str = transpose(Gstr) * mu .* cov_beta';  % order?
+                m_str_B_new = m_str_B + dm_str;
+                Ncheck(p) = sum( (dnorm - Gstr*dm_str).^2 );  % matches rss from tsvd.m
+            end
+        end
+        
+        % check the norms and the norms of the inverse
+        norm(H), norm( U*S*V' ), norm(Hp)
+        norm(inv(H)), norm( Vp*inv(Sp)*Up' ), norm(inv(Hp))
+        
+        figure; hold on; plot(H(:),'b.'); plot(Hp(:),'ro');
+    end
+    
+    %H = H / 0.5;   % 9550
+    
+    pinds = [1:nsrc]';
+    [mu_all,rss,f_r_ss] = tsvd(dnorm,H,pinds);   % KEY: TSVD
+    
+    % norms of mu vectors
+    mu_norm = zeros(nsrc,1);
+    for ip = 1:nsrc
+        mu_norm(ip) = norm(mu_all(:,ip));
+    end
+    
+    figure; nr=2; nc=2;
+    xlab1 = 'p, singular value index';
+    xlab2 = 'p, singular value truncation index';
+    ylab1 = 'singular value';
+    ylab2 = 'misfit : dot[ d - H*mu(p), d - H*mu(p) ]';
+   
+    subplot(nr,nc,1); plot(pinds,s,'.','markersize',20);
+    grid on; xlabel(xlab1); ylabel(ylab1); title(dir2lab);
+    subplot(nr,nc,2); semilogy(pinds,s,'.','markersize',20);
+    grid on; xlabel(xlab1); ylabel(ylab1);
+    subplot(nr,nc,3); plot(pinds,rss,'.','markersize',20);
+    grid on; xlabel(xlab2); ylabel(ylab2);
+    subplot(nr,nc,4); semilogy(pinds,rss,'.','markersize',20);
+    grid on; xlabel(xlab2); ylabel(ylab2);
+    orient tall, wysiwyg
+    
+    figure; nr=2; nc=2;
+    ylab3 = 'norm of mu vector';
+   
+    subplot(nr,nc,1); semilogy(pinds,s,'.','markersize',20);
+    grid on; xlabel(xlab1); ylabel(ylab1);
+    subplot(nr,nc,2); semilogy(pinds,rss,'.','markersize',20);
+    grid on; xlabel(xlab2); ylabel(ylab2);
+    subplot(nr,nc,3); plot(pinds,mu_all,'.');
+    grid on; xlabel('source index'); ylabel('elements of mu vectors');
+    subplot(nr,nc,4); semilogy(pinds,mu_norm,'.','markersize',20);
+    grid on; xlabel(xlab2); ylabel(ylab3);
+    orient tall, wysiwyg
+else
+    Hinv = inv(H);
+    mu = Hinv * dnorm;
+end
+
+%------------------------------------------------------------------------
+
+% set of pmax TSVD values to try (if TSVD = 1)
+if TSVD == 1
+    iyes = 0;
+    while iyes == 0
+        disp(' Enter truncation values for TSVD:');
+        pmin = input(' Enter pmin : ');
+        pmax = input(' Enter pmax : ');
+        pinc = input(' Enter pinc : ');
+        pmax_vec = [pmin : pinc : pmax]
+        iyes = input(' Enter 1 if this is what you want (0 otherwise) : ');
+    end
+else
+    pmax_vec = 1;
+end
+nump = length(pmax_vec);
+
+source_error_norm_mat = zeros(nump,5);
+source_error_norm_mat(:,1) = pmax_vec';
+
+if inew == 1
+    Hnew = GG'*GG + Cmi;
+    dnew = GG'*dnorm;
+end
+
+for ip = 1:nump
+
+    % OPTIONS FOR INVERTING HESSIAN:
+    % (1) truncated singular value decomposition
+    % (2) cross-validation
+    if TSVD == 1
+        pmax = pmax_vec(ip);
+        disp(sprintf('%i out of %i : pmax = %i',ip,nump,pmax));
+        
+        %[mu_all,rss,f_r_ss] = tsvd(dnorm,H,pinds);   % KEY: TSVD
+        mu = mu_all(:,pmax);        % KEY vector
+
+        stp = sprintf('pmax = %i',pmax);
+        if 0 == 1
+            figure; nr=2; nc=2;
+            subplot(nr,nc,1);
+            plot(pinds,s,'.',pinds(pmax),s(pmax),'pr','markersize',20,'linewidth',2);
+            grid on; xlabel(xlab1); ylabel(ylab1); title({dir2lab,stp});
+            subplot(nr,nc,2);
+            semilogy(pinds,s,'.',pinds(pmax),s(pmax),'pr','markersize',20,'linewidth',2);
+            grid on; xlabel(xlab1); ylabel(ylab1); title(stp);
+            subplot(nr,nc,3);
+            plot(pinds,rss,'.',pinds(pmax),rss(pmax),'pr','markersize',20,'linewidth',2);
+            grid on; xlabel(xlab2); ylabel(ylab2); title(stp);
+            subplot(nr,nc,4);
+            semilogy(pinds,rss,'.',pinds(pmax),rss(pmax),'pr','markersize',20,'linewidth',2);
+            grid on; xlabel(xlab2); ylabel(ylab2); title(stp);
+            orient tall, wysiwyg
+        end
+
+    else
+        if inew == 1
+            midlampwr = log10(trace(Hnew))/2;
+        else
+            midlampwr = log10(trace(H))/2;
+        end
+        
+        % regularization choices
+        %minlampwr = -3; maxlampwr = 3;
+        minlampwr = midlampwr - 2; maxlampwr = midlampwr + 2;
+        numlam = 100;
+        lampwr = linspace(minlampwr,maxlampwr,numlam);
+        lamvec = 10.^lampwr;
+        
+        if inew == 1
+            [f_h, rss, mss, Gvec, Fvec, dof, kap, iL, iGCV, iOCV] = ridge_carl(dnew,Hnew,lamvec);
+        else
+            [f_h, rss, mss, Gvec, Fvec, dof, kap, iL, iGCV, iOCV] = ridge_carl(dnorm,H,lamvec);
+        end
+        
+        ipick = input(' Enter 0 for GCV, 1 for OCV, 2 for L-curve : ');
+        switch ipick
+            case 0, lam = lamvec(iGCV);
+            case 1, lam = lamvec(iOCV);
+            case 2, lam = lamvec(iL);
+        end
+        
+        % KEY vector
+        if inew == 1
+            mu = inv(Hnew'*Hnew + lam^2*eye(3*nsrc,3*nsrc))*Hnew'*dnew;
+        else
+            mu = inv(H'*H + lam^2*eye(nsrc,nsrc))*H'*dnorm;
+        end
+        
+        stp = sprintf('lambda = %.3f',lam);
+        
+        %Hinv = inv(H);
+        %mu = Hinv * dnorm;
+    end
+    
+    % testing H + I
+    %Hinv = inv(H);
+    %mu = Hinv * dnorm;
+
+    % KEY: solve for the STRUCTURE model update
+    dm_str = zeros(nmod_str,1);
+    if INV_STRUCT == 1
+        if inew == 1
+            dm_str = cov_beta' .* (Pstr * mu(1:nsrc));
+        else
+            dm_str = cov_beta' .* (transpose(Gstr) * mu);
+        end
+    end
+    %disp(' norm of structure update:');
+    %sum( dm_str .* dm_str ./ cov_beta' )
+    
+    % KEY: solve for the SOURCE model update (ts1, ts2, ..., xs1, xs2, ..., ys1, ys2, ...)
+    dm_src = zeros(nmod_src,1);
+    if INV_SOURCE == 1
+        %mtemp = repmat(mu',3,1); mu_expand = mtemp(:);
+        %wtemp = repmat(ws',3,1); ws_expand = wtemp(:);
+        %dm_src = -cov_src' .* grad_src' .* ws_expand .* mu_expand;  % SIGN OR NOT?
+        
+        if inew == 1
+            dm_src = cov_src' .* (Psrc * mu(nsrc+1:end));
+        else
+            dm_src = cov_src' .* (transpose(Gsrc) * mu);
+        end
+    end
+    %disp(' norm of source update:');
+    %sum( dm_src .* dm_src ./ cov_src' )
+    
+    %-------------------
+
+    % source parameter updates
+    if INV_SOURCE == 1
+
+        %for ii = 1:nsrc
+        %    i0 = (ii-1)*3;
+        %    m_src_xs_new(ii) = m_src_xs(ii) + dm_src(i0+1);
+        %    m_src_ys_new(ii) = m_src_ys(ii) + dm_src(i0+2);
+        %    m_src_ts_new(ii) = m_src_ts(ii) + dm_src(i0+3);
+        %end
+        
+        m_src_ts_new = m_src_ts + dm_src(inds_ts - m_inds(2,2));
+        m_src_xs_new = m_src_xs + dm_src(inds_xs - m_inds(2,2));
+        m_src_ys_new = m_src_ys + dm_src(inds_ys - m_inds(2,2));
+        
+        m_src_ts_d_new = m_src_ts_new - m_src_ts_dat;
+        m_src_xs_d_new = m_src_xs_new - m_src_xs_dat;
+        m_src_ys_d_new = m_src_ys_new - m_src_ys_dat;
+
+%         idisplay = 0;   % display information on source parameters
+%         if idisplay == 1
+%             disp('  '); disp('Source parameter updates:');
+%             for ii = 1:nsrc
+%                 i0 = (ii-1)*3;
+%                 disp(sprintf('  Event %2i : (xs = %7.1f m,  ys = %7.1f m,  ts = %5.2f s )',...
+%                    ii,dm_src(i0+1),dm_src(i0+2),dm_src(i0+3) ));
+%             end
+%             disp('  '); disp('Current parameter errors:');
+%             for ii = 1:nsrc
+%                 disp(sprintf('  Event %2i : (xs = %7.1f m,  ys = %7.1f m,  ts = %5.2f s )',...
+%                    ii, m_src_xs_d(ii), m_src_ys_d(ii),m_src_ts_d(ii)));
+%             end
+%             disp('  '); disp('New source parameter errors:');
+%             for ii = 1:nsrc
+%                 disp(sprintf('  Event %2i : (xs = %7.1f m,  ys = %7.1f m,  ts = %5.2f s )',...
+%                    ii, m_src_xs_d_new(ii), m_src_ys_d_new(ii),m_src_ts_d_new(ii)));
+%             end
+%         end
+    else
+        m_src_ts_d_new = m_src_ts_d;
+        m_src_xs_d_new = m_src_xs_d;
+        m_src_ys_d_new = m_src_ys_d;
+        
+        m_src_ts_new = m_src_ts;
+        m_src_xs_new = m_src_xs;
+        m_src_ys_new = m_src_ys;
+    end
+
+    % compute norms of errors in new source parameters
+    %norm_ts = sum(m_src_ts_d_new.^2 ./ cov_src(3:3:nsrc*3)');
+    %norm_xs = sum(m_src_xs_d_new.^2 ./ cov_src(1:3:nsrc*3)');
+    %norm_ys = sum(m_src_ys_d_new.^2 ./ cov_src(2:3:nsrc*3)');
+    norm_ts = sum(m_src_ts_d_new.^2 ./ cov_model(inds_ts));
+    norm_xs = sum(m_src_xs_d_new.^2 ./ cov_model(inds_xs));
+    norm_ys = sum(m_src_ys_d_new.^2 ./ cov_model(inds_ys));
+    source_error_norm_mat(ip,[2:5]) = [norm_xs norm_ys norm_ts sum([norm_xs norm_ys norm_ts])];
+    
+    % structure parameter updates
+    if INV_STRUCT == 1
+        m_str_B_new = m_str_B + dm_str;   % updated B
+        m_str_C_new = m_str_C; 
+    else
+        m_str_B_new = m_str_B;
+        m_str_C_new = m_str_C;
+    end
+
+    % convert to beta, c, kappa, mu, rho
+    m_str_beta_new  = beta0 * exp( m_str_B_new );
+    m_str_bulk_new  = bulk0 * exp( m_str_C_new );
+    m_str_rho_new   = m_str_rho;
+    m_str_kappa_new = m_str_rho_new .* m_str_bulk_new.^2;
+    m_str_mu_new    = m_str_rho_new .* m_str_beta_new.^2;
+
+    %disp(' norm of new structure model:');
+    %sum( m_str_B_new .* m_str_B_new ./ cov_beta' )
+    
+    % plot structure model update and new model
+    if and(INV_STRUCT == 1, ifigure == 1)
+        tlabs = {{dir2lab,'data'},'m0',['dm (' stp ')'],['m1 (' stp ')']};
+        cmax = 0.1;
+        figure; nr=3; nc=2;
+        for kk = 1:4
+            switch kk
+                case 1, mplot = m_dat_str_B;
+                case 2, mplot = m_str_B;
+                case 3, mplot = dm_str;
+                case 4, mplot = m_str_B_new;
+            end
+            [X,Y,Z] = griddataXB(lon,lat,mplot,100,'nearest');
+
+            subplot(nr,nc,kk); hold on;
+            pcolor(X,Y,Z); shading interp;
+            caxis([-1 1]*cmax); colormap(seis); axis equal, axis tight
+            plot(rlon,rlat,'k.','markersize',16);
+            plot(slon,slat,'p','markersize',18,'markeredgecolor','k','linewidth',2);
+            title(tlabs{kk});
+        end
+        
+        % TSVD plots
+        if TSVD == 1
+            subplot(nr,nc,5);
+            semilogy(pinds,s,'.',pinds(pmax),s(pmax),'pr','markersize',20,'linewidth',2);
+            grid on; xlabel(xlab1); ylabel(ylab1); title(stp);
+            subplot(nr,nc,6);
+            semilogy(pinds,rss,'.',pinds(pmax),rss(pmax),'pr','markersize',20,'linewidth',2);
+            grid on; xlabel(xlab2); ylabel(ylab2); title(stp);
+        end
+        
+        orient tall, wysiwyg
+    end
+
+    % write EVERY pmax updated model to file
+    if iwrite == 1
+        
+        if COMPUTE_KERNELS
+            dir3 = dir2;
+        else
+            % make directory
+            pdir = ['run_p' sprintf('%2.2i',ip)];
+            dir3 = [dir2 pdir '/'];
+            mkdir(dir2,pdir)
+        end
+        
+        % save pertinent Matlab variables
+        save([dir3 'wave2d_subspace_matlab_h' sth],...
+            'dnorm','H','Hsrc','Hstr',...
+            'mu','INV_SOURCE','INV_STRUCT');
+
+        % ! CURRENT MODEL (synthetics)
+        % write(19,'(7e20.10)') x_plot(iglob), z_plot(iglob), &
+        % kappa_syn(i,j,ispec), mu_syn(i,j,ispec), rho_syn(i,j,ispec), &
+        % log( bulk_syn(i,j,ispec) / bulk0 ), log( beta_syn(i,j,ispec) / beta0 ) 
+        fid = fopen([dir3 'structure_syn_h' sth '.dat'],'w');
+        for ii = 1:length(m_str_lon)
+            fprintf(fid,'%20.10e%20.10e%20.10e%20.10e%20.10e%20.10e%20.10e\n',...
+                 m_str_lon(ii), m_str_lat(ii),...
+                 m_str_kappa_new(ii), m_str_mu_new(ii), m_str_rho_new(ii),...
+                 m_str_C_new(ii), m_str_B_new(ii) );   
+        end
+        fclose(fid);
+
+        % ! sources for synthetics
+        % write(20,'(8e20.10)') xtemp, ztemp, &
+        % m_src_syn_vec(itemp1), m_src_syn_vec(itemp2), m_src_syn_vec(itemp3), &
+        % (m_src_syn_vec(itemp1) - m_src_dat_vec(itemp1)), &
+        % (m_src_syn_vec(itemp2) - m_src_dat_vec(itemp2)), &
+        % m_src_syn_vec(itemp3) - m_src_dat_vec(itemp3)
+        fid = fopen([dir3 'src_syn_h' sth '.dat'],'w');
+        for ii = 1:length(m_src_lon)
+            fprintf(fid,'%20.10e%20.10e%20.10e%20.10e%20.10e%20.10e%20.10e%20.10e\n',...
+                 m_src_lon(ii), m_src_lat(ii),...
+                 m_src_ts_new(ii), m_src_xs_new(ii), m_src_ys_new(ii),...
+                 m_src_ts_d_new(ii), m_src_xs_d_new(ii), m_src_ys_d_new(ii) );   
+        end
+        fclose(fid);
+
+        % write out pmax
+        if TSVD == 1
+            fid = fopen([dir3 'pmax_h' sth '.dat'],'w');
+            fprintf(fid,'%i\n',pmax);   
+            fclose(fid);
+        else
+            fid = fopen([dir3 'lambda_h' sth '.dat'],'w');
+            fprintf(fid,'%16.8e\n',lam);   
+            fclose(fid);
+        end
+        
+        % write out the balance of the gradient norms
+        fid = fopen([dir3 'norm_gradient_h' sth '.dat'],'w');
+        fprintf(fid,'Balance of the gradients for each event\n');
+        fprintf(fid,'%16s%16s%16s%16s\n','STR','SRC','TOTAL','SRC/STR');
+        for ii = 1:nsrc
+            fprintf(fid,'%16.4f%16.4f%16.4f%16.4f\n',...
+                Hstr(ii,ii), Hsrc(ii,ii), H(ii,ii), Hsrc(ii,ii)/Hstr(ii,ii) );
+        end
+        fprintf(fid,'%48s%16.4f\n','MEAN -->',mean( diag(Hsrc)./diag(Hstr)) );
+        fclose(fid);
+        
+    end
+    
+end  % ip
+
+% norm in intial source errors
+%norm_xs = sum(m_src_xs_d.^2 ./ cov_src(1:3:nsrc*3)');
+%norm_ys = sum(m_src_ys_d.^2 ./ cov_src(2:3:nsrc*3)');
+%norm_ts = sum(m_src_ts_d.^2 ./ cov_src(3:3:nsrc*3)');
+norm_ts = sum(m_src_ts_d.^2 ./ cov_model(inds_ts));
+norm_xs = sum(m_src_xs_d.^2 ./ cov_model(inds_xs));
+norm_ys = sum(m_src_ys_d.^2 ./ cov_model(inds_ys));
+source_error_norm_old = [0 norm_xs norm_ys norm_ts sum([norm_xs norm_ys norm_ts])];
+
+disp('   ');
+disp(' NORMS of the errors in the old source vectors (xs, ys, ts) :');
+disp(source_error_norm_old);
+disp(' NORMS of the errors in the new source vectors (xs, ys, ts) :');
+disp('    pmax         xs        ys        ts      total');
+disp(source_error_norm_mat);
+
+% save pertinent Matlab variables
+if iwrite == 1
+    if COMPUTE_KERNELS
+        ofile = [dir2 'wave2d_subspace_matlab_pmax'];
+    else
+        ofile = [dir2 'wave2d_subspace_matlab_all'];
+    end
+    
+    if TSVD == 0
+        save(ofile,'dnorm','lamvec','lam',...
+            'f_h','rss','mss','Gvec','Fvec','dof','kap','iL','iGCV','iOCV',...
+            'source_error_norm_mat','source_error_norm_old',...
+            'INV_SOURCE','INV_STRUCT');
+    else   
+        save(ofile,'dnorm','U','S','V','pinds','mu_all','rss','f_r_ss',...
+            'source_error_norm_mat','source_error_norm_old',...
+            'INV_SOURCE','INV_STRUCT');
+    end
+end
+
+%------------------------------------------------
+% extra code for plotting misfit values
+
+if 0==1
+   clear
+   
+   run0 = 6550; close all
+   for h = 1:4
+
+       strun0 = num2str(run0);
+       sth = sprintf('%2.2i',h);
+       idir = ['/net/denali/scratch1/carltape/OUTPUT/run_' strun0 '/HESSIAN/model_m' sth '/'];
+       load([idir 'wave2d_subspace_matlab_all']);
+
+       clear chi_data_norm chi_model_norm chi_total pmax_vec
+       for ii = 1:25
+          dir1 = [ idir 'run_p' sprintf('%2.2i',ii) '/'];
+          chi_file = [dir1 'chi_data_norm.dat'];
+          if exist(chi_file)
+              chi_data_norm(ii) = load(chi_file);
+              chi_model_norm(ii) = load([dir1 'chi_model_norm.dat']);
+              chi_total(ii) = load([dir1 'chi.dat']);
+              %chi_total(ii) = load([dir1 'summed_chi_all.dat']);
+              pmax_vec(ii) = load([dir1 'pmax_h' sth '.dat']);
+          end
+       end
+
+       %disp('  '); disp('     pmax  2*S(m(pmax)) S-data   S-model');
+       %disp([pinds 2*chi_total' chi_data_norm' chi_model_norm']);
+
+       % semilogy plots or not?
+       figure; nr=2; nc=2;
+       xlab1 = 'p, singular value index';
+       xlab2 = 'p, singular value truncation index';
+       ylab1 = 'singular value';
+       ylab2 = 'misfit : dot[ d - G*dm(p), d - G*dm(p) ]';
+
+       subplot(nr,nc,1); semilogy(pinds, diag(S),'.','markersize',22); grid on;
+       xlabel(xlab1); ylabel(ylab1);
+       subplot(nr,nc,3); semilogy(pinds, rss,'.','markersize',22); grid on;
+       xlabel(xlab2); ylabel(ylab2);
+
+       subplot(nr,nc,2);
+       plot( pmax_vec,2*chi_total,'r.',pmax_vec,chi_data_norm,'b.','markersize',22);
+       grid on; legend('2 S(m(pmax))','chi-data-norm');
+       xlabel(xlab2); title(['RUN ' strun0 ' - H' sth]);
+       subplot(nr,nc,4);
+       plot( pmax_vec,chi_model_norm,'g.','markersize',22);
+       grid on; legend('chi-model-norm','location','northeast');
+       xlabel(xlab2); title(['RUN ' strun0 ' - H' sth]);
+
+       orient tall, wysiwyg
+   end
+   
+end
+
+%======================================================================

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wysiwyg.m
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wysiwyg.m	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/matlab/wysiwyg.m	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,17 @@
+function wysiwyg
+%WYSIWYG -- this function is called with no args and merely
+%       changes the size of the figure on the screen to equal
+%       the size of the figure that would be printed, 
+%       according to the papersize attribute.  Use this function
+%       to give a more accurate picture of what will be 
+%       printed.
+%       Dan(K) Braithwaite, Dept. of Hydrology U.of.A  11/93
+ 
+unis = get(gcf,'units');
+ppos = get(gcf,'paperposition');
+set(gcf,'units',get(gcf,'paperunits'));
+pos = get(gcf,'position');
+pos(3:4) = ppos(3:4);
+set(gcf,'position',pos);
+set(gcf,'units',unis);
+  

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/Makefile
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/Makefile	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/Makefile	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,45 @@
+F90 = ifort 
+F90_FLAGS = -O2
+#F90_FLAGS = -O2 -check all -align all     # type "man ifort" for options
+
+# first is for FFT, second is for bandpass filter
+#LIB = -L/opt/seismo-util/lib -lfftw3 -lDSacLib
+
+# libraries for the original filter.f90
+#LIB = -L/opt/seismo-util/lib -lDRWFiles -lDSacLib -lDSacio -lSacTools -lm
+
+# wave2d_solver should be LAST, since it calls wave2d_sub
+#MOD = wave2d_constants wave2d_variables wave2d_define_der_matrices wave2d_sub wave2d_sub2 wave2d_sub3 wave2d_solver
+MOD = wave2d_constants wave2d_variables wave2d_define_der_matrices wave2d_sub wave2d_sub2 wave2d_sub4 wave2d_solver
+SUB = gll_library lagrange_poly numerical_recipes
+
+SRC_DIR = src
+MOD_DIR = mod
+OBJ_DIR = obj
+BIN_DIR = .
+MAIN = wave2d wave2d_2 wave2d_3 wave2d_4 test_smooth
+MOD_FLAG = module
+
+MOD_OBJ = $(patsubst %,$(OBJ_DIR)/%.o,$(MOD))
+F90_OBJ = $(patsubst %,$(OBJ_DIR)/%.o,$(SUB))
+OBJ = $(F90_OBJ) $(MOD_OBJ)
+
+all : wave2d wave2d_2 wave2d_3 wave2d_4 test_smooth
+
+$(MAIN) : % : $(SRC_DIR)/%.f90 $(F90_OBJ) $(MOD_OBJ)
+	$(F90) -o $(BIN_DIR)/$* $(F90_FLAGS) $(SRC_DIR)/$*.f90 -$(MOD_FLAG) $(MOD_DIR) $(OBJ) $(LIB)
+
+$(F90_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.f90
+	$(F90) -o $@ $(F90_FLAGS) -c $(SRC_DIR)/$*.f90 
+
+$(MOD_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.f90
+	$(F90) -o $@ $(F90_FLAGS) -c $(SRC_DIR)/$*.f90 -$(MOD_FLAG) $(MOD_DIR) 
+
+.PHONY : clean
+
+clean:
+	\rm -f *.o *.mod *~ $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod  *.gif *.ps $(MAIN)  plot*.csh *.eps *.cpt src/*~
+cleanall:
+	\rm -f OUTPUT/* *.o *.mod *~ $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod  *.gif *.jpg *.ps $(MAIN)  plot*.csh *.eps *.cpt
+
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/gll_library.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/gll_library.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/gll_library.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,528 @@
+!=======================================================================
+!
+!  Library to compute the Gauss-Lobatto-Legendre points and weights
+!  Based on Gauss-Lobatto routines from M.I.T.
+!  Department of Mechanical Engineering
+!
+!=======================================================================
+
+  double precision function endw1(n,alpha,beta)
+
+  implicit none
+
+  integer n
+  double precision alpha,beta
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0,three=3.d0,four=4.d0
+  double precision apb,f1,fint1,fint2,f2,di,abn,abnn,a1,a2,a3,f3
+  double precision, external :: gammaf
+  integer i
+
+  f3 = zero
+  apb   = alpha+beta
+  if (n == 0) then
+   endw1 = zero
+   return
+  endif
+  f1   = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
+  f1   = f1*(apb+two)*two**(apb+two)/two
+  if (n == 1) then
+   endw1 = f1
+   return
+  endif
+  fint1 = gammaf(alpha+two)*gammaf(beta+one)/gammaf(apb+three)
+  fint1 = fint1*two**(apb+two)
+  fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
+  fint2 = fint2*two**(apb+three)
+  f2    = (-two*(beta+two)*fint1 + (apb+four)*fint2) * (apb+three)/four
+  if (n == 2) then
+   endw1 = f2
+   return
+  endif
+  do i=3,n
+   di   = dble(i-1)
+   abn  = alpha+beta+di
+   abnn = abn+di
+   a1   = -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
+   a2   =  (two*(alpha-beta))/(abnn*(abnn+two))
+   a3   =  (two*(abn+one))/((abnn+two)*(abnn+one))
+   f3   =  -(a2*f2+a1*f1)/a3
+   f1   = f2
+   f2   = f3
+  enddo
+  endw1  = f3
+
+  end function endw1
+
+!
+!=======================================================================
+!
+
+  double precision function endw2(n,alpha,beta)
+
+  implicit none
+
+  integer n
+  double precision alpha,beta
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0,three=3.d0,four=4.d0
+  double precision apb,f1,fint1,fint2,f2,di,abn,abnn,a1,a2,a3,f3
+  double precision, external :: gammaf
+  integer i
+
+  apb   = alpha+beta
+  f3 = zero
+  if (n == 0) then
+   endw2 = zero
+   return
+  endif
+  f1   = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
+  f1   = f1*(apb+two)*two**(apb+two)/two
+  if (n == 1) then
+   endw2 = f1
+   return
+  endif
+  fint1 = gammaf(alpha+one)*gammaf(beta+two)/gammaf(apb+three)
+  fint1 = fint1*two**(apb+two)
+  fint2 = gammaf(alpha+two)*gammaf(beta+two)/gammaf(apb+four)
+  fint2 = fint2*two**(apb+three)
+  f2    = (two*(alpha+two)*fint1 - (apb+four)*fint2) * (apb+three)/four
+  if (n == 2) then
+   endw2 = f2
+   return
+  endif
+  do i=3,n
+   di   = dble(i-1)
+   abn  = alpha+beta+di
+   abnn = abn+di
+   a1   =  -(two*(di+alpha)*(di+beta))/(abn*abnn*(abnn+one))
+   a2   =  (two*(alpha-beta))/(abnn*(abnn+two))
+   a3   =  (two*(abn+one))/((abnn+two)*(abnn+one))
+   f3   =  -(a2*f2+a1*f1)/a3
+   f1   = f2
+   f2   = f3
+  enddo
+  endw2  = f3
+
+  end function endw2
+
+!
+!=======================================================================
+!
+
+  double precision function gammaf (x)
+
+  implicit none
+
+  double precision, parameter :: pi = 3.141592653589793d0
+
+  double precision x
+
+  double precision, parameter :: half=0.5d0,one=1.d0,two=2.d0
+
+  gammaf = one
+
+  if (x == -half) gammaf = -two*dsqrt(pi)
+  if (x ==  half) gammaf =  dsqrt(pi)
+  if (x ==  one ) gammaf =  one
+  if (x ==  two ) gammaf =  one
+  if (x ==  1.5d0) gammaf =  dsqrt(pi)/2.d0
+  if (x ==  2.5d0) gammaf =  1.5d0*dsqrt(pi)/2.d0
+  if (x ==  3.5d0) gammaf =  2.5d0*1.5d0*dsqrt(pi)/2.d0
+  if (x ==  3.d0 ) gammaf =  2.d0
+  if (x ==  4.d0 ) gammaf = 6.d0
+  if (x ==  5.d0 ) gammaf = 24.d0
+  if (x ==  6.d0 ) gammaf = 120.d0
+
+  end function gammaf
+
+!
+!=====================================================================
+!
+
+  subroutine jacg (xjac,np,alpha,beta)
+
+!=======================================================================
+!
+! computes np Gauss points, which are the zeros of the
+! Jacobi polynomial with parameters alpha and beta
+!
+!                  .alpha = beta =  0.0  ->  Legendre points
+!                  .alpha = beta = -0.5  ->  Chebyshev points
+!
+!=======================================================================
+
+  implicit none
+
+  integer np
+  double precision alpha,beta
+  double precision xjac(np)
+
+  integer k,j,i,jmin,jm,n
+  double precision xlast,dth,x,x1,x2,recsum,delx,xmin,swap
+  double precision p,pd,pm1,pdm1,pm2,pdm2
+
+  integer, parameter :: K_MAX_ITER = 10
+  double precision, parameter :: zero = 0.d0, eps = 1.0d-12
+
+  pm1 = zero
+  pm2 = zero
+  pdm1 = zero
+  pdm2 = zero
+
+  xlast = 0.d0
+  n   = np-1
+  dth = 4.d0*datan(1.d0)/(2.d0*dble(n)+2.d0)
+  p = 0.d0
+  pd = 0.d0
+  jmin = 0
+  do j=1,np
+   if(j == 1) then
+      x = dcos((2.d0*(dble(j)-1.d0)+1.d0)*dth)
+   else
+      x1 = dcos((2.d0*(dble(j)-1.d0)+1.d0)*dth)
+      x2 = xlast
+      x  = (x1+x2)/2.d0
+   endif
+   do k=1,K_MAX_ITER
+      call jacobf (p,pd,pm1,pdm1,pm2,pdm2,np,alpha,beta,x)
+      recsum = 0.d0
+      jm = j-1
+      do i=1,jm
+         recsum = recsum+1.d0/(x-xjac(np-i+1))
+      enddo
+      delx = -p/(pd-recsum*p)
+      x    = x+delx
+      if(abs(delx) < eps) goto 31
+   enddo
+ 31      continue
+   xjac(np-j+1) = x
+   xlast        = x
+  enddo
+  do i=1,np
+   xmin = 2.d0
+   do j=i,np
+      if(xjac(j) < xmin) then
+         xmin = xjac(j)
+         jmin = j
+      endif
+   enddo
+   if(jmin /= i) then
+      swap = xjac(i)
+      xjac(i) = xjac(jmin)
+      xjac(jmin) = swap
+   endif
+  enddo
+
+  end subroutine jacg
+
+!
+!=====================================================================
+!
+
+  subroutine jacobf (poly,pder,polym1,pderm1,polym2,pderm2,n,alp,bet,x)
+
+!=======================================================================
+!
+! Computes the Jacobi polynomial of degree n and its derivative at x
+!
+!=======================================================================
+
+  implicit none
+
+  double precision poly,pder,polym1,pderm1,polym2,pderm2,alp,bet,x
+  integer n
+
+  double precision apb,polyl,pderl,dk,a1,a2,b3,a3,a4,polyn,pdern,psave,pdsave
+  integer k
+
+  apb  = alp+bet
+  poly = 1.d0
+  pder = 0.d0
+  psave = 0.d0
+  pdsave = 0.d0
+
+  if (n == 0) return
+
+  polyl = poly
+  pderl = pder
+  poly  = (alp-bet+(apb+2.d0)*x)/2.d0
+  pder  = (apb+2.d0)/2.d0
+  if (n == 1) return
+
+  do k=2,n
+    dk = dble(k)
+    a1 = 2.d0*dk*(dk+apb)*(2.d0*dk+apb-2.d0)
+    a2 = (2.d0*dk+apb-1.d0)*(alp**2-bet**2)
+    b3 = (2.d0*dk+apb-2.d0)
+    a3 = b3*(b3+1.d0)*(b3+2.d0)
+    a4 = 2.d0*(dk+alp-1.d0)*(dk+bet-1.d0)*(2.d0*dk+apb)
+    polyn  = ((a2+a3*x)*poly-a4*polyl)/a1
+    pdern  = ((a2+a3*x)*pder-a4*pderl+a3*poly)/a1
+    psave  = polyl
+    pdsave = pderl
+    polyl  = poly
+    poly   = polyn
+    pderl  = pder
+    pder   = pdern
+  enddo
+
+  polym1 = polyl
+  pderm1 = pderl
+  polym2 = psave
+  pderm2 = pdsave
+
+  end subroutine jacobf
+
+!
+!------------------------------------------------------------------------
+!
+
+  double precision FUNCTION PNDLEG (Z,N)
+
+!------------------------------------------------------------------------
+!
+!     Compute the derivative of the Nth order Legendre polynomial at Z.
+!     Based on the recursion formula for the Legendre polynomials.
+!
+!------------------------------------------------------------------------
+  implicit none
+
+  double precision z
+  integer n
+
+  double precision P1,P2,P1D,P2D,P3D,FK,P3
+  integer k
+
+  P1   = 1.d0
+  P2   = Z
+  P1D  = 0.d0
+  P2D  = 1.d0
+  P3D  = 1.d0
+
+  do K = 1, N-1
+    FK  = dble(K)
+    P3  = ((2.d0*FK+1.d0)*Z*P2 - FK*P1)/(FK+1.d0)
+    P3D = ((2.d0*FK+1.d0)*P2 + (2.d0*FK+1.d0)*Z*P2D - FK*P1D) / (FK+1.d0)
+    P1  = P2
+    P2  = P3
+    P1D = P2D
+    P2D = P3D
+  enddo
+
+  PNDLEG = P3D
+
+  end function pndleg
+
+!
+!------------------------------------------------------------------------
+!
+
+  double precision FUNCTION PNLEG (Z,N)
+
+!------------------------------------------------------------------------
+!
+!     Compute the value of the Nth order Legendre polynomial at Z.
+!     Based on the recursion formula for the Legendre polynomials.
+!
+!------------------------------------------------------------------------
+  implicit none
+
+  double precision z
+  integer n
+
+  double precision P1,P2,P3,FK
+  integer k
+
+  P1   = 1.d0
+  P2   = Z
+  P3   = P2
+
+  do K = 1, N-1
+    FK  = dble(K)
+    P3  = ((2.d0*FK+1.d0)*Z*P2 - FK*P1)/(FK+1.d0)
+    P1  = P2
+    P2  = P3
+  enddo
+
+  PNLEG = P3
+
+  end function pnleg
+
+!
+!------------------------------------------------------------------------
+!
+
+  double precision function pnormj (n,alpha,beta)
+
+  implicit none
+
+  double precision alpha,beta
+  integer n
+
+  double precision one,two,dn,const,prod,dindx,frac
+  double precision, external :: gammaf
+  integer i
+
+  one   = 1.d0
+  two   = 2.d0
+  dn    = dble(n)
+  const = alpha+beta+one
+
+  if (n <= 1) then
+    prod   = gammaf(dn+alpha)*gammaf(dn+beta)
+    prod   = prod/(gammaf(dn)*gammaf(dn+alpha+beta))
+    pnormj = prod * two**const/(two*dn+const)
+    return
+  endif
+
+  prod  = gammaf(alpha+one)*gammaf(beta+one)
+  prod  = prod/(two*(one+const)*gammaf(const+one))
+  prod  = prod*(one+alpha)*(two+alpha)
+  prod  = prod*(one+beta)*(two+beta)
+
+  do i=3,n
+    dindx = dble(i)
+    frac  = (dindx+alpha)*(dindx+beta)/(dindx*(dindx+alpha+beta))
+    prod  = prod*frac
+  enddo
+
+  pnormj = prod * two**const/(two*dn+const)
+
+  end function pnormj
+
+!
+!------------------------------------------------------------------------
+!
+
+  subroutine zwgjd(z,w,np,alpha,beta)
+
+!=======================================================================
+!
+!     Z w g j d : Generate np Gauss-Jacobi points and weights
+!                 associated with Jacobi polynomial of degree n = np-1
+!
+!     Note : Coefficients alpha and beta must be greater than -1.
+!     ----
+!=======================================================================
+
+  implicit none
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0
+
+  integer np
+  double precision z(np),w(np)
+  double precision alpha,beta
+
+  integer n,np1,np2,i
+  double precision p,pd,pm1,pdm1,pm2,pdm2
+  double precision apb,dnp1,dnp2,fac1,fac2,fac3,fnorm,rcoef
+  double precision, external :: gammaf,pnormj
+
+  pd = zero
+  pm1 = zero
+  pm2 = zero
+  pdm1 = zero
+  pdm2 = zero
+
+  n    = np-1
+  apb  = alpha+beta
+  p    = zero
+  pdm1 = zero
+
+  if (np <= 0) stop 'minimum number of Gauss points is 1'
+
+  if ((alpha <= -one) .or. (beta <= -one)) stop 'alpha and beta must be greater than -1'
+
+  if (np == 1) then
+   z(1) = (beta-alpha)/(apb+two)
+   w(1) = gammaf(alpha+one)*gammaf(beta+one)/gammaf(apb+two) * two**(apb+one)
+   return
+  endif
+
+  call jacg(z,np,alpha,beta)
+
+  np1   = n+1
+  np2   = n+2
+  dnp1  = dble(np1)
+  dnp2  = dble(np2)
+  fac1  = dnp1+alpha+beta+one
+  fac2  = fac1+dnp1
+  fac3  = fac2+one
+  fnorm = pnormj(np1,alpha,beta)
+  rcoef = (fnorm*fac2*fac3)/(two*fac1*dnp2)
+  do i=1,np
+    call jacobf(p,pd,pm1,pdm1,pm2,pdm2,np2,alpha,beta,z(i))
+    w(i) = -rcoef/(p*pdm1)
+  enddo
+
+  end subroutine zwgjd
+
+!
+!------------------------------------------------------------------------
+!
+
+  subroutine zwgljd(z,w,np,alpha,beta)
+
+!=======================================================================
+!
+!     Z w g l j d : Generate np Gauss-Lobatto-Jacobi points and the
+!     -----------   weights associated with Jacobi polynomials of degree
+!                   n = np-1.
+!
+!     Note : alpha and beta coefficients must be greater than -1.
+!            Legendre polynomials are special case of Jacobi polynomials
+!            just by setting alpha and beta to 0.
+!
+!=======================================================================
+
+  implicit none
+
+  double precision, parameter :: zero=0.d0,one=1.d0,two=2.d0
+
+  integer np
+  double precision alpha,beta
+  double precision z(np), w(np)
+
+  integer n,nm1,i
+  double precision p,pd,pm1,pdm1,pm2,pdm2
+  double precision alpg,betg
+  double precision, external :: endw1,endw2
+
+  p = zero
+  pm1 = zero
+  pm2 = zero
+  pdm1 = zero
+  pdm2 = zero
+
+  n   = np-1
+  nm1 = n-1
+  pd  = zero
+
+  if (np <= 1) stop 'minimum number of Gauss-Lobatto points is 2'
+
+! with spectral elements, use at least 3 points
+  if (np <= 2) stop 'minimum number of Gauss-Lobatto points for the SEM is 3'
+
+  if ((alpha <= -one) .or. (beta <= -one)) stop 'alpha and beta must be greater than -1'
+
+  if (nm1 > 0) then
+    alpg  = alpha+one
+    betg  = beta+one
+    call zwgjd(z(2),w(2),nm1,alpg,betg)
+  endif
+
+  z(1)  = - one
+  z(np) =  one
+
+  do i=2,np-1
+   w(i) = w(i)/(one-z(i)**2)
+  enddo
+
+  call jacobf(p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(1))
+  w(1)  = endw1(n,alpha,beta)/(two*pd)
+  call jacobf(p,pd,pm1,pdm1,pm2,pdm2,n,alpha,beta,z(np))
+  w(np) = endw2(n,alpha,beta)/(two*pd)
+
+  end subroutine zwgljd
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/lagrange_poly.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/lagrange_poly.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/lagrange_poly.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,83 @@
+  subroutine lagrange_poly(xi,NGLL,xigll,h,hprime)
+
+! subroutine to compute the Lagrange interpolants based upon the GLL points
+! and their first derivatives at any point xi in [-1,1]
+
+  implicit none
+
+  integer NGLL
+  double precision xi,xigll(NGLL),h(NGLL),hprime(NGLL)
+
+  integer dgr,i,j
+  double precision prod1,prod2
+
+  do dgr=1,NGLL
+
+  prod1 = 1.0d0
+  prod2 = 1.0d0
+  do i=1,NGLL
+    if(i /= dgr) then
+      prod1 = prod1*(xi-xigll(i))
+      prod2 = prod2*(xigll(dgr)-xigll(i))
+    endif
+  enddo
+  h(dgr)=prod1/prod2
+
+  hprime(dgr)=0.0d0
+  do i=1,NGLL
+    if(i /= dgr) then
+      prod1=1.0d0
+      do j=1,NGLL
+        if(j /= dgr .and. j /= i) prod1 = prod1*(xi-xigll(j))
+      enddo
+      hprime(dgr) = hprime(dgr)+prod1
+    endif
+  enddo
+  hprime(dgr) = hprime(dgr)/prod2
+
+  enddo
+
+  end subroutine lagrange_poly
+
+!
+!=====================================================================
+!
+
+! subroutine to compute the derivative of the Lagrange interpolants
+! at the GLL points at any given GLL point
+
+  double precision function lagrange_deriv_GLL(I,j,ZGLL,NZ)
+
+!------------------------------------------------------------------------
+!
+!     Compute the value of the derivative of the I-th
+!     Lagrange interpolant through the
+!     NZ Gauss-Lobatto Legendre points ZGLL at point ZGLL(j)
+!
+!------------------------------------------------------------------------
+
+  implicit none
+
+  integer i,j,nz
+  double precision zgll(0:nz-1)
+
+  integer degpoly
+
+  double precision, external :: pnleg,pndleg
+
+  degpoly = nz - 1
+  if (i == 0 .and. j == 0) then
+    lagrange_deriv_GLL = - dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+  else if (i == degpoly .and. j == degpoly) then
+    lagrange_deriv_GLL = dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+  else if (i == j) then
+    lagrange_deriv_GLL = 0.d0
+  else
+    lagrange_deriv_GLL = pnleg(zgll(j),degpoly) / &
+      (pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))) &
+      + (1.d0-zgll(j)*zgll(j))*pndleg(zgll(j),degpoly) / (dble(degpoly)* &
+      (dble(degpoly)+1.d0)*pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))*(zgll(j)-zgll(i)))
+  endif
+
+  end function lagrange_deriv_GLL
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/numerical_recipes.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/numerical_recipes.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/numerical_recipes.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,234 @@
+!=====================================================================
+!
+!  Routines from "Numerical Recipes: the Art of Scientific Computing"
+!  W. H. Press et al., Cambridge University Press
+!
+!=====================================================================
+
+! double precision routines
+
+  double precision function erf(x)
+  double precision x
+
+! this routine uses routine gammp
+  double precision gammp
+
+  if(x<0.)then
+    erf=-gammp(0.5d0,x**2)
+  else
+    erf=gammp(0.5d0,x**2)
+  endif
+
+  end function erf
+
+! ---------------------------------
+
+  double precision function gammp(a,x)
+  double precision a,x
+
+! this routine uses routines gcf and gser
+  double precision gammcf,gamser,gln
+
+  if(x<0.d0 .or. a <= 0.d0) stop 'bad arguments in gammp'
+
+  if(x<a+1.d0)then
+    call gser(gamser,a,x,gln)
+    gammp=gamser
+  else
+    call gcf(gammcf,a,x,gln)
+    gammp=1.d0-gammcf
+  endif
+
+  end function gammp
+
+! ---------------------------------
+
+  subroutine gcf(gammcf,a,x,gln)
+
+  double precision a,gammcf,gln,x
+
+  double precision, parameter :: EPS=3.d-7,FPMIN=1.d-30
+  integer, parameter :: ITMAX=100
+
+! this routine uses routine gammln
+
+  integer i
+  double precision an,b,c,d,del,h
+
+  double precision, external :: gammln
+
+  gln=gammln(a)
+  b=x+1.d0-a
+  c=1.d0/FPMIN
+  d=1.d0/b
+  h=d
+  do i=1,ITMAX
+    an=-i*(i-a)
+    b=b+2.d0
+    d=an*d+b
+    if(dabs(d)<FPMIN)d=FPMIN
+    c=b+an/c
+    if(dabs(c)<FPMIN)c=FPMIN
+    d=1.d0/d
+    del=d*c
+    h=h*del
+    if(dabs(del-1.d0)<EPS) then
+      gammcf=exp(-x+a*log(x)-gln)*h
+      return
+    endif
+  enddo
+
+  stop 'a too large, ITMAX too small in gcf'
+
+  end subroutine gcf
+
+! ---------------------------------
+
+  subroutine gser(gamser,a,x,gln)
+
+  double precision a,gamser,gln,x
+
+  integer, parameter :: ITMAX=100
+  double precision, parameter :: EPS=3.d-7
+
+! this routine uses routine gammln
+
+  integer n
+  double precision ap,del,sumval
+
+  double precision, external :: gammln
+
+  gln=gammln(a)
+
+  if(x <= 0.d0)then
+    if(x<0.d0) stop 'x < 0 in gser'
+    gamser=0.d0
+    return
+  endif
+
+  ap=a
+  sumval=1.d0/a
+  del=sumval
+
+  do n=1,ITMAX
+    ap=ap+1.d0
+    del=del*x/ap
+    sumval=sumval+del
+    if(dabs(del)<dabs(sumval)*EPS) then
+      gamser=sumval*exp(-x+a*log(x)-gln)
+      return
+    endif
+  enddo
+
+  stop 'a too large, ITMAX too small in gser'
+
+  end subroutine gser
+
+! ---------------------------------
+
+  double precision function gammln(xx)
+
+  double precision xx
+
+  integer j
+  double precision ser,stp,tmp,x,y,cof(6)
+
+  cof(1) = 76.18009172947146d0
+  cof(2) = -86.50532032941677d0
+  cof(3) = 24.01409824083091d0
+  cof(4) = -1.231739572450155d0
+  cof(5) = 0.1208650973866179d-2
+  cof(6) = -0.5395239384953d-5
+
+  stp = 2.5066282746310005d0
+
+  x=xx
+  y=x
+  tmp=x+5.5d0
+  tmp=(x+0.5d0)*log(tmp)-tmp
+  ser=1.000000000190015d0
+  do j=1,6
+    y=y+1.d0
+    ser=ser+cof(j)/y
+  enddo
+  gammln=tmp+log(stp*ser/x)
+
+  end function gammln
+
+! ---------------------------------
+
+! compute spline coefficients (Numerical Recipes)
+! modified to use dynamic allocation
+
+  subroutine spline(x,y,n,yp1,ypn,y2)
+
+  implicit none
+
+  integer n
+  double precision x(n),y(n),y2(n)
+  double precision yp1,ypn
+  double precision, dimension(:), allocatable :: u
+
+  integer i,k
+  double precision sig,p,qn,un
+
+  allocate(u(n))
+
+  y2(1)=-0.5d0
+  u(1)=(3.d0/(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
+
+  do i=2,n-1
+    sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
+    p=sig*y2(i-1)+2.d0
+    y2(i)=(sig-1.d0)/p
+    u(i)=(6.d0*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1)) &
+                /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p
+  enddo
+
+  qn=0.5d0
+  un=(3.d0/(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
+  y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.d0)
+
+  do k=n-1,1,-1
+    y2(k)=y2(k)*y2(k+1)+u(k)
+  enddo
+
+  deallocate(u)
+
+  end subroutine spline
+
+! --------------
+
+! evaluate spline (Numerical Recipes)
+
+  subroutine splint(xa,ya,y2a,n,x,y)
+
+  implicit none
+
+  integer n
+  double precision XA(N),YA(N),Y2A(N)
+  double precision x,y
+
+  integer k,klo,khi
+  double precision h,a,b
+
+  KLO=1
+  KHI=N
+ 1 IF (KHI-KLO > 1) THEN
+    K=(KHI+KLO)/2
+    IF(XA(K) > X)THEN
+      KHI=K
+    ELSE
+      KLO=K
+    ENDIF
+  goto 1
+  ENDIF
+  H=XA(KHI)-XA(KLO)
+  IF (H == 0.d0) stop 'Bad input in spline evaluation'
+  A=(XA(KHI)-X)/H
+  B=(X-XA(KLO))/H
+
+  Y=A*YA(KLO)+B*YA(KHI)+((A**3-A)*Y2A(KLO) + (B**3-B)*Y2A(KHI))*(H**2)/6.d0
+
+  end subroutine splint
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/test_smooth.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/test_smooth.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/test_smooth.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,316 @@
+program test_smooth
+
+  use wave2d_variables  ! global variables
+  use wave2d_solver     ! mesher
+
+  implicit none
+
+  ! smoothing
+  integer :: igaus
+  double precision :: d, dmin, dist2, dtrsh2, xtar, ztar, gamma, xcen, zcen
+  double precision, dimension(NGLOB) :: k_rough_global, k_smooth_global
+  double precision, dimension(NGLOB) :: k_gaus_global, k_gaus_global_ex, k_gaus_int_global
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: k_temp, k_gaus_local, k_smooth_local, k_rough_local
+
+  ! corners of the grid
+  double precision, dimension(4) :: corners_utm_x, corners_utm_z, corners_lon, corners_lat
+  double precision :: sq_south, sq_east, sq_north, sq_west, sq_fac, da_mean, sda_mean, m_scale_str, mfac
+
+  ! corners of the elements, in a global vector
+  !integer, dimension(NSPEC_CORNER) :: ielement_corner
+  !logical, dimension(NGLOB) :: mask_ibool
+  !integer :: iglob1, iglob2, iglob3, iglob4
+
+  double precision :: xtemp,ztemp,dx,dz,xmesh,zmesh
+  double precision :: junk1,junk2,junk3
+  double precision :: temp1,temp2,temp3,temp4,temp5,temp6,temp7
+
+  integer :: i, j, k, iq, iglob, itemp, itype, icorner, ispec
+  !integer :: isolver, irun0, irun, idat, iopt, ispec, istep, istep_switch, imod
+
+  !********* PROGRAM STARTS HERE *********************
+
+  ! mesher (gets Jacobian)
+  call mesher()
+
+  ! compute da_global, da_local, valence, ielement_corner
+  call mesher_additional()
+
+  da_mean = sum(da_global)/NGLOB
+  sda_mean = sqrt(da_mean)
+
+  ! global mesh
+  open(unit=15,file='global_mesh.dat',status='unknown')
+  do iglob = 1,NGLOB
+     write(15,'(2i8,3e18.8)') iglob, valence(iglob), x(iglob), z(iglob), da_global(iglob)
+  enddo
+  close(15)
+
+!!$  ! da vector and valence vector
+!!$  da_global(:) = 0.
+!!$  valence(:) = 0
+!!$  do ispec = 1,NSPEC
+!!$    do j = 1,NGLLZ
+!!$      do i = 1,NGLLX 
+!!$        iglob = ibool(i,j,ispec)
+!!$        da_local(i,j,ispec) = wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+!!$
+!!$        !da_global(iglob) = da_global(iglob) + wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+!!$        da_global(iglob) = da_global(iglob) + da_local(i,j,ispec)
+!!$        valence(iglob) = valence(iglob) + 1
+!!$      enddo
+!!$    enddo
+!!$  enddo
+!!$  da_mean = sum(da_global)/NGLOB
+!!$  sda_mean = sqrt(da_mean)
+!!$
+!!$  ! global mesh
+!!$  open(unit=15,file='global_mesh.dat',status='unknown')
+!!$  do iglob = 1,NGLOB
+!!$    write(15,'(2i8,3e18.8)') iglob, valence(iglob), x(iglob), z(iglob), da_global(iglob)
+!!$  enddo
+!!$  close(15)
+!!$
+!!$  ! GLL points defining the corners of elements
+!!$  mask_ibool(:) = .false.
+!!$  do ispec = 1,NSPEC
+!!$     iglob1 = ibool(1,1,ispec)
+!!$     iglob2 = ibool(NGLLX,1,ispec)
+!!$     iglob3 = ibool(1,NGLLZ,ispec)
+!!$     iglob4 = ibool(NGLLX,NGLLZ,ispec)
+!!$
+!!$      if(.not. mask_ibool(iglob1)) mask_ibool(iglob1) = .true.
+!!$      if(.not. mask_ibool(iglob2)) mask_ibool(iglob2) = .true.
+!!$      if(.not. mask_ibool(iglob3)) mask_ibool(iglob3) = .true.
+!!$      if(.not. mask_ibool(iglob4)) mask_ibool(iglob4) = .true.
+!!$  enddo
+!!$
+!!$  k = 0
+!!$  ielement_corner(:) = 0
+!!$  do iglob = 1,NGLOB
+!!$      if(mask_ibool(iglob)) then
+!!$         k = k+1
+!!$         ielement_corner(k) = iglob
+!!$      endif
+!!$  enddo
+
+  if(0==1) then
+
+     ! corner points for each element, and centerpoint (in km)
+     open(unit=15,file='elements.dat',status='unknown')
+     do ispec = 1,nspec
+        xtemp = (x1(ispec) + x2(ispec))/2.
+        ztemp = (z1(ispec) + z2(ispec))/2.
+        write(15,'(i8,6f14.6)') ispec,xtemp/1000.,ztemp/1000,x1(ispec)/1000.,x2(ispec)/1000.,z1(ispec)/1000.,z2(ispec)/1000.
+     enddo
+     close(15)
+
+     ! GLL points for one element (in km)
+     ispec = 292  ! pick an element
+     open(unit=15,file='gll_points.dat',status='unknown')
+     do j = 1,NGLLZ
+        do i = 1,NGLLX
+           iglob = ibool(i,j,ispec)
+           write(15,'(4i10,3e18.8)') ispec, i, j, valence(iglob), da_global(iglob)/1e6, x(iglob)/1000., z(iglob)/1000.
+        enddo
+     enddo
+     close(15)
+
+     ! GLL points defining the corners of elements
+     open(unit=15,file='element_corners.dat',status='unknown')
+     do i = 1,NSPEC_CORNER
+        iglob = ielement_corner(i)
+        write(15,'(1i10,2e18.8)') iglob, x(iglob)/1000., z(iglob)/1000.
+     enddo
+     close(15)
+
+     stop 'testing'
+  endif
+
+  print *
+  write(*,'(a,1f20.10)') '     da_min  (m^2) : ', minval(da_global)
+  write(*,'(a,1f20.10)') '     da_mean (m^2) : ', da_mean
+  write(*,'(a,1f20.10)') '     da_max  (m^2) : ', maxval(da_global)
+  write(*,*)             ' sum [ da_global ] : ', sum(da_global)
+  write(*,*)             ' sum [ da_local  ] : ', sum(da_local)
+  write(*,*)             '   LENGTH * HEIGHT : ', LENGTH * HEIGHT
+  print *
+  print *, ' GLL weights:'
+  do i=1,NGLLX
+     print *, wxgll(i)
+  enddo
+  do i=1,NGLLZ
+     print *, wzgll(i)
+  enddo
+
+  !-----------------------
+  ! apply smoothing
+
+  gamma = 60.0d+03     ! scalelength of smoothing Gaussian
+
+  itype = 3        ! type of integration to test
+
+  ! read in sample function
+  k_rough_global(:) = 0.
+
+  ! read in test function
+  ! NOTE: this has to have been greated using the same mesh
+  open(unit=19,file='/net/denali/scratch1/carltape/OUTPUT/run_0460/fun_smooth.dat',status='unknown')
+  do iglob = 1,NGLOB
+     read(19,'(8e16.6)') temp1, temp2, temp3, temp4, &
+          k_rough_global(iglob), temp5, temp6, temp7
+  enddo
+  close(19)
+
+  ! construct local version of the unsmoothed kernel
+  if(itype==1) then
+     k_rough_local(:,:,:) = 0.
+     do ispec = 1,NSPEC
+        do j = 1,NGLLZ
+           do i = 1,NGLLX 
+              itemp = ibool(i,j,ispec)
+              k_rough_local(i,j,ispec) = k_rough_global(itemp)
+           enddo
+        enddo
+     enddo
+  endif
+
+  ! Smoothing function is a Gaussian whose full-width is given by gamma;
+  ! all points outside d^2 (dtrsh2) are set to zero.
+  dtrsh2 = (1.5*gamma)**2 
+
+  ! EXAMPLE gaussian smoothing function for one point
+  ! (1) find the closest gridpoint to the target point
+  xtar = 0.25*LENGTH
+  ztar = 0.25*HEIGHT
+  dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+  do iglob = 1,NGLOB
+     d = sqrt((xtar-x(iglob))**2+(ztar-z(iglob))**2)
+     if(d < dmin) then
+        igaus = iglob
+        dmin = d
+     endif
+  enddo
+  xcen = x(igaus)
+  zcen = z(igaus)
+
+  ! (2) compute the example gaussian
+  k_gaus_global_ex(:) = 0.
+  do iglob = 1,NGLOB
+     dist2 = (xcen - x(iglob))**2 + (zcen - z(iglob))**2
+     if(dist2 <= dtrsh2) &
+          k_gaus_global_ex(iglob) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+  enddo
+
+  !------------------------------------
+  ! Compute the SMOOTHED kernel by convolving a Gaussian with the UNSMOOTHED kernel.
+  ! This involves integrating NGLOB products between a Gaussian and the unsmoothed kernel.     
+
+  print *, 'convolving the kernel with a Gaussian...'
+
+  k_smooth_global(:) = 0.
+
+  ! loop over CONVOLUTION POINTS, either GLL points or simply the element corners
+  do iglob = 1,NGLOB
+
+     !do icorner = 1,NSPEC_CORNER
+     !   iglob = ielement_corner(icorner)
+
+     if (mod(iglob,500) == 0) write(*,*) iglob, ' out of ', NGLOB
+
+     ! compute a Gaussian centered at the iglob point
+     ! (part of the Gaussian may be outside the grid)
+     xcen = x(iglob)
+     zcen = z(iglob)
+     if(itype==1) then
+
+        k_gaus_local(:,:,:) = 0.
+        do ispec = 1,NSPEC
+           do j = 1,NGLLZ
+              do i = 1,NGLLX 
+                 itemp = ibool(i,j,ispec)
+                 dist2 = (xcen - x(itemp))**2 + (zcen - z(itemp))**2
+                 if(dist2 <= dtrsh2) then
+                    k_gaus_local(i,j,ispec) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+                    !k_gaus_global(itemp) = k_gaus_local(i,j,ispec)
+                 endif
+              enddo
+           enddo
+        enddo
+     else
+
+        k_gaus_global(:) = 0.
+        do i = 1,NGLOB
+           dist2 = (xcen - x(i))**2 + (zcen - z(i))**2
+           if(dist2 <= dtrsh2) &
+                k_gaus_global(i) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+        enddo
+     endif
+
+     ! There are two primary steps:
+     ! (1) Integrate the Gaussian over the grid; this provides the normalization for the Gaussian
+     ! and accounts for Gaussians that are partially outside the grid.
+     ! (2) Integrate the product of the Gaussian and the rough function.
+
+     if(itype==1) then            ! local integration with local arrays
+
+        k_gaus_int_global(iglob) = sum( k_gaus_local(:,:,:) * da_local(:,:,:) )
+        k_smooth_global(iglob) = sum( k_rough_local(:,:,:) * k_gaus_local(:,:,:) * da_local(:,:,:) ) / k_gaus_int_global(iglob) 
+
+     elseif(itype==2) then        ! local integration with global array
+
+        k_temp(:,:,:) = 0.
+        do ispec = 1,NSPEC
+           do j = 1,NGLLZ
+              do i = 1,NGLLX 
+                 itemp = ibool(i,j,ispec)
+                 k_temp(i,j,ispec) = k_gaus_global(itemp) * da_local(i,j,ispec)
+              enddo
+           enddo
+        enddo
+        k_gaus_int_global(iglob) = sum( k_temp(:,:,:) )
+
+        k_temp(:,:,:) = 0.
+        do ispec = 1,NSPEC
+           do j = 1,NGLLZ
+              do i = 1,NGLLX 
+                 itemp = ibool(i,j,ispec)
+                 k_temp(i,j,ispec) = k_rough_global(itemp) * k_gaus_global(itemp) * da_local(i,j,ispec)
+              enddo
+           enddo
+        enddo
+        k_smooth_global(iglob) = sum( k_temp(:,:,:) ) / k_gaus_int_global(iglob)
+
+     elseif(itype==3) then       ! global integration with global arrays
+
+        k_gaus_int_global(iglob) = sum( k_gaus_global(:) * da_global(:) )
+        k_smooth_global(iglob) = sum( k_rough_global(:) * k_gaus_global(:) * da_global(:) ) / k_gaus_int_global(iglob)        
+
+     endif
+
+  enddo   ! iglob = 1,NGLOB
+
+  ! write smooth-related functions to file
+  open(unit=19,file='fun_smooth.dat',status='unknown')
+  do iglob = 1,NGLOB
+     !do icorner = 1,NSPEC_CORNER
+     !iglob = ielement_corner(icorner)
+
+     write(19,'(9e16.6)') x_lon(iglob), z_lat(iglob), x(iglob), z(iglob), &
+          k_rough_global(iglob), k_gaus_global_ex(iglob), &
+          k_smooth_global(iglob), k_rough_global(iglob) - k_smooth_global(iglob), &
+          k_gaus_int_global(iglob)
+  enddo
+  close(19)
+
+  ! plot rough function, Gaussian filter, smooth function, and residual
+  !filename1 = 'get_smooth.csh'
+  !filename2 = trim(script_dir)//'plot_smoothed_function.pl'
+  !open(19,file=filename1,status='unknown')
+  !write(19,'(5a,1e16.6)') trim(filename2),' ', trim(out_dir1),' ', &
+  !   trim(file_smooth), gamma
+  !close(19)
+  !call system('chmod 755 get_smooth.csh ; get_smooth.csh')
+
+end program test_smooth
+ 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,3544 @@
+program wave2d
+
+  !---------------------------------------------------------------------
+  ! This program simulates elastic wave propagation on a 2D grid.
+  ! The wavefield is stored as 3-component displacement records.
+  !
+  ! It has the option of computed sensitivity kernels via adjoint methods.
+  !
+  ! It also contains an embedded conjugate-gradient scheme for recovering
+  ! "target models" from reference models.
+  !
+  ! For more information, see the following papers:
+  !   Tromp, Tape, Liu, 2005, GJI.
+  !   Tape, Liu, Tromp, 2007, GJI.
+  !---------------------------------------------------------------------
+  !
+  !   wave2d.f90
+  !   Carl Tape, 28-Jan-2008
+  !   Forward solver is based on earlier versions by Jeroen Tromp and Qinya Liu.
+  !
+  ! The spectral-element method papers are by Dimitri Komatitsch, Jeroen Tromp, and others.
+  ! Dimitri's SPECFEM2D code is the primary 2D SEM code on the SVN server.
+  ! Eventually, CHT will merge the capabilities of this code with Dimitri's version.
+  !
+  !---------------------------------------------------------------------
+
+  use wave2d_variables  ! declare global variables
+  use wave2d_solver     ! mesher, set_model_property, solver
+  use wave2d_sub        ! source time function, write seismograms, smoothing
+  use wave2d_sub2       ! UTM conversion
+  !use wave2d_sub3       ! measurements, adjoint sources
+  use wave2d_sub4       ! cross-correlation measurements and adjoint sources
+
+  implicit none
+
+  ! wavefields and seismograms
+  double precision, dimension(:,:,:), allocatable :: samp, samp_dat, data, syn, adj_syn, data_recon
+
+  ! source function
+  double precision, dimension(NSTEP) :: stf_dat, stf_syn
+  double precision :: f0(NCOMP), ti(NSTEP)
+
+  ! socal coast and shelf data (for membrane surface wave simulations)
+  integer :: FINITE_SOURCE
+  integer :: nshelf,ncoast
+  double precision :: d,dmin
+  double precision, dimension(:), allocatable :: shelf_lat,shelf_lon,shelf_z,shelf_x
+  double precision, dimension(:), allocatable :: coast_lat,coast_lon,coast_z,coast_x
+  character(len=200) :: shelf_file,coast_file
+
+  ! corners of the grid  (for membrane surface wave simulations)
+  double precision, dimension(4) :: corners_utm_x, corners_utm_z, corners_lon, corners_lat
+  double precision :: sq_south, sq_east, sq_north, sq_west
+
+  !------------------------
+  ! source and receiver variables (and fake receivers for spectral plots)
+  integer :: istf, nsrc, nrec, nrecf, nevent, nevent_dat, nevent_run, nparm_src_run, idata
+  double precision :: dnparm_src_run
+  !integer, dimension(:), allocatable :: sglob, sglob_dat
+  !integer, dimension(:), allocatable :: sglob_temp, rglob_temp, fglob_temp
+
+  integer, dimension(MAX_EVENT):: ifilter_eve_dat
+  double precision, dimension(MAX_EVENT)      :: x_eve_lon0_dat, z_eve_lat0_dat, x_eve0_dat, z_eve0_dat
+  double precision, dimension(:), allocatable :: x_eve_lon_dat,  z_eve_lat_dat,  x_eve_dat,  z_eve_dat, otime_dat
+  double precision, dimension(:), allocatable :: xi_eve_dat, gamma_eve_dat
+  integer, dimension(:), allocatable          :: eglob_dat, ispec_eve_dat
+
+  integer, dimension(MAX_EVENT):: ifilter_eve_syn
+  double precision, dimension(MAX_EVENT)      :: x_eve_lon0_syn, z_eve_lat0_syn, x_eve0_syn, z_eve0_syn
+  double precision, dimension(:), allocatable :: x_eve_lon_syn,  z_eve_lat_syn,  x_eve_syn,  z_eve_syn, otime_syn
+  double precision, dimension(:), allocatable :: xi_eve_syn, gamma_eve_syn
+  integer, dimension(:), allocatable          :: eglob_syn, ispec_eve_syn
+
+  integer, dimension(MAX_SR):: ifilter_rec, rglob0
+  double precision, dimension(MAX_SR)         :: x_rec_lon0, z_rec_lat0, x_rec0, z_rec0
+  double precision,dimension(:), allocatable  :: x_rec_lon,  z_rec_lat,  x_rec,  z_rec
+  double precision, dimension(:), allocatable :: xi_rec, gamma_rec
+  integer, dimension(:), allocatable          :: rglob, ispec_rec
+
+  integer, dimension(MAX_SR_FAKE):: ifilter_recf
+  double precision, dimension(MAX_SR_FAKE)    :: x_recf0, z_recf0
+  double precision,dimension(:), allocatable  :: x_recf, z_recf
+  integer, dimension(:), allocatable          :: fglob
+
+  integer, dimension(MAX_SR):: ifilter_src
+  double precision, dimension(MAX_SR)         :: x_src_lon0, z_src_lat0, x_src0, z_src0
+  double precision,dimension(:), allocatable  :: x_src_lon,  z_src_lat,  x_src,  z_src
+  double precision, dimension(:), allocatable :: xi_src, gamma_src
+  integer, dimension(:), allocatable          :: sglob, ispec_src
+
+  integer, dimension(MAX_SR):: ifilter_src_dat
+  double precision, dimension(MAX_SR)         :: x_src_lon0_dat, z_src_lat0_dat, x_src0_dat, z_src0_dat
+  double precision,dimension(:), allocatable  :: x_src_lon_dat,  z_src_lat_dat,  x_src_dat,  z_src_dat
+  double precision, dimension(:), allocatable :: xi_src_dat, gamma_src_dat
+  integer, dimension(:), allocatable          :: sglob_dat, ispec_src_dat
+  !------------------------
+
+  ! allocate Lagrange interpolators for sources and receivers
+  double precision, dimension(:,:), allocatable :: hxir_store, hxie_store, hxied_store, hxis_store, hxisd_store
+  double precision, dimension(:,:), allocatable :: hgammar_store, hgammae_store, hgammaed_store, hgammas_store, hgammasd_store
+  double precision, dimension(:), allocatable :: hxir,hpxir,hgammar,hpgammar
+  double precision, dimension(:), allocatable :: hxie,hpxie,hgammae,hpgammae
+  double precision, dimension(:), allocatable :: hxis,hpxis,hgammas,hpgammas
+  double precision, dimension(:), allocatable :: hxied,hpxied,hgammaed,hpgammaed
+  double precision, dimension(:), allocatable :: hxisd,hpxisd,hgammasd,hpgammasd
+
+  !double precision, dimension(:), allocatable :: x_src_lon, z_src_lat, x_src, z_src
+
+  double precision :: x_src_lon_i, z_src_lat_i, x_src_i, z_src_i, x_src_f, z_src_f
+  double precision :: flen,finc,src_az,xd
+  double precision :: s_radius,xcen,zcen,xcen_lon,zcen_lat
+  double precision :: dmin_trsh_s,dmin_trsh_r,dmin_trsh_f
+  character(len=200) :: quake_file
+
+  ! velocity structure variables
+  integer :: iref
+
+  ! source perturbations (01-Feb-2006)
+  ! presently only set up for 2D surface waves
+  !logical :: ISOURCE_LOG
+  !integer :: PERT_SOURCE, PERT_STRUCT, INV_SOURCE, INV_STRUCT
+  logical :: stop_cg
+  double precision :: src_pert_time, origin_time, origin_time_dat, origin_time_syn, ptmin, ptmax, ptime
+  double precision :: src_pert_dist, rand1, amin, amax, pangle, rmin, rmax, prad
+  double precision :: dx_src, dz_src, dt_src
+  double precision, dimension(NVAR_STRUCT) :: m_scale_str
+  double precision, dimension(NVAR_SOURCE) :: m_scale_src
+  double precision, dimension(:,:,:,:), allocatable :: three_source_model
+  double precision, dimension(:), allocatable :: source_gradient, m_scale_src_all   ! source_kernel
+  double precision, dimension(:), allocatable :: gradient, gradient_data, gradient_model
+  double precision, dimension(:,:), allocatable :: gradient_data_all
+
+  !double precision, dimension(NGLLX,NGLLZ,NSPEC) :: gradient_local
+
+  ! socal earthquake location
+  double precision, dimension(MAX_EVENT) :: socal_events_lon, socal_events_lat, socal_events_mag
+  integer, dimension(MAX_EVENT) :: socal_events_lab
+  integer nmeas, nmeas_run, ievent_min, ievent_max, ifirst_event
+
+  !----------------------
+  ! misfit and conjugate gradient algorithm
+
+  ! weighting and smoothing
+  double precision :: gamma  ! sigma
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: kbulk_smooth, kbeta_smooth   ! scale_array
+!  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: bulk_pert_syn, beta_pert_syn
+  double precision :: scale_bulk, scale_beta, scale_source, scale_struct, scale_struct_gji
+  double precision :: sigma_bulk, sigma_beta, sigma_xs, sigma_zs, sigma_ts, sigma_checker_scale
+  double precision :: cov_fac, cov_src_fac, cov_str_fac
+  double precision :: afac_target, coverage_str, coverage_src
+  double precision :: joint_str_src_grad_ratio, jsw_str, jsw_src, joint_total_weight, jfac
+  double precision :: fac_str, fac_ts, fac_xs, fac_ys, fac_total
+  double precision :: ugrad_str, ugrad_ts, ugrad_xs, ugrad_ys, ugrad_src
+  double precision, dimension(:), allocatable :: cov_imetric, icov_metric, cov_model, icov_model
+
+  ! conjugate gradient optimization (using line-search)
+  double precision, dimension(:), allocatable :: pk, gk, g0, p0, m0, gt, mt, mdiff ! m0_prior
+  double precision :: beta_val, lam_0_val, lam_t_val, chi_t_val, chi_k_val, mu_val
+  double precision :: Pa,Pb,Pc,Pd,qfac,xx1,xx2,yy1,yy2,g1,g2,xmin
+
+  ! arrays describing the structure and source parameters
+  double precision, dimension(:), allocatable :: m0_vec, mt_vec, m0_vec_initial, mtarget
+  double precision, dimension(:), allocatable :: m_src_syn_vec, m_src_syn, m_src_syn_vec_initial, m_src_syn_initial
+  double precision, dimension(:), allocatable :: m_src_dat_vec, m_src_dat
+
+  double precision :: vel_min, vel_max
+  integer :: itest, nmod, nmod_src, nmod_str
+
+  !----------------------
+
+  ! kernels
+  double precision, dimension(:), allocatable :: tstart, tend
+  character(len=200) :: last_frame_name
+  double precision, dimension(:,:,:,:,:), allocatable :: absorb_field
+  double precision, dimension(:,:,:), allocatable :: atype_kernel, btype_kernel, rtype_kernel
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: atype_kernel_sum, btype_kernel_sum
+  double precision, dimension(NLOCAL) :: ktemp
+
+  double precision :: xtemp,ztemp,dx,dz,xmesh,zmesh
+  double precision :: t_target, tcen
+  double precision :: junk1,junk2,junk3
+  double precision :: temp1,temp2,temp3,temp4,temp5,temp6,temp7
+
+  double precision :: da_local_mean, sda_local_mean, da_global_mean, sda_global_mean
+  double precision :: mfac, norm_source_2, norm_bulk_2, norm_beta_2, norm_struct_2
+
+  character(len=20)  :: data_tag,syn_tag,stf_tag,stfadj_tag
+  character(len=200) :: srcfile,recfile,socal_map
+  character(len=200) :: socal_dir, model_dir, script_dir, out_dir3, out_dir2, out_dir1, ev_dir
+  character(len=200) :: filename, filename1, filename2, filename3, file_structure_dat, file_structure_syn, file_src_rec, file_stf
+  character(len=200) :: command1
+
+  integer :: itemp,itemp1,itemp2,itemp3, hmod
+  integer :: i, j, k, iq, itime, iglob, irec, isrc, ipick, ievent, icomp  ! irunz
+  integer :: isolver, irun0, irun, iopt, ispec, istep, istep_switch, imod, ipar
+
+  !double precision :: meas_pert, rand1,  meas, ppert
+
+  integer :: GJI_PAPER, qmax
+
+  !-------------------------------------------------------------------------------------
+  !********* PROGRAM STARTS HERE *********************
+  !-------------------------------------------------------------------------------------
+
+  !--------------------------------------
+  ! stop program is there are certain unallowed paramter combinations
+
+  if(HESSIAN) then
+      print *, 'For Hessian runs...'
+      if(NITERATION /= 0) stop 'NITERATION = 0'
+      if(ISRC_SPACE /= 6) stop 'ISRC_SPACE = 6'
+      hmod = 1      ! iteration number for Hessian-based models
+  endif
+
+  if( IKER/=0 .and. IKER/=1 .and. IKER/=2 ) stop 'IKER must = 0,1,2'
+
+  if( ADD_DATA_ERRORS .and. IKER/=1 ) stop 'for now, IKER = 1 for adding errors to data'
+
+  ! if you do not want kernels, then you cannot iterate
+  if( (.not. COMPUTE_KERNELS) .and. NITERATION /= 0 ) stop 'NITERATION = 0'
+
+  !--------------------------------------
+
+  ! random number generator (for including measurement errors)
+  !call random_seed()
+
+  ! specify input and output directories
+  out_dir3   = "OUTPUT/"
+  in_dir     = "INPUT/"
+
+  ! NOTE: check that these directories exist
+  !model_dir  = 'model_files/'
+  !script_dir = "scripts/"
+  !socal_dir = '/net/denali/scratch1/carltape/socal_modes/socal_modes/local_modes/'
+
+  ! whether a point source or finite source is used
+  if(ISRC_SPACE==1) FINITE_SOURCE = 0
+  if(ISRC_SPACE/=1) FINITE_SOURCE = 1
+
+  !--------------------------------------
+  ! load or specify events, depending on whether you are computing
+  ! membrane surface waves (ISURFACE==1) or body waves
+
+  if(ISURFACE==1) then
+
+     !----------
+     ! read in target events (socal_quakes.m)
+     ! socal events M > 4 (1990-2005), selected to get semi-uniform coverage
+
+     !quake_file = 'socal_quakes_v02.dat'
+     quake_file = 'socal_quakes_N025.dat'
+     open(55,file=trim(in_dir)//trim(quake_file),status='unknown')
+     read(55,*) nevent
+     if(nevent > MAX_EVENT) stop 'nevent > MAX_EVENT (so increase MAX_EVENT)'
+     print *, nevent, ' target events (for synthetics)'
+     read(55,'(i14,3f14.7)') (socal_events_lab(i),socal_events_lon(i),socal_events_lat(i),socal_events_mag(i),i = 1,nevent)
+     close(55)
+
+     print *
+     print *, 'SoCal events (label, lon, lat, mag):'
+     do i = 1,nevent
+        write(*,'(i14,3f14.7)') socal_events_lab(i), socal_events_lon(i), socal_events_lat(i), socal_events_mag(i)
+     enddo
+
+     !----------
+     ! load socal coast and shelf points
+     ! (This is useful for some ocean microseismi time-rerversal experiments.)
+
+     ! exclude sources or receivers that are this close to THE SOCAL COAST
+     dmin_trsh_s = 0.0d+03                  ! sources
+     !dmin_trsh_r = STATION_GRID_BUFFER     ! receivers
+     dmin_trsh_r = 0.0d+03
+     dmin_trsh_f = 0.0d+03                  ! fake receivers
+
+     ! read in data files
+     nshelf = 101
+     ncoast = 810
+     allocate(shelf_lat(nshelf),shelf_lon(nshelf),shelf_z(nshelf),shelf_x(nshelf))
+     allocate(coast_lat(ncoast),coast_lon(ncoast),coast_z(ncoast),coast_x(ncoast))
+     shelf_file = 'oms_shelf'
+     coast_file = 'oms_coast'
+     open(77,file=trim(in_dir)//'BOUNDARIES/'//trim(shelf_file),status='unknown')
+     read(77,*) (shelf_lat(i),shelf_lon(i),i = 1,nshelf)
+     close(77)
+     open(66,file=trim(in_dir)//'BOUNDARIES/'//trim(coast_file),status='unknown')
+     read(66,*) (coast_lat(i),coast_lon(i),i = 1,ncoast)
+     close(66)
+
+     ! convert lat-lon to mesh coordinates
+     call mesh_geo(nshelf,shelf_lon,shelf_lat,shelf_x,shelf_z,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+     call mesh_geo(ncoast,coast_lon,coast_lat,coast_x,coast_z,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+     !write(*,'(4f16.6)') (shelf_lon(i), shelf_lat(i), shelf_x(i)/1000.0, shelf_z(i)/1000.0, i = 1,nshelf)
+     !write(*,'(4f16.6)') (coast_lon(i), coast_lat(i), coast_x(i)/1000.0, coast_z(i)/1000.0, i = 1,ncoast)
+
+  else
+     !----------
+     ! events for data
+
+     ! all vectors should be this length
+     nevent = MAX_EVENT
+
+     if(0==1) then    ! read in target events (socal1D.m)
+
+        quake_file = 'socal_quakes_1D_rand10.dat'   ! 200 km width
+        !quake_file = 'socal_quakes_1D_rand15.dat'   ! 400 km width
+        open(55,file=trim(in_dir)//trim(quake_file),status='unknown')
+        read(55,*) nevent
+        if(nevent > MAX_EVENT) stop 'nevent > MAX_EVENT (so increase MAX_EVENT)'
+        print *, nevent, ' target events (for synthetics)'
+        read(55,'(i10,3f24.12)') (junk1,x_eve0_dat(i),z_eve0_dat(i),junk2,i = 1,nevent)
+        close(55)
+
+        print *
+        print *, 'Target events (index, x, z):'
+        do i = 1,nevent
+           write(*,*) i,x_eve0_dat(i),z_eve0_dat(i)
+        enddo
+
+     else              ! specify target events here
+
+        ! target events (data)
+        x_eve0_dat(:) = -99.0            ; z_eve0_dat(:) = -99.0
+        !x_eve0_dat(1) = 50.0d3   ; z_eve0_dat(1) = 0.75 * HEIGHT
+        !x_eve0_dat(2) = 50.0d3   ; z_eve0_dat(2) = 0.50 * HEIGHT
+        !x_eve0_dat(3) = 50.0d3   ; z_eve0_dat(3) = 0.25 * HEIGHT
+
+        !x_eve0_dat(1) = 50.0d3   ; z_eve0_dat(1) = HEIGHT - 2.5d3
+        !x_eve0_dat(2) = 50.0d3   ; z_eve0_dat(2) = HEIGHT - 10.0d3
+        !x_eve0_dat(3) = 50.0d3   ; z_eve0_dat(3) = HEIGHT - 20.0d3
+        !x_eve0_dat(4) = 50.0d3   ; z_eve0_dat(4) = HEIGHT - 40.0d3
+
+        x_eve0_dat(1) = LENGTH/2.0   ; z_eve0_dat(1) = HEIGHT
+
+     endif
+
+     !----------
+     ! KEY: define 1D model for body waves
+
+     ! SoCal 1D model (Dreger & Helmberger 1990)
+     !z_breaks(1) = 5500.0 ; z_breaks(2) = 16000.0 ; z_breaks(3) = 35000.0 ; nlayer = 4
+
+     ! model to honor discontinuities (32 elements in 80 km depth)
+     z_breaks(1) = 5000.0 ; z_breaks(2) = 15000.0 ; z_breaks(3) = 35000.0 ; nlayer = 4
+
+     ! four-layer 1D model
+     r_layers(1) = 2400.0 ; r_layers(2) = 2670.0 ; r_layers(3) = 2800.0 ; r_layers(4) = 3000.0
+     a_layers(1) = 5500.0 ; a_layers(2) = 6300.0 ; a_layers(3) = 6700.0 ; a_layers(4) = 7800.0
+     b_layers(1) = 3180.0 ; b_layers(2) = 3640.0 ; b_layers(3) = 3870.0 ; b_layers(4) = 4500.0
+
+     !alpha_min = a_layers(1)
+     !alpha_max = a_layers(nlayer)
+     !beta_min  = b_layers(1)
+     !beta_max  = b_layers(nlayer)
+  endif
+
+  !--------------------------------------
+
+  ! events to use (5-5, 1-5, or 1-25)
+  !ievent_min = 1  ; ievent_max = nevent
+  !ievent_min = 1 ; ievent_max = 5
+  ievent_min = 5  ; ievent_max = ievent_min
+  nevent_run = ievent_max - ievent_min + 1
+
+  ! number of source parameters
+  ! NOTE: we used to normalize the whole source portion of the model vector (3 x 25 = 75),
+  !       but now we allow for variable balancing among structure, ts, xy, and ys.
+  !nparm_src_run = nevent_run * NVAR_SOURCE
+  nparm_src_run = nevent_run
+  dnparm_src_run = dble(nparm_src_run)
+
+  ! MAX source perturbations for location (lat-lon) and origin time
+  !    dt0 = dt0_dat - dt0_syn ( < 0 for delayed synthetics)
+  !src_pert_dist = 5000.0      ! source spatial perturbation (m)
+  !src_pert_time = 1.0         ! source temporal perturbation (s)
+
+  ! STANDARD DEVIATIONS of source perturbations (see wave2d_sigmas.m)
+  src_pert_dist = 2000.0       ! source spatial perturbation (m)
+  src_pert_time = 0.5            ! source temporal perturbation (s)
+
+  origin_time     = tshift       ! reference origin time (s)
+  origin_time_dat = origin_time
+  origin_time_syn = origin_time
+
+  ! reference directory for the run
+  !irunz = 500
+
+  GJI_PAPER = 0
+
+  ! if you are not computing kernels, loop over 25 TSVD models to read in
+  qmax = 25
+  if(COMPUTE_KERNELS) qmax = 1
+
+  !============================================
+  ! LOOP 1: different tomographic runs
+  do iq = 1,qmax
+  !============================================
+
+     ! KEY COMMAND: scalelength of checker for velocity models (1,2,3)
+     Nfac = 3   ! use Nfac=3 for one-source examples
+
+     if(HESSIAN) then
+        irun0 = IRUNZ
+     else
+        irun0 = IRUNZ + 20*(iq-1)    ! increment is 20
+     endif
+
+     ! name the reference output directory for the optimization run
+     if(HESSIAN) then
+        ! Hessian-based inversions
+        if(COMPUTE_KERNELS) then
+           write(out_dir2,'(a,i4.4,a,i2.2,a)') trim(out_dir3)//'run_',irun0,'/HESSIAN/model_m',hmod,'/'
+        else
+           write(out_dir2,'(a,i4.4,a,i2.2,a,i2.2,a)') trim(out_dir3)//'run_',irun0,'/HESSIAN/model_m',hmod,'/run_p',iq,'/'
+        endif
+     else
+        ! gradient-based inversion
+        write(out_dir2,'(a,i4.4,a)') trim(out_dir3)//'run_',irun0,'/'
+        command1 = 'mkdir ' // trim(out_dir2)
+        call system(command1)
+        print *, command1
+     endif
+
+     !open(19,file='temp.csh',status='unknown')
+     !write(19,'(2a)') 'mkdir ',out_dir2
+     !close(19)
+     !call system('chmod 755 temp.csh ; temp.csh')
+
+     !--------------------------------------
+
+     print *
+     print *, ' max time-step is ', NSTEP
+     print *, '            DT is ', sngl(DT)
+     print *, '      max time is ', sngl(NSTEP*DT), ' s,', sngl(NSTEP*DT/60), ' min'
+     print *
+
+     ! copy wave2d_constants.f90 and wave2d.f90 into output directory
+     command1 = 'cp ' // 'src/wave2d_constants.f90 ' // trim(out_dir2)
+     call system(command1)
+     command1 = 'cp ' // 'src/wave2d.f90 ' // trim(out_dir2)
+     call system(command1)
+
+     call write_parameters(trim(out_dir2)//'parameters1.log')
+
+     !--------------------------------------
+     ! mesher
+
+     ! set up model (gets Jacobian)
+     call mesher()
+
+     ! compute da_global, da_local, valence, ielement_corner
+     call mesher_additional()
+
+     da_global_mean  = sum(da_global)/NGLOB
+     da_local_mean   = sum(da_local)/NLOCAL
+     sda_global_mean = sqrt(da_global_mean)
+     sda_local_mean  = sqrt(da_local_mean)
+
+     if(1==1) then
+        ! global mesh
+        open(unit=15,file=trim(out_dir2)//'global_mesh.dat',status='unknown')
+        do iglob = 1,NGLOB
+           write(15,'(2i8,3e18.8)') iglob, valence(iglob), x(iglob), z(iglob), da_global(iglob)
+        enddo
+        close(15)
+
+        ! local mesh (see subroutine mesher_additional in wave2d_solver.f90)
+        open(unit=15,file=trim(out_dir2)//'local_mesh.dat',status='unknown')
+        k = 0
+        do ispec = 1,NSPEC
+           do j = 1,NGLLZ
+              do i = 1,NGLLX 
+                 k = k+1
+                 iglob = ibool(i,j,ispec)
+                 write(15,'(6i8,4e18.8)') k, ispec, i, j, iglob, valence(iglob), &
+                      x(iglob), z(iglob), da_local(i,j,ispec), da_global(iglob)
+              enddo
+           enddo
+        enddo
+        close(15)
+     endif
+
+     if(0==1) then
+        ! corner points for each element, and centerpoint (in km)
+        open(unit=15,file='elements.dat',status='unknown')
+        do ispec = 1,nspec
+           xtemp = (x1(ispec) + x2(ispec))/2.0
+           ztemp = (z1(ispec) + z2(ispec))/2.0
+           write(15,'(i8,6f14.6)') ispec,xtemp/1000.0,ztemp/1000.0, &
+              x1(ispec)/1000.0,x2(ispec)/1000.0,z1(ispec)/1000.0,z2(ispec)/1000.0
+        enddo
+        close(15)
+
+        ! GLL points for one element (in km)
+        ispec = 292  ! pick an element
+        open(unit=15,file='gll_points.dat',status='unknown')
+        do j = 1,NGLLZ
+           do i = 1,NGLLX
+              iglob = ibool(i,j,ispec)
+              write(15,'(4i10,3e18.8)') ispec, i, j, valence(iglob), da_global(iglob)/1e6, x(iglob)/1000.0, z(iglob)/1000.0
+           enddo
+        enddo
+        close(15)
+
+        ! GLL points defining the corners of elements
+        open(unit=15,file='element_corners.dat',status='unknown')
+        do i = 1,NSPEC_CORNER
+           iglob = ielement_corner(i)
+           write(15,'(1i10,2e18.8)') iglob, x(iglob)/1000.0, z(iglob)/1000.0
+        enddo
+        close(15)
+
+        stop 'checking the GLL indexing on the elements'
+     endif
+
+     print * 
+     write(*,*)             ' PROPERTIES OF THE GRID :'
+     write(*,*)             '   GLOBAL          :'
+     write(*,'(a,1f20.10)') '     da_min  (m^2) : ', minval(da_global)
+     write(*,'(a,1f20.10)') '     da_mean (m^2) : ', da_global_mean
+     write(*,'(a,1f20.10)') '     da_max  (m^2) : ', maxval(da_global)
+     write(*,*)             '        sum [ da ] : ', sum(da_global)
+     write(*,*)             '   LOCAL           :'
+     write(*,'(a,1f20.10)') '     da_min  (m^2) : ', minval(da_local)
+     write(*,'(a,1f20.10)') '     da_mean (m^2) : ', da_local_mean
+     write(*,'(a,1f20.10)') '     da_max  (m^2) : ', maxval(da_local)
+     write(*,*)             '       sum [ da  ] : ', sum(da_local)
+     print *
+     write(*,*)             '   LENGTH * HEIGHT : ', LENGTH * HEIGHT
+     print *
+     write(*,*)             '      GAMMA_SMOOTH : ', GAMMA_SMOOTH
+     write(*,*)             '              Nfac : ', Nfac
+     write(*,*)             '             irun0 : ', irun0
+     write(*,*)             '              IKER : ', IKER
+     print *
+     print *, ' GLL weights:'
+     do i = 1,NGLLX
+        print *, wxgll(i)
+     enddo
+     do i = 1,NGLLZ
+        print *, wzgll(i)
+     enddo
+
+     !stop 'testing'
+
+     !--------------------------------------
+
+     ! determine the UTM coordinates of your origin and corners  
+     if(ISURFACE==1) then
+
+        call utm_geo(LON_MIN,LAT_MIN,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+        corners_utm_x(1) = utm_xmin
+        corners_utm_z(1) = utm_zmin
+        corners_utm_x(2) = utm_xmin + LENGTH
+        corners_utm_z(2) = utm_zmin
+        corners_utm_x(3) = utm_xmin + LENGTH
+        corners_utm_z(3) = utm_zmin + HEIGHT
+        corners_utm_x(4) = utm_xmin
+        corners_utm_z(4) = utm_zmin + HEIGHT
+
+        print *
+        print *,'origin (LON_MIN, LAT_MIN):'
+        print *, LON_MIN, LAT_MIN
+        print *, '        lon             lat           utm_x            utm_z'
+        do i = 1,4
+           call utm_geo(xtemp,ztemp,corners_utm_x(i),corners_utm_z(i),UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+           corners_lon(i) = xtemp
+           corners_lat(i) = ztemp
+           write(*,'(2f16.6,2e16.6)') corners_lon(i), corners_lat(i), corners_utm_x(i), corners_utm_z(i)
+        enddo
+
+        ! convert global gridpoint mesh coordinates to lat-lon
+        x_lon(:) = 0.0
+        z_lat(:) = 0.0 
+        call mesh_geo(NGLOB,x_lon,z_lat,x,z,UTM_PROJECTION_ZONE,IMESH2LONLAT)
+        !write(*,'(2f16.6)') (x_lon(iglob), z_lat(iglob), iglob=1,NGLOB)
+
+        ! compute min/max lat-lon
+        sq_east  = maxval(x_lon(:))
+        sq_west  = minval(x_lon(:))
+        sq_north = maxval(z_lat(:))
+        sq_south = minval(z_lat(:))
+
+        print *
+        print *, 'grid fits within the spherical square patch with these boundaries:'
+        print *, '  west  : ', sq_west
+        print *, '  east  : ', sq_east
+        print *, '  south : ', sq_south
+        print *, '  north : ', sq_north
+
+        ! determine the UTM coordinates of your origin
+        print *
+        print *, 'UTM check for origin of mesh:'
+        print *, LON_MIN,LAT_MIN
+        call utm_geo(LON_MIN,LAT_MIN,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+        print *, utm_xmin, utm_zmin
+        call utm_geo(xtemp,ztemp,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+        print *, xtemp,ztemp   ! should match LON_MIN,LAT_MIN
+        print *
+
+     endif
+
+     !--------------------------------------
+     ! assign values for plotting grid
+
+     if(ISURFACE==1) then
+         x_plot(:) = x_lon(:)
+         z_plot(:) = z_lat(:)
+
+     elseif(ISURFACE==0) then
+         x_plot(:) = x(:)
+         z_plot(:) = z(:)
+
+     endif
+
+     !--------------------------------------
+     ! phase velocity model
+
+     t_target = 2*hdur     ! target period for phase velocity map
+
+!!$  ! homogeneous or heterogeneous phase velocity map 
+!!$
+!!$  if(IMODEL_DAT == 1 .or. IMODEL_SYN == 1) then     ! read or compute a heterogeneous map
+!!$     ! This calls model_files/get_socal_map.csh, which executes wave2d_socal.f90
+!!$     ! from /net/denali/scratch1/carltape/socal_modes/local_modes
+!!$
+!!$     if(0==1) then    ! compute phase velocity map
+!!$
+!!$        ! write lat-lon gridpoints to file
+!!$        filename = trim(socal_dir) // 'socal_input.dat'
+!!$        print *, 'Output data file is ',trim(filename)
+!!$        open(unit=15,file=filename,status='unknown')
+!!$        write(15,*) t_target
+!!$        write(15,*) 1               ! formerly IHOMO, IMODEL
+!!$        write(15,*) UTM_PROJECTION_ZONE
+!!$        write(15,*) NGLOB
+!!$        write(15,*) (x_lon(iglob),z_lat(iglob),iglob=1,NGLOB)
+!!$        close(15)
+!!$
+!!$        ! run wave2d_socal.f90 to create output file
+!!$        ! KEY NOTE: must run this each time you change the grid, hdur, or IMODEL_DAT
+!!$        call system(trim(model_dir) // 'get_socal_map.csh')
+!!$
+!!$        ! read in phase velocity map
+!!$        !write(infile,'(a,a,i4.4,a)') trim(socal_dir), 'socal_T', int(100*t_target),'.dat'
+!!$        socal_map = 'socaltest.dat'
+!!$        open(unit=16, file = trim(model_dir)//socal_map, status='unknown')
+!!$        read(16,*) (junk1,junk2,c_glob(iglob),junk3,iglob=1,NGLOB)
+!!$        close(16)
+!!$
+!!$        ! read in REFERENCE phase velocity (km/s)
+!!$        filename = trim(model_dir) // 'socaltest2.dat'
+!!$        open(unit=17,file=filename,status='unknown')
+!!$        read(17,*) beta0
+!!$        close(17)
+!!$
+!!$        ! convert km/s --> m/s
+!!$        c_glob(:) = 1000.*c_glob(:)
+!!$        beta0 = beta0*1000.
+!!$
+!!$     else             ! read in phase velocity map for data
+!!$
+!!$        open(unit=16,file=trim(model_dir)//'socal_vel_dat.dat', status='unknown')
+!!$        read(16,*) (junk1,junk2,c_glob(iglob),junk3,iglob=1,NGLOB)
+!!$        close(16)
+!!$
+!!$     endif
+!!$
+!!$     ! compute beta0 by finding the average of the phase velocity map
+!!$     print *, 'computing the average of the phase velocity map'
+!!$     beta0 = 0.0     
+!!$     do iglob = 1,NGLOB
+!!$        beta0 = beta0 + c_glob(iglob) * da_global(iglob)
+!!$     enddo
+!!$     beta0 = beta0 / (LENGTH * HEIGHT)
+!!$
+!!$  endif
+!!$
+!!$  if(IMODEL_SYN == 1) c_glob_syn(:) = c_glob(:)
+!!$  if(IMODEL_DAT == 1) c_glob_dat(:) = c_glob(:)
+
+     ! reference phase velocity (m/s) (should be obtained based on hdur)
+     ! (This is only relevant for homogeneous models.)
+     if(ISURFACE==1) then
+        alpha0 = 5800.0
+        beta0 = 3500.0    ! (3500 for GJI)
+        rho0 = DENSITY
+
+     elseif(ISURFACE==0) then
+        !alpha0 = a_layers(2)    ! layer 2 of SoCal model (1D)
+        !beta0  = b_layers(2)    ! layer 2 of SoCal model (1D)
+        alpha0 = (a_layers(2)+a_layers(1))/2
+        beta0  = (b_layers(2)+b_layers(1))/2
+     endif
+
+     ! parameters for checkerboard pattern
+     if(IMODEL_DAT==2 .or. IMODEL_SYN==2) then
+        !Nfac = 3      ! scalelength of map = N * (wavelength of surface waves for hdur)
+        afac = 10.0   ! max PERCENT variation of synthetic model  (10.0)
+
+        ! spatial frequency corresponding to scalelength
+        ! factor of 2 in demoninator is because the scalelength is a 1/2 cycle
+        w_scale = 2*pi/(Nfac*2*beta0*t_target)
+     endif
+
+     !=========================================
+     ! (INITIAL) REFERENCE MODEL (synthetics)
+
+     ! set velocity field for the synthetics (e.g., homogeneous reference model)
+     ! assigns local arrays mu_syn, kappa_syn, rho_syn
+     iref = 1
+     call set_model_property(iref)
+
+     ! smooth the reference model
+     ! (This was motivated for the imaging principle kernel tests, Feb 2007.)
+     if(ISMOOTH_INITIAL_MODEL == 1) then
+        call smooth_function(kappa_syn, GAMMA_SMOOTH_MODEL, temp_local1)  ; kappa_syn = temp_local1;
+        call smooth_function(   mu_syn, GAMMA_SMOOTH_MODEL, temp_local1)  ;    mu_syn = temp_local1;
+        call smooth_function(  rho_syn, GAMMA_SMOOTH_MODEL, temp_local1)  ;   rho_syn = temp_local1;
+        bulk_syn  = sqrt( kappa_syn / rho_syn )
+        beta_syn  = sqrt( mu_syn / rho_syn )
+        alpha_syn = sqrt( (kappa_syn + FOUR_THIRDS*mu_syn) / rho_syn )
+     endif
+
+     ! compute alpha0 and beta0 by finding the average of the phase velocity map
+     print *, 'computing the average of the phase velocity map'
+     kappa0 = sum(kappa_syn * da_local) / (LENGTH * HEIGHT)
+     mu0    = sum(   mu_syn * da_local) / (LENGTH * HEIGHT)
+     rho0   = sum(  rho_syn * da_local) / (LENGTH * HEIGHT)
+     alpha0 = sqrt( (kappa0 + FOUR_THIRDS*mu0) / rho0 )
+     beta0  = sqrt(    mu0 / rho0 )
+     bulk0  = sqrt( kappa0 / rho0 )
+     !alpha0 = sum(alpha_initial_syn * da_local) / (LENGTH * HEIGHT)
+     !beta0  = sum(beta_initial_syn * da_local)  / (LENGTH * HEIGHT)     
+
+!!$     ! initial and reference velocity structure
+!!$     ! From this model, we compute fractional perturbations.
+!!$     bulk_initial_syn(:,:,:) = bulk_syn(:,:,:)
+!!$     beta_initial_syn(:,:,:) = beta_syn(:,:,:)
+
+     !=========================================
+     ! TARGET MODEL (data)
+
+     ! set velocity field for the data (perturbed reference model)
+     ! assigns local arrays mu_dat, kappa_dat, rho_dat
+     iref = 0
+     call set_model_property(iref)
+
+     ! if HESSIAN option, then READ in the structure file (local level)
+     ! NOTE: Assume that the mesh and scaling values are IDENTICAL
+     !       to what was used in the base directory for the CG algorithm.
+     if (HESSIAN .and. INV_STRUCT == 1) then
+
+        kappa_syn = 0.0
+        mu_syn = 0.0
+        rho_syn = 0.0
+
+        ! THERE IS SOME UNRESOLVED ISSUE WITH EITHER THE MATLAB FILES WRITING OVER OLD FILES,
+        ! OR THE SCRATCH DISK ON DENALI.  WHATEVER THE CASE, WE MUST CHECK THAT THE OUTPUT
+        ! FILE IS THE SAME AS THE ONE THAT IS READ IN.
+
+        write(filename2,'(a,i2.2,a)') trim(out_dir2)//'structure_syn_h',hmod,'.dat'
+        open(unit=19,file=filename2,status='unknown')
+        do ispec = 1,NSPEC
+           do j = 1,NGLLZ
+              do i = 1,NGLLX 
+                 ! CURRENT MODEL (synthetics)
+                 !read(19,*) temp1, temp2, &
+                 !     kappa_syn(i,j,ispec), mu_syn(i,j,ispec), rho_syn(i,j,ispec), &
+                 !     temp3, temp4
+
+                 read(19,'(7e20.10)') temp1, temp2, temp3, temp4, temp5, temp6, temp7
+                 kappa_syn(i,j,ispec) = temp3
+                 mu_syn(i,j,ispec) = temp4
+                 rho_syn(i,j,ispec) = temp5
+
+                 !print *, temp4, mu_syn(i,j,ispec)
+
+                 !print *, filename2
+                 !stop 'CHECK THE FIRST ENTRY'
+
+              enddo
+           enddo
+        enddo
+        close(19)
+
+        ! smooth the input model
+        if(ISMOOTH_MODEL_UPDATE == 1) then
+           call smooth_function(kappa_syn, GAMMA_SMOOTH_MODEL, temp_local1)  ; kappa_syn = temp_local1;
+           call smooth_function(   mu_syn, GAMMA_SMOOTH_MODEL, temp_local1)  ;    mu_syn = temp_local1;
+           call smooth_function(  rho_syn, GAMMA_SMOOTH_MODEL, temp_local1)  ;   rho_syn = temp_local1;
+        endif
+
+        alpha_syn = sqrt( (kappa_syn + FOUR_THIRDS*mu_syn) / rho_syn )
+        beta_syn  = sqrt( mu_syn / rho_syn )
+        bulk_syn  = sqrt( kappa_syn / rho_syn )
+     endif
+
+     ! unperturbed structure (set target map to the map used to compute synthetics)
+     if(PERT_STRUCT == 0) then
+        kappa_dat = kappa_syn
+        mu_dat    = mu_syn
+        rho_dat   = rho_syn
+        bulk_dat  = bulk_syn
+        alpha_dat = alpha_syn
+        beta_dat  = beta_syn
+     endif
+
+     ! write velocity structure for data and synthetics to file -- LOCAL LEVEL
+     file_structure_dat = 'structure_dat.dat'
+     file_structure_syn = 'structure_syn.dat'
+     open(unit=18,file=trim(out_dir2)//file_structure_dat,status='unknown')
+     open(unit=19,file=trim(out_dir2)//file_structure_syn,status='unknown')
+     do ispec = 1,NSPEC
+        do j = 1,NGLLZ
+           do i = 1,NGLLX 
+              iglob = ibool(i,j,ispec)
+
+              ! TARGET MODEL (data)
+              write(18,'(7e20.10)') x_plot(iglob), z_plot(iglob), &
+                   kappa_dat(i,j,ispec), mu_dat(i,j,ispec), rho_dat(i,j,ispec), &
+                   log( bulk_dat(i,j,ispec) / bulk0 ), log( beta_dat(i,j,ispec) / beta0 )       
+   
+              ! CURRENT MODEL (synthetics)
+              write(19,'(7e20.10)') x_plot(iglob), z_plot(iglob), &
+                   kappa_syn(i,j,ispec), mu_syn(i,j,ispec), rho_syn(i,j,ispec), &
+                   log( bulk_syn(i,j,ispec) / bulk0 ), log( beta_syn(i,j,ispec) / beta0 ) 
+           enddo
+        enddo
+     enddo
+     close(18)
+     close(19)
+
+     !stop 'TESTING'
+
+!!$     ! TARGET MODEL (data)
+!!$     call local2global(alpha_dat, temp_global1)
+!!$     call local2global(beta_dat, temp_global2)
+!!$     open(unit=18,file=trim(out_dir2)//file_structure_dat,status='unknown')
+!!$     do iglob = 1,NGLOB
+!!$        write(18,'(6e20.10)') x_plot(iglob), z_plot(iglob), temp_global1(iglob), temp_global2(iglob), &
+!!$            log( temp_global1(iglob) / alpha0 )*100.0, log( temp_global2(iglob) / beta0 )*100.0
+!!$     enddo
+!!$     close(18)
+!!$
+!!$     ! CURRENT MODEL (synthetics)
+!!$     call local2global(alpha_syn, temp_global1)     ! P-wave structure
+!!$     call local2global(beta_syn, temp_global2)      ! S-wave structure
+!!$     open(unit=19,file=trim(out_dir2)//file_structure_syn,status='unknown')
+!!$     do iglob = 1,NGLOB
+!!$        write(19,'(6e20.10)') x_plot(iglob), z_plot(iglob), temp_global1(iglob), temp_global2(iglob), &
+!!$            log( temp_global1(iglob) / alpha0 )*100.0, log( temp_global2(iglob) / beta0 )*100.0
+!!$     enddo
+!!$     close(19)
+
+     ! write reference structure values to file
+     open(unit=16,file=trim(out_dir2)//'reference_values.dat', status='unknown')
+     write(16,'(6e20.10)') alpha0, beta0, rho0, bulk0, kappa0, mu0
+     close(16)
+
+     ! write period to file
+     open(unit=16,file=trim(out_dir2)//'reference_period.dat', status='unknown')
+     write(16,*) 2*hdur
+     close(16)
+
+!!$  ! plot phase velocity map for synthetics (and data)
+!!$  iopt = 1 + idat
+!!$  filename1 = 'get_model.csh'
+!!$  filename2 = trim(script_dir)//'plot_model.pl'
+!!$  open(19,file=filename1,status='unknown')
+!!$  write(19,'(4a,i5,3a,2f12.6,2a)') trim(filename2),' ', trim(out_dir2),' ', &
+!!$     iopt, ' ', trim(file_structure_syn), ' ', sngl(beta0), sngl(t_target),' ',trim(file_structure_dat)
+!!$  close(19)
+!!$  call system('chmod 755 get_model.csh ; get_model.csh')
+
+     ! min/max velocities and gridpoints per wavelength (locally defined)
+     alpha_min = minval(alpha_dat)
+     alpha_max = maxval(alpha_dat)
+     beta_min  = minval(beta_dat)
+     beta_max  = maxval(beta_dat)
+
+     print *, ' Mean spacing between GLL points in m :'
+     print *, '   dh    :', sngl(dh)
+     print *, ' Velocities in km/s :'
+     print *, '   Pmin  :', sngl(alpha_min/1000.0)
+     print *, '   Pmax  :', sngl(alpha_max/1000.0)
+     print *, '   Smin  :', sngl(beta_min/1000.0)
+     print *, '   Smax  :', sngl(beta_max/1000.0)
+     print *, ' Gridpoints per wavelength :'
+     print *, '   Pmin  :', floor(hdur*alpha_min/dh)
+     print *, '   Pmax  :', floor(hdur*alpha_max/dh)
+     print *, '   Smin  :', floor(hdur*beta_min/dh)
+     print *, '   Smax  :', floor(hdur*beta_max/dh)
+
+    ! estimate the time step
+    dh = HEIGHT/dble((NGLLZ-1)*NEZ)
+    if(dh > LENGTH/dble((NGLLX-1)*NEX)) dh = LENGTH/dble((NGLLX-1)*NEX)
+    print *
+    print *,'                       space step (km) :', sngl(dh/1000.0)
+    if(ISURFACE==0) then
+       print *,'time step est from courant = 0.2, Pmax : ',sngl(0.2*dh/alpha_max),' seconds'
+       print *,'time step est from courant = 0.2, Pmin : ',sngl(0.2*dh/alpha_min),' seconds'
+       print *,'time step est from courant = 0.2, Smax : ',sngl(0.2*dh/beta_max),' seconds'
+       print *,'time step est from courant = 0.2, Smin : ',sngl(0.2*dh/beta_min),' seconds'
+       print *,'                      actual time step : ',sngl(DT),' seconds'
+    endif
+
+     !--------------------------------------
+     ! Prior to Feb 2006, we simply assigned the source location to the nearst gridpoint.
+     ! But now we compute the locations such that ANY location is allowed.
+     !--------------------------------------
+     ! events for synthetics (eglob_syn)
+
+     if(ISURFACE==1) then
+        ! fill a portion of the [1:MAX_EVENT] vector with the SoCal events
+        x_eve_lon0_syn(1:nevent) = socal_events_lon(:)
+        z_eve_lat0_syn(1:nevent) = socal_events_lat(:)
+
+        ! all vectors should be this length
+        nevent = MAX_EVENT
+
+        ! convert from lat-lon to mesh coordinates (in meters) -- update nevent
+        call mesh_geo(nevent,x_eve_lon0_syn,z_eve_lat0_syn,x_eve0_syn,z_eve0_syn,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+     endif
+
+     ! filter target points (utm-mesh) (update nevent)
+     print *
+     print *, 'events for synthetics:'
+     call station_filter(nevent, x_eve0_syn, z_eve0_syn, ifilter_eve_syn, SOURCE_GRID_BUFFER)
+
+     if(nevent < 1) stop 'Must have at least one event'
+
+     ! allocate variables
+     if(ISURFACE==1) allocate(x_eve_lon_syn(nevent),z_eve_lat_syn(nevent))
+     allocate(x_eve_syn(nevent),z_eve_syn(nevent))
+     allocate(eglob_syn(nevent))
+     allocate(ispec_eve_syn(nevent),xi_eve_syn(nevent),gamma_eve_syn(nevent))
+     allocate(otime_syn(nevent))
+
+     ! origin time for synthetics
+     otime_syn(:) = origin_time
+
+     ! assign initial synthetic events to (x_eve_syn, z_eve_syn)
+     do i = 1,nevent
+        x_eve_syn(i) = x_eve0_syn(ifilter_eve_syn(i))
+        z_eve_syn(i) = z_eve0_syn(ifilter_eve_syn(i))
+     enddo
+
+     !write(*,'(2e24.16)') (x_eve_syn(i), z_eve_syn(i), i = 1,nevent)
+
+     ! determine the (eta, xi) corresponding to the (initial synthetic) points
+     ! this UPDATES x_eve, z_eve; eglob_syn is the index of the closest gridpoint
+     call locate_targets(nevent, x_eve_syn, z_eve_syn, eglob_syn, ispec_eve_syn, xi_eve_syn, gamma_eve_syn)
+
+     !write(*,'(2e24.16)') (x_eve_syn(i), z_eve_syn(i), i = 1,nevent)
+
+     print *
+     print *, 'ievent, x, z, iglob, ispec, xi, gamma'
+     do i = 1,nevent
+        write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_eve_syn(i), z_eve_syn(i), &
+             eglob_syn(i), ispec_eve_syn(i), xi_eve_syn(i), gamma_eve_syn(i)
+     enddo
+
+     ! display target events and final events -- and the distance between (in meters)
+     if(ISURFACE==1) then
+        ! convert from mesh to lat-lon
+        call mesh_geo(nevent, x_eve_lon_syn, z_eve_lat_syn, x_eve_syn, z_eve_syn, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+        ! The distance error is due to the UTM conversion, but the lat-lon points are only
+        ! used for plotting purposes, so this is fine.
+        print *
+        print *, 'events [x_eve_lon0_syn, z_eve_lat0_syn, x_eve_lon_syn, x_eve_lat_syn, dist (m)]:'
+        do i = 1,nevent
+           temp1 = x_eve_lon0_syn(ifilter_eve_syn(i))
+           temp2 = z_eve_lat0_syn(ifilter_eve_syn(i))
+           temp3 = x_eve_lon_syn(i)
+           temp4 = z_eve_lat_syn(i)
+           temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+           write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.0*1000.0
+        enddo
+
+     elseif(ISURFACE==0) then
+        print *
+        print *, 'events, km [x_eve0_syn, z_eve0_syn, x_eve_syn, x_eve_syn, dist]:'
+        do i = 1,nevent
+           temp1 = x_eve0_syn(ifilter_eve_syn(i))
+           temp2 = z_eve0_syn(ifilter_eve_syn(i))
+           temp3 = x_eve_syn(i)
+           temp4 = z_eve_syn(i)
+           temp5 = sqrt( (temp3-temp1)**2 + (temp4 - temp2)**2 )
+           write(*,'(i8, 5f17.10)') i,temp1/1000.0,temp2/1000.0,temp3/1000.0,temp4/1000.0,temp5/1000.0
+        enddo
+     endif
+
+     ! write events for SYNTHETICS to file
+     if( .not. HESSIAN ) then
+        open(19,file=trim(out_dir2)//'events_syn_xz.dat',status='unknown')
+        do ievent = 1,nevent
+           write(19,'(3f20.10,1i12)') x_eve_syn(ievent), z_eve_syn(ievent), otime_syn(ievent), ievent
+        enddo
+        close(19)
+        if(ISURFACE==1) then
+           open(18,file=trim(out_dir2)//'events_syn_lonlat.dat',status='unknown')
+           do ievent = 1,nevent
+              !write(18,*) sngl(x_lon(eglob_syn(ievent))), sngl(z_lat(eglob_syn(ievent))), ievent
+              write(18,'(2f20.10,1i12)') x_eve_lon_syn(ievent), z_eve_lat_syn(ievent), ievent
+           enddo
+           close(18)
+        endif
+     endif
+
+     !write(*,'(2e24.16)') (x_eve_lon_syn(i), z_eve_lat_syn(i), i = 1,nevent)
+
+     !stop 'testing event locations'
+
+     !--------------------------------------
+     ! events for data (eglob_dat)
+
+     ! allocate variables
+     if(ISURFACE==1) allocate(x_eve_lon_dat(nevent),z_eve_lat_dat(nevent))
+     allocate(x_eve_dat(nevent),z_eve_dat(nevent))
+     allocate(eglob_dat(nevent))
+     allocate(ispec_eve_dat(nevent),xi_eve_dat(nevent),gamma_eve_dat(nevent))
+     allocate(otime_dat(nevent))
+
+     if( PERT_SOURCE_T == 1 .or. PERT_SOURCE_X == 1 ) then  ! source perturbations
+
+        if(ISURFACE==1) then   ! read in PERTURBED events from another file (for GJI-2007 simulations)
+
+           ! perturbations generated from gji_src_inversion.m
+           ! NOTE: OLD ordering scheme for source indexing
+           open(19,file='INPUT/events_xy_pert.dat',status='unknown')
+           do ievent = 1,25
+              read(19,*) temp1,temp2,temp3
+              if( PERT_SOURCE_T == 0 ) temp3 = 0.0
+              if( PERT_SOURCE_X == 0 ) then
+                 temp1 = 0.0  ; temp2 = 0.0
+              endif
+              x_eve_dat(ievent) = x_eve_syn(ievent) + temp1
+              z_eve_dat(ievent) = z_eve_syn(ievent) + temp2
+              otime_dat(ievent) = otime_syn(ievent) + temp3
+           enddo
+           close(19)
+
+!!$           open(19,file='OUTPUT/run_2550/events_xy.dat',status='unknown') 
+!!$           do ievent = 1,25
+!!$              read(19,'(3f20.10,1i12)') x_eve_dat(ievent), z_eve_dat(ievent), otime_dat(ievent), itemp1
+!!$           enddo
+!!$           close(19)
+!!$          otime_dat(5) = otime_syn(5) + 0.8   ! testing for event 5 (0.8)
+
+        elseif(ISURFACE==0) then
+
+           ! perturb the events to get target events for the synthetics
+           ! perturbation is described as (r,theta) polar coordinates
+           amin = 0.0
+           amax = 2.*PI
+           rmin = 0.0
+           rmax = src_pert_dist
+           ptmin = -abs(src_pert_time)
+           ptmax =  abs(src_pert_time)
+
+           do ievent = 1,nevent
+
+              ! origin time perturbation
+              call random_number(rand1)
+              ptime = (ptmax - ptmin)*rand1 + ptmin
+              !ptime = src_pert_time   
+
+              ! azimuthal perturbation (in radians)
+              call random_number(rand1)
+              pangle = (amax - amin)*rand1 + amin
+              !pangle = 30.0*(PI/180.0)               ! fix for TESTING
+
+              ! radial perturbation (in meters)
+              call random_number(rand1)
+              prad = (rmax - rmin)*rand1 + rmin
+              !prad = rmax    
+
+              ! fill vectors
+              otime_dat(ievent) = otime_syn(ievent) - ptime                ! NOTE THE SIGN
+              x_eve_dat(ievent) = x_eve_syn(ievent) + cos(pangle)*prad
+              z_eve_dat(ievent) = z_eve_syn(ievent) + sin(pangle)*prad
+              temp1 = sqrt((x_eve_syn(ievent)-x_eve_dat(ievent))**2 + (z_eve_syn(ievent)-z_eve_dat(ievent))**2)
+
+              !write(*,'(5f18.8)') x_eve_dat(ievent)/1000.0, z_eve_dat(ievent)/1000.0, &
+              !     x_eve_syn(ievent)/1000.0, z_eve_syn(ievent)/1000.0, temp1/1000.0
+           enddo
+
+        endif
+
+        ! determine the (eta, xi) corresponding to the target points
+        ! this UPDATES x_eve, z_eve; eglob is the index of the closest gridpoint
+        call locate_targets(nevent, x_eve_dat, z_eve_dat, eglob_dat, ispec_eve_dat, xi_eve_dat, gamma_eve_dat)
+
+        print *
+        print *, 'ievent, x, z, iglob, ispec, xi, gamma'
+        do i = 1,nevent
+           write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_eve_dat(i), z_eve_dat(i), &
+                eglob_dat(i), ispec_eve_dat(i), xi_eve_dat(i), gamma_eve_dat(i)
+        enddo
+
+        if(ISURFACE==1) then
+           ! convert from mesh to lat-lon
+           call mesh_geo(nevent, x_eve_lon_dat, z_eve_lat_dat, x_eve_dat, z_eve_dat, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+           ! display target events and perturbed events -- and the distance between (in meters)
+           print *
+           print *, 'events [x_eve_lon_syn, z_eve_lat_syn, x_eve_lon_dat, z_eve_lat_dat, dist (m)]:'
+           do i = 1,nevent
+              temp1 = x_eve_lon_syn(i)
+              temp2 = z_eve_lat_syn(i)
+              temp3 = x_eve_lon_dat(i)
+              temp4 = z_eve_lat_dat(i)
+              temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+              write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.0*1000.0
+           enddo
+        endif
+
+     else  ! no source perturbation for target sources
+
+        if(ISURFACE==1) then
+           x_eve_lon_dat(:) = x_eve_lon_syn(:)
+           z_eve_lat_dat(:) = z_eve_lat_syn(:)
+        endif
+        eglob_dat(:)     = eglob_syn(:)
+        x_eve_dat(:)     = x_eve_syn(:)
+        z_eve_dat(:)     = z_eve_syn(:)
+        ispec_eve_dat(:) = ispec_eve_syn(:)
+        xi_eve_dat(:)    = xi_eve_syn(:)
+        gamma_eve_dat(:) = gamma_eve_syn(:) 
+        otime_dat(:)     = otime_syn(:)
+
+     endif   ! PERT_SOURCE
+
+     ! write events for data to file
+     if( .not. HESSIAN ) then
+        open(19,file=trim(out_dir2)//'events_dat_xz.dat',status='unknown')
+        do ievent = 1,nevent
+           write(19,'(3f20.10,1i12)') x_eve_dat(ievent), z_eve_dat(ievent), otime_dat(ievent), ievent
+        enddo
+        close(19)
+        if(ISURFACE==1) then
+           open(19,file=trim(out_dir2)//'events_dat_lonlat.dat',status='unknown')
+           do ievent = 1,nevent
+              write(19,'(2f20.10,1i12)') x_eve_lon_dat(ievent), z_eve_lat_dat(ievent), ievent
+           enddo
+           close(19)
+        endif
+     endif
+
+     !stop 'testing'
+
+     !--------------------------------------
+     ! receivers
+
+     ! allocation and initialization
+     !allocate(rglob_temp(MAX_SR))
+     !allocate(x_rec0(MAX_SR),z_rec0(MAX_SR),x_rec_lon0(MAX_SR),z_rec_lat0(MAX_SR),ifilter_rec(MAX_SR))
+     x_rec0(:) = 0.0      ; z_rec0(:) = 0.0
+     x_rec_lon0(:) = 0.0  ; z_rec_lat0(:) = 0.0
+     !rglob_temp(:) = 0
+
+     ! get the lat-lon of the TARGET RECEIVERS
+
+     if(ISURFACE==1) then   ! enter target lat-lon
+
+        if(IREC_SPACE==1) then  ! individual receivers
+
+           ! target receiver
+           !x_rec0(1) = 3 * LENGTH/4     ; z_rec0(1) = HEIGHT/2
+           x_rec_lon0(1) = -119.6        ; z_rec_lat0(1) = 34.0
+           x_rec_lon0(2) = -116.0        ; z_rec_lat0(2) = 32.5
+           x_rec_lon0(3) = -116.5        ; z_rec_lat0(3) = 35.5
+           !x_rec_lon0(1) = -116.5        ; z_rec_lat0(1) = 35.5
+
+           !x_rec_lon0(1) = -117.450717    ; z_rec_lat0(1) = 34.542814   ! 001
+           !x_rec_lon0(1) = -118.141053    ; z_rec_lat0(1) = 35.547570   ! 126
+
+           !x_rec_lon0(1) = socal_events_lon(ievent) + 1.0   ; z_rec_lat0(1) = socal_events_lat(ievent) + 1.0
+           !x_rec_lon0(2) = socal_events_lon(ievent) + 1.0   ; z_rec_lat0(2) = socal_events_lat(ievent) - 1.0
+           !x_rec_lon0(3) = socal_events_lon(ievent) - 1.0   ; z_rec_lat0(3) = socal_events_lat(ievent) + 1.0
+           !x_rec_lon0(4) = socal_events_lon(ievent) - 1.0   ; z_rec_lat0(4) = socal_events_lat(ievent) - 1.0
+
+           nrec = 3
+
+        elseif(IREC_SPACE==2) then  ! actual station locations
+
+           ! read in (target) receivers
+           recfile = trim(in_dir)//'STATION_149_full'
+           !recfile = trim(in_dir)//'STATION_144_noisland'
+           !recfile = trim(in_dir)//'STATION_067_nobasin'
+
+           open(88,file=trim(recfile),status='unknown')
+           read(88,*) nrec
+           read(88,*) (x_rec_lon0(i),z_rec_lat0(i),i = 1,nrec)
+           close(88)
+
+        elseif(IREC_SPACE==4) then ! 'regular' mesh of receivers
+
+           ! calculate mesh spacing
+           dx = LENGTH/NMESH_REC
+           dz = dx
+           j = 0
+           do xmesh = STATION_GRID_BUFFER+1.0,LENGTH,dx
+              do zmesh = STATION_GRID_BUFFER+1.0,HEIGHT,dz
+                 j = j+1
+                 x_rec0(j) = xmesh
+                 z_rec0(j) = zmesh
+              enddo
+           enddo
+           nrec = j
+
+           ! get x_rec_lon0, z_rec_lat0
+           call mesh_geo(MAX_SR,x_rec_lon0,z_rec_lat0,x_rec0,z_rec0,UTM_PROJECTION_ZONE,IMESH2LONLAT)
+
+        else
+           stop 'invalid entry for IREC_SPACE'
+
+        endif  ! IREC_SPACE
+
+     elseif(ISURFACE==0) then   ! enter target x-z
+
+        if(IREC_SPACE==1) then  ! individual receivers
+           stop ' no individual receiver listed'
+
+        elseif(IREC_SPACE==2) then  ! actual station locations
+           
+           ! read in (target) receivers
+           recfile = trim(in_dir)//'STATIONS_socal1D_rand15'  ! 200 km width
+           !recfile = trim(in_dir)//'STATIONS_socal1D_rand30'   ! 400 km width
+           open(88,file=trim(recfile),status='unknown')
+           read(88,*) nrec
+           read(88,*) (x_rec0(i),z_rec0(i),i = 1,nrec)
+           close(88)
+
+        elseif(IREC_SPACE==4) then  ! 'regular' line of receivers (BODY waves)
+
+           ! calculate mesh spacing
+           dx = LENGTH/NMESH_REC
+           j = 0
+           do xmesh = dx,LENGTH-dx,dx
+              j = j+1
+              x_rec0(j) = xmesh
+              z_rec0(j) = HEIGHT
+           enddo
+           nrec = j
+
+           ! receivers at depth (GJI2005 paper)
+           !x_rec0(j+1) = 150.0d3; z_rec0(j+1) = 0.75*HEIGHT
+           !x_rec0(j+2) = 150.0d3; z_rec0(j+2) = 0.50*HEIGHT
+           !x_rec0(j+3) = 150.0d3; z_rec0(j+3) = 0.25*HEIGHT
+           !nrec = nrec+3
+
+        else
+           stop 'invalid entry for IREC_SPACE'
+
+        endif  ! IREC_SPACE
+
+     endif
+
+     ! make sure that there are fewer target points than the max allowed
+     if(nrec > MAX_SR) then
+        print *
+        print *, ' IREC_SPACE = ', IREC_SPACE
+        print *, '       nrec = ', nrec
+        print *, '     MAX_SR = ', MAX_SR
+        stop 'rec > MAX_SR so increase MAX_SR'
+     endif
+
+     print *
+     print *, 'receivers (adjoint sources):'
+
+     ! all vectors should be length MAX_SR
+     nrec = MAX_SR
+
+     if(ISURFACE==1) then
+        ! convert from lat-lon to mesh coordinates (in meters)
+        call mesh_geo(nrec,x_rec_lon0,z_rec_lat0,x_rec0,z_rec0,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+     endif
+
+     ! filter target points (utm-mesh) -- update nrec
+     call station_filter(nrec, x_rec0, z_rec0, ifilter_rec, STATION_GRID_BUFFER)
+     !call station_filter(nrec, x_rec, z_rec, dmin_trsh_r, ncoast, coast_x, coast_z)
+     !call station_filter_2(nrec, x_rec, z_rec, -1)  ! -1 for left, +1 for right
+
+     if(nrec < 1) stop 'Must have at least one receiver'
+
+     ! allocate vectors
+     if(ISURFACE==1) allocate(x_rec_lon(nrec),z_rec_lat(nrec))
+     allocate(x_rec(nrec),z_rec(nrec))
+     allocate(rglob(nrec))
+     allocate(ispec_rec(nrec),xi_rec(nrec),gamma_rec(nrec))
+
+     ! assign allowable target receivers to (x_rec, z_rec)
+     do i = 1,nrec
+        x_rec(i) = x_rec0(ifilter_rec(i))
+        z_rec(i) = z_rec0(ifilter_rec(i))
+     enddo
+
+     ! determine the (eta, xi) corresponding to the target points
+     ! this UPDATES x_rec, z_rec; rglob is the index of the closest gridpoint
+     call locate_targets(nrec, x_rec, z_rec, rglob, ispec_rec, xi_rec, gamma_rec)
+
+     print *
+     print *, 'irec, x, z, iglob, ispec, xi, gamma'
+     do i = 1,nrec
+        write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_rec(i), z_rec(i), rglob(i), ispec_rec(i), xi_rec(i), gamma_rec(i)
+     enddo
+
+     if(ISURFACE==1) then
+        ! convert from mesh to lat-lon
+        call mesh_geo(nrec, x_rec_lon, z_rec_lat, x_rec, z_rec, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+        ! display target receivers and final receivers -- and the distance between (in meters)
+        ! The distance error is due to the UTM conversion, but the lat-lon points are only
+        ! used for plotting purposes, so this is fine.
+        print *
+        print *, ' receivers [x_rec_lon0, z_rec_lat0, x_rec_lon, x_rec_lat, dist (m)] :'
+        do i = 1,nrec
+           temp1 = x_rec_lon0(ifilter_rec(i))
+           temp2 = z_rec_lat0(ifilter_rec(i))
+           temp3 = x_rec_lon(i)
+           temp4 = z_rec_lat(i)
+           temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+           write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.0*1000.0
+        enddo
+     endif
+
+     ! receiver indices for writing the misfit chi_data(rec), summed over all events
+     rglob0(1:nrec) = rglob(1:nrec)
+
+     !do i = 1,nrec
+     !   print *, sngl(x(rglob(i))/1000.0),sngl(z(rglob(i))/1000.0),sngl(x_rec(i)/1000.0),sngl(z_rec(i)/1000.0)
+     !enddo
+
+     !stop 'testing'
+
+     ! deallocate
+     !deallocate(x_rec,z_rec)
+
+     ! write receivers to file
+     if(ISURFACE==1) then
+        open(18,file=trim(out_dir2)//'recs_lonlat.dat',status='unknown')
+        do irec = 1,nrec
+           write(18,'(2f20.10,1i12)') x_rec_lon(irec), z_rec_lat(irec), irec
+        enddo
+        close(18)
+     endif
+     open(19,file=trim(out_dir2)//'recs_xz.dat',status='unknown')
+     do irec = 1,nrec
+        write(19,'(2f20.10,1i12)') x_rec(irec), z_rec(irec), irec
+     enddo
+     close(19)
+
+     !--------------------------------------
+     ! allocate Lagrange interpolators for sources and receivers for both data and synthetics
+
+     ! allocate 1-D Lagrange interpolators and derivatives
+     allocate(hxied(NGLLX), hpxied(NGLLX), hgammaed(NGLLZ), hpgammaed(NGLLZ))
+     allocate(hxied_store(nevent,NGLLX), hgammaed_store(nevent,NGLLZ))
+
+     allocate(hxie(NGLLX), hpxie(NGLLX), hgammae(NGLLZ), hpgammae(NGLLZ))
+     allocate(hxie_store(nevent,NGLLX), hgammae_store(nevent,NGLLZ))
+
+     allocate(hxir(NGLLX), hpxir(NGLLX), hgammar(NGLLZ), hpgammar(NGLLZ))
+     allocate(hxir_store(nrec,NGLLX), hgammar_store(nrec,NGLLZ))
+
+     ! events for data
+     do ievent = 1,nevent
+        call lagrange_poly(xi_eve_dat(ievent),NGLLX,xigll,hxied,hpxied)
+        call lagrange_poly(gamma_eve_dat(ievent),NGLLZ,zigll,hgammaed,hpgammaed)
+        hxied_store(ievent,:)    = hxied(:)
+        hgammaed_store(ievent,:) = hgammaed(:)
+        !write(*,'(i8,5f16.10)') ievent, hxied(:)       ! NGLLX
+        !write(*,'(i8,5f16.10)') ievent, hgammaed(:)    ! NGLLZ
+     enddo
+     deallocate(hxied, hpxied, hgammaed, hpgammaed)
+
+     ! events for synthetics
+     do ievent = 1,nevent
+        call lagrange_poly(xi_eve_syn(ievent),NGLLX,xigll,hxie,hpxie)
+        call lagrange_poly(gamma_eve_syn(ievent),NGLLZ,zigll,hgammae,hpgammae)
+        hxie_store(ievent,:)    = hxie(:)
+        hgammae_store(ievent,:) = hgammae(:)
+        !write(*,'(i8,5f16.10)') ievent, hxie(:)       ! NGLLX
+        !write(*,'(i8,5f16.10)') ievent, hgammae(:)    ! NGLLZ
+     enddo
+     deallocate(hxie, hpxie, hgammae, hpgammae)
+
+     ! receivers
+     do irec = 1,nrec
+        call lagrange_poly(xi_rec(irec),NGLLX,xigll,hxir,hpxir)
+        call lagrange_poly(gamma_rec(irec),NGLLZ,zigll,hgammar,hpgammar)
+        hxir_store(irec,:)    = hxir(:)
+        hgammar_store(irec,:) = hgammar(:)
+        !write(*,'(i8,5f16.10)') irec, hxir(:)       ! NGLLX
+        !write(*,'(i8,5f16.10)') irec, hgammar(:)    ! NGLLZ
+     enddo
+     deallocate(hxir, hpxir, hgammar, hpgammar)
+
+     !stop 'testing'
+
+     !--------------------------------------
+     ! fake receivers for recording seismograms from the adjoint wavefield
+     ! (note that we do not compute lat-lon for these points)
+     ! THIS PORTION COULD BE REMOVED -- IT WAS FOR COMPUTING THE SPECTRAL MAP
+     ! FOR THE OCEAN MICROSEISM SIMULATIONS.
+
+     if(ISURFACE==1) then
+
+        ! mesh of target points
+        x_recf0(:) = 0.0
+        z_recf0(:) = 0.0
+        dx = LENGTH/9.0
+        dz = dx
+        i = 0
+        do xmesh = 0.0,LENGTH,dx
+           do zmesh = 0.0,HEIGHT,dz
+              i = i+1
+              if(i > MAX_SR_FAKE) stop 'i > MAX_SR_FAKE so change dx, dz, or MAX_SR_FAKE'
+              x_recf0(i) = xmesh
+              z_recf0(i) = zmesh
+           enddo
+        enddo
+        !nrecf = i
+
+        print *
+        print *, 'fake receivers (for spectral maps):'
+
+        ! all vectors should be length MAX_SR_FAKE
+        nrecf = MAX_SR_FAKE
+
+        ! filter target points (utm-mesh) -- update nrecf
+        call station_filter(nrecf, x_recf0, z_recf0, ifilter_recf, STATION_GRID_BUFFER)
+
+        if(nrecf < 1) stop 'Must have at least one fake (adjoint) receiver'
+
+        ! allocate vectors
+        allocate(x_recf(nrecf),z_recf(nrecf),fglob(nrecf))
+
+        ! assign allowable target receivers to (x_rec, z_rec)
+        do i = 1,nrecf
+           x_recf(i) = x_recf0(ifilter_recf(i))
+           z_recf(i) = z_recf0(ifilter_recf(i))
+           !print *, i, x_recf(i), z_recf(i)
+        enddo
+
+        ! fglob is the index of the CLOSEST GRIDPOINT
+        call locate_targets(nrecf, x_recf, z_recf, fglob)
+
+        !do i = 1,nrecf
+        !  print *, sngl(x(fglob(i))/1000.0),sngl(z(fglob(i))/1000.0),sngl(x_recf(i)/1000.0),sngl(z_recf(i)/1000.0)
+        !enddo
+
+        if(0==1) then
+           ! display target receivers and final fake receivers -- distances in km
+           print *
+           print *, ' fake receivers [x_rec0, z_rec0, x_rec, x_rec, dist (km)]:'
+           do i = 1,nrecf
+              temp1 = x_recf0(ifilter_recf(i)) / 1000.0
+              temp2 = z_recf0(ifilter_recf(i)) / 1000.0
+              temp3 = x_recf(i) / 1000.0
+              temp4 = z_recf(i) / 1000.0
+              temp5 = sqrt( (temp3-temp1)**2 + (temp4-temp2)**2 )
+              write(*,'(i8,5f17.10)') i, temp1, temp2, temp3, temp4, temp5
+           enddo
+        endif
+
+        ! deallocate: all we need is fglob
+        deallocate(x_recf,z_recf)
+
+     endif
+
+     !--------------------------------------
+     ! initial model vectors
+
+     !nmod_str = NVAR_STRUCT * NGLOB      ! structure parameters
+     nmod_str = NVAR_STRUCT * NLOCAL     ! structure parameters
+     nmod_src = NVAR_SOURCE * nevent     ! source parameters
+     nmod     = nmod_str + nmod_src       ! total model parameters
+
+     print *, '         NGLOB ', NGLOB
+     print *, '        NLOCAL ', NLOCAL
+     print *, '          nmod ', nmod
+     print *, '      nmod_str ', nmod_str
+     print *, '      nmod_src ', nmod_src
+
+     m_inds(:,:) = 0
+     m_inds(1,1) = 1                   ; m_inds(1,2) = NLOCAL
+     m_inds(2,1) = NLOCAL+1            ; m_inds(2,2) = nmod_str
+     m_inds(3,1) = nmod_str+1          ; m_inds(3,2) = nmod_str+nevent
+     m_inds(4,1) = nmod_str+nevent+1   ; m_inds(4,2) = nmod_str+2*nevent
+     m_inds(5,1) = nmod_str+2*nevent+1 ; m_inds(5,2) = nmod
+
+     ! write source indexing to file
+     open(unit=18,file=trim(out_dir2)//'m_inds.dat',status='unknown')
+     do i = 1,NVAR
+         write(18,'(2i10)') m_inds(i,1),m_inds(i,2)
+     enddo
+     close(18)
+
+     ! source indexing for the model vector
+     allocate(index_source(NVAR_SOURCE, nevent))
+     itemp = 0
+     do i = 1,NVAR_SOURCE
+        do j = 1,nevent
+           itemp = itemp + 1
+           index_source(i,j) = itemp
+        enddo
+     enddo
+
+     ! write source indexing to file
+     open(unit=18,file=trim(out_dir2)//'index_source.dat',status='unknown')
+     do i = 1,NVAR_SOURCE
+        do j = 1,nevent
+           write(18,'(4i10)') index_source(i,j),i,j
+        enddo
+     enddo
+     close(18)
+
+     ! allocate model vector
+     allocate(m0(nmod),mt(nmod),mdiff(nmod))
+     allocate(cov_imetric(nmod),icov_metric(nmod),cov_model(nmod),icov_model(nmod))
+     allocate(gradient(nmod),gradient_data(nmod),gradient_model(nmod))
+     allocate(m0_vec(nmod),mt_vec(nmod),m0_vec_initial(nmod))
+     allocate(g0(nmod),gt(nmod),gk(nmod),p0(nmod),pk(nmod))
+
+     ! gradient values for each parameter
+     allocate(gradient_data_all(nevent,NVAR))
+     gradient_data_all(:,:) = 0.0
+
+     !allocate(m_vel(nmod_str),m0_vel(nmod_str),mt_vel(nmod_str))
+
+     m0(:)       = 0.0
+     mt(:)       = 0.0
+     m0_vec(:)   = 0.0
+     mt_vec(:)   = 0.0
+     !m0_prior(:) = 0.0
+
+     !------------------
+     ! source-related vectors
+
+     ! scaling for source model coefficients
+     allocate(source_gradient(nmod_src))
+     allocate(m_src_syn_vec(nmod_src),m_src_syn(nmod_src),m_src_syn_vec_initial(nmod_src),m_src_syn_initial(nmod_src))
+     allocate(m_src_dat_vec(nmod_src),m_src_dat(nmod_src))
+     !allocate(m_scale_src_all(nmod_src))
+     !allocate(m_src(nmod_src),mt_src(nmod_src),m0_src(nmod_src),m_scale_src_all(nmod_src))
+
+     m_src_dat(:) = 0.0
+     m_src_syn(:) = 0.0
+     m_src_dat_vec(:) = 0.0
+     m_src_syn_vec(:) = 0.0
+     m_src_syn_vec_initial(:) = 0.0
+
+     ! fill source model vector for SYNTHETICS AND DATA
+     ! NOTE: Only fill the source parameters that are being RUN;
+     !       otherwise, the computation of the norm of the model vector
+     !       and target model vector will differ based on events
+     !       that you are not interested in.
+     !       This also avoids the issue of iterating the non-running
+     !       sources to new sources.
+     do ievent = ievent_min,ievent_max
+        !itemp1 = (ievent-1)*3 + 1
+        !itemp2 = (ievent-1)*3 + 2
+        !itemp3 = (ievent-1)*3 + 3
+
+        itemp1 = index_source(1,ievent)
+        itemp2 = index_source(2,ievent)
+        itemp3 = index_source(3,ievent)
+
+        m_src_syn_vec(itemp1) = otime_syn(ievent)
+        m_src_syn_vec(itemp2) = x_eve_syn(ievent)
+        m_src_syn_vec(itemp3) = z_eve_syn(ievent)
+
+        m_src_dat_vec(itemp1) = otime_dat(ievent)
+        m_src_dat_vec(itemp2) = x_eve_dat(ievent)
+        m_src_dat_vec(itemp3) = z_eve_dat(ievent)
+     enddo
+
+     !------------------
+     ! initial model vector (physical coordinates)
+
+     ! create m0 -- should be identical to what is "un-done" in the CG algorithm
+     temp_local1(:,:,:) = log( bulk_syn(:,:,:) / bulk0 )
+     temp_local2(:,:,:) = log( beta_syn(:,:,:) / beta0 )
+     call local2mvec(temp_local1, temp_local2, nmod_src, m_src_syn, nmod, m0)
+
+     ! create m0_vec
+     call local2mvec(bulk_syn, beta_syn, nmod_src, m_src_syn_vec, nmod, m0_vec)
+
+     !m0_prior(:) = m0(:)
+     m0_vec_initial(:) = m0_vec(:)
+
+     if( .not. HESSIAN ) then
+        open(88,file=trim(out_dir2)//'initial_model_vector.dat',status='unknown')
+        do i = 1,nmod
+           write(88,'(2e24.12)') m0_vec(i), m0(i)
+        enddo
+        close(88)
+     endif
+
+     !stop 'testing'
+
+     ! apply uniform scaling
+     !m_scale_src(:) = m_scale_src(:) / joint_str_src_grad_ratio
+
+!!$     do ievent = 1,nevent
+!!$        do i = 1,3
+!!$           itemp = (ievent-1)*3 + i
+!!$           m_scale_src_all(itemp) = m_scale_src(i)
+!!$        enddo
+!!$     enddo
+
+     ! initial source parameters for SYNTHETICS
+     m_src_syn_vec_initial(:) = m_src_syn_vec(:)
+     m_src_syn_initial(:)     = m_src_syn_vec(:) - m_src_syn_vec_initial(:)     ! = 0.
+
+     ! initial source parameters for DATA and SYNTHETICS
+     ! perturbations are w.r.t. INITIAL SYNTHETICS
+     m_src_dat(:) = m_src_dat_vec(:) - m_src_syn_vec_initial(:)
+     m_src_syn(:) = m_src_syn_vec(:) - m_src_syn_vec_initial(:)
+
+     ! write out initial source vector
+     if( .not. HESSIAN ) then
+        open(88,file=trim(out_dir2)//'initial_source.dat',status='unknown')
+        do i = 1,nmod_src
+           !write(88,'(5e24.12)') m_scale_src_all(i), m_src_syn_vec_initial(i), m_src_syn_initial(i), m_src_dat_vec(i), m_src_dat(i)
+           write(88,'(4e24.12)') m_src_syn_vec_initial(i), m_src_syn_initial(i), m_src_dat_vec(i), m_src_dat(i)
+        enddo
+        close(88)
+     endif
+
+     !------------------
+     ! MODEL COVARIANCE MATRIX = inverse metric tensor
+     ! NOTE: This part of the code is crucial for doing joint source-structure inversions,
+     !       which require a particular balance between source gradients and structure gradients.
+     !       IT IS STILL IN DEVELOPMENT, but will work for the test cases.
+
+     ! (INVERSE) METRIC TENSOR: variances only
+     ! NOTE: The inverse metric tensor is a diagonal covariance matrix.
+
+     ! scaling vector for STRUCTURE parameters
+     sigma_checker_scale = 2.0   ! to mimic a Gaussian distibution
+     m_scale_str(1) = (afac/sigma_checker_scale)/100.0    ! dimensionless : bulk* = ln(bulk/bulk0)
+     m_scale_str(2) = (afac/sigma_checker_scale)/100.0    ! dimensionless : beta* = ln(beta/beta0)
+
+     ! scaling vector for SOURCE parameters
+     if( GJI_PAPER == 1 ) then
+        !joint_str_src_grad_ratio = (70000.0 / 5000.0)   ! to match the new version
+        !joint_str_src_grad_ratio = 1.0
+        m_scale_src(1) = 2*hdur         ! dts is scaled by period (20s)
+        m_scale_src(2) = 2*hdur*beta0   ! dxs is scaled by wavelength (70000 m)
+        m_scale_src(3) = 2*hdur*beta0   ! dzs is scaled by wavelength (70000 m)
+     else
+        !joint_str_src_grad_ratio = 1.0
+        !m_scale_src(1) = src_pert_time * (20.0/1.0)/(70000.0/5000.0)   ! to match the old version
+        m_scale_src(1) = src_pert_time
+        m_scale_src(2) = src_pert_dist
+        m_scale_src(3) = src_pert_dist
+     endif
+
+     sigma_bulk = m_scale_str(1)
+     sigma_beta = m_scale_str(2)
+     sigma_ts   = m_scale_src(1)
+     sigma_xs   = m_scale_src(2)
+     sigma_zs   = m_scale_src(3)
+
+!!$     ! For JOINT inversions, there are several ways to balance the source and structure portions.
+!!$     ! A simple way is to incorporate a scaling factor in the sigma-structure terms.
+!!$     ! This will control the relative weight of each set of parameters.
+!!$     ! NOTE : We approximate our checkerboard-generated structure values by a Gaussian distribution.
+!!$     if( INV_SOURCE == 1 .and. INV_STRUCT == 1) then
+!!$        if( HESSIAN ) then
+!!$           joint_str_src_grad_ratio = 1.0
+!!$        else
+!!$           ! see also scale_struct_gji (F^2)
+!!$           joint_str_src_grad_ratio = 10.0
+!!$           !joint_str_src_grad_ratio = 6.25
+!!$        endif
+!!$        joint_total_weight = 0.5         ! split the source and structure parts evenly
+!!$
+!!$     else   ! basic structure or basic source inversion
+!!$        joint_str_src_grad_ratio = 1.0
+!!$        joint_total_weight = 1.0
+!!$
+!!$     endif
+!!$     jfac    = 0.5 * (joint_str_src_grad_ratio + 1.0)  ! =1 for non-joint inversions
+!!$     jsw_str = joint_str_src_grad_ratio / jfac             ! =1 for non-joint inversions
+!!$     jsw_src = 1.0 / jfac                                ! =1 for non-joint inversions
+
+     !------------------------------
+
+     ! DEFAULT: do not incorporate the norms of the initial gradients into the 
+     ugrad_str = 1.0 ; ugrad_ts = 1.0 ; ugrad_xs = 1.0 ; ugrad_ys = 1.0
+
+     ! DEFAULT: equal weight to each part
+     fac_str = 1.0  ;  fac_ts = 1.0 ;  fac_xs = 1.0 ;  fac_ys = 1.0
+     fac_total = 1.0
+
+     ! (1) unbalanced initial gradient values (gradient_norm_all_unbalanced.dat) -- 3 x 3 checker model
+     ! (2) how much toward the norm should each variable contribute
+     if     ( INV_STRUCT == 1 .and. INV_SOURCE_T == 0 .and. INV_SOURCE_X == 0 ) then   ! structure
+        fac_str = 1.00
+
+     elseif ( INV_STRUCT == 0 .and. INV_SOURCE_T == 1 .and. INV_SOURCE_X == 0 ) then   ! origin time
+        fac_ts = 1.00
+
+     elseif ( INV_STRUCT == 0 .and. INV_SOURCE_T == 0 .and. INV_SOURCE_X == 1 ) then   ! location
+        fac_xs = 0.50 ;  fac_ys = 0.50
+
+     elseif ( INV_STRUCT == 1 .and. INV_SOURCE_T == 1 .and. INV_SOURCE_X == 0 ) then   ! structure + origin time
+        fac_str = 0.50 ;  fac_ts = 0.50
+
+     elseif ( INV_STRUCT == 1 .and. INV_SOURCE_T == 0 .and. INV_SOURCE_X == 1 ) then   ! structure + location
+        fac_str = 0.50 ;  fac_xs = 0.25 ;  fac_ys = 0.25
+
+     elseif ( INV_STRUCT == 0 .and. INV_SOURCE_T == 1 .and. INV_SOURCE_X == 1 ) then   ! source
+        !ugrad_ts = 6.538943677 ; ugrad_xs = 3.288688153 ; ugrad_ys = 3.900641302  !  fac_total = 43.0
+        !fac_ts = 0.50 ;  fac_xs = 0.25 ;  fac_ys = 0.25
+        fac_total = (ugrad_ts/fac_ts) + (ugrad_xs/fac_xs) + (ugrad_ys/fac_ys)
+
+     elseif ( INV_STRUCT == 1 .and. INV_SOURCE_T == 1 .and. INV_SOURCE_X == 1 ) then   ! joint
+        ! we obtain these values by looking at the initial unbalanced data gradient (gradient_norm_data_all_unbalanced.dat)
+        ! TEST CASES: 1-25 events, 1-5 events, 5-5 event
+        !ugrad_str = 0.1296496361d6 ; ugrad_ts = 0.2706999550d4; ugrad_xs = 0.1334372694d4 ; ugrad_ys = 0.1743549898d4  ! Nfac = 2, 25 events
+
+        !ugrad_str = 0.2070999127d6 ; ugrad_ts = 0.3507740673d4 ; ugrad_xs = 0.1940368586d4 ; ugrad_ys = 0.2142118702d4  ! Nfac = 3, 25 events
+        !ugrad_str =  0.4247330856d6; ugrad_ts = 0.5896527525d4; ugrad_xs = 0.2643538184d4; ugrad_ys = 0.3342815391d4  ! Nfac = 3, 5 events
+        ugrad_str = 0.1205146534d6 ; ugrad_ts = 0.2926409454d3; ugrad_xs = 0.9695606936d3; ugrad_ys = 0.7224889563d3  ! Nfac = 3, 1 event
+
+        fac_str = 1.0/2.0  ;  fac_ts = 1.0/6.0 ;  fac_xs = 1.0/6.0  ;  fac_ys = 1.0/6.0 
+        fac_total = (ugrad_str/fac_str) + (ugrad_ts/fac_ts) + (ugrad_xs/fac_xs) + (ugrad_ys/fac_ys)
+     endif
+
+     ! weight for source, to compare with ugrad_str (hence factor of 2)
+     !ugrad_src = 2.0 * (fac_ts*ugrad_ts + fac_xs*ugrad_xs + fac_ys*ugrad_ys)
+
+     ! Re-set any weights that are 0.0 to 1.0; these portions of the covariance matrix
+     ! should not play a role, since the corresponding gradients will always be 0.0.
+     !if(fac_str < EPS) fac_str = 1.0
+     !if(fac_ts < EPS) fac_ts = 1.0
+     !if(fac_xs < EPS) fac_xs = 1.0
+     !if(fac_ys < EPS) fac_ys = 1.0
+
+     ! Because we do not have perfect coverage, we need to adjust the normalization such that
+     ! a perfectly recovered (source or structure) model gives a norm of about 1.0.
+     ! The means adjusting the weights of the respective parts, based on the
+     ! perfectly recovered model (i.e., no data errors added, no model norm term).
+     ! Thus, the norm of the target model will then be somewhat GREATER than 1.0.
+     coverage_str = 0.666 / 0.962
+     coverage_src = 0.946 / 1.018
+     !coverage_str = 1.0
+     !coverage_src = 1.0
+
+     ! structure part
+     cov_model(m_inds(1,1):m_inds(1,2)) = ( sigma_bulk )**2 / da_local_vec(:) * AREA * coverage_str
+     cov_model(m_inds(2,1):m_inds(2,2)) = ( sigma_beta )**2 / da_local_vec(:) * AREA * coverage_str
+
+     ! source part
+     cov_model(m_inds(3,1):m_inds(3,2)) = sigma_ts**2 * dnparm_src_run * coverage_src
+     cov_model(m_inds(4,1):m_inds(4,2)) = sigma_xs**2 * dnparm_src_run * coverage_src
+     cov_model(m_inds(5,1):m_inds(5,2)) = sigma_zs**2 * dnparm_src_run * coverage_src
+
+     ! incorporate relative weighting to make the final metric
+     ! STRUCTURE: (fac_str / ugrad_str) * ugrad_str --> fac_str
+     cov_imetric(m_inds(1,1):m_inds(1,2)) = cov_model(m_inds(1,1):m_inds(1,2)) * (fac_str / ugrad_str) * fac_total
+     cov_imetric(m_inds(2,1):m_inds(2,2)) = cov_model(m_inds(2,1):m_inds(2,2)) * (fac_str / ugrad_str) * fac_total
+     cov_imetric(m_inds(3,1):m_inds(3,2)) = cov_model(m_inds(3,1):m_inds(3,2)) * (fac_ts / ugrad_ts) * fac_total
+     cov_imetric(m_inds(4,1):m_inds(4,2)) = cov_model(m_inds(4,1):m_inds(4,2)) * (fac_xs / ugrad_xs) * fac_total
+     cov_imetric(m_inds(5,1):m_inds(5,2)) = cov_model(m_inds(5,1):m_inds(5,2)) * (fac_ys / ugrad_ys) * fac_total
+
+     ! METRIC TENSOR: inverse diagponal covariance matrix
+     icov_metric = 1.0 / cov_imetric
+     icov_model  = 1.0 / cov_model       ! unbalanced version
+
+     ! compute norm of the target model
+     ! create mtarget -- should be identical to what is shown in the CG algorithm
+     allocate(mtarget(nmod))
+     mtarget(:) = 0.0
+     temp_local1(:,:,:) = log( bulk_dat(:,:,:) / bulk0 )
+     temp_local2(:,:,:) = log( beta_dat(:,:,:) / beta0 )
+     call local2mvec(temp_local1, temp_local2, nmod_src, m_src_dat, nmod, mtarget)
+
+     ! possible stopping criteria based on the target model
+     chi_model_stop = 0.5 * model_target_norm
+
+     ! possible stopping criteria based on fitting the data
+     chi_data_stop = 0.0
+     if(ADD_DATA_ERRORS) chi_data_stop = 0.5
+
+     ! write model covariance values to file
+     open(unit=19,file=trim(out_dir2)//'sigma_values.dat',status='unknown')
+     write(19,'(2e20.10)') sigma_bulk, m_scale_str(1)
+     write(19,'(2e20.10)') sigma_beta, m_scale_str(2)
+     write(19,'(2e20.10)') sigma_ts, m_scale_src(1)
+     write(19,'(2e20.10)') sigma_xs, m_scale_src(2)
+     write(19,'(2e20.10)') sigma_zs, m_scale_src(3)
+     close(19)
+
+     open(unit=19,file=trim(out_dir2)//'scaling_values.dat',status='unknown')
+     write(19,*) 'GJI_PAPER = ', GJI_PAPER
+     write(19,*) 'IRUNZ = ', IRUNZ
+     write(19,'(6i10)') 1, NLOCAL, NLOCAL+1, nmod_str, nmod_str+1, nmod
+     write(19,'(2i10)') nparm_src_run, NLOCAL
+     write(19,'(5e14.6)') sum(da_local(:,:,:)), sum(da_local_vec(:)), sum(da_global(:)), LENGTH*HEIGHT, AREA
+     write(19,'(3e14.6)') minval(da_local_vec(:)), maxval(da_local_vec(:)), sum(da_local_vec(:))/NLOCAL
+     write(19,'(3e14.6)') minval(da_global(:)), maxval(da_global(:)), sum(da_global(:))/NGLOB
+     write(19,*) 
+     write(19,*) 'COVERAGE WEIGHTS: '
+     write(19,'(2f14.6)') coverage_str, coverage_src
+     write(19,*) 'JOINT WEIGHTS (based on unbalanced gradients): '
+     write(19,'(4f14.6)') fac_str, fac_ts, fac_xs, fac_ys
+     write(19,'(1f14.6)') fac_total
+     write(19,'(4e14.6)') ugrad_str, ugrad_ts, ugrad_xs, ugrad_ys
+     !write(19,'(1e14.6)') ugrad_src
+     write(19,'(4e14.6)') fac_str/ugrad_str, fac_ts/ugrad_ts, fac_xs/ugrad_xs, fac_ys/ugrad_ys
+     write(19,'(4e14.6)') (fac_str/ugrad_str)*fac_total, (fac_ts/ugrad_ts)*fac_total, &
+                           (fac_xs/ugrad_xs)*fac_total,  (fac_ys/ugrad_ys)*fac_total
+     !write(19,'(a20,5e14.6)') 'JOINT WEIGHTS: ', joint_str_src_grad_ratio, joint_total_weight, jfac, jsw_str, jsw_src
+     !write(19,'(a20,3e14.6)') 'STRUCTURE: ', jsw_str, joint_total_weight, jsw_str/joint_total_weight
+     !write(19,'(a20,3e14.6)') 'SOURCE: ', jsw_src, joint_total_weight, jsw_src/joint_total_weight
+     close(19)
+
+     open(unit=19,file=trim(out_dir2)//'cov_model_diagonal.dat',status='unknown')
+     do i = 1,nmod
+        write(19,'(4e20.10)') cov_imetric(i), icov_metric(i), cov_model(i), icov_model(i)
+     enddo
+     close(19)
+
+     ! write model covariance matrix diagonal to file
+     !open(unit=19,file=trim(out_dir2)//'cov_imetric_diagonal.dat',status='unknown')
+     !write(19,'(1e20.10)') (cov_imetric(i), i = 1,nmod)
+     !close(19)
+
+     ! write inverse model covariance matrix diagonal to file
+     !open(unit=19,file=trim(out_dir2)//'icov_metric_diagonal.dat',status='unknown')
+     !write(19,'(1e20.10)') (icov_metric(i), i = 1,nmod)
+     !close(19)
+
+     !------------------
+     ! DATA COVARIANCE MATRIX AND DATA INDEXING
+
+     ! number of measurements
+     nmeas     = nevent * nrec * NCOMP
+     nmeas_run = nevent_run * nrec * NCOMP
+     print *, ' nmeas = nevent * nrec * ncomp = ', nmeas
+     print *, ' nmeas_run = nevent_run * nrec * ncomp = ', nmeas_run
+
+     ! data indexing
+     allocate(index_data(nevent,nrec,ncomp))
+     itemp = 0
+     do i = 1,nevent
+        do j = 1,nrec
+           do k = 1,NCOMP
+              itemp = itemp + 1
+              index_data(i,j,k) = itemp
+           enddo
+        enddo
+     enddo
+
+     ! write data indexing to file
+     open(unit=18,file=trim(out_dir2)//'index_data.dat',status='unknown')
+     do i = 1,nevent
+        do j = 1,nrec
+           do k = 1,NCOMP
+              write(18,'(4i10)') index_data(i,j,k),i,j,k
+           enddo
+        enddo
+     enddo
+     close(18)
+
+     ! data covariance
+     allocate(cov_data(nmeas))
+     cov_data(:) = 0.0
+     
+     if(IKER==0) then
+        cov_data(:) = SIGMA_WAVEFORM * SIGMA_WAVEFORM * nmeas_run
+     elseif(IKER==1) then
+        cov_data(:) = SIGMA_DT * SIGMA_DT * nmeas_run
+     elseif(IKER==2) then
+        cov_data(:) = SIGMA_DLNA * SIGMA_DLNA * nmeas_run
+     endif
+
+     !stop 'Should this not be SIGMA_DT SQUARED?'
+
+     ! write data covariance matrix diagonal to file
+     open(unit=19,file=trim(out_dir2)//'cov_data_diagonal.dat',status='unknown')
+     write(19,'(1e20.10)') (cov_data(i), i = 1,nmeas)
+     close(19)
+
+     ! load measurement perturbations
+     if( ADD_DATA_ERRORS ) then
+
+        if(nmeas .ge. 10000) stop 'measurement error file only contains 10000 lines'
+
+        allocate(measure_pert_vec(nmeas))
+        measure_pert_vec(:) = 0.0
+
+        ! By reading in the same set of perturbations, rather than generating 
+        ! a new distrubution each time, we can be sure that the data errors will
+        ! not influence the convergence.
+        open(55,file=trim(in_dir)//'sigma_0p1_pert.dat',status='unknown')
+        do i = 1,nmeas
+           read(55,*) measure_pert_vec(i)
+        enddo
+        close(55)
+ 
+        ! check this by writing to file
+        open(55,file=trim(out_dir2)//'data_errors_added.dat',status='unknown')
+        do i = 1,nmeas
+           write(55,'(1e20.12)') measure_pert_vec(i)
+        enddo
+        close(55)
+
+     endif
+
+     !------------------
+
+     !nrec = 1
+
+     if(ISOURCE_LOG) open(91,file=trim(out_dir2)//'source_vector.log',status='unknown')
+
+     var_red_val = 100.0    ! initialize
+     chi_k_val   = 1.0d10     ! initialize to a very high value
+     itest = 0
+     !============================================
+     ! LOOP 2: over the models in the CG optimization
+     do istep = 0,2*NITERATION
+        !============================================
+
+        imod = (istep - mod(istep,2))/2          ! index into model number
+
+        irun = irun0 + istep
+        print *,'=============================================================='
+        print *,'  istep, imod, irun : ', istep, imod, irun
+        if(INV_STRUCT==1) print *, '  inverting for structure parameters'
+        if(INV_SOURCE_T==1) print *, '  inverting for source origin times'
+        if(INV_SOURCE_X==1) print *, '  inverting for source locations'
+        print *,'=============================================================='
+
+        if (HESSIAN) then
+           out_dir1 = trim(out_dir2)     ! no iteration
+        else
+           write(out_dir1,'(a,i4.4,a)') trim(out_dir3)//'run_',irun,'/'
+           command1 = 'mkdir ' // trim(out_dir1)
+           call system(command1)
+           !open(19,file='temp.csh',status='unknown')
+           !write(19,'(2a)') 'mkdir ',out_dir1
+           !close(19)
+           !call system('chmod 755 temp.csh ; temp.csh')
+        endif
+
+        ! KEY: obtain the structure and source arrays from the model vector:
+        !      structure parameters fill the top portion (bulk_syn, beta_syn);
+        !      source parameters fill the bottom portion (m_src_syn_vec)
+        if(itest==0) then      ! reference model (current model)
+           call mvec2local(nmod, nmod_src, m0_vec, bulk_syn, beta_syn, m_src_syn_vec)
+
+        elseif(itest==1) then  ! test model
+           call mvec2local(nmod, nmod_src, mt_vec, bulk_syn, beta_syn, m_src_syn_vec)
+        endif
+
+        ! for CG algorithm, update kappa_syn and mu_syn
+        if( .not. HESSIAN) then
+          kappa_syn = rho_syn * bulk_syn * bulk_syn
+          mu_syn    = rho_syn * beta_syn * beta_syn
+        endif
+
+        ! read in the sources from another file
+        ! NOTE: FOR NOW, WE DO NOT LOAD THE DATA SOURCES -- THEY SHOULD BE IDENTICAL.
+        !       (In the future, we might want to modify this to read in ANY data sources.)
+        if( HESSIAN .and. (INV_SOURCE_T == 1 .and. INV_SOURCE_X == 1)) then
+
+           write(filename,'(a,i2.2,a)') trim(out_dir2)//'src_syn_h',hmod,'.dat'
+           open(unit=18,file=filename,status='unknown')
+           m_src_syn_vec(:) = m_src_dat_vec(:)   ! initialize to no perturbation
+           do i = 1,nevent
+              !itemp1 = (i-1)*3 + 1     ! origin time
+              !itemp2 = (i-1)*3 + 2     ! x position
+              !itemp3 = (i-1)*3 + 3     ! z position
+
+              itemp1 = index_source(1,i)
+              itemp2 = index_source(2,i)
+              itemp3 = index_source(3,i)
+
+              read(18,*) temp1, temp2, &
+                   m_src_syn_vec(itemp1), m_src_syn_vec(itemp2), m_src_syn_vec(itemp3), &
+                   temp3, temp4, temp5
+           enddo
+           close(18)
+
+           ! update the entries in the model vector, then re-compute the norm
+           m0(nmod_str+1 : nmod) = m_src_syn_vec(:) - m_src_syn_vec_initial(:)
+
+        endif
+
+!!$        ! option to smooth the model update
+!!$        if( istep > 0 .and. ISMOOTH_MODEL_UPDATE == 1) then
+!!$
+!!$
+!!$        endif
+
+        ! compute model norm term in the misfit function
+        ! NOTE: The initial (prior) model is always all ZEROS (B,C,Ts,Xs,Ys);
+        !       hence, we replace (m0 - mprior) --> m0 and (mt - mprior) --> mt .
+        ! NOTE THAT THE FACTOR OF 0.5 IS NOT INCLUDED HERE
+        if(itest==0) then      ! reference model (current model)
+           call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, m0, cov_imetric, &
+               model_norm, model_norm_struct, model_norm_source, model_norm_parts)
+
+        elseif(itest==1) then  ! test model
+           call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, mt, cov_imetric, &
+               model_norm, model_norm_struct, model_norm_source, model_norm_parts)
+        endif
+
+        ! compute the difference between the present model and the target model
+        ! NOTE: We used the UN-BALANCED model covariance for the norms
+        mdiff(:) = 0.0
+        if(itest==0) then
+           mdiff = m0 - mtarget
+        elseif(itest==1) then
+           mdiff = mt - mtarget
+        endif
+        call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, mdiff, cov_model, &
+           model_diff_norm, model_diff_norm_struct, model_diff_norm_source, model_diff_norm_parts)
+
+        ! write model norms to file
+        filename1 = trim(out_dir1)//'model_norm_all.dat'
+        filename2 = trim(out_dir1)//'model_diff_norm_all.dat'
+        call write_norm_sq(filename1,model_norm_parts)
+        call write_norm_sq(filename2,model_diff_norm_parts)
+
+        ! write unbalanced target model norm to file (cov_model)
+        filename = trim(out_dir1)//'model_target_norm_all_unbalanced.dat'
+        call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, mtarget, cov_model, &
+             model_target_norm, model_target_norm_struct, model_target_norm_source, model_target_norm_parts)
+        call write_norm_sq(filename,model_target_norm_parts)
+
+        ! write balanced target model norm to file (cov_imetric)
+        filename = trim(out_dir1)//'model_target_norm_all.dat'
+        call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, mtarget, cov_imetric, &
+             model_target_norm, model_target_norm_struct, model_target_norm_source, model_target_norm_parts)
+        call write_norm_sq(filename,model_target_norm_parts)
+
+        !stop 'TESTING NORMS'
+
+        !--------------------------
+
+        ! initialize measurement vector for the current model (or test model)
+        !allocate(measure_vec(nmeas,5))   ! waveform, tt-xcor, dlna-xcorr, tt-mtm, dlna-mtm
+        allocate(measure_vec(nmeas,5))   ! tt-xcor-pert, tt-xcor, dlna-xcorr-pert, dln-xcorr, waveform
+        measure_vec(:,:) = 0.0
+        !imeasure = 0                     ! KEY: initialize for each new model
+
+        ! initialize gradient vectors
+        gradient(:) = 0.0 ; gradient_data(:) = 0.0 ; gradient_model(:) = 0.0
+        source_gradient(:) = 0.0
+        atype_kernel_sum = 0.0
+        btype_kernel_sum = 0.0
+
+        ! initialize misfit
+        chi_data(:,:,:,:) = 0.0
+
+        !stop 'testing'
+
+        ! flag to write wave-speed values and source locations to file ONCE per model
+        ifirst_event = 1
+
+        !============================================
+        ! LOOP 3: over the events
+        do ievent = ievent_min, ievent_max
+        !do ievent = 5,5    ! 1,5 or 5,5
+           !============================================
+
+           print *,'------------------------------------'
+           print *,'  EVENT NUMBER ',ievent
+           print *,'  istep, imod, irun : ', istep, imod, irun
+           print *,'------------------------------------'
+
+           ! NAME THE OUTPUT DIRECTORY
+           write(ev_dir,'(a,i3.3,a)') 'event_',ievent,'/'
+           out_dir = trim(out_dir1)//trim(ev_dir)
+           command1 = 'mkdir ' // trim(out_dir)
+           call system(command1)
+           !open(19,file='temp.csh',status='unknown')
+           !write(19,'(2a)') 'mkdir ',out_dir
+           !close(19)
+           !call system('chmod 755 temp.csh ; temp.csh')
+
+           !--------------------------------------
+           ! source
+
+           ! get the lat-lon of the TARGET SOURCES
+
+           if(ISURFACE==1) then
+
+              if(ISRC_SPACE <= 5) then  ! if you do NOT want a point source from the event list
+
+                 x_src_lon0(:) = 0.0  ; z_src_lat0(:) = 0.0
+                 x_src0(:) = 0.0      ; z_src0(:) = 0.0
+
+                 if (ISRC_SPACE==1) then  ! point source(s)
+
+                    !x_src0(1) = LENGTH/4      ; z_src0(1) = HEIGHT/2
+                    !x_src_lon0(1) = -118.5370     ; z_src_lat0(1) = 34.2130   ! Northridge
+                    !x_src_lon0(1) = -117.918     ; z_src_lat0(1) = 32.3290   ! 2004/06/15
+                    !x_src_lon0(1) = -117.776     ; z_src_lat0(1) = 33.917    ! Yorba Linda
+
+                    !x_src_lon0(1) = -119.0     ; z_src_lat0(1) = 33.0
+                    !x_src_lon0(2) = -118.0     ; z_src_lat0(2) = 33.5
+                    !x_src_lon0(3) = -119.5     ; z_src_lat0(3) = 34.3
+
+                    x_src_lon0(1) = -117.7616    ; z_src_lat0(1) = 33.9228     ! event kernel for Yorba Linda
+                    !x_src_lon0(1) = -116.8480    ; z_src_lat0(1) = 34.3098     ! event kernel for Big Bear
+
+                    !x_src_lon0(1) = x_eve_lon_syn(ievent)
+                    !z_src_lat0(1) = z_eve_lat_syn(ievent)
+                    nsrc = 1
+
+                 elseif (ISRC_SPACE==2) then  ! finite source segment
+
+                    ! specify the target starting point of the fault, the azimuth, and the length
+                    x_src_lon_i = -119.0    ;  z_src_lat_i = 33.0   ;   flen   = 100.0d+03  ! short fault
+                    !x_src_lon_i = -118.0   ;  z_src_lat_i = 32.0   ;   flen   = 500.0d+03  ! long fault
+                    src_az = -45.0*(PI/180.0)        ! azimuth (clockwise from north)
+                    finc   = 1.5*dh                ! distance betwen target gridpoints (m)
+
+                    ! determine the target endpoint of the fault
+                    call utm_geo(x_src_lon_i, z_src_lat_i, x_src_i, z_src_i, UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+                    x_src_i = x_src_i - utm_xmin
+                    z_src_i = z_src_i - utm_zmin
+                    x_src_f = x_src_i + sin(src_az)*flen
+                    z_src_f = z_src_i + cos(src_az)*flen
+
+                    ! determine the xz target points of the fault (Cartesion polar coordinates)
+                    i = 0
+                    do xd = 0,flen,finc
+                       i = i+1
+                       x_src0(i) = x_src_i + sin(src_az)*(i-1)*finc
+                       z_src0(i) = z_src_i + cos(src_az)*(i-1)*finc
+                       print *, x_src0(i)/1000.0, z_src0(i)/1000.0
+                    enddo
+                    nsrc = i
+
+                    ! get target fault points in lat-lon
+                    call mesh_geo(MAX_SR,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+
+                 elseif (ISRC_SPACE==3) then  ! California continental shelf (OMS)
+
+                    x_src_lon0(1:nshelf) = shelf_lon(1:nshelf)
+                    z_src_lat0(1:nshelf) = shelf_lat(1:nshelf)
+                    nsrc = nshelf      
+
+                 elseif (ISRC_SPACE==4) then  ! California coastline (OMS)
+
+                    x_src_lon0(1:ncoast) = coast_lon(1:ncoast)
+                    z_src_lat0(1:ncoast) = coast_lat(1:ncoast)
+                    nsrc = ncoast
+
+                 elseif (ISRC_SPACE==5) then  ! finite circular region
+
+                    ! lat-lon of the center point
+                    xcen_lon = -119.0
+                    zcen_lat = 33.0
+                    x_src_lon0(1) = xcen_lon
+                    z_src_lat0(1) = zcen_lat
+                    nsrc = 1
+
+                    call mesh_geo(nsrc,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+                    xcen = x_src0(1)
+                    zcen = z_src0(1)
+
+                    ! target points within a radius of the center point
+                    s_radius = 30.0d+03
+                    dx = dh/2.0
+                    dz = dx
+                    i = 0
+                    do xmesh = xcen-s_radius, xcen+s_radius, dx
+                       do zmesh = zcen-s_radius, zcen+s_radius, dx
+                          d = sqrt((xmesh - xcen)**2+(zmesh - zcen)**2)
+                          if(d < s_radius) then
+                             i = i+1
+                             x_src0(i) = xmesh
+                             z_src0(i) = zmesh
+                          endif
+                       enddo
+                    enddo
+                    nsrc = i
+
+                    ! get circle points in lat-lon
+                    call mesh_geo(MAX_SR,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+
+                 endif  ! ISRC_SPACE
+
+                 do i = 1,nsrc
+                    print *, x_src_lon0(i), z_src_lat0(i)
+                 enddo
+
+                 ! make sure that there are fewer target points than the max allowed
+                 ! (this is not ideal, since you might have a file of points that extend far outside the grid)
+                 if(nsrc > MAX_SR) then
+                    print *
+                    print *, ' ISRC_SPACE = ', ISRC_SPACE
+                    print *, '       nsrc = ', nsrc
+                    print *, '     MAX_SR = ', MAX_SR
+                    stop 'nsrc > MAX_SR so increase MAX_SR'
+                 endif
+
+                 print *
+                 print *, 'source(s) for event ', ievent, ' :'
+
+                 ! all vectors should be length MAX_SR
+                 nsrc = MAX_SR
+
+                 ! convert from lat-lon to mesh coordinates (in meters) -- get (x_src0,z_src0)
+                 call mesh_geo(nsrc,x_src_lon0,z_src_lat0,x_src0,z_src0,UTM_PROJECTION_ZONE,ILONLAT2MESH)
+
+                 ! filter target points (utm-mesh) -- update nsrc
+                 call station_filter(nsrc, x_src0, z_src0, ifilter_src, SOURCE_GRID_BUFFER)
+
+                 if(nsrc < 1) stop 'Must have at least one source'
+
+                 ! allocate vectors
+                 allocate(x_src(nsrc),z_src(nsrc),x_src_lon(nsrc),z_src_lat(nsrc))
+                 allocate(sglob(nsrc))
+                 allocate(ispec_src(nsrc),xi_src(nsrc),gamma_src(nsrc))
+
+                 ! assign allowable target sources to (x_src, z_src)
+                 do i = 1,nsrc
+                    x_src(i) = x_src0(ifilter_src(i))
+                    z_src(i) = z_src0(ifilter_src(i))
+                 enddo
+
+                 ! determine the (eta, xi) corresponding to the target points
+                 ! this UPDATES x_src, z_src; sglob is the index of the closest gridpoint
+                 call locate_targets(nsrc, x_src, z_src, sglob, ispec_src, xi_src, gamma_src)
+
+                 print *
+                 do i = 1,nsrc
+                    write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_src(i), z_src(i), sglob(i), ispec_src(i), xi_src(i), gamma_src(i)
+                 enddo
+
+                 ! convert from mesh to lat-lon
+                 call mesh_geo(nsrc, x_src_lon, z_src_lat, x_src, z_src, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+                 ! display target sources and final sources -- and the distance between (in meters)
+                 ! The distance error is due to the UTM conversion, but the lat-lon points are only
+                 ! used for plotting purposes, so this is fine.
+                 print *
+                 print *, 'sources [x_src_lon0, z_src_lat0, x_src_lon, x_src_lat, dist (m)]:'
+                 do i = 1,nsrc
+                    temp1 = x_src_lon0(ifilter_src(i))
+                    temp2 = z_src_lat0(ifilter_src(i))
+                    temp3 = x_src_lon(i)
+                    temp4 = z_src_lat(i)
+                    temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+                    write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.0*1000.0
+                 enddo
+
+                 ! CHT, 05-Dec-2006
+                 allocate(hxis(NGLLX), hpxis(NGLLX), hgammas(NGLLZ), hpgammas(NGLLZ))
+                 allocate(hxis_store(nsrc,NGLLX), hgammas_store(nsrc,NGLLZ))
+
+                 ! key variables for locating synthetic sources
+                 do isrc = 1,nsrc
+                    call lagrange_poly(xi_src(isrc),NGLLX,xigll,hxis,hpxis)
+                    call lagrange_poly(gamma_src(isrc),NGLLZ,zigll,hgammas,hpgammas)
+                    hxis_store(isrc,:)    = hxis(:)
+                    hgammas_store(isrc,:) = hgammas(:)
+                    !write(*,'(i8,5f16.10)') isrc, hxis(:)       ! NGLLX
+                    !write(*,'(i8,5f16.10)') isrc, hgammas(:)    ! NGLLZ
+                 enddo
+                 deallocate(hxis, hpxis, hgammas, hpgammas)
+
+              else         ! select POINT SOURCE for array of events
+                 nsrc = 1
+              endif
+
+           else
+              if(ISRC_SPACE /= 6) stop ' for body waves, we only select a point source from the specified events'
+              nsrc = 1
+
+           endif  ! ISURFACE==1
+
+           ! allocate vectors (sources for data)
+           if(ISURFACE==1) allocate(x_src_lon_dat(nsrc),z_src_lat_dat(nsrc))
+           allocate(x_src_dat(nsrc),z_src_dat(nsrc))
+           allocate(sglob_dat(nsrc))
+           allocate(ispec_src_dat(nsrc),xi_src_dat(nsrc),gamma_src_dat(nsrc))
+
+           ! allocate 1-D Lagrange interpolators and derivatives
+           allocate(hxisd_store(nsrc,NGLLX),hgammasd_store(nsrc,NGLLZ))
+
+           if(ISRC_SPACE <= 5) then  ! if you do NOT want a point source from the event list
+              if(ISURFACE==0) stop ' for body waves, we only select a point source from the specified events'
+
+              ! use same source for data and synthetics
+              sglob_dat(1:nsrc)     = sglob(1:nsrc)   ! closest gridpoint
+              x_src_dat(1:nsrc)     = x_src(1:nsrc)
+              z_src_dat(1:nsrc)     = z_src(1:nsrc)
+              x_src_lon_dat(1:nsrc) = x_src_lon(1:nsrc)
+              z_src_lat_dat(1:nsrc) = z_src_lat(1:nsrc)
+
+              ispec_src_dat(1:nsrc) = ispec_src(1:nsrc)
+              gamma_src_dat(1:nsrc) = gamma_src(1:nsrc)
+              hxisd_store(1:nsrc,:) = hxis_store(1:nsrc,:)
+              hgammasd_store(1:nsrc,:) = hgammas_store(1:nsrc,:)
+
+              origin_time_dat = origin_time
+
+           else                      ! select POINT SOURCE for array of events
+
+              !-----------------
+              ! sources for data (DO NOT allow for iterative perturbations)
+
+              sglob_dat(1) = eglob_dat(ievent)   ! closest gridpoint
+              x_src_dat(1) = x_eve_dat(ievent)
+              z_src_dat(1) = z_eve_dat(ievent)
+              origin_time_dat = otime_dat(ievent)
+              if(ISURFACE==1) then 
+                 x_src_lon_dat(1) = x_eve_lon_dat(ievent)
+                 z_src_lat_dat(1) = z_eve_lat_dat(ievent)
+              endif
+              ispec_src_dat(1) = ispec_eve_dat(ievent)
+              xi_src_dat(1)    = xi_eve_dat(ievent)
+              gamma_src_dat(1) = gamma_eve_dat(ievent)
+              hxisd_store(1,:) = hxied_store(ievent,:)
+              hgammasd_store(1,:) = hgammaed_store(ievent,:)
+
+              !-----------------
+              ! sources for synthetics (allows for source perturbations)
+
+              ! source perturbations for this event
+              !itemp1 = (ievent-1)*3 + 1
+              !itemp2 = (ievent-1)*3 + 2
+              !itemp3 = (ievent-1)*3 + 3
+
+              itemp1 = index_source(1,ievent)
+              itemp2 = index_source(2,ievent)
+              itemp3 = index_source(3,ievent)
+
+              ! allocate vectors (sources for synthetics)
+              if(ISURFACE==1) allocate(x_src_lon(nsrc),z_src_lat(nsrc))
+              allocate(x_src(nsrc),z_src(nsrc))
+              allocate(sglob(nsrc))
+              allocate(ispec_src(nsrc),xi_src(nsrc),gamma_src(nsrc))
+
+              ! KEY: source values for current model and event ievent
+              origin_time_syn = m_src_syn_vec(itemp1)     ! new origin time
+              x_src(1) = m_src_syn_vec(itemp2)            ! new x position
+              z_src(1) = m_src_syn_vec(itemp3)            ! new z position
+
+              ! filter target points (utm-mesh) -- update nsrc
+              call station_filter(nsrc, x_src, z_src, ifilter_src, SOURCE_GRID_BUFFER)
+
+              if(nsrc /= 1) stop 'Must be a single point source'
+
+              ! determine the (eta, xi) corresponding to the target points
+              ! this UPDATES x_src, z_src; sglob is the index of the closest gridpoint
+              call locate_targets(nsrc, x_src, z_src, sglob, ispec_src, xi_src, gamma_src)
+
+              print *
+              do i = 1,nsrc
+                 write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_src(i), z_src(i), sglob(i), ispec_src(i), xi_src(i), gamma_src(i)
+                 write(*,'(i8,2e18.8,2i8,2e18.8)') i, x_src_dat(i), z_src_dat(i), &
+                      sglob_dat(i), ispec_src_dat(i), xi_src_dat(i), gamma_src_dat(i)
+              enddo
+
+              allocate(hxis(NGLLX), hpxis(NGLLX), hgammas(NGLLZ), hpgammas(NGLLZ))
+              allocate(hxis_store(nsrc,NGLLX), hgammas_store(nsrc,NGLLZ))
+
+              ! key variables for locating synthetic sources
+              do isrc = 1,nsrc
+                 call lagrange_poly(xi_src(isrc),NGLLX,xigll,hxis,hpxis)
+                 call lagrange_poly(gamma_src(isrc),NGLLZ,zigll,hgammas,hpgammas)
+                 hxis_store(isrc,:)    = hxis(:)
+                 hgammas_store(isrc,:) = hgammas(:)
+                 !write(*,'(i8,5f16.10)') isrc, hxis(:)       ! NGLLX
+                 !write(*,'(i8,5f16.10)') isrc, hgammas(:)    ! NGLLZ
+              enddo
+              deallocate(hxis, hpxis, hgammas, hpgammas)
+
+              !-------------------
+              ! source for data and source for synthetic
+              if(ISURFACE==1) then
+                 ! convert from mesh to lat-lon
+                 call mesh_geo(nsrc, x_src_lon, z_src_lat, x_src, z_src, UTM_PROJECTION_ZONE, IMESH2LONLAT)
+
+                 print *
+                 print *, 'sources [x_src_lon_dat, z_src_lat_dat, x_src_lon, z_src_lat, dist (m)]:'
+                 do i = 1,nsrc
+                    temp1 = x_src_lon_dat(i)
+                    temp2 = z_src_lat_dat(i)
+                    temp3 = x_src_lon(i)
+                    temp4 = z_src_lat(i)
+                    temp5 = acos( sin(temp2/DEG)*sin(temp4/DEG) + cos(temp2/DEG)*cos(temp4/DEG)*cos(temp1/DEG - temp3/DEG) )
+                    write(*,'(i8, 5f17.10)') i, temp1, temp2, temp3, temp4, temp5*6371.0*1000.0
+                 enddo
+
+              elseif(ISURFACE==0) then
+                 print *
+                 print *, 'sources [x_src_dat, z_src_dat, x_src, z_src, dist (m)]:'
+                 do i = 1,nsrc
+                    temp1 = x_src_dat(i)
+                    temp2 = z_src_dat(i)
+                    temp3 = x_src(i)
+                    temp4 = z_src(i)
+                    temp5 = sqrt( (temp3-temp1)**2 + (temp4-temp2)**2 )
+                    write(*,'(i8, 5e20.10)') i, temp1, temp2, temp3, temp4, temp5
+                 enddo
+              endif
+
+           endif  ! ISRC_SPACE
+
+           ! source log file
+           if(ISOURCE_LOG .and. ISRC_SPACE==6) then
+
+              ! indices into source vector
+              itemp1 = index_source(1,ievent)
+              itemp2 = index_source(2,ievent)
+              itemp3 = index_source(3,ievent)
+
+              !itemp1 = (ievent-1)*3 + 1     ! origin time
+              !itemp2 = (ievent-1)*3 + 2     ! x position
+              !itemp3 = (ievent-1)*3 + 3     ! z position
+
+              write(91,*)
+              write(91,*) '------------------------'
+              write(91,*) 'istep, imod, ievent, irun : '
+              write(91,*) istep, imod, ievent, irun
+              write(91,*) 'SOURCE MODEL (xs, ys, t0) :'
+              write(91,*) ' [m_src_syn_vec]:'
+              write(91,'(a12,3f18.8)') ' t0, s : ', &
+                   m_src_syn_vec(itemp1), &
+                   m_src_dat_vec(itemp1), &
+                   m_src_syn_vec(itemp1) - m_src_dat_vec(itemp1)
+              write(91,'(a12,3f18.8)') ' xs, km : ', &
+                   m_src_syn_vec(itemp2)/1000.0, &
+                   m_src_dat_vec(itemp2)/1000.0, &
+                  (m_src_syn_vec(itemp2) - m_src_dat_vec(itemp2))/1000.0
+              write(91,'(a12,3f18.8)') ' zs, km : ', &
+                   m_src_syn_vec(itemp3)/1000.0, &
+                   m_src_dat_vec(itemp3)/1000.0, &
+                  (m_src_syn_vec(itemp3) - m_src_dat_vec(itemp3))/1000.0
+           endif
+
+           !--------------------------------------
+           ! source time function FOR DATA AND SYNTHETICS
+
+           ! source magnitude (same for data and synthetics)
+           if(ISURFACE==0) then
+              ! DEBUG ARRAY SIZE
+              f0(1) = FNORM * FOR_X
+              f0(2) = FNORM * FOR_Y
+              f0(3) = FNORM * FOR_Z
+           elseif(ISURFACE==1) then
+              f0(1) = FNORM
+           else
+              stop 'NCOMP must be 1 or 3'
+           endif
+
+           ! source time function for DATA (DO NOT allow for iterative origin time perturbations)
+           stf_dat(:) = 0.0
+           call get_source_time_function(origin_time_dat,stf_dat,ti)
+
+           ! source function for data (includes the source magnitude f0)
+           allocate(samp_dat(NSTEP,NCOMP,nsrc))
+           samp_dat = 0.0 
+           do i = 1,nsrc
+              do icomp = 1,NCOMP
+                 samp_dat(:, icomp, i) = stf_dat(:) * f0(icomp)
+              enddo
+           enddo
+
+           ! source time function for SYNTHETICS (allows for iterative origin time perturbations)
+           stf_syn(:) = 0.0
+           call get_source_time_function(origin_time_syn,stf_syn,ti) 
+
+           ! source function for synthetics (includes the source magnitude f0)
+           allocate(samp(NSTEP,NCOMP,nsrc))
+           samp = 0.0 
+           do i = 1,nsrc
+              do icomp = 1,NCOMP
+                 samp(:, icomp, i) = stf_syn(:) * f0(icomp)
+              enddo
+           enddo
+
+           ! write out source time functions for the first point source (for plot_model.pl)
+           ! other source time functions will be written in write_seismogram.f90
+           do i = 1,nsrc
+              do icomp = 1,NCOMP
+                 write(file_stf,'(a,i5.5,a,i1)') trim(out_dir)//'stf_',i,'_',icomp
+                 open(12,file=file_stf,status='unknown')
+                 write(*,*)
+                 write(*,*) 'Event #', ievent, ', Source #', i
+                 write(*,*) '  actual location       : ', sngl(x_src(i)), ', ', sngl(z_src(i))
+                 write(*,*) '  closest GLL gridpoint : ', sngl(x(sglob(i))), ', ', sngl(z(sglob(i)))
+                 !write(*,*) '  actual location       : ', sngl(x_src_lon(i)), ', ', sngl(z_src_lat(i))
+                 !write(*,*) '  closest GLL gridpoint : ', sngl(x_lon(sglob(i))), ', ', sngl(z_lat(sglob(i)))
+                 do itime=1,NSTEP
+                    write(12,'(1f16.6,1e16.6)') ti(itime), samp_dat(itime,icomp,i)
+                 enddo
+                 close(12)
+              enddo
+           enddo
+
+           !--------------------------------------
+           ! testing FFT routines
+
+!!$           print *, 'testing the fft subroutine using the source time function'
+!!$           call write_spectral_map(samp, nsrc, sglob, trim(out_dir)//'test')
+!!$
+!!$           print *, 'testing the bandpass filter subroutine using the source time function'
+!!$           call filter(ti, samp, nsrc)
+!!$
+!!$           print *, 'testing the fft subroutine using the bandpass-filtered source time function'
+!!$           call write_spectral_map(samp, nsrc, sglob, trim(out_dir)//'test_f')
+!!$
+!!$           stop
+
+           !--------------------------------------
+
+           ! write source and receivers to file
+           ! NOTE THAT THE RECEIVER LABELING IS SIMPLY NUMERICAL ORDER (FOR NOW)
+           !write(filename,'(a,i3.3,a)') trim(out_dir)//'sr_e',ievent,'.txt'
+           file_src_rec = trim(out_dir)//'sr.txt'
+           open(12,file=file_src_rec,status='unknown',iostat=ios)
+           if (ios /= 0) stop 'Error opening out_dir/sr.txt'
+           write(12,'(a,2e20.10,i10)') ('S ', x_plot(sglob(i)), z_plot(sglob(i)), i, i = 1,nsrc)
+           write(12,'(a,2e20.10,i10)') ('R ', x_plot(rglob(i)), z_plot(rglob(i)), i, i = 1,nrec)
+           close(12)
+
+           ! the following are not needed, since we have sglob/rglob/fglob, the index vectors
+           ! into the sources, receivers, and fake receivers
+
+           deallocate(x_src,z_src)
+           deallocate(x_src_dat,z_src_dat)
+           if(ISURFACE==1)  deallocate(x_src_lon,z_src_lat,x_src_lon_dat,z_src_lat_dat)
+
+           !stop 'testing'
+
+           !-----------------------------------------------------
+           ! write the current models to file
+
+           ! only write the files for the first event, since they are the same for each event
+           if(ifirst_event == 1) then
+              
+              ! write velocity structure for data and synthetics to file -- LOCAL LEVEL
+              file_structure_dat = 'structure_dat.dat'
+              file_structure_syn = 'structure_syn.dat'
+              open(unit=18,file=trim(out_dir1)//file_structure_dat,status='unknown')
+              open(unit=19,file=trim(out_dir1)//file_structure_syn,status='unknown')
+              do ispec = 1,NSPEC
+                 do j = 1,NGLLZ
+                    do i = 1,NGLLX 
+                       iglob = ibool(i,j,ispec)
+
+                       ! TARGET MODEL (data)
+                       write(18,'(7e20.10)') x_plot(iglob), z_plot(iglob), &
+                            kappa_dat(i,j,ispec), mu_dat(i,j,ispec), rho_dat(i,j,ispec), &
+                            log( bulk_dat(i,j,ispec) / bulk0 ), log( beta_dat(i,j,ispec) / beta0 )       
+
+                       ! CURRENT MODEL (synthetics)
+                       write(19,'(7e20.10)') x_plot(iglob), z_plot(iglob), &
+                            kappa_syn(i,j,ispec), mu_syn(i,j,ispec), rho_syn(i,j,ispec), &
+                            log( bulk_syn(i,j,ispec) / bulk0 ), log( beta_syn(i,j,ispec) / beta0 ) 
+                    enddo
+                 enddo
+              enddo
+              close(18)
+              close(19)
+
+!!$              ! write wave-speed maps to file (data is always the same)
+!!$              ! TARGET MODEL (data)
+!!$              call local2global(bulk_dat, temp_global1)
+!!$              call local2global(beta_dat, temp_global2)
+!!$              open(unit=18,file=trim(out_dir1)//file_structure_dat,status='unknown')
+!!$              do iglob = 1,NGLOB
+!!$                 write(18,'(6e20.10)') x_plot(iglob), z_plot(iglob), temp_global1(iglob), temp_global2(iglob), &
+!!$                      log( temp_global1(iglob) / bulk0 )*100.0, log( temp_global2(iglob) / beta0 )*100.0
+!!$              enddo
+!!$              close(18)
+!!$
+!!$              ! CURRENT MODEL (synthetics)
+!!$              call local2global(bulk_syn, temp_global1)
+!!$              call local2global(beta_syn, temp_global2)
+!!$              open(unit=19,file=trim(out_dir1)//file_structure_syn,status='unknown')
+!!$              do iglob = 1,NGLOB
+!!$                 write(19,'(6e20.10)') x_plot(iglob), z_plot(iglob), temp_global1(iglob), temp_global2(iglob), &
+!!$                      log( temp_global1(iglob) / bulk0 )*100.0, log( temp_global2(iglob) / beta0 )*100.0
+!!$              enddo
+!!$              close(19)
+
+              ! write ALL source vectors to file (data is always the same)
+              open(unit=19,file=trim(out_dir1)//'src_dat.dat',status='unknown')
+              open(unit=20,file=trim(out_dir1)//'src_syn.dat',status='unknown')
+              do i = 1,nevent
+                 ! indices into source vector
+                 itemp1 = index_source(1,i)
+                 itemp2 = index_source(2,i)
+                 itemp3 = index_source(3,i)
+
+                 !itemp1 = (i-1)*3 + 1     ! origin time
+                 !itemp2 = (i-1)*3 + 2     ! x position
+                 !itemp3 = (i-1)*3 + 3     ! z position
+
+                 ! longitude and latitude values from INITIAL SYNTHETIC events for plotting only
+                 xtemp = x_plot(eglob_syn(i))
+                 ztemp = z_plot(eglob_syn(i))
+
+                 ! sources for data
+                 write(19,'(8e20.10)') xtemp, ztemp, &
+                      m_src_dat_vec(itemp1), m_src_dat_vec(itemp2), m_src_dat_vec(itemp3), &
+                      m_src_dat_vec(itemp1) - m_src_dat_vec(itemp1), &
+                      m_src_dat_vec(itemp2) - m_src_dat_vec(itemp2), &
+                      m_src_dat_vec(itemp3) - m_src_dat_vec(itemp3)
+                      
+                 ! sources for synthetics
+                 write(20,'(8e20.10)') xtemp, ztemp, &
+                      m_src_syn_vec(itemp1), m_src_syn_vec(itemp2), m_src_syn_vec(itemp3), &
+                      m_src_syn_vec(itemp1) - m_src_dat_vec(itemp1), &
+                      m_src_syn_vec(itemp2) - m_src_dat_vec(itemp2), &
+                      m_src_syn_vec(itemp3) - m_src_dat_vec(itemp3)
+              enddo
+              close(19)
+              close(20)
+
+              ifirst_event = 0
+
+           endif  ! ifirst_event
+
+           ! source time functions for data and synthetics
+           if(WRITE_STF_F) call write_seismogram(samp_dat, nsrc, trim(out_dir)//'stffor_dat')
+           if(WRITE_STF_F) call write_seismogram(samp, nsrc, trim(out_dir)//'stffor_syn')
+
+           ! STOPPING CRITERIA : exit program if structure parameters are unrealistic
+           ! for either the test model or present model
+!!$           if( maxval( m0*m0 / (SIGMA_FAC**2 * cov_imetric) ) > 1. ) then
+!!$              print *, ' maxval( m0*m0 / (SIGMA_FAC**2 * cov_imetric) ) > 1. ) : ', &
+!!$                         maxval( m0*m0 / (SIGMA_FAC**2 * cov_imetric) )
+!!$              print *, ' index : ', maxloc( m0*m0 / (SIGMA_FAC**2 * cov_imetric) )
+!!$              stop ' STOP: model values are too extreme'
+!!$           endif
+!!$           if( maxval( mt*mt / (SIGMA_FAC**2 * cov_imetric) ) > 1. ) then
+!!$              print *, ' maxval( mt*mt / (SIGMA_FAC**2 * cov_imetric) ) > 1. ) : ', &
+!!$                         maxval( mt*mt / (SIGMA_FAC**2 * cov_imetric) )
+!!$              print *, ' index : ', maxloc( mt*mt / (SIGMA_FAC**2 * cov_imetric) )
+!!$              stop ' STOP: model values are too extreme'
+!!$           endif
+
+!!$           vel_min = beta_min / 2.
+!!$           vel_max = alpha_max * 2.
+!!$           if(itest==1) then
+!!$              if( minval(mt_vec(1:nmod_str)) < vel_min .or. maxval(mt_vec(1:nmod_str)) > vel_max ) then
+!!$                 print *, minval(mt_vec(1:nmod_str)), maxval(mt_vec(1:nmod_str))
+!!$                 stop ' STOP: test model for structure is too extreme'
+!!$              endif
+!!$           else
+!!$              if( minval(m0_vec(1:nmod_str)) < vel_min .or. maxval(m0_vec(1:nmod_str)) > vel_max ) then
+!!$                 print *, minval(m0_vec(1:nmod_str)), maxval(m0_vec(1:nmod_str))
+!!$                 stop ' STOP: current model for structure is too extreme'
+!!$              endif
+!!$           endif
+
+!stop 'testing -- not running wave simulations'
+
+           !=============================================================================================
+           ! ******************************** WAVE SIMULATIONS ******************************************
+           !=============================================================================================
+
+           !=========================
+           ! DATA (forward wavefield)
+
+           ! compute data for misfit kernels
+           allocate(data(NSTEP,NCOMP,nrec))
+           data = 0.0
+
+           ! assign structure values for computing the data (always the same)
+           kappa = kappa_dat
+           mu    = mu_dat
+           rho   = rho_dat
+
+           ! DATA (forward wavefield)
+           ! nsrc, sglob, samp_dat  : #src, src index, source
+           ! nrec, rglob, data :      #rec, rec index, seis
+           ! NOTE THAT sglob_dat ALLOWS FOR A PERTURBED SOURCE FROM THE SOURCES USED TO COMPUTE THE SYNTHETICS
+           isolver = 1
+           idata = 1
+           call solver(isolver, idata, &
+                nsrc, sglob_dat, ispec_src_dat,  hxisd_store, hgammasd_store, samp_dat, &
+                nrec, rglob,     ispec_rec,      hxir_store,  hgammar_store,  data)
+
+           ! write out seismograms at the receivers
+           data_tag = 'dat'
+           if(WRITE_SEISMO_F) call write_seismogram(data, nrec, trim(out_dir)//data_tag)
+
+           !stop 'testing simulation for data'
+
+           !=========================
+           ! SYNTHETICS (forward wavefield)
+
+           !stop 'testing'
+
+           ! forward wavefield
+           allocate(syn(NSTEP,NCOMP,nrec))
+           syn = 0.0
+
+           ! assign structure values for the synthetics
+           ! (bulk and beta may change for each new model)
+           !kappa = rho_syn * (alpha_syn * alpha_syn - FOUR_THIRDS * beta_syn * beta_syn )
+           kappa = kappa_syn
+           mu    = mu_syn
+           rho   = rho_syn
+
+           isolver = 1
+           idata = 0
+           last_frame_name = trim(out_dir)//'last_frame.txt'
+           allocate(absorb_field(NSTEP, NCOMP, NGLL, NELE, NABSORB))
+           call solver(isolver, idata, &
+                nsrc, sglob, ispec_src, hxis_store, hgammas_store, samp, &
+                nrec, rglob, ispec_rec, hxir_store, hgammar_store,  syn, trim(last_frame_name), absorb_field)
+
+           ! write out seismograms at the receivers
+           syn_tag = 'syn'
+           !syn_tag = 'forward'
+           if(WRITE_SEISMO_F) call write_seismogram(syn, nrec, trim(out_dir)//syn_tag)
+
+!!$           if(WRITE_SPECTRAL_MAP_F) then
+!!$              print *, 'compute and write out forward spectral map '
+!!$              call write_spectral_map(syn, nrec, rglob, trim(out_dir)//'spectral_forward',WRITE_SPECTRA_F)
+!!$           endif
+
+           !=========================
+           ! MEASUREMENTS AND ADJOINT SOURCES
+
+           ! adjoint source function
+           allocate(adj_syn(NSTEP,NCOMP,nrec))
+           adj_syn = 0.0
+
+           ! initialize time window for adjoint source to be the entire record
+           allocate(tstart(nrec),tend(nrec))
+           tstart(:) = 0.0
+           tend(:)   = NSTEP*DT
+
+           if(ISURFACE==1) then
+              ! compute time windows for measurements based on a HOMOGENEOUS reference model
+              ! Window with should be wide enough to capture synthetic and data waveforms,
+              ! but narrow enough to exclude suprious boundary reflections.
+              print *
+              print *, 'cut times for adjoint sources'
+              open(19,file=trim(out_dir)//'measurement_time_windows.dat',status='unknown')
+              do i = 1,nrec
+
+                 ! d: distance from the source to the receivers (assuming HOMOGENEOUS model)
+                 d = sqrt( (x(sglob(1)) - x(rglob(i)))**2 + (z(sglob(1)) - z(rglob(i)))**2  )
+                 tcen = tshift + d/beta0
+
+                 ! wider window for data and synthetics that have LARGE time shifts
+                 tstart(i) = tcen - HWIN1
+                 tend(i)   = tcen + HWIN1
+
+                 write(19,'(i8,3f12.4)') i, tstart(i), tcen, tend(i)
+              enddo
+              close(19)
+           endif
+
+           !stop 'testing'
+
+           if(WRITE_SEISMO_RECONSTRUCT) then
+              allocate(data_recon(NSTEP,NCOMP,nrec))
+              data_recon = 0.0
+           endif
+
+           ! construct the adjoint source (IKER in wave2d_constants.f90)
+           !call make_adjoint_source(nrec, syn, tstart, tend, adj_syn, data)
+           call mtm_adj(ievent, nrec, syn, tstart, tend, adj_syn, data, data_recon)
+
+           if(WRITE_SEISMO_RECONSTRUCT) call write_seismogram(data_recon, nrec, trim(out_dir)//'dat_recon')
+           
+           ! specify which components you want to send back 
+           if(ISURFACE==0) then
+              if(REV_X == 0) adj_syn(:,1,:) = 0.0
+              if(REV_Y == 0) adj_syn(:,2,:) = 0.0
+              if(REV_Z == 0) adj_syn(:,3,:) = 0.0
+           endif
+
+           ! write out adjoint source time function at the receivers
+           stfadj_tag = 'stfadj'
+           if(WRITE_STF_A) call write_seismogram(adj_syn, nrec, trim(out_dir)//stfadj_tag)
+
+           ! OUTPUT ASCII FILES --> SAC FILES (make_sac_files.pl)
+           ! (1) data, (2) synthetics, (3) adjoint source time function
+
+!!$           if(WRITE_SEISMO_F) then
+!!$              filename1 = trim(script_dir)//'make_sac_files.csh'
+!!$              filename2 = 'make_sac_files.pl'
+!!$              open(19,file=filename1,status='unknown')
+!!$              if(IKER <= 4) write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', &
+!!$                   trim(out_dir),' ', trim(data_tag)  ,' ','1', tshift
+!!$              write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', & 
+!!$                   trim(out_dir),' ', trim(syn_tag)   ,' ','1', tshift
+!!$              if(WRITE_STF_A)   write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', &
+!!$                   trim(out_dir),' ', trim(stfadj_tag),' ','1', tshift
+!!$              close(19)
+!!$              call system('chmod 755 scripts/make_sac_files.csh ; scripts/make_sac_files.csh')
+!!$           endif
+
+           ! misfit for each receiver for one event for all components
+           print *,'---------------------------'
+           print *,' misfit for IKER = ',IKER
+           print *,' istep, imod, irun, ievent : ', istep, imod, irun, ievent
+           print *,' chi-data = ', sum(chi_data(ievent,:,:,1))
+           print *,'---------------------------'
+
+!!$           ! write ALL adjoint sources to file
+!!$           do ipick = 0,6
+!!$              call mtm_adj(ipick, ievent, nrec, syn, tstart, tend, adj_syn, data)
+!!$              write(stfadj_tag,'(a,i1)') 'stfadj-', ipick
+!!$              call write_source_function(nrec, ti, adj_syn, rglob, trim(out_dir)//stfadj_tag)
+!!$           enddo
+!!$
+!!$           ! plot ALL adjoint sources
+!!$           filename1 = trim(script_dir)//'make_sac_files.csh'
+!!$           filename2 = 'make_sac_files.pl'
+!!$           open(19,file=filename1,status='unknown')
+!!$           write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', trim(out_dir),' ', trim(data_tag)  ,' ',"1",tshift
+!!$           write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', trim(out_dir),' ', trim(syn_tag)   ,' ',"1",tshift
+!!$           do ipick = 0,6
+!!$              write(stfadj_tag,'(a,i1)') 'stfadj-', ipick
+!!$              write(19,'(7a,f12.6)') trim(script_dir)//trim(filename2),' ', trim(out_dir),' ', trim(stfadj_tag),' ',"1",tshift
+!!$           enddo
+!!$           close(19)
+!!$           call system('chmod 755 scripts/make_sac_files.csh ; scripts/make_sac_files.csh')
+
+           !stop 'testing adjoint sources'
+
+           !------------
+           ! we always evaluate the kernels for the present model
+           ! we only evaluate the kernel for the test model if itest==1 or POLY_ORDER==3
+
+           if( (itest==0 .or. POLY_ORDER==3) .and. COMPUTE_KERNELS) then
+              print *
+              print *, 'compute the kernel via adjoint wavefield interaction'
+              print *
+
+              isolver = 3
+              allocate(atype_kernel(NGLLX,NGLLZ,NSPEC),btype_kernel(NGLLX,NGLLZ,NSPEC),rtype_kernel(NGLLX,NGLLZ,NSPEC))
+
+              ! initialize source perturbation time series
+              allocate(three_source_model(NSTEP,NCOMP,nsrc,NVAR_SOURCE))
+              !allocate(three_source_model(NSTEP,NCOMP,nsrc,10))             ! testing
+              three_source_model(:,:,:,:) = 0.0
+
+              ! kernels
+              ! samp enters as the forward source time function,
+              ! and returns as the (time-reversed) adjoint seismograms
+              call solver(isolver, idata, &
+                   nsrc, sglob, ispec_src, hxis_store, hgammas_store, samp, &
+                   nrec, rglob, ispec_rec, hxir_store, hgammar_store, adj_syn, &
+                   trim(last_frame_name), absorb_field, &
+                   atype_kernel, btype_kernel, rtype_kernel, three_source_model, stf_syn, f0)
+              
+              !----------------------
+
+              ! gradient vector for source parameters
+              ! NOTE : FILLS ONLY NVAR_SOURCE ENTRIES OF source_gradient FOR EACH ievent
+              print *
+              print *, ' integrate time series to make the gradient for the source (unscaled)'
+              do icomp = 1,NCOMP
+                 do ipar = 1,NVAR_SOURCE   ! mislocations AND origin time error
+                 !do ipar = 2,3              ! test mislocations only
+                 !do ipar = 1,1              ! test origin time error only
+                 !do ipar = 1,10             ! testing (see solver.f90)
+
+                    !itemp = (ievent-1)*3 + ipar
+                    itemp = index_source(ipar,ievent)
+
+                    write(*,'(3i8,1e20.10)') icomp, ipar, itemp, DT*sum(three_source_model(:,icomp,1,ipar))
+                    source_gradient(itemp) = source_gradient(itemp) + DT*sum(three_source_model(:,icomp,1,ipar))
+
+                    ! write out all the time series used for the source inversion
+                    write(filename,'(a,i2.2,a,i1.1,a,i2.2)') trim(out_dir)//'pert_src_e',ievent,'_c',icomp,'_p',ipar
+                    call write_time_series(three_source_model(:,icomp,1,ipar), NSTEP, filename)
+                 enddo
+              enddo
+
+              deallocate(three_source_model)
+              !----------------------    
+
+              ! smooth EACH event kernel for the data subspace method
+              if(ISMOOTH_EVENT_KERNEL == 1) then
+                 call smooth_function(btype_kernel, GAMMA_SMOOTH, kbeta_smooth)
+                 !call smooth_function(atype_kernel, GAMMA_SMOOTH, kbulk_smooth)
+
+              else
+                 kbeta_smooth = btype_kernel
+                 !kbulk_smooth = atype_kernel
+              endif
+
+!!$              ! smooth EACH event kernel for the data subspace method
+!!$              if(ISMOOTH_EVENT_KERNEL == 1) then
+
+                 ! write smoothed beta kernel to file
+                 open(unit = 13, file = trim(out_dir)//'kernel_basis_smooth', status = 'unknown',iostat=ios) 
+                 if (ios /= 0) stop 'Error writing smoothed kernel to disk'
+                 k = 1
+                 ktemp(:) = 0.0
+                 do ispec = 1,NSPEC
+                    do j = 1,NGLLZ
+                       do i = 1,NGLLX 
+                          iglob = ibool(i,j,ispec)
+                          write(13,'(3e16.6)') x_plot(iglob), z_plot(iglob), kbeta_smooth(i,j,ispec)
+
+                          ktemp(k) = kbeta_smooth(i,j,ispec)
+                          k = k+1
+                       enddo
+                    enddo
+                 enddo
+                 close(13)
+
+                 ! store (unbalanced) norm of gradient
+                 itemp1 = index_source(1,ievent)
+                 itemp2 = index_source(2,ievent)
+                 itemp3 = index_source(3,ievent)
+                 gradient_data_all(ievent,1) = 0.0
+                 gradient_data_all(ievent,2) = sum( ktemp**2 * cov_model(m_inds(2,1):m_inds(2,2)) )
+                 gradient_data_all(ievent,3) = source_gradient(itemp1)**2 * cov_model(itemp1+nmod_str)
+                 gradient_data_all(ievent,4) = source_gradient(itemp2)**2 * cov_model(itemp2+nmod_str)
+                 gradient_data_all(ievent,5) = source_gradient(itemp3)**2 * cov_model(itemp3+nmod_str)
+
+                 ! write the gradient parts for each event to file
+                 open(unit=18,file=trim(out_dir)//'gradient_data_unbalanced.dat',status='unknown')
+                 write(18,'(5e20.10)') gradient_data_all(ievent,1), gradient_data_all(ievent,2), &
+                      gradient_data_all(ievent,3), gradient_data_all(ievent,4), gradient_data_all(ievent,5)
+                 close(18)
+
+!!$              endif
+
+              ! summed kernel (= misfit kernel) -- UNSMOOTHED
+              atype_kernel_sum = atype_kernel_sum + atype_kernel
+              btype_kernel_sum = btype_kernel_sum + btype_kernel
+
+              deallocate(atype_kernel,btype_kernel,rtype_kernel)
+
+              ! write out adjoint seismograms at the original sources
+              if(WRITE_SEISMO_A) call write_seismogram(samp, nsrc, trim(out_dir)//'synadj')
+
+           endif
+
+           ! deallocate variables associated with one event
+
+           if(WRITE_SEISMO_RECONSTRUCT) deallocate(data_recon)
+
+           deallocate(data, adj_syn, absorb_field)
+           deallocate(syn, tstart, tend)
+
+           deallocate(ispec_src_dat, xi_src_dat, gamma_src_dat)
+           deallocate(hxisd_store, hgammasd_store)
+           deallocate(samp_dat, sglob_dat)
+
+           deallocate(ispec_src, xi_src, gamma_src)
+           deallocate(hxis_store, hgammas_store)
+           deallocate(samp, sglob)
+
+        !=====================
+        enddo  ! LOOP 3 (ievent, events)
+        !=====================
+
+        print *
+        print *, ' Done with all the events for irun =', irun
+        print *, ' Now we update the model, or compute a test model'
+
+        !  stop 'testing'
+
+        !-----------------------------------------------------
+        ! misfit values
+
+        ! sum of all chi values (used in CG inversion) (nsrc = 1)
+        data_norm = sum(chi_data(:,:,:,1))
+        if (INCLUDE_MODEL_NORM) then
+           chi_val = 0.5 * ( data_norm + model_norm )
+        else
+           chi_val = 0.5 * data_norm
+        endif
+
+        ! VARIANCE REDUCTION -- note that chi_data_stop is removed
+        ! NOTE: if the new chi is larger than the previous chi, then VR < 0.
+        if(istep >= 2) then
+           var_red_val = 100.0 * ( 1.0 - ( (chi_val - chi_data_stop)**2 / (chi_k_val - chi_data_stop)**2 ) )
+
+           open(19,file=trim(out_dir1)//'variance_reduction.dat',status='unknown')
+           do ievent = 1,nevent
+              write(19,'(1f20.10)') var_red_val
+           enddo
+           close(19)
+        endif
+
+        ! write chi_data values to various files
+        call write_chi(out_dir1,nevent,nrec)
+
+        ! write all nevent * nrec * ncomp measurements to file
+        open(unit=18,file=trim(out_dir1)//'measure_vec.dat',status='unknown')
+        do i = 1,nmeas
+           write(18,'(5e20.10)') (measure_vec(i,j),j=1,5)
+        enddo
+        close(18)
+        deallocate(measure_vec)
+
+        if(ISOURCE_LOG) then
+           write(91,*) 'SUMMED MISFIT FOR ALL EVENTS'
+           write(91,'(a30,1i16)') ' N-data : ', nmeas_run
+           write(91,'(a30,1e16.8)') ' chi-data(m) : ', data_norm
+           write(91,'(a30,3e16.8)') ' chi-model(m) : ', model_norm, model_norm_struct, model_norm_source
+           write(91,'(a30,3e16.8)') ' chi_model_target(m) : ', model_target_norm, model_target_norm_struct, model_target_norm_source
+           write(91,'(a30,1e16.8)') ' chi_model_stop(mtarget) : ', chi_model_stop 
+           write(91,'(a30,1e16.8)') ' chi_data_stop : ', chi_data_stop 
+           write(91,'(a30,1e16.8)') ' chi(m) : ', chi_val
+        endif
+
+        ! STOPPING CRITERIA for CG algorithm
+        ! Program will stop after files are written (search stop_cg)
+        stop_cg = .false.
+        if( data_norm <= 2.0 * chi_data_stop) then
+            stop_cg = .true.
+            print *, ' data_norm <= 2(chi_data_stop) : ', data_norm, 2.0*chi_data_stop
+        endif
+
+        !if( itest==0 .and. (chi_val .ge. chi_k_val) ) then
+        if( itest==0 .and. var_red_val < VAR_RED_MIN ) then
+            stop_cg = .true.
+            print *, '   chi_k_val : ', chi_k_val
+            print *, '     chi_val : ', chi_val
+            print *, ' var_red_val : ', var_red_val
+            print *, ' VAR_RED_MIN : ', VAR_RED_MIN 
+            print *, ' var_red_val < VAR_RED_MIN'
+        endif
+
+!!$        if(istep == 0) chi_val_0 = chi_val
+!!$        if( chi_val <= chi_val_0 * CONV_STOP ) then
+!!$            print *, ' chi_val : ', chi_val
+!!$            print *, ' chi_val_0 * CONV_STOP : ', chi_val_0 * CONV_STOP
+!!$            print *, ' chi_val <= chi_val_0 * CONV_STOP'
+!!$            stop ' convergence criteria is met.'
+!!$        endif
+
+
+        ! enter this section if you want to compute the gradient and/or iterate
+        if( COMPUTE_KERNELS ) then
+
+           print *, ' Now we compute the gradient of the misfit function (using the misfit kernel)'
+
+           !-----------------------------------------
+           ! ASSEMBLE THE MODEL VECTOR
+
+           if (itest==0) then
+
+              m0(:) = 0.0
+              temp_local1(:,:,:) = log( bulk_syn(:,:,:) / bulk0 )
+              temp_local2(:,:,:) = log( beta_syn(:,:,:) / beta0 )
+              m_src_syn(:) = m_src_syn_vec(:) - m0_vec_initial(nmod_str+1 : nmod)    ! w.r.t initial source values (m_src_syn_vec_initial)
+              call local2mvec(temp_local1, temp_local2, nmod_src, m_src_syn, nmod, m0)
+
+           endif
+
+           !-----------------------------------------------------
+           ! COMPUTE THE GRADIENT OF THE MISFIT FUNCTION, if the present model is not
+           ! a test model or if the CG polynomial is a cubic function
+
+           if( itest==0 .or. POLY_ORDER==3 ) then
+
+              print *, ' Computing the gradient of the misfit function for a given model'
+              gradient(:) = 0.0 ; gradient_data(:) = 0.0 ; gradient_model(:) = 0.0
+
+              if(INV_STRUCT == 1) then
+
+                 ! source gradient
+                 open(unit=19,file=trim(out_dir1)//'source_gradient.dat',status='unknown')
+                 write(19,'(1e20.10)') (source_gradient(i), i = 1,nmod_src)
+                 close(19)
+
+                 ! gradient for each event
+                 open(unit=18,file=trim(out_dir)//'gradient_data_all_unbalanced.dat',status='unknown')
+                 do i = 1,nevent
+                    write(18,'(5e20.10)') gradient_data_all(i,1), gradient_data_all(i,2), &
+                       gradient_data_all(i,3), gradient_data_all(i,4), gradient_data_all(i,5)
+                 enddo
+                 close(18)
+
+                 ! WRITE OUT summed event kernel (= misfit kernel)
+                 call local2global(atype_kernel_sum, temp_global1)
+                 call local2global(btype_kernel_sum, temp_global2)
+                 open(19,file=trim(out_dir1)//'summed_ker.dat',status='unknown')
+                 do iglob = 1,NGLOB
+                    write(19,'(4e16.6)') x_plot(iglob), z_plot(iglob), temp_global1(iglob), temp_global2(iglob)
+                 enddo
+                 close(19)
+
+                 ! Smooth the summed event kernel (= misfit kernel) to remove spurious src-rec effects;
+                 ! this is done via Gaussian convolution.
+                 if( ISMOOTH_MISFIT_KERNEL == 1) then
+                    call smooth_function(btype_kernel_sum, GAMMA_SMOOTH, kbeta_smooth)
+                    !call smooth_function(atype_kernel_sum, GAMMA_SMOOTH, kbulk_smooth)
+                 else
+                    kbeta_smooth = btype_kernel_sum 
+                    !kbulk_smooth = atype_kernel_sum 
+                 endif
+                 kbulk_smooth = 0.0       ! testing for S-wave only
+
+              endif  ! INV_STRUCT
+
+              !------------------------
+              ! assemble the gradient vector
+
+              ! NOTE: structure gradient g_i = K_i * dA_i
+              temp_local1 = kbulk_smooth * da_local
+              temp_local2 = kbeta_smooth * da_local
+              call local2mvec(temp_local1, temp_local2, nmod_src, source_gradient, nmod, gradient_data)
+
+              ! add the gradient term associated with the MODEL NORM in the misfit function
+              if( INCLUDE_MODEL_NORM ) then
+                 if (itest == 0) then
+                    gradient_model(:) = m0(:) / cov_imetric(:)
+                 else
+                    gradient_model(:) = mt(:) / cov_imetric(:) 
+                 endif
+              endif
+
+              ! if NOT inverting for structure or source, then set those parts of the gradient to zero
+              if(INV_STRUCT == 0) then
+                  gradient_data(m_inds(1,1) : m_inds(2,2)) = 0.0
+                 gradient_model(m_inds(1,1) : m_inds(2,2)) = 0.0
+              endif
+              if(INV_SOURCE_T == 0) then
+                  gradient_data(m_inds(3,1) : m_inds(3,2)) = 0.0
+                 gradient_model(m_inds(3,1) : m_inds(3,2)) = 0.0
+              endif
+              if(INV_SOURCE_X == 0) then
+                 gradient_data( m_inds(4,1) : m_inds(5,2)) = 0.0
+                 gradient_model(m_inds(4,1) : m_inds(5,2)) = 0.0
+              endif
+
+              ! overall gradient
+              gradient = gradient_data + gradient_model
+
+              ! write gradient vector to file (source and structure parameters)
+              !write(19,'(1e20.10)') (gradient(i), i = 1,nmod)
+              open(unit=19,file=trim(out_dir1)//'gradient_vec.dat',status='unknown')
+              do i = 1,nmod
+                 write(19,'(3e20.10)') gradient(i), gradient_data(i), gradient_model(i)
+              enddo
+              close(19)
+
+              ! compute the overall gradient norm
+              ! NOTE THE TRICK: To compute the norm of the gradient, we would MULTIPLY by Cm, rather than divide.
+              !                 We achieve this by passing in 1/Cm instead of Cm.
+              call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, gradient, icov_metric, &
+                 gradient_norm, gradient_norm_struct, gradient_norm_source, gradient_norm_parts)
+              call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, gradient_data, icov_metric, &
+                 gradient_data_norm, gradient_data_norm_struct, gradient_data_norm_source, gradient_data_norm_parts)
+              call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, gradient_model, icov_metric, &
+                 gradient_model_norm, gradient_model_norm_struct, gradient_model_norm_source, gradient_model_norm_parts)
+
+              ! old scaling used in GJI-2007 paper
+              !scale_struct_gji = sqrt( norm_source_2 / (norm_bulk_2 + norm_beta_2) )
+              scale_struct_gji = sqrt( gradient_norm_source / gradient_norm_struct )
+              open(unit=19,file=trim(out_dir1)//'scaling_gji.dat',status='unknown')
+              write(19,'(1e20.10)') scale_struct_gji 
+              close(19)
+
+              ! write gradient norms to file
+              filename1 = trim(out_dir1)//'gradient_norm_all.dat'
+              filename2 = trim(out_dir1)//'gradient_norm_data_all.dat'
+              filename3 = trim(out_dir1)//'gradient_norm_model_all.dat'
+              call write_norm_sq(filename1,gradient_norm_parts)
+              call write_norm_sq(filename2,gradient_data_norm_parts)
+              call write_norm_sq(filename3,gradient_model_norm_parts)
+
+              ! SAME AS ABOVE, only use the unbalanced icov_model instead of icov_metric
+              call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, gradient, icov_model, &
+                 gradient_norm, gradient_norm_struct, gradient_norm_source, gradient_norm_parts)
+              call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, gradient_data, icov_model, &
+                 gradient_data_norm, gradient_data_norm_struct, gradient_data_norm_source, gradient_data_norm_parts)
+              call compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, gradient_model, icov_model, &
+                 gradient_model_norm, gradient_model_norm_struct, gradient_model_norm_source, gradient_model_norm_parts)
+
+              ! write (unbalanced) gradient norms to file
+              filename1 = trim(out_dir1)//'gradient_norm_all_unbalanced.dat'
+              filename2 = trim(out_dir1)//'gradient_norm_data_all_unbalanced.dat'
+              filename3 = trim(out_dir1)//'gradient_norm_model_all_unbalanced.dat'
+              call write_norm_sq(filename1,gradient_norm_parts)
+              call write_norm_sq(filename2,gradient_data_norm_parts)
+              call write_norm_sq(filename3,gradient_model_norm_parts)
+
+              ! scaling for joint inversions
+              if( istep==0 .and. 0==1 ) then
+
+                 ! scaling for joint source-structure inversions
+
+                 ! Formulas used for GJI paper
+                 !norm_bulk_2   = sum( kbulk_smooth**2 * da_local )
+                 !norm_beta_2   = sum( kbeta_smooth**2 * da_local )
+                 !norm_source_2 = sum( ( source_gradient(:) * m_scale_src_all(:) )**2 )
+
+                 ! NORM-SQUARED of the steepest ascent vector : sqrt( ghat C ghat )
+                 norm_bulk_2   = sum( kbulk_smooth(:,:,:)**2 * da_local(:,:,:) * (m_scale_str(1))**2 * AREA )
+                 norm_beta_2   = sum(  kbeta_smooth(:,:,:)**2 * da_local(:,:,:) * (m_scale_str(2))**2 * AREA )
+                 norm_source_2 = sum( ( source_gradient(:) * m_scale_src_all(:) )**2 * dnparm_src_run )   ! m_scale_src_all NOT ALLOCATED
+
+                 ! This shows the balance used in the GJI-2007 paper
+                 scale_struct_gji = sqrt( norm_source_2 / (norm_bulk_2 + norm_beta_2) )
+
+                 !scale_struct = scale_struct_gji
+                 scale_struct = 1.0
+
+                 write(*,*) 'Scaling for joint inversions:'
+                 write(*,'(a24,1e14.4)') ' norm_bulk            : ', sqrt( norm_bulk_2 )
+                 write(*,'(a24,1e14.4)') ' norm_beta            : ', sqrt( norm_beta_2 )
+                 write(*,'(a24,1e14.4)') ' norm_source          : ', sqrt( norm_source_2 )
+                 write(*,'(a24,1e14.4)') ' scale_struct_gji (F) : ', scale_struct_gji
+                 write(*,'(a24,1e14.4)') ' scale_struct (F)     : ', scale_struct
+
+                 open(unit=19,file=trim(out_dir1)//'scaling_values.dat',status='unknown')
+                 write(19,*) 'GJI_PAPER = ', GJI_PAPER
+                 write(19,*) 'IRUNZ = ', IRUNZ
+                 write(19,'(6i14)') 1, NLOCAL, NLOCAL+1, nmod_str, nmod_str+1, nmod
+                 write(19,'(2i14)') nparm_src_run, NLOCAL
+                 write(19,'(5e14.6)') sum(da_local(:,:,:)), sum(da_local_vec(:)), sum(da_global(:)), LENGTH*HEIGHT, AREA
+                 write(19,'(3e14.6)') minval(da_local_vec(:)), maxval(da_local_vec(:)), sum(da_local_vec(:))/NLOCAL
+                 write(19,'(3e14.6)') minval(da_global(:)), maxval(da_global(:)), sum(da_global(:))/NGLOB
+                 write(19,'(a20,2e14.6)') 'cov_str_fac : ', cov_str_fac, cov_str_fac**2
+                 write(19,'(a20,2e14.6)') 'cov_src_fac : ', cov_src_fac, cov_src_fac**2
+                 write(19,*) 'SIGMA VALUES :'
+                 write(19,'(5e14.6)') m_scale_str(1), m_scale_str(2), m_scale_src(1), m_scale_src(2), m_scale_src(3)
+                 write(19,'(5e14.6)') (m_scale_str(1))**2, (m_scale_str(2))**2, &
+                      (m_scale_src(1))**2, (m_scale_src(2))**2, (m_scale_src(3))**2
+                 write(19,'(5e14.6)') sigma_bulk, sigma_beta, sigma_xs, sigma_zs, sigma_ts
+                 write(19,'(5e14.6)') (sigma_bulk)**2, (sigma_beta)**2, (sigma_xs)**2, (sigma_zs)**2, (sigma_ts)**2
+                 write(19,'(a20,4e14.6)') 'scale_struct : ', scale_struct, scale_struct**2, 1.0/scale_struct, (1.0/scale_struct)**2
+                 write(19,'(a20,4e14.6)') 'scale_struct_gji : ', scale_struct_gji , scale_struct_gji **2, &
+                      1.0/scale_struct_gji , (1.0/scale_struct_gji )**2
+                 close(19)
+              endif
+
+           endif  ! itest==0 .or. POLY_ORDER==3
+
+           !====================
+           ! CG algorithm: update search direction and model
+           !
+           ! For details, see Tarantola (2005), Section 6.22
+           ! HAT variables: g0, gk, gt
+           ! NON-HAT variables: p0, pk, m0, mt
+
+           print *, ' Entering CG algorithm to compute new model or test model'
+
+           if(itest==0) then      ! if the present kernel is for a REAL model
+
+              chi_k_val = chi_val
+              gk(:) = gradient(:)
+
+              !-----------------------------------------
+
+              ! update the current search direction p0 (p0 and pk are NON-hat)
+              if(istep == 0) then
+                 beta_val = 0.0
+              else
+                 beta_val = sum((gk(:) - g0(:)) * (cov_imetric(:)*gk(:)) ) / sum(g0(:) * (cov_imetric(:)*g0(:)) )
+              endif
+              pk(:) = -cov_imetric(:) * gk(:) + beta_val * p0(:)
+
+              ! KEY: test value for line-search to get test model
+              ! You must be careful to define the metric for the dot product operation.
+              ! Here, we use a diagonal covariance matrix; for a full covariance matrix,
+              ! the operation would be : g_k C^kl p_l 
+
+              ! The minimum of the test-model parameter should go through 0.5, which
+              ! is the misfit if all the data are fit within the uncertainties specified by
+              ! the data covariance matrix.
+              mu_val = chi_data_stop
+              !mu_val = 0.0
+
+              lam_t_val = 2.0*(mu_val - chi_k_val) / sum( gk(:) * pk(:) )   ! ghat dot p
+
+              ! alternative approach (more ad hoc)
+              !lam_t_val = -2.0*(1.0 - mu_val)*chi_k_val  / sum( gk(:) * pk(:) )
+
+              !lam_t_val = -2.0*chi_k_val / dot_product(gk, pk)      ! GJI paper
+              !istep_switch = 6
+              !if(istep < istep_switch)  lam_t_val = -2.0*chi_k_val / dot_product(gk, pk)    ! quadratic extrapolation
+              !if(istep >= istep_switch) lam_t_val =    -chi_k_val / dot_product(gk, pk)    ! linear extrapolation
+
+              ! compute test model
+              mt(:)  = m0(:) + lam_t_val * pk(:)
+              itest  = 1
+
+!!$           ! Re-set the source parameters for the events NOT being run to the initial values.
+!!$           ! Otherwise, you will perturb all 25 events, even though they are not being run,
+!!$           ! and this will affect the computation of the model norm.
+!!$           do i = 1,nevent
+!!$              itemp1 = nmod_str + (i-1)*3 + 1
+!!$              itemp2 = nmod_str + (i-1)*3 + 2
+!!$              itemp3 = nmod_str + (i-1)*3 + 3
+!!$              if( i < ievent_min .or. i > ievent_max ) then
+!!$                 mt(itemp1) = 0.0
+!!$                 mt(itemp2) = 0.0
+!!$                 mt(itemp3) = 0.0
+!!$              endif
+!!$           enddo
+
+              ! STRUCTURE PARAMETERS (bulk, then beta)
+              if(INV_STRUCT == 0) then
+                 mt_vec(1 : nmod_str) = m0_vec_initial(1 : nmod_str)     ! initial structure
+              else
+                 mt_vec(1 : NLOCAL)          = bulk0 * exp( mt(1 : NLOCAL) )
+                 mt_vec(NLOCAL+1 : nmod_str) =  beta0 * exp( mt(NLOCAL+1 : nmod_str) )
+              endif
+
+              ! SOURCE PARAMETERS
+              if(INV_SOURCE_T == 0 .and. INV_SOURCE_X == 0) then
+                 mt_vec(nmod_str+1 : nmod) = m0_vec_initial(nmod_str+1 : nmod)     ! initial source
+              else
+                 mt_vec(nmod_str+1 : nmod) = mt(nmod_str+1 : nmod) + m0_vec_initial(nmod_str+1 : nmod)
+              endif
+
+              print *, 'lam_t_val = ', sngl(lam_t_val)
+
+              ! save vectors for next iteration
+              g0(:) = gk(:)    ! gradient
+              p0(:) = pk(:)    ! search direction vector
+
+           elseif(itest==1) then  ! if present kernel is for a test model
+
+              chi_t_val = chi_val
+
+              ! a cubic or quadratic fit requires at least 5 values
+              xx1 = 0.0
+              xx2 = lam_t_val
+              yy1 = chi_k_val
+              yy2 = chi_t_val
+              g1  = sum(g0(:) * pk(:))
+              !g1  = dot_product(g0, pk)              ! GJI paper 
+
+              if(POLY_ORDER == 3) then
+                 ! use cubic polynomial: six values gives an analytical minimum
+                 ! see Matlab scripts cubic_min_4.m and cubic_min.m
+
+                 ! compute gradient of test function (needed for cubic polynomial)
+                 gt(:) = gradient(:)
+
+                 g2 = sum(gt(:) * pk(:))
+                 !g2 = dot_product(gt,pk)              ! GJI paper
+
+                 ! coefficients of the cubic polynomial
+                 Pa = ( -2.0*(yy2-yy1) + (g1+g2)*(xx2-xx1) ) / (xx2-xx1)**3
+                 Pb = ( 3.0*(yy2-yy1) - (2.0*g1 + g2)*(xx2-xx1) ) / (xx2-xx1)**2
+                 Pc = g1
+                 Pd = yy1
+
+                 ! get the analytical minimum
+                 qfac = Pb**2.0 - 3.0*Pa*Pc
+                 if(Pa /= 0.0 .and. qfac >= 0.0) then
+                    xmin = (-Pb + sqrt(qfac)) / (3.0*Pa)
+                 elseif(Pa == 0.0 .and. Pb /= 0.0) then
+                    xmin = -Pc/(2.0*Pb)
+                 else
+                    print *, 'Pa, Pb, Pc, Pd, qfac: ',Pa,Pb,Pc,Pd,qfac
+                    print *, 'xmin: ',xmin
+                    stop 'check the cubic input polynomial'
+                 endif
+
+                 ! write cubic function parameters to file
+                 open(unit=19,file=trim(out_dir1)//'cubic_poly.dat',status='unknown')
+                 write(19,'(11e16.6)') xx1,xx2,yy1,yy2,g1,g2,Pa,Pb,Pc,Pd,xmin
+                 close(19)
+
+              else
+                 ! use quadratic polynomial: five values gives an analytical minimum
+                 ! see Matlab script quad_min_4.m
+
+                 ! coefficients of the quadratic polynomial (ax^2 + bx + c)
+                 Pa = ((yy2 - yy1) - g1*(xx2 - xx1)) / (xx2**2 - xx1**2)
+                 Pb = g1
+                 Pc = yy1 - Pa*xx1**2 - Pb*xx1
+
+                 ! get the analytical minimum (the vertex)
+                 if(Pa /= 0.0) then
+                    xmin = -Pb / (2.0*Pa)
+                 else
+                    print *, 'Pa, Pb, Pc: ',Pa,Pb,Pc
+                    print *, 'xmin: ',xmin
+                    stop 'check the quadratic input polynomial'
+                 endif
+
+                 ! write quadratic function parameters to file
+                 open(unit=19,file=trim(out_dir1)//'quad_poly.dat',status='unknown')
+                 write(19,'(9e16.6)') xx1,xx2,yy1,yy2,g1,Pa,Pb,Pc,xmin
+                 close(19)
+
+              endif  ! POLY_ORDER == 3
+
+              ! compute updated model
+              lam_0_val = xmin
+              m0(:) = m0(:) + lam_0_val * pk(:)
+              itest = 0
+
+!!$           ! Re-set the source parameters for the events NOT being run to the initial values.
+!!$           ! Otherwise, you will perturb all 25 events, even though they are not being run,
+!!$           ! and this will affect the computation of the model norm.
+!!$           do i = 1,nevent
+!!$              itemp1 = nmod_str + (i-1)*3 + 1
+!!$              itemp2 = nmod_str + (i-1)*3 + 2
+!!$              itemp3 = nmod_str + (i-1)*3 + 3
+!!$              if( i < ievent_min .or. i > ievent_max ) then
+!!$                 m0(itemp1) = 0.0
+!!$                 m0(itemp2) = 0.0
+!!$                 m0(itemp3) = 0.0
+!!$              endif
+!!$           enddo
+
+              ! STRUCTURE PARAMETERS
+              if(INV_STRUCT == 0) then
+                 m0_vec(1 : nmod_str) = m0_vec_initial(1 : nmod_str)   ! initial structure
+              else
+                 m0_vec(1 : NLOCAL)          = bulk0 * exp( m0(1 : NLOCAL) )
+                 m0_vec(NLOCAL+1 : nmod_str) = beta0 * exp( m0(NLOCAL+1 : nmod_str) )
+              endif
+
+              ! SOURCE PARAMETERS
+              if(INV_SOURCE_T == 0 .and. INV_SOURCE_X == 0) then
+                 m0_vec(nmod_str+1 : nmod) = m0_vec_initial(nmod_str+1 : nmod)      ! initial source
+              else
+                 m0_vec(nmod_str+1 : nmod) = m0(nmod_str+1 : nmod) + m0_vec_initial(nmod_str+1 : nmod)
+              endif
+
+              print *, 'lam_0_val = ', sngl(lam_0_val)
+
+           endif
+
+           !====================
+           ! write updated/test model to file (source + structure)
+
+           ! write CG vectors to file
+           if(1==1) then
+              open(unit=19,file=trim(out_dir1)//'cg_model_vectors.dat',status='unknown')
+              do i = 1,nmod
+                 write(19,'(4e16.6)') m0(i), mt(i),  m0_vec(i), mt_vec(i)
+              enddo
+              close(19)
+           endif
+           if(1==1) then
+              open(unit=19,file=trim(out_dir1)//'cg_grad_vectors.dat',status='unknown')
+              do i = 1,nmod
+                 write(19,'(5e16.6)') g0(i), gt(i), gk(i), p0(i), pk(i)
+              enddo
+              close(19)
+           endif
+
+           ! NOTE: if the structure parameters are unrealistic, then we will exit
+           ! the program before the NEXT wave simulation. This way, we at least write
+           ! the unrealistic model to file.
+
+           !====================
+
+           ! stop CG algorithm (search stop_cg)
+           if( stop_cg ) then
+              stop ' convergence criteria is met.'
+           endif
+
+           !call system("xv model.jpg &")
+
+        endif   ! COMPUTE_KERNELS
+
+        print *, ' Done with LOOP 2 iteration -- on to next model.'
+
+        !==================================
+     enddo  ! LOOP 2 (istep, models)
+     !==================================
+
+     print *, ' Done with LOOP 2.'
+
+     if(ISOURCE_LOG) close(91)  ! source log file
+
+     ! deallocate event and receiver variables
+     if(ISURFACE==1) deallocate(fglob)
+
+     deallocate(rglob)
+     deallocate(ispec_rec,xi_rec,gamma_rec)
+     deallocate(x_rec,z_rec)
+     deallocate(hxir_store, hgammar_store)
+     if(ISURFACE==1) deallocate(x_rec_lon,z_rec_lat)
+
+     deallocate(eglob_syn)
+     deallocate(ispec_eve_syn,xi_eve_syn,gamma_eve_syn)
+     deallocate(x_eve_syn,z_eve_syn)
+     deallocate(hxie_store,hgammae_store)
+     if(ISURFACE==1) deallocate(x_eve_lon_syn,z_eve_lat_syn)
+
+     deallocate(eglob_dat)
+     deallocate(ispec_eve_dat,xi_eve_dat,gamma_eve_dat)
+     deallocate(x_eve_dat,z_eve_dat)
+     deallocate(hxied_store, hgammaed_store)
+     if(ISURFACE==1) deallocate(x_eve_lon_dat,z_eve_lat_dat)
+
+     deallocate(otime_syn,otime_dat)
+
+     ! conjugate-gradient variables
+     deallocate(m0,mt,mdiff,mtarget) ! m0_prior
+     deallocate(cov_imetric,icov_metric,cov_model,icov_model)
+     deallocate(gradient,gradient_data,gradient_model)
+     deallocate(gradient_data_all)
+     deallocate(g0,gt,gk,p0,pk)
+     deallocate(source_gradient)
+     deallocate(m0_vec,mt_vec,m0_vec_initial)
+     deallocate(m_src_syn_vec,m_src_syn,m_src_syn_vec_initial,m_src_syn_initial)
+     deallocate(m_src_dat_vec,m_src_dat)
+     !deallocate(m_scale_src_all)
+ 
+     deallocate(cov_data,index_data,index_source)
+     if(ADD_DATA_ERRORS) deallocate(measure_pert_vec)
+
+     ! print output
+     print *
+     print *, ' max time-step is ', NSTEP
+     print *, '  time-step DT is ', sngl(DT)
+     print *, '      max time is ', sngl(dble(NSTEP)*DT), ' s,', sngl(dble(NSTEP)*DT/60.0), ' min'
+     print *, ' space-step dh is ', sngl(dh)
+     print *
+     print *, '         beta0 is ', sngl(beta0)
+     print *, '         bulk0 is ', sngl(bulk0)
+     print *, '        alpha0 is ', sngl(alpha0)
+     print *, '          hdur is ', sngl(hdur)
+     print *, '    time shift is ', sngl(tshift)
+     print *
+     print *, '         NGLOB ', NGLOB
+     print *, '        NLOCAL ', NLOCAL
+     print *, '          nmod ', nmod
+     print *, '      nmod_str ', nmod_str
+     print *, '      nmod_src ', nmod_src
+     print *
+
+  enddo  ! LOOP 1 (iq, tests)
+
+end program wave2d
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_cmap.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_cmap.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_cmap.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,368 @@
+program wave2d_cmap
+
+  use wave2d_variables
+  use wave2d_solver
+  use wave2d_sub
+  use wave2d_sub2
+  implicit none
+
+! wavefields and seismograms
+  double precision, dimension(:,:,:), allocatable :: samp, data, syn, adj_syn
+
+! socal coast and shelf data
+  integer :: UTM_PROJECTION_ZONE, FINITE_SOURCE
+  integer :: nshelf,ncoast,itemp
+  double precision :: d,dmin
+  double precision, dimension(:), allocatable :: shelf_lat,shelf_lon,shelf_z,shelf_x
+  double precision, dimension(:), allocatable :: coast_lat,coast_lon,coast_z,coast_x
+  character(len=200) :: shelf_file,coast_file
+
+! model variables
+  integer :: Nfac
+  double precision :: w_scale, afac
+
+! additional velocity models
+  double precision, dimension(NGLOB) :: c_glob_dat, c_glob_syn, m0, m0_vel
+
+! regular mesh for computing phase velocity
+!  integer :: ntemp, i_regular
+!  double precision, dimension(:), allocatable :: x9,z9,x_lon9,z_lat9,da9
+!  double precision, dimension(:), allocatable :: c_glob_dat9, c_glob_syn9, c_glob9
+!  double precision :: fac
+
+  double precision :: xtemp,ztemp,dx,dz,xmesh,zmesh
+  double precision :: t_target, tcen
+  double precision :: junk1,junk2,junk3
+
+  double precision :: temp1,temp2,temp3,temp4
+
+! smoothing
+  integer :: igaus
+  double precision :: dist2, dtrsh2, xtar, ztar, xcen, zcen
+  double precision, dimension(NGLOB) :: k_rough_global, k_smooth_global
+  double precision, dimension(NGLOB) :: k_gaus_global, k_gaus_global_ex, k_gaus_int_global, da
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: k_temp
+  !double precision, dimension(NLOCAL) :: gk_local, m0_local, mt_local, mt2_local, da_local
+  !integer, dimension(NLOCAL) :: ibool2
+  character(len=200) :: file_smooth
+
+  character(len=20)  :: data_tag,syn_tag,stf_tag,stfadj_tag
+  character(len=200) :: srcfile,recfile,socal_map
+  character(len=200) :: socal_dir, model_dir, script_dir, out_dir2, out_dir1, ev_dir
+  character(len=200) :: filename, filename1, filename2, file_dat_c, file_syn_c, file_src_rec, file_stf
+
+  integer :: i, j, k, itime, iglob, irec, isrc, ipick, ievent, icomp
+  integer :: isolver, irun0, irun, idat, iopt, ispec, istep
+
+  !********* PROGRAM STARTS HERE *********************
+ 
+  irun0 = 420
+
+  !out_dir2   = "OUTPUT/"
+  in_dir     = "INPUT/"
+  script_dir = "scripts/"
+
+  socal_dir = '/home/carltape/socal_modes/local_modes/'
+  model_dir = 'model_files/'
+
+  UTM_PROJECTION_ZONE = 11
+
+!--------------------------------------
+
+  print *
+  print *, ' max time-step is ', NSTEP
+  print *, '            DT is ', sngl(DT)
+  print *, '      max time is ', sngl(NSTEP*DT), ' s,', sngl(NSTEP*DT/60), ' min'
+  print *
+
+!--------------------------------------
+! mesher
+
+  ! set up model (gets Jacobian)
+  call mesher()
+
+  ! da vector
+  da(:) = 0.
+  do ispec = 1,NSPEC
+    do j = 1,NGLLZ
+      do i = 1,NGLLX 
+        iglob     = ibool(i,j,ispec)
+        da(iglob) = da(iglob) + wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+      enddo
+    enddo
+  enddo
+
+  print *
+  write(*,'(a,2f20.10)') '     da(min/max) : ', minval(da), maxval(da)
+  write(*,*)             '      sum [ da ] : ', sum(da)
+  write(*,*)             ' LENGTH * HEIGHT : ', LENGTH * HEIGHT
+  print *
+  write(*,*)             '           SIGMA : ', SIGMA
+  write(*,*)             '           irun0 : ', irun0
+  write(*,*)             '            IKER : ', IKER
+  print *
+  print *, ' GLL weights:'
+  do i=1,NGLLX
+     print *, wxgll(i)
+  enddo
+  do i=1,NGLLZ
+     print *, wzgll(i)
+  enddo
+
+  ! determine the UTM coordinates of your origin
+  print *
+  print *, 'UTM check for origin of mesh:'
+  print *, LON_MIN,LAT_MIN
+  call utm_geo(LON_MIN,LAT_MIN,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+  print *, utm_xmin, utm_zmin
+  call utm_geo(xtemp,ztemp,utm_xmin,utm_zmin,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+  print *, xtemp,ztemp   ! should match LON_MIN,LAT_MIN
+  print *
+
+!!$  ! regular mesh or SPECFEM mesh
+!!$  i_regular = 0
+!!$
+!!$  if(i_regular==1) then
+!!$
+!!$     ! enter new uniform mesh
+!!$     dx = 40.0d+03
+!!$     dz = dx
+!!$     fac = 10.0d+03
+!!$     k = 0
+!!$     do xtemp = -fac,LENGTH+fac,dx
+!!$        do ztemp = -fac,HEIGHT+fac,dz
+!!$           k = k+1
+!!$        enddo
+!!$     enddo
+!!$     ntemp = k
+!!$
+!!$  else
+!!$     ntemp = NGLOB
+!!$  endif
+!!$
+!!$  allocate(x9(ntemp),z9(ntemp),x_lon9(ntemp),z_lat9(ntemp))
+!!$  allocate(c_glob9(ntemp),c_glob_syn9(ntemp),c_glob_dat9(ntemp))
+!!$  allocate(da9(ntemp))
+!!$
+!!$  if(i_regular==1) then
+!!$
+!!$     k = 0
+!!$     do xtemp = -fac,LENGTH+fac,dx
+!!$        do ztemp = -fac,HEIGHT+fac,dz
+!!$     !do i=utm_xmin-fac,utm_xmin+LENGTH+fac,dx
+!!$     !   do j=utm_zmin-fac,utm_zmin+HEIGHT+fac,dz
+!!$           k = k+1
+!!$           x9(k) = xtemp
+!!$           z9(k) = ztemp
+!!$        enddo
+!!$     enddo
+!!$
+!!$     da9(:) = LENGTH*HEIGHT/ntemp
+!!$
+!!$  else
+!!$     x9(:) = x(:)
+!!$     z9(:) = z(:)
+!!$     da9(:) = da(:)
+!!$  endif
+
+  print *, NGLOB, ' gridpoints for which we compute a phase velocity'
+  print *, 'x-range is: ', minval(x), maxval(x)
+  print *, 'z-range is: ', minval(z), maxval(z)
+
+  !stop 'testing'
+
+  ! convert global gridpoint mesh coordinates to lat-lon
+  x_lon(:) = 0.
+  z_lat(:) = 0. 
+  call mesh_geo(NGLOB,x_lon,z_lat,x,z,UTM_PROJECTION_ZONE,IMESH2LONLAT)
+  !write(*,'(2f16.6)') (x_lon(iglob), z_lat(iglob), iglob=1,NGLOB)
+
+  !stop 'testing'
+
+!--------------------------------------
+! phase velocity model
+
+  t_target = 2*hdur     ! target period for phase velocity map
+
+     ! write lat-lon gridpoints to file
+     filename = trim(socal_dir) // 'socal_input.dat'
+     print *, 'Output data file is ',trim(filename)
+     open(unit=15,file=filename,status='unknown')
+     write(15,*) t_target
+     write(15,*) 0
+     write(15,*) UTM_PROJECTION_ZONE
+     write(15,*) NGLOB
+     write(15,*) (x_lon(iglob),z_lat(iglob),iglob=1,NGLOB)
+     close(15)
+
+     ! run wave2d_socal.f90 to create output file
+     ! KEY NOTE: must run this each time you change the grid, hdur, or IMODEL
+     call system(trim(model_dir) // 'get_socal_map.csh')
+
+     ! read in phase velocity map
+     !write(infile,'(a,a,i4.4,a)') trim(socal_dir), 'socal_T', int(100*t_target),'.dat'
+     socal_map = 'socaltest.dat'
+     open(unit=16, file = trim(model_dir)//socal_map, status='unknown')
+     read(16,*) (junk1,junk2,c_glob(iglob),junk3,iglob=1,NGLOB)
+     close(16)
+
+     ! read in reference phase velocity (km/s)
+     filename = trim(model_dir) // 'socaltest2.dat'
+     open(unit=17,file=filename,status='unknown')
+     read(17,*) c0
+     close(17)
+     
+     ! convert km/s --> m/s
+     c_glob(:) = 1000.*c_glob(:)
+     c0 = c0*1000.
+
+     c_glob_syn(:) = c0       ! c-maps for synthetics
+
+  !============================================
+  ! smooth the Gaussian according to SIGMA
+
+  k_rough_global(:) = c_glob(:)/c0 - 1.
+
+  ! Gaussian half-width controlling the smoothing (m)
+  dtrsh2 = (3.*SIGMA)**2  ! all points outside d^2 are set to zero
+
+  ! EXAMPLE gaussian smoothing function for one point
+  ! find the closest gridpoint to the target point
+  xtar = 0.7*LENGTH
+  ztar = 0.5*HEIGHT
+  dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+  do iglob = 1,NGLOB
+    d = sqrt((xtar-x(iglob))**2+(ztar-z(iglob))**2)
+    if(d < dmin) then
+       igaus = iglob
+       dmin = d
+    endif
+  enddo
+  xcen = x(igaus)
+  zcen = z(igaus)
+  k_gaus_global_ex(:) = 0.
+  do iglob = 1,NGLOB
+     dist2 = (xcen - x(iglob))**2 + (zcen - z(iglob))**2
+     if(dist2 <= dtrsh2) &
+        k_gaus_global_ex(iglob) = (1./(2*PI*SIGMA**2)) * exp(-dist2 / (2.*SIGMA**2))
+  enddo
+
+  ! compute the SMOOTHED kernel
+  k_smooth_global(:) = 0.
+  k_gaus_int_global(:) = 0.
+  do iglob = 1,NGLOB
+     ! compute a Gaussian centered at the iglob point
+     xcen = x(iglob)
+     zcen = z(iglob)
+     k_gaus_global(:) = 0.
+     do i = 1,NGLOB
+        dist2 = (xcen - x(i))**2 + (zcen - z(i))**2
+        if(dist2 <= dtrsh2) &
+           k_gaus_global(i) = (1./(2.*PI*SIGMA**2)) * exp(-dist2 / (2.*SIGMA**2))
+     enddo
+
+     ! integrate the Gaussian over the grid
+     ! (this will be constant only for the interior Gaussians)
+     k_temp(:,:,:) = 0.
+     do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+         do i = 1,NGLLX 
+           itemp = ibool(i,j,ispec)
+           k_temp(i,j,ispec) = k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+         enddo
+       enddo
+     enddo
+     k_gaus_int_global(iglob) = sum( k_temp(:,:,:) )
+
+
+     ! compute the product of the Gaussian and the rough function, then sum
+     k_temp(:,:,:) = 0.
+     do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+         do i = 1,NGLLX 
+           itemp = ibool(i,j,ispec)
+           k_temp(i,j,ispec) = k_rough_global(itemp) * k_gaus_global(itemp) * wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+         enddo
+       enddo
+     enddo
+     k_smooth_global(iglob) = sum( k_temp(:,:,:) ) / k_gaus_int_global(iglob)
+  enddo
+
+  do i=1,NGLOB
+     print *, k_gaus_int_global(i)
+  enddo
+
+  !============================================
+  
+  !k_smooth_global(:) = c_glob(:)
+
+  ! c-maps for data
+  c_glob_dat(:) = c0*(1. + k_smooth_global(:) )
+
+  ! write data phase velocity map to file
+  file_dat_c = 'socal_vel_dat.dat'
+  open(unit=18,file=file_dat_c,status='unknown')
+  do iglob = 1,NGLOB
+     write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_dat(iglob)), sngl(c_glob_dat(iglob)/c0 - 1.)
+  enddo
+  close(18)
+
+  ! write syn phase velocity map to file
+  ! (reference model is 0% perturbation)
+  file_syn_c = 'socal_vel_syn.dat'
+  open(unit=18,file=file_syn_c,status='unknown')
+  do iglob = 1,NGLOB
+     write(18,*) sngl(x_lon(iglob)), sngl(z_lat(iglob)), sngl(c_glob_syn(iglob)), sngl(c_glob_syn(iglob)/c0 - 1.)
+  enddo
+  close(18)
+
+  cmin = minval(c_glob)
+  cmax = maxval(c_glob)
+
+!!$  ! plot phase velocity map for synthetics (and data)
+!!$  iopt = 1 + idat
+!!$  filename1 = 'get_model.csh'
+!!$  filename2 = trim(script_dir)//'plot_model.pl'
+!!$  open(19,file=filename1,status='unknown')
+!!$  write(19,'(4a,i5,3a,2f12.6,2a)') trim(filename2),' ', trim(out_dir2),' ', &
+!!$     iopt, ' ', trim(file_syn_c), ' ', sngl(c0), sngl(t_target),' ',trim(file_dat_c)
+!!$  close(19)
+!!$  call system('chmod 755 get_model.csh ; get_model.csh')
+
+  ! write smooth-related functions to file
+  file_smooth = 'fun_smooth.dat'
+  open(unit=19,file=file_smooth,status='unknown')
+  do iglob = 1,NGLOB
+     write(19,'(6e16.6)') x(iglob), z(iglob), &
+        k_rough_global(iglob), k_gaus_global_ex(iglob), &
+        k_smooth_global(iglob), k_rough_global(iglob) - k_smooth_global(iglob)
+  enddo
+  close(19)
+
+  ! plot rough function, Gaussian filter, smooth function, and residual
+  filename1 = 'get_smooth.csh'
+  filename2 = trim(script_dir)//'plot_smoothed_function.pl'
+  open(19,file=filename1,status='unknown')
+  write(19,'(5a,1e16.6)') trim(filename2),' ', '.',' ',trim(file_smooth), SIGMA
+  close(19)
+  call system('chmod 755 get_smooth.csh ; get_smooth.csh')
+
+  ! assign model parameters to gridpoints
+  ihomo = 0
+  call set_model_property()
+
+  print *, 'Velocities in km/s :'
+  print *, '  S     :', sngl(sqrt(RIGIDITY/DENSITY)/1000.)
+  print *, '  cmin  :', sngl(cmin/1000.)
+  print *, '  c0    :', sngl(c0/1000.)
+  print *, '  cmax  :', sngl(cmax/1000.)
+  print *
+  print *, ' actual  rigidity (Pa-s)       : ', sngl(RIGIDITY)
+  print *, ' desired rigidity (Pa-s), cmin : ', sngl(DENSITY * cmin**2)
+  print *, ' desired rigidity (Pa-s), c0   : ', sngl(DENSITY * c0**2)
+  print *, ' desired rigidity (Pa-s), cmax : ', sngl(DENSITY * cmax**2)
+
+  !deallocate(x,z,x_lon,z_lat,c_glob,c_glob_syn,c_glob_dat)
+
+end program wave2d_cmap
+ 

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,336 @@
+module wave2d_constants
+
+! This file is copied into the output directory when wave2d.f90 is run
+! There are two basic options: membrane (surface) waves and body waves.
+! Several lines need to be commented/uncommented to go from one to the other.
+
+! index of the reference directory for the simulation output
+  integer, parameter :: IRUNZ = 100
+
+!========================
+! GRID, TIME-STEP, AND SOURCE PARAMETERS
+
+! NFRAME : number of frames to save: membrane, 10; body, 20
+! NSAVE  : timestep increment to save the wavefield: membrane, 400; body, 400
+! NSTEP  : number of timesteps
+  integer, parameter :: NFRAME = 10     ! membrane
+  !integer, parameter :: NFRAME = 11     ! body
+  integer, parameter :: NSAVE  = 400   ! 200,400
+  integer, parameter :: NSTEP  = NFRAME*NSAVE
+
+! time step in seconds
+  !double precision, parameter :: DT = 2.0d-02 ! body waves
+  double precision, parameter :: DT = 6.0d-02 ! membrane surface waves
+
+! temporal properties of source (source time function)
+  integer, parameter :: ISRC_TIME = 1                   ! type (1)
+  double precision, parameter :: hdur = 10.0d0            ! HALF-duration (s), membrane
+  !double precision, parameter :: hdur = 2.0d0            ! HALF-duration (s), body
+  double precision, parameter :: tshift = 2.0d0*DT*dble(NSAVE) ! time shift (s)
+  !double precision, parameter :: tshift = 8.0d0*hdur
+  logical, parameter :: SRC_TAPER  = .true.             ! taper the endpoints of the time series
+
+! normalization factor of point source force
+  double precision, parameter :: FNORM = 1.0d10
+
+! forward wavefield source-time function
+! (For membrane waves, FOR_Y = 1 is all that matters.)
+  integer, parameter :: FOR_X = 1       ! boolean
+  integer, parameter :: FOR_Y = 1       ! boolean
+  integer, parameter :: FOR_Z = 1       ! boolean
+
+! adjoint wavefield source-time function
+! (For membrane waves, REV_Y = 1 is all that matters.)
+!  integer, parameter :: IPSV  = 0       ! boolean: plot PSV or SH kernels
+  integer, parameter :: REV_X = 1       ! boolean
+  integer, parameter :: REV_Y = 1       ! boolean
+  integer, parameter :: REV_Z = 1       ! boolean
+
+! spatial properties of sources
+! BODY WAVE OPTIONS : (6) a point source EVENT (GJI paper)
+! SURFACE WAVE OPTIONS : (1) point source, (2) finite segment, (3) CA shelf boundary
+!                        (4) CA coast, (5) finite circle, (6) a point source EVENT (GJI paper)
+  integer, parameter :: ISRC_SPACE = 6 ! see wave2d.f90
+
+! spatial properties of receivers
+! IREC_SPACE
+!   (1) individual station(s)
+!   (2) SoCal (used for GJI paper)
+!   (3) regular mesh on land
+!   (4) regular mesh
+! NMESH_REC : determines the number of receivers in a regular mesh (IREC_SPACE > 3)
+! STATION_GRID_BUFFER : exclude stations within this distance from edge of grid
+! STATION_COAST_BUFFER : exclude stations within this distance from edge of coast
+  integer, parameter          :: IREC_SPACE = 2 ! see wave2d.f90
+  integer, parameter          :: NMESH_REC = 17
+  double precision, parameter :: SOURCE_GRID_BUFFER   =  4.0d+03  ! m    !  4km for membrane surface waves
+  double precision, parameter :: STATION_GRID_BUFFER  = 15.0d+03  ! m    ! 15km for membrane surface waves
+  double precision, parameter :: STATION_COAST_BUFFER =  0.0d+03  ! m
+
+! lower right corner for membrane surface waves plotting grid
+  double precision, parameter :: LAT_MIN = 32.0d0
+  double precision, parameter :: LON_MIN = -120.d0
+  integer, parameter :: UTM_PROJECTION_ZONE = 11     ! southern California
+
+! mesh specifications: membrane surface waves
+  double precision, parameter :: LENGTH = 480.0d+03 ! m
+  double precision, parameter :: HEIGHT = 480.0d+03 ! m
+  double precision, parameter :: AREA = LENGTH*HEIGHT  
+  integer, parameter :: NEX = 40
+  integer, parameter :: NEZ = 40
+!!$
+!!$! mesh specifications: body waves
+!!$  double precision, parameter :: LENGTH = 200.0d+03 ! m      ! 400 for 1D body waves
+!!$  double precision, parameter :: HEIGHT = 80.0d+03 ! m
+!!$  integer, parameter :: NEX = 80   ! 160
+!!$  integer, parameter :: NEZ = 32   ! 32
+
+!========================
+! MODEL SPECIFICATIONS (REFERENCE MODEL AND TARGET MODEL)
+
+! model perturbations for HOMOGENEOUS model (or perturbation)
+! scaling from beta to alpha
+! value is from Master et al. (2000), "The relative behavior of shear velocity..."
+  double precision, parameter :: R_BETA_OVER_ALPHA = 1.3d0
+  double precision, parameter :: PBETA  = 10.0d0
+  double precision, parameter :: PALPHA = PBETA / R_BETA_OVER_ALPHA
+  double precision, parameter :: PRHO   = 0.0d0
+
+  ! reference model and target model choice
+  integer, parameter :: IMODEL_SYN = 0
+  integer, parameter :: IMODEL_DAT = 2
+  !-----------------------------------------------------------------------------------------
+  !                               0           1                2              3          
+  !-----------------------------------------------------------------------------------------
+  ! ISURFACE=1, IMODEL_SYN : homo                         checker          het
+  ! ISURFACE=1, IMODEL_DAT : homo pert                    checker pert     het pert
+  !-----------------------------------------------------------------------------------------
+  ! ISURFACE=0, IMODEL_SYN : homo         1D model        checker          het        
+  ! ISURFACE=0, IMODEL_DAT : homo pert    1D model        checker pert     het pert  
+  !-----------------------------------------------------------------------------------------
+
+  ! whether you want to smooth the structure model for computing the synthetics
+  integer, parameter :: ISMOOTH_INITIAL_MODEL = 0
+  integer, parameter :: ISMOOTH_MODEL_UPDATE  = 0
+  integer, parameter :: ISMOOTH_EVENT_KERNEL  = 1
+  integer, parameter :: ISMOOTH_MISFIT_KERNEL = 1
+
+  ! smoothing scalelength
+  double precision, parameter :: GAMMA_SMOOTH_MODEL = 30.0d+03
+
+!========================
+
+! boolean parameters
+! IKER: (0) waveform
+!       (1) traveltime, cross-correlation, misfit
+!       (2) amplitude, cross-correlation, misfit
+!       (3) traveltime, multitaper
+!       (4) amplitude, multitaper
+!       (5) traveltime, cross-correlation, sampling -- NOT AN OPTION
+!       (6) amplitude, cross-correlation, sampling -- NOT AN OPTION
+  integer, parameter :: IKER = 1
+  integer, parameter :: IAMP_VEL = 0  ! measure amplitudes between velocity traces
+
+! KEY: USE ONE LINE OR THE OTHER
+  integer, parameter :: ISURFACE = 1, NCOMP = 1, NABSORB = 4   ! surface waves
+!  integer, parameter :: ISURFACE = 0, NCOMP = 3, NABSORB = 3   ! body waves
+
+! parameters controlling what to write to file
+! NOTE: for the tomography simulations, ALL of these can be .false.
+
+  logical, parameter :: WRITE_STF_F           = .false.
+  logical, parameter :: WRITE_SEISMO_F        = .false.
+!  logical, parameter :: WRITE_SPECTRA_F       = .false.
+!  logical, parameter :: WRITE_SPECTRAL_MAP_F  = .false.
+
+  logical, parameter :: WRITE_SEISMO_RECONSTRUCT = .false.  ! multitaper
+!  logical, parameter :: WRITE_MTM_FILES = .false.           ! multitaper
+
+  logical, parameter :: WRITE_STF_A           = .false.
+  logical, parameter :: WRITE_SEISMO_A        = .false.     ! source inversions
+!  logical, parameter :: WRITE_SPECTRA_A       = .false. 
+!  logical, parameter :: WRITE_SPECTRAL_MAP_A  = .false.
+
+  logical, parameter :: WRITE_KERNELS = .true.             ! write all nine kernels
+  logical, parameter :: WRITE_KERNEL_SNAPSHOTS = .false.    ! kernel snapshots
+  logical, parameter :: WRITE_WAVFIELD_SNAPSHOTS = .false.  ! wavefield snapshots
+  
+!--------------------------------------
+! INVERSION PARAMETERS
+
+  ! whether you want to compute kernels, or simply the misfit function
+  logical, parameter :: COMPUTE_KERNELS = .true.
+
+  ! whether to use the data subspace method, which has a Hessian
+  logical, parameter :: HESSIAN = .false.
+
+  ! stopping criteria
+  ! NITERATION  : number of iterations
+  ! VAR_RED_MIN : minimum variance reduction (in percent)
+  ! SIGMA_FAC   : stop if a model value exceeds SIGMA_FAC * sigma_m 
+  ! CONV_STOP   : stop when the misfit value is this fraction of the INITIAL misfit value
+  integer, parameter :: NITERATION = 16
+  double precision, parameter :: VAR_RED_MIN = 8.0d0
+
+  ! Gaussian errors containted in input file
+  ! see wave2d_sigmas.m and INPUT/sigma_0p1_pert.dat
+  double precision, parameter :: SIGMA_DT = 0.10d0
+  double precision, parameter :: SIGMA_DLNA = 1.0d0
+  double precision, parameter :: SIGMA_WAVEFORM = 1.0d0
+  logical, parameter :: ADD_DATA_ERRORS = .true.
+  
+  !double precision, parameter :: SIGMA_FAC = 2.0d0 
+  !double precision, parameter :: CONV_STOP = 1.0d-04
+
+  ! order of interpolating polynomial in conjugate gradient algorithm
+  ! using POLY_ORDER = 3 required computing the gradient of the test model
+  integer, parameter :: POLY_ORDER = 2      ! 2 (preferred) or 3
+
+  ! use inversion and scaling used for the GJI paper
+  !integer, parameter :: GJI_PAPER = 1
+
+  ! what to perturb, what to invert
+  integer, parameter :: PERT_STRUCT = 1
+  integer, parameter :: PERT_SOURCE_T = 0
+  integer, parameter :: PERT_SOURCE_X = 0
+
+  integer, parameter ::  INV_STRUCT = 1
+  integer, parameter ::  INV_SOURCE_T = 0
+  integer, parameter ::  INV_SOURCE_X = 0
+
+  ! whether to include the model norm term in the misfit function, which acts like damping
+  logical, parameter :: INCLUDE_MODEL_NORM = .true.  
+  
+  ! log file showing source loactions
+  logical, parameter :: ISOURCE_LOG = .true.
+  
+  ! DO NOT CHANGE THESE
+  integer, parameter :: NVAR_STRUCT = 2   ! alpha, beta (seismic velocities only)
+  integer, parameter :: NVAR_SOURCE = 3   ! x position, z position, origin time
+  integer, parameter :: NVAR = NVAR_STRUCT + NVAR_SOURCE
+
+! parameterization for structure in the inversion
+! 1 : kappa-mu-rho
+! 2 : alpha-beta-rho
+! 3 : c-beta-rho
+  integer, parameter :: STRUCTURE_PARAMETER_TYPE = 2
+
+! scalelength of smoothing Gaussian
+! GJI paper : 30,60,90
+! body waves : 10
+  double precision, parameter :: GAMMA_SMOOTH = 60.0d+03
+
+  ! parameters for smoothing
+  logical, parameter :: HIGH_RES_SMOOTHING = .true.  ! smooth at high resolution
+  logical, parameter :: EXAMPLE_GAUSSIAN = .false.   ! plot an example Gaussian
+
+! homogeneous background model (S.I. units)
+  double precision, parameter :: DENSITY           = 2.60d+03 ! kg/m^3
+  double precision, parameter :: INCOMPRESSIBILITY = 5.20d+10 ! Pa
+  double precision, parameter :: RIGIDITY          = 2.66d+10 ! Pa
+
+!---------------------------------------------------------------
+! measurement windows
+
+  double precision, parameter :: HWIN1 = 2.5d0*hdur   ! half-window width for pulse (2.5)
+  double precision, parameter :: HWIN2 = 5.0d0*hdur   ! half-window with for MTM measurement (zero-padding)
+
+!---------------------------------------------------------------
+! CHT: do not change these
+
+! UTM zone for Southern California region 
+!  integer, parameter :: UTM_PROJECTION_ZONE = 11
+
+! to suppress UTM projection for SCEC benchmarks
+  logical, parameter :: SUPPRESS_UTM_PROJECTION = .false.
+
+! flag for projection from latitude/longitude to UTM, and back
+  integer, parameter :: ILONGLAT2UTM = 0, IUTM2LONGLAT = 1
+
+! flag for projection from latitude/longitude to mesh-UTM, and back
+  integer, parameter :: ILONLAT2MESH = 0, IMESH2LONLAT = 1
+
+! max number of fake receivers
+  integer, parameter :: MAX_SR_FAKE = 1000
+
+! max number of events, receivers, and phass
+  integer, parameter :: MAX_EVENT = 50
+  integer, parameter :: MAX_SR    = 1400
+  integer, parameter :: MAX_PHASE = 1
+  integer, parameter :: MAX_COMP  = NCOMP
+
+!========================
+! GRID AND GLL POINTS
+
+  integer, parameter :: NELE = MAX(NEX,NEZ)
+  integer, parameter :: NSPEC = NEX*NEZ
+
+! number of GLL points (polynomial degree plus one)
+  integer, parameter :: NGLLX = 5
+  integer, parameter :: NGLLZ = 5
+  integer, parameter :: NGLL = MAX(NGLLX,NGLLZ)
+
+! number of global points
+  integer, parameter :: NGLLSQUARE = NGLLX * NGLLZ                       ! element GLL points
+  integer, parameter :: NGLOB = ((NGLLX-1)*NEX + 1)*((NGLLZ-1)*NEZ +1)   ! global GLL points
+  integer, parameter :: NLOCAL = NGLLX * NGLLZ * NSPEC                   ! local GLL points
+  integer, parameter :: NSPEC_CORNER = (NEX+1) * (NEZ+1)                 ! element corner points
+
+! number of nodes for 2D and 3D shape functions for hexahedra
+! we use 8-node mesh bricks, which are more stable than 27-node elements
+  integer, parameter :: NGNOD = 8, NGNOD2D = 4
+  
+! number of iterations to solve the system for xi and eta
+  integer, parameter :: NUM_ITER = 1
+
+! very large and very small values
+  double precision, parameter :: HUGEVAL = 1.0d+30, TINYVAL = 1.0d-9
+
+! for the Gauss-Lobatto-Legendre points and weights
+  double precision, parameter :: GAUSSALPHA = 0.0d0,GAUSSBETA = 0.0d0
+
+!
+! CONSTANTS
+!
+  double precision, parameter :: PI = 3.141592653589793d+00
+  double precision, parameter :: FOUR_THIRDS = 4.0d0 / 3.0d0
+  double precision, parameter :: ONE_THIRD = 1.0d0 / 3.0d0
+  double precision, parameter :: ONEOVERTWO = 0.5d0
+  double precision, parameter :: EPS = 1.0d-35
+  double precision, parameter :: DEG = 180.0/PI
+
+!!$! parameter for FFTW
+!!$  integer, parameter :: NOUT = NSTEP/2 + 1
+!!$
+!!$! bounds for bandpass filter
+!!$  double precision, parameter :: hwid = 3.0  ! HALF-width of window (s)
+!!$  double precision, parameter :: tmin = 2.0*hdur-hwid
+!!$  double precision, parameter :: tmax = 2.0*hdur+hwid
+!!$  double precision, parameter :: fmin = 1.0/tmax, fmax = 1.0/tmin
+!!$  double precision, parameter :: trbdndw = 0.3, a = 30.0
+!!$  integer, parameter :: passes = 2, iord = 4
+!!$
+!!$! 
+!!$! MULTI-TAPER PARAMETERS
+!!$!
+!!$! Ying Zhou: The fit between the recovered data and the data can be improved
+!!$! by either increasing the window width (HWIN above) or by decreasing NPI.
+!!$! In her experience, NPI = 2.5 is good for noisy data.
+!!$! For synthetic data, we can use a lower NPI.
+!!$! number of tapers should be fixed as twice NPI -- see Latex notes
+!!$  double precision, parameter :: WTR = 0.02
+!!$  double precision, parameter :: NPI = 2.5
+!!$  integer, parameter :: NTAPER = int(2.0*NPI)
+!!$
+!!$! FFT parameters
+!!$! FOR SOME REASON, I CANNOT SET NDIM = npt when lnpt <= 11 -- WHY NOT?
+!!$  integer, parameter :: lnpt = 13, npt = 2**lnpt, NDIM = 20000
+!!$  !integer, parameter :: lnpt = 14, npt = 2**lnpt, NDIM = npt
+!!$
+!!$  !double precision, parameter :: ZZIGN = -1.0   ! sign convention -- WATCH OUT
+!!$  double precision, parameter :: FORWARD_FFT = 1.0
+!!$  double precision, parameter :: REVERSE_FFT = -1.0
+
+  integer, parameter :: NDIM = 20000
+
+end module wave2d_constants

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants_gji2007.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants_gji2007.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_constants_gji2007.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,334 @@
+module wave2d_constants
+!
+! This file is copied into the output directory when wave2d.f90 is run
+! There are two basic options: membrane (surface) waves and body waves.
+! Several lines need to be commented/uncommented to go from one to the other.
+!
+
+!========================
+! GRID, TIME-STEP, AND SOURCE PARAMETERS
+
+! NFRAME : number of frames to save: membrane, 10; body, 20
+! NSAVE  : timestep increment to save the wavefield: membrane, 400; body, 400
+! NSTEP  : number of timesteps
+  integer, parameter :: NFRAME = 10     ! membrane
+  !integer, parameter :: NFRAME = 11     ! body
+  integer, parameter :: NSAVE  = 400   ! 200,400
+  integer, parameter :: NSTEP  = NFRAME*NSAVE
+
+! time step in seconds
+  !double precision, parameter :: DT = 2.0d-02 ! body waves
+  double precision, parameter :: DT = 6.0d-02 ! membrane surface waves
+
+! temporal properties of source (source time function)
+  integer, parameter :: ISRC_TIME = 1                   ! type (1)
+  double precision, parameter :: hdur = 10.0d0            ! HALF-duration (s), membrane
+  !double precision, parameter :: hdur = 2.0d0            ! HALF-duration (s), body
+  double precision, parameter :: tshift = 2.0d0*DT*dble(NSAVE) ! time shift (s)
+  !double precision, parameter :: tshift = 8.0d0*hdur
+  logical, parameter :: SRC_TAPER  = .true.             ! taper the endpoints of the time series
+
+! normalization factor of point source force
+  double precision, parameter :: FNORM = 1.0d10
+
+! forward wavefield source-time function
+! (For membrane waves, FOR_Y = 1 is all that matters.)
+  integer, parameter :: FOR_X = 1       ! boolean
+  integer, parameter :: FOR_Y = 1       ! boolean
+  integer, parameter :: FOR_Z = 1       ! boolean
+
+! adjoint wavefield source-time function
+! (For membrane waves, REV_Y = 1 is all that matters.)
+!  integer, parameter :: IPSV  = 0       ! boolean: plot PSV or SH kernels
+  integer, parameter :: REV_X = 1       ! boolean
+  integer, parameter :: REV_Y = 1       ! boolean
+  integer, parameter :: REV_Z = 1       ! boolean
+
+! spatial properties of sources
+! BODY WAVE OPTIONS : (6) a point source EVENT (GJI paper)
+! SURFACE WAVE OPTIONS : (1) point source, (2) finite segment, (3) CA shelf boundary
+!                        (4) CA coast, (5) finite circle, (6) a point source EVENT (GJI paper)
+  integer, parameter :: ISRC_SPACE = 6 ! see wave2d.f90
+
+! spatial properties of receivers
+! IREC_SPACE
+!   (1) individual station(s)
+!   (2) SoCal (used for GJI paper)
+!   (3) regular mesh on land
+!   (4) regular mesh
+! NMESH_REC : determines the number of receivers in a regular mesh (IREC_SPACE > 3)
+! STATION_GRID_BUFFER : exclude stations within this distance from edge of grid
+! STATION_COAST_BUFFER : exclude stations within this distance from edge of coast
+  integer, parameter          :: IREC_SPACE = 2 ! see wave2d.f90
+  integer, parameter          :: NMESH_REC = 17
+  double precision, parameter :: SOURCE_GRID_BUFFER   =  4.0d+03  ! m    !  4km for membrane surface waves
+  double precision, parameter :: STATION_GRID_BUFFER  = 15.0d+03  ! m    ! 15km for membrane surface waves
+  double precision, parameter :: STATION_COAST_BUFFER =  0.0d+03  ! m
+
+! lower right corner for membrane surface waves plotting grid
+  double precision, parameter :: LAT_MIN = 32.0d0
+  double precision, parameter :: LON_MIN = -120.d0
+  integer, parameter :: UTM_PROJECTION_ZONE = 11     ! southern California
+
+! mesh specifications: membrane surface waves
+  double precision, parameter :: LENGTH = 480.0d+03 ! m
+  double precision, parameter :: HEIGHT = 480.0d+03 ! m
+  double precision, parameter :: AREA = LENGTH*HEIGHT  
+  integer, parameter :: NEX = 40
+  integer, parameter :: NEZ = 40
+!!$
+!!$! mesh specifications: body waves
+!!$  double precision, parameter :: LENGTH = 200.0d+03 ! m      ! 400 for 1D body waves
+!!$  double precision, parameter :: HEIGHT = 80.0d+03 ! m
+!!$  integer, parameter :: NEX = 80   ! 160
+!!$  integer, parameter :: NEZ = 32   ! 32
+
+!========================
+! MODEL SPECIFICATIONS (REFERENCE MODEL AND TARGET MODEL)
+
+! model perturbations for HOMOGENEOUS model (or perturbation)
+! scaling from beta to alpha
+! value is from Master et al. (2000), "The relative behavior of shear velocity..."
+  double precision, parameter :: R_BETA_OVER_ALPHA = 1.3d0
+  double precision, parameter :: PBETA  = 10.0d0
+  double precision, parameter :: PALPHA = PBETA / R_BETA_OVER_ALPHA
+  double precision, parameter :: PRHO   = 0.0d0
+
+  ! reference model and target model choice
+  integer, parameter :: IMODEL_SYN = 0
+  integer, parameter :: IMODEL_DAT = 2
+  !-----------------------------------------------------------------------------------------
+  !                               0           1                2              3          
+  !-----------------------------------------------------------------------------------------
+  ! ISURFACE=1, IMODEL_SYN : homo                         checker          het
+  ! ISURFACE=1, IMODEL_DAT : homo pert                    checker pert     het pert
+  !-----------------------------------------------------------------------------------------
+  ! ISURFACE=0, IMODEL_SYN : homo         1D model        checker          het        
+  ! ISURFACE=0, IMODEL_DAT : homo pert    1D model        checker pert     het pert  
+  !-----------------------------------------------------------------------------------------
+
+  ! whether you want to smooth the structure model for computing the synthetics
+  integer, parameter :: ISMOOTH_INITIAL_MODEL = 0
+  integer, parameter :: ISMOOTH_MODEL_UPDATE  = 0
+  integer, parameter :: ISMOOTH_EVENT_KERNEL  = 1
+  integer, parameter :: ISMOOTH_MISFIT_KERNEL = 1
+
+  ! smoothing scalelength
+  double precision, parameter :: GAMMA_SMOOTH_MODEL = 30.0d+03
+
+!========================
+
+! boolean parameters
+! IKER: (0) waveform
+!       (1) traveltime, cross-correlation, misfit
+!       (2) amplitude, cross-correlation, misfit
+!       (3) traveltime, multitaper
+!       (4) amplitude, multitaper
+!       (5) traveltime, cross-correlation, sampling -- NOT AN OPTION
+!       (6) amplitude, cross-correlation, sampling -- NOT AN OPTION
+  integer, parameter :: IKER = 1
+  integer, parameter :: IAMP_VEL = 0  ! measure amplitudes between velocity traces
+
+! KEY: USE ONE LINE OR THE OTHER
+  integer, parameter :: ISURFACE = 1, NCOMP = 1, NABSORB = 4   ! surface waves
+!  integer, parameter :: ISURFACE = 0, NCOMP = 3, NABSORB = 3   ! body waves (grep DEBUG)
+
+! parameters controlling what to write to file
+! NOTE: for the tomography simulations, ALL of these can be .false.
+
+  logical, parameter :: WRITE_STF_F           = .false.
+  logical, parameter :: WRITE_SEISMO_F        = .false.
+!  logical, parameter :: WRITE_SPECTRA_F       = .false.
+!  logical, parameter :: WRITE_SPECTRAL_MAP_F  = .false.
+
+  logical, parameter :: WRITE_SEISMO_RECONSTRUCT = .false.  ! multitaper
+!  logical, parameter :: WRITE_MTM_FILES = .false.           ! multitaper
+
+  logical, parameter :: WRITE_STF_A           = .false.
+  logical, parameter :: WRITE_SEISMO_A        = .false.     ! source inversions
+!  logical, parameter :: WRITE_SPECTRA_A       = .false. 
+!  logical, parameter :: WRITE_SPECTRAL_MAP_A  = .false.
+
+  logical, parameter :: WRITE_KERNELS = .true.             ! write all nine kernels
+  logical, parameter :: WRITE_KERNEL_SNAPSHOTS = .false.    ! kernel snapshots
+  logical, parameter :: WRITE_WAVFIELD_SNAPSHOTS = .false.  ! wavefield snapshots
+  
+!--------------------------------------
+! INVERSION PARAMETERS
+
+  ! whether you want to compute kernels, or simply the misfit function
+  logical, parameter :: COMPUTE_KERNELS = .true.
+
+  ! whether to use the data subspace method, which has a Hessian
+  logical, parameter :: HESSIAN = .false.
+
+  ! stopping criteria
+  ! NITERATION  : number of iterations
+  ! VAR_RED_MIN : minimum variance reduction (in percent)
+  ! SIGMA_FAC   : stop if a model value exceeds SIGMA_FAC * sigma_m 
+  ! CONV_STOP   : stop when the misfit value is this fraction of the INITIAL misfit value
+  integer, parameter :: NITERATION = 16
+  double precision, parameter :: VAR_RED_MIN = 0.0d0
+
+  ! Gaussian errors containted in input file
+  ! see wave2d_sigmas.m and INPUT/sigma_0p1_pert.dat
+  double precision, parameter :: SIGMA_DT = 0.10d0
+  double precision, parameter :: SIGMA_DLNA = 1.0d0
+  double precision, parameter :: SIGMA_WAVEFORM = 1.0d0
+  logical, parameter :: ADD_DATA_ERRORS = .false.
+  
+  !double precision, parameter :: SIGMA_FAC = 2.0d0 
+  !double precision, parameter :: CONV_STOP = 1.0d-04
+
+  ! order of interpolating polynomial in conjugate gradient algorithm
+  ! using POLY_ORDER = 3 required computing the gradient of the test model
+  integer, parameter :: POLY_ORDER = 2      ! 2 (preferred) or 3
+
+  ! use inversion and scaling used for the GJI paper
+  !integer, parameter :: GJI_PAPER = 1
+
+  ! what to perturb, what to invert
+  integer, parameter :: PERT_STRUCT = 1
+  integer, parameter :: PERT_SOURCE_T = 0
+  integer, parameter :: PERT_SOURCE_X = 0
+
+  integer, parameter ::  INV_STRUCT = 1
+  integer, parameter ::  INV_SOURCE_T = 0
+  integer, parameter ::  INV_SOURCE_X = 0
+
+  ! whether to include the model norm term in the misfit function, which acts like damping
+  logical, parameter :: INCLUDE_MODEL_NORM = .false.  
+  
+  ! log file showing source loactions
+  logical, parameter :: ISOURCE_LOG = .true.
+  
+  ! DO NOT CHANGE THESE
+  integer, parameter :: NVAR_STRUCT = 2   ! alpha, beta (seismic velocities only)
+  integer, parameter :: NVAR_SOURCE = 3   ! x position, z position, origin time
+  integer, parameter :: NVAR = NVAR_STRUCT + NVAR_SOURCE
+
+! parameterization for structure in the inversion
+! 1 : kappa-mu-rho
+! 2 : alpha-beta-rho
+! 3 : c-beta-rho
+  integer, parameter :: STRUCTURE_PARAMETER_TYPE = 2
+
+! scalelength of smoothing Gaussian
+! GJI paper : 30,60,90
+! body waves : 10
+  double precision, parameter :: GAMMA_SMOOTH = 60.0d+03
+
+  ! parameters for smoothing
+  logical, parameter :: HIGH_RES_SMOOTHING = .true.  ! smooth at high resolution
+  logical, parameter :: EXAMPLE_GAUSSIAN = .false.   ! plot an example Gaussian
+
+! homogeneous background model (S.I. units)
+  double precision, parameter :: DENSITY           = 2.60d+03 ! kg/m^3
+  double precision, parameter :: INCOMPRESSIBILITY = 5.20d+10 ! Pa
+  double precision, parameter :: RIGIDITY          = 2.66d+10 ! Pa
+
+!---------------------------------------------------------------
+! measurement windows
+
+  double precision, parameter :: HWIN1 = 2.5d0*hdur   ! half-window width for pulse (2.5)
+  double precision, parameter :: HWIN2 = 5.0d0*hdur   ! half-window with for MTM measurement (zero-padding)
+
+!---------------------------------------------------------------
+! CHT: do not change these
+
+! UTM zone for Southern California region 
+!  integer, parameter :: UTM_PROJECTION_ZONE = 11
+
+! to suppress UTM projection for SCEC benchmarks
+  logical, parameter :: SUPPRESS_UTM_PROJECTION = .false.
+
+! flag for projection from latitude/longitude to UTM, and back
+  integer, parameter :: ILONGLAT2UTM = 0, IUTM2LONGLAT = 1
+
+! flag for projection from latitude/longitude to mesh-UTM, and back
+  integer, parameter :: ILONLAT2MESH = 0, IMESH2LONLAT = 1
+
+! max number of fake receivers
+  integer, parameter :: MAX_SR_FAKE = 1000
+
+! max number of events, receivers, and phass
+  integer, parameter :: MAX_EVENT = 50
+  integer, parameter :: MAX_SR    = 1400
+  integer, parameter :: MAX_PHASE = 1
+  integer, parameter :: MAX_COMP  = NCOMP
+
+!========================
+! GRID AND GLL POINTS
+
+  integer, parameter :: NELE = MAX(NEX,NEZ)
+  integer, parameter :: NSPEC = NEX*NEZ
+
+! number of GLL points (polynomial degree plus one)
+  integer, parameter :: NGLLX = 5
+  integer, parameter :: NGLLZ = 5
+  integer, parameter :: NGLL = MAX(NGLLX,NGLLZ)
+
+! number of global points
+  integer, parameter :: NGLLSQUARE = NGLLX * NGLLZ                       ! element GLL points
+  integer, parameter :: NGLOB = ((NGLLX-1)*NEX + 1)*((NGLLZ-1)*NEZ +1)   ! global GLL points
+  integer, parameter :: NLOCAL = NGLLX * NGLLZ * NSPEC                   ! local GLL points
+  integer, parameter :: NSPEC_CORNER = (NEX+1) * (NEZ+1)                 ! element corner points
+
+! number of nodes for 2D and 3D shape functions for hexahedra
+! we use 8-node mesh bricks, which are more stable than 27-node elements
+  integer, parameter :: NGNOD = 8, NGNOD2D = 4
+  
+! number of iterations to solve the system for xi and eta
+  integer, parameter :: NUM_ITER = 1
+
+! very large and very small values
+  double precision, parameter :: HUGEVAL = 1.0d+30, TINYVAL = 1.0d-9
+
+! for the Gauss-Lobatto-Legendre points and weights
+  double precision, parameter :: GAUSSALPHA = 0.0d0,GAUSSBETA = 0.0d0
+
+!
+! CONSTANTS
+!
+  double precision, parameter :: PI = 3.141592653589793d+00
+  double precision, parameter :: FOUR_THIRDS = 4.0d0 / 3.0d0
+  double precision, parameter :: ONE_THIRD = 1.0d0 / 3.0d0
+  double precision, parameter :: ONEOVERTWO = 0.5d0
+  double precision, parameter :: EPS = 1.0d-35
+  double precision, parameter :: DEG = 180.0/PI
+
+!!$! parameter for FFTW
+!!$  integer, parameter :: NOUT = NSTEP/2 + 1
+!!$
+!!$! bounds for bandpass filter
+!!$  double precision, parameter :: hwid = 3.0  ! HALF-width of window (s)
+!!$  double precision, parameter :: tmin = 2.0*hdur-hwid
+!!$  double precision, parameter :: tmax = 2.0*hdur+hwid
+!!$  double precision, parameter :: fmin = 1.0/tmax, fmax = 1.0/tmin
+!!$  double precision, parameter :: trbdndw = 0.3, a = 30.0
+!!$  integer, parameter :: passes = 2, iord = 4
+!!$
+!!$! 
+!!$! MULTI-TAPER PARAMETERS
+!!$!
+!!$! Ying Zhou: The fit between the recovered data and the data can be improved
+!!$! by either increasing the window width (HWIN above) or by decreasing NPI.
+!!$! In her experience, NPI = 2.5 is good for noisy data.
+!!$! For synthetic data, we can use a lower NPI.
+!!$! number of tapers should be fixed as twice NPI -- see Latex notes
+!!$  double precision, parameter :: WTR = 0.02
+!!$  double precision, parameter :: NPI = 2.5
+!!$  integer, parameter :: NTAPER = int(2.0*NPI)
+!!$
+!!$! FFT parameters
+!!$! FOR SOME REASON, I CANNOT SET NDIM = npt when lnpt <= 11 -- WHY NOT?
+!!$  integer, parameter :: lnpt = 13, npt = 2**lnpt, NDIM = 20000
+!!$  !integer, parameter :: lnpt = 14, npt = 2**lnpt, NDIM = npt
+!!$
+!!$  !double precision, parameter :: ZZIGN = -1.0   ! sign convention -- WATCH OUT
+!!$  double precision, parameter :: FORWARD_FFT = 1.0
+!!$  double precision, parameter :: REVERSE_FFT = -1.0
+
+  integer, parameter :: NDIM = 20000
+
+end module wave2d_constants

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_define_der_matrices.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_define_der_matrices.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_define_der_matrices.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,65 @@
+module wave2d_define_der_matrices
+
+  use wave2d_constants
+
+contains
+
+  subroutine define_derivative_matrices(xigll,zigll,wxgll,wzgll,hprime_xx,hprime_zz,wgllwgll_xz)
+
+  implicit none
+ 
+! Gauss-Lobatto-Legendre points of integration
+  double precision, dimension(NGLLX) :: xigll
+  double precision, dimension(NGLLZ) :: zigll
+
+! weights
+  double precision, dimension(NGLLX) :: wxgll
+  double precision, dimension(NGLLZ) :: wzgll
+
+! array with derivatives of Lagrange polynomials
+  double precision, dimension(NGLLX,NGLLX) :: hprime_xx
+  double precision, dimension(NGLLZ,NGLLZ) :: hprime_zz
+  double precision, dimension(NGLLX,NGLLZ) :: wgllwgll_xz
+
+! array with all the weights in the square
+  double precision, dimension(NGLLX,NGLLZ) :: wgll_square
+
+! function for calculating derivatives of Lagrange polynomials
+  double precision, external :: lagrange_deriv_GLL
+
+  integer i1,i2,k1,k2,i,k
+
+! $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+! set up coordinates of the Gauss-Lobatto-Legendre points
+  call zwgljd(xigll,wxgll,NGLLX,GAUSSALPHA,GAUSSBETA)
+  call zwgljd(zigll,wzgll,NGLLZ,GAUSSALPHA,GAUSSBETA)
+
+! if number of points is odd, the middle abscissa is exactly zero
+  if(mod(NGLLX,2) /= 0) xigll((NGLLX-1)/2+1) = 0.d0
+  if(mod(NGLLZ,2) /= 0) zigll((NGLLZ-1)/2+1) = 0.d0
+
+! calculate derivatives of the Lagrange polynomials
+! and precalculate some products in double precision
+! hprime(i,j) = h'_i(xigll_j) by definition of the derivative matrix
+  do i1=1,NGLLX
+    do i2=1,NGLLX
+      hprime_xx(i1,i2) = lagrange_deriv_GLL(i1-1,i2-1,xigll,NGLLX)
+    enddo
+  enddo
+
+  do k1=1,NGLLZ
+    do k2=1,NGLLZ
+      hprime_zz(k1,k2) = lagrange_deriv_GLL(k1-1,k2-1,zigll,NGLLZ)
+    enddo
+  enddo
+
+  do i=1,NGLLX
+    do k=1,NGLLZ
+      wgllwgll_xz(i,k) = wxgll(i)*wzgll(k)
+    enddo
+  enddo
+
+end subroutine define_derivative_matrices
+
+end module wave2d_define_der_matrices
+

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_solver.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_solver.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_solver.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,1699 @@
+module wave2d_solver
+
+  use wave2d_constants
+  use wave2d_variables
+  use wave2d_define_der_matrices
+  use wave2d_sub    ! for plotting using subroutine local2global.f90
+
+  implicit none
+
+contains
+
+  subroutine mesher
+
+    integer ispec,ib,i,j,k,iglob,iglob1,itime,ix,iz
+
+    double precision :: ztemp, z1temp, z2temp
+    double precision :: ztemp1, ztemp2, dtemp, dtrsh, dinc, zdiff, dz1, dz2
+    integer :: iel, ik
+
+    ! set up grid and spectral elements
+    call define_derivative_matrices(xigll,zigll,wxgll,wzgll,hprime_xx,hprime_zz,wgllwgll_xz)
+
+    !===================
+
+!!$    dtrsh = 0.1   ! level of accuracy for the position of the GLL points w.r.t. the discontinuity
+!!$    dinc  = 0.1   ! how much to perturb the top of the element
+!!$
+!!$    z2temp = 0.0
+!!$    ispec = 0
+!!$
+!!$    ! elements in Z dimension
+!!$    do iz = 1,NEZ
+!!$       do ix = 1,NEX
+!!$          ispec = ispec+1
+!!$
+!!$      if(ix==1) then
+!!$
+!!$      ! evenly spaced anchors between 0 and 1
+!!$      !z1temp = HEIGHT*dble(iz-1)/dble(NEZ)
+!!$      !z2temp = HEIGHT*dble(iz)/dble(NEZ)
+!!$
+!!$      z1temp = z2temp
+!!$      z2temp = z2temp + HEIGHT/dble(NEZ)    ! standard element height
+!!$      if(iz==NEZ) z2temp = HEIGHT
+!!$
+!!$      ! determine whether the element is cut by a discontinuity
+!!$      iel = 0
+!!$      do k = 1,nlayer-1
+!!$        dtemp = HEIGHT - z_breaks(k)
+!!$        if(dtemp > z1temp .and. dtemp < z2temp) then
+!!$          print *, k, iz
+!!$          iel = 1
+!!$          ik = k
+!!$        endif
+!!$      enddo
+!!$      !iel = 0
+!!$
+!!$      ! perturb the boundary of the top of the element (z2)
+!!$      if(iel == 1) then
+!!$
+!!$         zdiff = HEIGHT*LENGTH  ! initial difference
+!!$         do while (zdiff > dtrsh)
+!!$            !write(*,'(5e18.8)') z2temp, zdiff, dtrsh, dz1, dz2
+!!$
+!!$            do j = 1,NGLLZ
+!!$               ! present GLL height (upper layer)
+!!$               ztemp2 = 0.5*(1.0-zigll(j))*z1temp + 0.5*(1.0+zigll(j))*z2temp
+!!$               
+!!$               if(j > 1) then
+!!$                  ! previous GLL z height (lower layer)
+!!$                  ztemp1 = 0.5*(1.0-zigll(j-1))*z1temp + 0.5*(1.0+zigll(j-1))*z2temp
+!!$
+!!$                  dtemp = HEIGHT - z_breaks(ik)   ! height of boundary
+!!$
+!!$                  ! discontinuity is inbetween GLL layers
+!!$                  if(dtemp > ztemp1 .and. dtemp < ztemp2) then
+!!$                     dz1 = abs(dtemp - ztemp1)
+!!$                     dz2 = abs(ztemp2 - dtemp)
+!!$                     zdiff = abs(dz2 - dz1)
+!!$                     !if (zdiff > dtrsh) then
+!!$                     !   if (dz1 > dz2) z2temp = z2temp + dinc  ! push it up
+!!$                     !   if (dz1 < dz2) z2temp = z2temp - dinc  ! push it down
+!!$                     !endif
+!!$                  endif
+!!$
+!!$               endif
+!!$            enddo
+!!$
+!!$            ! changes the position of the top of the element
+!!$            if (dz1 > dz2) z2temp = z2temp + dinc  ! push it up
+!!$            if (dz1 < dz2) z2temp = z2temp - dinc  ! push it down
+!!$
+!!$         enddo
+!!$       endif
+!!$
+!!$       ! compute the GLL points for this element
+!!$       do j = 1,NGLLZ
+!!$         ztemp2 = 0.5*(1.0-zigll(j))*z1temp + 0.5*(1.0+zigll(j))*z2temp
+!!$         print *, iz, j, ztemp2
+!!$       enddo
+!!$
+!!$       endif  ! ix==1
+!!$
+!!$       z1(ispec) = z1temp
+!!$       z2(ispec) = z2temp
+!!$
+!!$    enddo
+!!$    enddo
+
+    !stop 'testing mesher'
+
+    !===================
+
+    ispec = 0
+    iglob = 0
+    nspecb(:) = 0
+
+    ! loop over all elements
+    do iz = 1,NEZ
+       do ix = 1,NEX
+          ispec = ispec+1
+
+          ! evenly spaced anchors between 0 and 1
+          x1(ispec) = LENGTH*dble(ix-1)/dble(NEX)
+          x2(ispec) = LENGTH*dble(ix)/dble(NEX)
+          z1(ispec) = HEIGHT*dble(iz-1)/dble(NEZ)  ! see above
+          z2(ispec) = HEIGHT*dble(iz)/dble(NEZ)    ! see above
+
+          ! loop over GLL points to calculate jacobian, and set up numbering
+          !
+          ! jacobian = | dx/dxi dx/dgamma | = (z2-z1)*(x2-x1)/4  as dx/dgamma=dz/dxi = 0
+          !            | dz/dxi dz/dgamma | 
+          !
+          do j = 1,NGLLZ
+             do i = 1,NGLLX
+
+                ! jacobian, integration weight
+                dxidx(i,j,ispec) = 2.0 / (x2(ispec)-x1(ispec))
+                dxidz(i,j,ispec) = 0.0
+                dgammadx(i,j,ispec) = 0.0
+                dgammadz(i,j,ispec) = 2.0 / (z2(ispec)-z1(ispec))
+                jacobian(i,j,ispec) = (z2(ispec)-z1(ispec))*(x2(ispec)-x1(ispec)) / 4. 
+
+                ! set up local to global numbering
+                if ( (i.eq.1).and.(ix.gt.1) ) then
+                   ibool(i,j,ispec) = ibool(NGLLX,j,ispec-1)
+                else if ( (j.eq.1).and.(iz.gt.1) ) then
+                   ibool(i,j,ispec) = ibool(i,NGLLZ,ispec-NEX)
+                else
+                   iglob = iglob + 1
+                   ibool(i,j,ispec) = iglob         
+                endif
+
+                ! get the global gridpoints
+                iglob1 = ibool(i,j,ispec)
+                x(iglob1) = 0.5*(1.0-xigll(i))*x1(ispec) + 0.5*(1.0+xigll(i))*x2(ispec)
+                z(iglob1) = 0.5*(1.0-zigll(j))*z1(ispec) + 0.5*(1.0+zigll(j))*z2(ispec)
+
+                ! end loop over GLL points
+             enddo
+          enddo
+
+          ! if boundary element
+          ! 1,2,3,4 --> left, right, bottom, top
+          if (ix.eq.1) then      ! left boundary
+             nspecb(1) = nspecb(1) + 1
+             ibelm(1,nspecb(1)) = ispec
+             do j = 1,NGLLZ
+                jacobianb(1,j,nspecb(1))= (z2(ispec)-z1(ispec))/2.0
+             end do
+          endif
+          if (ix.eq.NEX) then    ! right boundary
+             nspecb(2) = nspecb(2) + 1
+             ibelm(2,nspecb(2)) = ispec
+             do j = 1,NGLLZ
+                jacobianb(2,j,nspecb(2))= (z2(ispec)-z1(ispec))/2.0
+             end do
+          endif
+          if (iz.eq.1) then      ! bottom boundary
+             nspecb(3) = nspecb(3) + 1
+             ibelm(3,nspecb(3)) = ispec
+             do i = 1,NGLLX
+                jacobianb(3,i,nspecb(3))= (x2(ispec)-x1(ispec))/2.0
+             end do
+          endif
+          if (iz.eq.NEZ) then    ! top boundary
+             nspecb(4) = nspecb(4) + 1
+             ibelm(4,nspecb(4)) = ispec
+             do i = 1,NGLLX
+                jacobianb(4,i,nspecb(4))= (x2(ispec)-x1(ispec))/2.0
+             end do
+          endif
+          ! end loop over elements
+       enddo
+    enddo
+
+!!$    do ibb=1,4
+!!$       print *, ibb, nspecb(ibb)
+!!$    enddo
+!!$    print *
+!!$    print *
+!!$    do ibb=1,4
+!!$       do ispec=1,nspecb(ibb)
+!!$          print *, ibb, ispec, ibelm(ibb,ispec)
+!!$       enddo
+!!$    enddo
+!!$    stop 'testing the boundary indexing'
+
+    ! estimate the time step
+    dh = HEIGHT/dble((NGLLZ-1)*NEZ)
+    if(dh > LENGTH/dble((NGLLX-1)*NEX)) dh = LENGTH/dble((NGLLX-1)*NEX)
+
+!!$    !c = sqrt((INCOMPRESSIBILITY+FOUR_THIRDS*RIGIDITY)/DENSITY)
+!!$    !time_step = 0.2*dh/c
+!!$    print *
+!!$    print *,'                       space step (km) :', sngl(dh/1000.0)
+!!$    if(ISURFACE==0) then
+!!$       print *,'time step est from courant = 0.2, Pmax : ',sngl(0.2*dh/alpha_max),' seconds'
+!!$       print *,'time step est from courant = 0.2, Pmin : ',sngl(0.2*dh/alpha_min),' seconds'
+!!$       print *,'time step est from courant = 0.2, Smax : ',sngl(0.2*dh/beta_max),' seconds'
+!!$       print *,'time step est from courant = 0.2, Smin : ',sngl(0.2*dh/beta_min),' seconds'
+!!$       print *,'                      actual time step : ',sngl(DT),' seconds'
+!!$    endif
+
+  end subroutine mesher
+
+  !-------------------------------------------------------
+
+  subroutine mesher_additional
+
+    logical, dimension(NGLOB) :: mask_ibool
+    integer :: iglob1, iglob2, iglob3, iglob4
+    integer :: ispec,i,j,k,iglob
+
+    !--------------
+
+    ! da vector and valence vector
+    da_global(:) = 0.0
+    valence(:) = 0
+    k = 0
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX 
+             iglob = ibool(i,j,ispec)
+             da_local(i,j,ispec) = wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+
+             k = k+1
+             da_local_vec(k) = da_local(i,j,ispec)
+
+             !da_global(iglob) = da_global(iglob) + wxgll(i)*wzgll(j)*jacobian(i,j,ispec)
+             da_global(iglob) = da_global(iglob) + da_local(i,j,ispec)
+             valence(iglob) = valence(iglob) + 1
+          enddo
+       enddo
+    enddo
+
+    ! GLL points defining the corners of elements
+    mask_ibool(:) = .false.
+    do ispec = 1,NSPEC
+       iglob1 = ibool(1,1,ispec)
+       iglob2 = ibool(NGLLX,1,ispec)
+       iglob3 = ibool(1,NGLLZ,ispec)
+       iglob4 = ibool(NGLLX,NGLLZ,ispec)
+
+       if(.not. mask_ibool(iglob1)) mask_ibool(iglob1) = .true.
+       if(.not. mask_ibool(iglob2)) mask_ibool(iglob2) = .true.
+       if(.not. mask_ibool(iglob3)) mask_ibool(iglob3) = .true.
+       if(.not. mask_ibool(iglob4)) mask_ibool(iglob4) = .true.
+    enddo
+
+    k = 0
+    ielement_corner(:) = 0
+    do iglob = 1,NGLOB
+       if(mask_ibool(iglob)) then
+          k = k+1
+          ielement_corner(k) = iglob
+       endif
+    enddo
+
+  end subroutine mesher_additional
+
+  !-------------------------------------------------------
+
+  subroutine set_model_property(iref)
+
+    ! This subroutine assigns the structure model parameters for the reference model (synthetics)
+    ! and for the target model (data).  All assignments are done LOCALLY, so that discontinuities
+    ! (such as the Moho) may be honored in the simulations.
+
+    integer, intent(in) :: iref
+    integer :: ispec, i, j, iglob
+
+    !double precision :: socal_z1, socal_z2, socal_z3, socal_z4
+    double precision :: dalpha, dbeta, drho, dmu, dkappa, dalpha2, dbeta2, drho2, dmu2, dkappa2
+    double precision :: atemp, btemp, rtemp, ktemp, mtemp
+    double precision :: btemp2
+
+    !------------------
+
+    ! commented out 06-Aug-2006
+!!$    ! model properties -- globally defined (no discontinuities permitted this way)
+!!$    do iglob = 1,NGLOB
+!!$       rho_global(iglob)   = DENSITY
+!!$       kappa_global(iglob) = INCOMPRESSIBILITY
+!!$       if(ISURFACE==0) then
+!!$          mu_global(iglob) = RIGIDITY
+!!$       else
+!!$          ! KEY: this means that the S velocity will be the surface wave phase velocity (m/s)
+!!$          mu_global(iglob) = DENSITY*(c_glob(iglob))**2
+!!$          !if(ihomo==1) mu_global(iglob) = DENSITY*beta0**2
+!!$          !if(ihomo==0) mu_global(iglob) = DENSITY*(c_glob(iglob))**2
+!!$       endif
+!!$    enddo
+
+    ! target model (data): perturbations are entered as percentages ( dm/m0 )
+    dalpha = PALPHA/100.0
+    dbeta  = PBETA/100.0
+    drho   = PRHO/100.0
+
+    print *
+    print *, 'setting model properties at a local scale'
+    if(iref==1) print *, ' --> reference model (synthetics), IMODEL_SYN = ', IMODEL_SYN
+    if(iref==0) print *, ' --> target model (data), IMODEL_DAT = ', IMODEL_DAT
+    if(IMODEL_SYN > 3) stop 'IMODEL_SYN must be 0,1,2,3'
+    if(IMODEL_DAT > 3) stop 'IMODEL_DAT must be 0,1,2,3'
+
+    !-----------------
+    ! fill local arrays of the reference structure model
+
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX 
+             iglob = ibool(i,j,ispec)
+
+             ! structure for reference model (synthetics)
+             if (iref==1) then
+
+                if(IMODEL_SYN == 0) then      ! homogeneous model
+
+                   !kappa_syn(i,j,ispec) = INCOMPRESSIBILITY
+                   !mu_syn(i,j,ispec)    = RIGIDITY
+                   !rho_syn(i,j,ispec)   = DENSITY
+
+                   kappa_syn(i,j,ispec) = DENSITY*(alpha0*alpha0 - FOUR_THIRDS*beta0*beta0)
+                   mu_syn(i,j,ispec)    = DENSITY*beta0*beta0
+                   rho_syn(i,j,ispec)   = DENSITY
+
+                elseif(IMODEL_SYN == 1) then  ! 1D model (body waves)
+
+                   if(ISURFACE==0) then
+                      call make_1D_model(i,j,ispec,ktemp,mtemp,rtemp)       ! 1D model
+                      kappa_syn(i,j,ispec) = ktemp
+                      mu_syn(i,j,ispec)    = mtemp
+                      rho_syn(i,j,ispec)   = rtemp
+                   else
+                      stop 'check model in set_model_property.f90'
+                   endif
+
+                elseif(IMODEL_SYN == 2) then  ! checkerboard model
+                   if(ISURFACE==0) then
+                      stop 'check model in set_model_property.f90'
+
+                   elseif(ISURFACE==1) then
+                      ! checkerboard S-wave velocity (= membrane wave phase velocity)
+                      ! GLOBALLY defined (not at the elemental level)
+                      btemp2 = beta0 * (1.0 + afac/100.0*(sin(x(iglob)*w_scale) * sin(z(iglob)*w_scale)) )
+
+                      kappa_syn(i,j,ispec) = INCOMPRESSIBILITY
+                      mu_syn(i,j,ispec)    = DENSITY * btemp2*btemp2
+                      rho_syn(i,j,ispec)   = DENSITY
+                   endif
+
+                elseif(IMODEL_SYN == 3) then  ! heterogeneous model
+                   if(ISURFACE==0) then
+                      stop 'check model in set_model_property.f90'
+
+                   else
+                      stop 'check model in set_model_property.f90'
+                      !kappa_syn(i,j,ispec) = INCOMPRESSIBILITY   ! not used
+                      !mu_syn(i,j,ispec)    = DENSITY * beta_syn(iglob)*beta_syn(iglob)
+                      !rho_syn(i,j,ispec)   = DENSITY
+
+                   endif
+
+                endif
+
+             ! structure for target model (data)
+             ! THE REFERENCE MODEL MUST HAVE BEEN PREVIOUSLY CONSTRUCTED
+             else
+
+                ! reference model values (m0)
+                ktemp = kappa_syn(i,j,ispec)
+                mtemp = mu_syn(i,j,ispec)
+                rtemp = rho_syn(i,j,ispec)
+                atemp = sqrt( (ktemp + FOUR_THIRDS*mtemp) / rtemp )
+                btemp = sqrt( mtemp / rtemp )
+
+                if(IMODEL_DAT == 0) then               ! uniform perturbation
+
+                   ! perturbations ( i.e., dm = m-m0 , NOT dm/m0 )
+                   dalpha2 = atemp*dalpha
+                   dbeta2 = btemp*dbeta
+                   drho2 = rtemp*drho
+
+                   ! Dahlen and Tromp, p.332
+                   dkappa2 = drho2*(atemp*atemp - FOUR_THIRDS*btemp*btemp) &
+                        + 2*rtemp*(atemp*dalpha2 - FOUR_THIRDS*btemp*dbeta2)
+                   dmu2 = drho2*btemp*btemp + 2*rtemp*btemp*dbeta2
+
+                   ! perturbed values
+                   !alpha_dat(i,j,ispec) = atemp + dalpha2
+                   !beta_dat(i,j,ispec)  = btemp + dbeta2
+                   rho_dat(i,j,ispec)   = rtemp + drho2
+                   kappa_dat(i,j,ispec) = ktemp + dkappa2
+                   mu_dat(i,j,ispec)    = mtemp + dmu2
+
+                elseif(IMODEL_DAT == 1) then         ! 1D model (NOT a 1D perturbation)
+
+                   if(ISURFACE==0) then
+                      call make_1D_model(i,j,ispec,ktemp,mtemp,rtemp)       ! 1D model
+
+                   else
+                      stop 'check model in set_model_property.f90'
+                   endif
+                   kappa_dat(i,j,ispec) = ktemp
+                   mu_dat(i,j,ispec)    = mtemp
+                   rho_dat(i,j,ispec)   = rtemp
+
+                elseif(IMODEL_DAT == 2) then         ! checkerboard perturbation
+
+                   if(ISURFACE==0) then
+                      stop 'check model in set_model_property.f90'
+                   else
+                      ! GJI-2007 paper
+                      ! perturbed S-wave velocity (= membrane wave phase velocity)
+                      ! GLOBALLY defined (not at the elemental level)
+                      btemp2 = btemp * (1.0 + afac/100.0*(sin(x(iglob)*w_scale) * sin(z(iglob)*w_scale)) )
+
+                      kappa_dat(i,j,ispec) = kappa_syn(i,j,ispec)
+                      mu_dat(i,j,ispec)    = DENSITY * btemp2*btemp2
+                      rho_dat(i,j,ispec)   = rho_syn(i,j,ispec)
+                      !kappa_dat(i,j,ispec) = INCOMPRESSIBILITY
+                      !mu_dat(i,j,ispec)    = DENSITY * btemp2*btemp2
+                      !rho_dat(i,j,ispec)   = DENSITY
+                   endif
+
+                elseif(IMODEL_DAT == 3) then         ! heterogeneous perturbation
+
+                   if(ISURFACE==0) then
+                      stop 'check model in set_model_property.f90'
+
+                   else
+                      kappa_dat(i,j,ispec) = INCOMPRESSIBILITY    ! not used
+                      mu_dat(i,j,ispec)    = DENSITY * beta_dat(i,j,ispec)*beta_dat(i,j,ispec)
+                      rho_dat(i,j,ispec)   = DENSITY
+
+                   endif
+
+                endif   ! IMODEL_DAT
+             endif   ! iref
+
+          enddo
+       enddo
+    enddo
+
+    if(iref == 1) then
+       alpha_syn = 0.0 ; beta_syn = 0.0 ; bulk_syn = 0.0
+       alpha_syn = sqrt( (kappa_syn + FOUR_THIRDS*mu_syn) / rho_syn )
+       beta_syn  = sqrt( mu_syn / rho_syn )
+       bulk_syn  = sqrt( kappa_syn / rho_syn )
+    else
+       alpha_dat = 0.0 ; beta_dat = 0.0 ; bulk_dat = 0.0
+       alpha_dat = sqrt( (kappa_dat + FOUR_THIRDS*mu_dat) / rho_dat )
+       beta_dat  = sqrt( mu_dat / rho_dat )
+       bulk_dat  = sqrt( kappa_dat / rho_dat )
+    endif
+
+  end subroutine set_model_property
+
+  !-------------------------------------------------------
+
+  subroutine make_1D_model(i,j,ispec,kappa1,mu1,rho1)
+
+    ! Given a GLL local index (i,j,ispec), this returns the structure values kappa-mu-rho,
+    ! for a 1D model that honors discontinuities in the mesh.
+
+    integer, intent(in) :: i,j,ispec
+    double precision, intent(out) :: kappa1, mu1, rho1
+    double precision :: atemp, btemp, rtemp, dtemp
+    integer :: iglob
+
+    !-----------------
+
+    iglob = ibool(i,j,ispec)
+    dtemp = HEIGHT - z(iglob)     ! depth of GLL point
+
+    if(dtemp < z_breaks(1)) then                                  ! shallow surface
+       rtemp = r_layers(1) ; atemp = a_layers(1) ; btemp = b_layers(1)
+
+    elseif(dtemp == z_breaks(1)) then                             ! 'basin' reflector
+       if(HEIGHT-z1(ispec) == dtemp) then
+          rtemp = r_layers(1) ; atemp = a_layers(1) ; btemp = b_layers(1)
+       elseif(HEIGHT-z2(ispec) == dtemp) then
+          rtemp = r_layers(2) ; atemp = a_layers(2) ; btemp = b_layers(2)
+       else
+          print *, dtemp, z_breaks(1), z1(ispec), z2(ispec)
+          stop 'error in make_1D_model.f90'
+       endif
+
+    elseif(dtemp > z_breaks(1) .and. dtemp < z_breaks(2)) then    ! upper crust
+       rtemp = r_layers(2) ; atemp = a_layers(2) ; btemp = b_layers(2)
+
+    elseif(dtemp == z_breaks(2)) then                             ! mid-crust reflector
+       if(HEIGHT-z1(ispec) == dtemp) then
+          rtemp = r_layers(2) ; atemp = a_layers(2) ; btemp = b_layers(2)
+       elseif(HEIGHT-z2(ispec) == dtemp) then
+          rtemp = r_layers(3) ; atemp = a_layers(3) ; btemp = b_layers(3)
+       else
+          print *, dtemp, z_breaks(2), z1(ispec), z2(ispec)
+          stop 'error in make_1D_model.f90'
+       endif
+
+    elseif(dtemp > z_breaks(2) .and. dtemp < z_breaks(3)) then    ! lower crust
+       rtemp = r_layers(3) ; atemp = a_layers(3) ; btemp = b_layers(3)
+
+    elseif(dtemp == z_breaks(3)) then                             ! Moho
+       if(HEIGHT-z1(ispec) == dtemp) then
+          rtemp = r_layers(3) ; atemp = a_layers(3) ; btemp = b_layers(3)
+       elseif(HEIGHT-z2(ispec) == dtemp) then
+          rtemp = r_layers(4) ; atemp = a_layers(4) ; btemp = b_layers(4)
+       else
+          print *, dtemp, z_breaks(3), z1(ispec), z2(ispec)
+          stop 'error in make_1D_model.f90'
+       endif
+
+    else                                                          ! upper mantle
+       rtemp = r_layers(4) ; atemp = a_layers(4) ; btemp = b_layers(4)
+    endif
+
+    ! compute kappa, mu, rho
+    kappa1 = rtemp*(atemp*atemp - FOUR_THIRDS*btemp*btemp)
+    mu1    = rtemp*btemp*btemp
+    rho1   = rtemp
+
+  end subroutine make_1D_model
+
+  !---------------------------------------------
+
+  subroutine solver(solver_type, idata, &
+       nsrc, sglob, ispec_src, hxis_store, hgammas_store, samp, &
+       nrec, rglob, ispec_rec, hxir_store, hgammar_store, ramp,  &
+       last_frame, absorbfield, &
+       atype_kernel, btype_kernel, rtype_kernel, &
+       three_source_model, stf_syn, f0)
+
+    ! required input and output
+    integer, intent(in) :: solver_type, idata
+    integer, intent(in) :: nsrc, sglob(nsrc), ispec_src(nsrc)
+    integer, intent(in) :: nrec, rglob(nrec), ispec_rec(nrec)
+    double precision, intent(in) :: hxir_store(nrec,NGLLX), hgammar_store(nrec,NGLLZ)
+    double precision, intent(in) :: hxis_store(nsrc,NGLLX), hgammas_store(nsrc,NGLLZ)
+    double precision, intent(inout) :: samp(NSTEP,NCOMP,nsrc)
+    double precision, intent(inout) :: ramp(NSTEP,NCOMP,nrec)
+
+    ! OPTIONAL ARGUMENTS
+    character(len=*), optional :: last_frame
+    double precision, intent(inout), optional :: absorbfield(NSTEP, NCOMP, NGLL, NELE, NABSORB)
+    double precision, intent(out), optional :: three_source_model(NSTEP,NCOMP,nsrc,NVAR_SOURCE)   ! 3 : ts, xs, zs
+    !double precision, intent(out), optional :: three_source_model(NSTEP,NCOMP,nsrc,10)    ! testing 
+    double precision, intent(out), dimension(NGLLX,NGLLZ,NSPEC), optional :: rtype_kernel, btype_kernel, atype_kernel
+    double precision, intent(in), optional :: stf_syn(NSTEP), f0(NCOMP)
+
+    ! if adjoint seismograms are desired while computing kernels, then we need to make sure
+    ! not to overwrite the forward source time function
+    double precision,  dimension(:,:,:), allocatable :: stf_for
+    double precision, dimension(NSTEP) :: stf_syn_dt
+
+    ! displacement gradients
+    ! only save the GLL points on the element where the source is located
+    double precision :: displ_grad(NGLLX,NGLLZ,2*NCOMP)
+
+    ! kernels and interaction fields
+    double precision, dimension(:,:,:), allocatable :: kappa_mu_rho_kernel, mu_kappa_rho_kernel, rho_kappa_mu_kernel
+    double precision, dimension(:,:,:), allocatable :: alpha_beta_rho_kernel, beta_alpha_rho_kernel, rho_alpha_beta_kernel
+    double precision, dimension(:,:,:), allocatable :: c_beta_rho_kernel, beta_c_rho_kernel, rho_c_beta_kernel
+    double precision, dimension(:,:,:), allocatable :: kappa_mu_rho_kernel_int, mu_kappa_rho_kernel_int, rho_kappa_mu_kernel_int
+    double precision, dimension(:,:,:), allocatable :: alpha_beta_rho_kernel_int, beta_alpha_rho_kernel_int, rho_alpha_beta_kernel_int
+    double precision, dimension(:,:,:), allocatable :: c_beta_rho_kernel_int, beta_c_rho_kernel_int, rho_c_beta_kernel_int
+
+    ! CHT
+    integer tlab
+    double precision :: temp1,temp2,temp3
+
+    ! Lagrange interpolation
+    double precision :: hlagrange
+
+    integer ispec,ib,i,j,k,iglob,iglob1,iglob2,itime,ix,iz,itime1,itime2,itime0
+    integer isrc, irec, icomp, isave
+    character(len=100) :: filename,filename1,filename2,filename3,filename4,filename5,filename6,fm
+    !double precision, dimension(NGLOB) :: mu_k, kappa_k
+    double precision, dimension(NGLLX,NGLLZ,NSPEC) :: mu_k, kappa_k
+    logical :: save_forward
+
+    !--------------------------------------
+
+    if(NCOMP==3) fm = '(9e12.3)'
+    if(NCOMP==1) fm = '(3e12.3)'
+
+    ! test of input arguments
+    if (solver_type /= 1 .and. solver_type /= 2 .and. solver_type /= 3) then
+       stop 'solver_type has to be 1, 2 or 3'
+    endif
+
+    if (idata /= 1 .and. idata /= 0) then
+       stop 'idata has to be 0 or 1'
+    endif
+
+    save_forward = .false.
+    if (solver_type == 1) then
+       if (present(last_frame) .and. present(absorbfield)) save_forward = .true.
+    endif
+
+    if (solver_type == 3) then
+       if (.not. (present(last_frame) .and. present(absorbfield)  &
+            .and. present(rtype_kernel) .and. present(btype_kernel) .and. present(atype_kernel))) &
+            stop 'For kernel calculation, last_frame, absorbfield and all kernel are in the argument'
+
+       ! interaction fields must be initialized
+       mu_k = 0.0
+       kappa_k = 0.0
+
+       ! allocate a new array for the forward source function (note: includes amplitude)
+       allocate(stf_for(NSTEP,NCOMP,nsrc))
+       stf_for = samp
+
+       ! compute the derivative of the source time function
+       stf_syn_dt(:) = 0.0
+       do i = 2, NSTEP-1
+          stf_syn_dt(i) =  (stf_syn(i+1) - stf_syn(i-1)) / (2.0*DT)
+       enddo
+       stf_syn_dt(1) = (stf_syn(2) - stf_syn(1)) / DT
+       stf_syn_dt(NSTEP) = (stf_syn(NSTEP) - stf_syn(NSTEP-1)) / DT
+
+       ! initialize adjoint seismograms
+       samp = 0.0
+
+    endif
+
+    ! gridpoints per wavelength estimation -- based on TARGET model (data)
+    print *
+    print *, 'space step (km):', sngl(dh/1000.0)
+    if(ISURFACE==1) then
+       print *, 'wavelength-min (km):', sngl(2*hdur*beta_min/1000.0)
+       print *, 'wavelength-max (km):', sngl(2*hdur*beta_max/1000.0)
+       print *, 'number of gridpoints per wavelength for S:'
+       print *, '  min (cmin) : ', floor(2*hdur*beta_min/dh)
+       print *, '  max (cmax) : ', floor(2*hdur*beta_max/dh)
+    else
+       !c = sqrt((INCOMPRESSIBILITY+FOUR_THIRDS*RIGIDITY)/DENSITY)
+       !print *, 'number of gridpoints per wavelength for P: ', floor(hdur*c/dh)
+       !c = sqrt(RIGIDITY/DENSITY)
+       !print *, 'number of gridpoints per wavelength for S:', floor(hdur*c/dh)
+       print *, 'Velocities in km/s :'
+       print *, '  Pmin  :', sngl(alpha_min/1000.0)
+       print *, '  Pmax  :', sngl(alpha_max/1000.0)
+       print *, '  Smin  :', sngl(beta_min/1000.0)
+       print *, '  Smax  :', sngl(beta_max/1000.0)
+       print *, 'Gridpoints per wavelength :'
+       print *, '  Pmin  :', floor(hdur*alpha_min/dh)
+       print *, '  Pmax  :', floor(hdur*alpha_max/dh)
+       print *, '  Smin  :', floor(hdur*beta_min/dh)
+       print *, '  Smax  :', floor(hdur*beta_max/dh)
+    endif
+
+    NINT = NSTEP/NSAVE
+    if (NINT * NSAVE > NSTEP) stop 'NSTEP should equal to NINT * NSAVE'
+
+    ! calculate the global mass matrix once and for all
+    ! note that the density variation is included here
+    mass_global(:) = 0.0
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX
+             mass_local = wxgll(i)*wzgll(j)*rho(i,j,ispec)*jacobian(i,j,ispec)
+             iglob = ibool(i,j,ispec)
+             mass_global(iglob) = mass_global(iglob) + mass_local
+          end do
+       end do
+    end do
+
+    ! time marching parameters
+    deltat = DT
+    deltatover2 = deltat/2.0
+    deltatsqover2 = deltat*deltat/2.0
+
+    if (solver_type == 3) then
+       b_deltat = -DT
+       b_deltatover2 = b_deltat/2.0
+       b_deltatsqover2 = b_deltat*b_deltat/2.0
+    endif
+
+    ! initialize
+    displ(:,:) = 0.0
+    veloc(:,:) = 0.0
+    accel(:,:) = 0.0
+    
+    if (solver_type == 3) then
+       open(11,file = trim(last_frame),status='old',iostat=ios)
+       if (ios /= 0) stop 'Error reading the last frame'
+       do i = 1, NGLOB
+          !read(11,*) b_displ(1,i), b_displ(2,i), b_displ(3,i), & 
+          !           b_veloc(1,i), b_veloc(2,i), b_veloc(3,i), &
+          !           b_accel(1,i), b_accel(2,i), b_accel(3,i)
+          read(11,fm) (b_displ(j,i), j = 1,NCOMP), &
+               (b_veloc(j,i), j = 1,NCOMP), & 
+               (b_accel(j,i), j = 1,NCOMP)
+       enddo
+       close(11)
+
+       ! allocate 9 (3 x 3) kernels
+       allocate(kappa_mu_rho_kernel(NGLLX,NGLLZ,NSPEC),mu_kappa_rho_kernel(NGLLX,NGLLZ,NSPEC),rho_kappa_mu_kernel(NGLLX,NGLLZ,NSPEC))
+       allocate(alpha_beta_rho_kernel(NGLLX,NGLLZ,NSPEC),beta_alpha_rho_kernel(NGLLX,NGLLZ,NSPEC),rho_alpha_beta_kernel(NGLLX,NGLLZ,NSPEC))
+       allocate(c_beta_rho_kernel(NGLLX,NGLLZ,NSPEC),beta_c_rho_kernel(NGLLX,NGLLZ,NSPEC),rho_c_beta_kernel(NGLLX,NGLLZ,NSPEC))
+
+       ! initialize kernels
+       kappa_mu_rho_kernel = 0.0   ; mu_kappa_rho_kernel = 0.0   ; rho_kappa_mu_kernel = 0.0
+       alpha_beta_rho_kernel = 0.0 ; beta_alpha_rho_kernel = 0.0 ; rho_alpha_beta_kernel = 0.0
+       c_beta_rho_kernel = 0.0     ; beta_c_rho_kernel = 0.0     ; rho_c_beta_kernel = 0.0
+
+       ! allocate interaction fields for 9 (3 x 3) kernels
+       if(WRITE_KERNEL_SNAPSHOTS) then
+          allocate(kappa_mu_rho_kernel_int(NGLLX,NGLLZ,NSPEC),mu_kappa_rho_kernel_int(NGLLX,NGLLZ,NSPEC),rho_kappa_mu_kernel_int(NGLLX,NGLLZ,NSPEC))
+          allocate(alpha_beta_rho_kernel_int(NGLLX,NGLLZ,NSPEC),beta_alpha_rho_kernel_int(NGLLX,NGLLZ,NSPEC),rho_alpha_beta_kernel_int(NGLLX,NGLLZ,NSPEC))
+          allocate(c_beta_rho_kernel_int(NGLLX,NGLLZ,NSPEC),beta_c_rho_kernel_int(NGLLX,NGLLZ,NSPEC),rho_c_beta_kernel_int(NGLLX,NGLLZ,NSPEC))
+
+          kappa_mu_rho_kernel_int = 0.0   ; mu_kappa_rho_kernel_int = 0.0   ; rho_kappa_mu_kernel_int = 0.0
+          alpha_beta_rho_kernel_int = 0.0 ; beta_alpha_rho_kernel_int = 0.0 ; rho_alpha_beta_kernel_int = 0.0
+          c_beta_rho_kernel_int = 0.0     ; beta_c_rho_kernel_int = 0.0     ; rho_c_beta_kernel_int = 0.0
+       endif
+
+    endif
+
+    !
+    ! START TIME MARCHING
+    !
+    do itime = 1, NSTEP
+
+       if (mod(itime,200) == 0) write(*,*) itime, ' out of ', NSTEP
+
+       ! 'predictor' update displacement using finite-difference time scheme (Newmark)
+       do i = 1,NCOMP
+          displ(i,:) = displ(i,:) + deltat*veloc(i,:) + deltatsqover2*accel(i,:)
+          veloc(i,:) = veloc(i,:) + deltatover2*accel(i,:)
+          accel(i,:) = 0.0
+          if (solver_type == 3) then
+             b_displ(i,:) = b_displ(i,:) + b_deltat*b_veloc(i,:) + b_deltatsqover2*b_accel(i,:)
+             b_veloc(i,:) = b_veloc(i,:) + b_deltatover2*b_accel(i,:)
+             b_accel(i,:) = 0.0
+          endif
+       enddo
+
+       ! displacement gradient at the source element GLL points at each time step
+       if(solver_type == 3) displ_grad = 0.0
+
+       if(NCOMP==1) then    ! SH, or surface waves only
+
+          !
+          !   INTEGRATION OVER SPECTRAL ELEMENTS
+          !
+          do ispec = 1,NSPEC
+
+             ! first double loop over GLL 
+             ! compute and store gradients
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+
+                   !iglob2 = ibool(i,j,ispec)     ! 09-Jan-2007
+
+                   ! derivative along x
+                   tempy1l = 0.0
+                   if (solver_type == 3) b_tempy1l = 0.0
+                   do k = 1,NGLLX
+                      hp1 = hprime_xx(k,i)
+                      iglob = ibool(k,j,ispec)
+                      tempy1l = tempy1l + displ(1,iglob)*hp1
+                      if (solver_type == 3) then
+                         b_tempy1l = b_tempy1l + b_displ(1,iglob)*hp1
+                      endif
+                   end do
+
+                   ! derivative along z
+                   tempy2l = 0.0
+                   if (solver_type == 3) b_tempy2l = 0.0
+                   do k = 1,NGLLZ
+                      hp2 = hprime_zz(k,j)
+                      iglob = ibool(i,k,ispec)
+                      tempy2l = tempy2l + displ(1,iglob)*hp2
+                      if (solver_type == 3) then
+                         b_tempy2l = b_tempy2l + b_displ(1,iglob)*hp2
+                      endif
+                   end do
+
+                   ! from mesher
+                   dxidxl = dxidx(i,j,ispec)
+                   dxidzl = dxidz(i,j,ispec)
+                   dgammadxl = dgammadx(i,j,ispec)
+                   dgammadzl = dgammadz(i,j,ispec)
+
+                   ! spatial gradients
+                   dsydxl = tempy1l*dxidxl + tempy2l*dgammadxl
+                   dsydzl = tempy1l*dxidzl + tempy2l*dgammadzl
+
+                   ! save spatial gradient for (point) source perturbations
+                   ! NOTE: point source only (nsrc=1)
+                   if(solver_type == 3 .and. ispec == ispec_src(1)) then
+                      displ_grad(i,j,1) = dsydxl
+                      displ_grad(i,j,2) = dsydzl
+                      !displ_grad(i,j,3) = dsydxl
+                      !displ_grad(i,j,4) = dsydzl
+                   endif
+
+                   ! strain tensor
+                   ds(:,:) = 0.0
+                   ds(1,2) = oneovertwo * dsydxl
+                   ds(2,3) = oneovertwo * dsydzl
+                   ds(2,1) = ds(1,2)
+                   ds(3,2) = ds(2,3)
+
+                   if (solver_type == 3) then
+                      b_dsydxl = b_tempy1l*dxidxl + b_tempy2l*dgammadxl
+                      b_dsydzl = b_tempy1l*dxidzl + b_tempy2l*dgammadzl
+
+                      b_ds(:,:) = 0.0
+                      b_ds(1,2) = oneovertwo * b_dsydxl
+                      b_ds(2,3) = oneovertwo * b_dsydzl
+                      b_ds(2,1) = b_ds(1,2)
+                      b_ds(3,2) = b_ds(2,3)
+
+                      ! mu kernel : K-mu = double-dot-product of deviatoric strains 
+                      ! kappa kernel : not used for SH case (see kappa_k below)
+                      ! (see below for kappa kernel) 
+                      mu_k(i,j,ispec) = sum(ds * b_ds)
+                      !mu_k(iglob2) = sum(ds * b_ds)                                 ! (09-Jan-2007)
+                      !mu_k(iglob2) = sum(ds * b_ds) - ONE_THIRD * kappa_k(iglob2)   ! (12-July-2006)
+                   endif
+
+                   mul = mu(i,j,ispec)      ! model heterogeneity
+                   sigma_xy = mul*dsydxl
+                   sigma_zy = mul*dsydzl
+
+                   if (solver_type == 3) then
+                      b_sigma_xy = mul* b_dsydxl
+                      b_sigma_zy = mul* b_dsydzl
+                   endif
+
+                   jacobianl = jacobian(i,j,ispec)
+
+                   ! non-symmetric form (first Piola-Kirchhoff stress)
+                   tempy1(i,j) = jacobianl*(sigma_xy*dxidxl+sigma_zy*dxidzl)
+                   tempy2(i,j) = jacobianl*(sigma_xy*dgammadxl+sigma_zy*dgammadzl)
+                   if (solver_type == 3) then
+                      b_tempy1(i,j) = jacobianl*(b_sigma_xy*dxidxl+ b_sigma_zy*dxidzl)
+                      b_tempy2(i,j) = jacobianl*(b_sigma_xy*dgammadxl+b_sigma_zy*dgammadzl)
+                   endif
+
+                enddo
+             enddo
+             !
+             ! second double-loop over GLL
+             ! compute all rhs terms
+             !
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+
+                   ! along x direction
+                   tempy1l = 0.0
+                   if (solver_type == 3) b_tempy1l = 0.0
+                   do k = 1,NGLLX
+                      fac1 = wxgll(k)*hprime_xx(i,k)
+                      tempy1l = tempy1l + tempy1(k,j)*fac1
+                      if (solver_type == 3) then
+                         b_tempy1l = b_tempy1l + b_tempy1(k,j)*fac1
+                      endif
+                   end do
+
+                   ! along z direction
+                   tempy2l = 0.0
+                   if (solver_type == 3) b_tempy2l = 0.0
+                   do k = 1,NGLLZ
+                      fac2 = wzgll(k)*hprime_zz(j,k)
+                      tempy2l = tempy2l + tempy2(i,k)*fac2
+                      if (solver_type == 3) then
+                         b_tempy2l = b_tempy2l + b_tempy2(i,k)*fac2
+                      endif
+                   end do
+
+                   fac1 = wzgll(j)
+                   fac2 = wxgll(i)
+
+                   iglob = ibool(i,j,ispec)
+                   accel(1,iglob) = accel(1,iglob) - (fac1*tempy1l + fac2*tempy2l)
+                   if (solver_type == 3) then
+                      b_accel(1,iglob) = b_accel(1,iglob) - (fac1* b_tempy1l + fac2* b_tempy2l)
+                   endif
+
+                end do ! second loop over the GLL points
+             end do
+
+          end do ! end loop over all spectral elements
+
+          !
+          ! boundary conditions
+          !
+          ! forward propagation
+
+          ! modifications by CHT are made to make the top boundary absorbing
+          ! if this is used in other options (e.g., kernels), then those
+          ! sections need to be adjusted as well
+
+          do ibb = 1,NABSORB  ! index of grid boundary
+             if(ibb == 1) then
+                i = 1
+             elseif(ibb == 2) then
+                i = NGLLX
+             elseif(ibb == 3) then
+                i = 1
+             elseif(ibb == 4) then
+                i = NGLLZ
+             endif
+
+             do ib = 1,nspecb(ibb)     ! elements on each grid boundary
+                ispec = ibelm(ibb,ib)  ! (global) index of boundary element
+
+                if (ibb == 1 .or. ibb == 2) then ! left or right boundary element
+                   j1 = 1; j2 = NGLLZ
+                else if (ib == 1) then           ! top left corner element
+                   j1 = 2; j2 = NGLLX 
+                else if (ib == nspecb(ibb)) then ! top right corner element
+                   j1 = 1; j2 = NGLLX-1  
+                else                             ! top or bottom boundary (excluding corner elements)
+                   j1 = 1; j2 = NGLLX
+                endif
+
+                do j = j1, j2
+                   if (ibb == 1 .or. ibb == 2) then  ! left or right boundary
+                      iglob = ibool(i,j,ispec)
+                      rho_vs = dsqrt(rho(i,j,ispec)*mu(i,j,ispec))
+                   else                              ! top or bottom boundary
+                      iglob = ibool(j,i,ispec)
+                      rho_vs = dsqrt(rho(j,i,ispec)*mu(j,i,ispec))
+                   endif
+
+                   vy = veloc(1,iglob)
+                   ty = rho_vs*vy
+                   weight = jacobianb(ibb,j,ib)*wzgll(j)
+                   accel(1,iglob) = accel(1,iglob) - ty*weight
+                   if (save_forward) then
+                      absorbfield(itime,1,j,ib,ibb) = ty*weight
+                   endif
+                end do
+             end do
+          enddo
+
+       else  ! NCOMP==3
+
+       ! DEBUG ARRAY SIZES
+
+          !
+          !   INTEGRATION OVER SPECTRAL ELEMENTS
+          !
+          do ispec = 1,NSPEC
+
+             ! first double loop over GLL 
+             ! compute and store gradients
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+
+                   !iglob2 = ibool(i,j,ispec)
+
+                   ! derivative along x
+                   tempx1l = 0.0
+                   tempy1l = 0.0
+                   tempz1l = 0.0
+                   if (solver_type == 3) then
+                      b_tempx1l = 0.0
+                      b_tempy1l = 0.0
+                      b_tempz1l = 0.0
+                   endif
+                   do k = 1,NGLLX
+                      hp1 = hprime_xx(k,i)
+                      iglob = ibool(k,j,ispec)
+                      tempx1l = tempx1l + displ(1,iglob)*hp1
+                      tempy1l = tempy1l + displ(2,iglob)*hp1
+                      tempz1l = tempz1l + displ(3,iglob)*hp1
+                      if (solver_type == 3) then
+                         b_tempx1l = b_tempx1l + b_displ(1,iglob)*hp1
+                         b_tempy1l = b_tempy1l + b_displ(2,iglob)*hp1
+                         b_tempz1l = b_tempz1l + b_displ(3,iglob)*hp1
+                      endif
+                   end do
+
+                   ! derivative along z
+                   tempx2l = 0.0
+                   tempy2l = 0.0
+                   tempz2l = 0.0
+                   if (solver_type == 3) then
+                      b_tempx2l = 0.0
+                      b_tempy2l = 0.0
+                      b_tempz2l = 0.0
+                   endif
+                   do k = 1,NGLLZ
+                      hp2 = hprime_zz(k,j)
+                      iglob = ibool(i,k,ispec)
+                      tempx2l = tempx2l + displ(1,iglob)*hp2
+                      tempy2l = tempy2l + displ(2,iglob)*hp2
+                      tempz2l = tempz2l + displ(3,iglob)*hp2
+                      if (solver_type == 3) then
+                         b_tempx2l = b_tempx2l + b_displ(1,iglob)*hp2
+                         b_tempy2l = b_tempy2l + b_displ(2,iglob)*hp2
+                         b_tempz2l = b_tempz2l + b_displ(3,iglob)*hp2
+                      endif
+                   end do
+
+                   ! from the mesher
+                   dxidxl = dxidx(i,j,ispec)
+                   dxidzl = dxidz(i,j,ispec)
+                   dgammadxl = dgammadx(i,j,ispec)
+                   dgammadzl = dgammadz(i,j,ispec)
+
+                   ! displacement gradients
+                   dsxdxl = tempx1l*dxidxl+tempx2l*dgammadxl
+                   dsxdzl = tempx1l*dxidzl+tempx2l*dgammadzl
+                   dsydxl = tempy1l*dxidxl+tempy2l*dgammadxl
+                   dsydzl = tempy1l*dxidzl+tempy2l*dgammadzl
+                   dszdxl = tempz1l*dxidxl+tempz2l*dgammadxl
+                   dszdzl = tempz1l*dxidzl+tempz2l*dgammadzl
+
+                   ! save spatial gradient for (point) source perturbations
+                   if(solver_type == 3 .and. ispec == ispec_src(1)) then
+                      displ_grad(i,j,1) = dsxdxl
+                      displ_grad(i,j,2) = dsxdzl
+                      displ_grad(i,j,3) = dsydxl
+                      displ_grad(i,j,4) = dsydzl
+                      displ_grad(i,j,5) = dszdxl
+                      displ_grad(i,j,6) = dszdzl
+                   endif
+
+                   ! strain tensor
+                   ds(1,1) = dsxdxl
+                   ds(1,2) = oneovertwo * dsydxl
+                   ds(1,3) = oneovertwo * (dszdxl + dsxdzl)
+                   ds(2,2) = 0                                ! 2D code
+                   ds(2,3) = oneovertwo * dsydzl
+                   ds(3,3) = dszdzl
+                   ds(2,1) = ds(1,2)
+                   ds(3,1) = ds(1,3)
+                   ds(3,2) = ds(2,3)
+
+                   if (solver_type == 3) then
+                      b_dsxdxl = b_tempx1l*dxidxl+ b_tempx2l*dgammadxl
+                      b_dsxdzl = b_tempx1l*dxidzl+ b_tempx2l*dgammadzl
+
+                      b_dsydxl = b_tempy1l*dxidxl+ b_tempy2l*dgammadxl
+                      b_dsydzl = b_tempy1l*dxidzl+ b_tempy2l*dgammadzl
+
+                      b_dszdxl = b_tempz1l*dxidxl+ b_tempz2l*dgammadxl
+                      b_dszdzl = b_tempz1l*dxidzl+ b_tempz2l*dgammadzl
+
+                      b_ds(1,1) = b_dsxdxl
+                      b_ds(1,2) = oneovertwo * b_dsydxl
+                      b_ds(1,3) = oneovertwo * (b_dszdxl + b_dsxdzl)
+                      b_ds(2,2) = 0
+                      b_ds(2,3) = oneovertwo * b_dsydzl
+                      b_ds(3,3) = b_dszdzl
+                      b_ds(2,1) = b_ds(1,2)
+                      b_ds(3,1) = b_ds(1,3)
+                      b_ds(3,2) = b_ds(2,3)
+
+                      ! kappa and mu kernels
+                      ! K-kappa = product of div_s
+                      ! K-mu = double-dot-product of deviatoric strains
+                      kappa_k(i,j,ispec) = (dsxdxl + dszdzl) * (b_dsxdxl + b_dszdzl)
+                      mu_k(i,j,ispec)    = sum(ds * b_ds) - ONE_THIRD * kappa_k(i,j,ispec)
+                      !kappa_k(iglob2) = (dsxdxl + dszdzl) * (b_dsxdxl + b_dszdzl)
+                      !mu_k(iglob2)    = sum(ds * b_ds) - ONE_THIRD * kappa_k(iglob2)
+                   endif
+
+                   ! variation in kappa and mu
+                   kappal = kappa(i,j,ispec)
+                   mul = mu(i,j,ispec)
+                   lambdalplus2mul = kappal + FOUR_THIRDS * mul
+                   lambdal = lambdalplus2mul - 2.0*mul
+
+                   sigma_xx = lambdalplus2mul*dsxdxl + lambdal*dszdzl
+                   sigma_xy = mul*dsydxl
+                   sigma_xz = mul*(dszdxl + dsxdzl)
+                   sigma_zx = sigma_xz
+                   sigma_zy = mul*dsydzl
+                   sigma_zz = lambdalplus2mul*dszdzl + lambdal*dsxdxl
+
+                   if (solver_type == 3) then
+                      b_sigma_xx = lambdalplus2mul* b_dsxdxl + lambdal* b_dszdzl
+                      b_sigma_xy = mul* b_dsydxl
+                      b_sigma_xz = mul*(b_dszdxl + b_dsxdzl)
+                      b_sigma_zx = b_sigma_xz
+                      b_sigma_zy = mul* b_dsydzl
+                      b_sigma_zz = lambdalplus2mul* b_dszdzl + lambdal* b_dsxdxl
+                   endif
+
+                   jacobianl = jacobian(i,j,ispec)
+
+                   ! non-symmetric form (first Piola-Kirchhoff stress)
+                   tempx1(i,j) = jacobianl*(sigma_xx*dxidxl+sigma_zx*dxidzl)
+                   tempy1(i,j) = jacobianl*(sigma_xy*dxidxl+sigma_zy*dxidzl)
+                   tempz1(i,j) = jacobianl*(sigma_xz*dxidxl+sigma_zz*dxidzl)
+
+                   tempx2(i,j) = jacobianl*(sigma_xx*dgammadxl+sigma_zx*dgammadzl)
+                   tempy2(i,j) = jacobianl*(sigma_xy*dgammadxl+sigma_zy*dgammadzl)
+                   tempz2(i,j) = jacobianl*(sigma_xz*dgammadxl+sigma_zz*dgammadzl)
+
+                   if (solver_type == 3) then
+                      b_tempx1(i,j) = jacobianl*(b_sigma_xx*dxidxl+ b_sigma_zx*dxidzl)
+                      b_tempy1(i,j) = jacobianl*(b_sigma_xy*dxidxl+ b_sigma_zy*dxidzl)
+                      b_tempz1(i,j) = jacobianl*(b_sigma_xz*dxidxl+ b_sigma_zz*dxidzl)
+
+                      b_tempx2(i,j) = jacobianl*(b_sigma_xx*dgammadxl+b_sigma_zx*dgammadzl)
+                      b_tempy2(i,j) = jacobianl*(b_sigma_xy*dgammadxl+b_sigma_zy*dgammadzl)
+                      b_tempz2(i,j) = jacobianl*(b_sigma_xz*dgammadxl+b_sigma_zz*dgammadzl)
+                   endif
+
+                end do
+             end do
+             !
+             ! second double-loop over GLL
+             ! compute all rhs terms
+             !
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+
+                   ! along x direction
+                   tempx1l = 0.0
+                   tempy1l = 0.0
+                   tempz1l = 0.0
+                   if (solver_type == 3) then
+                      b_tempx1l = 0.0
+                      b_tempy1l = 0.0
+                      b_tempz1l = 0.0
+                   endif
+                   do k = 1,NGLLX
+                      fac1 = wxgll(k)*hprime_xx(i,k)
+                      tempx1l = tempx1l + tempx1(k,j)*fac1
+                      tempy1l = tempy1l + tempy1(k,j)*fac1
+                      tempz1l = tempz1l + tempz1(k,j)*fac1
+                      if (solver_type == 3) then
+                         b_tempx1l = b_tempx1l + b_tempx1(k,j)*fac1
+                         b_tempy1l = b_tempy1l + b_tempy1(k,j)*fac1
+                         b_tempz1l = b_tempz1l + b_tempz1(k,j)*fac1
+                      endif
+                   end do
+
+                   ! along z direction
+                   tempx2l = 0.0
+                   tempy2l = 0.0
+                   tempz2l = 0.0
+                   if (solver_type == 3) then
+                      b_tempx2l = 0.0
+                      b_tempy2l = 0.0
+                      b_tempz2l = 0.0
+                   endif
+                   do k = 1,NGLLZ
+                      fac2 = wzgll(k)*hprime_zz(j,k)
+                      tempx2l = tempx2l + tempx2(i,k)*fac2
+                      tempy2l = tempy2l + tempy2(i,k)*fac2
+                      tempz2l = tempz2l + tempz2(i,k)*fac2 
+                      if (solver_type == 3) then
+                         b_tempx2l = b_tempx2l + b_tempx2(i,k)*fac2
+                         b_tempy2l = b_tempy2l + b_tempy2(i,k)*fac2
+                         b_tempz2l = b_tempz2l + b_tempz2(i,k)*fac2 
+                      endif
+                   end do
+
+                   fac1 = wzgll(j)
+                   fac2 = wxgll(i)
+
+                   ! key computation
+                   iglob = ibool(i,j,ispec)
+                   accel(1,iglob) = accel(1,iglob) - (fac1*tempx1l + fac2*tempx2l)
+                   accel(2,iglob) = accel(2,iglob) - (fac1*tempy1l + fac2*tempy2l)
+                   accel(3,iglob) = accel(3,iglob) - (fac1*tempz1l + fac2*tempz2l)
+
+                   if (solver_type == 3) then
+                      b_accel(1,iglob) = b_accel(1,iglob) - (fac1* b_tempx1l + fac2* b_tempx2l)
+                      b_accel(2,iglob) = b_accel(2,iglob) - (fac1* b_tempy1l + fac2* b_tempy2l)
+                      b_accel(3,iglob) = b_accel(3,iglob) - (fac1* b_tempz1l + fac2* b_tempz2l)
+                   endif
+
+                end do ! second loop over the GLL points
+             end do
+
+          end do ! end loop over all spectral elements
+
+          !
+          ! boundary conditions
+          !
+          ! forward propagation
+
+          !do ibb = 1, 3
+          do ibb = 1,NABSORB  ! index of grid boundary (CHT)
+             if (ibb == 1) then
+                i = 1; nx = -1.0; nz = 0.0
+             elseif (ibb == 2) then
+                i = NGLLX; nx = 1.0; nz = 0.0
+             elseif (ibb == 3) then
+                i = 1; nx = 0.0; nz = -1.0
+             elseif (ibb == 4) then       ! CHT
+                i = NGLLZ; nx = 0.0; nz = 1.0
+             endif
+
+             do ib = 1,nspecb(ibb)     ! elements on each grid boundary
+                ispec = ibelm(ibb,ib)  ! (global) index of boundary element
+
+                if (ibb == 1 .or. ibb == 2) then ! left or right boundary element
+                   j1 = 1; j2 = NGLLZ
+                else if (ib == 1) then           ! top left corner element
+                   j1 = 2; j2 = NGLLX 
+                else if (ib == nspecb(ibb)) then ! top right corner element
+                   j1 = 1; j2 = NGLLX-1  
+                else                             ! top or bottom boundary (excluding corner elements)
+                   j1 = 1; j2 = NGLLX
+                endif
+
+                do j = j1, j2
+                   if (ibb == 1 .or. ibb == 2) then  ! left or right boundary
+                      iglob = ibool(i,j,ispec)
+                      rho_vp = dsqrt(rho(i,j,ispec)*(kappa(i,j,ispec)+FOUR_THIRDS*mu(i,j,ispec)))
+                      rho_vs = dsqrt(rho(i,j,ispec)*mu(i,j,ispec))
+                   else                              ! top or bottom boundary
+                      iglob = ibool(j,i,ispec)
+                      rho_vp = dsqrt(rho(j,i,ispec)*(kappa(j,i,ispec)+FOUR_THIRDS*mu(j,i,ispec)))
+                      rho_vs = dsqrt(rho(j,i,ispec)*mu(j,i,ispec))
+                   endif
+
+                   vx = veloc(1,iglob)
+                   vy = veloc(2,iglob)
+                   vz = veloc(3,iglob)
+
+                   vn = nx*vx+nz*vz
+
+                   tx = rho_vp*vn*nx+rho_vs*(vx-vn*nx)
+                   ty = rho_vs*vy
+                   tz = rho_vp*vn*nz+rho_vs*(vz-vn*nz)
+
+                   weight = jacobianb(ibb,j,ib)*wzgll(j)
+
+                   accel(1,iglob) = accel(1,iglob) - tx*weight
+                   accel(2,iglob) = accel(2,iglob) - ty*weight
+                   accel(3,iglob) = accel(3,iglob) - tz*weight
+                   if (save_forward) then
+                      absorbfield(itime,1,j,ib,ibb) = tx*weight
+                      absorbfield(itime,2,j,ib,ibb) = ty*weight
+                      absorbfield(itime,3,j,ib,ibb) = tz*weight
+                   endif
+                end do
+             end do
+          enddo
+
+       endif  ! NCOMP
+
+       ! backward propogation boundary condition
+       if (solver_type == 3) then
+          do ibb = 1,NABSORB     ! CHT : add 4th boundary
+             if (ibb == 1) then
+                i = 1
+             elseif (ibb == 2) then
+                i = NGLLX
+             elseif (ibb == 3) then
+                i = 1
+             elseif (ibb == 4) then
+                i = NGLLZ
+             end if
+
+             ! see comments above
+             do ib = 1,nspecb(ibb)
+                if (ibb == 1 .or. ibb == 2) then
+                   j1 = 1; j2 = NGLLZ
+                elseif (ib == 1) then
+                   j1 = 2; j2 = NGLLX 
+                elseif (ib == nspecb(ibb)) then
+                   j1 = 1; j2 = NGLLX-1  
+                else
+                   j1 = 1; j2 = NGLLX
+                endif
+                ispec = ibelm(ibb,ib)
+                do j = j1, j2
+                   if (ibb == 1 .or. ibb == 2) then
+                      iglob = ibool(i,j,ispec)
+                   else
+                      iglob = ibool(j,i,ispec)
+                   endif
+                   b_accel(:,iglob) = b_accel(:,iglob) - absorbfield(NSTEP-itime+1,:,j,ib,ibb)
+                enddo
+             enddo
+          enddo
+       endif
+
+       ! KEY: add source
+       if (solver_type == 1) then
+          ! forward wavefield
+          do isrc = 1,nsrc
+
+             ! perform the general interpolation using Lagrange polynomials -- NEW METHOD
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+                   iglob = ibool(i,j,ispec_src(isrc))
+                   hlagrange = hxis_store(isrc,i) * hgammas_store(isrc,j)
+
+                   accel(:,iglob) = accel(:,iglob) + samp(itime,:,isrc)*hlagrange
+                enddo
+             enddo
+
+             ! take the value at the closest gridpoint -- OLD METHOD
+             !iglob = sglob(isrc)
+             !accel(:,iglob) = accel(:,iglob) + samp(itime,:,isrc) 
+
+          enddo  ! isrc
+
+       else
+          ! adjoint wavefield
+          do irec = 1,nrec
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+                   iglob = ibool(i,j,ispec_rec(irec))
+                   hlagrange = hxir_store(irec,i) * hgammar_store(irec,j)
+
+                   accel(:,iglob) = accel(:,iglob) + ramp(NSTEP-itime+1,:,irec)*hlagrange
+                enddo
+             enddo
+             !iglob = rglob(irec)
+             !accel(:,iglob) = accel(:,iglob) + ramp(NSTEP-itime+1,:,irec) 
+          enddo
+
+          ! forward wavefield, but computed in reverse
+          if (solver_type == 3) then
+             do isrc = 1,nsrc
+                do j = 1,NGLLZ
+                   do i = 1,NGLLX
+                      iglob = ibool(i,j,ispec_src(isrc))
+                      hlagrange = hxis_store(isrc,i) * hgammas_store(isrc,j)
+
+                      !b_accel(:,iglob) = b_accel(:,iglob) + samp(NSTEP-itime+1,:,isrc)*hlagrange
+                      b_accel(:,iglob) = b_accel(:,iglob) + stf_for(NSTEP-itime+1,:,isrc)*hlagrange
+                   enddo
+                enddo
+                !iglob = sglob(isrc)
+                !b_accel(:,iglob) = b_accel(:,iglob) + samp(NSTEP-itime+1,:,isrc) 
+             enddo
+          endif
+
+       endif
+
+       ! above here, accel(:) are actually the RHS!
+       ! divide by the mass matrix
+       do i = 1,NGLOB
+          accel(:,i) = accel(:,i)/mass_global(i)
+
+          if(solver_type == 3) &
+               b_accel(:,i) = b_accel(:,i)/mass_global(i)
+       enddo
+
+       ! `corrector' update velocity
+       do i = 1,NCOMP
+          veloc(i,:) = veloc(i,:) + deltatover2*accel(i,:)
+          if (solver_type == 3) then
+             b_veloc(i,:) = b_veloc(i,:) + b_deltatover2 * b_accel(i,:)
+          endif
+       enddo
+
+       !--------------------------------
+       ! save this time-step into seismograms and/or calculate kernels
+       ! NEW METHOD -- perform the general interpolation using Lagrange polynomials
+       ! OLD METHOD -- closest gridpoint
+
+       if (solver_type == 1) then         ! forward seismograms
+
+          do irec = 1,nrec
+
+             ! perform the general interpolation using Lagrange polynomials -- NEW METHOD
+             do j = 1,NGLLZ
+                do i = 1,NGLLX
+                   iglob = ibool(i,j,ispec_rec(irec))
+                   hlagrange = hxir_store(irec,i) * hgammar_store(irec,j)
+
+                   ! equivalent to using closest gridpoint -- OLD METHOD
+                   !hlagrange = 0.0
+                   !if(iglob == rglob(irec)) hlagrange = 1.0
+
+                   ramp(itime,:,irec) = ramp(itime,:,irec) + displ(:,iglob)*hlagrange
+                enddo
+             enddo
+
+             ! take the value at the closest gridpoint -- OLD METHOD
+             !ramp(itime,:,irec) = displ(:,rglob(irec))
+
+          enddo  ! irec
+
+       elseif (solver_type == 2 .or. solver_type == 3) then
+
+          ! ADJOINT SEISMOGRAMS (adjoint wavefield recorded at the original source)
+          ! These are needed for the source (and joint) inversions.
+          ! note that samp above is copied to stf_for
+          ! We fill the record 'in reverse' so that the max arrival will coincide
+          ! with the forward source time function pulse.
+          
+          do isrc = 1,nsrc
+             do icomp = 1,NCOMP
+
+                ! NOTE: these values depend on the component
+                temp1 = 0.0; temp2 = 0.0 ; temp3 = 0.0
+
+                ! INTERPOLATE to obtain the function value at the exact source location;
+                ! this requires looping over all GLL points within the element containing the source
+                do j = 1,NGLLZ
+                   do i = 1,NGLLX
+                      ! only finds the GLL points of the element containing the source
+                      iglob = ibool(i,j,ispec_src(isrc))
+
+                      hlagrange = hxis_store(isrc,i) * hgammas_store(isrc,j)
+
+                      ! KEY: interpolation to get exact source location values
+                      !temp1 = temp1 + displ(icomp,iglob)*hlagrange    ! sydag
+                      !temp2 = temp2 + displ_grad(i,j,3)*hlagrange     ! d/dx(sydag)
+                      !temp3 = temp3 + displ_grad(i,j,4)*hlagrange     ! d/dz(sydag)
+                      temp1 = temp1 + displ(icomp,iglob)*hlagrange           ! sxdag, sydag, szdag
+                      temp2 = temp2 + displ_grad(i,j,2*icomp - 1)*hlagrange    ! d/dx(sdag)
+                      temp3 = temp3 + displ_grad(i,j,2*icomp    )*hlagrange    ! d/dz(sdag)
+                   enddo
+                enddo
+
+                !samp(NSTEP-itime+1,:,isrc) = displ(:,sglob(isrc))
+
+                ! adjoint (displacement) seismograms (time-reversed)
+                samp(NSTEP-itime+1,icomp,isrc) = temp1
+
+                ! source perturbation TIME SERIES (3 x NCOMP time series)
+                ! NOTE the ordering: dxs, dzs, dts
+                three_source_model(NSTEP-itime+1,icomp,nsrc,1) = -temp1 * f0(icomp) * stf_syn_dt(NSTEP-itime+1) ! dts
+                three_source_model(NSTEP-itime+1,icomp,nsrc,2) =  temp2 * f0(icomp) * stf_syn(NSTEP-itime+1)    ! dxs
+                three_source_model(NSTEP-itime+1,icomp,nsrc,3) =  temp3 * f0(icomp) * stf_syn(NSTEP-itime+1)    ! dzs
+
+                ! DEBUG ARRAY SIZES
+                ! additional time series for checking
+                if(0==1) then
+                   three_source_model(NSTEP-itime+1,icomp,nsrc,4) = temp1
+                   three_source_model(NSTEP-itime+1,icomp,nsrc,5) = temp2
+                   three_source_model(NSTEP-itime+1,icomp,nsrc,6) = temp3
+                   three_source_model(itime,icomp,nsrc,7) = stf_syn_dt(itime)
+                   three_source_model(itime,icomp,nsrc,8) = stf_syn(itime)
+                   three_source_model(itime,icomp,nsrc,9) = f0(icomp) * stf_syn(itime)
+                endif
+
+             enddo  ! icomp
+          enddo  ! isrc
+
+          if(solver_type==3) then
+
+             ! CALCULATE ALL NINE KERNELS
+             !   note the TIME INTEGRATION
+             !   note the minus sign in these expressions (Tromp-Tape-Liu, 2005)
+
+             do ispec = 1,NSPEC
+                do j = 1,NGLLZ
+                   do i = 1,NGLLX 
+                      iglob = ibool(i,j,ispec)
+
+                      ! kappa-mu-rho -- THESE ARE THE TWO KERNELS FOR AN ISOTROPIC ELASTIC MEDIUM, PLUS DENSITY
+                      kappa_mu_rho_kernel(i,j,ispec) = kappa_mu_rho_kernel(i,j,ispec) - &
+                           kappa(i,j,ispec) * kappa_k(i,j,ispec) * DT
+                      mu_kappa_rho_kernel(i,j,ispec) = mu_kappa_rho_kernel(i,j,ispec) - &
+                           2.0 * mu(i,j,ispec) * mu_k(i,j,ispec) * DT
+                      rho_kappa_mu_kernel(i,j,ispec) = rho_kappa_mu_kernel(i,j,ispec) - &
+                           rho(i,j,ispec) * dot_product(accel(:,iglob),b_displ(:,iglob)) * DT
+
+                      ! alpha-beta-rho (derived from kappa-mu-rho kernels)
+                      alpha_beta_rho_kernel(i,j,ispec) = 2.0 * (1.0 + FOUR_THIRDS*mu(i,j,ispec)/kappa(i,j,ispec)) * kappa_mu_rho_kernel(i,j,ispec)
+                      beta_alpha_rho_kernel(i,j,ispec) = 2.0 * mu_kappa_rho_kernel(i,j,ispec) - &
+                          2.0 * FOUR_THIRDS * mu(i,j,ispec)/kappa(i,j,ispec) * kappa_mu_rho_kernel(i,j,ispec)
+                      rho_alpha_beta_kernel(i,j,ispec) = rho_kappa_mu_kernel(i,j,ispec) + kappa_mu_rho_kernel(i,j,ispec) + mu_kappa_rho_kernel(i,j,ispec)
+
+                      ! c-beta-rho (derived from kappa-mu-rho kernels)
+                      c_beta_rho_kernel(i,j,ispec) = 2.0 * kappa_mu_rho_kernel(i,j,ispec)
+                      beta_c_rho_kernel(i,j,ispec) = 2.0 * mu_kappa_rho_kernel(i,j,ispec)
+                      rho_c_beta_kernel(i,j,ispec) = rho_kappa_mu_kernel(i,j,ispec) + kappa_mu_rho_kernel(i,j,ispec) + mu_kappa_rho_kernel(i,j,ispec)
+
+                      ! interaction fields -- each is integrated to form a kernel
+                      if(WRITE_KERNEL_SNAPSHOTS) then
+                         ! kappa-mu-rho
+                         kappa_mu_rho_kernel_int(i,j,ispec) = -kappa(i,j,ispec) * kappa_k(i,j,ispec)
+                         mu_kappa_rho_kernel_int(i,j,ispec) = -2.0*mu(i,j,ispec) * mu_k(i,j,ispec)
+                         rho_kappa_mu_kernel_int(i,j,ispec) = -rho(i,j,ispec) * dot_product(accel(:,iglob),b_displ(:,iglob))
+
+                         ! alpha-beta-rho (derived from kappa-mu-rho interaction fields)
+                         alpha_beta_rho_kernel_int(i,j,ispec) = 2.0 * (1.0 + FOUR_THIRDS*mu(i,j,ispec)/kappa(i,j,ispec)) * kappa_mu_rho_kernel_int(i,j,ispec)
+                         beta_alpha_rho_kernel_int(i,j,ispec) = 2.0 * mu_kappa_rho_kernel_int(i,j,ispec) - &
+                              2.0 * FOUR_THIRDS * mu(i,j,ispec)/kappa(i,j,ispec) * kappa_mu_rho_kernel_int(i,j,ispec)
+                         rho_kappa_mu_kernel_int(i,j,ispec)   = kappa_mu_rho_kernel_int(i,j,ispec) + &
+                              mu_kappa_rho_kernel_int(i,j,ispec) + rho_kappa_mu_kernel_int(i,j,ispec)
+
+                         ! c-beta-rho (derived from kappa-mu-rho interaction fields)
+                         c_beta_rho_kernel_int(i,j,ispec) = 2.0 * kappa_mu_rho_kernel_int(i,j,ispec)
+                         beta_c_rho_kernel_int(i,j,ispec) = 2.0 * mu_kappa_rho_kernel_int(i,j,ispec)
+                         rho_c_beta_kernel_int(i,j,ispec) = rho_kappa_mu_kernel_int(i,j,ispec) + &
+                              kappa_mu_rho_kernel_int(i,j,ispec) + mu_kappa_rho_kernel_int(i,j,ispec)
+                      endif  ! WRITE_KERNEL_SNAPSHOTS
+
+                   enddo
+                enddo
+             enddo
+
+          endif  ! solver_type = 3
+       endif  ! solver_type = 2 or 3
+
+       ! save FINAL SNAPSHOT
+       if (mod(itime, NSAVE) == 0) then      
+
+          if (save_forward) then
+             open(11,file = trim(last_frame),status='unknown',iostat=ios)
+             if (ios /= 0) stop 'Error reading the last frame'
+             do i = 1,NGLOB
+                write(11,fm) (sngl(displ(j,i)), j = 1,NCOMP), & 
+                     (sngl(veloc(j,i)), j = 1,NCOMP), &
+                     (sngl(accel(j,i)), j = 1,NCOMP)
+             enddo
+             close(11)
+          endif
+       endif
+
+       !===================================
+
+       ! write snapshots or kernels
+       if (itime == 1 .or. mod(itime, NSAVE) == 0) then   ! save the initial frame
+          if (itime == 1) tlab = 0
+          if (itime /= 1) tlab = itime
+          !if (mod(itime, NSAVE) == 0) then
+          if (solver_type == 1) then
+             if(idata==0) write(filename1,'(a,i5.5)') trim(out_dir)//'forward_syn_',tlab
+             if(idata==1) write(filename1,'(a,i5.5)') trim(out_dir)//'forward_dat_',tlab
+          elseif (solver_type == 2) then
+             write(filename1,'(a,i5.5)') trim(out_dir)//'adjoint_',tlab
+          else
+             write(filename1,'(a,i5.5)') trim(out_dir)//'adjoint_',tlab      ! adjoint wavefield
+             write(filename2,'(a,i5.5)') trim(out_dir)//'backward_',tlab
+             write(filename3,'(a,i5.5)') trim(out_dir)//'kernel_kmr_',tlab      ! kernels for kappa-mu-rho
+             write(filename4,'(a,i5.5)') trim(out_dir)//'kernel_abr_',tlab      ! kernels for alpha-beta-rho
+             write(filename5,'(a,i5.5)') trim(out_dir)//'kernel_cbr_',tlab      ! kernels for c-beta-rho
+             !write(filename6,'(a,i5.5)') trim(out_dir)//'interaction_',tlab  ! interaction
+          endif
+
+          if(WRITE_WAVFIELD_SNAPSHOTS) then      ! wavefield snapshots (globally defined)
+             open(unit=11, file=trim(filename1), status='unknown', iostat=ios)
+             if (ios /= 0) stop 'Error writing snapshot to disk'
+             do iglob = 1, NGLOB
+                write(11,'(5e16.6)') sngl(x_plot(iglob)), sngl(z_plot(iglob)), (sngl(displ(j,iglob)),j=1,NCOMP) 
+             enddo
+             close(11)
+          endif
+
+          if(WRITE_KERNEL_SNAPSHOTS) then        ! kernel snapshots (LOCALLY defined)
+             if(solver_type == 3) then
+                open(unit=11, file=trim(filename2), status='unknown', iostat=ios)
+                if (ios /= 0) stop 'Error writing snapshot to disk'
+                do iglob = 1, NGLOB
+                   write(11,'(5e16.6)') sngl(x_plot(iglob)), sngl(z_plot(iglob)), (sngl(b_displ(j,iglob)),j=1,NCOMP) 
+                enddo
+                close(11)
+
+                open(unit = 11, file = trim(filename3), status = 'unknown',iostat=ios)
+                open(unit = 12, file = trim(filename4), status = 'unknown',iostat=ios)
+                open(unit = 13, file = trim(filename5), status = 'unknown',iostat=ios)
+                !if (ios /= 0) stop 'Error writing snapshot to disk'
+
+                do ispec = 1,NSPEC
+                   do j = 1,NGLLZ
+                      do i = 1,NGLLX 
+                         iglob = ibool(i,j,ispec)
+
+                         ! kappa-mu-rho : three kernels and three interaction fields
+                         write(11,'(8e16.6)') sngl(x_plot(iglob)), sngl(z_plot(iglob)), &
+                              sngl(kappa_mu_rho_kernel(i,j,ispec)), &
+                              sngl(mu_kappa_rho_kernel(i,j,ispec)), &
+                              sngl(rho_kappa_mu_kernel(i,j,ispec)), &
+                              sngl(kappa_mu_rho_kernel_int(i,j,ispec)), &
+                              sngl(mu_kappa_rho_kernel_int(i,j,ispec)), &
+                              sngl(rho_kappa_mu_kernel_int(i,j,ispec))
+
+                         ! alpha-beta-rho : three kernels and three interaction fields
+                         write(12,'(8e16.6)') sngl(x_plot(iglob)), sngl(z_plot(iglob)), &
+                              sngl(alpha_beta_rho_kernel(i,j,ispec)), &
+                              sngl(beta_alpha_rho_kernel(i,j,ispec)), &
+                              sngl(rho_alpha_beta_kernel(i,j,ispec)), &
+                              sngl(alpha_beta_rho_kernel_int(i,j,ispec)), &
+                              sngl(beta_alpha_rho_kernel_int(i,j,ispec)), &
+                              sngl(rho_alpha_beta_kernel_int(i,j,ispec))
+
+                         ! c-beta-rho : three kernels and three interaction fields
+                         write(13,'(8e16.6)') sngl(x_plot(iglob)), sngl(z_plot(iglob)), &
+                              sngl(c_beta_rho_kernel(i,j,ispec)), &
+                              sngl(beta_c_rho_kernel(i,j,ispec)), &
+                              sngl(rho_c_beta_kernel(i,j,ispec)), &
+                              sngl(c_beta_rho_kernel_int(i,j,ispec)), &
+                              sngl(beta_c_rho_kernel_int(i,j,ispec)), &
+                              sngl(rho_c_beta_kernel_int(i,j,ispec))
+                   enddo
+                enddo
+             enddo
+             close(11) ; close(12) ; close(13)
+
+             endif  ! solver_type == 3
+          endif  ! WRITE_KERNEL_SNAPSHOTS
+
+       endif  ! write snapshots or kernels
+
+       ! stop if wavefield contains NaN (13-Aug-2006)
+       !do i=1,ncomp
+       !   do j=1,nglob
+       !      if( isnan(displ(i,j)) ) stop 'exiting: encountered NaN in solver.f90'
+       !   enddo
+       !enddo
+
+    enddo ! end time loop
+
+    !-------------------------------------
+
+    ! KERNELS at the FINAL TIME STEP
+    if (solver_type == 3) then
+
+       ! write out all nine kernels
+       ! (Using local2global is a bit safer.)
+       if(WRITE_KERNELS) then
+          filename5 = trim(out_dir)//'kernel_basis'
+          open(unit = 13, file = trim(filename5), status = 'unknown',iostat=ios) 
+          if (ios /= 0) stop 'Error writing all nine kernels to disk'
+          do ispec = 1,NSPEC
+             do j = 1,NGLLZ
+                do i = 1,NGLLX 
+                   iglob = ibool(i,j,ispec)
+
+                   ! x, z, -- kappa, mu, rho -- alpha, beta, rho -- c, beta rho
+                   write(13,'(11e16.6)') sngl(x_plot(iglob)), sngl(z_plot(iglob)), &
+                        sngl(kappa_mu_rho_kernel(i,j,ispec)), &
+                        sngl(mu_kappa_rho_kernel(i,j,ispec)), &
+                        sngl(rho_kappa_mu_kernel(i,j,ispec)), &
+                        sngl(alpha_beta_rho_kernel(i,j,ispec)), &
+                        sngl(beta_alpha_rho_kernel(i,j,ispec)), &
+                        sngl(rho_alpha_beta_kernel(i,j,ispec)), &
+                        sngl(c_beta_rho_kernel(i,j,ispec)), &
+                        sngl(beta_c_rho_kernel(i,j,ispec)), &
+                        sngl(rho_c_beta_kernel(i,j,ispec))
+                enddo
+             enddo
+          enddo
+          close(13)
+       endif
+
+       ! assign kernels for the inversion
+       if (STRUCTURE_PARAMETER_TYPE == 1) then
+          atype_kernel = kappa_mu_rho_kernel
+          btype_kernel = mu_kappa_rho_kernel
+          rtype_kernel = rho_kappa_mu_kernel
+
+       elseif (STRUCTURE_PARAMETER_TYPE == 2) then
+          atype_kernel = alpha_beta_rho_kernel
+          btype_kernel = beta_alpha_rho_kernel
+          rtype_kernel = rho_alpha_beta_kernel
+
+       elseif (STRUCTURE_PARAMETER_TYPE == 3) then
+          atype_kernel = c_beta_rho_kernel
+          btype_kernel = beta_c_rho_kernel
+          rtype_kernel = rho_c_beta_kernel
+       endif
+
+       ! deallocate variables for kernels
+       deallocate(stf_for)
+       deallocate(kappa_mu_rho_kernel, mu_kappa_rho_kernel, rho_kappa_mu_kernel)
+       deallocate(alpha_beta_rho_kernel, beta_alpha_rho_kernel, rho_alpha_beta_kernel)
+       deallocate(c_beta_rho_kernel, beta_c_rho_kernel, rho_c_beta_kernel)
+
+       ! deallocate interaction fields
+       if(WRITE_KERNEL_SNAPSHOTS) then
+          deallocate(kappa_mu_rho_kernel_int, mu_kappa_rho_kernel_int, rho_kappa_mu_kernel_int)
+          deallocate(alpha_beta_rho_kernel_int, beta_alpha_rho_kernel_int, rho_alpha_beta_kernel_int)
+          deallocate(c_beta_rho_kernel_int, beta_c_rho_kernel_int, rho_c_beta_kernel_int)
+       endif
+
+    endif
+
+  end subroutine solver
+  !---------------------------------------------
+
+end module wave2d_solver

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,1031 @@
+module wave2d_sub
+
+  use wave2d_constants
+  use wave2d_variables
+
+  implicit none
+
+contains
+
+  !-----------------------------------------------------  
+  
+  subroutine write_parameters(filename)
+
+    character(len=*),intent(in) :: filename
+
+    print *, 'writing out parameters'
+
+    open(unit=12, file=filename, status='unknown')
+
+    write(12,'(3i10)')   0,NSTEP,NSAVE
+    write(12,'(3i10)')   FOR_X, FOR_Y, FOR_Z 
+    write(12,'(1f16.8)') DT
+    write(12,'(1f16.8)') hdur
+    close(12)
+
+  end subroutine write_parameters
+
+  !-----------------------------------------------------  
+
+  subroutine write_chi(dir,nevent,nrec)
+
+    ! Following the simulations for the event kernel, we have chi_data(nevent,nrec,NCOMP,nsrc).
+    ! Here we write out various versions of this.
+
+    integer, intent(in) :: nevent, nrec
+    integer :: ievent, irec, icomp
+    character(len=200) :: dir, filename
+
+    print *, 'writing out chi_data(nevent,nrec,NCOMP,nsrc) to various files...'
+    print *, '  nevent = ', nevent
+    print *, '    nrec = ', nrec
+    print *, '   NCOMP = ', NCOMP
+    print *, '    nsrc = ', 1
+
+    ! all chi_data values
+    open(19,file=trim(dir)//'chi_all.dat',status='unknown')
+    do ievent = 1,nevent
+       do irec = 1,nrec
+          do icomp = 1,NCOMP
+             write(19,'(3i8,1e20.10)') ievent, irec, icomp, chi_data(ievent,irec,icomp,1)
+          enddo
+       enddo
+    enddo
+    close(19)
+
+    ! summed chi_data value for each event (nevent by 1)
+    open(19,file=trim(dir)//'summed_chi_e.dat',status='unknown')
+    do ievent = 1,nevent
+       write(19,'(1f20.10)') sum(chi_data(ievent,:,:,1))
+    enddo
+    close(19)
+
+    ! summed chi_data value for each receiver (nrec by 1)
+    open(19,file=trim(dir)//'summed_chi_r.dat',status='unknown')
+    do irec = 1,nrec
+       write(19,'(1f20.10)') sum(chi_data(:,irec,:,1))
+    enddo
+    close(19)
+
+    ! summed chi_data value for each component (NCOMP by 1)
+    open(19,file=trim(dir)//'summed_chi_c.dat',status='unknown')
+    do icomp = 1,NCOMP
+       write(19,'(1f20.10)') sum(chi_data(:,:,icomp,1))
+    enddo
+    close(19)
+
+    ! WRITE OUT GLOBAL VARIABLES
+
+!!$    open(19,file=trim(dir)//'chi_model_norm_target.dat',status='unknown')
+!!$    write(19,'(1f20.10)') chi_model_norm_target
+!!$    close(19)
+!!$
+!!$    open(19,file=trim(dir)//'chi_model_stop.dat',status='unknown')
+!!$    write(19,'(1f20.10)') chi_model_stop
+!!$    close(19)
+
+    open(19,file=trim(dir)//'chi_data_stop.dat',status='unknown')
+    write(19,'(1f20.10)') chi_data_stop
+    close(19)
+
+    open(19,file=trim(dir)//'chi_model_norm.dat',status='unknown')
+    write(19,'(1f20.10)') model_norm
+    close(19)
+
+    open(19,file=trim(dir)//'chi_data_norm.dat',status='unknown')
+    write(19,'(1f20.10)') data_norm
+    close(19)
+
+    open(19,file=trim(dir)//'chi.dat',status='unknown')
+    write(19,'(1f20.10)') chi_val
+    close(19)
+
+    print *, ' Done writing chi values to files'
+
+  end subroutine write_chi
+
+  !-----------------------------------------------------  
+
+!!$  subroutine get_source_function(nsrc,origin_time,f0,samp,ti)
+!!$
+!!$  ! compute the source time function for each source
+!!$  ! in general, we use a point source
+!!$  ! note that we do not need to know WHERE the source is located
+!!$
+!!$    ! input
+!!$    integer, intent(in) :: nsrc
+!!$    double precision, intent(in) :: f0(NCOMP)
+!!$    double precision, intent(in) :: origin_time
+!!$
+!!$    double precision, intent(inout) :: samp(NSTEP,NCOMP,nsrc)
+!!$    double precision, intent(out) :: ti(NSTEP)
+!!$    integer :: i,icomp
+!!$
+!!$  ! fill each source index with the source time function
+!!$  ! multiplied by the magnitude and direction of the source
+!!$  do i = 1,nsrc
+!!$    do icomp = 1,NCOMP
+!!$       samp(:, icomp, i) = stf(:) * f0(icomp)
+!!$    enddo
+!!$  enddo
+!!$
+!!$  end subroutine get_source_function
+
+  !-----------------------------------------------------  
+
+  subroutine get_source_time_function(origin_time,stf_vec,ti)
+
+  ! compute the source time function for each source
+  ! in general, we use a point source
+  ! note that we do not need to know WHERE the source is located
+
+    double precision, intent(in) :: origin_time
+    double precision, intent(out) :: ti(NSTEP), stf_vec(NSTEP)
+
+    ! source decay rate (also change in source spectrum if needed)
+    double precision, parameter :: decay_rate = 2.628
+    !double precision, external :: erf
+
+    integer :: itime,i,icomp,nsrc_plot
+    double precision :: alpha, per, t, t1, t2, amp, stf, fgaus, dgaus, tmp, cyc
+    double precision :: az,kx,ky,c_source
+    double precision, dimension(:), allocatable :: d_vec
+    character(len=200) :: filename
+
+!-------------------------------------
+
+  print *
+  print *, 'compute the forward source time function in get_source_time_function.f90'
+  print *, 'hdur = ',sngl(hdur),' s, ISRC_TIME = ', ISRC_TIME
+  print *, 'origin time is = ', sngl(origin_time),' s'
+
+  ! parameters for source time function
+  ! the non-zero Gaussian is needed for plotting the source time function (perl)
+  alpha = decay_rate/hdur
+  fgaus = 1.0d-8                  ! fraction of amplitude at edge of gaussian
+  dgaus = sqrt(-log(fgaus)) / alpha
+
+  if(ISRC_TIME==1) then ! Ricker
+     amp = -2.0*(alpha**3)/dsqrt(PI)
+
+  elseif(ISRC_TIME==2) then ! Gaussian
+     amp = alpha/dsqrt(PI)
+
+  elseif(ISRC_TIME==3) then ! truncated sine
+     cyc = 3.0
+     per = 2.*hdur
+     !t1 = -0.50*per
+     t1 = 0.0
+     t2 = t1 + per*cyc
+     amp = alpha**2.0*dsqrt(2.0/PI)*exp(-0.5)
+
+  elseif(ISRC_TIME==4) then ! sine
+     per = 2.0*hdur
+     amp = alpha**2.0*dsqrt(2.0/PI)*exp(-0.5)
+
+!!$  elseif(ISRC_TIME==5) then ! plane wave field
+!!$
+!!$     amp = alpha**2*dsqrt(2./PI)*exp(-0.5)   ! amplitude
+!!$     az = 25.*PI/180.0                          ! azimuth of vector (from north)
+!!$     kx = sin(az) ; ky = cos(az)               ! directional unit vector k
+!!$     per = 2.*hdur                             ! period of wavefield (s)
+!!$
+!!$     ! phase velocity of source wavefield (m/s)
+!!$     ! NOTE: this signal will be ALIASED if the wavelength is too short
+!!$     ! this is based on the Airy dispersion for gravity waves (Bromirski+Duennebier, 5-3)
+!!$     ! probably the speed should be based on the slope of the seafloor
+!!$     !c_source = 9.81*per/(2*PI)  ! T=16s, c=25 m/s
+!!$     c_source = c0
+!!$   
+!!$     ! projection of each source point vector onto the directional vector k
+!!$     allocate(d_vec(nsrc))
+!!$     d_vec(:) = 0.0
+!!$     print *
+!!$     print *, 'Plane wave source:'
+!!$     print *, '   azimuth        : ', sngl(az*180/PI)
+!!$     print *, '   period         : ', sngl(per), ' s'
+!!$     print *, '   phase velocity : ', sngl(c_source/1000.0), ' km/s'
+!!$     print *, '   wavelength     : ', sngl(c_source*per/1000.0), ' km'
+!!$     print *, 'relative distance from plane wave wavefront to each source point:' 
+!!$     do i=1,nsrc
+!!$        d_vec(i) = kx*x(sglob(i)) + ky*z(sglob(i))
+!!$        write(*,'(i6,3f12.3)') i, x(sglob(i))/1000.0, z(sglob(i))/1000.0, d_vec(i)/1000.0
+!!$     enddo
+!!$     print *
+  endif
+
+    do itime = 1, NSTEP
+       ti(itime) = dble(itime-1)*DT
+
+       t = ti(itime) - origin_time  ! time shift
+    
+       if(ISRC_TIME==1) then
+          ! d/dt[Gaussian] wavelet
+          if(t >= -dgaus .and. t <= dgaus) then
+             stf = amp*t*exp(-alpha*alpha*t*t)
+          else
+             stf = 0.0
+          endif
+
+       elseif(ISRC_TIME==2) then
+          ! Error function
+          ! source_time_function = 0.5*(1.0+erf(decay_rate*t/hdur))
+
+          ! Gaussian (this one causes static offset at stations)
+          if(t >= -dgaus .and. t <= dgaus) then
+             stf = amp*exp(-alpha*alpha*t*t)
+          else
+             stf = 0.0
+          endif
+
+       elseif(ISRC_TIME==3) then
+          ! truncated sine function (duration is cyc*per seconds)
+          if(t >= t1 .and. t <= t2) then
+             stf = amp*sin(2.0*PI*(t-t1)/per)
+          else
+             stf = 0.0
+          endif
+
+       elseif(ISRC_TIME==4) then
+          ! sine function
+          stf = amp*sin(2*PI*t/per)
+          !stf = amp/2.*sin(2*PI*t/per) + amp/2.*sin(2*PI*t/(1.1*per))
+
+       !elseif(ISRC_TIME==5) then
+       !   ! plane wavefield, dependant on source position
+       !   tmp = t - d_vec(i)/c_source
+       !   !stf = amp*sin( 2*PI/per*tmp )
+       !   stf = amp/2.*sin(2*PI*tmp/per) + amp/2.*sin(2*PI*tmp/(1.1*per))
+
+       endif
+  
+       ! fill source time function
+       stf_vec(itime) = stf
+    
+    enddo
+
+
+  ! taper time series
+  ! DO WE WANT TO SIMPLY DETREND THE TIME SERIES?
+  if(SRC_TAPER) call taper_series(stf_vec(:),NSTEP)
+
+  end subroutine get_source_time_function
+
+  !-----------------------------------------------------  
+
+  subroutine taper_series(x,nt)
+
+  integer, intent(in) :: nt
+  double precision, intent(inout) :: x(nt)
+
+  double precision :: ntemp,jtemp,wtemp,cfac
+  integer :: i,pwr
+ 
+  ntemp = dble(nt)/2.0
+
+  ! KEY COMMAND: power of polynomial taper
+  ! higher power means affecting only the ends of the series
+  pwr = 10   ! Welch : pwr=2
+
+  ! Welch taper (in time)
+  do i = 1,nt
+     
+     jtemp = dble(i-1)
+     wtemp = (jtemp - ntemp) / ntemp
+     cfac = 1. - wtemp**pwr
+     !cfac = 1 - (2*(i - 1)/(nt - 1) - 1) ** pwr  ! see Qinya code below
+ 
+     x(i) = cfac*x(i)
+  enddo 
+
+  end subroutine taper_series
+
+  !-----------------------------------------------------  
+
+  subroutine write_snapshot(disp, filename)
+
+    double precision,intent(in) :: disp(NCOMP,NGLOB)
+    character(len=200),intent(in) :: filename
+
+    integer :: icomp, iglob, ios
+
+    open(unit = 11, file = trim(filename), status = 'unknown',iostat=ios)
+    if (ios /= 0) stop 'Error writing snapshot to disk'
+    do iglob = 1, NGLOB
+       ! DEBUG ARRAY SIZE
+       if(NCOMP==3) then
+          write(11,'(5e12.3)') x(iglob)/LENGTH, z(iglob)/LENGTH, &
+                  sngl(disp(1,iglob)),sngl(disp(2,iglob)),sngl(disp(3,iglob))
+       else
+          write(11,'(5e12.3)') x(iglob)/LENGTH, z(iglob)/LENGTH, sngl(disp(1,iglob))
+       endif
+    enddo
+    close(11)
+
+  end subroutine write_snapshot
+
+  !-----------------------------------------------------   
+
+!!$  subroutine write_source_function(nsrc, ti, seis, sglob, seis_name)
+!!$
+!!$    integer, intent(in) :: nsrc
+!!$    integer, intent(in) :: sglob(nsrc)
+!!$    double precision, intent(in) ::  seis(NSTEP,NCOMP,nsrc)
+!!$    double precision, intent(in) ::  ti(NSTEP)
+!!$    character(len=*),intent(in) :: seis_name
+!!$
+!!$    character(len=200) :: filename
+!!$    integer :: i,icomp,itime
+!!$
+!!$    print *, 'writing out source time function'
+!!$
+!!$   ! write out source time functions for each point source
+!!$   do i = 1,nsrc
+!!$      do icomp = 1,NCOMP
+!!$
+!!$         write(filename,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_', i, '_', icomp
+!!$
+!!$         open(12,file=filename,status='unknown')
+!!$         write(*,*) 'Source #', i, ' at ', sngl(x_lon(sglob(i))), ', ', sngl(z_lat(sglob(i)))
+!!$         do itime=1,NSTEP
+!!$            write(12,'(f16.6,e16.6)') ti(itime), seis(itime,icomp,i)
+!!$            !write(12,'(f16.6,e16.6)') ti(itime), seis(itime,icomp,nsrc)/maxval(seis(:,icomp,nsrc))
+!!$         enddo
+!!$         close(12)
+!!$      enddo
+!!$   enddo
+!!$
+!!$  end subroutine write_source_function
+
+  !-----------------------------------------------------   
+
+  subroutine write_seismogram(seis, nrec, seis_name)
+
+    integer, intent(in) :: nrec
+    double precision, intent(in) ::  seis(NSTEP,NCOMP,nrec)
+    character(len=*),intent(in) :: seis_name
+
+    character(len=200) :: filename
+    integer :: irec, icomp, itime
+
+    print *, 'writing out time series (source time function or seismogram)'
+
+    do irec = 1,nrec
+       do icomp = 1,NCOMP
+          write(filename,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_', irec, '_', icomp
+          call write_time_series(seis(:,icomp,irec), NSTEP, filename)
+!!$          open(unit = 12, file = filename, status = 'unknown', iostat=ios)
+!!$          if (ios /= 0) stop 'Error opening seismogram to write'
+!!$          do itime = 1,NSTEP
+!!$             write(12,*) DT*itime, seis(itime, icomp, irec)
+!!$          enddo
+!!$          close(12)
+
+       enddo
+    enddo
+
+  end subroutine write_seismogram
+
+  !-----------------------------------------------------   
+
+  subroutine write_time_series(fvec, tlen, filename)
+
+    integer, intent(in) :: tlen
+    double precision, intent(in) ::  fvec(tlen)
+    character(len=*),intent(in) :: filename
+    integer :: itime
+
+    open(unit=12, file=filename, status='unknown', iostat=ios)
+    if (ios /= 0) stop 'Error opening time series file to write'
+    do itime = 1,tlen
+       write(12,*) DT*itime, fvec(itime)
+    enddo
+    close(12)
+
+  end subroutine write_time_series
+
+  !-----------------------------------------------------   
+
+!!$  subroutine write_spectral_map(seis, nrec, rglob, seis_name, write_spectra)
+!!$
+!!$    integer, intent(in) :: nrec
+!!$    integer, intent(in) :: rglob(nrec)
+!!$    double precision, intent(in) ::  seis(NSTEP,NCOMP,nrec)
+!!$    character(len=*),intent(in) :: seis_name
+!!$    logical, intent(in) :: write_spectra
+!!$
+!!$    character(len=200) :: filename,filename1,filename2
+!!$    integer :: i, irec, icomp, itime
+!!$
+!!$    ! frequency domain
+!!$    integer, parameter :: FFTW_FORWARD=-1, FFTW_ESTIMATE=0
+!!$    complex*16 :: out(NOUT)
+!!$    double precision :: in(NSTEP),ti(NSTEP)
+!!$    integer :: plan
+!!$    double precision :: wmax,w,re,im,abs_val,ph_val,dw,abs_int
+!!$    double precision :: wmin_win, wmax_win
+!!$
+!!$    !------------------------------------
+!!$
+!!$    wmax = PI/DT        ! Nyquist frequency
+!!$
+!!$    ! window for computing integrated power spectrum
+!!$    ! fmin,fmax are parameters (constants.f90)
+!!$    wmin_win = 2*PI*fmin
+!!$    wmax_win = 2*PI*fmax
+!!$
+!!$    do icomp = 1,NCOMP
+!!$
+!!$       ! open spectral map file
+!!$       write(filename1,'(a,a,i1.1)') trim(seis_name), '_map_', icomp
+!!$       open(unit=99, file=filename1, status='unknown', iostat=ios)
+!!$       if (ios /= 0) stop 'Error opening spectral map file to write'
+!!$
+!!$       do irec = 1, nrec
+!!$
+!!$          ! KEY: initialize Fourier transform
+!!$          call dfftw_plan_dft_r2c_1d(plan,NSTEP,in,out,FFTW_ESTIMATE)
+!!$
+!!$          ! specify input time series
+!!$          in(:) = seis(:,icomp,irec)
+!!$
+!!$          if(0==1) then
+!!$            ! write input data to file
+!!$            write(filename,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_in_', irec, '_', icomp
+!!$            open(unit=10, file=filename, status='unknown', iostat=ios)
+!!$            if (ios /= 0) stop 'Error opening seismogram to write'
+!!$            do itime = 1,NSTEP
+!!$               write(10,'(2e16.6)') DT*itime , in(itime)
+!!$            enddo
+!!$            close(10)
+!!$          endif
+!!$
+!!$          ! KEY: Fourier transform
+!!$          call dfftw_execute(plan)
+!!$
+!!$          if(write_spectra) then
+!!$             write(filename2,'(a,a,i5.5,a,i1.1)') trim(seis_name), '_', irec, '_', icomp
+!!$             open(unit=12, file=filename2, status='unknown', iostat=ios)
+!!$             if (ios /= 0) stop 'Error opening seismogram spectra to write'
+!!$          endif
+!!$
+!!$          dw = wmax/dble(NOUT)
+!!$          abs_int = 0.0
+!!$          do i = 1,NOUT
+!!$             !w = (i-1)/dble(NOUT) * wmax
+!!$             w = (i-1)*dw
+!!$             re = real(out(i))
+!!$             im = aimag(out(i))
+!!$             abs_val = sqrt(re*re+im*im)
+!!$             !ph_val = atan2(im,re)
+!!$
+!!$             ! if within the frequency band
+!!$             if(w >= wmin_win .and. w <= wmax_win) abs_int = abs_int + abs_val
+!!$
+!!$             if(write_spectra) write(12,'(2e16.6)') w, abs_val 
+!!$             !if(write_spectra.and.w/=0.0) write(12,'(2e16.6)') (2*PI)/w, abs_val 
+!!$          enddo
+!!$          if(write_spectra) close(12)
+!!$ 
+!!$          if(0==1) then
+!!$            write(*,'(a,3f12.4)') ' T, s     (min/0/max) :', (2*PI)/wmax_win , 2*hdur        , (2*PI)/wmin_win
+!!$            write(*,'(a,3f12.4)') ' f, Hz    (min/0/max) :', wmin_win/(2*PI) , 1/(2*hdur)    , wmax_win/(2*PI)
+!!$            write(*,'(a,3f12.4)') ' w, rad/s (min/0/max) :', wmin_win        , 2*PI/(2*hdur) , wmax_win
+!!$            write(*,'(a,e24.8)')  '     integrated power :', dw*abs_int
+!!$            print * 
+!!$          endif   
+!!$
+!!$          call dfftw_destroy_plan(plan)
+!!$
+!!$          ! write the spectral amplitude to file
+!!$          write(99,'(3e16.6)') x_lon(rglob(irec)), z_lat(rglob(irec)), dw*abs_int
+!!$          !write(99,'(3e16.6)') x(rglob(irec)), z(rglob(irec)), dw*abs_int
+!!$
+!!$       enddo  ! irec
+!!$       close(99)  ! spectral map file for one component
+!!$    enddo  ! icomp
+!!$
+!!$  end subroutine write_spectral_map
+
+  !-----------------------------------------------------   
+
+!!$  subroutine filter(ti, seis, nrec)
+!!$
+!!$    integer, intent(in) :: nrec
+!!$    double precision, intent(in) :: ti(NSTEP)
+!!$    double precision, intent(inout) :: seis(NSTEP,NCOMP,nrec)
+!!$    
+!!$    character(len=200) :: filename
+!!$    double precision :: data(NSTEP)
+!!$    double precision :: dt
+!!$    integer irec,itime,icomp,npts
+!!$
+!!$    npts = NSTEP
+!!$    dt = ti(2) - ti(1)
+!!$
+!!$    do irec = 1, nrec
+!!$       do icomp = 1,NCOMP
+!!$          data(:) = 0.0
+!!$          data(:) = seis(:,icomp,irec)
+!!$
+!!$          !write(filename,'(a,i5.5,a,i1.1)') trim(out_dir)//'bpass_in_', irec, '_', icomp
+!!$          !open(unit=11, file=filename, status='unknown')
+!!$          !write(11,'(2e16.6)') (ti(itime), data(itime), itime=1,NSTEP)
+!!$          !close(11)
+!!$
+!!$          ! bandpass filter the records (see constants.f90 for parameter values)
+!!$          call rmean(data,npts)
+!!$          call rtrend(data,npts)
+!!$          call xapiir(data,npts,'BU',trbdndw,a,iord,'BP',fmin, fmax, dt, passes)
+!!$
+!!$          !write(filename,'(a,i5.5,a,i1.1)') trim(out_dir)//'bpass_out_', irec, '_', icomp
+!!$          !open(unit=12, file=filename, status='unknown')
+!!$          !write(12,'(2e16.6)') (ti(itime), data(itime), itime=1,NSTEP)
+!!$          !close(12)
+!!$
+!!$          ! replace the unfiltered record by the filtered record
+!!$          seis(:,icomp,irec) = data(:)
+!!$
+!!$       enddo
+!!$    enddo
+!!$
+!!$  end subroutine filter
+
+  !----------------------------------------------------
+
+!!$  subroutine make_adjoint_source(nrec, syn, tstart, tend, adj_syn, data)
+!!$
+!!$  integer, intent(in) :: nrec
+!!$  double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+!!$  double precision, dimension(nrec), intent(in) :: tstart, tend
+!!$  double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+!!$
+!!$  double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+!!$
+!!$  integer itime, icomp, istart, iend, nstart, nend, i, j, irec
+!!$  double precision, dimension(NSTEP) :: time_window
+!!$  double precision, dimension(NSTEP,NCOMP,nrec) :: syn_veloc, syn_accel
+!!$  double precision :: norm_mat(nrec,NCOMP)
+!!$  double precision :: norm, junk, ntemp
+!!$
+!!$  !----------------------------------------
+!!$
+!!$  adj_syn(:,:,:) = 0.0
+!!$  norm_mat(:,:) = 0.0
+!!$
+!!$  do irec = 1,nrec
+!!$
+!!$    ! time window function
+!!$
+!!$    istart = max(floor(tstart(irec) / DT), 1)
+!!$    iend = min(floor(tend(irec) / DT), NSTEP)
+!!$    if (istart >= iend) stop 'Check if istart < iend'
+!!$
+!!$    write(*,'(a,i6,a,f12.6,a,f12.6)') ' Receiver ', irec, ' : time window is from ', tstart(irec), ' to', tend(irec)
+!!$    write(*,*) '       index ', istart, ' to ', iend
+!!$
+!!$    time_window(:) = 0.0
+!!$
+!!$    ! welch taper
+!!$    ntemp = (iend - istart + 1)/2.
+!!$    do i = istart, iend
+!!$      !time_window(i) = 1 - (2 * (i - istart)/(iend - istart) - 1) ** 2
+!!$
+!!$      time_window(i) = 1 - ( (i - istart + 1 - ntemp) / ntemp  ) ** 2
+!!$    enddo
+!!$
+!!$    !---------------------------
+!!$
+!!$    ! calculate velocity and acceleration from syn (traveltime adjoint source only)
+!!$    if(IKER >= 1) then
+!!$       do itime = 2, NSTEP-1
+!!$          syn_veloc(itime,:,irec) =  (syn(itime+1,:,irec) - syn(itime-1,:,irec)) / (2 * DT)
+!!$       enddo
+!!$       syn_veloc(1,:,irec) = (syn(2,:,irec) - syn(1,:,irec)) / DT
+!!$       syn_veloc(NSTEP,:,irec) = (syn(NSTEP,:,irec) - syn(NSTEP-1,:,irec)) /DT
+!!$
+!!$       do itime = 2, NSTEP-1
+!!$          syn_accel(itime,:,irec) =  (syn_veloc(itime+1,:,irec) - syn_veloc(itime-1,:,irec)) / (2 * DT)
+!!$       enddo
+!!$       syn_accel(1,:,irec) = (syn_veloc(2,:,irec) - syn_veloc(1,:,irec)) / DT
+!!$       syn_accel(NSTEP,:,irec) = (syn_veloc(NSTEP,:,irec) - syn_veloc(NSTEP-1,:,irec)) /DT
+!!$    endif
+!!$
+!!$    ! assign adjoint force
+!!$
+!!$    do i = 1,NCOMP
+!!$
+!!$       if(IKER==0) then       ! waveform
+!!$
+!!$          adj_syn(:,i,irec) = ( syn(:,i,irec) -  data(:,i,irec) ) * time_window(:)
+!!$
+!!$       elseif(IKER==5) then   ! traveltime
+!!$
+!!$          ! minus sign is shifted from norm to adj_syn, in comparison with Tromp et al (2005)
+!!$          ! thus, norm is ensured to be POSITIVE (N > 0)
+!!$          norm = -DT * sum( time_window(:) * syn(:,i,irec) * syn_accel(:,i,irec) )
+!!$          if (abs(norm) > EPS) adj_syn(:,i,irec) = -syn_veloc(:,i,irec) * time_window(:) / norm
+!!$
+!!$       elseif(IKER==6) then  ! amplitude
+!!$
+!!$          ! norm is ensured to be POSITIVE (M > 0)
+!!$          norm = DT * sum( time_window(:) * syn(:,i,irec) * syn(:,i,irec) )
+!!$          if (abs(norm) > EPS) adj_syn(:,i,irec) = syn(:,i,irec) * time_window(:) / norm
+!!$
+!!$       endif
+!!$
+!!$       norm_mat(irec,i) = norm  ! could be either nothing or traveltime or amplitude
+!!$
+!!$       !adj_syn(:,i,irec) = time_window(:) ! test
+!!$       !adj_syn(:,i,irec) = syn(:,i,irec) ! test
+!!$    enddo
+!!$
+!!$  enddo ! loop over all receivers
+!!$
+!!$  ! write normalizations to file
+!!$  open(15,file=trim(out_dir)//'Nbanana.dat',status='unknown')
+!!$  do irec = 1,nrec
+!!$     do i = 1,NCOMP
+!!$        write(15,'(2i12,1e18.6)') irec, i, norm_mat(irec,i)
+!!$     enddo
+!!$  enddo
+!!$  close(15)
+!!$
+!!$  end subroutine make_adjoint_source
+
+  !----------------------------------------------------
+
+  subroutine smooth_function(rough_fun, gamma, smooth_fun)
+
+    ! This smooths a locally defined function via Gaussian convolution.
+
+    double precision, intent(in) :: gamma
+    double precision, dimension(NGLLX,NGLLZ,NSPEC),intent(in) :: rough_fun
+    double precision, dimension(NGLLX,NGLLZ,NSPEC),intent(out) :: smooth_fun
+    double precision, dimension(NGLOB) :: rough_global, smooth_global
+
+    !------------
+
+    ! convert local array to global vector
+    call local2global(rough_fun, rough_global)
+
+    ! smooth global function
+    call smooth_global_function(rough_global, gamma, smooth_global)
+
+    ! convert global vector to local array
+    call global2local(smooth_global, smooth_fun)
+
+  end subroutine smooth_function
+
+  !----------------------------------------------------
+
+  subroutine smooth_global_function(rough_global, gamma, smooth_global)
+
+    ! copied from test_smooth.f90 and wave2d_surf.f90 on 08-Jan-2007
+    ! This convolves a Gaussian function with a spatial 2D function to obtain
+    ! a smoothed version of the initial function.
+
+    double precision, intent(in) :: gamma
+    double precision, dimension(NGLOB),intent(in) :: rough_global
+    double precision, dimension(NGLOB),intent(out) :: smooth_global
+
+    double precision, dimension(NGLOB) :: gaus_global_ex, gaus_global
+    double precision :: dist2, dtrsh2, xcen, zcen, gaus_int
+    double precision :: xtar, ztar, d, dmin
+    integer :: i,iglob,igaus,icorner
+    !character(len=200) :: file_smooth
+
+  !-----------------------
+
+  ! The parameter gamma controls the scalelength of the smoothing Gaussian;
+  ! gamma is the full-width of the Gaussian (at 1/e).
+
+  ! All points outside d^2 (dtrsh2) are set to zero.
+  dtrsh2 = (1.5*gamma)**2
+
+  if(EXAMPLE_GAUSSIAN) then
+
+     ! EXAMPLE global gaussian smoothing function for one point
+     ! (1) find the closest gridpoint to the target point
+     xtar = 0.25*LENGTH
+     ztar = 0.25*HEIGHT
+     dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+     do iglob = 1,NGLOB
+        d = sqrt((xtar-x(iglob))**2+(ztar-z(iglob))**2)
+        if(d < dmin) then
+           igaus = iglob
+           dmin = d
+        endif
+     enddo
+     xcen = x(igaus)
+     zcen = z(igaus)
+
+     ! (2) compute the example gaussian
+     gaus_global_ex(:) = 0.0
+     do iglob = 1,NGLOB
+        dist2 = (xcen - x(iglob))**2 + (zcen - z(iglob))**2
+        if(dist2 <= dtrsh2) &
+           gaus_global_ex(iglob) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+     enddo
+
+   endif
+
+   !------------------------------------
+   ! Compute the SMOOTHED kernel by convolving a Gaussian with the UNSMOOTHED kernel.
+   ! This involves integrating NGLOB products between a Gaussian and the unsmoothed kernel.     
+   
+   print *, 'convolving the kernel with a Gaussian...'
+
+   smooth_global(:) = 0.0
+   
+   ! There are FOUR STEPS to the convolution:
+   ! (1) Obtain the center-point for the Gaussian; this could be a GLL point for
+   !       high-resolution smoothing, or it could be an element corner (low-resolution).
+   ! (2) Compute the Gaussian smoothing function at the local level.
+   ! (3) Integrate the Gaussian over the grid; this provides the normalization for the Gaussian
+   !       and accounts for Gaussians that are partially outside the grid.
+   ! (4) Integrate the product of the Gaussian and the rough function.
+
+   if(HIGH_RES_SMOOTHING) then
+      ! loop over every GLL point for high-resolution smoothing
+      do iglob = 1,NGLOB
+         if (mod(iglob,1000) == 0) write(*,*) iglob, ' out of ', NGLOB
+
+         xcen = x(iglob)
+         zcen = z(iglob)
+         gaus_global(:) = 0.0
+         do i = 1,NGLOB
+            dist2 = (xcen - x(i))**2 + (zcen - z(i))**2
+            if(dist2 <= dtrsh2) &
+                 gaus_global(i) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+         enddo
+
+         !gaus_int_global(iglob) = sum( gaus_global(:) * da_global(:) )
+         gaus_int = sum( gaus_global(:) * da_global(:) )
+         smooth_global(iglob) = sum( rough_global(:) * gaus_global(:) * da_global(:) ) / gaus_int
+      enddo   ! iglob = 1,NGLOB
+
+   else
+      ! loop over every element corner-point for low-resolution smoothing
+      do icorner = 1,NSPEC_CORNER
+         iglob = ielement_corner(icorner)
+
+         xcen = x(iglob)
+         zcen = z(iglob)
+         gaus_global(:) = 0.0
+         do i = 1,NGLOB
+            dist2 = (xcen - x(i))**2 + (zcen - z(i))**2
+            if(dist2 <= dtrsh2) &
+                 gaus_global(i) = (4./(PI*gamma**2)) * exp(-4.*dist2 / (gamma**2))
+         enddo
+
+         !gaus_int_global(iglob) = sum( gaus_global(:) * da_global(:) )
+         gaus_int = sum( gaus_global(:) * da_global(:) )
+         smooth_global(iglob) = sum( rough_global(:) * gaus_global(:) * da_global(:) ) / gaus_int
+      enddo   ! icorner = 1,NSPEC_CORNER
+
+   endif
+
+   ! write smooth-related functions to file
+   ! (We can also write gaus_int_global(iglob) to file if desired.)
+   if(EXAMPLE_GAUSSIAN) then
+      open(unit=19,file='fun_smooth.dat',status='unknown')
+      if(HIGH_RES_SMOOTHING) then
+         do iglob = 1,NGLOB
+            write(19,'(8e16.6)') x(iglob), z(iglob), x_lon(iglob), z_lat(iglob), &
+                 rough_global(iglob), gaus_global_ex(iglob), &
+                 smooth_global(iglob), rough_global(iglob) - smooth_global(iglob)
+         enddo
+      else
+         do icorner = 1,NSPEC_CORNER
+            iglob = ielement_corner(icorner)
+            write(19,'(8e16.6)') x(iglob), z(iglob), x_lon(iglob), z_lat(iglob), &
+                 rough_global(iglob), gaus_global_ex(iglob), &
+                 smooth_global(iglob), rough_global(iglob) - smooth_global(iglob)
+         enddo
+      endif
+      close(19)
+   endif
+
+  ! plot rough function, Gaussian filter, smooth function, and residual
+  !filename1 = 'get_smooth.csh'
+  !filename2 = trim(script_dir)//'plot_smoothed_function.pl'
+  !open(19,file=filename1,status='unknown')
+  !write(19,'(5a,1e16.6)') trim(filename2),' ', trim(out_dir1),' ', &
+  !   trim(file_smooth), gamma
+  !close(19)
+  !call system('chmod 755 get_smooth.csh ; get_smooth.csh')
+
+  end subroutine smooth_global_function
+
+  !----------------------------------------------------
+
+  subroutine local2global(array_local, vec_global)
+
+    ! This converts from a local array to a global array by averaging
+    ! the multi-valued GLL points. This has the effect of smoothing
+    ! any discontinuities that are honored by the mesh.
+
+    double precision, dimension(NGLLX,NGLLZ,NSPEC),intent(in) :: array_local
+    double precision, dimension(NGLOB),intent(out) :: vec_global
+    integer :: i,j,ispec,iglob
+
+    vec_global(:) = 0.0
+
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX 
+             iglob = ibool(i,j,ispec)
+             vec_global(iglob) = vec_global(iglob) + array_local(i,j,ispec)
+          enddo
+       enddo
+    enddo
+
+    ! now divide by the valence
+    vec_global(:) = vec_global(:) / valence(:)
+
+  end subroutine local2global
+
+  !----------------------------------------------------
+
+  subroutine global2local(vec_global, array_local)
+
+    ! This converts from a global vector to a local array.
+    ! By definition, the resultant array have NO jumps in values
+    ! at the element boundaries.
+    ! NOTE: This is useful for plotting purposes.
+
+    double precision, dimension(NGLOB),intent(in) :: vec_global
+    double precision, dimension(NGLLX,NGLLZ,NSPEC),intent(out) :: array_local
+    integer :: i,j,ispec,iglob
+
+    array_local(:,:,:) = 0.0
+
+    do ispec = 1,NSPEC
+       do j = 1,NGLLZ
+          do i = 1,NGLLX 
+             iglob = ibool(i,j,ispec)
+             array_local(i,j,ispec) = vec_global(iglob)
+          enddo
+       enddo
+    enddo
+
+  end subroutine global2local
+
+  !----------------------------------------------------
+  
+  !  subroutine local2mvec(array1, array2, nmod_src, source_vec, nmod, mvec, array_fac0)
+  subroutine local2mvec(array1, array2, nmod_src, source_vec, nmod, mvec)
+
+    ! This inputs three arrays and creates a vector that can be used
+    ! in the conjugate gradient algorithm.
+
+    double precision, dimension(NGLLX,NGLLZ,NSPEC),intent(in) :: array1, array2
+    integer, intent(in) :: nmod_src, nmod
+    double precision, dimension(nmod_src),intent(in) :: source_vec
+    double precision, dimension(nmod), intent(out) :: mvec
+
+    !double precision, dimension(NGLLX,NGLLZ,NSPEC),intent(in), optional :: array_fac0
+    double precision, dimension(NGLLX,NGLLZ,NSPEC) :: array_fac
+
+    integer :: i,j,k,ipar,ispec
+
+    !----------
+
+    mvec(:) = 0.0
+
+!!$    ! if the optional argument is not used, then default the factor of 1
+!!$    if(.not.present(array_fac0)) then
+!!$       array_fac(:,:,:) = 1.
+!!$    else
+!!$       array_fac(:,:,:) = array_fac0(:,:,:)
+!!$    endif
+
+    ! structure parameters
+    k = 0
+    do ipar = 1,NVAR_STRUCT
+       do ispec = 1,NSPEC
+          do j = 1,NGLLZ
+             do i = 1,NGLLX 
+                k = k+1
+                !if(ipar==1) mvec(k) = array1(i,j,ispec) * array_fac(i,j,ispec)  ! alpha
+                !if(ipar==2) mvec(k) = array2(i,j,ispec) * array_fac(i,j,ispec)  ! beta
+
+                if(ipar==1) mvec(k) = array1(i,j,ispec)  ! atype (kappa, alpha, c)
+                if(ipar==2) mvec(k) = array2(i,j,ispec)  ! btype (mu, beta, beta
+             enddo
+          enddo
+       enddo
+    enddo
+    if (k /= NVAR_STRUCT * NLOCAL) stop ' check that k = (NVAR_STRUCT * NLOCAL) '
+
+    ! source parameters
+    mvec(NVAR_STRUCT*NLOCAL+1 : nmod) = source_vec(:)
+
+  end subroutine local2mvec
+
+  !----------------------------------------------------
+
+  subroutine mvec2local(nmod, nmod_src, mvec, array1, array2, source_vec)
+
+    ! This inputs a model vector and outputs the constituent arrays: alpha, beta, source.
+
+    integer, intent(in) :: nmod, nmod_src
+    double precision, dimension(nmod), intent(in) :: mvec
+    double precision, dimension(NGLLX,NGLLZ,NSPEC), intent(out) :: array1, array2
+    double precision, dimension(nmod_src), intent(out) :: source_vec
+    integer :: i,j,k,ipar,ispec
+
+    !----------
+
+    array1(:,:,:) = 0.0
+    array2(:,:,:) = 0.0
+    source_vec(:) = 0.0
+
+    ! structure arrays
+    k = 0
+    do ipar = 1,NVAR_STRUCT
+       do ispec = 1,NSPEC
+          do j = 1,NGLLZ
+             do i = 1,NGLLX 
+                k = k+1
+                if(ipar==1) array1(i,j,ispec) = mvec(k)  ! atype (kappa, alpha, c)
+                if(ipar==2) array2(i,j,ispec) = mvec(k)  ! btype (mu, beta, beta)
+             enddo
+          enddo
+       enddo
+    enddo
+    if (k /= NVAR_STRUCT * NLOCAL) stop ' check that k = (NVAR_STRUCT * NLOCAL) '
+
+    ! source vector
+    source_vec(:) = mvec(NVAR_STRUCT*NLOCAL+1 : nmod)
+
+  end subroutine mvec2local
+
+  !----------------------------------------------------
+
+  subroutine compute_norm_sq(ievent_min, ievent_max, nevent, index_source, nmod, mvec, cov_model, &
+        norm_total, norm_struct, norm_source, norm_parts)
+
+    ! This computes the norm-squared of a model vector using the model covariance.
+    ! The dimensions of the input model vector are always the same, but this norm
+    ! takes into account the number of events used, which may be less than nevent.
+    ! It outputs the overall norm, the source part, and the structure part.
+
+    integer, intent(in) :: ievent_min, ievent_max, nevent, nmod
+    integer, dimension(NVAR_SOURCE, nevent), intent(in) ::index_source
+    double precision, dimension(nmod), intent(in) :: mvec, cov_model
+
+    !double precision, intent(out) :: norm_total, norm_struct, norm_source
+    double precision, intent(out) :: norm_total, norm_struct, norm_source
+    double precision, dimension(NVAR), intent(out) :: norm_parts
+    integer :: ievent, itemp1, itemp2, itemp3
+
+    !----------
+    
+    norm_parts(:) = 0.0
+
+    ! structure part of the norm -- BETA only
+    norm_parts(1) = 0.0
+    norm_parts(2) = sum( mvec(NLOCAL+1 : 2*NLOCAL)**2 / cov_model(NLOCAL+1 : 2*NLOCAL) )
+
+    ! source part of the norm -- only events that you are inverting for
+    do ievent = ievent_min, ievent_max
+       !itemp1 = 2*NLOCAL + (ievent-1)*3 + 1
+       !itemp2 = 2*NLOCAL + (ievent-1)*3 + 2
+       !itemp3 = 2*NLOCAL + (ievent-1)*3 + 3
+
+       itemp1 = 2*NLOCAL + index_source(1,ievent)
+       itemp2 = 2*NLOCAL + index_source(2,ievent)
+       itemp3 = 2*NLOCAL + index_source(3,ievent)
+
+       norm_parts(3) = norm_parts(3) + mvec(itemp1)**2 / cov_model(itemp1)
+       norm_parts(4) = norm_parts(4) + mvec(itemp2)**2 / cov_model(itemp2)
+       norm_parts(5) = norm_parts(5) + mvec(itemp3)**2 / cov_model(itemp3)
+    enddo
+
+    norm_struct = sum( norm_parts(1:2) )
+    norm_source = sum( norm_parts(3:5) )
+    norm_total  = sum( norm_parts(1:5) )
+
+  end subroutine compute_norm_sq
+
+  !-----------------------------------------------------  
+
+  subroutine write_norm_sq(filename,norm_parts)
+
+    double precision, dimension(NVAR), intent(in) :: norm_parts
+    character(len=200), intent(in) :: filename
+    integer :: i
+
+    open(unit=19,file=filename,status='unknown')
+    do i = 1,NVAR
+       write(19,'(1i10,3e20.10)') i, norm_parts(i)
+    enddo
+    write(19,'(1i10,1e20.10)') 1, sum( norm_parts(1:2) )
+    write(19,'(1i10,1e20.10)') 2, sum( norm_parts(3:5) )
+    write(19,'(1i10,1e20.10)') 1, sum( norm_parts(1:5) )
+
+  end subroutine write_norm_sq
+
+end module wave2d_sub

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub2.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub2.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub2.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,821 @@
+module wave2d_sub2
+
+  use wave2d_constants
+  use wave2d_variables
+
+  implicit none
+
+  ! this module contains subroutines pertaining to filtering gridpoints
+  ! and converting amoung UTM, mesh, and index coordinates
+
+contains
+
+  !=====================================================================
+
+  subroutine locate_targets(nrec, x_target, z_target, &
+       iglob_selected_rec, ispec_selected_rec, xi_receiver, gamma_receiver)
+
+    ! adapted from locate_receivers.f90 (3D code)
+    ! This does NOT remove redundant closest gridpoints, like in set_glob.f90
+
+    ! input
+    integer, intent(inout) :: nrec
+    double precision, intent(inout) :: x_target(nrec), z_target(nrec)
+
+    ! output -- note that (ispec, xi, gamma) are optional output
+    integer,          dimension(nrec), intent(out)           :: iglob_selected_rec
+    integer,          dimension(nrec), intent(out), optional :: ispec_selected_rec
+    double precision, dimension(nrec), intent(out), optional :: xi_receiver, gamma_receiver
+
+    ! local
+    double precision, dimension(nrec) :: x_found, z_found, final_distance, dmin_selected_rec
+    integer, dimension(nrec) :: ix_initial_guess, iz_initial_guess
+    double precision :: dmin, dist
+    double precision :: xtemp, ztemp, xi, gamma, dx, dz, dxi, dgamma
+    double precision :: xix,xiz,gammax,gammaz
+    integer :: irec, ispec, i, j, iglob, iter_loop, ispec_iterate
+    logical :: i_xi_gamma
+
+    ! control points of the surface element
+    !integer iax, iaz, ia
+    !integer iaddx(NGNOD2D), iaddz(NGNOD2D)
+    !double precision xelm(NGNOD2D),zelm(NGNOD2D)
+
+    !----------------------------------
+
+    print *, nrec,' input target points into locate_targets.f90'
+    print *, ' all target points should now lie within the mesh (station_filter.f90)'
+
+    ! boolean: whether the (ispec, xi, gamma) are in the subroutine call
+    i_xi_gamma = present(ispec_selected_rec) .and. present(xi_receiver) .and. present(gamma_receiver)
+
+    ! loop over target points to get the (xi,gamma) for the closest gridpoint
+    do irec=1,nrec
+
+       dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+
+       do ispec=1,NSPEC
+
+          ! loop only on points inside the element
+          ! exclude edges to ensure this point is not shared with other elements
+          do j = 2,NGLLZ-1
+             do i = 2,NGLLX-1
+
+                iglob = ibool(i,j,ispec)
+                dist = sqrt((x_target(irec) - x(iglob))**2 + (z_target(irec) - z(iglob))**2)
+
+                ! keep this point if it is closer to the receiver
+                if(dist < dmin) then
+                   dmin = dist
+                   dmin_selected_rec(irec) = dmin
+                   iglob_selected_rec(irec) = iglob  ! closest gridpoint
+                   if(i_xi_gamma) then
+                      ispec_selected_rec(irec) = ispec
+                      ix_initial_guess(irec) = i
+                      iz_initial_guess(irec) = j
+                   endif
+                endif
+
+             enddo
+          enddo
+       enddo  ! ispec
+    enddo  ! irec
+
+    ! TESTING ONLY (01-Feb-2006)
+    ! If the GLL points are your target points, then this should give the same
+    ! "interpolated" seismograms as if you simply saved the wavefield at the GLL point.
+    !x_target(:) = x(iglob_selected_rec(:))
+    !z_target(:) = z(iglob_selected_rec(:))
+
+    ! ****************************************
+    ! find the best (xi,gamma) for each target point
+    ! ****************************************
+
+    ! if the (xi, gamma) are desired
+    if(i_xi_gamma) then
+
+       do irec = 1,nrec
+
+          ! element that contains the target point
+          ispec_iterate = ispec_selected_rec(irec)
+
+          ! use initial guess in xi and gamma
+          xi    = xigll(ix_initial_guess(irec))
+          gamma = zigll(iz_initial_guess(irec))
+
+!!$    ! define coordinates of the control points of the element
+!!$    ! (ordering of these four points shouldn't matter)
+!!$    ! We could also access the vectors x1,x2,z1,z2 instead.
+!!$    do ia = 1,NGNOD2D    ! (NGNOD2D = 4)
+!!$
+!!$       if(ia==1) then
+!!$          iax = 1
+!!$          iaz = 1
+!!$       elseif(ia==2) then
+!!$          iax = NGLLX
+!!$          iaz = 1
+!!$       elseif(ia==3) then
+!!$          iax = NGLLX
+!!$          iaz = NGLLZ
+!!$       elseif(ia==4) then
+!!$          iax = 1
+!!$          iaz = NGLLZ
+!!$       endif
+!!$       iglob = ibool(iax,iaz,ispec_iterate)
+!!$       xelm(ia) = x(iglob)
+!!$       zelm(ia) = z(iglob)
+!!$    enddo  ! ia
+
+          ! iterate to solve the non linear system (it seems we only need one iteration for 2D)
+          do iter_loop = 1,NUM_ITER
+
+             ! recompute jacobian for the new point
+             ! INPUT:  xelm,zelm,xi,gamma
+             ! OUTPUT: xtemp,ztemp,xix,xiz,gammax,gammaz
+
+             !call recompute_jacobian(xelm,yelm,zelm,xi,eta,gamma,xtemp,ytemp,ztemp, &
+             !   xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz)
+             call recompute_jacobian_2d(ispec_iterate,xi,gamma,xtemp,ztemp,xix,xiz,gammax,gammaz)
+
+             ! compute distance to target location
+             dx = -(xtemp - x_target(irec))
+             dz = -(ztemp - z_target(irec))
+
+             ! compute increments
+             ! gamma does not change since we know the receiver is exactly on the surface
+             dxi  = xix*dx + xiz*dz
+             dgamma = gammax*dx + gammaz*dz
+
+             !print *
+             !print *, 'iteration   : ', iter_loop
+             !print *, ' (dx, dz)   : ', dx,dz
+             !print *, ' (xi,gamma) : ', xi,gamma
+             !print *, xix,xiz,gammax,gammaz
+
+             ! update values
+             xi = xi + dxi
+             gamma = gamma + dgamma
+
+             !print *, xi,gamma,dxi,dgamma
+
+             ! impose that we stay in that element
+             ! (useful if user gives a receiver outside the mesh for instance)
+             ! we can go slightly outside the [1,1] segment since with finite elements
+             ! the polynomial solution is defined everywhere
+             ! can be useful for convergence of iterative scheme with distorted elements
+             if (xi > 1.10) xi = 1.10
+             if (xi < -1.10) xi = -1.10
+             if (gamma > 1.10) gamma = 1.10
+             if (gamma < -1.10) gamma = -1.10
+
+          enddo  ! iter_loop
+
+          ! compute final coordinates of point found
+          xtemp = 0. ; ztemp = 0.  ! re-initialize
+          call recompute_jacobian_2d(ispec_iterate,xi,gamma,xtemp,ztemp,xix,xiz,gammax,gammaz)
+
+          ! store xi,gamma and x,z of point found
+          xi_receiver(irec) = xi
+          gamma_receiver(irec) = gamma
+          x_found(irec) = xtemp
+          z_found(irec) = ztemp
+
+          ! compute final distance between asked and found
+          final_distance(irec) = sqrt((x_target(irec) - x_found(irec))**2 + &
+               (z_target(irec) - z_found(irec))**2)
+       enddo  ! irec
+
+       ! display information
+       do irec=1,nrec
+
+          if(final_distance(irec) == HUGEVAL) stop 'error locating receiver'
+
+          if(0==1) then
+             print *
+             print *,                'target point # ', irec
+             write(*,'(a,1f18.8)')   '  target x (km)            : ', x_target(irec)/1000.
+             write(*,'(a,1f18.8)')   '  target z (km)            : ', z_target(irec)/1000.
+             write(*,'(a,1e18.8,a)') '  closest gridpoint found  : ', dmin_selected_rec(irec)/1000.,' km away'
+             write(*,'(a,1f18.8)')   '  closest gridpoint x (km) : ', x(iglob_selected_rec(irec))/1000.
+             write(*,'(a,1f18.8)')   '  closest gridpoint z (km) : ', z(iglob_selected_rec(irec))/1000.
+             print *,                '     element = ', ispec_selected_rec(irec)
+             print *,                '          xi = ', xigll(ix_initial_guess(irec))
+             print *,                '       gamma = ', zigll(iz_initial_guess(irec))
+             write(*,'(a,1f18.8)')   '  estimate x (km)            : ', x_found(irec)/1000.
+             write(*,'(a,1f18.8)')   '  estimate z (km)            : ', z_found(irec)/1000.
+             print *,                '  closest estimate found   : ', final_distance(irec)/1000.,' km away'
+             print *,                '     element = ', ispec_selected_rec(irec)
+             print *,                '          xi = ', xi_receiver(irec)
+             print *,                '       gamma = ', gamma_receiver(irec)
+          endif
+
+          ! add warning if estimate is poor
+          ! (usually means receiver outside the mesh given by the user)
+          if(final_distance(irec) > 5.) then
+             print *, 'station # ',irec
+             print *, '*******************************************************'
+             print *, '***** WARNING: receiver location estimate is poor *****'
+             print *, '*******************************************************'
+          endif
+
+       enddo
+
+       ! replace the input target points with the (x,z) corresponding to the (xi,gamma) values
+       x_target(:) = x_found(:)
+       z_target(:) = z_found(:)
+
+    else
+       ! replace the input target points with the (x,z) of the closest gridpoint
+       x_target(:) = x(iglob_selected_rec(:))
+       z_target(:) = z(iglob_selected_rec(:))
+
+    endif
+
+    !print *
+    !print *, nrec,' output gridpoint indices from locate_targets.f90'
+
+  end subroutine locate_targets
+
+  !=====================================================================
+
+  subroutine recompute_jacobian_2d(ispec, xi, gamma, xtemp, ztemp, xix, xiz, gammax, gammaz)
+
+    ! subroutine recompute_jacobian(xelm,yelm,zelm,xi,eta,gamma,x,y,z, &
+    !                  xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz)
+
+    ! recompute jacobian for any (xi,eta,gamma) point, not necessarily a GLL point
+    ! adapted from recompute_jacobian.f90 and mesher.f90 (above)
+    !
+    ! INPUT:  ispec,xi,gamma
+    ! OUTPUT: xtemp,ztemp,xix,xiz,gammax,gammaz
+
+    ! input
+    integer ispec
+    double precision :: xi,gamma
+    !double precision xelm(NGNOD2D),zelm(NGNOD2D)  ! coordinates of the control points
+
+    ! output
+    double precision :: xtemp,ztemp,xix,xiz,gammax,gammaz
+
+    double precision :: jacob
+
+    !---------------------------------------------
+    !
+    ! jacobian = | dx/dxi dx/dgamma | = (z2-z1)*(x2-x1)/4  as dx/dgamma=dz/dxi = 0
+    !            | dz/dxi dz/dgamma | 
+
+    ! jacobian, integration weight
+    xix = 2. / (x2(ispec)-x1(ispec))
+    xiz = 0.
+    gammax = 0.
+    gammaz = 2. / (z2(ispec)-z1(ispec))
+
+    jacob = (z2(ispec)-z1(ispec))*(x2(ispec)-x1(ispec)) / 4. 
+
+    ! find the (x,z) corresponding to (xi,gamma,ispec)
+    xtemp = 0.5*(1.-    xi)*x1(ispec) + 0.5*(1.+   xi)*x2(ispec)
+    ztemp = 0.5*(1.- gamma)*z1(ispec) + 0.5*(1.+gamma)*z2(ispec)
+
+    if(jacob <= 0.) stop '2D Jacobian undefined'
+
+  end subroutine recompute_jacobian_2d
+
+  !=====================================================================
+
+  subroutine lagrange_poly(xi,NGLL,xigll,h,hprime)
+
+    ! subroutine to compute the Lagrange interpolants based upon the GLL points
+    ! and their first derivatives at any point xi in [-1,1]
+    ! copied from lagrange_poly.f90 in Qinya's original codes
+
+    integer,intent(in) :: NGLL
+    double precision,intent(in) :: xi, xigll(NGLL)
+    double precision,intent(out) :: h(NGLL), hprime(NGLL)
+
+    integer dgr,i,j
+    double precision prod1,prod2
+
+    !---------------------------------------------
+
+    do dgr=1,NGLL
+
+       prod1 = 1.0
+       prod2 = 1.0
+       do i=1,NGLL
+          if(i /= dgr) then
+             prod1 = prod1*(xi-xigll(i))
+             prod2 = prod2*(xigll(dgr)-xigll(i))
+          endif
+       enddo
+       h(dgr)=prod1/prod2
+
+       hprime(dgr)=0.0
+       do i=1,NGLL
+          if(i /= dgr) then
+             prod1=1.0
+             do j=1,NGLL
+                if(j /= dgr .and. j /= i) prod1 = prod1*(xi-xigll(j))
+             enddo
+             hprime(dgr) = hprime(dgr)+prod1
+          endif
+       enddo
+       hprime(dgr) = hprime(dgr)/prod2
+
+    enddo
+
+  end subroutine lagrange_poly
+
+  !=====================================================================
+
+  double precision function lagrange_deriv_GLL(I,j,ZGLL,NZ)
+
+    ! subroutine to compute the derivative of the Lagrange interpolants
+    ! at the GLL points at any given GLL point
+    !
+    !------------------------------------------------------------------------
+    !  Compute the value of the derivative of the I-th
+    !  Lagrange interpolant through the
+    !  NZ Gauss-Lobatto Legendre points ZGLL at point ZGLL(j)
+    !------------------------------------------------------------------------
+
+    integer i,j,nz
+    double precision zgll(0:nz-1)
+    integer degpoly
+    double precision, external :: pnleg,pndleg   ! external functions
+
+    !---------------------------------------------
+
+    degpoly = nz - 1
+    if (i == 0 .and. j == 0) then
+       lagrange_deriv_GLL = - dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+
+    else if (i == degpoly .and. j == degpoly) then
+       lagrange_deriv_GLL = dble(degpoly)*(dble(degpoly)+1.d0) / 4.d0
+
+    else if (i == j) then
+       lagrange_deriv_GLL = 0.d0
+
+    else
+       lagrange_deriv_GLL = pnleg(zgll(j),degpoly) / &
+            (pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))) &
+            + (1.d0-zgll(j)*zgll(j))*pndleg(zgll(j),degpoly) / (dble(degpoly)* &
+            (dble(degpoly)+1.d0)*pnleg(zgll(i),degpoly)*(zgll(j)-zgll(i))*(zgll(j)-zgll(i)))
+    endif
+
+  end function lagrange_deriv_GLL
+
+  !=====================================================================
+
+  subroutine set_glob(nrec, x_rec, z_rec, rglob)
+
+    integer, intent(inout) :: nrec
+    double precision, intent(in) :: x_rec(nrec), z_rec(nrec)
+    integer, intent(out) :: rglob(nrec)
+
+    double precision :: dmin, d
+    integer, dimension(nrec) :: rglobtemp
+    integer :: irec, ispec, i, j, k, iglob, itemp, iflag
+
+    !----------------------------------
+
+    print *, nrec,' input target points into set_glob.f90'
+
+    if(nrec/=0) then
+
+       ! find the closest gridpoint to the target point
+       do irec = 1, nrec
+          dmin = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+          do iglob = 1,NGLOB
+             d = sqrt((x_rec(irec)-x(iglob))**2+(z_rec(irec)-z(iglob))**2)
+             if(d < dmin) then
+                dmin  = d
+                rglob(irec) = iglob
+             endif
+          enddo
+       enddo
+
+       ! remove redundant gridpoint indices
+       ! (is there a more elegant way to do this?)
+       rglobtemp(1) = rglob(1)
+       k = 1
+       do i = 2,nrec
+          itemp = rglob(i)
+          iflag = 0
+          do j = 1,i
+             if(rglobtemp(j) == itemp) iflag = 1
+          enddo
+          if(iflag==0) then
+             k = k+1
+             rglobtemp(k) = itemp
+          endif
+       enddo
+
+       ! update nrec and rglob
+       nrec = k
+       rglob(1:nrec) = rglobtemp(1:nrec)
+       print *, nrec,' output gridpoint indices from set_glob.f90'
+
+       ! NO NEED TO LOOP OVER i,j,k -- only iglob
+!!$    do irec = 1, nrec
+!!$       d_min_rec = sqrt(LENGTH**2+HEIGHT**2)  ! max possible distance
+!!$       do ispec = 1,NSPEC
+!!$          do j = 1,NGLLZ
+!!$             do i = 1,NGLLX
+!!$                iglob = ibool(i,j,ispec)
+!!$                d = sqrt((x_rec(irec)-x(iglob))**2+(z_rec(irec)-z(iglob))**2)
+!!$                if(d < d_min_rec) then
+!!$                  d_min_rec  = d
+!!$                  rglob(irec) = ibool(i,j,ispec)
+!!$                endif
+!!$             enddo
+!!$          enddo
+!!$       enddo
+!!$    enddo
+
+    endif
+
+  end subroutine set_glob
+
+  !=====================================================================
+
+  !  subroutine station_filter(nrec, x_rec, z_rec, dmin_trsh, ncoast, coast_x, coast_z)
+  subroutine station_filter(nrec, x_rec, z_rec, ifilter, dmin_trsh)
+
+    ! Update this so that there is nrec_in and nrec_out (20-Jan-2007).
+
+    integer, intent(inout) :: nrec
+    double precision, intent(in) :: dmin_trsh, x_rec(nrec), z_rec(nrec)
+
+    integer, intent(out) :: ifilter(nrec)      ! WARNING : nrec may change
+
+    !integer, intent(in) :: ncoast
+    !double precision, intent(in) :: dmin_trsh
+    !double precision, intent(in) :: coast_x(ncoast), coast_z(ncoast)
+
+    double precision :: dmin, d, xtar, ztar, dcompare
+    integer :: ispec, irec, i, j, iglob
+
+    !---------------------------------------
+
+    ! this value is assigned in order to avoid equality comparisons below
+    dcompare = 1.    ! in meters
+
+    print *, nrec,' input target points into station_filter.f90 (some may be zeros)'
+    print *, 'removing target points that are outside mesh or'
+    print *, sngl(dmin_trsh/1000.),' km from grid boundary'
+    !print *, 'removing target points that are ',sngl(dmin_trsh/1000.),' km from the SoCal coast'
+
+    ! (1) exclude stations outside, or close to the boundary, of the mesh
+    ! (2) exclude stations within a certain distance of the SoCal coast
+
+    j = 0
+    do irec = 1,nrec
+
+       ! target point
+       xtar = x_rec(irec)
+       ztar = z_rec(irec)
+ 
+       !print *, xtar, ztar
+
+       ! if target point is not near grid boundary
+       if       ( xtar > (0.    -dcompare) + dmin_trsh   &
+            .and. xtar < (LENGTH-dcompare) - dmin_trsh   &
+            .and. ztar > (0.    -dcompare) + dmin_trsh   &
+            .and. ztar < (HEIGHT+dcompare) - dmin_trsh ) then
+
+          if(.not.(xtar==0. .and. ztar==0.)) then    ! exclude the origin
+
+             j = j+1
+             !x_rec(j) = xtar
+             !z_rec(j) = ztar
+             ifilter(j) = irec
+
+             ! obtain the coastal point closest to the target point
+             !dmin = sqrt(LENGTH**2+HEIGHT**2)
+             !do i=1,ncoast
+             !   ! distance from target point to coastal points
+             !   d = sqrt((xtar-coast_x(i))**2+(ztar-coast_z(i))**2)
+             !   if(d < dmin) then
+             !      dmin  = d
+             !   endif
+             !enddo
+
+             !! if target point is at least dmin_trsh from the coast, then keep it 
+             !if ( dmin >= dmin_trsh ) then
+             !  j = j+1
+             !  x_rec(j) = xtar
+             !  z_rec(j) = ztar
+             !endif
+
+          endif
+
+       endif
+    enddo
+    nrec = j
+    print *, nrec,' output target points from station_filter.f90'
+
+!!$    ! modified to exclude stations within a designated circle (CHT)
+!!$    r    = 300.d+03
+!!$    xcen = 50.d+03
+!!$    zcen = 50.d+03
+!!$    j = 0
+!!$    do irec = 1, nrec
+!!$       d = sqrt((x(rglob(irec)) - xcen)**2+(z(rglob(irec)) - zcen)**2)
+!!$       if(d > r) then
+!!$          j = j+1
+!!$          rglob(j) = rglob(irec)
+!!$       endif
+!!$    enddo
+!!$    nrec = j
+!!$    print *, nrec,' output gridpoints'
+!!$    print *
+
+  end subroutine station_filter
+
+  !=====================================================================
+
+  subroutine station_filter_2(nrec, x_rec, z_rec, ieast)
+
+    integer, intent(inout) :: nrec
+    double precision, intent(inout) :: x_rec(nrec), z_rec(nrec)
+    integer, intent(in) :: ieast
+
+    double precision :: xtar,ztar,m0,b0,mp,bp,x_div,z_div
+    integer :: irec, j
+
+    !---------------------------------------
+
+    ! dividing line for stations
+    m0 = HEIGHT/LENGTH    ! slope
+    b0 = 0.d+03           ! y-intercept
+    mp = -1./m0           ! perpendicular slope
+    !ieast = -1             ! (1) for east points or (-1) for west points
+
+    print *, nrec,' input target points into station_filter_2.f90'
+    print *, 'removing a fraction of the target points'
+
+    j = 0
+    do irec = 1,nrec
+
+       ! target point
+       xtar = x_rec(irec)
+       ztar = z_rec(irec)
+
+       ! obtain the closest point on the dividing line to the target point
+       bp       = ztar - mp*xtar
+       x_div    = (bp - b0)/(m0 - mp)
+       z_div    = mp*x_div + bp
+       !write(*,'(4f16.6)') xtar/1000., ztar/1000., x_div/1000., z_div/1000
+
+       ! if target point is at least dmin_trsh from the coast, then keep it 
+       if ( 0 < dble(ieast)*(xtar - x_div) ) then
+          j = j+1
+          x_rec(j) = xtar
+          z_rec(j) = ztar
+       endif
+    enddo
+    nrec = j
+    print *, nrec,' output target points from station_filter_2.f90'
+
+  end subroutine station_filter_2
+
+  !=====================================================================
+
+  subroutine mesh_geo(npt,rlon,rlat,rx,rz,UTM_PROJECTION_ZONE,iway)
+
+    integer, intent(in) :: npt, UTM_PROJECTION_ZONE, iway
+    double precision, intent(inout) :: rx(npt),rz(npt),rlon(npt),rlat(npt)
+
+    double precision :: xtemp,ztemp
+    integer i
+
+    if (iway==ILONLAT2MESH) then  ! lon-lat to mesh coordinates
+       do i=1,npt
+          call utm_geo(rlon(i),rlat(i),xtemp,ztemp,UTM_PROJECTION_ZONE,ILONGLAT2UTM)
+          rx(i) = xtemp - utm_xmin
+          rz(i) = ztemp - utm_zmin
+       enddo
+
+    else                           ! mesh coordinates to lon-lat
+       do i=1,npt
+          xtemp = rx(i) + utm_xmin
+          ztemp = rz(i) + utm_zmin
+          call utm_geo(rlon(i),rlat(i),xtemp,ztemp,UTM_PROJECTION_ZONE,IUTM2LONGLAT)
+       enddo
+    endif
+
+  end subroutine mesh_geo
+
+  !------------------------------------------
+
+  subroutine utm_geo(rlon,rlat,rx,ry,UTM_PROJECTION_ZONE,iway)
+
+    !=====================================================================
+    !
+    !  UTM (Universal Transverse Mercator) projection from the USGS
+    !
+    !=====================================================================
+    !
+    ! convert geodetic longitude and latitude to UTM, and back
+    ! use iway = ILONGLAT2UTM for long/lat to UTM, IUTM2LONGLAT for UTM to lat/long
+    !
+    ! NOTE: THIS APPEARS TO BE ONLY GOOD TO SINGLE PRECISION (25-JAN-2006)
+    !
+    !
+    !-----CAMx v2.03
+    !
+    !     UTM_GEO performs UTM to geodetic (long/lat) translation, and back.
+    !
+    !     This is a Fortran version of the BASIC program "Transverse Mercator
+    !     Conversion", Copyright 1986, Norman J. Berls (Stefan Musarra, 2/94)
+    !     Based on algorithm taken from "Map Projections Used by the USGS"
+    !     by John P. Snyder, Geological Survey Bulletin 1532, USDI.
+    !
+    !     Input/Output arguments:
+    !
+    !        rlon                  Longitude (deg, negative for West)
+    !        rlat                  Latitude (deg)
+    !        rx                    UTM easting (m)
+    !        ry                    UTM northing (m)
+    !        UTM_PROJECTION_ZONE  UTM zone
+    !        iway                  Conversion type
+    !                              ILONGLAT2UTM = geodetic to UTM
+    !                              IUTM2LONGLAT = UTM to geodetic
+    !
+
+    integer UTM_PROJECTION_ZONE,iway
+    double precision rx,ry,rlon,rlat
+
+    double precision, parameter :: degrad=PI/180., raddeg=180./PI
+    double precision, parameter :: semimaj=6378206.4, semimin=6356583.8
+    double precision, parameter :: scfa=.9996
+    double precision, parameter :: north=0., east=500000.
+
+    double precision e2,e4,e6,e8,ep2,xx,yy,dlat,dlon,zone,cm,cmr,delam
+    double precision f1,f2,f3,f4,rm,rn,t,c,a,e1,u,rlat1,dlat1,c1,t1,rn1,r1,d
+    double precision rx_save,ry_save,rlon_save,rlat_save
+
+    !---------------------------------------------------
+
+    if(SUPPRESS_UTM_PROJECTION) then
+       if (iway == ILONGLAT2UTM) then
+          rx = rlon
+          ry = rlat
+       else
+          rlon = rx
+          rlat = ry
+       endif
+       return
+    endif
+
+    ! save original parameters
+    rlon_save = rlon
+    rlat_save = rlat
+    rx_save = rx
+    ry_save = ry
+
+    ! define parameters of reference ellipsoid
+    e2  = 1.0-(semimin/semimaj)**2.0
+    e4  = e2*e2
+    e6  = e2*e4
+    e8  = e4*e4  
+    ep2 = e2/(1.-e2)
+
+    if (iway == IUTM2LONGLAT) then
+       xx = rx
+       yy = ry
+    else
+       dlon = rlon
+       dlat = rlat
+    endif
+
+    ! set zone parameters
+    zone = dble(UTM_PROJECTION_ZONE)
+    cm   = zone*6.0 - 183.0
+    cmr  = cm*degrad
+
+    if (iway == ILONGLAT2UTM) then  ! lat-lon to UTM
+
+       rlon = degrad*dlon
+       rlat = degrad*dlat
+
+       delam = dlon - cm
+       if (delam < -180.) delam = delam + 360.
+       if (delam > 180.) delam = delam - 360.
+       delam = delam*degrad
+
+       f1 = (1. - e2/4. - 3.*e4/64. - 5.*e6/256)*rlat
+       f2 = 3.*e2/8. + 3.*e4/32. + 45.*e6/1024.
+       f2 = f2*sin(2.*rlat)
+       f3 = 15.*e4/256.*45.*e6/1024.
+       f3 = f3*sin(4.*rlat)
+       f4 = 35.*e6/3072.
+       f4 = f4*sin(6.*rlat)
+       rm  = semimaj*(f1 - f2 + f3 - f4)  ! mm in other code
+
+       if (dlat == 90. .or. dlat == -90.) then
+          xx = 0.
+          yy = scfa*rm
+
+       else
+          rn = semimaj/sqrt(1. - e2*sin(rlat)**2)
+          t = tan(rlat)**2
+          c = ep2*cos(rlat)**2
+          a = cos(rlat)*delam
+
+          f1 = (1. - t + c)*a**3 / 6.
+          f2 = 5. - 18.*t + t**2 + 72.*c - 58.*ep2
+          f2 = f2*a**5 / 120.
+          xx = scfa*rn*(a + f1 + f2)
+
+          f1 = a**2 / 2.
+          f2 = 5. - t + 9.*c + 4.*c**2
+          f2 = f2*a**4 / 24.
+          f3 = 61. - 58.*t + t**2 + 600.*c - 330.*ep2
+          f3 = f3*a**6/720.
+          yy = scfa*(rm + rn*tan(rlat)*(f1 + f2 + f3))
+
+       endif
+
+       ! apply false easting and northing
+       xx = xx + east
+       yy = yy + north
+
+    else  ! UTM to lat-lon
+
+       ! remove false easting and northing
+       xx = xx - east
+       yy = yy - north
+
+       ! calculate the footpoint latitude
+       e1 = sqrt(1. - e2)
+       e1 = (1. - e1)/(1. + e1)
+       rm = yy/scfa
+       u = 1. - e2/4. - 3.*e4/64. - 5.*e6/256.
+       u = rm / (semimaj*u)
+
+       f1 = 3.*e1/2. - 27.*e1**3./32.
+       f1 = f1*sin(2.*u)
+       f2 = 21.*e1**2 / 16. - 55.*e1**4 / 32.
+       f2 = f2*sin(4.*u)
+       f3 = 151.*e1**3. / 96.
+       f3 = f3*sin(6.*u)
+       f4 = 1097.*e1**4. / 512.  ! added term (CHT)
+       f4 = f4*sin(8.*u)         ! added term (CHT)
+
+       rlat1 = u + f1 + f2 + f3 + f4
+       dlat1 = rlat1*raddeg
+
+       if (dlat1 >= 90. .or. dlat1 <= -90.) then
+          dlat1 = dmin1(dlat1,dble(90.) )
+          dlat1 = dmax1(dlat1,dble(-90.) )
+          dlon = cm
+
+       else
+          c1 = ep2*cos(rlat1)**2.
+          t1 = tan(rlat1)**2.
+          f1 = 1. - e2*sin(rlat1)**2.
+          rn1 = semimaj/sqrt(f1)
+          r1 = semimaj*(1. - e2)/sqrt(f1**3)
+          d = xx / (rn1*scfa)
+
+          ! latitude
+          f1 = rn1*tan(rlat1) / r1
+          f2 = d**2 / 2.
+          f3 = 5.*3.*t1 + 10.*c1 - 4.*c1**2 - 9.*ep2
+          f3 = f3*d**2*d**2 / 24.
+          f4 = 61. + 90.*t1 + 298.*c1 + 45.*t1**2. - 252.*ep2 - 3.*c1**2
+          f4 = f4*(d**2)**3 / 720.
+          rlat = rlat1 - f1*(f2 - f3 + f4)
+          dlat = rlat*raddeg
+
+          ! longitude
+          f1 = 1. + 2.*t1 + c1
+          f1 = f1*d**2*d/6.
+          f2 = 5. - 2.*c1 + 28.*t1 - 3.*c1**2 + 8.*ep2 + 24.*t1**2
+          f2 = f2*(d**2)**2*d/120.
+          rlon = cmr + (d - f1 + f2)/cos(rlat1)
+          dlon = rlon*raddeg
+          if (dlon < -180.) dlon = dlon + 360.
+          if (dlon >  180.) dlon = dlon - 360.
+       endif
+
+    endif
+
+    if (iway == IUTM2LONGLAT) then
+       rlon = dlon
+       rlat = dlat
+       rx = rx_save
+       ry = ry_save
+    else
+       rx = xx
+       ry = yy
+       rlon = rlon_save
+       rlat = rlat_save
+    endif
+
+  end subroutine utm_geo
+
+  !=====================================================================
+
+end module wave2d_sub2

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub3.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub3.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub3.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,1328 @@
+module wave2d_sub3
+
+  use wave2d_constants
+  use wave2d_variables
+
+  implicit none
+
+  ! This module contains subroutines pertaining to making measurements
+  ! between data and synthetics, and then constructing the corresponding adjoint source.
+  !
+  ! AS OF DEC 2006, THIS CODE SHOULD BE REPLACED BY THE VERSION THAT QINYA HAS
+  ! TESTED AND CHECKED INTO THE SVN SERVER (mt_measure_adj.f90).
+
+contains
+
+  !------------------------------------------
+
+  subroutine mtm_test(ievent, nrec, syn, tstart, tend, adj_syn, data, data_recon)
+
+    integer, intent(in) :: nrec, ievent
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+    double precision, dimension(nrec), intent(in) :: tstart, tend
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+    double precision, dimension(NSTEP,NCOMP,nrec),optional :: data_recon
+
+    complex*16, dimension(NDIM) :: wseis_syn, wseis_dat, wseis_dat2
+    double precision, dimension(NDIM) :: fp, fq, fq2, wvec
+    double precision, dimension(NSTEP) :: syn_displ, syn_veloc
+    double precision :: twopi, df, dw, w0, a0, f0
+
+    complex*16 :: cci
+    integer :: i,j,nlen,icomp,irec
+
+    !=======================================================
+
+    twopi = 2.*PI
+    df = 1./(npt*DT)
+    dw = twopi / (npt*DT)
+    cci = cmplx(0.,1.)
+    w0 = twopi/20.
+    f0 = 1./20.
+    a0 = 0.04
+
+    !icomp = 1
+
+    do icomp = 1,NCOMP
+
+       ! real time series for analysis
+       syn_displ(:) = 0.
+       syn_displ(1:NSTEP) = data(1:NSTEP,icomp,1)
+       syn_veloc(:) = 0.
+       syn_veloc(1:NSTEP) = data(1:NSTEP,icomp,2)
+
+!!$  open(29,file='junk1.dat',status='unknown')
+!!$  do i=1,NSTEP
+!!$     write(29,*) i*DT, syn_displ(i), syn_veloc(i)
+!!$  enddo
+!!$  close(29)
+
+       nlen = NSTEP
+
+       ! FFT to obtain complex frequency-domain version
+       wseis_syn(:) = cmplx(0.,0.)
+       !do j = 1,nlen
+       !   wseis_syn(j)       = cmplx(syn_displ(j),0.)
+       !   wseis_syn(npt-j+1) = cmplx(syn_displ(j),0.)
+       !enddo
+       wseis_syn(1:nlen) = cmplx(syn_displ(1:nlen),0.)
+       call fft(lnpt,wseis_syn,FORWARD_FFT,DT)   ! displacement
+
+       ! KEY: assemble omega vector 
+       wvec(:) = 0.
+       do j = 1,npt
+          if(j > npt/2) then
+             wvec(j) = dw*(j-npt-1)   ! negative frequencies in second half
+          else
+             wvec(j) = dw*(j-1)       ! positive frequencies in first half
+          endif
+       enddo
+
+       ! analytical expression (Harris and Stocker, 1998)
+       ! With this IFFT routine, only the positive frequencies need to be filled, in order
+       ! to recover the original REAL signal when we IFFT.
+       wseis_dat(:) = cmplx(0.,0.)
+       do j = 1,npt
+          !do j = 1,npt/2
+          wseis_dat(j)  = cmplx(w0,0.) / ( (cmplx(wvec(j),0.)*cci + cmplx(a0,0.))**2 + cmplx(w0**2,0.) )
+          wseis_dat2(j) = wseis_dat(j) * cmplx(0.,wvec(j))
+       enddo
+
+       open(91,file='test1.dat',status='unknown')
+       do j = 1,npt
+          write(91,'(4e18.8)') wvec(j)/twopi, abs(wseis_syn(j)), real(wseis_syn(j)), aimag(wseis_syn(j))
+       enddo
+       close(91)
+
+       open(91,file='test2.dat',status='unknown')
+       do j = 1,npt
+          write(91,'(4e18.8)') wvec(j)/twopi, abs(wseis_dat(j)), real(wseis_dat(j)), aimag(wseis_dat(j))
+       enddo
+       close(91)
+
+       open(91,file='test3.dat',status='unknown')
+       do j = 1,npt
+          write(91,'(4e18.8)') wvec(j)/twopi, abs(wseis_dat2(j)), real(wseis_dat2(j)), aimag(wseis_dat2(j))
+       enddo
+       close(91)
+
+       !wseis_dat(:) = 0.
+
+       ! back to real time series
+       call fftinv(lnpt,wseis_syn,REVERSE_FFT,DT,fp)    ! displacement -- from NUMERICAL
+       call fftinv(lnpt,wseis_dat,REVERSE_FFT,DT,fq)    ! displacement -- from ANALYTICAL
+       call fftinv(lnpt,wseis_dat2,REVERSE_FFT,DT,fq2)    ! should be velocity
+
+       open(91,file='test0.dat',status='unknown')
+       do j = 1,nlen
+          write(91,'(6e18.8)') j*DT, syn_displ(j), fp(j), fq(j), syn_veloc(j), fq2(j)
+       enddo
+       close(91)
+
+       adj_syn(:,:,:) = 0.
+
+    enddo  ! do icomp=1,NCOMP
+
+    !------------------------------------------------------------------
+  end subroutine mtm_test
+  !------------------------------------------------------------------
+  ! END TEST PROGRAM
+  !------------------------------------------------------------------
+
+  subroutine mtm_adj(ievent, nrec, syn, tstart, tend, adj_syn, data, data_recon)
+
+    ! PARAMETERS ARE INCLUDED IN wave2d_constants.f90
+    !parameter(NDIM=8000*4,NDIM2=16000*4,lnpt=14,npt=2**lnpt)
+    !parameter(NTAPER=5,WTR=0.02,ZZIGN=-1.0)
+    !implicit real(a-h,o-z)
+
+    double precision :: tas(NDIM,NTAPER), ey1(NDIM), ey2(NDIM)
+    !double precision, dimension(NDIM,NTAPER) :: phi_mul, dt_mul, abs_mul, abs2_mul
+    double precision, dimension(NDIM) :: dzr, dzr2, phi, fr
+    double precision, dimension(NDIM) :: dzr_win, dzr2_win, dzr3_win, dzr0_win, dzr30_win, tseis_recon
+    !double precision, dimension(NDIM) :: dt_mtm, phi_mtm, abs_mtm, abs2_mtm
+    !double precision, dimension(NDIM) :: err_phi, err_dt, err_abs, err_abs2
+
+    ! variables for adjoint sources (p(w) and q(w), etc)
+    complex*16, dimension(NDIM,NTAPER) :: top_p_ntaper
+    complex*16, dimension(NDIM) :: pwc_adj, qwc_adj, top_p, bot_p, ctemp, dtemp, dtau_pj_wc, dlnA_qj_wc
+    double precision, dimension(NDIM,NTAPER) :: pw_adj, qw_adj, pt_adj, qt_adj, dtau_pj_t, dlnA_qj_t
+    double precision, dimension(NDIM) :: wvec, tvec, dlnA_w, dtau_w, fp, fq, w_taper, wp_taper, wq_taper
+    double precision :: nw
+
+    ! cross-correlation sources
+    double precision, dimension(NSTEP) :: syn_displ, dat_displ, syn_veloc, dat_veloc, syn_accel
+    double precision, dimension(NSTEP) :: ft_bar_t, ft_t, fa_bar_t, fa_t
+    double precision :: Nnorm, Mnorm, dlnA, dlnAd, dlnAv
+
+    complex*16, dimension(NDIM) :: wseis_syn, wseis_dat, wseis, wseis3, wseis_rec
+    complex*16, dimension(NDIM) :: trans_mtm, top_mtm, bot_mtm   ! removed trans
+    complex*16 :: wtr_use, wtr_use_unw, cci, junkc
+    character*20 hfmt
+    character*100 filename
+
+    ! -----------------
+    integer, intent(in) :: nrec, ievent
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+    double precision, dimension(nrec), intent(in) :: tstart, tend
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+    double precision, dimension(NSTEP,NCOMP,nrec),optional :: data_recon
+
+    integer itime, icomp, istart1, iend1, istart2, iend2, nlen
+    double precision, dimension(NSTEP) :: time_window
+    double precision :: norm, junk, ntemp, Ffac, win_extend, planch_fac
+    double precision :: dtau_mtm, dlnA_mtm
+    ! -----------------
+
+    double precision :: twopi, wtr_mtm, fac, cr_shift, cc, cc_max, sfac1, sfac2
+    double precision :: tshift_xc, ampmax, ampmax_unw, omega
+    double precision :: t_stop, t_start, df, df_new, dw, temp
+    integer :: ipwr_t, ipwr_w, ishift, n_left, n_right, fnum, i1
+    integer :: i_right, i_right_stop, i_amp_max, i_amp_max_unw, idf_new
+
+    ! error associated with measurement
+    double precision :: meas_pert, rand1, ppert
+
+    integer :: i,j,ik,n,ictaper,irec
+
+    !=======================================================
+
+    twopi = 2.*PI
+    cci = cmplx(0.,1.)
+    wtr_mtm = 1.e-10
+
+    ! parameters for tapers
+    ipwr_t = 10                  ! for 1 - [cos(t)]^(ipwr)
+    ipwr_w = 10                  ! for 1 - [cos(w)]^(ipwr)
+
+    adj_syn(:,:,:) = 0.
+    !icomp = 1
+
+    print *, ' (mtm_adj.f90) IKER = ', IKER
+
+    !===============
+
+    ! loop over receivers -- tstart and tend are nrec x 1 arrays
+    do irec = 1,nrec
+
+       ! loop over components
+       do icomp = 1,NCOMP
+
+          print *
+          print *, ' irec = ', irec
+
+          ! create the NON-windowed records for which the measurement is made
+          do itime = 1,NSTEP
+             dzr(itime)  = syn(itime,icomp,irec)     ! synthetic
+             dzr2(itime) = data(itime,icomp,irec)    ! data
+          enddo
+
+          ! window -- based on HWIN
+          istart1 = max(floor( (tstart(irec)) / DT), 1)
+          iend1   = min(floor( (tend(irec)  ) / DT), NSTEP)
+          nlen = iend1 - istart1
+          print *, istart1, iend1, nlen
+          if (istart1 >= iend1) stop 'Check if istart1 < iend1'
+
+          ! start and stop times -- assume t0 = 0
+          !t_start = tstart(irec)
+          !t_stop  = tend(irec)
+          t_start = istart1*DT
+          t_stop  = iend1*DT
+
+          ! parameters for time window
+          sfac1 = (2./dble(nlen))**2  ! for Welch window
+          !ipwr_t = 2                  ! for cosine window
+
+          ! initialise windowed arrays
+          dzr_win(:) = 0.             ! length npt (npt is in wave2d_constants.f90)
+          dzr0_win(:) = 0.            ! length npt
+          dzr2_win(:) = 0.            ! length npt
+
+          ! PRE-PROCESSING -- the type of window does not seem to matter too much
+          ! (It is not necessary to fix the endpoints, I think.)
+          ! Note that dzr_win is length npt, but dzr is length NSTEP
+          do i = 1,nlen
+             !fac = 1.                                        ! boxcar window
+             !fac = 1 - sfac1*((i-1) - dble(nlen)/2.)**2     ! welch window
+             fac = 1. - cos(PI*(i-1)/(nlen+1))**ipwr_t        ! cosine window
+             !print *, fac
+
+             dzr_win(i)  = dzr(i+istart1) * fac  ! syn, windowed
+             dzr2_win(i) = dzr2(i+istart1)* fac  ! dat, windowed
+          enddo
+          dzr0_win(:) = dzr_win(:)  ! syn, windowed
+
+          ! post-processing taper, length NSTEP
+          time_window(:) = 0.
+          do i = 1,nlen
+             !fac = 1.                                        ! boxcar window
+             !fac = 1 - sfac2*((i-1) - dble(nlen)/2.)**2     ! welch window
+             fac = 1. - cos(PI*(i-1)/(nlen+1))**ipwr_t        ! cosine window
+
+             time_window(i) = fac
+          enddo
+
+          !------------------------------------------------------------------
+          ! Determine cross-correlation traveltime measurement.
+          ! Check that the output is consistent with your convention.
+          !------------------------------------------------------------------
+
+          !cr_shift = 300.0
+          cr_shift = 2.*nlen*DT        ! 14-Nov-2006
+
+          n_left  = ceiling( -1.0 * cr_shift / DT )
+          n_right = floor( cr_shift / DT )
+          ishift = 0
+          cc_max = 0.
+
+          do i = n_left, n_right, 1
+             cc = 0.
+             do j = 1, nlen
+                if((j+i) > 1 .and. (j+i) < nlen) cc = cc + dzr_win(j) * dzr2_win(j+i)   ! cross-correlation
+             enddo
+             if( cc > cc_max) then 
+                cc_max = cc
+                ishift = i
+             endif
+          enddo
+          tshift_xc = ishift*DT  ! KEY: cross-correlation time shift
+
+          !==================================================================
+          ! CROSS-CORRELATION ADJOINT SOURCES (these are computed always)
+          ! The number of time-steps we deal with is the length of the measurement window.
+
+          !synt(:) = dzr0_win(:)
+          !datt(:) = dzr2_win(:)
+          syn_displ(1:nlen) = dzr0_win(1:nlen)     ! windowed synthetic displacement
+          dat_displ(1:nlen) = dzr2_win(1:nlen)     ! windowed data displacement, UNSHIFTED
+
+          ! calculate velocity and acceleration from synthetic displacement
+          do i = 2, nlen-1
+             syn_veloc(i) = (syn_displ(i+1) - syn_displ(i-1)) / (2.*DT)
+             dat_veloc(i) = (dat_displ(i+1) - dat_displ(i-1)) / (2.*DT)
+          enddo
+          syn_veloc(1)    = (syn_displ(2) - syn_displ(1)) / DT
+          syn_veloc(nlen) = (syn_displ(nlen) - syn_displ(nlen-1)) /DT
+          dat_veloc(1)    = (dat_displ(2) - dat_displ(1)) / DT
+          dat_veloc(nlen) = (dat_displ(nlen) - dat_displ(nlen-1)) /DT
+
+          do i = 2, nlen-1
+             syn_accel(i) = (syn_veloc(i+1) - syn_veloc(i-1)) / (2.*DT)
+          enddo
+          syn_accel(1)    = (syn_veloc(2) - syn_veloc(1)) / DT
+          syn_accel(nlen) = (syn_veloc(nlen) - syn_veloc(nlen-1)) /DT
+
+          ! normalization factors
+          ! NOTE sign convention for N (Qinya, not GJI paper)
+          Nnorm = -DT * sum( syn_displ(:) * syn_accel(:) )
+
+          Mnorm =  DT * sum( syn_displ(:) * syn_displ(:) )
+
+          ! cross-correlation traveltime adjoint source
+          ft_bar_t(:) = -syn_veloc(:) / Nnorm       ! BD kernel
+          ft_t(:)     = -tshift_xc * ft_bar_t(:)    ! misfit kernel (note sign)
+
+          ! cross-correlation amplitude MEASUREMENT
+          ! definition of Dahlen and Baig (2002), Eq. 3,17,18 : dlnA = Aobs/Asyn - 1
+          dlnAd = sqrt( (DT * sum( dat_displ(:) * dat_displ(:) )) / (DT * sum( syn_displ(:) * syn_displ(:) )) ) - 1.
+          dlnAv = sqrt( (DT * sum( dat_veloc(:) * dat_veloc(:) )) / (DT * sum( syn_veloc(:) * syn_veloc(:) )) ) - 1.
+
+          ! cross-correlation amplitude adjoint source
+          ! You have TWO OPTIONS: measure the amplitudes based on DISPLACEMENT or VELOCITY
+          ! Default option has been IAMP_VEL = 0
+          if(IAMP_VEL == 0) then     ! DISPLACEMENT
+             fa_bar_t(:) = syn_displ(:) / Mnorm 
+             dlnA = dlnAd
+          else                        ! VELOCITY
+             fa_bar_t(:) = -syn_accel(:) / Nnorm
+             dlnA = dlnAv
+          endif
+          fa_t(:) = -dlnA * fa_bar_t(:)    ! misfit kernel
+
+          if(0==1) then
+             !print *
+             print *, 'cross-correlation measurments:'
+             print *, '       dT = ', tshift_xc
+             print *, '   dlnA-d = ', dlnAd
+             print *, '   dlnA-v = ', dlnAv
+             print *, '        N = ', Nnorm
+             print *, '        M = ', Mnorm
+          else
+             write(*,'(a8,i5,a8,1f18.10,a8,1f18.10)') &
+                  'irec = ', irec, ', dT = ', tshift_xc, ', dA = ', dlnA
+          endif
+
+          ! additional files for checking (measure_socal_adj.m)
+          if(WRITE_SEISMO_RECONSTRUCT) then
+             ! time domain : time, data-disp, syn-disp, syn-vel, syn-accel
+             write(filename,'(a,i5.5,a)') 'syn_time_', irec, '.dat'
+             open(29,file=filename,status='unknown')
+             do i = 1,nlen
+                write(29,'(5e18.8)') i*DT, dat_displ(i), syn_displ(i), syn_veloc(i), syn_accel(i)
+             enddo
+             close(29)
+
+             ! xcorr adjoint sources : traveltime (banana-doughnut), traveltime (misfit), amplitude (banana-doughnut), amplitude (misfit)
+             write(filename,'(a,i5.5,a)') 'xcorr_time_', irec, '.dat'
+             open(39,file=filename,status='unknown')
+             do i = 1,nlen
+                if(IAMP_VEL == 0) then
+                   write(39,'(6e18.8)') ft_bar_t(i), ft_t(i), fa_bar_t(i), fa_t(i), -syn_accel(i)/Nnorm, -dlnAv*(-syn_accel(i)/Nnorm)
+                else
+                   write(39,'(6e18.8)') ft_bar_t(i), ft_t(i), fa_bar_t(i), fa_t(i), syn_displ(i)/Mnorm, -dlnAd*(syn_displ(i)/Mnorm)
+                endif
+             enddo
+             close(39)
+          endif
+
+          !if(irec==4) stop 'testing'
+
+          !===================================================
+          ! MULTITAPER MEASUREMENTS
+
+          ! initialize multitaper measurements
+          dtau_mtm = 0.
+          dlnA_mtm = 0.
+
+          if(IKER==3 .or. IKER==4) then     ! multitaper measurements
+
+             ! calculate frequency step and number of frequencies
+             df = 1./(npt*DT)
+             dw = twopi / (npt*DT)
+             fnum = npt/2 + 1
+
+             ! KEY: assemble omega vector 
+             wvec(:) = 0.
+             do j = 1,npt
+                if(j > npt/2) then
+                   wvec(j) = dw*(j-npt-1)   ! negative frequencies in second half
+                else
+                   wvec(j) = dw*(j-1)       ! positive frequencies in first half
+                endif
+             enddo
+
+             ! numerical factor for Plancherel theorem
+             ! THIS COST US QUITE A BIT OF TIME TO FIGURE OUT
+             planch_fac = dble(npt * DT * DT)
+
+             !----------------
+
+             ! apply time shift to DATA (observed seismogram)
+             print *, ' shift observed seismogram by (s) : ', tshift_xc
+             do i = 1, nlen
+                dzr3_win(i) = 0.
+                if( (ishift+i) > 1 .and. (ishift+i) < nlen ) dzr3_win(i) = dzr2_win(i+ishift)
+                dzr30_win(i) = dzr3_win(i) 
+             enddo
+
+             ! create complex synthetic seismogram and complex data seismogram
+             ! wseis_syn -- windowed synthetic record in freq domain
+             ! wseis_dat -- windowed data record, shifted by xcorr-tt, in freq domain
+             wseis_syn(:) = cmplx(0.,0.)
+             wseis_dat(:) = cmplx(0.,0.)
+             wseis_syn(1:nlen) =  dzr0_win(1:nlen)
+             wseis_dat(1:nlen) = dzr30_win(1:nlen)
+
+             ! apply FFT to get frequency domain versions (syn and data)
+             call fft(lnpt,wseis_syn,FORWARD_FFT,DT)
+             call fft(lnpt,wseis_dat,FORWARD_FFT,DT)
+
+             ! get the tapers
+             call staper(nlen, NPI, NTAPER, tas, NDIM, ey1, ey2)
+
+             ! format statement -- might be a problem with some Fortran packages
+             write(hfmt,'(a,i2.2,a)') '(', NTAPER,'e18.6)'
+
+             !------------------------------------------------------------------
+
+             ! initialize transfer function terms
+             top_mtm(:)   = cmplx(0.,0.)
+             bot_mtm(:)   = cmplx(0.,0.)
+             trans_mtm(:) = cmplx(0.,0.)
+
+             do ictaper = 1, NTAPER  ! loop over tapers
+
+                ! time domain: apply taper ictaper to synth and obs windowed seismograms 
+                ! these get written over at each loop iteration of ictaper
+                do i = 1, nlen
+                   dzr_win(i)  =  dzr0_win(i) * tas(i,ictaper)   ! syn(t), single-tapered and windowed
+                   dzr3_win(i) = dzr30_win(i) * tas(i,ictaper)   ! dat(t), single-tapered and windowed
+                enddo
+
+                ! create complex seismograms
+                wseis(:)  = cmplx(0.,0.)
+                wseis3(:) = cmplx(0.,0.)
+                wseis(1:nlen)  = cmplx(dzr_win(1:nlen),0.)  ! syn(t), single-tapered and windowed
+                wseis3(1:nlen) = cmplx(dzr3_win(1:nlen),0.) ! dat(t), single-tapered and windowed
+
+                ! apply FFT to get complex spectra
+                call fft(lnpt,wseis, FORWARD_FFT,DT)   ! syn
+                call fft(lnpt,wseis3,FORWARD_FFT,DT)   ! dat
+
+                ! find max spectral power for single taper
+                ! --> could also use maxval and maxloc
+                ampmax = 0.
+                ampmax_unw = 0.
+                do i = 1, fnum   ! loop over frequencies
+                   if( abs(wseis(i)) > ampmax) then              ! syn, single-tapered
+                      ampmax = abs(wseis(i))
+                      i_amp_max = i
+                   endif
+                   if( abs(wseis_syn(i)) > ampmax_unw) then      ! syn
+                      ampmax_unw =  abs(wseis_syn(i))
+                      i_amp_max_unw = i
+                   endif
+                enddo
+
+                ! compute water level for single taper measurement
+                wtr_use     = cmplx(ampmax * WTR, 0.)       ! syn
+                wtr_use_unw = cmplx(ampmax_unw * WTR, 0.)   ! syn, single-tapered
+
+                ! determine i_right values using the power in the (untapered) synthetic 
+                ! these variables define maximum frequency for measurement
+                ! i_right_stop = 1 --> stop at frequency i_right, not fnum
+                i_right = fnum 
+                i_right_stop = 0 
+                do i = 1,fnum             ! loop over frequencies
+                   if(i > i_amp_max_unw .and. abs(wseis_syn(i)) <= abs(wtr_use_unw) .and. i_right_stop == 0) then 
+                      i_right_stop = 1
+                      i_right = i
+                   endif
+                   if(i > i_amp_max_unw .and. abs(wseis_syn(i)) >= 10.*abs(wtr_use_unw) .and. i_right_stop == 1) then 
+                      i_right_stop = 0 
+                      i_right = i
+                   endif
+                enddo  ! frequencies: i = 1,fnum
+
+                ! loop over frequencies
+                do i = 1,fnum
+
+                   ! calculate top and bottom of transfer function for multitapers
+                   ! NOTE THAT THESE QUANTITIES ARE SUMMED OVER THE TAPERS AS WELL
+                   top_mtm(i) = top_mtm(i) +  wseis3(i) * conjg(wseis(i))   ! uses data and syn
+                   bot_mtm(i) = bot_mtm(i) +  wseis(i)  * conjg(wseis(i))   ! uses syn only
+
+                   ! calculate transfer function for single taper measurement using water level
+                   ! CHT: trans IS NEVER USED HERE
+                   !if(abs(wseis(i)) >  abs(wtr_use)) trans(i) = wseis3(i) / wseis(i)
+                   !if(abs(wseis(i)) <= abs(wtr_use)) trans(i) = wseis3(i) / (wseis(i)+wtr_use)
+
+                enddo  ! frequencies: i = 1,fnum
+
+                !print *, ' taper number ', ictaper, ' out of ', NTAPER
+
+             enddo  ! tapers: ictaper = 1,NTAPER
+
+             ! it appears that this has a negligible effect on the recovery of seismograms
+             !i_right = fnum
+
+             !------------------------------------------------------------------
+             ! Multi-taper measurement, calculation, and output
+             !------------------------------------------------------------------
+
+             ! find water level for multi-taper measurement
+             ampmax = 0.
+             do i = 1, fnum
+                if( abs(bot_mtm(i)) > ampmax) then 
+                   ampmax =  abs(bot_mtm(i))
+                   i_amp_max = i
+                endif
+             enddo
+             wtr_use = cmplx(ampmax * wtr_mtm**2, 0.)       ! original expression
+             !wtr_use = cmplx(ampmax * 0.01, 0.)            ! Qinya test value
+
+             ! calculate transfer function using water level
+             !do i = 1, fnum
+             !  if(abs(bot_mtm(i)) >  abs(wtr_use)) trans_mtm(i) = top_mtm(i) / bot_mtm(i)
+             !  if(abs(bot_mtm(i)) <= abs(wtr_use)) trans_mtm(i) = top_mtm(i) / (bot_mtm(i)+wtr_use)
+             !enddo
+             do i = 1, fnum
+                if(abs(bot_mtm(i)) <= abs(wtr_use)) bot_mtm(i) = bot_mtm(i) + wtr_use
+             enddo
+             trans_mtm(1:fnum) = top_mtm(1:fnum) / bot_mtm(1:fnum)
+
+             !=======================================================
+             ! construct time series : tau(omega), dlnA(omega)
+
+             ! taper function for the FREQUENCY domain
+             nw = dble(i_right - 1)
+
+             ! loop to calculate phase and amplitude
+             ! NOTE: here we include the (cross-correlation) time shift
+             dtau_w(:) = 0.
+             dlnA_w(:) = 0.
+             w_taper(:) = 0.
+             do i = 2, i_right   ! start from 1 to avoid dividing by 0
+
+                !wvec(i)     = dw*i     ! do not divide by zero
+                !dtau_w(i)   = -atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) + tshift_xc
+                !dtau_w(i)   = -(1./wvec(i)) * atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) + tshift_xc
+
+                dtau_w(i)   = (-1./wvec(i)) * atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) + tshift_xc
+                dlnA_w(i)   = abs(trans_mtm(i)) - 1.
+
+                ! type of filter in the freq domain : boxcar, welch, cosine
+                !w_taper(i) = 1.
+                !w_taper(i) = 1. - (2./nw)**2 * ((i-1) - nw/2.)**2
+                w_taper(i) = 1. - cos(PI*(i-1)/(nw+1))**ipwr_w
+             enddo
+
+             ! TESTING: create a flat transfer function to compare with adjoint sources
+             !dtau_w(:) = tshift_xc
+             !dlnA_w(:) = dlnA
+
+             ! compute normalization factor for W(w)
+             ! factor of 2 takes into account integration from -infty to +infty
+             Ffac = 2. * dw*sum(w_taper(:) )     ! crude integration
+
+             ! modified frequency-domain tapers (see Latex notes)
+             ! In theory, these would incorporate the error functions sigma_p and sigma_q.
+             wp_taper(:) = w_taper(:) / Ffac
+             wq_taper(:) = w_taper(:) / Ffac
+
+             if(WRITE_MTM_FILES) then
+                ! write transfer function to file
+                write(filename,'(a,i5.5,a)') 'transfer_freq_', irec, '.dat'
+                open(91,file=filename,status='unknown')
+                do i = 1, i_right 
+                   write(91,'(4e18.8)') wvec(i)/twopi, dtau_w(i), dlnA_w(i), w_taper(i)
+                enddo
+                close(91)
+
+                write(filename,'(a,i5.5,a)') 'transfer_freq_int_', irec, '.dat'
+                open(91,file=filename,status='unknown')
+                write(91,*) Ffac
+                close(91)
+             endif
+
+             ! compute multitaper measurements (crude integration)
+             ! These formulas are equivalent to using a BOXCAR window for the taper,
+             ! and the values should be close to the cross-correlation values.
+             !dtau_mtm = 1. / (i_right*dw) * dw*sum( dtau_w(1:i_right) )
+             !dlnA_mtm = 1. / (i_right*dw) * dw*sum( dlnA_w(1:i_right) )
+             dtau_mtm = sum( dtau_w(1:i_right) ) / i_right
+             dlnA_mtm = sum( dlnA_w(1:i_right) ) / i_right
+
+             ! reconstruct data (wseis_rec) from synthetics (wseis_syn) using the transfer function (trans_mtm)
+             if(WRITE_SEISMO_RECONSTRUCT) then
+
+                ! Reconstruct mtm fit seismograms : syn*tran
+                ! d(w) = s(w) T(w) exp[-i w dT]
+                ! trans_mtm is for transferring syn --> SHIFTED data
+                wseis_rec(:) = cmplx(0.,0.)
+                do i = 1,i_right
+                   omega = wvec(i)
+
+                   ! mathematically, these are identical
+                   ! numerically, they produce nearly identical results
+                   wseis_rec(i) = wseis_syn(i)  * (1.+ dlnA_w(i)) * exp(-cci*omega*dtau_w(i))
+                   !wseis_rec(i) = wseis_syn(i) * trans_mtm(i) * exp(-cci*omega*tshift_xc)
+
+                   !wseis_rec(i) = wseis_syn(i)*exp(-cci*omega*tshift_xc)*trans_mtm(i)  ! sign
+                   !wseis_rec(i) = wseis_syn(i) * exp(-cci*omega*dtau_w(i)*w_taper(i)) * (1.+ dlnA_w(i)*w_taper(i))
+                enddo
+
+                ! inverse FFT into time domain
+                call fftinv(lnpt,wseis_rec,REVERSE_FFT,DT,tseis_recon)
+
+                write(filename,'(a,i5.5,a)') 'recovered_seis_time_', irec, '.dat'
+                open(17,file=filename,status='unknown')
+                do i = 1,nlen
+                   write(17,'(2e18.8)') DT*i, tseis_recon(i)
+                enddo
+                close(17)
+
+                ! write power spectra (a.k.a. spectral amplitude) to files
+                ! Note that the spectral power for a uniform time shift will not be apparent;
+                ! only the amplitudes will appear.
+                ! Note that the transfer function (trans_mtm) deals with the SHIFTED synthetics.
+                write(filename,'(a,i5.5,a)') 'recovered_seis_freq_', irec, '.dat'
+                open(91,file=filename,status='unknown')
+                do i = 1,i_right 
+
+                   omega = wvec(i)
+                   wseis_rec(i) = wseis_syn(i) * (1.+ dlnA_w(i)) * exp(-cci*omega*dtau_w(i))
+                   !wseis_rec(i) = wseis_syn(i) * (1. + dlnA_mtm) * exp(-cci*omega*tshift_xc)  ! xcor shift
+                   !wseis_rec(i) = wseis_syn(i) * trans_mtm(i) * exp(-cci*omega*tshift_xc)
+
+                   ! w, syn, dat, dat-recon
+                   write(91,'(4e18.8)') wvec(i), abs(wseis_syn(i)), abs(wseis_dat(i)), abs(wseis_rec(i))
+                enddo
+                close(91)
+
+             endif
+
+             !endif  ! IKER==3,4
+
+             !===================================================
+             ! FFT TESTING: to determine what conventions we are using!
+             ! We do this by taking a function, s(t) and its time derivative,
+             ! and then computing fourier transforms.
+
+             if(0==1) then
+
+                ! create complex synthetic seismogram and complex data seismogram
+                wseis_syn(:) = cmplx(0.,0.)
+                wseis_dat(:) = cmplx(0.,0.)
+                wseis_syn(1:nlen) = cmplx(syn_displ(1:nlen),0.)  ! displacement
+                wseis_dat(1:nlen) = cmplx(syn_veloc(1:nlen),0.)  ! velocity
+
+                print *, '-----------------------------'
+                print *, FORWARD_FFT
+                print *, wseis_syn(100), wseis_dat(100)
+
+                ! FFT. to get frequency domain versions
+                call fft(lnpt,wseis_syn,FORWARD_FFT,DT)   ! displacement
+                call fft(lnpt,wseis_dat,FORWARD_FFT,DT)   ! velocity
+
+                print *, wseis_syn(100), wseis_dat(100)
+                print *, FORWARD_FFT
+                print *, '-----------------------------'
+
+                if(1==1) then    ! check Fourier convention
+
+                   ! check convention -- s_d(w)*iw should give velocity
+                   do i = 1,i_right   ! KEY: do not go too high frequency
+                      dtemp(i) = wseis_syn(i) * cmplx(0.,wvec(i))
+                      !dtemp(npt-i+1) = wseis_syn(npt-i+1) * cmplx(0.,wvec(npt-i+1))
+                   enddo
+
+                   ! back to real time series
+                   ! if our convention is consistent, then wp_taper should match syn_veloc
+                   call fftinv(lnpt,wseis_syn,REVERSE_FFT,DT,fp)    ! displacement
+                   call fftinv(lnpt,wseis_dat,REVERSE_FFT,DT,fq)    ! velocity
+                   call fftinv(lnpt,dtemp,REVERSE_FFT,DT,wp_taper)  ! should be velocity
+
+                   open(91,file='test.dat',status='unknown')
+                   do i = 1,nlen*2
+                      write(91,'(5e18.8)') syn_displ(i),fp(i),syn_veloc(i),fq(i),wp_taper(i)
+                   enddo
+                   close(91)
+
+                else            ! check Plancherel's theorem
+
+                   ! discrete form of Plancherel's theorem
+                   junk  = sum(syn_displ(:)*syn_veloc(:))
+                   junkc = (1./planch_fac) * sum( wseis_syn(:) * conjg(wseis_dat(:)) )
+
+                   print *, 'checking Plancherel theorem...'
+                   print *, junk
+                   print *, junkc
+                   print *, real(junkc)
+                   print *, planch_fac, 1./planch_fac
+
+                   print *, ' this should be 1 : ', (junk / real(junkc))
+                   print *
+                   print *, '   Nt = ', nlen
+                   print *, '   dt = ', DT
+                   print *, '  wNy = ', twopi/(2.*DT)
+                   print *, '  wRy = ', twopi/(nlen*DT)
+                   print *
+                   print *, '   Nw = ', npt
+                   print *, '   dw = ', dw
+
+                endif
+
+                stop 'testing the FFT from mtm_adj.f90'
+
+             endif
+
+             !==================================================================
+             ! MULTITAPER ADJOINT SOURCES
+
+             !if(IKER==3 .or. IKER==4) then
+
+             pw_adj(:,:) = 0.      ;  qw_adj(:,:) = 0.
+             pt_adj(:,:) = 0.      ;  qt_adj(:,:) = 0.
+             dtau_pj_t(:,:) = 0.   ;  dlnA_qj_t(:,:) = 0.
+             fp(:) = 0.            ;  fq(:) = 0.
+
+             bot_p(:) = cmplx(0.,0.)
+             top_p_ntaper(:,:) = cmplx(0.,0.)
+
+             ! This loops over the tapers to get the DENOMINATOR term of pj(w).
+             ! It also stores the displacement field sj(w), which is in the NUMERATOR term of p(w).
+             do ictaper = 1,NTAPER
+
+                ! apply TAPER ictaper to windowed synthetics 
+                dzr_win(:) = 0.
+                do i = 1,nlen   ! time domain
+                   dzr_win(i) = dzr0_win(i) * tas(i,ictaper)
+                enddo
+
+                ! create complex seismograms (tapered synthetics, sj(w))
+                wseis(:) = cmplx(dzr_win(:),0.)
+
+                ! apply f.t. to get complex spectra
+                call fft(lnpt,wseis,FORWARD_FFT,DT)
+
+                ! bottom of p function for multitapers (complex)
+                do i = 1, i_right
+                   bot_p(i) = bot_p(i) + wseis(i)*conjg(wseis(i))
+                enddo
+
+                ! term in numerator (sj) (complex)
+                top_p_ntaper(:,ictaper) = wseis(:)     
+
+             enddo  ! loop over tapers
+
+             do ictaper = 1,NTAPER   ! loop over tapers
+                !print *, ' taper number ', ictaper, ' out of ', NTAPER
+
+                top_p(:)   = top_p_ntaper(:,ictaper)  ! top of p function for multitapers
+                pwc_adj(:) = cmplx(0.,0.)
+                qwc_adj(:) = cmplx(0.,0.)
+
+                ! compute pj(w) and qj(w) -- j term is in top_p
+                ! (these get over-written each loop)
+                do i = 2, i_right  ! start from index 2 to avoid division by w=0
+                   !omega = dw*i   ! omega should not =0
+                   omega = wvec(i)
+
+                   ! formulas for Fourier convention FFT --> e^(-iwt)
+                   pwc_adj(i) = cmplx(0.,1./omega) * top_p(i) / bot_p(i)  ! (1/w)i = (-iw)/(-w^2) = -1/(iw)
+                   qwc_adj(i) = cmplx(0.,omega) * pwc_adj(i)              ! d/dt <--> -iw
+
+                   ! formulas for Fourier convention FFT --> e^(iwt)
+                   !pwc_adj(i) = cmplx(0.,-1./omega) * top_p(i) / bot_p(i)  ! (-1/w)i = (iw)/(-w^2) = 1/(iw)
+                   !qwc_adj(i) = cmplx(0.,-omega) * pwc_adj(i)              ! d/dt <--> -iw
+
+                enddo
+
+                ! SAVE A COPY HERE -- fftinv
+                ctemp(:) = pwc_adj(:)
+                dtemp(:) = qwc_adj(:)
+
+                ! EXTRA OUTPUT : IFFT into the time domain : pj(w) --> pj(t) and qj(w) --> qj(t)
+                if(WRITE_MTM_FILES) then
+                   call fftinv(lnpt,pwc_adj,REVERSE_FFT,DT,pt_adj(:,ictaper))
+                   call fftinv(lnpt,qwc_adj,REVERSE_FFT,DT,qt_adj(:,ictaper))
+                endif
+
+                ! incorporate measurement
+                ! create [dtau(w) pj(w) W(w)] and save [dtau(t) * pj(t) * W(t)]
+                ! create [dlnA(w) qj(w) W(w)] and save [dlnA(t) * qj(t) * W(t)]
+                dtau_pj_wc(:) = cmplx(0.,0.)
+                dlnA_qj_wc(:) = cmplx(0.,0.)
+                dtau_pj_wc(:) = twopi * ctemp(:) * cmplx(dtau_w(:),0.) * cmplx(wp_taper(:),0.)
+                dlnA_qj_wc(:) = twopi * dtemp(:) * cmplx(dlnA_w(:),0.) * cmplx(wq_taper(:),0.)
+                !dtau_pj_wc(:) = twopi * ctemp(:) * cmplx(wp_taper(:),0.)   ! no measurement
+                !dlnA_qj_wc(:) = twopi * dtemp(:) * cmplx(wq_taper(:),0.)   ! no measurement
+
+                ! IFFT into the time domain
+                call fftinv(lnpt,dtau_pj_wc,REVERSE_FFT,DT,dtau_pj_t(:,ictaper))
+                call fftinv(lnpt,dlnA_qj_wc,REVERSE_FFT,DT,dlnA_qj_t(:,ictaper))
+
+                ! create adjoint source
+                fp(:) = fp(:) + tas(:,ictaper) * dtau_pj_t(:,ictaper)
+                fq(:) = fq(:) + tas(:,ictaper) * dlnA_qj_t(:,ictaper)
+
+             enddo
+
+             if(WRITE_MTM_FILES) then
+                ! write banana-doughnut adjoint sources to file
+                write(filename,'(a,i5.5,a)') 'test_fadj_t_', irec, '.dat'
+                open(21,file=filename,status='unknown')
+                do i = 1,nlen
+                   write(21,*) sngl(fp(i)), sngl(fq(i))
+                enddo
+                close(21)
+
+                ! write banana-doughnut adjoint sources to file
+                open(21,file='test_fadj_t.dat',status='unknown')
+                do i = 1,nlen
+                   write(21,*) sngl(fp(i)), sngl(fq(i))
+                enddo
+                close(21)
+
+                ! time domain : tapers and other time series 
+                open(18,file='test_hj_t.dat',status='unknown')
+                open(19,file='test_pj_t.dat',status='unknown')
+                open(20,file='test_Pj_t.dat',status='unknown')
+                open(21,file='test_Pj_hj_t.dat',status='unknown')
+                open(22,file='test_qj_t.dat',status='unknown')
+                open(23,file='test_Qj_t.dat',status='unknown')
+                open(24,file='test_Qj_hj_t.dat',status='unknown')
+
+                do i = 1,nlen  ! loop over time points
+                   write(18,hfmt) ( sngl(tas(i,ictaper)), ictaper=1,NTAPER )                         ! hj(t)
+                   write(19,hfmt) ( sngl(pt_adj(i,ictaper)), ictaper=1,NTAPER )                      ! pj(t)
+                   write(20,hfmt) ( sngl(dtau_pj_t(i,ictaper)), ictaper=1,NTAPER )                   ! Pj(t)
+                   write(21,hfmt) ( sngl(dtau_pj_t(i,ictaper) * tas(i,ictaper)), ictaper=1,NTAPER )  ! hj(t) Pj(t)
+
+                   write(22,hfmt) ( sngl(qt_adj(i,ictaper)), ictaper=1,NTAPER )                      ! qj(t)
+                   write(23,hfmt) ( sngl(dlnA_qj_t(i,ictaper)), ictaper=1,NTAPER )                   ! Qj(t)
+                   write(24,hfmt) ( sngl(dlnA_qj_t(i,ictaper) * tas(i,ictaper)), ictaper=1,NTAPER )  ! hj(t) Qj(t) 
+                enddo
+
+                close(18) ; close(19) ; close(20) ; close(21) ; close(22) ; close(23) ; close(24)
+             endif
+
+          endif  ! if IKER==3,4
+
+          ! generate a random number to simulate error in the measurement
+          ! ppert determines the range over which the perturbed measurement will be
+          ppert = 0.
+          call random_number(rand1)
+          meas_pert = 1. + ppert*(2.*rand1 - 1.)
+          !meas_pert = 1. + ppert
+
+          !print *, tshift_xc, meas_pert, tshift_xc * meas_pert
+
+          ! CREATE THE ADJOINT SOURCES
+          ! HERE WE APPLY A TAPER TO FIX THE ENDPOINTS OF THE TIME WINDOW
+          do i = 1,nlen   ! loop over points WITHIN the (OUTER) time window
+
+             i1 = istart1 - 1 + i
+
+             ! store the reconstructed data: d'(w) = T(w) s(w)
+             if(WRITE_SEISMO_RECONSTRUCT) then
+                if(IKER==4 .or. IKER==4) data_recon(i1,icomp,irec) = tseis_recon(i)
+             endif
+
+             if(IKER==0) then
+                adj_syn(i1,icomp,irec) = ( syn(i1,icomp,irec) -  data(i1,icomp,irec) ) * time_window(i) * meas_pert
+
+             elseif(IKER==1) then
+                ! meas_pert = 1.0 for most runs
+                adj_syn(i1,icomp,irec) = ft_t(i) * time_window(i) * meas_pert
+
+             elseif(IKER==2) then
+                adj_syn(i1,icomp,irec) = fa_t(i) * time_window(i) * meas_pert
+
+             elseif(IKER==3) then
+                adj_syn(i1,icomp,irec) = fp(i) * time_window(i)
+
+             elseif(IKER==4) then
+                adj_syn(i1,icomp,irec) = fq(i) * time_window(i)
+
+             elseif(IKER==5) then
+                adj_syn(i1,icomp,irec) = ft_bar_t(i) * time_window(i)
+
+             elseif(IKER==6) then
+                adj_syn(i1,icomp,irec) = fa_bar_t(i) * time_window(i)
+             endif
+
+          enddo
+
+          ! (1) COMPUTE MEASUREMENT VECTOR
+          ! (2) COMPUTE MISFIT FUNCTION (currently only for waveform, xc-tt, xc-lnA)
+          ! IKER: (0) waveform
+          !       (1) traveltime, cross-correlation, misfit
+          !       (2) amplitude, cross-correlation, misfit
+          !       (3) traveltime, multitaper
+          !       (4) amplitude, multitaper
+
+          ! the 2 factor is needed to offset the 2 factor in Ffac
+          dtau_mtm = 2./Ffac * dw*sum( dtau_w(1:i_right) )
+          dlnA_mtm = 2./Ffac * dw*sum( dlnA_w(1:i_right) )
+
+          ! measurement values
+          imeasure = imeasure + 1    ! global counter variable
+          measure_vec(imeasure,1) = 0.5 * DT*sum( adj_syn(:,icomp,irec)**2 )
+          measure_vec(imeasure,2) = tshift_xc * meas_pert
+          measure_vec(imeasure,3) = dlnA * meas_pert
+          measure_vec(imeasure,4) = dtau_mtm     ! integrated dtau(w) -- compare with tshift_xc
+          measure_vec(imeasure,5) = dlnA_mtm     ! integrated dlnA(w) -- compare with dlnA
+
+          if(IKER==0) then
+             ! crude integration of the waveform difference
+             chi(ievent,irec,icomp,1) = 0.5 * DT*sum( adj_syn(:,icomp,irec)**2 )
+
+          elseif(IKER==1) then
+             chi(ievent,irec,icomp,1) = 0.5 * (tshift_xc * meas_pert)**2
+
+          elseif(IKER==2) then
+             chi(ievent,irec,icomp,1) = 0.5 * (dlnA * meas_pert)**2
+
+          elseif(IKER==3) then
+             chi(ievent,irec,icomp,1) = 0.5 * 2.*dw*sum( wp_taper(1:i_right) * (dtau_w(1:i_right)**2) )
+
+          elseif(IKER==4) then
+             chi(ievent,irec,icomp,1) = 0.5 * 2.*dw*sum( wq_taper(1:i_right) * (dlnA_w(1:i_right)**2) )
+
+          endif
+
+       enddo  ! loop over components (icomp=1,NCOMP)
+
+    enddo  ! loop over receivers (irec=1,nrec)
+
+    !------------------------------------------------------------------
+  end subroutine mtm_adj
+  !------------------------------------------------------------------
+  ! END MAIN PROGRAM
+  !------------------------------------------------------------------
+        
+!------------------------------------------------------------------
+  subroutine fft(n,xi,zign,dt)
+! Fourier transform
+! This inputs AND outputs a complex function.
+! The convention is FFT --> e^(-iwt)
+!------------------------------------------------------------------
+      complex*16, dimension(NDIM) :: xi
+      integer :: n
+      double precision :: dt
+
+      complex*16 :: wk, hold, q
+      double precision :: m(25)
+      double precision :: zign,flx,v
+      integer :: lblock,k,fk,jh,ii,istart
+      integer :: l,iblock,nblock,i,lbhalf,j,lx
+
+      ! sign must be +1. or -1.
+      if(zign >= 0.) then
+        zign = 1.
+      else
+        zign = -1.
+      endif
+
+      lx = 2**n
+      do 1 i=1,n
+    1 m(i) = 2**(n-i)
+      do 4 l=1,n
+      nblock = 2**(l-1)
+      lblock = lx/nblock
+      lbhalf = lblock/2
+      k = 0
+      do 4 iblock=1,nblock
+      fk = k
+      flx = lx
+
+      v = zign*2.*PI*fk/flx         ! Fourier convention
+
+      wk = cmplx(cos(v),-sin(v))   ! sign change to -sin(v) 17-Nov-2006
+      istart = lblock*(iblock-1)
+
+      do 2 i=1,lbhalf
+      j  = istart+i
+      jh = j+lbhalf
+      q = xi(jh)*wk
+      xi(jh) = xi(j)-q
+      xi(j)  = xi(j)+q
+    2 continue
+
+      do 3 i=2,n
+      ii = i
+      if(k < m(i)) go to 4
+    3 k = k-m(i)
+    4 k = k+m(ii)
+      k = 0
+      do 7 j=1,lx
+      if(k < j) go to 5
+      hold = xi(j)
+      xi(j) = xi(k+1)
+      xi(k+1) = hold
+    5 do 6 i=1,n
+      ii = i
+      if(k < m(i)) go to 7
+    6 k = k-m(i)
+    7 k = k+m(ii)
+
+      ! final steps deal with dt factors
+      if(zign > 0.) then       ! FORWARD FFT
+         do i = 1,lx 
+            xi(i) = xi(i)*dt   ! multiplication by dt
+         enddo
+
+      else                     ! REVERSE FFT
+         flx = flx*dt
+         do i = 1,lx 
+            xi(i) = xi(i)/flx  ! division by dt
+         enddo
+      endif
+
+  end subroutine fft
+
+!------------------------------------------------------------------
+  subroutine fftinv(npow,s,zign,dt,r)
+! inverse Fourier transform -- calls fft
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !dimension r(4096*4)
+      !complex s(4096*4)
+
+      complex*16, intent(in) :: s(NDIM)
+      double precision, intent(out) :: r(NDIM)   ! note this is REAL
+
+      !complex*16 :: stemp(NDIM)
+      double precision :: dt,zign
+      integer :: npow, nsmp, nhalf, i
+
+      nsmp = 2**npow
+      nhalf = nsmp/2
+      call rspec(s,nhalf)   ! re-structuring
+
+      call fft(npow,s,zign,dt)    ! Fourier transform
+
+      do i = 1,nsmp
+        r(i) = real(s(i))     ! REAL part
+      enddo
+ 
+  end subroutine fftinv
+
+!------------------------------------------------------------------
+  subroutine rspec(s,np2)
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !complex s(4096*4)
+
+      complex*16 :: s(NDIM)
+      integer :: np2,n,n1,i
+
+      n = 2*np2
+      n1 = np2+1
+
+      s(n1) = 0.
+!     s(1)  = 0.
+      s(1)  = cmplx( real(s(1)),0.)
+
+      do i = 1,np2
+         s(np2+i) = conjg(s(np2+2-i))
+      enddo
+
+  end subroutine rspec
+
+!------------------------------------------------------------------
+  subroutine staper(nt, fw, nev, v, ndim, a, w)
+!------------------------------------------------------------------
+!$$$$ calls tsturm, root
+!  Slepian - Thomson multi-taper procedure
+!  Slepian, D.     1978  Bell Sys Tech J v57 n5 1371-1430
+!  Thomson, D. J.  1982  Proc IEEE v70 n9 1055-1096
+!    nt    the number of points in the series
+!    fw    the time-bandwidth product (number of Rayleigh bins)
+!    nev   the desired number of tapers
+!    v     the eigenvectors (tapers) are returned in v(.,nev)
+!    a, w  work arrays dimensioned at least nt long (nt+1, nt odd)
+!    a(1..nev) contains bandwidth retention factors on output.
+!  The tapers are the eigenvectors of the tridiagonal matrix sigma(i,j)
+!  [see Slepian(1978) eq 14 and 25.] They are also the eigenvectors of
+!  the Toeplitz matrix eq. 18. We solve the tridiagonal system in
+!  tsturm for the tapers and use them in Slepians eq 18 to get the
+!  bandwidth retention factors (i.e. the eigenvalues) Thomson's
+!  normalisation is used with no attention to sign.
+      !implicit real*8(a-h,o-z)
+      !dimension a(*),w(*),v(ndim,*)
+      !parameter (pi=3.14159265358979d0,r2=1.414213562373095d0)
+
+      integer :: nt, nev, ndim
+      double precision :: fw
+      double precision :: v(NDIM,NTAPER), a(NDIM), w(NDIM)
+
+      integer :: i,j,k,m
+      integer :: nxi, lh, lp1, neven, nodd, ntot, kk, kmax, nlow, nup
+      double precision :: r2,om,com,hn,asav,rbd,dc,sm,s,sn,vmax
+
+      !-------------------------
+
+      r2 = sqrt(2.)
+
+      if(nt < 2) return
+      nxi=mod(nt,2)
+      lh=(nt/2)+nxi
+      lp1=nt+1
+      om=2.*PI*fw/nt
+      com=cos(om)
+      hn=0.5*dble(lp1)
+      do 10 i=1,lh
+        a(i)=com*(i-hn)**2
+   10   w(i)=0.5*dble(i*(nt-i))
+      if(nxi == 0) then
+        asav=a(lh)-w(lh)
+        a(lh)=a(lh)+w(lh)
+        rbd=1./(a(lh)+w(lh-1))
+      else
+        asav=w(lh-1)
+        rbd=1./(w(lh)+w(lh-1))
+        w(lh-1)=r2*w(lh-1)
+      endif
+      do 15 i=1,lh
+        a(i+lh)=w(i)*rbd
+        w(i)=a(i+lh)**2
+   15   a(i)=a(i)*rbd
+      neven=max0((nev+1)/2,1)
+      nodd=nev-neven
+!  Do the even tapers
+      call tsturm(nt,lh,a,a(lh+1),w,neven,v,ndim,w(lh+1),0)
+      do 20 i=1,neven
+        k=2*i-1
+        if(nxi == 1) v(lh,k)=r2*v(lh,k)
+          do 20 j=1,lh
+   20     v(lp1-j,k)=v(j,k)
+      if(nodd <= 0) goto 34
+!  Do the odd tapers
+      if(nxi == 0) then
+        a(lh)=asav*rbd
+      else
+        a(nt)=asav*rbd
+        w(lh-1)=asav*asav
+      endif
+      call tsturm(nt,lh-nxi,a,a(lh+1),w,nodd,v,ndim,w(lh+1),1)
+      do 30 i=1,nodd
+        k=2*i
+        if(nxi == 1) v(lh,k)=0.
+          do 30 j=1,lh
+   30     v(lp1-j,k)=-v(j,k)
+   34 ntot=neven+nodd
+!  Calculate bandwidth retention parameters
+      dc=2.*com
+      sm=0.
+      s=sin(om)
+      w(1)=om/PI
+      w(2)=s/PI
+      do 35 j=3,nt
+        sn=dc*s-sm
+        sm=s
+        s=sn
+   35   w(j)=s/(PI*(j-1))
+      do 55 m=1,ntot
+        vmax=abs(v(1,m))
+        kmax=1
+        do 40 kk=2,lh
+          if(abs(v(kk,m)) <= vmax) goto 40
+          kmax=kk
+          vmax=abs(v(kk,m))
+   40     continue
+        a(m)=0.
+        nlow=kmax-1
+          do 45 j=1,nlow
+   45     a(m)=a(m)+w(j+1)*v(nlow+1-j,m)
+        nup=nt-nlow
+          do 50 j=1,nup
+   50     a(m)=a(m)+w(j)*v(nlow+j,m)
+   55 a(m)=a(m)/v(kmax,m)
+      return
+
+  end subroutine staper
+
+!------------------------------------------------------------------
+  subroutine tsturm(nt,n,a,b,w,nev,r,ndim,ev,ipar)
+!------------------------------------------------------------------
+!$$$$ calls root
+!  Uses bisection and Sturm counting to isolate the eigenvalues of the
+!  symmetric tridiagonal matrix with main diagonal a(.) and sub/super
+!  diagonal b(.).  Newton's method is used to refine the eigenvalue in
+!  subroutine root then direct recursion is used to get the eigenvector
+!  as this is always stable.  Note  ipar=0 for even tapers   =1 for odd
+!  tapers
+      !implicit real*8(a-h,o-z)
+      !parameter (epsi=1.d-15,epsi1=5.d-15)
+      !dimension a(*),b(*),ev(*),w(*),r(ndim,*)
+
+      double precision, parameter :: epsi = 1.d-15, epsi1 = 5.d-15
+
+      double precision, dimension(NDIM) :: a, b, w, ev
+      double precision, dimension(NDIM,NTAPER) :: r
+      integer :: nt,n,ndim,nev,ipar
+
+      double precision, dimension(NDIM) :: bb
+      double precision :: q,el,elam,u,umeps,x,ddot,rnorm
+      integer :: i,j,ik,iag,m,jk,jm1
+
+      !-------------------------
+
+      if(n <= 0.or.nev <= 0) return
+      umeps=1.-epsi
+      do 5 i=1,nev
+    5 ev(i)=-1.
+      u=1.
+      do 1000 ik=1,nev
+      if(ik > 1) u=ev(ik-1)*umeps
+      el=min(ev(ik),u)
+   10 elam=0.5*(u+el)
+      if(abs(u-el) <= epsi1) goto 35
+      iag=0
+      q=a(1)-elam
+      if(q >= 0.) iag=iag+1
+      do 15 i=2,n
+      if(q == 0.) x=abs(b(i-1))/epsi
+      if(q /= 0.) x=w(i-1)/q
+      q=a(i)-elam-x
+      if(q >= 0.) iag=iag+1
+      if(iag > nev) goto 20
+   15 continue
+      if(iag >= ik) go to 20
+      u=elam
+      go to 10
+   20 if(iag == ik) go to 30
+      m=ik+1
+      do 25 i=m,iag
+   25 ev(i)=elam
+      el=elam
+      go to 10
+   30 el=elam
+      call root(u,el,elam,a,b,w,n,ik)
+   35 ev(ik)=elam
+      jk=2*ik+ipar-1
+      r(1,jk)=1.
+      r(2,jk)=-(a(1)-ev(ik))/b(1)
+      ddot=1.+r(2,jk)*r(2,jk)
+      jm1=2
+      do 45 j=3,n
+      r(j,jk)=-((a(jm1)-ev(ik))*r(jm1,jk)+b(j-2)*r(j-2,jk))/b(jm1)
+      ddot=ddot+r(j,jk)*r(j,jk)
+   45 jm1=j
+      rnorm=sqrt(nt/(2.*ddot))
+      do 50 j=1,n
+   50 r(j,jk)=r(j,jk)*rnorm
+ 1000 continue
+      return
+
+  end subroutine tsturm
+
+!------------------------------------------------------------------
+  subroutine root(u,el,elam,a,bb,w,n,ik)
+!------------------------------------------------------------------
+
+      !implicit real*8(a-h,o-z)
+      !parameter (epsi = 1.d-15, epsi1 = 5.d-15)
+      !dimension a(*),bb(*),w(*)
+
+      double precision, parameter :: epsi = 1.d-15, epsi1 = 5.d-15
+      double precision :: u,el,elam
+      double precision, dimension(NDIM) :: a,bb,w
+      integer :: n,ik
+
+      double precision :: an,b,bm,bn,del,x
+      integer :: i,iag
+
+      !----------------------
+
+    5 elam=0.5*(u+el)
+   10 if(abs(u-el) <= 1.5*epsi1) return
+      an=a(1)-elam
+      b=0.
+      bn=-1./an
+      iag=0
+      if(an >= 0.) iag=iag+1
+      do 20 i=2,n
+      if(an == 0.) x=abs(bb(i-1))/epsi
+      if(an /= 0.) x=w(i-1)/an
+      an=a(i)-elam-x
+      if(an == 0.) an=epsi
+      bm=b
+      b=bn
+      bn=((a(i)-elam)*b-bm*x-1.)/an
+      if(an >= 0.) iag=iag+1
+   20 continue
+      if(iag == ik) goto 25
+      u=elam
+      goto 30
+   25 el=elam
+   30 del=1./bn
+      if(abs(del) <= epsi1) del=sign(epsi1,del)
+      elam=elam-del
+      if(elam >= u.or.elam <= el) goto 5
+      goto 10
+
+  end subroutine root
+!-------------------------------------------
+
+end module wave2d_sub3

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub4.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub4.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_sub4.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,1386 @@
+module wave2d_sub4
+
+  use wave2d_constants
+  use wave2d_variables
+
+  implicit none
+
+  ! This module contains subroutines pertaining to making measurements
+  ! between data and synthetics, and then constructing the corresponding adjoint source.
+  !
+  ! AS OF DEC 2006, THIS CODE SHOULD BE REPLACED BY THE VERSION THAT QINYA HAS
+  ! TESTED AND CHECKED INTO THE SVN SERVER (mt_measure_adj.f90).
+  ! AS OF JAN 2008, THE MULTI-TAPER CAPABILITIES HAVE BEEN COMMENTED OUT.
+
+contains
+
+  !------------------------------------------
+
+!!$  subroutine mtm_test(ievent, nrec, syn, tstart, tend, adj_syn, data, data_recon)
+!!$
+!!$    integer, intent(in) :: nrec, ievent
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+!!$    double precision, dimension(nrec), intent(in) :: tstart, tend
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+!!$
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),optional :: data_recon
+!!$
+!!$    complex*16, dimension(NDIM) :: wseis_syn, wseis_dat, wseis_dat2
+!!$    double precision, dimension(NDIM) :: fp, fq, fq2, wvec
+!!$    double precision, dimension(NSTEP) :: syn_displ, syn_veloc
+!!$    double precision :: twopi, df, dw, w0, a0, f0
+!!$
+!!$    complex*16 :: cci
+!!$    integer :: i,j,nlen,icomp,irec
+!!$
+!!$    !=======================================================
+!!$
+!!$    twopi = 2.*PI
+!!$    df = 1./(npt*DT)
+!!$    dw = twopi / (npt*DT)
+!!$    cci = cmplx(0.,1.)
+!!$    w0 = twopi/20.
+!!$    f0 = 1./20.
+!!$    a0 = 0.04
+!!$
+!!$    !icomp = 1
+!!$
+!!$    do icomp = 1,NCOMP
+!!$
+!!$       ! real time series for analysis
+!!$       syn_displ(:) = 0.
+!!$       syn_displ(1:NSTEP) = data(1:NSTEP,icomp,1)
+!!$       syn_veloc(:) = 0.
+!!$       syn_veloc(1:NSTEP) = data(1:NSTEP,icomp,2)
+!!$
+!!$  !open(29,file='junk1.dat',status='unknown')
+!!$  !do i=1,NSTEP
+!!$  !   write(29,*) i*DT, syn_displ(i), syn_veloc(i)
+!!$  !enddo
+!!$  !close(29)
+!!$
+!!$       nlen = NSTEP
+!!$
+!!$       ! FFT to obtain complex frequency-domain version
+!!$       wseis_syn(:) = cmplx(0.,0.)
+!!$       !do j = 1,nlen
+!!$       !   wseis_syn(j)       = cmplx(syn_displ(j),0.)
+!!$       !   wseis_syn(npt-j+1) = cmplx(syn_displ(j),0.)
+!!$       !enddo
+!!$       wseis_syn(1:nlen) = cmplx(syn_displ(1:nlen),0.)
+!!$       call fft(lnpt,wseis_syn,FORWARD_FFT,DT)   ! displacement
+!!$
+!!$       ! KEY: assemble omega vector 
+!!$       wvec(:) = 0.
+!!$       do j = 1,npt
+!!$          if(j > npt/2) then
+!!$             wvec(j) = dw*(j-npt-1)   ! negative frequencies in second half
+!!$          else
+!!$             wvec(j) = dw*(j-1)       ! positive frequencies in first half
+!!$          endif
+!!$       enddo
+!!$
+!!$       ! analytical expression (Harris and Stocker, 1998)
+!!$       ! With this IFFT routine, only the positive frequencies need to be filled, in order
+!!$       ! to recover the original REAL signal when we IFFT.
+!!$       wseis_dat(:) = cmplx(0.,0.)
+!!$       do j = 1,npt
+!!$          !do j = 1,npt/2
+!!$          wseis_dat(j)  = cmplx(w0,0.) / ( (cmplx(wvec(j),0.)*cci + cmplx(a0,0.))**2 + cmplx(w0**2,0.) )
+!!$          wseis_dat2(j) = wseis_dat(j) * cmplx(0.,wvec(j))
+!!$       enddo
+!!$
+!!$       open(91,file='test1.dat',status='unknown')
+!!$       do j = 1,npt
+!!$          write(91,'(4e18.8)') wvec(j)/twopi, abs(wseis_syn(j)), real(wseis_syn(j)), aimag(wseis_syn(j))
+!!$       enddo
+!!$       close(91)
+!!$
+!!$       open(91,file='test2.dat',status='unknown')
+!!$       do j = 1,npt
+!!$          write(91,'(4e18.8)') wvec(j)/twopi, abs(wseis_dat(j)), real(wseis_dat(j)), aimag(wseis_dat(j))
+!!$       enddo
+!!$       close(91)
+!!$
+!!$       open(91,file='test3.dat',status='unknown')
+!!$       do j = 1,npt
+!!$          write(91,'(4e18.8)') wvec(j)/twopi, abs(wseis_dat2(j)), real(wseis_dat2(j)), aimag(wseis_dat2(j))
+!!$       enddo
+!!$       close(91)
+!!$
+!!$       !wseis_dat(:) = 0.
+!!$
+!!$       ! back to real time series
+!!$       call fftinv(lnpt,wseis_syn,REVERSE_FFT,DT,fp)    ! displacement -- from NUMERICAL
+!!$       call fftinv(lnpt,wseis_dat,REVERSE_FFT,DT,fq)    ! displacement -- from ANALYTICAL
+!!$       call fftinv(lnpt,wseis_dat2,REVERSE_FFT,DT,fq2)    ! should be velocity
+!!$
+!!$       open(91,file='test0.dat',status='unknown')
+!!$       do j = 1,nlen
+!!$          write(91,'(6e18.8)') j*DT, syn_displ(j), fp(j), fq(j), syn_veloc(j), fq2(j)
+!!$       enddo
+!!$       close(91)
+!!$
+!!$       adj_syn(:,:,:) = 0.
+!!$
+!!$    enddo  ! do icomp=1,NCOMP
+!!$
+!!$    !------------------------------------------------------------------
+!!$  end subroutine mtm_test
+!!$  !------------------------------------------------------------------
+!!$  ! END TEST PROGRAM
+!!$  !------------------------------------------------------------------
+
+  subroutine mtm_adj(ievent, nrec, syn, tstart, tend, adj_syn, data, data_recon)
+
+    double precision :: nw
+    double precision, dimension(NSTEP) :: syn_displ, dat_displ, syn_veloc, dat_veloc, syn_accel
+    double precision, dimension(NSTEP) :: ft_bar_t, ft_t, fa_bar_t, fa_t
+    double precision :: Nnorm, Mnorm, dlnA, dlnAd, dlnAv
+    character*100 filename
+
+    integer, intent(in) :: nrec, ievent
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+    double precision, dimension(nrec), intent(in) :: tstart, tend
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+
+    double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+    double precision, dimension(NSTEP,NCOMP,nrec),optional :: data_recon
+
+    double precision, dimension(NDIM) :: dzr, dzr2, dzr_win, dzr2_win, dzr0_win
+
+    integer :: itime, icomp, istart1, iend1, istart2, iend2, nlen
+    integer :: n_left, n_right, ishift, i1, ipwr_t
+    double precision :: cc, cc_max, tshift_xc, cr_shift, fac, sfac1, t_start, t_stop
+    double precision, dimension(NSTEP) :: time_window
+
+    ! error associated with measurement
+    double precision :: dlnA_pert, tshift_xc_pert, rand1, ppert
+    double precision :: twopi
+
+    integer :: i,j,ik,n,ictaper,irec,imeasure
+
+!====================================================================
+
+!!$    ! PARAMETERS ARE INCLUDED IN wave2d_constants.f90
+!!$    !parameter(NDIM=8000*4,NDIM2=16000*4,lnpt=14,npt=2**lnpt)
+!!$    !parameter(NTAPER=5,WTR=0.02,ZZIGN=-1.0)
+!!$    !implicit real(a-h,o-z)
+!!$
+!!$    double precision :: tas(NDIM,NTAPER), ey1(NDIM), ey2(NDIM)
+!!$    !double precision, dimension(NDIM,NTAPER) :: phi_mul, dt_mul, abs_mul, abs2_mul
+!!$    double precision, dimension(NDIM) :: dzr, dzr2, phi, fr
+!!$    double precision, dimension(NDIM) :: dzr_win, dzr2_win, dzr3_win, dzr0_win, dzr30_win, tseis_recon
+!!$    !double precision, dimension(NDIM) :: dt_mtm, phi_mtm, abs_mtm, abs2_mtm
+!!$    !double precision, dimension(NDIM) :: err_phi, err_dt, err_abs, err_abs2
+!!$
+!!$    ! variables for adjoint sources (p(w) and q(w), etc)
+!!$    complex*16, dimension(NDIM,NTAPER) :: top_p_ntaper
+!!$    complex*16, dimension(NDIM) :: pwc_adj, qwc_adj, top_p, bot_p, ctemp, dtemp, dtau_pj_wc, dlnA_qj_wc
+!!$    double precision, dimension(NDIM,NTAPER) :: pw_adj, qw_adj, pt_adj, qt_adj, dtau_pj_t, dlnA_qj_t
+!!$    double precision, dimension(NDIM) :: wvec, tvec, dlnA_w, dtau_w, fp, fq, w_taper, wp_taper, wq_taper
+!!$    double precision :: nw
+!!$
+!!$    ! cross-correlation sources
+!!$    double precision, dimension(NSTEP) :: syn_displ, dat_displ, syn_veloc, dat_veloc, syn_accel
+!!$    double precision, dimension(NSTEP) :: ft_bar_t, ft_t, fa_bar_t, fa_t
+!!$    double precision :: Nnorm, Mnorm, dlnA, dlnAd, dlnAv
+!!$
+!!$    complex*16, dimension(NDIM) :: wseis_syn, wseis_dat, wseis, wseis3, wseis_rec
+!!$    complex*16, dimension(NDIM) :: trans_mtm, top_mtm, bot_mtm   ! removed trans
+!!$    complex*16 :: wtr_use, wtr_use_unw, cci, junkc
+!!$    character*20 hfmt
+!!$    character*100 filename
+!!$
+!!$    ! -----------------
+!!$    integer, intent(in) :: nrec, ievent
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(in) :: syn
+!!$    double precision, dimension(nrec), intent(in) :: tstart, tend
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(out) :: adj_syn
+!!$
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),intent(in),optional :: data
+!!$    double precision, dimension(NSTEP,NCOMP,nrec),optional :: data_recon
+!!$
+!!$    integer itime, icomp, istart1, iend1, istart2, iend2, nlen
+!!$    double precision, dimension(NSTEP) :: time_window
+!!$    double precision :: norm, junk, ntemp, Ffac, win_extend, planch_fac
+!!$    double precision :: dtau_mtm, dlnA_mtm
+!!$    ! -----------------
+!!$
+!!$    double precision :: twopi, wtr_mtm, fac, cr_shift, cc, cc_max, sfac1, sfac2
+!!$    double precision :: tshift_xc, ampmax, ampmax_unw, omega
+!!$    double precision :: t_stop, t_start, df, df_new, dw, temp
+!!$    integer :: ipwr_t, ipwr_w, ishift, n_left, n_right, fnum, i1
+!!$    integer :: i_right, i_right_stop, i_amp_max, i_amp_max_unw, idf_new
+!!$
+!!$    ! error associated with measurement
+!!$    double precision :: meas_pert, rand1, ppert
+!!$
+!!$    integer :: i,j,ik,n,ictaper,irec
+
+    !=======================================================
+
+    twopi = 2.*PI
+    !cci = cmplx(0.,1.)
+    !wtr_mtm = 1.e-10
+
+    ! parameters for tapers
+    ipwr_t = 10                  ! for 1 - [cos(t)]^(ipwr)
+    !ipwr_w = 10                  ! for 1 - [cos(w)]^(ipwr)
+
+    adj_syn(:,:,:) = 0.
+    !icomp = 1
+
+    print *, ' (mtm_adj.f90) IKER = ', IKER
+
+    ! KEY: global counter variable
+    !imeasure = imeasure + 1
+
+    !===============
+
+    ! loop over receivers -- tstart and tend are nrec x 1 arrays
+    do irec = 1,nrec
+
+       ! loop over components
+       do icomp = 1,NCOMP
+
+          imeasure = index_data(ievent,irec,icomp)
+
+          print *
+          write(*,'(a30,4i10)') ' ievent, irec, icomp, imeasure: ', ievent, irec, icomp, imeasure
+
+          ! create the NON-windowed records for which the measurement is made
+          do itime = 1,NSTEP
+             dzr(itime)  = syn(itime,icomp,irec)     ! synthetic
+             dzr2(itime) = data(itime,icomp,irec)    ! data
+          enddo
+
+          ! window -- based on HWIN
+          istart1 = max(floor( (tstart(irec)) / DT), 1)
+          iend1   = min(floor( (tend(irec)  ) / DT), NSTEP)
+          nlen = iend1 - istart1
+          print *, istart1, iend1, nlen
+          if (istart1 >= iend1) stop 'Check if istart1 < iend1'
+
+          ! start and stop times -- assume t0 = 0
+          !t_start = tstart(irec)
+          !t_stop  = tend(irec)
+          t_start = istart1*DT
+          t_stop  = iend1*DT
+
+          ! parameters for time window
+          sfac1 = (2./dble(nlen))**2  ! for Welch window
+          !ipwr_t = 2                  ! for cosine window
+
+          ! initialise windowed arrays
+          dzr_win(:) = 0.             ! length npt (npt is in wave2d_constants.f90)
+          dzr0_win(:) = 0.            ! length npt
+          dzr2_win(:) = 0.            ! length npt
+
+          ! PRE-PROCESSING -- the type of window does not seem to matter too much
+          ! (It is not necessary to fix the endpoints, I think.)
+          ! Note that dzr_win is length npt, but dzr is length NSTEP
+          do i = 1,nlen
+             !fac = 1.                                        ! boxcar window
+             !fac = 1 - sfac1*((i-1) - dble(nlen)/2.)**2     ! welch window
+             fac = 1. - cos(PI*(i-1)/(nlen+1))**ipwr_t        ! cosine window
+             !print *, fac
+
+             dzr_win(i)  = dzr(i+istart1) * fac  ! syn, windowed
+             dzr2_win(i) = dzr2(i+istart1)* fac  ! dat, windowed
+          enddo
+          dzr0_win(:) = dzr_win(:)  ! syn, windowed
+
+          ! post-processing taper, length NSTEP
+          time_window(:) = 0.
+          do i = 1,nlen
+             !fac = 1.                                        ! boxcar window
+             !fac = 1 - sfac2*((i-1) - dble(nlen)/2.)**2     ! welch window
+             fac = 1. - cos(PI*(i-1)/(nlen+1))**ipwr_t        ! cosine window
+
+             time_window(i) = fac
+          enddo
+
+          !==================================================================
+          ! CROSS-CORRELATION MEASUREMENTS
+          ! The number of time-steps we deal with is the length of the measurement window.
+
+          ! TRAVELTIME: Check that the output is consistent with your convention.
+
+          !cr_shift = 300.0
+          cr_shift = 2.*nlen*DT        ! 14-Nov-2006
+
+          n_left  = ceiling( -1.0 * cr_shift / DT )
+          n_right = floor( cr_shift / DT )
+          ishift = 0
+          cc_max = 0.
+
+          do i = n_left, n_right, 1
+             cc = 0.
+             do j = 1, nlen
+                if((j+i) > 1 .and. (j+i) < nlen) cc = cc + dzr_win(j) * dzr2_win(j+i)   ! cross-correlation
+             enddo
+             if( cc > cc_max) then 
+                cc_max = cc
+                ishift = i
+             endif
+          enddo
+          tshift_xc = ishift*DT  ! KEY: cross-correlation time shift
+
+          ! AMPLITUDE: Check that the output is consistent with your convention.
+
+          !synt(:) = dzr0_win(:)
+          !datt(:) = dzr2_win(:)
+          syn_displ(1:nlen) = dzr0_win(1:nlen)     ! windowed synthetic displacement
+          dat_displ(1:nlen) = dzr2_win(1:nlen)     ! windowed data displacement, UNSHIFTED
+
+          ! calculate velocity and acceleration from synthetic displacement
+          do i = 2, nlen-1
+             syn_veloc(i) = (syn_displ(i+1) - syn_displ(i-1)) / (2.*DT)
+             dat_veloc(i) = (dat_displ(i+1) - dat_displ(i-1)) / (2.*DT)
+          enddo
+          syn_veloc(1)    = (syn_displ(2) - syn_displ(1)) / DT
+          syn_veloc(nlen) = (syn_displ(nlen) - syn_displ(nlen-1)) /DT
+          dat_veloc(1)    = (dat_displ(2) - dat_displ(1)) / DT
+          dat_veloc(nlen) = (dat_displ(nlen) - dat_displ(nlen-1)) /DT
+
+          do i = 2, nlen-1
+             syn_accel(i) = (syn_veloc(i+1) - syn_veloc(i-1)) / (2.*DT)
+          enddo
+          syn_accel(1)    = (syn_veloc(2) - syn_veloc(1)) / DT
+          syn_accel(nlen) = (syn_veloc(nlen) - syn_veloc(nlen-1)) /DT
+
+          ! cross-correlation amplitude MEASUREMENT
+          ! definition of Dahlen and Baig (2002), Eq. 3,17,18 : dlnA = Aobs/Asyn - 1
+          dlnAd = sqrt( (DT * sum( dat_displ(:) * dat_displ(:) )) / (DT * sum( syn_displ(:) * syn_displ(:) )) ) - 1.
+          dlnAv = sqrt( (DT * sum( dat_veloc(:) * dat_veloc(:) )) / (DT * sum( syn_veloc(:) * syn_veloc(:) )) ) - 1.
+
+          !----------------------------------------------
+          ! ADD MEASUREMENT ERRORS
+
+          ! meas_pert and measure_pert_vec are GLOBAL variables
+          if ( ADD_DATA_ERRORS ) then
+             meas_pert = measure_pert_vec(imeasure)
+          else
+             meas_pert = 0.0
+          endif
+          tshift_xc_pert = tshift_xc + meas_pert
+
+          !----------------------------------------------
+          ! CROSS-CORRELATION ADJOINT SOURCES
+
+          ! normalization factors
+          ! NOTE sign convention for N (Qinya, not GJI paper) so that Nnorm >= 0
+          Nnorm = -DT * sum( syn_displ(:) * syn_accel(:) )
+
+          Mnorm =  DT * sum( syn_displ(:) * syn_displ(:) )
+
+          ! cross-correlation traveltime adjoint source
+          ft_bar_t(:) = -syn_veloc(:) / Nnorm       ! BD kernel
+          ft_t(:)     = -( tshift_xc_pert / cov_data(imeasure) ) * ft_bar_t(:)    ! misfit kernel (note sign)
+
+          ! cross-correlation amplitude adjoint source
+          ! You have TWO OPTIONS: measure the amplitudes based on DISPLACEMENT or VELOCITY
+          ! Default option has been IAMP_VEL = 0
+          if(IAMP_VEL == 0) then     ! DISPLACEMENT
+             fa_bar_t(:) = syn_displ(:) / Mnorm 
+             dlnA = dlnAd
+          else                        ! VELOCITY
+             fa_bar_t(:) = -syn_accel(:) / Nnorm
+             dlnA = dlnAv
+          endif
+          fa_t(:) = -(dlnA / cov_data(imeasure) ) * fa_bar_t(:)    ! misfit kernel
+
+          ! for now, we do not allow perturbations for the amplitude measurement
+          dlnA_pert = dlnA
+
+          if(0==1) then
+             !print *
+             print *, 'cross-correlation measurments:'
+             print *, '       dT = ', tshift_xc
+             print *, '   dlnA-d = ', dlnAd
+             print *, '   dlnA-v = ', dlnAv
+             print *, '        N = ', Nnorm
+             print *, '        M = ', Mnorm
+          else
+             write(*,'(a8,i5,a8,1f18.10,a8,1f18.10)') &
+                  'irec = ', irec, ', dT = ', tshift_xc, ', dA = ', dlnA
+          endif
+
+          ! additional files for checking (measure_socal_adj.m)
+          if(WRITE_SEISMO_RECONSTRUCT) then
+             ! time domain : time, data-disp, syn-disp, syn-vel, syn-accel
+             write(filename,'(a,i5.5,a)') 'syn_time_', irec, '.dat'
+             open(29,file=filename,status='unknown')
+             do i = 1,nlen
+                write(29,'(5e18.8)') i*DT, dat_displ(i), syn_displ(i), syn_veloc(i), syn_accel(i)
+             enddo
+             close(29)
+
+             ! xcorr adjoint sources : traveltime (banana-doughnut), traveltime (misfit), amplitude (banana-doughnut), amplitude (misfit)
+             write(filename,'(a,i5.5,a)') 'xcorr_time_', irec, '.dat'
+             open(39,file=filename,status='unknown')
+             do i = 1,nlen
+                if(IAMP_VEL == 0) then
+                   write(39,'(6e18.8)') ft_bar_t(i), ft_t(i), fa_bar_t(i), fa_t(i), -syn_accel(i)/Nnorm, -dlnAv*(-syn_accel(i)/Nnorm)
+                else
+                   write(39,'(6e18.8)') ft_bar_t(i), ft_t(i), fa_bar_t(i), fa_t(i), syn_displ(i)/Mnorm, -dlnAd*(syn_displ(i)/Mnorm)
+                endif
+             enddo
+             close(39)
+          endif
+
+          !if(irec==4) stop 'testing'
+
+!!$          !===================================================
+!!$          ! MULTITAPER MEASUREMENTS
+!!$
+!!$          ! initialize multitaper measurements
+!!$          dtau_mtm = 0.
+!!$          dlnA_mtm = 0.
+!!$
+!!$          if(IKER==3 .or. IKER==4) then     ! multitaper measurements
+!!$
+!!$             ! calculate frequency step and number of frequencies
+!!$             df = 1./(npt*DT)
+!!$             dw = twopi / (npt*DT)
+!!$             fnum = npt/2 + 1
+!!$
+!!$             ! KEY: assemble omega vector 
+!!$             wvec(:) = 0.
+!!$             do j = 1,npt
+!!$                if(j > npt/2) then
+!!$                   wvec(j) = dw*(j-npt-1)   ! negative frequencies in second half
+!!$                else
+!!$                   wvec(j) = dw*(j-1)       ! positive frequencies in first half
+!!$                endif
+!!$             enddo
+!!$
+!!$             ! numerical factor for Plancherel theorem
+!!$             ! THIS COST US QUITE A BIT OF TIME TO FIGURE OUT
+!!$             planch_fac = dble(npt * DT * DT)
+!!$
+!!$             !----------------
+!!$
+!!$             ! apply time shift to DATA (observed seismogram)
+!!$             print *, ' shift observed seismogram by (s) : ', tshift_xc
+!!$             do i = 1, nlen
+!!$                dzr3_win(i) = 0.
+!!$                if( (ishift+i) > 1 .and. (ishift+i) < nlen ) dzr3_win(i) = dzr2_win(i+ishift)
+!!$                dzr30_win(i) = dzr3_win(i) 
+!!$             enddo
+!!$
+!!$             ! create complex synthetic seismogram and complex data seismogram
+!!$             ! wseis_syn -- windowed synthetic record in freq domain
+!!$             ! wseis_dat -- windowed data record, shifted by xcorr-tt, in freq domain
+!!$             wseis_syn(:) = cmplx(0.,0.)
+!!$             wseis_dat(:) = cmplx(0.,0.)
+!!$             wseis_syn(1:nlen) =  dzr0_win(1:nlen)
+!!$             wseis_dat(1:nlen) = dzr30_win(1:nlen)
+!!$
+!!$             ! apply FFT to get frequency domain versions (syn and data)
+!!$             call fft(lnpt,wseis_syn,FORWARD_FFT,DT)
+!!$             call fft(lnpt,wseis_dat,FORWARD_FFT,DT)
+!!$
+!!$             ! get the tapers
+!!$             call staper(nlen, NPI, NTAPER, tas, NDIM, ey1, ey2)
+!!$
+!!$             ! format statement -- might be a problem with some Fortran packages
+!!$             write(hfmt,'(a,i2.2,a)') '(', NTAPER,'e18.6)'
+!!$
+!!$             !------------------------------------------------------------------
+!!$
+!!$             ! initialize transfer function terms
+!!$             top_mtm(:)   = cmplx(0.,0.)
+!!$             bot_mtm(:)   = cmplx(0.,0.)
+!!$             trans_mtm(:) = cmplx(0.,0.)
+!!$
+!!$             do ictaper = 1, NTAPER  ! loop over tapers
+!!$
+!!$                ! time domain: apply taper ictaper to synth and obs windowed seismograms 
+!!$                ! these get written over at each loop iteration of ictaper
+!!$                do i = 1, nlen
+!!$                   dzr_win(i)  =  dzr0_win(i) * tas(i,ictaper)   ! syn(t), single-tapered and windowed
+!!$                   dzr3_win(i) = dzr30_win(i) * tas(i,ictaper)   ! dat(t), single-tapered and windowed
+!!$                enddo
+!!$
+!!$                ! create complex seismograms
+!!$                wseis(:)  = cmplx(0.,0.)
+!!$                wseis3(:) = cmplx(0.,0.)
+!!$                wseis(1:nlen)  = cmplx(dzr_win(1:nlen),0.)  ! syn(t), single-tapered and windowed
+!!$                wseis3(1:nlen) = cmplx(dzr3_win(1:nlen),0.) ! dat(t), single-tapered and windowed
+!!$
+!!$                ! apply FFT to get complex spectra
+!!$                call fft(lnpt,wseis, FORWARD_FFT,DT)   ! syn
+!!$                call fft(lnpt,wseis3,FORWARD_FFT,DT)   ! dat
+!!$
+!!$                ! find max spectral power for single taper
+!!$                ! --> could also use maxval and maxloc
+!!$                ampmax = 0.
+!!$                ampmax_unw = 0.
+!!$                do i = 1, fnum   ! loop over frequencies
+!!$                   if( abs(wseis(i)) > ampmax) then              ! syn, single-tapered
+!!$                      ampmax = abs(wseis(i))
+!!$                      i_amp_max = i
+!!$                   endif
+!!$                   if( abs(wseis_syn(i)) > ampmax_unw) then      ! syn
+!!$                      ampmax_unw =  abs(wseis_syn(i))
+!!$                      i_amp_max_unw = i
+!!$                   endif
+!!$                enddo
+!!$
+!!$                ! compute water level for single taper measurement
+!!$                wtr_use     = cmplx(ampmax * WTR, 0.)       ! syn
+!!$                wtr_use_unw = cmplx(ampmax_unw * WTR, 0.)   ! syn, single-tapered
+!!$
+!!$                ! determine i_right values using the power in the (untapered) synthetic 
+!!$                ! these variables define maximum frequency for measurement
+!!$                ! i_right_stop = 1 --> stop at frequency i_right, not fnum
+!!$                i_right = fnum 
+!!$                i_right_stop = 0 
+!!$                do i = 1,fnum             ! loop over frequencies
+!!$                   if(i > i_amp_max_unw .and. abs(wseis_syn(i)) <= abs(wtr_use_unw) .and. i_right_stop == 0) then 
+!!$                      i_right_stop = 1
+!!$                      i_right = i
+!!$                   endif
+!!$                   if(i > i_amp_max_unw .and. abs(wseis_syn(i)) >= 10.*abs(wtr_use_unw) .and. i_right_stop == 1) then 
+!!$                      i_right_stop = 0 
+!!$                      i_right = i
+!!$                   endif
+!!$                enddo  ! frequencies: i = 1,fnum
+!!$
+!!$                ! loop over frequencies
+!!$                do i = 1,fnum
+!!$
+!!$                   ! calculate top and bottom of transfer function for multitapers
+!!$                   ! NOTE THAT THESE QUANTITIES ARE SUMMED OVER THE TAPERS AS WELL
+!!$                   top_mtm(i) = top_mtm(i) +  wseis3(i) * conjg(wseis(i))   ! uses data and syn
+!!$                   bot_mtm(i) = bot_mtm(i) +  wseis(i)  * conjg(wseis(i))   ! uses syn only
+!!$
+!!$                   ! calculate transfer function for single taper measurement using water level
+!!$                   ! CHT: trans IS NEVER USED HERE
+!!$                   !if(abs(wseis(i)) >  abs(wtr_use)) trans(i) = wseis3(i) / wseis(i)
+!!$                   !if(abs(wseis(i)) <= abs(wtr_use)) trans(i) = wseis3(i) / (wseis(i)+wtr_use)
+!!$
+!!$                enddo  ! frequencies: i = 1,fnum
+!!$
+!!$                !print *, ' taper number ', ictaper, ' out of ', NTAPER
+!!$
+!!$             enddo  ! tapers: ictaper = 1,NTAPER
+!!$
+!!$             ! it appears that this has a negligible effect on the recovery of seismograms
+!!$             !i_right = fnum
+!!$
+!!$             !------------------------------------------------------------------
+!!$             ! Multi-taper measurement, calculation, and output
+!!$             !------------------------------------------------------------------
+!!$
+!!$             ! find water level for multi-taper measurement
+!!$             ampmax = 0.
+!!$             do i = 1, fnum
+!!$                if( abs(bot_mtm(i)) > ampmax) then 
+!!$                   ampmax =  abs(bot_mtm(i))
+!!$                   i_amp_max = i
+!!$                endif
+!!$             enddo
+!!$             wtr_use = cmplx(ampmax * wtr_mtm**2, 0.)       ! original expression
+!!$             !wtr_use = cmplx(ampmax * 0.01, 0.)            ! Qinya test value
+!!$
+!!$             ! calculate transfer function using water level
+!!$             !do i = 1, fnum
+!!$             !  if(abs(bot_mtm(i)) >  abs(wtr_use)) trans_mtm(i) = top_mtm(i) / bot_mtm(i)
+!!$             !  if(abs(bot_mtm(i)) <= abs(wtr_use)) trans_mtm(i) = top_mtm(i) / (bot_mtm(i)+wtr_use)
+!!$             !enddo
+!!$             do i = 1, fnum
+!!$                if(abs(bot_mtm(i)) <= abs(wtr_use)) bot_mtm(i) = bot_mtm(i) + wtr_use
+!!$             enddo
+!!$             trans_mtm(1:fnum) = top_mtm(1:fnum) / bot_mtm(1:fnum)
+!!$
+!!$             !=======================================================
+!!$             ! construct time series : tau(omega), dlnA(omega)
+!!$
+!!$             ! taper function for the FREQUENCY domain
+!!$             nw = dble(i_right - 1)
+!!$
+!!$             ! loop to calculate phase and amplitude
+!!$             ! NOTE: here we include the (cross-correlation) time shift
+!!$             dtau_w(:) = 0.
+!!$             dlnA_w(:) = 0.
+!!$             w_taper(:) = 0.
+!!$             do i = 2, i_right   ! start from 1 to avoid dividing by 0
+!!$
+!!$                !wvec(i)     = dw*i     ! do not divide by zero
+!!$                !dtau_w(i)   = -atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) + tshift_xc
+!!$                !dtau_w(i)   = -(1./wvec(i)) * atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) + tshift_xc
+!!$
+!!$                dtau_w(i)   = (-1./wvec(i)) * atan2(aimag(trans_mtm(i)), real(trans_mtm(i))) + tshift_xc
+!!$                dlnA_w(i)   = abs(trans_mtm(i)) - 1.
+!!$
+!!$                ! type of filter in the freq domain : boxcar, welch, cosine
+!!$                !w_taper(i) = 1.
+!!$                !w_taper(i) = 1. - (2./nw)**2 * ((i-1) - nw/2.)**2
+!!$                w_taper(i) = 1. - cos(PI*(i-1)/(nw+1))**ipwr_w
+!!$             enddo
+!!$
+!!$             ! TESTING: create a flat transfer function to compare with adjoint sources
+!!$             !dtau_w(:) = tshift_xc
+!!$             !dlnA_w(:) = dlnA
+!!$
+!!$             ! compute normalization factor for W(w)
+!!$             ! factor of 2 takes into account integration from -infty to +infty
+!!$             Ffac = 2. * dw*sum(w_taper(:) )     ! crude integration
+!!$
+!!$             ! modified frequency-domain tapers (see Latex notes)
+!!$             ! In theory, these would incorporate the error functions sigma_p and sigma_q.
+!!$             wp_taper(:) = w_taper(:) / Ffac
+!!$             wq_taper(:) = w_taper(:) / Ffac
+!!$
+!!$             if(WRITE_MTM_FILES) then
+!!$                ! write transfer function to file
+!!$                write(filename,'(a,i5.5,a)') 'transfer_freq_', irec, '.dat'
+!!$                open(91,file=filename,status='unknown')
+!!$                do i = 1, i_right 
+!!$                   write(91,'(4e18.8)') wvec(i)/twopi, dtau_w(i), dlnA_w(i), w_taper(i)
+!!$                enddo
+!!$                close(91)
+!!$
+!!$                write(filename,'(a,i5.5,a)') 'transfer_freq_int_', irec, '.dat'
+!!$                open(91,file=filename,status='unknown')
+!!$                write(91,*) Ffac
+!!$                close(91)
+!!$             endif
+!!$
+!!$             ! compute multitaper measurements (crude integration)
+!!$             ! These formulas are equivalent to using a BOXCAR window for the taper,
+!!$             ! and the values should be close to the cross-correlation values.
+!!$             !dtau_mtm = 1. / (i_right*dw) * dw*sum( dtau_w(1:i_right) )
+!!$             !dlnA_mtm = 1. / (i_right*dw) * dw*sum( dlnA_w(1:i_right) )
+!!$             dtau_mtm = sum( dtau_w(1:i_right) ) / i_right
+!!$             dlnA_mtm = sum( dlnA_w(1:i_right) ) / i_right
+!!$
+!!$             ! reconstruct data (wseis_rec) from synthetics (wseis_syn) using the transfer function (trans_mtm)
+!!$             if(WRITE_SEISMO_RECONSTRUCT) then
+!!$
+!!$                ! Reconstruct mtm fit seismograms : syn*tran
+!!$                ! d(w) = s(w) T(w) exp[-i w dT]
+!!$                ! trans_mtm is for transferring syn --> SHIFTED data
+!!$                wseis_rec(:) = cmplx(0.,0.)
+!!$                do i = 1,i_right
+!!$                   omega = wvec(i)
+!!$
+!!$                   ! mathematically, these are identical
+!!$                   ! numerically, they produce nearly identical results
+!!$                   wseis_rec(i) = wseis_syn(i)  * (1.+ dlnA_w(i)) * exp(-cci*omega*dtau_w(i))
+!!$                   !wseis_rec(i) = wseis_syn(i) * trans_mtm(i) * exp(-cci*omega*tshift_xc)
+!!$
+!!$                   !wseis_rec(i) = wseis_syn(i)*exp(-cci*omega*tshift_xc)*trans_mtm(i)  ! sign
+!!$                   !wseis_rec(i) = wseis_syn(i) * exp(-cci*omega*dtau_w(i)*w_taper(i)) * (1.+ dlnA_w(i)*w_taper(i))
+!!$                enddo
+!!$
+!!$                ! inverse FFT into time domain
+!!$                call fftinv(lnpt,wseis_rec,REVERSE_FFT,DT,tseis_recon)
+!!$
+!!$                write(filename,'(a,i5.5,a)') 'recovered_seis_time_', irec, '.dat'
+!!$                open(17,file=filename,status='unknown')
+!!$                do i = 1,nlen
+!!$                   write(17,'(2e18.8)') DT*i, tseis_recon(i)
+!!$                enddo
+!!$                close(17)
+!!$
+!!$                ! write power spectra (a.k.a. spectral amplitude) to files
+!!$                ! Note that the spectral power for a uniform time shift will not be apparent;
+!!$                ! only the amplitudes will appear.
+!!$                ! Note that the transfer function (trans_mtm) deals with the SHIFTED synthetics.
+!!$                write(filename,'(a,i5.5,a)') 'recovered_seis_freq_', irec, '.dat'
+!!$                open(91,file=filename,status='unknown')
+!!$                do i = 1,i_right 
+!!$
+!!$                   omega = wvec(i)
+!!$                   wseis_rec(i) = wseis_syn(i) * (1.+ dlnA_w(i)) * exp(-cci*omega*dtau_w(i))
+!!$                   !wseis_rec(i) = wseis_syn(i) * (1. + dlnA_mtm) * exp(-cci*omega*tshift_xc)  ! xcor shift
+!!$                   !wseis_rec(i) = wseis_syn(i) * trans_mtm(i) * exp(-cci*omega*tshift_xc)
+!!$
+!!$                   ! w, syn, dat, dat-recon
+!!$                   write(91,'(4e18.8)') wvec(i), abs(wseis_syn(i)), abs(wseis_dat(i)), abs(wseis_rec(i))
+!!$                enddo
+!!$                close(91)
+!!$
+!!$             endif
+!!$
+!!$             !endif  ! IKER==3,4
+!!$
+!!$             !===================================================
+!!$             ! FFT TESTING: to determine what conventions we are using!
+!!$             ! We do this by taking a function, s(t) and its time derivative,
+!!$             ! and then computing fourier transforms.
+!!$
+!!$             if(0==1) then
+!!$
+!!$                ! create complex synthetic seismogram and complex data seismogram
+!!$                wseis_syn(:) = cmplx(0.,0.)
+!!$                wseis_dat(:) = cmplx(0.,0.)
+!!$                wseis_syn(1:nlen) = cmplx(syn_displ(1:nlen),0.)  ! displacement
+!!$                wseis_dat(1:nlen) = cmplx(syn_veloc(1:nlen),0.)  ! velocity
+!!$
+!!$                print *, '-----------------------------'
+!!$                print *, FORWARD_FFT
+!!$                print *, wseis_syn(100), wseis_dat(100)
+!!$
+!!$                ! FFT. to get frequency domain versions
+!!$                call fft(lnpt,wseis_syn,FORWARD_FFT,DT)   ! displacement
+!!$                call fft(lnpt,wseis_dat,FORWARD_FFT,DT)   ! velocity
+!!$
+!!$                print *, wseis_syn(100), wseis_dat(100)
+!!$                print *, FORWARD_FFT
+!!$                print *, '-----------------------------'
+!!$
+!!$                if(1==1) then    ! check Fourier convention
+!!$
+!!$                   ! check convention -- s_d(w)*iw should give velocity
+!!$                   do i = 1,i_right   ! KEY: do not go too high frequency
+!!$                      dtemp(i) = wseis_syn(i) * cmplx(0.,wvec(i))
+!!$                      !dtemp(npt-i+1) = wseis_syn(npt-i+1) * cmplx(0.,wvec(npt-i+1))
+!!$                   enddo
+!!$
+!!$                   ! back to real time series
+!!$                   ! if our convention is consistent, then wp_taper should match syn_veloc
+!!$                   call fftinv(lnpt,wseis_syn,REVERSE_FFT,DT,fp)    ! displacement
+!!$                   call fftinv(lnpt,wseis_dat,REVERSE_FFT,DT,fq)    ! velocity
+!!$                   call fftinv(lnpt,dtemp,REVERSE_FFT,DT,wp_taper)  ! should be velocity
+!!$
+!!$                   open(91,file='test.dat',status='unknown')
+!!$                   do i = 1,nlen*2
+!!$                      write(91,'(5e18.8)') syn_displ(i),fp(i),syn_veloc(i),fq(i),wp_taper(i)
+!!$                   enddo
+!!$                   close(91)
+!!$
+!!$                else            ! check Plancherel's theorem
+!!$
+!!$                   ! discrete form of Plancherel's theorem
+!!$                   junk  = sum(syn_displ(:)*syn_veloc(:))
+!!$                   junkc = (1./planch_fac) * sum( wseis_syn(:) * conjg(wseis_dat(:)) )
+!!$
+!!$                   print *, 'checking Plancherel theorem...'
+!!$                   print *, junk
+!!$                   print *, junkc
+!!$                   print *, real(junkc)
+!!$                   print *, planch_fac, 1./planch_fac
+!!$
+!!$                   print *, ' this should be 1 : ', (junk / real(junkc))
+!!$                   print *
+!!$                   print *, '   Nt = ', nlen
+!!$                   print *, '   dt = ', DT
+!!$                   print *, '  wNy = ', twopi/(2.*DT)
+!!$                   print *, '  wRy = ', twopi/(nlen*DT)
+!!$                   print *
+!!$                   print *, '   Nw = ', npt
+!!$                   print *, '   dw = ', dw
+!!$
+!!$                endif
+!!$
+!!$                stop 'testing the FFT from mtm_adj.f90'
+!!$
+!!$             endif
+!!$
+!!$             !==================================================================
+!!$             ! MULTITAPER ADJOINT SOURCES
+!!$
+!!$             !if(IKER==3 .or. IKER==4) then
+!!$
+!!$             pw_adj(:,:) = 0.      ;  qw_adj(:,:) = 0.
+!!$             pt_adj(:,:) = 0.      ;  qt_adj(:,:) = 0.
+!!$             dtau_pj_t(:,:) = 0.   ;  dlnA_qj_t(:,:) = 0.
+!!$             fp(:) = 0.            ;  fq(:) = 0.
+!!$
+!!$             bot_p(:) = cmplx(0.,0.)
+!!$             top_p_ntaper(:,:) = cmplx(0.,0.)
+!!$
+!!$             ! This loops over the tapers to get the DENOMINATOR term of pj(w).
+!!$             ! It also stores the displacement field sj(w), which is in the NUMERATOR term of p(w).
+!!$             do ictaper = 1,NTAPER
+!!$
+!!$                ! apply TAPER ictaper to windowed synthetics 
+!!$                dzr_win(:) = 0.
+!!$                do i = 1,nlen   ! time domain
+!!$                   dzr_win(i) = dzr0_win(i) * tas(i,ictaper)
+!!$                enddo
+!!$
+!!$                ! create complex seismograms (tapered synthetics, sj(w))
+!!$                wseis(:) = cmplx(dzr_win(:),0.)
+!!$
+!!$                ! apply f.t. to get complex spectra
+!!$                call fft(lnpt,wseis,FORWARD_FFT,DT)
+!!$
+!!$                ! bottom of p function for multitapers (complex)
+!!$                do i = 1, i_right
+!!$                   bot_p(i) = bot_p(i) + wseis(i)*conjg(wseis(i))
+!!$                enddo
+!!$
+!!$                ! term in numerator (sj) (complex)
+!!$                top_p_ntaper(:,ictaper) = wseis(:)     
+!!$
+!!$             enddo  ! loop over tapers
+!!$
+!!$             do ictaper = 1,NTAPER   ! loop over tapers
+!!$                !print *, ' taper number ', ictaper, ' out of ', NTAPER
+!!$
+!!$                top_p(:)   = top_p_ntaper(:,ictaper)  ! top of p function for multitapers
+!!$                pwc_adj(:) = cmplx(0.,0.)
+!!$                qwc_adj(:) = cmplx(0.,0.)
+!!$
+!!$                ! compute pj(w) and qj(w) -- j term is in top_p
+!!$                ! (these get over-written each loop)
+!!$                do i = 2, i_right  ! start from index 2 to avoid division by w=0
+!!$                   !omega = dw*i   ! omega should not =0
+!!$                   omega = wvec(i)
+!!$
+!!$                   ! formulas for Fourier convention FFT --> e^(-iwt)
+!!$                   pwc_adj(i) = cmplx(0.,1./omega) * top_p(i) / bot_p(i)  ! (1/w)i = (-iw)/(-w^2) = -1/(iw)
+!!$                   qwc_adj(i) = cmplx(0.,omega) * pwc_adj(i)              ! d/dt <--> -iw
+!!$
+!!$                   ! formulas for Fourier convention FFT --> e^(iwt)
+!!$                   !pwc_adj(i) = cmplx(0.,-1./omega) * top_p(i) / bot_p(i)  ! (-1/w)i = (iw)/(-w^2) = 1/(iw)
+!!$                   !qwc_adj(i) = cmplx(0.,-omega) * pwc_adj(i)              ! d/dt <--> -iw
+!!$
+!!$                enddo
+!!$
+!!$                ! SAVE A COPY HERE -- fftinv
+!!$                ctemp(:) = pwc_adj(:)
+!!$                dtemp(:) = qwc_adj(:)
+!!$
+!!$                ! EXTRA OUTPUT : IFFT into the time domain : pj(w) --> pj(t) and qj(w) --> qj(t)
+!!$                if(WRITE_MTM_FILES) then
+!!$                   call fftinv(lnpt,pwc_adj,REVERSE_FFT,DT,pt_adj(:,ictaper))
+!!$                   call fftinv(lnpt,qwc_adj,REVERSE_FFT,DT,qt_adj(:,ictaper))
+!!$                endif
+!!$
+!!$                ! incorporate measurement
+!!$                ! create [dtau(w) pj(w) W(w)] and save [dtau(t) * pj(t) * W(t)]
+!!$                ! create [dlnA(w) qj(w) W(w)] and save [dlnA(t) * qj(t) * W(t)]
+!!$                dtau_pj_wc(:) = cmplx(0.,0.)
+!!$                dlnA_qj_wc(:) = cmplx(0.,0.)
+!!$                dtau_pj_wc(:) = twopi * ctemp(:) * cmplx(dtau_w(:),0.) * cmplx(wp_taper(:),0.)
+!!$                dlnA_qj_wc(:) = twopi * dtemp(:) * cmplx(dlnA_w(:),0.) * cmplx(wq_taper(:),0.)
+!!$                !dtau_pj_wc(:) = twopi * ctemp(:) * cmplx(wp_taper(:),0.)   ! no measurement
+!!$                !dlnA_qj_wc(:) = twopi * dtemp(:) * cmplx(wq_taper(:),0.)   ! no measurement
+!!$
+!!$                ! IFFT into the time domain
+!!$                call fftinv(lnpt,dtau_pj_wc,REVERSE_FFT,DT,dtau_pj_t(:,ictaper))
+!!$                call fftinv(lnpt,dlnA_qj_wc,REVERSE_FFT,DT,dlnA_qj_t(:,ictaper))
+!!$
+!!$                ! create adjoint source
+!!$                fp(:) = fp(:) + tas(:,ictaper) * dtau_pj_t(:,ictaper)
+!!$                fq(:) = fq(:) + tas(:,ictaper) * dlnA_qj_t(:,ictaper)
+!!$
+!!$             enddo
+!!$
+!!$             if(WRITE_MTM_FILES) then
+!!$                ! write banana-doughnut adjoint sources to file
+!!$                write(filename,'(a,i5.5,a)') 'test_fadj_t_', irec, '.dat'
+!!$                open(21,file=filename,status='unknown')
+!!$                do i = 1,nlen
+!!$                   write(21,*) sngl(fp(i)), sngl(fq(i))
+!!$                enddo
+!!$                close(21)
+!!$
+!!$                ! write banana-doughnut adjoint sources to file
+!!$                open(21,file='test_fadj_t.dat',status='unknown')
+!!$                do i = 1,nlen
+!!$                   write(21,*) sngl(fp(i)), sngl(fq(i))
+!!$                enddo
+!!$                close(21)
+!!$
+!!$                ! time domain : tapers and other time series 
+!!$                open(18,file='test_hj_t.dat',status='unknown')
+!!$                open(19,file='test_pj_t.dat',status='unknown')
+!!$                open(20,file='test_Pj_t.dat',status='unknown')
+!!$                open(21,file='test_Pj_hj_t.dat',status='unknown')
+!!$                open(22,file='test_qj_t.dat',status='unknown')
+!!$                open(23,file='test_Qj_t.dat',status='unknown')
+!!$                open(24,file='test_Qj_hj_t.dat',status='unknown')
+!!$
+!!$                do i = 1,nlen  ! loop over time points
+!!$                   write(18,hfmt) ( sngl(tas(i,ictaper)), ictaper=1,NTAPER )                         ! hj(t)
+!!$                   write(19,hfmt) ( sngl(pt_adj(i,ictaper)), ictaper=1,NTAPER )                      ! pj(t)
+!!$                   write(20,hfmt) ( sngl(dtau_pj_t(i,ictaper)), ictaper=1,NTAPER )                   ! Pj(t)
+!!$                   write(21,hfmt) ( sngl(dtau_pj_t(i,ictaper) * tas(i,ictaper)), ictaper=1,NTAPER )  ! hj(t) Pj(t)
+!!$
+!!$                   write(22,hfmt) ( sngl(qt_adj(i,ictaper)), ictaper=1,NTAPER )                      ! qj(t)
+!!$                   write(23,hfmt) ( sngl(dlnA_qj_t(i,ictaper)), ictaper=1,NTAPER )                   ! Qj(t)
+!!$                   write(24,hfmt) ( sngl(dlnA_qj_t(i,ictaper) * tas(i,ictaper)), ictaper=1,NTAPER )  ! hj(t) Qj(t) 
+!!$                enddo
+!!$
+!!$                close(18) ; close(19) ; close(20) ; close(21) ; close(22) ; close(23) ; close(24)
+!!$             endif
+!!$
+!!$          endif  ! if IKER==3,4
+
+!=====================================================
+
+!!$          ! generate a UNIFORM random number to simulate error in the measurement
+!!$          ! ppert determines the range over which the perturbed measurement will be
+!!$          ppert = 0.
+!!$          call random_number(rand1)
+!!$          meas_pert = 1. + ppert*(2.*rand1 - 1.)
+!!$          !print *, tshift_xc, meas_pert, tshift_xc * meas_pert
+
+          ! CREATE THE ADJOINT SOURCES
+          ! HERE WE APPLY A TAPER TO FIX THE ENDPOINTS OF THE TIME WINDOW
+          do i = 1,nlen   ! loop over points WITHIN the (OUTER) time window
+
+             i1 = istart1 - 1 + i
+
+!!$             ! store the reconstructed data: d'(w) = T(w) s(w)
+!!$             if(WRITE_SEISMO_RECONSTRUCT) then
+!!$                if(IKER==4 .or. IKER==4) data_recon(i1,icomp,irec) = tseis_recon(i)
+!!$             endif
+
+             if(IKER==0) then
+                adj_syn(i1,icomp,irec) = ( syn(i1,icomp,irec) -  data(i1,icomp,irec) ) * time_window(i)
+
+             elseif(IKER==1) then
+                adj_syn(i1,icomp,irec) = ft_t(i) * time_window(i)
+
+             elseif(IKER==2) then
+                adj_syn(i1,icomp,irec) = fa_t(i) * time_window(i)
+
+             elseif(IKER==3) then
+                stop 'Multitaper measurements NOT an option'
+                !adj_syn(i1,icomp,irec) = fp(i) * time_window(i)
+
+             elseif(IKER==4) then
+                stop 'Multitaper measurements NOT an option'
+                !adj_syn(i1,icomp,irec) = fq(i) * time_window(i)
+
+             elseif(IKER==5) then
+                adj_syn(i1,icomp,irec) = ft_bar_t(i) * time_window(i)
+
+             elseif(IKER==6) then
+                adj_syn(i1,icomp,irec) = fa_bar_t(i) * time_window(i)
+             endif
+
+          enddo
+
+          ! (1) COMPUTE MEASUREMENT VECTOR
+          ! (2) COMPUTE MISFIT FUNCTION (currently only for waveform, xc-tt, xc-lnA)
+          ! IKER: (0) waveform
+          !       (1) traveltime, cross-correlation, misfit
+          !       (2) amplitude, cross-correlation, misfit
+          !       (3) traveltime, multitaper
+          !       (4) amplitude, multitaper
+
+!!$          ! the 2 factor is needed to offset the 2 factor in Ffac
+!!$          dtau_mtm = 2./Ffac * dw*sum( dtau_w(1:i_right) )
+!!$          dlnA_mtm = 2./Ffac * dw*sum( dlnA_w(1:i_right) )
+
+          ! measurement values
+          !imeasure = imeasure + 1    ! global counter variable
+
+          measure_vec(imeasure,1) = tshift_xc_pert
+          measure_vec(imeasure,2) = tshift_xc
+          measure_vec(imeasure,3) = dlnA_pert
+          measure_vec(imeasure,4) = dlnA
+          measure_vec(imeasure,5) = 0.5 * DT*sum( adj_syn(:,icomp,irec)**2 )
+
+!!$          measure_vec(imeasure,4) = dtau_mtm     ! integrated dtau(w) -- compare with tshift_xc
+!!$          measure_vec(imeasure,5) = dlnA_mtm     ! integrated dlnA(w) -- compare with dlnA
+
+         ! NOTE THAT THE FACTOR OF 0.5 IS NOT INCLUDED HERE
+
+          if(IKER==0) then
+             ! crude integration of the waveform difference
+             chi_data(ievent,irec,icomp,1) = DT*sum( adj_syn(:,icomp,irec)**2 ) / cov_data(imeasure)
+
+          elseif(IKER==1) then
+             chi_data(ievent,irec,icomp,1) = (tshift_xc_pert )**2 / cov_data(imeasure)
+
+          elseif(IKER==2) then
+             chi_data(ievent,irec,icomp,1) = (dlnA_pert)**2 / cov_data(imeasure)
+
+!!$          elseif(IKER==3) then
+!!$             chi_data(ievent,irec,icomp,1) = 2.*dw*sum( wp_taper(1:i_right) * (dtau_w(1:i_right)**2) )
+!!$
+!!$          elseif(IKER==4) then
+!!$             chi_data(ievent,irec,icomp,1) = 2.*dw*sum( wq_taper(1:i_right) * (dlnA_w(1:i_right)**2) )
+
+          endif
+
+       enddo  ! loop over components (icomp=1,NCOMP)
+
+    enddo  ! loop over receivers (irec=1,nrec)
+
+    !------------------------------------------------------------------
+  end subroutine mtm_adj
+  !------------------------------------------------------------------
+  ! END MAIN PROGRAM
+  !------------------------------------------------------------------
+        
+!!$!------------------------------------------------------------------
+!!$  subroutine fft(n,xi,zign,dt)
+!!$! Fourier transform
+!!$! This inputs AND outputs a complex function.
+!!$! The convention is FFT --> e^(-iwt)
+!!$!------------------------------------------------------------------
+!!$      complex*16, dimension(NDIM) :: xi
+!!$      integer :: n
+!!$      double precision :: dt
+!!$
+!!$      complex*16 :: wk, hold, q
+!!$      double precision :: m(25)
+!!$      double precision :: zign,flx,v
+!!$      integer :: lblock,k,fk,jh,ii,istart
+!!$      integer :: l,iblock,nblock,i,lbhalf,j,lx
+!!$
+!!$      ! sign must be +1. or -1.
+!!$      if(zign >= 0.) then
+!!$        zign = 1.
+!!$      else
+!!$        zign = -1.
+!!$      endif
+!!$
+!!$      lx = 2**n
+!!$      do 1 i=1,n
+!!$    1 m(i) = 2**(n-i)
+!!$      do 4 l=1,n
+!!$      nblock = 2**(l-1)
+!!$      lblock = lx/nblock
+!!$      lbhalf = lblock/2
+!!$      k = 0
+!!$      do 4 iblock=1,nblock
+!!$      fk = k
+!!$      flx = lx
+!!$
+!!$      v = zign*2.*PI*fk/flx         ! Fourier convention
+!!$
+!!$      wk = cmplx(cos(v),-sin(v))   ! sign change to -sin(v) 17-Nov-2006
+!!$      istart = lblock*(iblock-1)
+!!$
+!!$      do 2 i=1,lbhalf
+!!$      j  = istart+i
+!!$      jh = j+lbhalf
+!!$      q = xi(jh)*wk
+!!$      xi(jh) = xi(j)-q
+!!$      xi(j)  = xi(j)+q
+!!$    2 continue
+!!$
+!!$      do 3 i=2,n
+!!$      ii = i
+!!$      if(k < m(i)) go to 4
+!!$    3 k = k-m(i)
+!!$    4 k = k+m(ii)
+!!$      k = 0
+!!$      do 7 j=1,lx
+!!$      if(k < j) go to 5
+!!$      hold = xi(j)
+!!$      xi(j) = xi(k+1)
+!!$      xi(k+1) = hold
+!!$    5 do 6 i=1,n
+!!$      ii = i
+!!$      if(k < m(i)) go to 7
+!!$    6 k = k-m(i)
+!!$    7 k = k+m(ii)
+!!$
+!!$      ! final steps deal with dt factors
+!!$      if(zign > 0.) then       ! FORWARD FFT
+!!$         do i = 1,lx 
+!!$            xi(i) = xi(i)*dt   ! multiplication by dt
+!!$         enddo
+!!$
+!!$      else                     ! REVERSE FFT
+!!$         flx = flx*dt
+!!$         do i = 1,lx 
+!!$            xi(i) = xi(i)/flx  ! division by dt
+!!$         enddo
+!!$      endif
+!!$
+!!$  end subroutine fft
+!!$
+!!$!------------------------------------------------------------------
+!!$  subroutine fftinv(npow,s,zign,dt,r)
+!!$! inverse Fourier transform -- calls fft
+!!$!------------------------------------------------------------------
+!!$
+!!$      !implicit real*8(a-h,o-z)
+!!$      !dimension r(4096*4)
+!!$      !complex s(4096*4)
+!!$
+!!$      complex*16, intent(in) :: s(NDIM)
+!!$      double precision, intent(out) :: r(NDIM)   ! note this is REAL
+!!$
+!!$      !complex*16 :: stemp(NDIM)
+!!$      double precision :: dt,zign
+!!$      integer :: npow, nsmp, nhalf, i
+!!$
+!!$      nsmp = 2**npow
+!!$      nhalf = nsmp/2
+!!$      call rspec(s,nhalf)   ! re-structuring
+!!$
+!!$      call fft(npow,s,zign,dt)    ! Fourier transform
+!!$
+!!$      do i = 1,nsmp
+!!$        r(i) = real(s(i))     ! REAL part
+!!$      enddo
+!!$ 
+!!$  end subroutine fftinv
+!!$
+!!$!------------------------------------------------------------------
+!!$  subroutine rspec(s,np2)
+!!$!------------------------------------------------------------------
+!!$
+!!$      !implicit real*8(a-h,o-z)
+!!$      !complex s(4096*4)
+!!$
+!!$      complex*16 :: s(NDIM)
+!!$      integer :: np2,n,n1,i
+!!$
+!!$      n = 2*np2
+!!$      n1 = np2+1
+!!$
+!!$      s(n1) = 0.
+!!$!     s(1)  = 0.
+!!$      s(1)  = cmplx( real(s(1)),0.)
+!!$
+!!$      do i = 1,np2
+!!$         s(np2+i) = conjg(s(np2+2-i))
+!!$      enddo
+!!$
+!!$  end subroutine rspec
+!!$
+!!$!------------------------------------------------------------------
+!!$  subroutine staper(nt, fw, nev, v, ndim, a, w)
+!!$!------------------------------------------------------------------
+!!$!$$$$ calls tsturm, root
+!!$!  Slepian - Thomson multi-taper procedure
+!!$!  Slepian, D.     1978  Bell Sys Tech J v57 n5 1371-1430
+!!$!  Thomson, D. J.  1982  Proc IEEE v70 n9 1055-1096
+!!$!    nt    the number of points in the series
+!!$!    fw    the time-bandwidth product (number of Rayleigh bins)
+!!$!    nev   the desired number of tapers
+!!$!    v     the eigenvectors (tapers) are returned in v(.,nev)
+!!$!    a, w  work arrays dimensioned at least nt long (nt+1, nt odd)
+!!$!    a(1..nev) contains bandwidth retention factors on output.
+!!$!  The tapers are the eigenvectors of the tridiagonal matrix sigma(i,j)
+!!$!  [see Slepian(1978) eq 14 and 25.] They are also the eigenvectors of
+!!$!  the Toeplitz matrix eq. 18. We solve the tridiagonal system in
+!!$!  tsturm for the tapers and use them in Slepians eq 18 to get the
+!!$!  bandwidth retention factors (i.e. the eigenvalues) Thomson's
+!!$!  normalisation is used with no attention to sign.
+!!$      !implicit real*8(a-h,o-z)
+!!$      !dimension a(*),w(*),v(ndim,*)
+!!$      !parameter (pi=3.14159265358979d0,r2=1.414213562373095d0)
+!!$
+!!$      integer :: nt, nev, ndim
+!!$      double precision :: fw
+!!$      double precision :: v(NDIM,NTAPER), a(NDIM), w(NDIM)
+!!$
+!!$      integer :: i,j,k,m
+!!$      integer :: nxi, lh, lp1, neven, nodd, ntot, kk, kmax, nlow, nup
+!!$      double precision :: r2,om,com,hn,asav,rbd,dc,sm,s,sn,vmax
+!!$
+!!$      !-------------------------
+!!$
+!!$      r2 = sqrt(2.)
+!!$
+!!$      if(nt < 2) return
+!!$      nxi=mod(nt,2)
+!!$      lh=(nt/2)+nxi
+!!$      lp1=nt+1
+!!$      om=2.*PI*fw/nt
+!!$      com=cos(om)
+!!$      hn=0.5*dble(lp1)
+!!$      do 10 i=1,lh
+!!$        a(i)=com*(i-hn)**2
+!!$   10   w(i)=0.5*dble(i*(nt-i))
+!!$      if(nxi == 0) then
+!!$        asav=a(lh)-w(lh)
+!!$        a(lh)=a(lh)+w(lh)
+!!$        rbd=1./(a(lh)+w(lh-1))
+!!$      else
+!!$        asav=w(lh-1)
+!!$        rbd=1./(w(lh)+w(lh-1))
+!!$        w(lh-1)=r2*w(lh-1)
+!!$      endif
+!!$      do 15 i=1,lh
+!!$        a(i+lh)=w(i)*rbd
+!!$        w(i)=a(i+lh)**2
+!!$   15   a(i)=a(i)*rbd
+!!$      neven=max0((nev+1)/2,1)
+!!$      nodd=nev-neven
+!!$!  Do the even tapers
+!!$      call tsturm(nt,lh,a,a(lh+1),w,neven,v,ndim,w(lh+1),0)
+!!$      do 20 i=1,neven
+!!$        k=2*i-1
+!!$        if(nxi == 1) v(lh,k)=r2*v(lh,k)
+!!$          do 20 j=1,lh
+!!$   20     v(lp1-j,k)=v(j,k)
+!!$      if(nodd <= 0) goto 34
+!!$!  Do the odd tapers
+!!$      if(nxi == 0) then
+!!$        a(lh)=asav*rbd
+!!$      else
+!!$        a(nt)=asav*rbd
+!!$        w(lh-1)=asav*asav
+!!$      endif
+!!$      call tsturm(nt,lh-nxi,a,a(lh+1),w,nodd,v,ndim,w(lh+1),1)
+!!$      do 30 i=1,nodd
+!!$        k=2*i
+!!$        if(nxi == 1) v(lh,k)=0.
+!!$          do 30 j=1,lh
+!!$   30     v(lp1-j,k)=-v(j,k)
+!!$   34 ntot=neven+nodd
+!!$!  Calculate bandwidth retention parameters
+!!$      dc=2.*com
+!!$      sm=0.
+!!$      s=sin(om)
+!!$      w(1)=om/PI
+!!$      w(2)=s/PI
+!!$      do 35 j=3,nt
+!!$        sn=dc*s-sm
+!!$        sm=s
+!!$        s=sn
+!!$   35   w(j)=s/(PI*(j-1))
+!!$      do 55 m=1,ntot
+!!$        vmax=abs(v(1,m))
+!!$        kmax=1
+!!$        do 40 kk=2,lh
+!!$          if(abs(v(kk,m)) <= vmax) goto 40
+!!$          kmax=kk
+!!$          vmax=abs(v(kk,m))
+!!$   40     continue
+!!$        a(m)=0.
+!!$        nlow=kmax-1
+!!$          do 45 j=1,nlow
+!!$   45     a(m)=a(m)+w(j+1)*v(nlow+1-j,m)
+!!$        nup=nt-nlow
+!!$          do 50 j=1,nup
+!!$   50     a(m)=a(m)+w(j)*v(nlow+j,m)
+!!$   55 a(m)=a(m)/v(kmax,m)
+!!$      return
+!!$
+!!$  end subroutine staper
+!!$
+!!$!------------------------------------------------------------------
+!!$  subroutine tsturm(nt,n,a,b,w,nev,r,ndim,ev,ipar)
+!!$!------------------------------------------------------------------
+!!$!$$$$ calls root
+!!$!  Uses bisection and Sturm counting to isolate the eigenvalues of the
+!!$!  symmetric tridiagonal matrix with main diagonal a(.) and sub/super
+!!$!  diagonal b(.).  Newton's method is used to refine the eigenvalue in
+!!$!  subroutine root then direct recursion is used to get the eigenvector
+!!$!  as this is always stable.  Note  ipar=0 for even tapers   =1 for odd
+!!$!  tapers
+!!$      !implicit real*8(a-h,o-z)
+!!$      !parameter (epsi=1.d-15,epsi1=5.d-15)
+!!$      !dimension a(*),b(*),ev(*),w(*),r(ndim,*)
+!!$
+!!$      double precision, parameter :: epsi = 1.d-15, epsi1 = 5.d-15
+!!$
+!!$      double precision, dimension(NDIM) :: a, b, w, ev
+!!$      double precision, dimension(NDIM,NTAPER) :: r
+!!$      integer :: nt,n,ndim,nev,ipar
+!!$
+!!$      double precision, dimension(NDIM) :: bb
+!!$      double precision :: q,el,elam,u,umeps,x,ddot,rnorm
+!!$      integer :: i,j,ik,iag,m,jk,jm1
+!!$
+!!$      !-------------------------
+!!$
+!!$      if(n <= 0.or.nev <= 0) return
+!!$      umeps=1.-epsi
+!!$      do 5 i=1,nev
+!!$    5 ev(i)=-1.
+!!$      u=1.
+!!$      do 1000 ik=1,nev
+!!$      if(ik > 1) u=ev(ik-1)*umeps
+!!$      el=min(ev(ik),u)
+!!$   10 elam=0.5*(u+el)
+!!$      if(abs(u-el) <= epsi1) goto 35
+!!$      iag=0
+!!$      q=a(1)-elam
+!!$      if(q >= 0.) iag=iag+1
+!!$      do 15 i=2,n
+!!$      if(q == 0.) x=abs(b(i-1))/epsi
+!!$      if(q /= 0.) x=w(i-1)/q
+!!$      q=a(i)-elam-x
+!!$      if(q >= 0.) iag=iag+1
+!!$      if(iag > nev) goto 20
+!!$   15 continue
+!!$      if(iag >= ik) go to 20
+!!$      u=elam
+!!$      go to 10
+!!$   20 if(iag == ik) go to 30
+!!$      m=ik+1
+!!$      do 25 i=m,iag
+!!$   25 ev(i)=elam
+!!$      el=elam
+!!$      go to 10
+!!$   30 el=elam
+!!$      call root(u,el,elam,a,b,w,n,ik)
+!!$   35 ev(ik)=elam
+!!$      jk=2*ik+ipar-1
+!!$      r(1,jk)=1.
+!!$      r(2,jk)=-(a(1)-ev(ik))/b(1)
+!!$      ddot=1.+r(2,jk)*r(2,jk)
+!!$      jm1=2
+!!$      do 45 j=3,n
+!!$      r(j,jk)=-((a(jm1)-ev(ik))*r(jm1,jk)+b(j-2)*r(j-2,jk))/b(jm1)
+!!$      ddot=ddot+r(j,jk)*r(j,jk)
+!!$   45 jm1=j
+!!$      rnorm=sqrt(nt/(2.*ddot))
+!!$      do 50 j=1,n
+!!$   50 r(j,jk)=r(j,jk)*rnorm
+!!$ 1000 continue
+!!$      return
+!!$
+!!$  end subroutine tsturm
+!!$
+!!$!------------------------------------------------------------------
+!!$  subroutine root(u,el,elam,a,bb,w,n,ik)
+!!$!------------------------------------------------------------------
+!!$
+!!$      !implicit real*8(a-h,o-z)
+!!$      !parameter (epsi = 1.d-15, epsi1 = 5.d-15)
+!!$      !dimension a(*),bb(*),w(*)
+!!$
+!!$      double precision, parameter :: epsi = 1.d-15, epsi1 = 5.d-15
+!!$      double precision :: u,el,elam
+!!$      double precision, dimension(NDIM) :: a,bb,w
+!!$      integer :: n,ik
+!!$
+!!$      double precision :: an,b,bm,bn,del,x
+!!$      integer :: i,iag
+!!$
+!!$      !----------------------
+!!$
+!!$    5 elam=0.5*(u+el)
+!!$   10 if(abs(u-el) <= 1.5*epsi1) return
+!!$      an=a(1)-elam
+!!$      b=0.
+!!$      bn=-1./an
+!!$      iag=0
+!!$      if(an >= 0.) iag=iag+1
+!!$      do 20 i=2,n
+!!$      if(an == 0.) x=abs(bb(i-1))/epsi
+!!$      if(an /= 0.) x=w(i-1)/an
+!!$      an=a(i)-elam-x
+!!$      if(an == 0.) an=epsi
+!!$      bm=b
+!!$      b=bn
+!!$      bn=((a(i)-elam)*b-bm*x-1.)/an
+!!$      if(an >= 0.) iag=iag+1
+!!$   20 continue
+!!$      if(iag == ik) goto 25
+!!$      u=elam
+!!$      goto 30
+!!$   25 el=elam
+!!$   30 del=1./bn
+!!$      if(abs(del) <= epsi1) del=sign(epsi1,del)
+!!$      elam=elam-del
+!!$      if(elam >= u.or.elam <= el) goto 5
+!!$      goto 10
+!!$
+!!$  end subroutine root
+!!$!-------------------------------------------
+
+end module wave2d_sub4

Added: seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_variables.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_variables.f90	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/iterate_adj/SEM2D_iterate/src/wave2d_variables.f90	2008-11-24 01:23:54 UTC (rev 13378)
@@ -0,0 +1,158 @@
+module wave2d_variables
+
+  use wave2d_constants
+
+! material properties and kernels
+! For safety reasons, we keep the models for synthetics and data separate,
+! and then assign one to rho-kappa-mu when we run the solver.
+  double precision kappal,mul,lambdal,lambdalplus2mul
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: rho,kappa,mu
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: rho_dat, kappa_dat, mu_dat, alpha_dat, beta_dat, bulk_dat
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: rho_syn, kappa_syn, mu_syn, alpha_syn, beta_syn, bulk_syn
+!  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: bulk_initial_syn, beta_initial_syn
+!  double precision, dimension(NGLOB) :: mu_global, kappa_global, rho_global
+!  double precision, dimension(NGLOB) :: alpha_global, beta_global
+
+! temporary arrays
+  double precision, dimension(NGLOB) :: temp_global1, temp_global2
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: temp_local1, temp_local2
+
+! area associated with each GLL point
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: da_local
+  double precision, dimension(NLOCAL) :: da_local_vec
+  double precision, dimension(NGLOB) :: da_global
+
+! Gauss-Lobatto-Legendre points of integration
+  double precision, dimension(NGLLX) :: xigll
+  double precision, dimension(NGLLZ) :: zigll
+
+! weights
+  double precision, dimension(NGLLX) :: wxgll
+  double precision, dimension(NGLLZ) :: wzgll
+
+! array with derivatives of Lagrange polynomials
+  double precision, dimension(NGLLX,NGLLX) :: hprime_xx
+  double precision, dimension(NGLLZ,NGLLZ) :: hprime_zz
+  double precision, dimension(NGLLX,NGLLZ) :: wgllwgll_xz
+
+! anchors (x1,x2,z1,z2 --> left,right,bottom,top
+  double precision, dimension(NSPEC) :: z1,z2
+  double precision, dimension(NSPEC) :: x1,x2
+
+! global grid points
+  double precision, dimension(NGLOB) :: x, z
+  integer, dimension(NGLOB) :: valence
+
+! corners of the elements, in a global vector
+  integer, dimension(NSPEC_CORNER) :: ielement_corner
+
+! phase velocity map (CHT)
+!  double precision, dimension(NGLOB) :: c_glob, c_glob_dat, c_glob_syn
+  double precision, dimension(NGLOB) :: x_lon, z_lat, x_plot, z_plot
+  double precision :: alpha0,beta0,rho0,kappa0,mu0,bulk0
+!  double precision :: c,cmin,cmax
+  integer :: Nfac
+  double precision :: w_scale, afac
+
+! 1D model
+  integer :: nlayer
+  double precision, dimension(10) :: z_breaks, r_layers, a_layers, b_layers
+
+! gridpoints per wavelength
+  double precision :: alpha_min, alpha_max, beta_min, beta_max
+
+! Jacobian matrix and Jacobian
+  double precision dxidxl,dxidzl,dgammadxl,dgammadzl,jacobianl
+  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: dxidx,dxidz,dgammadx,dgammadz,jacobian
+
+! boundary elements: 1-xmin, 2-xmax, 3-zmin, 4-zmax (1,2,3,4 --> left, right, bottom, top)
+! ibelm contains ispec indices for elements on the boundary of the grid
+  integer, dimension(4,NELE) :: ibelm
+  double precision, dimension(4,NGLL,NELE) :: jacobianb
+  integer nspecb(4)
+
+! absorbing boundary conditions
+  integer j1, j2, ib, ibb
+  double precision nx,nz,vx,vy,vz,vn,rho_vp,rho_vs,tx,ty,tz,weight
+
+! local to global numbering
+  integer, dimension(NGLLX,NGLLZ,NSPEC) :: ibool
+
+! Mass matrix
+  double precision mass_local
+  double precision, dimension(NGLOB) :: mass_global
+
+! time marching
+  double precision deltat,deltatover2,deltatsqover2
+  double precision b_deltat,b_deltatover2,b_deltatsqover2
+  double precision dh,time_step
+
+! displacement, velocity and acceleration
+  double precision, dimension(NCOMP,NGLOB) :: displ,veloc,accel
+  double precision, dimension(NCOMP,NGLOB) :: b_displ,b_veloc,b_accel
+  
+! plotting
+!  double precision, dimension(NGLOB) :: norm
+
+! space derivatives
+  double precision tempx1l,tempx2l,tempy1l,tempy2l,tempz1l,tempz2l
+  double precision fac1,fac2,hp1,hp2
+  double precision dsxdxl,dszdxl,dsydxl,dsydzl,dsxdzl,dszdzl 
+  double precision sigma_xx,sigma_xy,sigma_xz,sigma_zx,sigma_zy,sigma_zz
+  double precision, dimension(NGLLX,NGLLZ) :: tempx1,tempx2,tempy1,tempy2,tempz1,tempz2
+  double precision, dimension(3,3) :: ds
+
+  double precision b_tempx1l,b_tempx2l,b_tempy1l,b_tempy2l,b_tempz1l,b_tempz2l
+  double precision b_dsxdxl,b_dszdxl,b_dsydxl,b_dsydzl,b_dsxdzl,b_dszdzl
+  double precision b_sigma_xx,b_sigma_xy,b_sigma_xz,b_sigma_zx,b_sigma_zy,b_sigma_zz
+  double precision, dimension(NGLLX,NGLLZ) :: b_tempx1,b_tempx2,b_tempy1,b_tempy2,b_tempz1,b_tempz2
+  double precision, dimension(3,3) :: b_ds
+
+  double precision :: utm_xmin, utm_zmin
+
+! measurements (data)
+!  integer :: imeasure
+  double precision :: meas_pert
+  double precision, dimension(:,:), allocatable :: measure_vec
+  double precision, dimension(:), allocatable :: measure_pert_vec, cov_data
+
+! indexing arrays
+  integer, dimension(:,:,:), allocatable :: index_data
+  integer, dimension(:,:), allocatable :: index_source
+  integer, dimension(NVAR,2) :: m_inds
+
+! misfit function
+  double precision :: chi_data(MAX_EVENT, MAX_SR, MAX_COMP, MAX_PHASE), chi_val, chi_val_0
+  double precision :: data_norm, chi_data_stop, chi_model_stop
+  double precision :: model_target_norm, model_norm, model_diff_norm
+  double precision :: model_target_norm_struct, model_norm_struct, model_diff_norm_struct
+  double precision :: model_target_norm_source, model_norm_source, model_diff_norm_source
+  double precision :: gradient_norm, gradient_model_norm, gradient_data_norm
+  double precision :: gradient_norm_struct, gradient_model_norm_struct, gradient_data_norm_struct
+  double precision :: gradient_norm_source, gradient_model_norm_source, gradient_data_norm_source
+  double precision, dimension(NVAR) :: model_target_norm_parts, model_norm_parts, model_diff_norm_parts
+  double precision, dimension(NVAR) :: gradient_norm_parts, gradient_model_norm_parts, gradient_data_norm_parts
+!  double precision :: chi_model_norm, chi_model_norm_struct, chi_model_norm_source
+!  double precision :: chi_model_norm_target, chi_model_norm_target_struct, chi_model_norm_target_source
+!  double precision :: chi_gradient_norm, chi_gradient_norm_struct, chi_gradient_norm_source
+!  double precision :: chi_gradient_data_norm, chi_gradient_data_norm_struct, chi_gradient_data_norm_source
+!  double precision :: chi_gradient_model_norm, chi_gradient_model_norm_struct, chi_gradient_model_norm_source
+  double precision :: var_red_val
+
+! kernels
+!  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: kernel_basis_sum, kernel_basis
+!  double precision, dimension(NGLLX,NGLLZ,NSPEC) :: alpha_basis_sum, beta_basis_sum
+
+! half duration of the source (put into wave2d_constants.f90)
+!  double precision hdur
+
+! file open or write status variable
+  integer ios
+
+! number of time steps to store wavefield
+  integer NINT 
+
+! input/output directory
+  character(len=100) :: in_dir,out_dir
+
+end module wave2d_variables



More information about the CIG-COMMITS mailing list