      SUBROUTINE STABL(DEPTH,PRVDPT,RHO,PRVRHO,RHOT,E)
C
C     TITLE:
C     *****
C
C       STABL  -- STABILITY
C
C     SYSTEM:
C     ******
C
C       PACODF HYDROGRAPHIC DATA LIBRARY
C
C     PURPOSE:
C     *******
C
C       TO STABILITY. STABILITY IS DEFINED:
C
C       E = 2*(RHOT-RHOP)/((RHO+RHOP)*DZ)
C
C       WHERE:          RHO  = INSITU DENSITY
C                       RHOP = PREVIOUS INSITU DENSITY
C                       RHOT = INSITU DENSITY @ RP= PREVIOUS PRESSURE
C                       DZ   = CHANGE IN DEPTH
C
C
C     USAGE:
C     *****
C
C       A PREVIOUS DEPTH (PRVDPT) AND PREVIOUS INSITU DENSITY (PRVRHO)
C       ARE REQUIRED FOR THE CALCULATION. THEY SHOULD BOTH INITIALLY
C       BE SET TO nan TO INITIALIZE THE CALCULATION.
C
C     PARAMETERS:
C     **********
C
C       DEPTH   -> DEPTH IN METERS
C       PRVDPT  -> PREVIOUS DEPTH IN METERS
C       RHO     -> INSITU DENSITY (SIGMAZ+1000)
C       PRVRHO  -> PREVIOUS RHO
C       RHOT    -> INSITU DENSITY AT REF PRESS=PREVIOUS PRESSURE
C       E       <- STABILITY (E X 10**8)
C
        REAL DEPTH,PRVDPT,RHO,PRVRHO,RHOT,E
C
C     VARIABLES:
C     *********
C
         REAL*4 DZ
C
C     CONSTANTS:
C     *********
C
        integer isnan
C         /* MISSING DATA VALUE */
C
C     CODE:
C     ****
C
C     /* CALCULATE STABILITY */
C
C     SELECT
C       (NO PREVIOUS DEPTH OR CHANGE IN DEPTH):
          IF(isnan(PRVDPT).ne.0.OR.PRVRHO.EQ.0.0) GO TO 10
          DZ = DEPTH - PRVDPT
          IF(ABS(DZ).GT.0.5) GO TO 20
   10     CONTINUE
          call setnan(E)
          GO TO 999
C       (OTHERWISE):
   20     CONTINUE
          E      = 2.0*(RHOT-PRVRHO)/((RHO+PRVRHO)*(DZ))*1.0E8
C           /* STABILITY: E X 10**8 */
C     END SELECT
C
C     /* RETURN */
C
  999 CONTINUE
      RETURN
C
C     END STABL
C
      END
