C******************** START FILE UFSCM2.FOR ; GROUP UFSCLK ******************
C---------------------------------------------------------------
C  UFSCM2
C   COMPARE KEYWORD LIST FROM SHOT 1 TO LIST FROM SHOT 2
C   SIMILAR TO ROUTINE UFSCMP BUT WITH DIFFERENT LABELING
C
      SUBROUTINE UFSCM2(ZLIST,ZVAL,IORD,NDIM,NUM,ISHOT,IDIFS)
C
      CHARACTER*10 ZLIST(3,NDIM,3)
      CHARACTER*6 ASHOT
      CHARACTER*40 ZLLAB(4)
      INTEGER IORD(NDIM,3),NUM(3),IDIFSA(4),ISHOT(2)
      REAL ZVAL(NDIM,3)
C
C  ZLIST-- SCALAR KEYWORDS AND LABELS
C  IORD-- CALCULATED ALPHABETIC ORDER ON LISTS
C  ZVAL-- REAL VALUES OF ENTRIES IN LIST
C   ROW 1: AVERAGED DATA LIST-- COMPILED FROM DATA AVERAGED SO FAR
C   ROW 2: NEW DATA LIST-- FROM DATA FILE JUST READ (NOT YET AVERAGED)
C   ROW 3: COMPARISON LIST  COMPUTED FROM ROWS 1 AND 2
C  NDIM-- ARRAY DIMENSION-- MAX NO. OF ENTRIES IN LIST
C  NUM(3)-- NUMBER OF ENTRIES IN EACH LIST
C
C  CALCULATE ALPHABETIC ORDERINGS
C
C *LISMAK* DATA SATEMENT MOVED 12-APR-88
C *LISMAK* DATA SATEMENT MOVED 12-APR-88
C *LISMAK* DATA SATEMENT MOVED 12-APR-88
C *LISMAK* DATA SATEMENT MOVED 12-APR-88
C
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCHAR,lxout
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
C => UFSCM2               BEGIN DATA BLOCK
C => LISMAK 12-APR-88  MOVED DATA STATEMENTS
      DATA ZLLAB/'LIST1:  FROM FILE, SHOT ######          ',
     >             'LIST2:  FROM FILE, SHOT ######          ',
     >             'IN FILE OF SHOT ######, BUT NOT ######  ',
     >             'IN FILE OF SHOT ######, BUT NOT ######  '/
C => END DATA BLOCK
C ====================
C
      luntrm=lnout(0)
C
      WRITE   (ASHOT,1000) ISHOT(1)
 1000 FORMAT(I6)
      ZLLAB(1)(25:30)=ASHOT
      ZLLAB(3)(17:22)=ASHOT
      ZLLAB(4)(33:38)=ASHOT
      WRITE   (ASHOT,1000) ISHOT(2)
      ZLLAB(2)(25:30)=ASHOT
      ZLLAB(3)(33:38)=ASHOT
      ZLLAB(4)(17:22)=ASHOT
 5    CONTINUE
      DO 10 ILIS=1,2
      IF(NUM(ILIS).GT.0)
     >     CALL UFSCOR(NUM(ILIS),ZLIST(1,1,ILIS),IORD(1,ILIS))
 10   CONTINUE
C
 30   CONTINUE
C  COMPARE THE LISTS
      IDIFS=0
      DO 40 ITYP=1,4
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,ITYP,1)
      IDIFS=MAX0(IDIFS,NUM(3))
      IDIFSA(ITYP)=NUM(3)
 40   CONTINUE
