      SUBROUTINE OBSSUM (IUO,G)

*** PRINTOUT THE OBSERVATIONAL SUMMARY

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      IMPLICIT INTEGER (I-N)
      PARAMETER ( MXSSN = 9999, NVECS = 16 )
      CHARACTER*1 ACON
      CHARACTER*30 NAMES,NAME1
      LOGICAL LOCSSN,FATAL
      LOGICAL LBB,LGF,LCS,LVD,LVA,LVZ,LVS,
     &        LVR,LVG,LVC,LIS,LPS,LPG,LDR,LOS,LAP
      LOGICAL LMSL,LSS,LUP
      DIMENSION G(*),IC(31),C(31),ICM((NVECS+1)*15+1)
      DIMENSION KINDS(3*NVECS),ISNS(3*NVECS),JSNS(3*NVECS),LOBS(3*NVECS)
      COMMON /NAMTAB/ NAMES(MXSSN)
      COMMON /OBSUM/ NSUM(MXSSN,14)
      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 /OPRINT/ CRIT,LBB,LGF,LCS,LVD,LVA,LVZ,LVS,
     &                LVR,LVG,LVC,LIS,LPS,LPG,LDR,LOS,LAP

*** PRINT HEADING

      IF (.NOT.LOS) RETURN
      CALL HEAD6

*** INITIALIZE TABLE

      CALL NEWI

      REWIND IUO
 100  READ (IUO,END=777) KIND,ISN,JSN,IC,C,LENG,CMO,OBSB,SD,
     &                   IOBS,IVF,IAUX,ITIME
      IF (KIND.LE.999) CALL CONTR (KIND,ISN,JSN,IAUX)
      IF ( KIND.EQ.1 ) THEN
        NSUM(ISN,7) = NSUM(ISN,7) + 1000
      ENDIF
      IF (KIND.GE.1000) THEN
        NVEC = ISN
        IAUX = JSN
        LENG = (NVEC + 1) * 3 + 1
        IF (NCD.GT.0) LENG = LENG + 12 * (NVEC + 1)
        NR = 3 * NVEC
        NC = NR + 5 + LENG
        READ (IUO,END=777) ICM,NICM,KINDS,ISNS,JSNS,LOBS
        DO 10 I2 = 1,NVEC
          J1 = (I2 - 1) * 3 + 1
          KIND = KINDS(J1)
          ISN = ISNS(J1)
          JSN = JSNS(J1)
          CALL CONTR (KIND,ISN,JSN,IAUX)
 10     CONTINUE
        CALL DUMRD (IUO,NR,NC,G)
      ENDIF
      GO TO 100

 777  FATAL = .FALSE.
      DO 1 I = 1,NSTA
        IF ( .NOT.LOCSSN(I,ISSN) ) THEN
          WRITE (6,666) I
 666      FORMAT ('0SSN TABLE ERROR IN OBSSUM--',I5)
          CALL ABORT2
        ENDIF
        NAME1 = NAMES(I)

*** TEST IF STATION IS UNDETER, NO-CHECK, OR CONSTRAINED

        NGPS = NSUM(I,7) + NSUM(I,8)
          N1 = NSUM(I,3) + NSUM(I, 4) + NSUM(I, 5) + NSUM(I, 6) + NGPS
          N2 = NSUM(I,1) + NSUM(I, 2) + NSUM(I, 3) + NSUM(1, 4) +
     &         NSUM(I,9) + NSUM(I,10) + NSUM(I,11) + NSUM(1,12) + NGPS
          IF ( (N1.LE.1 .AND. NGPS.NE.1) .OR.
     &         (N2.LE.1 .AND. NGPS.NE.1) ) THEN
            ACON = 'U'
            FATAL = .TRUE.
          ELSEIF ( (N1.EQ.2 .OR. (N1.EQ.1 .AND. NGPS.EQ.1) ).OR.
     &             (N2.EQ.2 .OR. (N2.EQ.1 .AND. NGPS.EQ.1) ) ) THEN
            ACON = 'N'
          ELSEIF ( (N1.GE.1000) .OR. (N2.GE.1000) ) THEN
            ACON = 'C'
            NSUM(I,7) = NSUM(I,7) - 1000
          ELSE
            ACON = ' '
          ENDIF
          IF (ACON.EQ.'N' .AND. NGPS.EQ.2) ACON = ' '

        CALL LINE6 (1)
        WRITE (6,5) ISSN,ACON,NAME1,
     &              NSUM(I, 9),NSUM(I,10), NSUM(I,11),NSUM(I,12),
     &              NSUM(I, 1),NSUM(I, 2), NSUM(I, 3),NSUM(I, 4),
     &              NSUM(I, 5),NSUM(I, 6), NSUM(I, 7),NSUM(I, 8),
     &              NSUM(I,13),NSUM(I,14)
    5   FORMAT (' ',I5,A1,2X,A30, I4,I5, 6(I7,I5) )

    1 CONTINUE

