      SUBROUTINE WEIGHT( X, NX, XTAB, NXTAB, W, IX )

C     Given 
C        X(*)    abscissas
C        XTAB(*) points for tabulation
C        NX      number of x points

C     Compute
C        W(*)    weights for linear interpolation
C        IX(*)   indices for    "         "

      INTEGER IX(*)
      REAL X(*), XTAB(*), W(*)

C     *** Is there just one X value for interpolation? ***

      IF ( NX .EQ. 1 ) THEN
         W(  1 ) = 0.0
         IX( 1 ) = 1
         RETURN
      ENDIF

C     *** Locate indices, compute weights ***

      L = 1
      DO 2000 IXTAB = 1, NXTAB

C        Does [X(L), X(L+1)] bracket rcvr depth?

 1000    IF ( X( L+1 ) .GE. XTAB( IXTAB ) .OR. L .GE. NX-1 ) THEN
C           ------ Yes: make note of L and weight for interpolation
            IX( IXTAB ) = L
            W(  IXTAB ) = ( XTAB(IXTAB) - X(L) ) / ( X(L+1) - X(L) )
            GOTO 2000
         ELSE
C           ------ No: advance to next depth
            IF ( L .LT. NX - 1 ) L = L + 1
            GOTO 1000
         ENDIF

 2000 CONTINUE

      RETURN
      END
