C
C Common block /POINTC/ is designed to contain the quantities at the
C individual points of a ray.
C The quantities stored in common block /POINTC/ are written into the
C unformatted output files by subroutines of file 'apw.for'.
C The quantities are then read from these unformatted files and stored
C in common block /POINTC/ by subroutine AP00.
C These subroutines mediate the exchange of rays between program
C 'crt.for' and other programs of package CRT.
C
C     INCLUDE 'pointc.inc'
C     ------------------------------------------------------------------
      INTEGER MYI,MYLI,MPVI,MY,MYL,MPV
      PARAMETER (MYI=29,MYLI=6,MPVI=9,MY=39,MYL=6,MPV=9)
      INTEGER ISRC,IWAVE,IRAY,IPT,NYF,ICB1F,ISRFF,KMAHF,NPVF
      INTEGER NY,ICB1,ISRF,KMAH,NPV,ICB1I,IEND,ISHEET,IREC,NPVI
      REAL XF,UEBRAF,YLF(MYL), YF(MY), PVF(MPV)
      REAL X ,UEBRAY,YL (MYL), Y (MY), PV (MPV),
     *               YLI(MYLI),YI(MYI),PVI(MPVI)
      COMMON/POINTC/ISRC,IWAVE,IRAY,IPT,
     *              NYF,ICB1F,ISRFF,KMAHF,XF,UEBRAF,YLF,YF,NPVF,PVF,
     *              NY ,ICB1 ,ISRF ,KMAH ,X ,UEBRAY,YL ,Y ,NPV ,PV ,
     *              ICB1I,IEND,ISHEET,IREC,         YLI,YI,NPVI,PVI
      SAVE /POINTC/