C
 100  CONTINUE
      CALL NEUPAG
      IF(LXOUT(0)) WRITE(LUNTRM,2001) ISHOT(1),ISHOT(2),NUM(1),NUM(2)
 2001 FORMAT(
     >  ' KEYWORD SCALAR LIST1:  FROM FILE, SHOT # ',I6/
     >  ' KEYWORD SCALAR LIST2:  FROM FILE, SHOT # ',I6/
     >  ' LIST1 HAS ',I3,' ENTRIES; LIST2 HAS ',I3,' ENTRIES')
      IF((LXOUT(0)).AND.(IDIFS.GT.0))
     >      WRITE(LUNTRM,2002) (IDIFSA(IJ),IJ=1,4)
 2002 FORMAT(
     >  1X,I3,' KEYWORD ENTRIES IN LIST1 ARE NOT IN LIST2'/
     >  1X,I3,' KEYWORD ENTRIES IN LIST2 ARE NOT IN LIST1'/
     >  1X,I3,' ENTRIES HAVE THE SAME KEYWORDS BUT DIFFERING LABELS'/
     >  1X,I3,' ENTRIES HAVE THE SAME KEYWORDS BUT DIFFERENT VALUES'/)
      IF((LXOUT(0)).AND.(IDIFS.EQ.0)) WRITE(LUNTRM,2003)
 2003 FORMAT(' >> LIST1 AND LIST2 ARE IDENTICAL'/)
      IF(LXOUT(0)) WRITE(LUNTRM,2005)
 2005 FORMAT(' >> OPTION CODES:'/
     >  '  1:  LIST ALL SCALARS IN LIST1'/
     >  '  2:  LIST ALL SCALARS IN LIST2')
      IF(LXOUT(0).AND.(IDIFSA(1).GT.0)) WRITE(LUNTRM,2051)
 2051 FORMAT(
     >  ' -1:  LIST ALL KEYWORD SCALARS IN LIST1 BUT NOT IN LIST2')
      IF(LXOUT(0).AND.(IDIFSA(2).GT.0)) WRITE(LUNTRM,2052)
 2052 FORMAT(
     >  ' -2:  LIST ALL KEYWORD SCALARS IN LIST2 BUT NOT IN LIST1')
      IF(LXOUT(0).AND.(IDIFSA(3).GT.0)) WRITE(LUNTRM,2053)
 2053 FORMAT('  3:  LIST ALL KEYWORDS FOR WHICH LABELS DISAGREE')
      IF(LXOUT(0).AND.(IDIFSA(4).GT.0)) WRITE(LUNTRM,2054)
 2054 FORMAT('  4:  LIST ALL KEYWORDS FOR WHICH VALUES DISAGREE')
      IF(LXOUT(0)) WRITE(LUNTRM,2055)
 2055 FORMAT('  Q:  ENTER "Q" TO EXIT'/)
      CALL UREAD('UFSCM2:  ENTER OPCODE (1/2////Q):$')
      IF(LCHAR('Q')) RETURN
      IANS=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 100
      IF(IANS.EQ.1) GO TO 110
      IF(IANS.EQ.2) GO TO 110
      IC1=0
      IC2=0
      IF((IANS.EQ.-1).AND.(IDIFSA(1).GT.0)) GO TO 200
      IF((IANS.EQ.-2).AND.(IDIFSA(2).GT.0)) GO TO 300
      IF((IANS.EQ.3).AND.(IDIFSA(3).GT.0)) GO TO 400
      IF((IANS.EQ.4).AND.(IDIFSA(4).GT.0)) GO TO 500
      GO TO 100
C------
 110  CONTINUE
      IF(NUM(IANS).EQ.0) GO TO 120
      CALL UFSCPR(ZLLAB(IANS),ZLIST(1,1,IANS),ZVAL(1,IANS),
     >     IORD(1,IANS),NUM(IANS),0)
      GO TO 100
 120  CONTINUE
      WRITE(LUNTRM,9051) IANS
 9051 FORMAT(/' % LIST',I1,' CONTAINS NO ENTRIES'/)
      CALL UPAUST(1)
      GO TO 100
C------
 200  CONTINUE
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,1,1)
      CALL UFSCPR(ZLLAB(3),
     >     ZLIST(1,1,3),ZVAL(1,3),IORD(1,3),NUM(3),IC1)
      GO TO 100
C------
 300  CONTINUE
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,2,1)
      CALL UFSCPR(ZLLAB(4),
     >     ZLIST(1,1,3),ZVAL(1,3),IORD(1,3),NUM(3),IC1)
      GO TO 100
C-----
 400  CONTINUE
C  PUT BOTH VERSIONS ON SAME PAGE IF NUMBER IS SMALL
      IF(IDIFSA(3).GT.10) GO TO 410
      IC1=-1
      IC2=1
 410  CONTINUE
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,3,1)
      CALL UFSCPR(ZLLAB(1),
     >     ZLIST(1,1,3),ZVAL(1,3),IORD(1,3),NUM(3),IC1)
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,3,2)
      CALL UFSCPR(ZLLAB(2),
     >     ZLIST(1,1,3),ZVAL(1,3),IORD(1,3),NUM(3),IC2)
      GO TO 100
C-----
 500  CONTINUE
C  PUT BOTH VERSIONS ON SAME PAGE IF NUMBER IS SMALL
      IF(IDIFSA(4).GT.10) GO TO 510
      IC1=-1
      IC2=1
 510  CONTINUE
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,4,1)
      CALL UFSCPR(ZLLAB(1),
     >     ZLIST(1,1,3),ZVAL(1,3),IORD(1,3),NUM(3),IC1)
      CALL UFSCDF(ZLIST,ZVAL,IORD,NDIM,NUM,4,2)
      CALL UFSCPR(ZLLAB(2),
     >     ZLIST(1,1,3),ZVAL(1,3),IORD(1,3),NUM(3),IC2)
      GO TO 100
C
      END
C******************** END FILE UFSCM2.FOR ; GROUP UFSCLK ******************
