GetTopSeg Subroutine

public subroutine GetTopSeg(r, t)

Arguments

Type IntentOptional Attributes Name
real(kind=8), intent(in) :: r
real(kind=8), intent(in) :: t

Calls

proc~~gettopseg~~CallsGraph proc~gettopseg GetTopSeg proc~errout ERROUT proc~gettopseg->proc~errout

Called by

proc~~gettopseg~~CalledByGraph proc~gettopseg GetTopSeg proc~traceray2d~2 TraceRay2D proc~traceray2d~2->proc~gettopseg proc~bellhopcore~2 BellhopCore proc~bellhopcore~2->proc~traceray2d~2 program~bellhop BELLHOP program~bellhop->proc~bellhopcore~2

Source Code

  SUBROUTINE GetTopSeg( r, t )

    ! Get the Top segment info (index and range interval) for range, r
    ! LP: t: range component of ray tangent. Endpoints of segments are handled
    ! so that if the ray moves slightly along its current direction, it will
    ! remain in the same segment.

    INTEGER, PARAMETER :: PRTFile = 6
    INTEGER :: IsegTopT( 1 )
    REAL (KIND=8), INTENT( IN ) :: r, t

    IF ( t > 0.0 ) THEN
       IsegTopT = MAXLOC( Top( : )%x( 1 ), Top( : )%x( 1 ) <= r )
    ELSE
       IsegTopT = MAXLOC( Top( : )%x( 1 ), Top( : )%x( 1 ) <  r )
    ENDIF

    IF ( IsegTopT( 1 ) > 0 .AND. IsegTopT( 1 ) < NatiPts ) THEN  ! IsegTop MUST LIE IN [ 1, NatiPts-1 ]
       IsegTop = IsegTopT( 1 )
       rTopSeg = [ Top( IsegTop )%x( 1 ), Top( IsegTop + 1 )%x( 1 ) ]   ! segment limits in range
    ELSE
       WRITE( PRTFile, * ) 'r = ', r
       WRITE( PRTFile, * ) 'rLeft  = ', Top( 1       )%x( 1 )
       WRITE( PRTFile, * ) 'rRight = ', Top( NatiPts )%x( 1 )
       CALL ERROUT( 'GetTopSeg', 'Top altimetry undefined above the ray' )
    ENDIF

  END SUBROUTINE GetTopSeg