



      SUBROUTINE WIF115 (IGRP)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INTEGER       IGRP
      LOGICAL       GVFIBN







   10 CONTINUE
      CALL ASKGROUP (IGRP,'?ASKGRP1')
      IF (IGRP.EQ.0) GOTO 998



      IF (.NOT.GVFIBN(IGRP,1,10)) THEN
         CALL GVSTT6 ('?NEWT202')
         GOTO 10
      END IF
      IF (.NOT.GRPACT(IGRP)) THEN
         CALL GVSTT6 ('?NEWT203')
         CALL GRPFREENB
         CALL GRPSHOW
         GOTO 10
      END IF



      CALL GRPREAD (IGRP)



      WIFPAR(1159)=IGRP



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GRPREAD (IGRP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      LOGICAL       GVFFOP, GVFIBN
      INTEGER       IGRP, IUNIT, IO, JO, NUMPIN







      IF (.NOT.GVFIBN(IGRP,1,10)) THEN
         CALL GVSTTE ('?NEWE121')
         GOTO 996
      END IF
      IF (.NOT.GRPACT(IGRP)) THEN
         CALL GVSTTE ('?NEWE122')
         GOTO 996
      END IF



      IUNIT=40+IGRP
      IF (.NOT.GVFFOP(IUNIT)) GOTO 997
      CALL GVSREW (IUNIT)
      READ (IUNIT) NUMPIN
      READ (IUNIT,END=999,ERR=998) ((GRPNTR(IO,JO),IO=1,2),JO=1,NUMPIN)

      GOTO 996

  999 CONTINUE
      CALL GVSTTE ('?M0891')
      IGRP=0
      GOTO 996

  998 CONTINUE
      CALL GVSTTE ('?M0892')
      IGRP=0
      GOTO 996

  997 CONTINUE
      CALL GVSTTB ('?M0893')
      IGRP=0



  996 CONTINUE


      RETURN
      END
      SUBROUTINE GRPSAVE (IGROUP,GRPROW,NUMHIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      LOGICAL       GVFFOP, GVFIBN
      INTEGER       GRPROW(2,MAXSP), IGROUP, NUMHIT, IUNIT, J, I







      IF (.NOT.GVFIBN(IGROUP,1,10)) THEN
         CALL GVSTTI ('?GRPB01',IGROUP)
         GOTO 998
      END IF



      IUNIT=40+IGROUP
      IF (.NOT.GVFFOP(IUNIT)) THEN
         CALL GVSTTB ('?GRPB02')
         GOTO 998
      END IF



      CALL GVSREW (IUNIT)
      WRITE (IUNIT,ERR=999) NUMHIT
      WRITE (IUNIT,ERR=999) ((GRPROW(I,J),I=1,2),J=1,NUMHIT)



      GRPACT(IGROUP)=.TRUE.
      GRPLEN(IGROUP)=NUMHIT
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('GRPSAVE')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GRPINITALL

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'DGLOOP.INC'







      CALL GVSIT0 (GRPLEN,10)
      CALL GVSBTF (GRPACT,10)
      CALL GVSCTB (GRPHOW,800)
      CALL GVSCTB (GRPTITLE,80)
      CALL GVSRT0 (FTCRDS,4*MAXIG)
      CALL GVSRT0 (QFCSTR,MAXDG*10)
      CALL GVSRT0 (DGVEC,3*MAXDG*10)
      CALL GVSRT0 (DGMAT,3*3*MAXDG*10)
      CALL GVSIT0 (DGWHER,2*10)
      CALL GVSRT0 (QFACTS,MAXSP)
      CALL GRPFREENB



      CALL SETHIS ('?RESGRP')





      RETURN
      END
      SUBROUTINE GRPFREENB

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INTEGER       IGRP







      NXTGRP=0



      DO 10 IGRP=1,10
         IF (.NOT.GRPACT(IGRP)) THEN
            NXTGRP=IGRP
            GOTO 998
         END IF
   10 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE GRPSHOW



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       GVFLEN, I, J







      CALL GVSNL6 (2)
      CALL SHOWTEXT ('?GRPHEAD')



      DO 10 I=1,10
         IF (GRPACT(I)) THEN



            CALL GVSFMT ('?FMT657')
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=10) I,GRPLEN(I),
     +       (GRPHOW(I)(J:J),J=1,GVFLEN(GRPHOW(I)))
            CALL GVSTT6 (LINE)
         ELSE



            CALL GVSFMT ('?FMT024')
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=10) I
            CALL GVSSTX (LINE(14:80),'?GRPINA')
            CALL GVSTT6 (LINE)
         END IF
   10 CONTINUE



      CALL GRPFREENB
      I=MAX(1,NXTGRP)
      CALL GVSNL6 (1)
      CALL GVSTTI ('?NXTGRP',I)





      RETURN
      END
      SUBROUTINE GRPRMS (IAA,IGRP)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'DGLOOP.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       IAA, IGRP, I, J, NUMLFT, ICA, ICAST, IHIT,
     +              NUMLF2
      REAL          XYZCON(3,MAXIG), XYZFIT(3,MAXIG), DGVLOC(MAXIG)
      LOGICAL       GVFIBN







      IF (.NOT.GVFIBN(IGRP,1,10)) THEN
         CALL GVSTTI ('?GRPB01',IGRP)
         GOTO 998
      END IF
      IF (.NOT.GVFIBN(IAA,WIFPAR(51)/2,NUMAAF-WIFPAR(51)/2)) THEN
         CALL GVSTTI ('?TLSB04',IAA)
         GOTO 998
      END IF
      IF (WIFPAR(54).LE.0) THEN
         CALL GVSTTE ('?GRPB05')
         GOTO 998
      END IF




      DO 20 I=1,WIFPAR(51)
         DO 10 J=1,3
            XYZCON(J,I)=FTCRDS(J,I)
   10    CONTINUE
   20 CONTINUE








      CALL GVSCPR (DGVLOC,DGWVAL,3*WIFPAR(51))
      CALL GRPSTRIP (XYZCON,DGVLOC,NUMLFT)
      IF (NUMLFT.LT.3) THEN
         CALL GVSTTE ('?GRPB07')
         GOTO 998
      END IF



      DO 100 IHIT=1,WIFPAR(54)



         ICAST=INDPNT(GRPNTR(1,IHIT))+GRPNTR(2,IHIT)
         DO 30 ICA=ICAST,ICAST+WIFPAR(51)-1
            READ (IU100,REC=ICA,ERR=28) RECRD
            XYZFIT(1,ICA-ICAST+1)=RECRD(11)
            XYZFIT(2,ICA-ICAST+1)=RECRD(12)
            XYZFIT(3,ICA-ICAST+1)=RECRD(13)
            GOTO 30



 28         CONTINUE
            XYZFIT(1,ICA-ICAST+1)=999.9+10.0*FLOAT(ICA)
            XYZFIT(2,ICA-ICAST+1)=999.9+10.0*FLOAT(ICA)
            XYZFIT(3,ICA-ICAST+1)=999.9+10.0*FLOAT(ICA)
   30    CONTINUE






         CALL GVSCPR (DGVLOC,DGWVAL,3*WIFPAR(51))
         CALL GRPSTRIP (XYZFIT,DGVLOC,NUMLF2)



         IF (NUMLF2.NE.NUMLFT) CALL GVSTTB ('?GRPB06')



         CALL GVSSP4 (NUMLFT,XYZCON,XYZFIT,DGMAT(1,1,IHIT,IGRP),
     +    DGVEC(1,IHIT,IGRP),QFCSTR(IHIT,IGRP),DGVLOC)
  100 CONTINUE



 998  CONTINUE 


      RETURN
      END
      SUBROUTINE GRPSTRIP (GXYZ,DGVLOC,NUMLFT)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       NUMLFT, I, J
      REAL          GXYZ(3,MAXIG), DGVLOC(MAXIG)







      NUMLFT=WIFPAR(51)
      I=WIFPAR(51)+1
   20 CONTINUE
         I=I-1
         IF (I.EQ.0) GOTO 998
    5    CONTINUE
         IF (ABS(DGVLOC(I)).LT.0.01) THEN



            IF (I.EQ.NUMLFT) THEN



               NUMLFT=NUMLFT-1
            ELSE



               NUMLFT=NUMLFT-1
               DO 10 J=I,NUMLFT
                  GXYZ(1,J)=GXYZ(1,J+1)
                  GXYZ(2,J)=GXYZ(2,J+1)
                  GXYZ(3,J)=GXYZ(3,J+1)
                  DGVLOC(J)=DGVLOC(J+1)
   10          CONTINUE






               GOTO 5
            END IF
         END IF
      GOTO 20



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFAND (NUM1,NUM2,NUM3)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'MAPINC.INC'
      INTEGER       NUM1, NUM2, NUM3, I1, I2, I1V, I2V
      INTEGER       GRPNT3(2,MAXSP)
      EQUIVALENCE   (GRPNT3(1,1),ALLGRD(1))







      IF (NUM1.EQ.0.OR.NUM2.EQ.0) THEN
         CALL GVSTT6 ('?GRPB08')
         NUM3=0
         GOTO 998
      END IF



      I1=1
      I2=1
      NUM3=0
      I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
      I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)



   10 CONTINUE
      IF (I1.LE.NUM1.AND.I2.LE.NUM2) THEN
         IF (I1V.EQ.I2V) THEN
            NUM3=NUM3+1
            GRPNT3(1,NUM3)=GRPNTR(1,I1)
            GRPNT3(2,NUM3)=GRPNTR(2,I1)
            IF (I1.GE.MAXSP.OR.I2.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFAND')
               GOTO 998
            END IF
            I1=I1+1
            I2=I2+1
            I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
            I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
         ELSE IF (I1V.LT.I2V) THEN
            IF (I1.GE.MAXSP.OR.I2.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFAND')
               GOTO 998
            END IF
            I1=I1+1
            I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
         ELSE IF (I2V.LT.I1V) THEN
            IF (I1.GE.MAXSP.OR.I2.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFAND')
               GOTO 998
            END IF
            I2=I2+1
            I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
         END IF
         GOTO 10
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFINV


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'DATBAS.INC'
      LOGICAL       GVFYON, NOGROUPS
      INTEGER       IG1, IG2, IUNIT1, NUM1, ISEQ, IAA, IALL, IOLD,
     +              IO, JO







      CALL GRPFREENB
      IF (NOGROUPS()) THEN
         CALL GVSTTE ('?GRPB10')
         GOTO 998
      END IF



   10 CONTINUE
      CALL ASKGROUP (IG1,'?ASKGRP1')
      IF (IG1.EQ.0) GOTO 998



      IF (.NOT.GRPACT(IG1)) THEN
         CALL GVSTTE ('?GRPB11')
         CALL GRPSHOW
         GOTO 10
      END IF



   11 CONTINUE
      CALL ASKGROUPF (IG2,'?ASKGRP2')
      IF (IG2.EQ.0) GOTO 998



      IF (GRPACT(IG2)) THEN
         CALL GRPSHOW
         CALL GVSTT6 ('?GRPB12')
         IF (.NOT.GVFYON('?WALB14',' ')) GOTO 11
      END IF



      IUNIT1=40+IG1
      CALL GVSREW (IUNIT1)
      READ (IUNIT1) NUM1
      READ (IUNIT1) ((GRPNTR(IO,JO),IO=1,2),JO=1,NUM1)



      IALL=0
      IOLD=1
      DO 100 ISEQ=1,NBINDB
         DO 90 IAA=1,NAAFIL(ISEQ)
            IF (GRPNTR(1,IOLD).EQ.ISEQ.AND.GRPNTR(2,IOLD).EQ.IAA) THEN
               IOLD=IOLD+1
            ELSE
               IALL=IALL+1
               GRPNT2(1,IALL)=ISEQ
               GRPNT2(2,IALL)=IAA
            END IF
   90    CONTINUE
  100 CONTINUE



      CALL GVSFMT ('?FMT658')
      CALL GVSCTB (TPTXLN,LENTPT)
      WRITE (TPTXLN,FMT,ERR=999) IALL
      CALL GVSRDB (TPTXLN)
      IF (.NOT.GVFYON(TPTXLN,' ')) GOTO 998



      CALL GRPSAVE (IG2,GRPNT2,IALL)
      CALL GVSCCC (GRPHOW(IG2),'.NOT.',GRPHOW(IG1))
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('WIFINV')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFMGR (NUMPIN,IGRUSE)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'MAPINC.INC'
      LOGICAL       GVFYON
      INTEGER       NUMPIN, IGRUSE, INMGRP
      CHARACTER*80  LOCLIN
      INTEGER       GRPNT3(2,MAXSP)
      EQUIVALENCE   (GRPNT3(1,1),ALLGRD(1))













      CALL GRPFREENB



      CALL GVSSTX (LOCLIN,GRPTITLE)



      IF (NUMPIN.EQ.0.AND.WIFPAR(48).NE.0) THEN
         CALL GVSTT6 ('?GRPB14')
         GOTO 998
      END IF
   10 CONTINUE
      IF (NUMPIN.NE.0.AND.WIFPAR(48).NE.0) THEN
         INMGRP=WIFPAR(48)
      ELSE
         CALL ASKGROUP (INMGRP,'?ASKGRP1')
         IF (INMGRP.EQ.0) GOTO 998
      END IF



      IF (GRPACT(INMGRP)) THEN
         IF (NUMPIN.NE.0.AND.WIFPAR(48).NE.0) THEN
            CALL GRPSHOW
            CALL GVSTTB ('?GRPB24')
         ELSE
            CALL GRPSHOW
            CALL GVSTT6 ('?GRPB12')
            IF (.NOT.GVFYON('?WALB14',' ')) GOTO 10
         END IF
      END IF



      CALL GVSSTX (GRPHOW(INMGRP),LOCLIN)



      IF (IGRUSE.EQ.1) CALL GRPSAVE (INMGRP,GRPNTR,NUMPIN)
      IF (IGRUSE.EQ.2) CALL GRPSAVE (INMGRP,GRPNT2,NUMPIN)
      IF (IGRUSE.EQ.3) CALL GRPSAVE (INMGRP,GRPNT3,NUMPIN)



      CALL GVSSTX (GRPTITLE,LOCLIN)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFOR (NUM1,NUM2,NUM3)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'MAPINC.INC'
      INTEGER       NUM1, NUM2, NUM3, I1, I2, I1V, I2V,
     +              I1LOOP, I2LOOP
      INTEGER       GRPNT3(2,MAXSP)
      EQUIVALENCE   (GRPNT3(1,1),ALLGRD(1))







      I1=1
      I2=1
      NUM3=0
      I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
      I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)



      IF (NUM1.EQ.0.AND.NUM2.EQ.0) THEN
         CALL GVSTTE ('?GRPB15')
         GOTO 998
      END IF



      IF (NUM1.EQ.0.AND.NUM2.NE.0) THEN
         CALL WIFT23 (NUM2,NUM3)
         GOTO 998
      END IF



      IF (NUM2.EQ.0.AND.NUM1.NE.0) THEN
         CALL WIFT13 (NUM1,NUM3)
         GOTO 998
      END IF



 10   CONTINUE
      IF (I1.LE.NUM1.AND.I2.LE.NUM2) THEN
         IF (I1V.EQ.I2V) THEN
            IF (NUM3.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFOR')
               GOTO 998
            END IF
            NUM3=NUM3+1
            GRPNT3(1,NUM3)=GRPNTR(1,I1)
            GRPNT3(2,NUM3)=GRPNTR(2,I1)
            I1=I1+1
            I2=I2+1
            I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
            I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
         ELSE IF (I1V.LT.I2V) THEN
            IF (NUM3.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFOR')
               GOTO 998
            END IF
            NUM3=NUM3+1
            GRPNT3(1,NUM3)=GRPNTR(1,I1)
            GRPNT3(2,NUM3)=GRPNTR(2,I1)
            I1=I1+1
            I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
         ELSE IF (I2V.LT.I1V) THEN
            IF (NUM3.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFOR')
               GOTO 998
            END IF
            NUM3=NUM3+1
            GRPNT3(1,NUM3)=GRPNT2(1,I2)
            GRPNT3(2,NUM3)=GRPNT2(2,I2)
            I2=I2+1
            I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
         END IF
         GOTO 10
      ELSE IF (I1.GT.NUM1.AND.I2.LE.NUM2) THEN



         DO 20 I2LOOP=I2,NUM2
            IF (NUM3.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFOR')
               GOTO 998
            END IF
            NUM3=NUM3+1
            GRPNT3(1,NUM3)=GRPNT2(1,I2LOOP)
            GRPNT3(2,NUM3)=GRPNT2(2,I2LOOP)
   20    CONTINUE
      ELSE IF (I2.GT.NUM2.AND.I1.LE.NUM1) THEN



         DO 30 I1LOOP=I1,NUM1
            IF (NUM3.GE.MAXSP) THEN
               CALL OVRFLO ('MAXSP',MAXSP,'WIFOR')
               GOTO 998
            END IF
            NUM3=NUM3+1
            GRPNT3(1,NUM3)=GRPNTR(1,I1LOOP)
            GRPNT3(2,NUM3)=GRPNTR(2,I1LOOP)
   30    CONTINUE
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFSAO




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'MAPINC.INC'
      LOGICAL       GVFYON
      INTEGER       IG1, IG2, IG3, IUNIT1, IUNIT2, I1,  I2, I3, IERR,
     +              I1V, I2V, NUM1, NUM2, JO, IO, I1LOOP, I2LOOP, IDUMMY
      LOGICAL       ISADG
      CHARACTER*3   OPERA
      INTEGER       GRPNT3(2,MAXSP)
      EQUIVALENCE   (GRPNT3(1,1),ALLGRD(1))







      ISADG=.FALSE.



      CALL GVSNL6 (2)
      CALL GVSTT6 ('?GRPAOH')



   10 CONTINUE
      CALL ASKGROUP (IG1,'?ASKGRP3')
      IF (IG1.EQ.0) GOTO 998



      IF (.NOT.GRPACT(IG1)) THEN
         CALL GVSTTE ('?GRPB11')
         CALL GRPSHOW
         GOTO 10
      END IF



   20 CONTINUE
      CALL ASKGROUP (IG2,'?ASKGRP4')
      IF (IG2.EQ.0) GOTO 998



      IF (.NOT.GRPACT(IG2)) THEN
         CALL GVSTTE ('?GRPB11')
         CALL GRPSHOW
         GOTO 20
      END IF
      IF (IG1.EQ.IG2) THEN
         CALL GVSTTE ('?M0894')
         GOTO 20
      END IF



      IF (GRPHOW(IG1)(1:2).EQ.'DG'.AND.GRPHOW(IG2)(1:2).EQ.'DG') THEN
         CALL GVSTTE ('?GRPB16')
         GOTO 998
      END IF
      IF (GRPHOW(IG1)(1:2).EQ.'DG'.OR.GRPHOW(IG2)(1:2).EQ.'DG') THEN
         ISADG=.TRUE.
      END IF



   11 CONTINUE
      CALL ASKGROUPF (IG3,'?ASKGRP2')
      IF (IG3.EQ.0) GOTO 998
      IF (IG3.EQ.IG1.OR.IG3.EQ.IG2) THEN
         CALL GVSTT6 ('?GRPB17')
         GOTO 11
      END IF



      IF (GRPACT(IG3)) THEN
         CALL GVSTT6 ('?GRPB12')
         CALL GRPSHOW
         IF (.NOT.GVFYON('?WALB14',' ')) GOTO 11
      END IF



      IUNIT1=40+IG1
      IUNIT2=40+IG2
      CALL GVSREW (IUNIT1)
      READ (IUNIT1) NUM1
      CALL GVSREW (IUNIT2)
      READ (IUNIT2) NUM2
      READ (IUNIT1) ((GRPNTR(IO,JO),IO=1,2),JO=1,NUM1)
      READ (IUNIT2) ((GRPNT2(IO,JO),IO=1,2),JO=1,NUM2)



   30 CONTINUE
      CALL IPROMPT ('?GRPOPR')
      CALL WIFBO1 (1,'?GRPB19')
      CALL NEEDWORD (OPERA,' ',IERR)
      IF (IERR.NE.0) GOTO 998
      CALL GVSCUC (OPERA)





      IF (OPERA.EQ.'AND') THEN
         CALL WIFAND (NUM1,NUM2,I3)



      ELSE IF (OPERA.EQ.'OR ') THEN
         IF (ISADG) THEN
            CALL GVSTTE ('?GRPB18')
            GOTO 998
         END IF
         CALL WIFOR (NUM1,NUM2,I3)



      ELSE IF (OPERA.EQ.'NOT') THEN
         IF (ISADG) THEN
            CALL GVSTTE ('?GRPB18')
            GOTO 998
         END IF
         I1=1
         I2=1
         I3=0
         I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
         I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
   60    IF (I1.LE.NUM1.AND.I2.LE.NUM2) THEN
            IF (I1V.EQ.I2V) THEN
               I1=I1+1
               I2=I2+1
               I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
               I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
            ELSE IF (I1V.LT.I2V) THEN
               I3=I3+1
               GRPNT3(1,I3)=GRPNTR(1,I1)
               GRPNT3(2,I3)=GRPNTR(2,I1)
               I1=I1+1
               I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
            ELSE IF (I2V.LT.I1V) THEN
               I3=I3+1
               GRPNT3(1,I3)=GRPNT2(1,I2)
               GRPNT3(2,I3)=GRPNT2(2,I2)
               I2=I2+1
               I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
            END IF
            GOTO 60
         ELSE IF (I1.GT.NUM1.AND.I2.LE.NUM2) THEN
            DO 62 I2LOOP=I2,NUM2
               I3=I3+1
               GRPNT3(1,I3)=GRPNT2(1,I2LOOP)
               GRPNT3(2,I3)=GRPNT2(2,I2LOOP)
   62       CONTINUE
         ELSE IF (I2.GT.NUM2.AND.I1.LE.NUM1) THEN
            DO 64 I1LOOP=I1,NUM1
               I3=I3+1
               GRPNT3(1,I3)=GRPNTR(1,I1LOOP)
               GRPNT3(2,I3)=GRPNTR(2,I1LOOP)
   64       CONTINUE
         END IF



      ELSE IF (OPERA.EQ.'XOR') THEN
         IF (ISADG) THEN
            CALL GVSTTE ('?GRPB18')
            GOTO 998
         END IF
         I1=1
         I2=1
         I3=0
         I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
         I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
   70    IF (I1.LE.NUM1.AND.I2.LE.NUM2) THEN
            IF (I1V.EQ.I2V) THEN
               I1=I1+1
               I2=I2+1
               I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
               I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
            ELSE IF (I1V.LT.I2V) THEN
               I3=I3+1
               GRPNT3(1,I3)=GRPNTR(1,I1)
               GRPNT3(2,I3)=GRPNTR(2,I1)
               I1=I1+1
               I1V=10000*GRPNTR(1,I1)+GRPNTR(2,I1)
            ELSE IF (I2V.LT.I1V) THEN
               I2=I2+1
               I2V=10000*GRPNT2(1,I2)+GRPNT2(2,I2)
            END IF
            GOTO 70
         ELSE IF (I2.GT.NUM2.AND.I1.LE.NUM1) THEN
            DO 74 I1LOOP=I1,NUM1
               I3=I3+1
               GRPNT3(1,I3)=GRPNTR(1,I1LOOP)
               GRPNT3(2,I3)=GRPNTR(2,I1LOOP)
   74       CONTINUE
         END IF



      ELSE
         GOTO 30
      END IF




      IF (ISADG) THEN
         CALL WIFT31 (I3,IDUMMY)
         WIFPAR(54)=I3
      END IF



      CALL GRPSAVE (IG3,GRPNT3,I3)
      CALL GVSCTB (GRPHOW(IG3),80)
      IF (ISADG) THEN
         CALL GVSFMT ('?FMT660')
         WRITE (GRPHOW(IG3),FMT,ERR=999) OPERA,IG1,IG2
      ELSE
         CALL GVSFMT ('?FMT659')
         WRITE (GRPHOW(IG3),FMT,ERR=999) OPERA,IG1,IG2
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('WIFSAO')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFSELS

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       IG1, IG2, IUNIT1, INEW, IOLD, IO, JO, NUM1
      LOGICAL       GVFYON, NOGROUPS







      CALL GRPFREENB
      IF (NOGROUPS()) THEN
         CALL GVSTTE ('?GRPB10')
         GOTO 998
      END IF



   10 CONTINUE
      CALL ASKGROUP (IG1,'?ASKGRP1')
      IF (IG1.EQ.0) GOTO 998



      IF (.NOT.GRPACT(IG1)) THEN
         CALL GVSTTE ('?GRPB11')
         CALL GRPSHOW
         GOTO 10
      END IF



   11 CONTINUE
      CALL ASKGROUPF (IG2,'?ASKGRP2')
      IF (IG2.EQ.0) GOTO 998



      IF (GRPACT(IG2)) THEN
         CALL GRPSHOW
         CALL GVSTT6 ('?GRPB12')
         CALL GVSSTX (TPTXLN,'?WALB14')
         IF (.NOT.GVFYON(TPTXLN,' ')) GOTO 11
         CALL GVSCTB (TPTXLN,LENTPT)
      END IF



      IUNIT1=40+IG1
      CALL GVSREW (IUNIT1)
      READ (IUNIT1) NUM1
      READ (IUNIT1) ((GRPNTR(IO,JO),IO=1,2),JO=1,NUM1)



      INEW=0
      IOLD=1
      DO 100 IOLD=1,NUM1
         IF (WIFFAC(GRPNTR(1,IOLD)).GE.2) THEN
            INEW=INEW+1
            GRPNT2(1,INEW)=GRPNTR(1,IOLD)
            GRPNT2(2,INEW)=GRPNTR(2,IOLD)
         END IF
  100 CONTINUE



      IF (INEW.LT.WIFPAR(18)) THEN



         INEW=0
         IOLD=1
         DO 110 IOLD=1,NUM1
            IF (WIFFAC(GRPNTR(1,IOLD)).GE.1) THEN
               INEW=INEW+1
               GRPNT2(1,INEW)=GRPNTR(1,IOLD)
               GRPNT2(2,INEW)=GRPNTR(2,IOLD)
            END IF
  110    CONTINUE
      END IF



      CALL GRPSAVE (IG2,GRPNT2,INEW)
      CALL GVSCCC (GRPHOW(IG2),'SELECT-',GRPHOW(IG1))



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIFSGP (IGROUP)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GRPINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'DGLOOP.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       HITS(2), IGROUP, IUNIT, IO, JO, NUMPIN, ISEQ, 
     +              IHIT, J, IAAS, IAAE, IGRP, I, ISHOW
      LOGICAL       GVFFOP, GVFIBN







      IF (IGROUP.EQ.0) THEN
         CALL ASKGROUP (IGRP,'?ASKGRP5')
         IF (IGRP.EQ.0) GOTO 997
      ELSE
         IGRP=IGROUP
      END IF



      IF (.NOT.GRPACT(IGRP)) THEN
         CALL GVSTTE ('?NEWE123')
         CALL GRPFREENB
         CALL GRPSHOW
         GOTO 997
      END IF



      IUNIT=40+IGRP
      CALL GVSREW (IUNIT)
      READ (IUNIT) NUMPIN
      IF (NUMPIN.LT.1) THEN
         CALL GVSTTE ('?GRPB11')
         CALL GRPFREENB
         CALL GRPSHOW
         GOTO 997
      END IF



      IUNIT=40+IGRP
      IF (.NOT.GVFFOP(IUNIT)) THEN
         CALL GVSTTB ('?GRPB20')
         GOTO 997
      END IF
      CALL GVSREW (IUNIT)
      READ (IUNIT) NUMPIN
      IF (NUMPIN.LE.0) THEN
         CALL GVSTTE ('?GRPB21')
         GOTO 997
      END IF
      READ (IUNIT,ERR=999,END=999) ((GRPNTR(IO,JO),IO=1,2),JO=1,NUMPIN)



      IF (GRPHOW(IGRP)(1:2).EQ.'DG') THEN



         DO 10 J=1,MIN(NUMPIN,WIFPAR(55))
            IHIT=J
            IF (.NOT.GVFIBN(IHIT,1,WIFPAR(54))) THEN
               CALL GVSTT6 ('?M2661')
               CALL GVSTTI2 ('?M2662',WIFPAR(54),WIFPAR(55))
               CALL GVSTTI2 ('?M2663',J,IHIT)
               CALL GVSKIL
               GOTO 10
            END IF
            ISEQ=GRPNTR(1,IHIT)
            IAAS=GRPNTR(2,IHIT)
            IAAE=IAAS+WIFPAR(51)-1
            IAAE=MIN(IAAE,IAAS+12)



            CALL GVSNL6 (1)
            CALL GVSFMT ('?FMT661')
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=998) J,NAMFIL(ISEQ),QFCSTR(IHIT,IGRP)
            CALL GVSTT6 (LINE)



            CALL GVSFMT ('?FMT667')
            CALL GVSCTB (LINE250,250)
            WRITE (LINE250,FMT,ERR=998) IAAS,IAAE,
     +       (AANAME(ALLSEQ(I,ISEQ)),I=IAAS,IAAE)
            CALL GVSTT6 (LINE250)



            CALL GVSFMT ('?FMT668')
            CALL GVSCTB (LINE250,250)
            WRITE (LINE250,FMT,ERR=998) (ALLHST(I,ISEQ),I=IAAS,IAAE)
            CALL GVSTT6 (LINE250)
   10    CONTINUE
      ELSE



         CALL GVSTT6 ('?M2221')
         CALL GVSTT6 (GRPHOW(IGRP))
         CALL GVSTTI ('?M2222',NUMPIN)



         CALL WIFG2N ('?GRPHSEE',HITS(1),HITS(2),NUMPIN)
         IF (HITS(1).EQ.0) GOTO 997
         IF (HITS(1).GT.NUMPIN) GOTO 997
         HITS(2)=MIN(HITS(2),NUMPIN)



         DO 30 ISHOW=HITS(1),HITS(2)
            ISEQ=GRPNTR(1,ISHOW)
            IAAS=GRPNTR(2,ISHOW)
            IAAE=IAAS+WIFPAR(51)-1
            IF (ISEQ.LE.0.OR.IAAS.LE.0.OR.IAAE.LE.0) THEN
               CALL GVSNL6 (2)
               CALL SHOWTEXT ('?M0068')
               CALL GVSNL6 (2)
               GOTO 30
            END IF



            CALL GVSNL6 (1)
            CALL GVSFMT ('?FMT666')
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=999) ISHOW,NAMFIL(ISEQ)
            CALL GVSTT6 (LINE)



            CALL GVSFMT ('?FMT667')
            CALL GVSCTB (LINE250,250)
            WRITE (LINE250,FMT,ERR=999) IAAS,IAAE,
     +       (AANAME(ALLSEQ(I,ISEQ)),I=IAAS,IAAE)
            CALL GVSTT6 (LINE250)



            CALL GVSFMT ('?FMT668')
            CALL GVSCTB (LINE250,250)
            WRITE (LINE250,FMT,ERR=999) (ALLHST(I,ISEQ),I=IAAS,IAAE)
            CALL GVSTT6 (LINE250)
   30    CONTINUE
      END IF
      GOTO 997



  999 CALL GVSTTB ('?GRPB22')
      GOTO 997



  998 CONTINUE
      CALL GVSEIW ('WIFSGP')



  997 CONTINUE


      RETURN
      END
      SUBROUTINE ASKGROUP (IGRP,INTEXT)

















      IMPLICIT      NONE
      INTEGER       IGRP
      LOGICAL       GVFIBN
      CHARACTER*(*) INTEXT
      CHARACTER*80  TEXT







      CALL GVSSTX (TEXT,INTEXT(1:MIN(80,LEN(INTEXT))))



   10 CONTINUE
      CALL GVSNL6 (1)
      IGRP=0



      CALL IPROMPT (TEXT)
      CALL WIFBO1 (4,' ')
      CALL GVSFFI (1,IGRP)
      IF (IGRP.EQ.0) GOTO 998



      IF (.NOT.GVFIBN(IGRP,1,10)) THEN
         CALL GVSTTE ('?GRPB09')
         CALL GRPSHOW
         GOTO 10
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ASKGROUPF (IGRP,INTEXT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INTEGER       IGRP, I, GVFFFI
      LOGICAL       GVFIBN
      CHARACTER*(*) INTEXT
      CHARACTER*80  TEXT







      CALL GRPFREENB
      IF (NXTGRP.EQ.0) THEN
         CALL SHOWTEXT ('?M2843')
         CALL GRPSHOW
      END IF



      CALL GVSSTX (TEXT,INTEXT(1:MIN(80,LEN(INTEXT))))
      CALL GVSFMT ('?FMT119A')
      WRITE (TEXT(77:80),FMT,ERR=999) NXTGRP
      CALL GVSRDB (TEXT)



   10 CONTINUE
      CALL GVSNL6 (1)
      IGRP=0



      CALL IPROMPT (TEXT)
      I=GVFFFI(1,IGRP)
      IF (I.EQ.0) THEN
         IF (GVFIBN(NXTGRP,1,10)) THEN
            IGRP=NXTGRP
            GOTO 998
         ELSE
            CALL SHOWTEXT ('?M2843')
            CALL GRPSHOW
            GOTO 10
         END IF
      ELSE
         IF (IGRP.EQ.0) GOTO 998
      END IF



      IF (.NOT.GVFIBN(IGRP,1,10)) THEN
         CALL GVSTTE ('?GRPB09')
         CALL GRPSHOW
         GOTO 10
      END IF
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('ASKGROUPF')



  998 CONTINUE


      RETURN
      END
      LOGICAL FUNCTION NOGROUPS()

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GRPINC.INC'
      INTEGER       IGRP







      NOGROUPS=.TRUE.



      DO 10 IGRP=1,10
         IF (GRPACT(IGRP)) THEN
            NOGROUPS=.FALSE.
            GOTO 998
         END IF
   10 CONTINUE



  998 CONTINUE


      RETURN
      END   
