



      SUBROUTINE WIF003


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR, IAA
      LOGICAL       PATTERN(NUMUA,3)


      RETURN
      END   
      SUBROUTINE WIF014

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IERR

      RETURN
      END   
      SUBROUTINE WIF018 (JFT1,JFT2,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IFT1, IFT2, JFT1, JFT2, IERR, IAA, IAT, IUSED
      LOGICAL       GVFIBN







      IF ((.NOT.GVFIBN(JFT1,0,NUMAAT)).OR.
     +    (.NOT.GVFIBN(JFT2,0,NUMAAT))) THEN
         CALL GVSTTI2 ('?M0906',JFT1,JFT2)
         IERR=1
         GOTO 998
      END IF



      IERR=0



      CALL SETIFT (IFT1,IFT2,JFT1,JFT2)
      IF (IFT1.EQ.0) GOTO 998



      DO 20 IAA=IFT1,IFT2
         PRPVAL(IAA)=0.0
         IUSED=0
         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.ISATOK(IAT)) GOTO 10
            IUSED=IUSED+1
            PRPVAL(IAA)=PRPVAL(IAA)+ATTVAL(IAT)
   10    CONTINUE
         IF (IUSED.GT.1) PRPVAL(IAA)=PRPVAL(IAA)/FLOAT(IUSED)
   20 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE WIF022 (IFT1,IFT2,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IFT1, IFT2, IERR, IAA, IAT
      LOGICAL       WIFIRI







      IF ((.NOT.WIFIRI(IFT1)).OR.(.NOT.WIFIRI(IFT2)).OR.
     +    IFT2.LT.IFT1) THEN
         CALL GVSTTI2 ('?M1552',IFT1,IFT2)
         IERR=1
         GOTO 998
      END IF



      IERR=0



      DO 20 IAA=IFT1,IFT2
         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ABS(ATTVAL(IAT)).GT.0.00001) THEN
               CALL SHOIAA (IAA)
               GOTO 20
            END IF
   10    CONTINUE
   20 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE WIF032


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      LOGICAL       WASIR6, GVFYON
      INTEGER       IAT, IAA, IERR, NUMUSE, ELMZ
      REAL          XMAS, YMAS, ZMAS, TMAS, XMIN, YMIN, ZMIN, XMAX, 
     +              YMAX, ZMAX, GVFLNV, ELMASS, LMASS







      IF (NUMATF.LT.1) THEN
         CALL GVSTTE ('?SOULOW')
         GOTO 998
      END IF
      IF (IRSTAT(6).EQ.1) THEN
         WASIR6=.TRUE.
         CALL GRTKON
      ELSE
         WASIR6=.FALSE.
      END IF



      XMAS=0.0
      YMAS=0.0
      ZMAS=0.0
      TMAS=0.0
      NUMUSE=0
      XMIN=100000.0
      YMIN=100000.0
      ZMIN=100000.0
      XMAX=-XMIN
      YMAX=-YMIN
      ZMAX=-ZMIN



      CALL WIFWTF (' ',IERR)
      IF (IERR.NE.0) GOTO 100
      CALL WRK1TFCOMPLETE



      DO 20 IAA=1,NUMAAT
         IF (WRK1TF(IAA)) THEN
            DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.ISATOK(IAT)) GOTO 10
               IF (ELMZ(IAT).EQ.0) THEN
                  CALL GVST6C ('?MATUNK',ONESAT(IAT),.TRUE.)
               ELSE
                  NUMUSE=NUMUSE+1
                  XMIN=MIN(XCOORD(IAT),XMIN)
                  YMIN=MIN(YCOORD(IAT),YMIN)
                  ZMIN=MIN(ZCOORD(IAT),ZMIN)
                  XMAX=MAX(XCOORD(IAT),XMAX)
                  YMAX=MAX(YCOORD(IAT),YMAX)
                  ZMAX=MAX(ZCOORD(IAT),ZMAX)
                  LMASS=ELMASS(IAT)
                  TMAS=TMAS+LMASS
                  XMAS=XMAS+LMASS*XCOORD(IAT)
                  YMAS=YMAS+LMASS*YCOORD(IAT)
                  ZMAS=ZMAS+LMASS*ZCOORD(IAT)
               END IF
   10       CONTINUE
         END IF
   20 CONTINUE



      XMAS=XMAS/TMAS
      YMAS=YMAS/TMAS
      ZMAS=ZMAS/TMAS



      CALL GVSTT6 ('?EXTCNM')
      CALL GVSTTR2 ('?XMINMAX',XMIN,XMAX)
      CALL GVSTTR2 ('?YMINMAX',YMIN,YMAX)
      CALL GVSTTR2 ('?ZMINMAX',ZMIN,ZMAX)
      CALL GVSTTR ('?XCENMAS',XMAS)
      CALL GVSTTR ('?YCENMAS',YMAS)
      CALL GVSTTR ('?ZCENMAS',ZMAS)



      CALL GVSNL6 (1)
      IF (GVFYON('?CENRNG',' ')) THEN
         CALL GVSBTF (USEAT,NUMATF)
         DO 40 IAA=1,NUMAAT
            IF (WRK1TF(IAA)) THEN
               DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)
                  IF (ISATOK(IAT)) THEN
                      XCOORD(IAT)=XCOORD(IAT)-XMAS
                      YCOORD(IAT)=YCOORD(IAT)-YMAS
                      ZCOORD(IAT)=ZCOORD(IAT)-ZMAS
                   END IF
   30          CONTINUE
            END IF
   40    CONTINUE
         CALL MOL200
         IF (GVFLNV(XYZ).GT.0.001.AND.WIFPAR(1105).EQ.0) 
     +    CALL SHOWTEXT ('?M0140')




            IF (USE300) THEN
               CALL GVSRT0 (ACONVC,3)
               CALL GRTCEN (IERR)
            END IF

      END IF



      CALL SETHIS ('?SOUCEN')



  100 CONTINUE
      IF (WASIR6) CALL GRTKOF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF034

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, IFT1, IFT2, ICNT(21)
      REAL          MASS
      LOGICAL       GVFIBN
      EQUIVALENCE   (ICNT(1),ESPACE(10001))







      CALL GVSIT0 (ICNT,21)
      MASS=0.0



      CALL WIFGRN (IFT1,IFT2,' ')
      IF (IFT1.EQ.0) GOTO 998



      DO 10 IAA=IFT1,IFT2
         IF (GVFIBN(RESTYP(IAA),1,20)) THEN
            ICNT(RESTYP(IAA))=ICNT(RESTYP(IAA))+1
         ELSE
            ICNT(21)=ICNT(21)+1
         END IF
   10 CONTINUE



      CALL GVSNL6 (1)
      CALL GVSTT6 ('?M2338')
      DO 20 IAA=1,20
         CALL GVSTTI (AANAME(IAA),ICNT(IAA))
   20 CONTINUE
      CALL GVSTTI ('?M2007',ICNT(21))



      CALL GVSNL6 (1)
      CALL GVSTTI ('?M2006',ICNT(9)+ICNT(15)-ICNT(3)-ICNT(4))
      CALL GVSTTI ('?M2005',ICNT(7))
      CALL GVSTT6 ('?M2004')



      MASS=MASS+71.08*ICNT(1)
      MASS=MASS+103.14*ICNT(2)
      MASS=MASS+115.09*ICNT(3)
      MASS=MASS+129.12*ICNT(4)
      MASS=MASS+147.18*ICNT(5)
      MASS=MASS+57.06*ICNT(6)
      MASS=MASS+137.15*ICNT(7)
      MASS=MASS+113.17*ICNT(8)
      MASS=MASS+128.18*ICNT(9)
      MASS=MASS+113.17*ICNT(10)
      MASS=MASS+131.21*ICNT(11)
      MASS=MASS+114.11*ICNT(12)
      MASS=MASS+97.12*ICNT(13)
      MASS=MASS+128.14*ICNT(14)
      MASS=MASS+156.20*ICNT(15)
      MASS=MASS+87.08*ICNT(16)
      MASS=MASS+101.11*ICNT(17)
      MASS=MASS+99.14*ICNT(18)
      MASS=MASS+186.21*ICNT(19)
      MASS=MASS+163.18*ICNT(20) 
      CALL GVSNL6 (1)
      CALL GVSTTR ('?M2337',MASS/1000.0)
      CALL GVSNL6 (1)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE WIF049

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'ANATRA.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IWRONG(MAXAA), IOK, INOTOK, IAA, IAT, I, IATBAD
      LOGICAL       WIFIRA
      EQUIVALENCE   (IWRONG(1),ESPACE(20001))







      CALL ESPSET (20001,20000+MAXAA,27)



      IOK=0
      INOTOK=0
      IATBAD=0
      CALL GVSIT0 (IWRONG,MAXAA)
      CALL MOL200



      DO 30 IAA=1,NUMAAF



         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.PROTON(IAT)) THEN
               IF (.NOT.ISATOK(IAT)) THEN
                  IATBAD=IATBAD+1
               END IF
            END IF
   10    CONTINUE



         DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.PROTON(IAT)) THEN
               IF (.NOT.ISATOK(IAT)) THEN
                  INOTOK=INOTOK+1
                  IWRONG(INOTOK)=IAA
                  CALL SHOIAA (IAA)
                  IF (DATLOG.GT.0) CALL SHOUAA (DATLOG,IAA)
                  GOTO 30
               END IF
            END IF
   20    CONTINUE
         IOK=IOK+1
   30 CONTINUE




      CALL GVSTTI ('?NMBAAE',NUMAAF)
      CALL GVSTTI ('?NMBAAC',IOK)
      CALL GVSTTI ('?NMBAAB',INOTOK)
      CALL GVSTTI ('?NMBATB',IATBAD)
      IF (DATLOG.GT.0) THEN
         CALL GVSTTIU (DATLOG,'?NMBAAE',NUMAAF)
         CALL GVSTTIU (DATLOG,'?NMBAAC',IOK)
         CALL GVSTTIU (DATLOG,'?NMBAAB',INOTOK)
         CALL GVSTTIU (DATLOG,'?NMBATB',IATBAD)
      END IF



      IF (INOTOK.GT.0) THEN
         CALL GVSTT6 ('?NMBAAL')
         CALL GVSFMT ('?FMT519')
         DO 40 IAA=1,INOTOK,16
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=999)(IWRONG(I),I=IAA,MIN(INOTOK,IAA+15))
            CALL GVSTT6 (LINE)
            IF (DATLOG.NE.0) CALL GVSTTU (DATLOG,LINE)
   40    CONTINUE
      END IF



      INOTOK=0
      CALL GVSIT0 (IWRONG,MAXAA)
      CALL MOL200



      DO 80 IAA=1,NUMAAF
         IF (.NOT.WIFIRA(IAA)) GOTO 80



         DO 60 IAT=PNTAAS(IAA),PNTAAS(IAA)+3
            IF (.NOT.PROTON(IAT)) THEN
               IF (.NOT.ISATOK(IAT)) THEN
                  INOTOK=INOTOK+1
                  IWRONG(INOTOK)=IAA
                  GOTO 80
               END IF
            END IF
   60    CONTINUE
   80 CONTINUE



      IF (INOTOK.GT.0) THEN
         CALL GVSTT6 ('?NMBAABB')
         CALL GVSFMT ('?FMT519')
         DO 90 IAA=1,INOTOK,16
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=999)(IWRONG(I),I=IAA,MIN(INOTOK,IAA+15))
            CALL GVSTT6 (LINE)
            IF (DATLOG.NE.0) CALL GVSTTU (DATLOG,LINE)
   90    CONTINUE
      END IF



      CALL ESPKIL (20001,20000+MAXAA,27,'WIF049')



  999 CONTINUE





      RETURN
      END
      SUBROUTINE WIF053

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ABAD, HBAD, BOTHBAD, BOTHOK, IAA, IAT
      LOGICAL       LABAD, LHBAD, LISTALL, GVFYON, GVFIBN







      IF (WIFPAR(84).EQ.0) THEN
         CALL SHOWTEXT ('?M2433')
      END IF



      ABAD=0
      HBAD=0
      BOTHBAD=0
      BOTHOK=0
      LISTALL=.FALSE.










      DO 20 IAA=1,NUMAAT
         LABAD=.FALSE.
         LHBAD=.FALSE.



         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.ISATOK(IAT)) THEN
               IF (PROTON(IAT)) THEN
                  LHBAD=.TRUE.
               ELSE
                  LABAD=.TRUE.
               END IF
            END IF
 10      CONTINUE



         IF (LABAD) THEN
            IF (LHBAD) THEN
               BOTHBAD=BOTHBAD+1
            ELSE
               ABAD=ABAD+1
            END IF
         ELSE
            IF (LHBAD) THEN
               HBAD=HBAD+1
            ELSE
               BOTHOK=BOTHOK+1
            END IF
         END IF
 20   CONTINUE



      IF (NUMAAT.EQ.BOTHOK) THEN
         CALL SHOWTEXT ('?M2439')
         GOTO 998
      ELSE IF (GVFIBN(NUMAAT-BOTHOK,1,NUMAAT/20)) THEN
         CALL SHOWTEXT ('?M2434')
         DO 40 IAA=1,NUMAAT
            DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.ISATOK(IAT)) THEN
                  CALL SHOIAA (IAA)
                  GOTO 40
               END IF
 30         CONTINUE
 40      CONTINUE
         GOTO 998
      END IF



      IF (ABAD.LE.0) THEN
         CALL SHOWTEXT ('?M2435')
         CALL GVSTTI ('?M2438',HBAD)
         IF (GVFYON('?M2437',' ')) LISTALL=.TRUE.
      ELSE IF (HBAD/ABAD.GT.5) THEN
         CALL SHOWTEXT ('?M2436')
         CALL GVSTTI ('?M2438',HBAD)
         IF (GVFYON('?M2437',' ')) LISTALL=.TRUE.
      ELSE
         CALL GVSTTI ('?M2438',HBAD)
         IF (GVFYON('?M2437',' ')) LISTALL=.TRUE.
      END IF



      IF (LISTALL) THEN
         DO 60 IAA=1,NUMAAT
            DO 50 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.ISATOK(IAT)) THEN
                  CALL SHOIAA (IAA)
                  GOTO 60
               END IF
 50         CONTINUE
 60      CONTINUE
      END IF



  998 CONTINUE
      CALL MOL200


      RETURN
      END   
      CHARACTER*2 FUNCTION WIF054(IAA)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT







      



      WIF054='  '



      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (WEIGHT(IAT).LT.0.5) THEN
            WIF054='O '
            GOTO 11
         END IF
 10   CONTINUE
 11   CONTINUE



      DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (XBFACT(IAT).GT.80.0) THEN
            IF (WIF054.EQ.'  ') THEN
               WIF054='B '
            ELSE
               WIF054='OB'
            END IF
            GOTO 998
         END IF
 20   CONTINUE



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION WIF069(XIN,YIN,ZIN)

























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IATX, IATY, IATZ
      REAL          XIN, YIN, ZIN







      WIF069=.FALSE.



      DO 10 IATX=1,NUMATF
         IF (ABS(XIN-XCOORD(IATX)).LT.0.0001) THEN



            DO 20 IATY=1,NUMATF
               IF (ABS(YIN-YCOORD(IATY)).LT.0.0001) THEN



                  DO 30 IATZ=1,NUMATF
                     IF (ABS(ZIN-ZCOORD(IATZ)).LT.0.0001) THEN
                        WIF069=.TRUE.
                        GOTO 998
                     END IF
   30             CONTINUE
               END IF
   20       CONTINUE
         END IF
   10 CONTINUE



  998 CONTINUE


      RETURN
      END
      INTEGER FUNCTION WIF072()



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IMENU







      WIF072=1
      DO 10 IMENU=1,99
         IF (MENULV(IMENU).EQ.'        ') THEN
            WIF072=IMENU
            GOTO 998
         END IF
   10 CONTINUE
      CALL GVSKIL



      CALL SHOWTEXT ('?MENBAD')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF089

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       I, IFT1, IFT2, IAA, INEW, GVFFFI, JAT, JAA, 
     +              IBND, IAT, INUM
      LOGICAL       GVFIBN, WIFIRO, WIFIRH, FIRST







      IF (NUMAAF.LE.0) THEN
         CALL GVSTTE ('?SOULOW')
         GOTO 998
      END IF



      CALL GVSBTF (WRK1TF,MAXAA)
      FIRST=.TRUE.



      IF (WIFPAR(1105).EQ.0) THEN
         CALL WIFGRN (IFT1,IFT2,'?RENRNG')
         IF (IFT1.EQ.0) GOTO 998
      ELSE
         IFT1=1
         IFT2=NUMAAT
      END IF



   10 CONTINUE
      IF (WIFPAR(1105).EQ.0) THEN
         CALL I1PROMPT ('?NEWNAA',IFT1)
         I=GVFFFI(1,INEW)
         IF (I.EQ.1.AND.INEW.EQ.0) GOTO 998
         IF (I.EQ.0) INEW=1
      ELSE
         INEW=1
      END IF



      IF (.NOT.GVFIBN(INEW,-999,(9999+IFT1-IFT2))) THEN
         CALL GVSTT6 ('?RNGSBE')
         CALL GVSTTI ('?RNG999',9999+IFT1-IFT2)
         GOTO 10
      END IF



      DO 50 IAA=IFT1,IFT2
         IF (.NOT.WRK1TF(IAA)) THEN
            INUM=INEW+IAA-IFT1
            WRK1TF(IAA)=.TRUE.
            IF (IAA.GT.9999.OR.INUM.GT.9999) THEN
               IF (FIRST) THEN
                  FIRST=.FALSE.
                  CALL GVSBOX ('?M4016')
               END IF
            END IF
            CALL WIF089S (IAA,INUM)



            DO 40 IAT=PNTAAS(IAA),PNTAAE(IAA)
               DO 30 IBND=1,8
                  JAT=BOUND_TO(IBND,IAT)
                  IF (JAT.GT.0) THEN
                     JAA=ATIAA(JAT)
                     IF (.NOT.WRK1TF(JAA).AND.(WIFIRH(JAA).OR.
     +                    WIFIRO(JAA))) THEN
                        WRK1TF(JAA)=.TRUE.
                        IF (JAA.GT.9999.OR.INUM.GT.9999) THEN
                           IF (FIRST) THEN
                              FIRST=.FALSE.
                              CALL GVSBOX ('?M4016')
                           END IF
                        END IF
                        CALL WIF089S (JAA,INUM)
                     END IF
                  END IF
 30            CONTINUE
 40         CONTINUE
         END IF
 50   CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF089A (IFT1,IFT2,INEW,IERR)

















      IMPLICIT      NONE
      INTEGER       IAA, IFT1, IFT2, INEW, IERR, INUM
      LOGICAL       GVFIBN, WIFIRI, FIRST







      IF ((.NOT.WIFIRI(IFT1)).OR.(.NOT.WIFIRI(IFT2))) THEN
         CALL GVSTT6 ('?BUG89A')
         IERR=1
         GOTO 998
      END IF
      IF (.NOT.GVFIBN(INEW,-999,(9999+IFT1-IFT2))) THEN
         CALL GVSTTE ('?BUG89B')
         IERR=1
         GOTO 998
      END IF



      IERR=0
      FIRST=.TRUE.



      DO 10 IAA=IFT1,IFT2
         INUM=INEW+IAA-IFT1
         IF (IAA.GT.9999.OR.INUM.GT.9999) THEN
            IF (FIRST) THEN
               FIRST=.FALSE.
               CALL GVSBOX ('?M4016')
            END IF
         END IF
         CALL WIF089S (IAA,INUM)
   10 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF089B

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       I, IFT1, INEW, GVFFFI
      LOGICAL       GVFIBN







      IF (NUMAAF.LE.0) THEN
         CALL GVSTTE ('?SOULOW')
         GOTO 998
      END IF



      CALL WIFGRS (IFT1,'?RENRES')
      IF (IFT1.EQ.0) GOTO 998



   10 CONTINUE
      CALL I1PROMPT ('?NEWNAA',IFT1)
      I=GVFFFI(1,INEW)
      IF (I.EQ.1.AND.INEW.EQ.-1) GOTO 998
      IF (I.EQ.0) INEW=IFT1



      IF (.NOT.GVFIBN(INEW,-999,(9999+IFT1))) THEN
         CALL GVSTTI ('?RNG999',9999+IFT1)
         GOTO 10
      END IF



      IF (IFT1.GT.9999.OR.INEW.GT.9999) CALL GVSBOX ('?M4016')
      CALL WIF089S (IFT1,INEW)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF089S (IAA,INUM)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, INUM, IC
      CHARACTER*1   CHAR1







      IF (IAA.LE.9999) THEN
         CALL GVSFMT ('?FMT024')
         WRITE (NUMNAM(IAA),FMT,ERR=999) INUM
      ELSE
         IC=INUM/1000
         CHAR1=CHADEF2(IC:IC)
         CALL GVSFMT ('?FMT681C')
         WRITE (NUMNAM(IAA),FMT,ERR=999)CHAR1,MOD(INUM,1000)
      END IF
      CALL GVSSHL (NUMNAM(IAA))
      INSRTC(IAA)=' '
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('WIF089S')



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION AREBOUND(JAT1,JAT2)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT1, IAT2, JAT1, JAT2, IAA1, IAA2, IBND,
     +              IATLC1, IATLC2, ISOU, ICON, IRT
      REAL          D12, WIFDST
      LOGICAL       WIFIRA, WIFIRN, WIFIRD, WIFIRO, WIFIRNO







      AREBOUND=.FALSE.



      IF (JAT1.GT.JAT2) THEN
         IAT1=JAT2
         IAT2=JAT1
      ELSE
         IAT1=JAT1
         IAT2=JAT2
      END IF



      IAA1=ATIAA(IAT1)
      IAA2=ATIAA(IAT2)



      IF (IAA1.LT.1.OR.IAA1.GT.NUMAAT) THEN
         CALL GVSTTI3 ('?M2491A',IAA1,IAA2,NUMAAT)
         CALL MOL010 ('Oeps')
         CALL DIF016  (6,JAT1,JAT2)
         CALL SHOSOU
         CALL GVSKIL
      END IF
      IF (IAA2.LT.1.OR.IAA2.GT.NUMAAT) THEN
         CALL GVSTTI3 ('?M2491B',IAA1,IAA2,NUMAAT)
         CALL MOL010 ('Oeps')
         CALL DIF016  (6,JAT1,JAT2)
         CALL SHOSOU
         CALL GVSKIL
      END IF



      IF (MODNMB(IAA1).NE.MODNMB(IAA2)) GOTO 998



      IF (SOUPNT(IAA1).NE.SOUPNT(IAA2)) GOTO 998



      IF (WIFIRD(IAA1).AND.WIFIRD(IAA2).AND.IAA1.NE.IAA2) THEN
         IF (WEIGHT(IAT1).LE.0.50.OR.WEIGHT(IAT2).LE.0.50) GOTO 998
      END IF




      IF (CHAINN(2,IAA1).LE.0.OR.CHAINN(2,IAA2).LE.0) THEN
         CALL GVSTTI2 ('?M2492',IAA1,IAA2)
      ELSE
         IF ((SOUADM(5,CHAINN(2,IAA1)).EQ.5).OR.
     +       (SOUADM(5,CHAINN(2,IAA2)).EQ.5)) THEN
            IF ((.NOT.PROTON(IAT1)).AND.PROTON(IAT2).AND.
     +           IAA1.EQ.IAA2.AND.
     +           (IAT2.EQ.IAT1+1.OR.IAT2.EQ.IAT1+2)) THEN
               AREBOUND=.TRUE.
            ELSE
               AREBOUND=.FALSE.
            END IF
            GOTO 998
         END IF
      END IF



      IATLC1=PINIAA(IAT1)
      IATLC2=PINIAA(IAT2)



      IF (RESTYP(IAA1).GT.0.AND.RESTYP(IAA2).GT.0) THEN



         IF (IAA1.EQ.IAA2) THEN
            IRT=RESTYP(IAA1)
            DO 10 ICON=1,MAXTAT
               IF (MUTCON(1,ICON,IRT).EQ.0) GOTO 11
               IF ((MUTCON(1,ICON,IRT).EQ.IATLC1.AND.
     +              MUTCON(2,ICON,IRT).EQ.IATLC2).OR.
     +             (MUTCON(1,ICON,IRT).EQ.IATLC2.AND.
     +              MUTCON(2,ICON,IRT).EQ.IATLC1)) THEN
                  AREBOUND=.TRUE.
                  GOTO 998
               END IF
 10         CONTINUE
 11         CONTINUE



         ELSE IF (IAA1+1.EQ.IAA2) THEN
            IF (WIFIRN(IAA1)) THEN



               IF (CHAINN(2,IAA1).EQ.CHAINN(2,IAA2).AND.
     +              IATLC1.EQ.3.AND.IATLC2.EQ.1) THEN
                  AREBOUND=.TRUE.
                  GOTO 998
               END IF
            ELSE IF (WIFIRA(IAA1)) THEN



               IF (CHAINN(2,IAA1).EQ.CHAINN(2,IAA2).AND.
     +              IATLC1.EQ.3.AND.IATLC2.EQ.1) THEN
                  AREBOUND=.TRUE.
                  GOTO 998
               END IF



               IF (IATLC1.EQ.3.AND.IATLC2.EQ.1) THEN
                  IF (WIFIRO(IAA2).OR.WIFIRNO(IAA2)) THEN
                     IF (WIFDST(IAT1,IAT2).LT.2.0) THEN
                        AREBOUND=.TRUE.
                        GOTO 998
                     END IF
                  END IF
               END IF
            END IF
         END IF



         IF (RESTYP(IAA1).EQ.2.AND.RESTYP(IAA2).EQ.2.AND.
     +        IATLC1.EQ.6.AND.IATLC2.EQ.6.AND.
     +        MODNMB(IAA1).EQ.MODNMB(IAA2).AND.
     +        SOUPNT(IAA1).EQ.SOUPNT(IAA2)) THEN
            D12=(XCOORD(IAT2)-XCOORD(IAT1))**2+
     +          (YCOORD(IAT2)-YCOORD(IAT1))**2+
     +          (ZCOORD(IAT2)-ZCOORD(IAT1))**2
            IF (D12.LT.2.5**2.AND.D12.GT.1.5**2) THEN
               AREBOUND=.TRUE.
               GOTO 998
            END IF
         END IF
      ELSE



         IF (IAA1.EQ.IAA2) THEN
            ISOU=CHAINN(2,IAA1)



            IF (SOUADM(5,ISOU).EQ.4) THEN
               DO 20 IBND=1,8
                  IF (BOUND_TO(IBND,IAT1).EQ.IAT2.OR.
     +                BOUND_TO(IBND,IAT2).EQ.IAT1) THEN
                     AREBOUND=.TRUE.
                     GOTO 998
                  END IF
   20          CONTINUE
               AREBOUND=.FALSE.
               GOTO 998
            END IF
         END IF
      END IF



      IF ((BOUND_TO(1,IAT1).EQ.IAT2.OR.BOUND_TO(2,IAT1).EQ.IAT2.OR.
     +     BOUND_TO(3,IAT1).EQ.IAT2.OR.BOUND_TO(4,IAT1).EQ.IAT2.OR.
     +     BOUND_TO(5,IAT1).EQ.IAT2.OR.BOUND_TO(6,IAT1).EQ.IAT2.OR.
     +     BOUND_TO(7,IAT1).EQ.IAT2.OR.BOUND_TO(8,IAT1).EQ.IAT2).AND.
     +    (BOUND_TO(1,IAT2).EQ.IAT1.OR.BOUND_TO(2,IAT2).EQ.IAT1.OR.
     +     BOUND_TO(3,IAT2).EQ.IAT1.OR.BOUND_TO(4,IAT2).EQ.IAT1.AND.
     +     BOUND_TO(5,IAT2).EQ.IAT1.OR.BOUND_TO(6,IAT2).EQ.IAT1.AND.
     +     BOUND_TO(7,IAT2).EQ.IAT1.OR.BOUND_TO(8,IAT2).EQ.IAT1)) THEN
         AREBOUND=.TRUE.
         GOTO 998
      END IF



  998 CONTINUE


      RETURN
      END
      LOGICAL FUNCTION AREBOUNDS(IAT,JAT,ISYM)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SYMINC.INC'
      INTEGER       IAT,JAT, ISYM
      REAL          TMP(3), D12
      LOGICAL       AREBOUND, WIFITW







      IF (ISYM.GT.NUMSYM) THEN
         CALL GVSTTB ('?M0146')
         AREBOUNDS=.FALSE.
         GOTO 998
      END IF



      IF (ISYM.LE.1) THEN
         AREBOUNDS=AREBOUND(IAT,JAT)
         GOTO 998
      END IF



      IF (WIFITW(IAT).OR.WIFITW(JAT)) THEN



         AREBOUNDS=.FALSE.
      ELSE IF (ONESAT(IAT).EQ.' SG  '.AND.ONESAT(JAT).EQ.' SG  ') THEN



         TMP(1)=XCOORD(JAT)
         TMP(2)=YCOORD(JAT)
         TMP(3)=ZCOORD(JAT)
         CALL GVSMPV (TMP,SYMMAT(1,1,ISYM),SYMVEC(1,ISYM))
         D12=SQRT((TMP(1)-XCOORD(IAT))**2+
     +        (TMP(2)-YCOORD(IAT))**2+
     +        (TMP(3)-ZCOORD(IAT))**2)
         IF (D12.LT.2.5) THEN
            AREBOUNDS=.TRUE.
            GOTO 998
         END IF
         AREBOUNDS=.FALSE.
      ELSE IF (IAT.GT.PNTAAE(NUMAAF).AND.JAT.GT.PNTAAE(NUMAAF)) THEN



         TMP(1)=XCOORD(JAT)
         TMP(2)=YCOORD(JAT)
         TMP(3)=ZCOORD(JAT)
         CALL GVSMPV (TMP,SYMMAT(1,1,ISYM),SYMVEC(1,ISYM))
         D12=SQRT((TMP(1)-XCOORD(IAT))**2+
     +        (TMP(2)-YCOORD(IAT))**2+
     +        (TMP(3)-ZCOORD(IAT))**2)
         IF (D12.GT.VDWRAD(IAT)+VDWRAD(JAT)-1.3) THEN



            AREBOUNDS=.FALSE.
         ELSE IF (D12.GT.1.1.AND..NOT.(PROTON(IAT).OR.PROTON(JAT))) THEN



            AREBOUNDS=.TRUE.
         ELSE IF (D12.GT.0.85.AND.(PROTON(IAT).OR.PROTON(JAT))) THEN



            AREBOUNDS=.TRUE.
         ELSE



            AREBOUNDS=.FALSE.
         END IF
      ELSE
         AREBOUNDS=.FALSE.
      END IF



  998 CONTINUE


      RETURN
      END
      LOGICAL FUNCTION AREB13(IATIN,JATIN,ISYM)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SYMINC.INC'
      INTEGER       IAT, JAT, ISYM, SYMMUL, SYMNEG, JSYM, JATARR(12), 
     +              JATSYM(12), NUM, I, KSYM, IAA, JAA, LOCIAT, LOCJAT,
     +              IAATYP, IATIN, JATIN, ICYS
      LOGICAL       AREBOUNDS, WIFIRA, WIFIRN







      AREB13=.FALSE.
      IF (IATIN.LT.JATIN) THEN
         IAT=IATIN
         JAT=JATIN
      ELSE
         IAT=JATIN
         JAT=IATIN
      END IF
      IAA=ATIAA(IAT)
      JAA=ATIAA(JAT)



      IF (ISYM.GT.NUMSYM) THEN
         CALL GVSTTB ('?M0147')
         GOTO 998
      END IF
      IF (MODNMB(IAA).NE.MODNMB(JAA)) GOTO 998
      IF (SOUPNT(IAA).NE.SOUPNT(JAA)) GOTO 998
      IF (IAT.EQ.JAT) GOTO 998
      IF (AREBOUNDS(IAT,JAT,ISYM)) GOTO 998



      IF (ISYM.EQ.1) THEN
         LOCIAT=PINIAA(IAT)
         LOCJAT=PINIAA(JAT)
         IAATYP=RESTYP(IAA)



         IF (IAA.EQ.JAA.AND.IAATYP.GT.0) THEN
            IF (BOND13(1,LOCIAT,IAATYP).GT.1) THEN
               DO 10 I=2,BOND13(1,LOCIAT,IAATYP)
                  IF (BOND13(I,LOCIAT,IAATYP).EQ.LOCJAT) THEN
                     AREB13=.TRUE.
                     GOTO 998
                  END IF
   10          CONTINUE
            END IF
            AREB13=.FALSE.
            GOTO 998
         ELSE IF (IAA.EQ.JAA+1) THEN



            IF (PINIAA(IAT).EQ.7.AND.
     +           (RESTYP(IAA).EQ.13.OR.RESTYP(IAA).EQ.21).AND.
     +           PINIAA(JAT).EQ.3.AND.
     +           CHAINN(2,IAA).EQ.CHAINN(2,JAA)) THEN
               AREB13=.TRUE.
               GOTO 998
            END IF
         ELSE IF (JAA.EQ.IAA+1) THEN



            IF (PINIAA(JAT).EQ.7.AND.
     +           (RESTYP(JAA).EQ.13.OR.RESTYP(JAA).EQ.21).AND.
     +           PINIAA(IAT).EQ.3.AND.
     +           CHAINN(2,JAA).EQ.CHAINN(2,IAA)) THEN
               AREB13=.TRUE.
               GOTO 998
            END IF
         END IF



         IF (IAATYP.EQ.2.AND.RESTYP(JAA).EQ.2) THEN
            IF (CHAINN(2,IAA).EQ.CHAINN(2,JAA)) THEN
               IF (LOCIAT*LOCJAT.EQ.30) THEN
                  DO 30 ICYS=1,NUMCYS
                     IF (CYSCYS(1,ICYS).EQ.IAA) THEN
                        IF (CYSCYS(2,ICYS).EQ.JAA) THEN
                           AREB13=.TRUE.
                           GOTO 998
                        END IF
                     END IF
   30             CONTINUE
                  GOTO 998
               END IF
            ELSE



               IF (LOCIAT*LOCJAT.EQ.30) GOTO 80
            END IF
         END IF



         IF (WIFIRA(IAA)) THEN



            IF (IAA-JAA.EQ.1) THEN
               IF (LOCIAT.EQ.1.AND.(LOCJAT.EQ.2.OR.LOCJAT.EQ.4)) THEN
                  AREB13=.TRUE.
                  GOTO 998
               ELSE IF (LOCIAT.EQ.2.AND.(LOCJAT.EQ.3)) THEN
                  AREB13=.TRUE.
                  GOTO 998
               END IF
            ELSE IF (JAA-IAA.EQ.1) THEN
               IF (LOCJAT.EQ.1.AND.(LOCIAT.EQ.2.OR.LOCIAT.EQ.4)) THEN
                  AREB13=.TRUE.
                  GOTO 998
               ELSE IF (LOCJAT.EQ.2.AND.(LOCIAT.EQ.3)) THEN
                  AREB13=.TRUE.
                  GOTO 998
               END IF
            END IF
         ELSE IF (WIFIRN(IAA)) THEN



            IF (IAA.EQ.JAA+1) THEN
               IF (LOCIAT.EQ.6.AND.LOCJAT.EQ.3) THEN
                  AREB13=.TRUE.
                  GOTO 998
               ELSE IF (LOCIAT.EQ.1.AND.LOCJAT.EQ.2) THEN
                  AREB13=.TRUE.
                  GOTO 998
               END IF
            ELSE IF (JAA.EQ.IAA+1) THEN
               IF (LOCJAT.EQ.6.AND.LOCIAT.EQ.3) THEN
                  AREB13=.TRUE.
                  GOTO 998
               ELSE IF (LOCJAT.EQ.1.AND.LOCIAT.EQ.2) THEN
                  AREB13=.TRUE.
                  GOTO 998
               END IF
            END IF
         END IF
      END IF




   80 CONTINUE


      CALL FBONDS (IAT,JATARR,JATSYM,12,NUM)






      DO 20 I=1,NUM
         JSYM=JATSYM(I)
         KSYM=SYMMUL(ISYM,SYMNEG(JSYM))
         IF (AREBOUNDS(JATARR(I),JAT,KSYM)) THEN
            AREB13=.TRUE.
            GOTO 998
         END IF
 20   CONTINUE



  998 CONTINUE


      RETURN
      END
      LOGICAL FUNCTION AREB14(IAT,JAT,ISYM,IBETWEEN,JBETWEEN)



















      IMPLICIT      NONE
      INTEGER       IAT, JAT, ISYM, JATARR(12), JATSYM(12), INUM, 
     +              IATARR(12), IATSYM(12), JNUM, I, J,
     +              IBETWEEN, JBETWEEN
      LOGICAL       AREBOUNDS, AREB13







      AREB14=.FALSE.



      IF (ISYM.GT.1) THEN
         CALL GVSTTB ('?M1846')
         GOTO 998
      END IF
      IF (IAT.EQ.JAT) GOTO 998
      IF (AREBOUNDS(IAT,JAT,ISYM)) GOTO 998
      IF (AREB13(IAT,JAT,ISYM)) GOTO 998




      CALL FBONDS (IAT,IATARR,IATSYM,12,INUM)
      IF (INUM.LE.0) GOTO 998
      CALL FBONDS (JAT,JATARR,JATSYM,12,JNUM)
      IF (JNUM.LE.0) GOTO 998






      DO 20 I=1,INUM
         IF (IATSYM(I).NE.1) GOTO 20
         DO 10 J=1,JNUM
            IF (JATSYM(J).NE.1) GOTO 10
            IF (AREBOUNDS(IATARR(I),JATARR(J),1)) THEN
               AREB14=.TRUE.
               IBETWEEN=IATARR(I)
               JBETWEEN=JATARR(J)
               GOTO 998
            END IF
 10      CONTINUE
 20   CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF103
























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IUNIT, GVFLEN
      CHARACTER*10  SFILES(11)
      CHARACTER*10  RFILES(10)
      SAVE          SFILES, RFILES
      DATA SFILES  /'FOR040.DAT','FOR041.DAT','FOR042.DAT',
     +              'FOR043.DAT','FOR044.DAT','FOR045.DAT',
     +              'FOR046.DAT','FOR047.DAT','FOR048.DAT',
     +              'FOR049.DAT','FOR050.DAT'/
      DATA RFILES  /'FOR021.DAT','FOR022.DAT',
     +              'FOR023.DAT','FOR024.DAT','FOR025.DAT',
     +              'FOR026.DAT','FOR027.DAT','FOR028.DAT',
     +              'FOR029.DAT','FOR030.DAT'/







      DO 10 IUNIT=40,50
         CALL GVSCLF (IUNIT)
         IF (GVFLEN(FILNMS(76)).LE.0) THEN
            CALL GVSTMP (PATH,SFILES(IUNIT-39))
         ELSE
            CALL GVSCC3 (PATH,FILNMS(76),'/',SFILES(IUNIT-39))
         END IF
         OPEN (UNIT=IUNIT,FILE=PATH,FORM='UNFORMATTED',STATUS='UNKNOWN')
   10 CONTINUE



      DO 20 IUNIT=21,30
         CALL GVSCLF (IUNIT)
         IF (GVFLEN(FILNMS(76)).LE.0) THEN
            CALL GVSTMP (PATH,RFILES(IUNIT-20))
         ELSE
            CALL GVSCC3 (PATH,FILNMS(76),'/',RFILES(IUNIT-20))
         END IF
         OPEN (UNIT=IUNIT,FILE=PATH,FORM='UNFORMATTED',STATUS='UNKNOWN')
   20 CONTINUE





      RETURN
      END
      SUBROUTINE DRG106 (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DRGINC.INC'
      INTEGER       ISOUP, IAT, IERR







      IERR=0
      DDBCNT=0



      DO 20 ISOUP=1,NUMSOU
         IF (SOUADM(10,ISOUP).EQ.2) THEN
            DO 10 IAT=PNTAAS(SOUADM(1,ISOUP)),PNTAAE(SOUADM(2,ISOUP))
               DDBCNT=DDBCNT+1
               DDBBCK(9,DDBCNT)=IAT
               CALL GVSCPI (DDBBCK(1,DDBCNT),BOUND_TO(1,IAT),8)
 10         CONTINUE
         END IF
 20   CONTINUE





      RETURN
      END   
      SUBROUTINE DRG107 (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DRGINC.INC'
      INTEGER       IAT, I, IERR







      IERR=0
      IF (DDBCNT.LE.0) GOTO 998



      DO 10 I=1,DDBCNT
         IAT=DDBBCK(9,I)
         CALL GVSCPI (BOUND_TO(1,IAT),DDBBCK(1,I),8)
 10   CONTINUE



 998  CONTINUE


      RETURN
      END   
