      SUBROUTINE BATHY(N,RANG,DPTH,IRLIN,RANGE,DEPTH,NREG,NRX,
     &                  IMAT,NEWSVP)
C
C     THIS SUBROUTINE GENERATES A STEPWISE REPRESENTATION OF A SLOPING
C     BOTTOM. THE LOGIC DEPENDS ON IRLIN (IRLIN(N) IS NOT USED).
C
C     IRLIN(J) .LE. 0 - THE DEPTH CHANGES FROM DPTH(J) TO DPTH(J+1) AT 
C                       RANG(J).
C
C     IRLIN(J) .GE. 1 - IRLIN(J) STEPS ARE INTRODUCED IN THE INTERVAL 
C                       BETWEEN RANG(J) AND RANG(J+1). EACH STEP IS
C                       (RANG(J+1)-RANG(J))/IRLIN(J) LONG. THE MID-
C                       POINTS OF THE TOPS OF THE STEPS LIE ON THE 
C                       LINE BETWEEN (DPTH(J),RANG(J)) AND (DPTH(J+1),
C                       RANG(J+1)).
C
      IMPLICIT REAL*8 (A-H,O-Z)
      DIMENSION RANG(NRX),DPTH(NRX),IRLIN(NRX)
      DIMENSION RANGE(NRX),DEPTH(NRX)
      CHARACTER*3 NEWSVP(NRX)
C
      IF(IMAT .NE. 0) THEN
      DO 50 NR=1,NRX
      NEWSVP(NR)='OLD'
   50 CONTINUE
      END IF      
C
      IF(RANG(1) .LE. 0.0) RANG(1)=RANG(2)/2.0
      JJ=1
      RANGE(JJ)=RANG(1)
      DEPTH(JJ)=DPTH(1)
      IF(IMAT .NE. 0) NEWSVP(JJ)='NEW'
C
      DO 150 J=1,N-1
C
      IF(IMAT .NE. 0) NEWSVP(JJ+1)='NEW'
C
      IF(IRLIN(J) .GT. 0 )   THEN
C
C     GENERATE REPRESENTATION OF THE SLOPE
C
      DRNG=(RANG(J+1)-RANG(J))/IRLIN(J)
      DDEP=(DPTH(J+1)-DPTH(J))/IRLIN(J)
C
      DO 100 I=1,IRLIN(J)
      JJ=JJ+1
      RANGE(JJ)=RANG(J)+I*DRNG
      DEPTH(JJ)=DPTH(J)+(FLOAT(I-1)+0.5)*DDEP
  100 CONTINUE
      GO TO 150
C
      END IF
C
      JJ=JJ+1
      RANGE(JJ)=RANG(J+1)
      DEPTH(JJ)=DPTH(J+1)
C
  150 CONTINUE
C
      IF(IRLIN(N-1) .GT. 0)   THEN
      JJ=JJ+1
      DEPTH(JJ)=DPTH(N)
      RANGE(JJ)=RANG(N)+DRNG
      END IF
C
      NREG=JJ
C
      RETURN
      END