C     ------------------------------------------------------------------
C     In the Chapter 7
C     of the paper on C.R.T., three different points situated on a ray
C     are introduced:
C     O/O (O subscript O)... Initial point of the ray.
C             Quantities: ICB1I,YLI,YI,NPVI,PVI.
C     O/S (O subscript S)... Another point situated on the ray.  In some
C             applications it may be treated as the endpoint of the ray.
C             Quantities: NY,ICB1,ISRF,KMAH,X,UEBRAY,YL,Y,NPV,PV.
C     O/F (O subscript F)... Another point situated on the ray, usually
C             situated between the points O/O and O/S, see
C             C.R.T.7.13:
C             Fresnel volumes.  This point is required just by few
C             applications and usually need not be defined.
C             Quantities: NYF,ICB1F,ISRFF,KMAHF,XF,UEBRAF,YLF,YF,NPVF,
C                         PVF.
C     Quantities ISRC,IWAVE,IRAY,IEND,ISHEET,IREC correspond to the ray
C             and are thus common to points O/O, O/S and 0/F.
C     If point O/F is defined, IPT corresponds to point O/F.
C     If point O/F is not defined (NYF=0), IPT corresponds to point O/S.
C     ------------------------------------------------------------------
C     Subroutine APYYF of file 'ap.for' exchanges points O/S and O/F
C             in common block /POINTC/, keeping the value of IPT which
C             becomes related to O/S instead of O/F after the exchange.
C     Subroutines of file 'apw.for' assume that point O/F is not defined
C             without checking the value of NYF, and work with points
C             O/O and O/S while checking the value of IPT.
C     Subroutine AP28 of file 'ap.for' works with point O/F if it is
C             defined, otherwise it works with point O/S.
C     Other subroutines of file 'ap.for' work with points O/O and O/S.
C     ------------------------------------------------------------------
C     ISRC... Index of the source.  The sources are indexed by positive
C             integers, see input file SRC.
C     IWAVE...Index of the elementary wave (output of the subroutine
C             CODE1).  Elementary waves are indexed by 1,2,3,... .
C             IWAVE=0 if the end of the input file is encountered.
C     IRAY... Index of the ray (output of the subroutine RPAR2).  Rays
C             within each elementary wave are indexed by 1,2,3,... .
C             Note that some of the indexed rays need not exist.
C             IRAY=0 if the end of the input file is encountered.
C     IPT...  Index of the point on a ray.  The points O/S or O/F are
C             indexed sequentially along each ray, taking the values
C             1,2,3,...
C             If the point is the first considered point of a new
C             elementary wave, IPT=0 instead of 1.
C     NYF,ICB1F,ISRFF,KMAHF,XF,UEBRAF,YLF,YF,NPVF,PVF... Quantities
C             at the point O/F.  Their meaning is the same as of
C             NY,ICB1,ISRF,KMAH,X,UEBRAY,YL,Y,NPV,PV below.
C             They need not be defined (option in subroutine AP00).
C             Although they may be defined by subroutine AP00,
C             they are never used by subroutines of file 'apw.for'.
C             NYF=0,NPV=0... Indication that these quantities are not
C               defined, i.e. that the point O/F has not been defined.
C     NY,ICB1,ISRF,KMAH,X,UEBRAY,YL,Y,NPV,PV... Quantities at the
C             point O/S.
C             A brief description follows:
C     NY=IY(1)=27+NAMPL... Number of the basic quantities describing the
C             point of the ray, see the file 'ray.for'.
C     ICB1=IY(5)... Index of the complex block in which the stored point
C             of the ray is situated, supplemented by a sign '+' for P
C             wave and sign '-' for S wave.
C     ISRF=IY(6)... Index of the surface at which the endpoint of the
C             computed element of the ray is situated, supplemented by
C             a sign '+' or '-' for the endpoint situated at the
C             positive or negative side of the surface, respectively.
C             Zero inside the complex block.  Note: The sign of this
C             quantity is the exception to the definition in the
C             original paper on C.R.T.
C     KMAH=IY(12)... Number of caustic points along the ray (the index
C             of the ray trajectory).
C     X=YY(1)... Independent variable along a ray.
C     UEBRAY=YY(2)... Upper error bound for ray tracing measured in
C             travel time.
C             Description of X and UEBRAY
C     YL...   Array containing local quantities at the point of the ray,
C             see C.R.T.5.5.4.
C     YL(1)=VP... Velocity of P waves at the point in an isotropic
C             medium.
C             Probably inconsistent use in an anisotropic medium:
C             Phase velocity of the P wave corresponding to the
C             direction of the reference slowness vector, or the P-wave
C             velocity in the reference isotropic medium.
C     YL(2)=VS... Velocity of S waves at the point in an isotropic
C             medium.
C             Probably inconsistent use in an anisotropic medium:
C             Common S-wave phase velocity corresponding to the
C             direction of the reference slowness vector, or the S-wave
C             velocity in the reference isotropic medium.
C     YL(3)=RO... Density at the point.
C     YL(4)=V1,YL(5)=V2,YL(6)=V3... Velocity derivatives in general
C             coordinates in an isotropic medium.
C             Probably inconsistent use in an anisotropic medium:
C             Spatial gradient of the P-wave or of the common S-wave
C             Hamiltonian function multiplied by the phase velocity
C             (both corresponding to the direction of the reference
C             slowness vector, or the velocity gradient in the reference
C             isotropic medium.
C     Y...    Array containing basic quantities computed along the ray
C             see C.R.T.5.2.1.
C     Y(1)... Reference travel time:
C             P-wave travel time or common S-wave travel time calculated
C             by ray tracing (output of crt.for),
C             or the coupling-ray-theory travel time calculated by
C             program crtpfa.for.
C     Y(2)... Imaginary part of the reference complex-valued travel
C             time.
C     Y(3),Y(4),Y(5)... Coordinates of points along the ray.
C     Y(6),Y(7),Y(8)... Covariant components of the reference slowness
C             vector:
C             P-wave slowness vector or common S-wave slowness vector
C             calculated by ray tracing (output of crt.for),
C             or the length-corrected common S-wave slowness vector
C             calculated by program crtpfa.for.
C     Y(9),Y(10),Y(11)... Covariant components (with respect to the
C             Riemannian model metric tensor in model coordinates) of
C             the first contravariant basis vector of the reference
C             ray-centred coordinate system (Klimes, 2006, sec. 5.4).
C             The basis vector is normalized with respect to the
C             Riemannian model metric.
C     ( Y(12),Y(16),Y(20),Y(24) )    Reference propagator matrix of
C     ( Y(13),Y(17),Y(21),Y(25) )... geodetic deviation in the reference
C     ( Y(14),Y(18),Y(22),Y(26) )    ray-centred coordinates.
C     ( Y(15),Y(19),Y(23),Y(27) )
C     Y(28) to Y(NY), where NY=27+NAMPL... NAMPL real quantities
C             representing the reference complex-valued vectorial
C             reduced amplitudes.
C             For S waves, the reference reduced amplitudes may
C             represent common S wave reduced amplitudes (output of
C             crt.for), or the propagator matrix corresponding to the
C             prevailing-frequency approximation of the coupling ray
C             theory calculated by program crtpfa.for.
C             The reference vectorial reduced amplitudes are specified
C             with respect to the reference polarization vectors PV
C             described below.
C             Specification of Y(28) to Y(NY):
C             P wave at the initial point of the ray,
C             P wave at the point under consideration:
C               NAMPL=2,
C               Y(28)=REAL(A33), Y(29)=AIMAG(A33).
C             P wave at the initial point of the ray,
C             S wave at the point under consideration:
C               NAMPL=4,
C               Y(28)=REAL(A13), Y(29)=AIMAG(A13),
C               Y(30)=REAL(A23), Y(31)=AIMAG(A23).
C             S wave at the initial point of the ray,
C             P wave at the point under consideration:
C               NAMPL=4,
C               Y(28)=REAL(A31), Y(29)=AIMAG(A31),
C               Y(30)=REAL(A32), Y(31)=AIMAG(A32).
C             S wave at the initial point of the ray,
C             S wave at the point under consideration:
C               NAMPL=8,
C               Y(28)=REAL(A11), Y(29)=AIMAG(A11),
C               Y(30)=REAL(A21), Y(31)=AIMAG(A21),
C               Y(32)=REAL(A12), Y(33)=AIMAG(A12),
C               Y(34)=REAL(A22), Y(35)=AIMAG(A22).
C     Y(NY+1) to Y(35), where NY=27+NAMPL... Undefined.
C     NPV...  Total number of the components of the defined reference
C             polarization vectors.
C             The P-vave reference polarization vector is equal to the
C             P-wave eigenvector of the reference Christoffel matrix.
C             The S-vave reference polarization vectors may equal to:
C             (a) S-wave polarization vectors in the low-frequency limit
C             of the coupling ray theory for S waves, which are situated
C             in the same plane as the S-wave eigenvectors of the
C             reference Christoffel matrix, but they do not rotate about
C             the common anisotropic reference ray (output of crt.for).
C             (b) S-wave eigenvectors of the reference Christoffel
C             matrix (coupling ray theory for S waves,
C             output of crtpfa.for).
C             NPV=0:  Isotropic medium.  The eigenvectors coincide
C               with the basis vectors of ray-centred coordinates.
C               Array PV is undefined.
C             NPV=3:  P wave in an anisotropic medium.
C               PV(1:6) are two zero vectors.
C               PV(7:9) is the P-wave eigenvector of the Christoffel
C                 matrix.
C             NPV=6:  S wave in an anisotropic medium.
C               PV(1:3) and PV(4:6) are the two S-wave reference
C                 polarization vectors.
C               PV(7:9) is a zero vector.
C             NPV=9:  All three eigenvectors are required in the case
C               of conversion coefficients at a free surface in an
C               anisotropic medium.
C               PV(1:3) and PV(4:6) are the two S-wave reference
C                 polarization vectors,
C               PV(7:9) is the P-wave reference polarization vector.
C     PV...   Possible components of the reference polarization vectors.
C     ICB1I,YLI,YI... Quantities at the initial point O/O of the ray:
C     ICB1I...Index of the complex block in which the initial point of
C             the ray is situated, supplemented by a sign '+' for P wave
C             and sign '-' for S wave, see C.R.T.6.1.
C     IEND... Reason of the termination of the computation of a ray, see
C             C.R.T.5.4.
C             See subroutine RAY2 in the subroutine file 'ray.for' for
C             detailed description of IEND.
C     ISHEET..Ray-history index.  The different ray histories are
C             consecutively indexed by positive integers 1,2,3,...
C             according to their appearance during ray tracing.
C             The ray histories are indexed independently within each
C             elementary wave.  The indices are the output of subroutine
C             RPAR4 which calls subroutine IHIST,
C             both of file 'rpar.for'.
C             The ray-history indices are complemented with sign:
C             positive - successful ray (crossing reference surface),
C             negative - unsuccessful ray (terminating before crossing
C             reference surface).
C     IREC... Index of the receiver for a two-point ray,
C             0 for basic ray,
C             -1 for other rays (e.g., auxialiary or boundary rays).
C     YLI...  Array containing the values of the quantities YL(1)-YL(6),
C             see C.R.T.5.5.4,
C             describing the local properties of the model
C             at the initial point of the ray.  See the list of
C             YL(1) to YL(6) above.
C     YI...   Array containing the quantities describing the properties
C             of the rays and of the travel-time field at the initial
C             point of the ray, see C.R.T.6.1.
C             These quantities are also listed in the file 'initc.inc'.
C     YI(1) to YI(11)... Initial values of quantities Y(1) to Y(11)
C             described above.
C     YI(12),YI(16)     QR11,QR12
C     YI(13),YI(17)     QR21,QR22
C     YI(14),YI(18)     PR11,PR12
C     YI(15),YI(19)...  PR21,PR22
C             Elements of the ray geometrical spreading matrix QR, and
C             of the matrix PR (see C.R.T.,
C             eq.(5.13))
C             at the initial point of the ray.
C     YI(20),YI(21)... Take-off parameters of the ray.
C     YI(22)..Area of the element of the ray-parameter surface,
C             corresponding to the ray, see C.R.T.,
C             eq.(6.1).
C     YI(23),YI(24),YI(25)... Components 11, 12, 22 of the symmetric
C             matrix inverse to the specific moment of the element of
C             the ray-parameter surface corresponding to the ray, see
C             eq.(6.2).
C     YI(26),YI(27)... Normalized take-off parameters of the ray, both
C             taking the values between 0 and 1.
C     YI(28),YI(29)... For a successful ray, values of the
C             X1 and X2
C             functions parametrizing the reference surface.
C             Otherwise zeros.
C     NPVI... Total number of the components of the defined reference
C             polarization vectors at the initial point of the ray.
C             The P-vave reference polarization vector is equal to the
C             P-wave eigenvector of the reference Christoffel matrix.
C             The S-vave reference polarization vectors may equal to:
C             (a) S-wave polarization vectors in the low-frequency limit
C             of the coupling ray theory for S waves, which are situated
C             in the same plane as the S-wave eigenvectors of the
C             reference Christoffel matrix, but they do not rotate about
C             the common anisotropic reference ray (output of crt.for).
C             In this case, the first S-vave reference polarization
C             vector at the initial point of the ray is given by the
C             projection of the first basis vector of the ray-centred
C             coordinate system onto the S-wave polarization plane.
C             (b) S-wave eigenvectors of the reference Christoffel
C             matrix (coupling ray theory for S waves,
C             output of crtpfa.for).
C             NPVI=0:  Isotropic medium.  The eigenvectors coincide
C               with the basis vectors of ray-centred coordinates.
C               Array PVI is undefined.
C             NPVI=3:  P wave in an anisotropic medium.
C               PVI(1:6) are two zero vectors.
C               PVI(7:9) is the P-wave eigenvector of the Christoffel
C                 matrix.
C             NPVI=6:  S wave in an anisotropic medium.
C               PVI(1:3) and PVI(4:6) are the two S-wave reference
C                 polarization vectors.
C               PVI(7:9) is a zero vector.
C             NPVI=9:  All three eigenvectors are required in the case
C               of conversion coefficients at a free surface in an
C               anisotropic medium.
C               PVI(1:3) and PVI(4:6) are the two S-wave reference
C                 polarization vectors,
C               PVI(7:9) is the P-wave reference polarization vector.
C     PVI...  Possible components of the reference polarization vectors
C             at the initial point of the ray.
C
C     The storage locations of the common block /POINTC/ are defined and
C     redefined in the external procedure AP00 of file 'ap.for'.
C     The quantities describing another point along a ray can be stored
C     into the common block /POINTC/ by another invocation of the
C     subroutine AP00.
C
C     Common block /POINTC/ is included in FORTRAN 77 source code files
C     'ap.for', 'apvar.for', 'crt2p.for', 'crtout.for', 'crtpts.for',
C     'crtray.for', 'invtt.for',  and may also be included in any user's
C     subroutine processing the results of the complete ray tracing
C     program.
C
C Version: 7.10
C Date: 2014, May 21
C Coded by Ludek Klimes
C
C=======================================================================
C