*** TERMINATE IF UNDETERMINED STATIONS EXIST

      IF (FATAL) THEN
        WRITE (6,667)
*667    FORMAT ('0***** FATAL ERROR - UNDETERMINED(U) STATIONS *****')
*       CALL ABORT2
  667   FORMAT ('0***** WARNING -- UNDETERMINED STATIONS MAY EXIST ***')
      ENDIF

      RETURN
      END

      SUBROUTINE NEWI

*** INITIALIZE THE TABLE TO ZERO

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      IMPLICIT INTEGER (I-N)
      PARAMETER (MXSSN = 9999)
      COMMON /OBSUM/ NSUM(MXSSN,14)
      COMMON /STRUCT/ NSTA,NAUX,NUNK,IDIM,NSTAS,NOBS,NCON,NZ,NCD

      DO 1 I = 1,NSTA
        DO 2 J = 1,14
          NSUM(I,J) = 0
    2   CONTINUE
    1 CONTINUE

      RETURN
      END
      SUBROUTINE CONTR (KIND,I,J,K)

*** KEEP COUNT OF EACH OBSERVATIONAL TYPE

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      IMPLICIT INTEGER (I-N)
      PARAMETER (MXSSN = 9999)
      COMMON /OBSUM/ NSUM(MXSSN,14)

*** COUNT ALL THE AZIMUTHS FROM(*,1) AND TO(*,2) KIND = 8, KIND = 12

      IF (KIND.EQ.8 .OR. KIND.EQ.12) THEN
        NSUM(I,1) = NSUM(I,1) + 1
        NSUM(J,2) = NSUM(J,2) + 1

*** COUNT ALL THE DISTANCES FROM(*,3) AND TO(*,4), KIND = 7, KIND = 13

      ELSEIF (KIND.EQ.7 .OR. KIND.EQ.13) THEN
        NSUM(I,3) = NSUM(I,3) + 1
        NSUM(J,4) = NSUM(J,4) + 1

*** COUNT ALL THE ZENITH DIST. FROM(*,5) AND TO(*,6) KIND = 9 KIND = 14

      ELSEIF (KIND.EQ.9 .OR. KIND.EQ.14) THEN
        NSUM(I,5) = NSUM(I,5) + 1
        NSUM(J,6) = NSUM(J,6) + 1

*** COUNT ALL THE GPS FROM(*,7) AND TO(*,8) KIND = 4

      ELSEIF (KIND.EQ.4) THEN
        NSUM(I,7) = NSUM(I,7) + 1
        NSUM(J,8) = NSUM(J,8) + 1

*** COUNT THE DIRECTIONS FROM(*,9) AND TO(*,10) KIND = 11

      ELSEIF (KIND.EQ.11) THEN
        NSUM(I,9) = NSUM(I,9) + 1
        NSUM(J,10) = NSUM(J,10) + 1

*** COUNT THE ANGLES FROM(*,11) AND TO(*,12) KIND = 10

      ELSEIF (KIND.EQ.10) THEN
        NSUM(I,11) = NSUM(I,11) + 1
        NSUM(J,12) = NSUM(J,12) + 1
        NSUM(K,12) = NSUM(K,12) + 1

*** COUNT THE CM CONSTRAINTS FROM(*,13) AND TO(*,14) KIND = 18

      ELSEIF (KIND.EQ.18) THEN
        NSUM(I,13) = NSUM(I,13) + 1
        NSUM(J,14) = NSUM(J,14) + 1
      ENDIF

      RETURN
      END
