      SUBROUTINE DISTOB (CARD,IUO,IOBS,B,NX,FATAL,LSN)

*** OBSERVATION EQUATIONS FOR DISTANCES

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      IMPLICIT INTEGER (I-N)
      CHARACTER*80 CARD
      CHARACTER*13 DATE
      CHARACTER*9 ADIS52
      CHARACTER*10 ADIS54
      LOGICAL FATAL,LSN
      LOGICAL GETSSN,GETPRM,GETIVF
      LOGICAL ADDCON
      LOGICAL LMSL,LSS,LUP
      DIMENSION B(*),NX(*)
      DIMENSION IC(31),C(31)
      COMMON /STRUCT/ NSTA,NAUX,NUNK,IDIM,NSTAS,NOBS,NCON,NZ,NCD
      COMMON /OPT/ AX,E2,DMSL,DGH,VM,VP,CTOL,ITMAX,ITMIN,IMODE,
     &             LMSL,LSS,LUP
      COMMON /STATCT/ N84,N85,N86,N89,NDIR,NANG,NGPS,NZD,NDS,NAZ,NQQ,
     &                NREJ,NGPSR

      READ (CARD,1) IRT, ISSN,  JSSN
    1 FORMAT (7X, I2, 1X, I4, 31X,  I4)
      IF (IRT.EQ.52) THEN
        READ (CARD,3) ADIS52
 3      FORMAT (63X,A9)
        CALL NBLANK (ADIS52,4,IBLK)
        READ (ADIS52,5) OBSB
 5      FORMAT (F9.4)
      ELSE
        READ (CARD,4) ADIS54
 4      FORMAT (63X,A10)
        CALL NBLANK (ADIS54,3,IBLK)
        READ (ADIS54,6) OBSB
 6      FORMAT (F10.3)
      ENDIF
      IF (CARD(6:6).EQ.'O') NREJ = NREJ + 1
      DATE = CARD(33:48)
      CALL TRNDAT(DATE, ITIME)
      IF ( CARD(6:6).NE.'O' ) THEN
        IF ( .NOT.GETSSN(ISSN,ISN) ) THEN
          CALL LINE (3)
          WRITE (6,2) CARD
 2        FORMAT ('0ERROR - NO *80* RECORD FOR--',A80,/)
        ELSEIF ( .NOT.GETSSN(JSSN,JSN) ) THEN
          CALL LINE (3)
          WRITE (6,2) CARD
        ELSE

***   RETRIEVE A STD DEV

          CALL STDDEV (CARD,IRT,SD)

*** KIND = 7 MARK TO MARK DISTANCE

          KIND = 7
          IOBS = IOBS + 1
          NOBS = NOBS + 1
          NDS = NDS + 1
          LSN = .TRUE.
          IF ( .NOT.GETPRM(52,ITIME,IAUX) ) IAUX = 0
          IF ( .NOT.GETIVF(52,ITIME,IVF) ) IVF = 0
          CALL FORMIC (KIND,ISN,JSN,IAUX,IC,LENG,B)
          CALL FORMC (KIND,C,B,ISN,JSN,IAUX,ITIME)
          CALL COMPIC(IC,C,LENG)
          CALL COMPOB (KIND,OBS0,B,OBSB,ISN,JSN,IAUX,ITIME)
          CMO = OBS0 - OBSB
          IF (IMODE.EQ.0) CMO = 0.D0
          CALL BIGV (KIND,ISN,JSN,IOBS,IVF,CMO,SD,FATAL)

*** UPDATE CONNECTIVITY
          IF ( .NOT.ADDCON(IC,LENG,NX) ) THEN
            WRITE (6,666)
 666        FORMAT ('0ERROR - INSUFFICIENT STORAGE FOR REDUCED',
     &              ' DISTANCES',/)
            CALL ABORT2
          ENDIF

          WRITE (IUO) KIND,ISN,JSN,IC,C,LENG,CMO,OBSB,SD,
     &                IOBS,IVF,IAUX,ITIME
        ENDIF
      ENDIF

      RETURN
      END
