



      SUBROUTINE MOL100







































      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ANISOU.INC'
      INCLUDE       'CHIANG.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'JUNIOR.INC'
      INCLUDE       'HSTINC.INC'
      INCLUDE       'CLUFAM.INC'
      INCLUDE       'MAKMOL.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, IAT, I, J, ICYS







      IF (NUMAAT.EQ.0) THEN
         NUMAAT=MAXAA
         NUMATF=MAXAT
      END IF



      CALL KLONKCLEAN



      WIFPAR(1504)=WIFPAR(1504)+1
      WIFPAR(1510)=0



      NUMSOU=0
      NUMAAF=0
      NUMCOF=0
      HBODON=.FALSE.
      HSTDON=.FALSE.
      WIFPAR(491)=0
      WIFPAR(846)=0
      WIFPAR(1503)=0
      WIFPAR(1510)=0



      WIFPAR(592)=0
      CALL SYMINI




      DO 2 J=1,MAXSET
         DO 1 I=1,80
            SCLCR1(J)(I:I)=' '
            SCLCR2(J)(I:I)=' '
            SCLCR3(J)(I:I)=' '
            CRYCRD(J)(I:I)=' '
            SOUNAM(J)(I:I)=' '
 1       CONTINUE
 2    CONTINUE





      CALL GVSIT0 (SOUADM,20*MAXMOL)
      CALL GVSIT0 (CHAINN,2*MAXAA)
      CALL GVSIT0 (USESOU,MAXMOL)



      IF (NUMAAT.GE.1) THEN
         DO 10 IAA=1,NUMAAT
            PNTAAS(IAA)=0
            PNTAAC(IAA)=0
            PNTAAE(IAA)=0
            SOUPNT(IAA)=0
            RESTYP(IAA)=0
            SPHRAD(1,IAA)=0.0
            SPHRAD(2,IAA)=0.0
            SPHRAD(3,IAA)=0.0
            SPHRAD(4,IAA)=0.0
            XYZCAS(1,IAA)=0.0
            XYZCAS(2,IAA)=0.0
            XYZCAS(3,IAA)=0.0
            PRPVAL(IAA)=0.0
            SUMACC(IAA)=0.0
            CHIANG(1,IAA)=0.0
            CHIANG(2,IAA)=0.0
            CHIANG(3,IAA)=0.0
            CHIANG(4,IAA)=0.0
            CHIANG(5,IAA)=0.0
            CHIANG(6,IAA)=0.0
            CHIANG(7,IAA)=0.0
            CHIANG(8,IAA)=0.0
            FIXRES(IAA)=0.0
            LOCHST(IAA)=' '
            INSRTC(IAA)=' '
            ONESA3(IAA)(1:1)=' '
            ONESA3(IAA)(2:2)=' '
            ONESA3(IAA)(3:3)=' '
            ONESA3(IAA)(4:4)=' '
            ONEORG(IAA)(1:1)=' '
            ONEORG(IAA)(2:2)=' '
            ONEORG(IAA)(3:3)=' '
            ONEORG(IAA)(4:4)=' '
            NUMNAM(IAA)(1:1)=' '
            NUMNAM(IAA)(2:2)=' '
            NUMNAM(IAA)(3:3)=' '
            NUMNAM(IAA)(4:4)=' '
            CHANAM(IAA)=' '
            NOBOND(IAA)=.FALSE.
            ISSHIT(IAA)=.FALSE.
            ACCDON(IAA)=.FALSE.
            WRK1TF(IAA)=.FALSE.
            CHOSTF(IAA)=.FALSE.
            PSTFLG(IAA)=.FALSE.
            CUTFLG(IAA)=.FALSE.
            HASALT(IAA)=.FALSE.
            MODNMB(IAA)=0
            SUGREA(IAA)=0
            FUTURE(IAA)=0
            JUNIAA(IAA)=0
            PREVSHOW(IAA)=0
 10      CONTINUE
         NUMAAT=0
      END IF
      IF (NUMCYS.GE.1) THEN
         DO 12 ICYS=1,NUMCYS
            CYSCYS(1,ICYS)=0
            CYSCYS(2,ICYS)=0
            FRCCYS(1,ICYS)=0
            FRCCYS(2,ICYS)=0
 12      CONTINUE
         NUMCYS=0
      END IF
      CALL GVSIT0 (FRCCYS,2*MAXCYS)
      CALL GVSIT0 (CLUSTR,MAXCLL*MAXCLU)
      CALL GVSIT0 (FAMILY,2*MAXFAM)



      IF (NUMATF.GE.1) THEN
         DO 20 IAT=1,NUMATF
            XCOORD(IAT)=0.0
            YCOORD(IAT)=0.0
            ZCOORD(IAT)=0.0
            XBFACT(IAT)=0.0
            ACCESS(IAT)=0.0
            WEIGHT(IAT)=0.0
            VDWRAD(IAT)=0.0
            ALTX(IAT)=0.0
            ALTY(IAT)=0.0
            ALTZ(IAT)=0.0
            ALTXBF(IAT)=0.0
            ALTWGT(IAT)=0.0
            ANISOU(1,IAT)=0.0
            ANISOU(2,IAT)=0.0
            ANISOU(3,IAT)=0.0
            ANISOU(4,IAT)=0.0
            ANISOU(5,IAT)=0.0
            ANISOU(6,IAT)=0.0
            ATCOLR(IAT)=0
            PINIAA(IAT)=0
            PREVCOL(IAT)=0
            BOUND_TO(1,IAT)=0
            BOUND_TO(2,IAT)=0
            BOUND_TO(3,IAT)=0
            BOUND_TO(4,IAT)=0
            BOUND_TO(5,IAT)=0
            BOUND_TO(6,IAT)=0
            BOUND_TO(7,IAT)=0
            BOUND_TO(8,IAT)=0
            ALTATM(I)=' '
            ALALAT(I)=' '
            MENDLV(I)(1:1)=' '
            MENDLV(I)(2:2)=' '
            ONEORG(I)(1:1)=' '
            ONEORG(I)(2:2)=' '
            ONEORG(I)(3:3)=' '
            ONEORG(I)(4:4)=' '
            ORGNAM(I)(1:1)=' '
            ORGNAM(I)(2:2)=' '
            ORGNAM(I)(3:3)=' '
            ORGNAM(I)(4:4)=' '
            ORGNAM(I)(5:5)=' '
            ONESAT(I)(1:1)=' '
            ONESAT(I)(2:2)=' '
            ONESAT(I)(3:3)=' '
            ONESAT(I)(4:4)=' '
            ONESAT(I)(5:5)=' '
            PROTON(I)=.FALSE.
            USEAT(I) =.FALSE.
            ISATOK(I)=.FALSE.
            NOBIAT(I)=.FALSE.
            PDBNUM(I)=0
 20      CONTINUE
         NUMATF=0
      END IF





      RETURN
      END   
      SUBROUTINE MOL101 (INSOU)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       INSOU, IAT, IATT, JAT, IDEL, ILOOP,
     +              DELROW(MAXMOL), PNTDEL, TOTDEL
      LOGICAL       GVFIBN
      EQUIVALENCE   (DELROW(1),ESPACE(90001))







      WIFPAR(1504)=WIFPAR(1504)+1



      IF (.NOT.GVFIBN(INSOU,1,NUMSOU)) THEN
         CALL GVSTTB ('?MOLB47')
         CALL GVSKIL
         GOTO 998
      END IF



      CALL ESPSET (90001,90000+MAXMOL,27)



      PNTDEL=1
      TOTDEL=1
      DELROW(PNTDEL)=INSOU



   10 CONTINUE
         DO 40 IAT=PNTAAS(SOUADM(1,DELROW(PNTDEL))),
     +       PNTAAE(SOUADM(2,DELROW(PNTDEL)))
            DO 30 IATT=1,8
               JAT=BOUND_TO(IATT,IAT)
               IF (JAT.GT.IAT) THEN
                  IF (ATIAA(JAT).GT.NUMAAF) THEN
                     IDEL=CHAINN(2,ATIAA(JAT))
                     DO 20 ILOOP=1,TOTDEL
                        IF (DELROW(ILOOP).EQ.IDEL) GOTO 30
   20                CONTINUE
                     TOTDEL=TOTDEL+1
                     DELROW(TOTDEL)=IDEL
                  END IF
               END IF
   30       CONTINUE
   40    CONTINUE
         PNTDEL=PNTDEL+1
      IF (PNTDEL.LT.TOTDEL) GOTO 10



      CALL GVSDT2 (DELROW,TOTDEL)



      DO 70 ILOOP=1,TOTDEL
         CALL MOL101A (DELROW(ILOOP))
         CALL MOL200
   70 CONTINUE



      IF (WIFPAR(111).EQ.0) THEN
         CALL MOL200
         CALL MOL200A
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL101A (INSOU)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'LABELS.INC'
      INTEGER       INSOU, ISOU, ITYPE, IAT, IATLOW, IATHIGH, IBND,
     +              ISHFAA, ISHFAT, MSHFAT, MSHFAA, MONE, ILAB, 
     +              JBND, JAT
      LOGICAL       GVFIBN







      IF (.NOT.GVFIBN(INSOU,1,NUMSOU)) THEN
         CALL GVSTTB ('?MOLB47A')
         CALL GVSTTI2 ('?M1092',INSOU,NUMSOU)
         CALL SHOSOU
         CALL GVSKIL
         GOTO 998
      END IF



      ISOU=INSOU
      ITYPE=SOUADM(5,ISOU)
      ISHFAA=SOUADM(3,ISOU)
      ISHFAT=SOUADM(4,ISOU)
      IF (ISHFAA.NE.SOUADM(2,ISOU)-SOUADM(1,ISOU)+1) THEN
         CALL GVSTTB ('?MOLB48')
         GOTO 998
      END IF
      IF (ISHFAT.NE.PNTAAE(SOUADM(2,ISOU))-PNTAAS(SOUADM(1,ISOU))+1)THEN
         CALL GVSTTB ('?MOLB49')
         GOTO 998
      END IF



      IF (ISOU.EQ.NUMSOU.AND.NUMSOU.EQ.1) THEN
         CALL MOL100
         CALL GVSTT6 ('?MOLLMR')
         CALL JUN001
         GOTO 998
      END IF



      IATLOW=PNTAAS(SOUADM(1,ISOU))
      IATHIGH=PNTAAE(SOUADM(2,ISOU))
      DO 50 IAT=1,NUMATF
         DO 40 IBND=1,8
            IF (BOUND_TO(IBND,IAT).NE.0) THEN
               JAT=BOUND_TO(IBND,IAT)
               IF (JAT.LE.IATHIGH.AND.JAT.GE.IATLOW) THEN
                  BOUND_TO(IBND,IAT)=0
                  DO 30 JBND=1,8
                     IF (BOUND_TO(JBND,JAT).EQ.IAT) THEN
                        BOUND_TO(JBND,JAT)=0
                     END IF
 30               CONTINUE
               END IF
            END IF
   40    CONTINUE
   50 CONTINUE



      DO 500 ILAB=1,MAXLAB
         DO 490 IBND=1,2
            IF (CUPDLST(IBND,ILAB).LE.IATHIGH.AND.
     +          CUPDLST(IBND,ILAB).GE.IATLOW) THEN
               CUPDLST(1,ILAB)=0
               CUPDLST(2,ILAB)=0
            END IF
  490    CONTINUE
  500 CONTINUE



      IF (ISOU.NE.NUMSOU) THEN



         MSHFAT=-ISHFAT
         MSHFAA=-ISHFAA
         MONE=-1
         CALL MOL112 (ISOU+1,NUMSOU,MSHFAT,MSHFAA,MONE)
         IF (MSHFAT.NE.-ISHFAT) CALL GVSTTB ('?MOLB50')
         IF (MSHFAA.NE.-ISHFAA) CALL GVSTTB ('?MOLB51')
         IF (MONE.NE.-1) CALL GVSTTB ('?MOLB52')
      END IF



      NUMATF=NUMATF-ISHFAT
      NUMAAT=NUMAAT-ISHFAA
      NUMSOU=NUMSOU-1
      IF (ITYPE.EQ.1.OR.ITYPE.EQ.3.OR.ITYPE.EQ.7) NUMAAF=NUMAAF-ISHFAA
      IF (ITYPE.EQ.2.OR.ITYPE.EQ.4.OR.ITYPE.EQ.6) NUMCOF=NUMCOF-1



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL101M

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IMOD, ISOUP







      CALL MOL310M (IMOD,' ')
      IF (IMOD.LE.0) GOTO 998



      DO 10 ISOUP=NUMSOU,-1
         IF (MODNMB(ISOUP).EQ.IMOD) CALL MOL101 (ISOUP)
   10 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL102

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'







      IF (NUMAAT.NE.0) THEN
         CALL GVSTTB ('?MOLB59')
         GOTO 998
      END IF
      IF (NUMSOU.NE.0) THEN
         CALL GVSTTB ('?MOLB60')
         GOTO 998
      END IF



      NUMSOU=1





      SOUADM(1,1)=1
      SOUADM(5,1)=1



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL103

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IN1, IN2, IO1, IO2







      WIFPAR(1504)=WIFPAR(1504)+1



      NUMSOU=NUMSOU+1
      IN1=0
      IO1=1
      IN2=0
      IO2=1

      CALL MOL112 (IO1,NUMSOU,IN1,IN2,IO2)
      IF (IO1.NE.1.OR.IO2.NE.0.OR.IN1.NE.0.OR.IN2.NE.0) THEN
         CALL GVSTTB ('?MOLB61')
      END IF





      CALL GVSIT0 (SOUADM(1,1),20)
      SOUADM(1,1)=1
      SOUADM(5,1)=1





      RETURN
      END
      SUBROUTINE MOL104 (THISAA,THISNM,THISOA,IAFTER,ALTRES,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAFTER, IAATYP, ISHFAT, INDAA3, IONE, INUL, LASTAA,
     +              ISOUP, NEWAAF, IERR
      LOGICAL       GVFIBN
      CHARACTER*4   THISAA, THISNM, THISOA
      CHARACTER*1   LOCCHA, ALTRES







      IF (NUMAAT.GT.MAXAA-10.OR.NUMSOU.GT.MAXMOL-3.OR.
     +    NUMATF.GT.MAXAT-1000-WIFPAR(1214)) THEN
         CALL TOOMANY ('something')
         IERR=1
         GOTO 998
      END IF
      IF (IAFTER.LT.0.OR.IAFTER.GT.NUMAAF) THEN
         CALL GVSTTI ('?MOLB62',IAFTER)
         IERR=1
         GOTO 998
      END IF
      IF (INDAA3(THISAA).EQ.0) THEN
         CALL GVST6C ('?MOLB63',THISAA,.TRUE.)
         CALL GVSKIL
         IERR=1
         GOTO 998
      END IF



      IAATYP=INDAA3(THISAA)
      ISHFAT=ATPRAA(IAATYP)
      IF (IAFTER.EQ.0) THEN
         WIFPAR(491)=1
         CALL GVSCTB (LOCCHA,1)
      ELSE
         WIFPAR(491)=SOUPNT(IAFTER)
         LOCCHA=CHANAM(IAFTER)
      END IF
      IERR=0




      IF (NUMAAF.EQ.0.OR.IAFTER.EQ.NUMAAF) THEN
         CALL MOL121 (THISAA,THISNM,THISOA,LOCCHA,' ')
         GOTO 998
      END IF



      IF (IAFTER.EQ.0) THEN
         ISOUP=1
         LASTAA=0
      ELSE
         ISOUP=CHAINN(2,IAFTER)
         IF (.NOT.GVFIBN(ISOUP,1,NUMSOU)) THEN
            CALL GVSTTB ('?MOLB64')
         END IF
         LASTAA=SOUADM(2,ISOUP)
      END IF
      IONE=1
      INUL=0
      IF (ISOUP.LT.NUMSOU) CALL MOL112 (ISOUP+1,NUMSOU,ISHFAT,IONE,INUL)
      IF (IONE.NE.1.OR.INUL.NE.0) CALL GVSTTB ('?MOLB65')



      IONE=1
      IF (IAFTER.LT.LASTAA) CALL MOL111 (IAFTER+1,LASTAA,ISHFAT,IONE)
      IF (IONE.NE.1) CALL GVSTTB ('?MOLB66')



      NEWAAF=IAFTER+1
      CALL MOL122 (ISOUP,NEWAAF,THISAA,THISNM,THISOA,LOCCHA,ISHFAT,
     + ALTRES)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL104A (IAA,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, IERR
      LOGICAL       WIFIRR







      IF (NUMAAT.GT.MAXAA-10.OR.NUMSOU.GT.MAXMOL-3.OR.
     +    NUMATF.GT.MAXAT-1000-WIFPAR(1214)) THEN
         CALL TOOMANY ('something')
         IERR=1
         GOTO 998
      END IF



      IF (WIFIRR(IAA)) THEN
         CALL GVSTTI2 ('?NEWB147',IAA,RESTYP(IAA))
         CALL GVSKIL
         IERR=1
         GOTO 998
      END IF



      WIFPAR(1504)=WIFPAR(1504)+1



      IERR=0
      ISOUP=CHAINN(2,IAA)



      NUMSOU=NUMSOU+1
      NUMAAT=NUMAAT+1
      SOUADM(1,NUMSOU)=NUMAAT
      SOUADM(2,NUMSOU)=NUMAAT
      SOUADM(3,NUMSOU)=1
      SOUADM(4,NUMSOU)=SOUADM(4,ISOUP)
      SOUADM(5,NUMSOU)=SOUADM(5,ISOUP)



      CHAINN(1,NUMAAT)=2
      CHAINN(2,NUMAAT)=NUMSOU



      IF (NUMAAT.EQ.1) THEN
         PNTAAS(NUMAAT)=1
      ELSE
         PNTAAS(NUMAAT)=PNTAAE(NUMAAT-1)+1
      END IF
      PNTAAC(NUMAAT)=PNTAAS(NUMAAT)
      PNTAAE(NUMAAT)=PNTAAS(NUMAAT)+SOUADM(4,NUMSOU)-1



      NUMATF=NUMATF+SOUADM(4,NUMSOU)



      CALL WIF088 (IAA,NUMAAT)



      IF (WIFPAR(1088).GT.0) THEN
         CALL GVSFMT ('?FMT024')
         WRITE (NUMNAM(NUMAAT),FMT,ERR=999) WIFPAR(1088)
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL104A')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL105 (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       GVFIBN, WIFIRI
      INTEGER       ISOUP, ISOLD, IAA







      IF (.NOT.WIFIRI(IAA)) THEN
         CALL GVSTTB ('?MOLB67')
         GOTO 998
      END IF



      WIFPAR(1504)=WIFPAR(1504)+1



      ISOUP=CHAINN(2,IAA)
      IF (.NOT.GVFIBN(ISOUP,1,NUMSOU)) THEN
         CALL GVSTTB ('?MOLB68')
      END IF



      IF (SOUADM(1,ISOUP).EQ.SOUADM(2,ISOUP)) THEN
         ISOLD=ISOUP
         IF (WIFPAR(1195).EQ.0) THEN
            CALL MOL101 (ISOUP)
         ELSE
            CALL MOL101A (ISOUP)
            CALL MOL200
         END IF
         IF (ISOUP.NE.ISOLD) CALL GVSTTB ('?MOLB69')
         GOTO 998
      END IF






      IF (IAA.GT.1) THEN
         PSTFLG(IAA-1)=.FALSE.
         CUTFLG(IAA-1)=.TRUE.
      END IF
      IF (IAA.LT.NUMAAF) THEN
         PSTFLG(IAA)=.FALSE.
         CUTFLG(IAA)=.TRUE.
      END IF
      CALL WIFPUSHPPP (1071,1)
      CALL MOL200
      CALL WIFPOPPPP (1071)



      IF (WIFPAR(1195).EQ.0) THEN
         CALL MOL101 (CHAINN(2,IAA))
      ELSE
         CALL MOL101A (CHAINN(2,IAA))
         CALL MOL200
      END IF
      IF (IAA.GT.1) CUTFLG(IAA-1)=.FALSE.



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL111 (AAFRM,AATO,ISHFAT,ISHFAA)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INCLUDE       'HSTINC.INC'
      INCLUDE       'CLUFAM.INC'
      INCLUDE       'LABELS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       AAFRM, AATO, ATFRM, ATTO, ISHFAT, ISHFAA, 
     +              IAA, IAT, I, J, IBND, IAT1, IAT2, ATDIR, IAA1, 
     +              IAA2, AADIR, ILAB
      LOGICAL       GVFIBN, WIFITI







      WIFPAR(1504)=WIFPAR(1504)+1



      IF (.NOT.GVFIBN(AAFRM,1,MAXAA-1)) THEN
         CALL GVSTTB ('?MOLB73')
         GOTO 998
      END IF
      IF (.NOT.GVFIBN(AATO,1,MAXAA-1)) THEN
         CALL GVSTTB ('?MOLB74')
         GOTO 998
      END IF
      ATFRM=PNTAAS(AAFRM)
      ATTO=PNTAAE(AATO)
      IF (.NOT.WIFITI(ATFRM)) THEN
         CALL GVSTTB ('?MOLB75')
         GOTO 998
      END IF
      IF (.NOT.WIFITI(ATTO)) THEN
         CALL GVSTTB ('?MOLB76')
         GOTO 998
      END IF
      IF (ISHFAT.EQ.0.AND.ISHFAA.EQ.0) GOTO 998



      IF (ISHFAA.EQ.0) THEN
         DO 80 IAA=AAFRM,AATO
            IF (.NOT.GVFIBN(IAA,1,MAXAA)) THEN
               CALL GVSTTB ('?MOLB81')
            END IF
            PNTAAS(IAA)=PNTAAS(IAA)+ISHFAT
            PNTAAC(IAA)=PNTAAC(IAA)+ISHFAT
            PNTAAE(IAA)=PNTAAE(IAA)+ISHFAT
   80    CONTINUE
      ELSE



         IF (ISHFAA.LT.0) THEN
            AADIR=1
            IAA1=AAFRM+ISHFAA
            IAA2=AATO+ISHFAA
         ELSE
            AADIR=-1
            IAA1=AATO+ISHFAA
            IAA2=AAFRM+ISHFAA
         END IF
         DO 60 IAA=IAA1,IAA2,AADIR
            PNTAAS(IAA)=PNTAAS(IAA-ISHFAA)+ISHFAT
            PNTAAC(IAA)=PNTAAC(IAA-ISHFAA)+ISHFAT
            PNTAAE(IAA)=PNTAAE(IAA-ISHFAA)+ISHFAT
            ONESA3(IAA)=ONESA3(IAA-ISHFAA)
            RESTYP(IAA)=RESTYP(IAA-ISHFAA)
            ISSHIT(IAA)=ISSHIT(IAA-ISHFAA)
            NOBOND(IAA)=NOBOND(IAA-ISHFAA)
            MODNMB(IAA)=MODNMB(IAA-ISHFAA)
            SOUPNT(IAA)=SOUPNT(IAA-ISHFAA)
            PSTFLG(IAA)=PSTFLG(IAA-ISHFAA)
            CUTFLG(IAA)=CUTFLG(IAA-ISHFAA)
            NUMNAM(IAA)=NUMNAM(IAA-ISHFAA)
            CHANAM(IAA)=CHANAM(IAA-ISHFAA)
            ACCDON(IAA)=ACCDON(IAA-ISHFAA)
            LOCHST(IAA)=LOCHST(IAA-ISHFAA)
            FIXRES(IAA)=FIXRES(IAA-ISHFAA)
            INSRTC(IAA)=INSRTC(IAA-ISHFAA)
            ONEORG(IAA)=ONEORG(IAA-ISHFAA)
            SUMACC(IAA)=SUMACC(IAA-ISHFAA)
            SUGREA(IAA)=SUGREA(IAA-ISHFAA)
            FUTURE(IAA)=FUTURE(IAA-ISHFAA)
            JUNIAA(IAA)=JUNIAA(IAA-ISHFAA)
            WRK1TF(IAA)=WRK1TF(IAA-ISHFAA)
            PREVSHOW(IAA)=PREVSHOW(IAA-ISHFAA)
            PRPVAL(IAA)=PRPVAL(IAA-ISHFAA)
            CHAINN(1,IAA)=CHAINN(1,IAA-ISHFAA)
            CHAINN(2,IAA)=CHAINN(2,IAA-ISHFAA)
  60     CONTINUE



         IF (ISHFAA.LT.0) THEN
            CALL MOL111A (AATO+1,AATO-ISHFAA)
         ELSE
            CALL MOL111A (AAFRM,AAFRM+ISHFAA-1)
         END IF
      END IF



      IF (NUMFAM.GT.0) THEN
         DO 82 I=1,MAXFAM
            IAA=FAMILY(1,I)
            IF (GVFIBN(IAA,AAFRM,AATO)) FAMILY(1,I)=FAMILY(1,I)+ISHFAA
            IAA=FAMILY(2,I)
            IF (GVFIBN(IAA,AAFRM,AATO)) FAMILY(2,I)=FAMILY(2,I)+ISHFAA
   82    CONTINUE
      END IF
      IF (NUMCLU.GT.0) THEN
         DO 86 I=1,NUMCLU
            DO 84 J=1,LENCLU(I)
               IAA=CLUSTR(J,I)
               IF (GVFIBN(IAA,AAFRM,AATO)) 
     +          CLUSTR(J,I)=CLUSTR(J,I)+ISHFAA
   84       CONTINUE
   86    CONTINUE
      END IF



      IF (ISHFAT.LT.0) THEN
         ATDIR=1
         IAT1=ATFRM+ISHFAT
         IAT2=ATTO+ISHFAT
      ELSE
         ATDIR=-1
         IAT1=ATTO+ISHFAT
         IAT2=ATFRM+ISHFAT
      END IF
      DO 90 IAT=IAT1,IAT2,ATDIR
         XCOORD(IAT)=XCOORD(IAT-ISHFAT)
         YCOORD(IAT)=YCOORD(IAT-ISHFAT)
         ZCOORD(IAT)=ZCOORD(IAT-ISHFAT)
         ALTX(IAT)=ALTX(IAT-ISHFAT)
         ALTY(IAT)=ALTY(IAT-ISHFAT)
         ALTZ(IAT)=ALTZ(IAT-ISHFAT)
         XBFACT(IAT)=XBFACT(IAT-ISHFAT)
         ALTXBF(IAT)=ALTXBF(IAT-ISHFAT)
         ALTATM(IAT)=ALTATM(IAT-ISHFAT)
         ALALAT(IAT)=ALALAT(IAT-ISHFAT)
         ACCESS(IAT)=ACCESS(IAT-ISHFAT)
         WEIGHT(IAT)=WEIGHT(IAT-ISHFAT)
         ALTWGT(IAT)=ALTWGT(IAT-ISHFAT)
         VDWRAD(IAT)=VDWRAD(IAT-ISHFAT)
         USEAT(IAT) =USEAT(IAT-ISHFAT)
         PROTON(IAT)=PROTON(IAT-ISHFAT)
         ISATOK(IAT)=ISATOK(IAT-ISHFAT)
         ATCOLR(IAT)=ATCOLR(IAT-ISHFAT)
         PINIAA(IAT)=PINIAA(IAT-ISHFAT)
         ATTVAL(IAT)=ATTVAL(IAT-ISHFAT)
         ONESAT(IAT)=ONESAT(IAT-ISHFAT)
         ORGNAM(IAT)=ORGNAM(IAT-ISHFAT)
         PREVCOL(IAT)=PREVCOL(IAT-ISHFAT)
         NOBIAT(IAT)=NOBIAT(IAT-ISHFAT)
         MENDLV(IAT)=MENDLV(IAT-ISHFAT)
         PDBNUM(IAT)=PDBNUM(IAT-ISHFAT)
         ATIAA(IAT)=ATIAA(IAT-ISHFAT)+ISHFAA
         DO 89 IBND=1,8
            BOUND_TO(IBND,IAT)=BOUND_TO(IBND,IAT-ISHFAT)
 89      CONTINUE
 90   CONTINUE



      IF (ISHFAT.LT.0) THEN
         CALL MOL111B (ATTO+1,ATTO-ISHFAT)
      ELSE
         CALL MOL111B (ATFRM,ATFRM+ISHFAT-1)
      END IF




      DO 400 IAT=1,NUMATF+ISHFAT
         DO 390 IBND=1,8
            IF (BOUND_TO(IBND,IAT).GE.ATFRM.AND.
     +          BOUND_TO(IBND,IAT).LE.ATTO) THEN
               BOUND_TO(IBND,IAT)=BOUND_TO(IBND,IAT)+ISHFAT
            END IF
  390    CONTINUE
  400 CONTINUE



      DO 500 ILAB=1,MAXLAB
         DO 490 IBND=1,2
            IF (CUPDLST(IBND,ILAB).GE.ATFRM) THEN
                CUPDLST(IBND,ILAB)=CUPDLST(IBND,ILAB)+ISHFAT
            END IF
  490    CONTINUE
  500 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL111A (IAA1IN,IAA2IN)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INCLUDE       'HSTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, IAA1, IAA2, IAA1IN, IAA2IN
      LOGICAL       GVFIBN
      CHARACTER*4   BLANK4
      SAVE          BLANK4
      DATA BLANK4   /'    '/







      IF ((.NOT.GVFIBN(IAA1IN,1,MAXAA)).OR.
     +    (.NOT.GVFIBN(IAA2IN,1,MAXAA))) THEN
         CALL GVSKIL
         GOTO 998
      END IF



      IAA1=IAA1IN
      IAA2=IAA2IN
      IF (IAA2.LT.IAA1) CALL GVSWIP (IAA1,IAA2)



      DO 10 IAA=IAA1,IAA2
         RESTYP(IAA)=0
         MODNMB(IAA)=0
         SOUPNT(IAA)=0
         FUTURE(IAA)=0
         JUNIAA(IAA)=0
         PREVSHOW(IAA)=0
         PNTAAS(IAA)=0
         PNTAAC(IAA)=0
         PNTAAE(IAA)=0
         CHAINN(1,IAA)=0
         CHAINN(2,IAA)=0
         SUMACC(IAA)=0.0
         SUGREA(IAA)=0
         PRPVAL(IAA)=0.0
         SPHRAD(1,IAA)=0.0
         SPHRAD(2,IAA)=0.0
         SPHRAD(3,IAA)=0.0
         SPHRAD(4,IAA)=0.0
         FIXRES(IAA)=0.0
         ONESA3(IAA)=BLANK4
         ONEORG(IAA)=BLANK4
         NUMNAM(IAA)=BLANK4
         CHANAM(IAA)=' '
         LOCHST(IAA)=' '
         INSRTC(IAA)=' '
         ISSHIT(IAA)=.TRUE.
         NOBOND(IAA)=.FALSE.
         PSTFLG(IAA)=.FALSE.
         CUTFLG(IAA)=.FALSE.
         ACCDON(IAA)=.FALSE.
         WRK1TF(IAA)=.FALSE.
   10 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL111B (IAT1IN,IAT2IN)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INTEGER       IAT, IAT1, IAT2, IAT1IN, IAT2IN, IBND
      CHARACTER*5   BLANK5
      SAVE          BLANK5
      DATA BLANK5   /'     '/







      IAT1=IAT1IN
      IAT2=IAT2IN
      IF (IAT2.LT.IAT1) CALL GVSWIP (IAT1,IAT2)



      DO 10 IAT=IAT1,IAT2
         ATCOLR(IAT)=0
         PINIAA(IAT)=0
         ATIAA(IAT)=0
         DO 5 IBND=1,8
            BOUND_TO(IBND,IAT)=0
 5       CONTINUE
         PREVCOL(IAT)=0
         MENDLV(IAT)='  '
         PDBNUM(IAT)=0
         NOBIAT(IAT)=.FALSE.
         XCOORD(IAT)=0.0
         YCOORD(IAT)=0.0
         ZCOORD(IAT)=0.0
         ALTX(IAT)  =0.0
         ALTY(IAT)  =0.0
         ALTZ(IAT)  =0.0
         XBFACT(IAT)=0.0
         ALTXBF(IAT)=0.0
         ACCESS(IAT)=0.0
         WEIGHT(IAT)=0.0
         ALTWGT(IAT)=0.0
         VDWRAD(IAT)=0.0
         ATTVAL(IAT)=0.0
         ONESAT(IAT)=BLANK5
         ORGNAM(IAT)=BLANK5
         USEAT(IAT) =.FALSE.
         ISATOK(IAT)=.FALSE.
         PROTON(IAT)=.FALSE.
   10 CONTINUE





      RETURN
      END   
      SUBROUTINE MOL112 (MOLFRM,MOLTO,ISHFAT,ISHFAA,ISHFML)
















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       MOLFRM, MOLTO, ISHFAT, ISHFAA, ISHFML, ISHFTM,
     +              IAAFRM, IAATO, ISOUP, I, IAA
      LOGICAL       GVFIBN, WIFIRI







      IF (.NOT.GVFIBN(MOLFRM,1,NUMSOU)) THEN
         CALL GVSTTB ('?MOLB86')
         GOTO 998
      END IF
      IF (.NOT.GVFIBN(MOLTO,1,NUMSOU)) THEN
         CALL GVSTTB ('?MOLB87')
         GOTO 998
      END IF



      WIFPAR(1504)=WIFPAR(1504)+1



      ISHFTM=ABS(ISHFML)
      IAAFRM=SOUADM(1,MOLFRM)
      IAATO=SOUADM(2,MOLTO)
      IF (.NOT.WIFIRI(IAAFRM)) THEN
         CALL GVSTTB ('?MOLB88')
      END IF
      IF (.NOT.WIFIRI(IAATO)) THEN
         CALL GVSTTB ('?MOLB89')
      END IF



      IF (ISHFAT.NE.0.OR.ISHFAA.NE.0) CALL MOL111 (IAAFRM,IAATO,
     + ISHFAT,ISHFAA)



      DO 70 IAA=IAAFRM+ISHFAA,IAATO+ISHFAA
         CHAINN(2,IAA)=CHAINN(2,IAA)+ISHFML
   70 CONTINUE



      IF (ISHFML.LT.0) THEN
         DO 20 ISOUP=MOLFRM+ISHFML,MOLTO+ISHFML
            IF (.NOT.GVFIBN(ISOUP,1,MAXMOL)) THEN
               CALL GVSTTB ('?MOLB90')
            END IF
            IF (.NOT.GVFIBN(ISOUP+ISHFTM,1,MAXMOL)) THEN
               CALL GVSTTB ('?MOLB91')
            END IF
            DO 10 I=1,20
               SOUADM(I,ISOUP)=SOUADM(I,ISOUP+ISHFTM)
   10       CONTINUE
            SOUADM(1,ISOUP)=SOUADM(1,ISOUP)+ISHFAA
            SOUADM(2,ISOUP)=SOUADM(2,ISOUP)+ISHFAA
   20    CONTINUE
      END IF



      IF (ISHFML.GT.0) THEN
         DO 40 ISOUP=MOLTO+ISHFTM,MOLFRM+ISHFTM,-1
            IF (.NOT.GVFIBN(ISOUP-ISHFTM,1,NUMSOU)) THEN
               CALL GVSTTB ('?MOLB92')
            END IF
            DO 30 I=1,20
               SOUADM(I,ISOUP)=SOUADM(I,ISOUP-ISHFTM)
   30       CONTINUE
            SOUADM(1,ISOUP)=SOUADM(1,ISOUP)+ISHFAA
            SOUADM(2,ISOUP)=SOUADM(2,ISOUP)+ISHFAA
   40    CONTINUE
         DO 50 ISOUP=MOLFRM,MOLFRM+ISHFTM-1
            IF (.NOT.GVFIBN(ISOUP,1,NUMSOU)) THEN
               CALL GVSTTB ('?MOLB93')
            END IF
            CALL GVSIT0 (SOUADM(1,ISOUP),20)
   50    CONTINUE
      END IF



      IF (ISHFML.EQ.0) THEN
         DO 60 ISOUP=MOLFRM,MOLTO
            SOUADM(1,ISOUP)=SOUADM(1,ISOUP)+ISHFAA
            SOUADM(2,ISOUP)=SOUADM(2,ISOUP)+ISHFAA
   60    CONTINUE
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL121 (THISAA,THISNM,THISOA,LOCCHA,ALTRES)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAATYP, ISHFAT, NEWAAF, ISOUP, INDAA3
      CHARACTER*4   THISAA, THISNM, THISOA
      CHARACTER*1   LOCCHA, ALTRES







      WIFPAR(1504)=WIFPAR(1504)+1








      IAATYP=INDAA3(THISAA)
      NEWAAF=NUMAAF+1
      ISHFAT=ATPRAA(IAATYP)
      IF (NUMAAF.EQ.0) THEN
         ISOUP=0
      ELSE
         ISOUP=CHAINN(2,NUMAAF)
      END IF









      IF (NUMAAF.NE.NUMAAT) THEN
         IF (ISOUP+1.GT.NUMSOU) THEN
            CALL GVSTTB ('?MOLB94')
            GOTO 998
         END IF
         CALL MOL112 (ISOUP+1,NUMSOU,ISHFAT,1,0)
      END IF
      IF (NUMAAT.EQ.0) THEN
         CALL MOL102
         ISOUP=1
      ELSE IF (NUMAAF.EQ.0) THEN
         CALL MOL103
         ISOUP=1
      END IF



      CALL MOL122 (ISOUP,NEWAAF,THISAA,THISNM,THISOA,LOCCHA,
     + ISHFAT,ALTRES)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL121A (THISAA,THISNM,THISOA,LOCCHA)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INCLUDE       'HSTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, NEWIAT, IATS, IAATYP, INDAA3, IBND
      REAL          WIFVDW
      LOGICAL       ISPROTON
      CHARACTER*4   THISAA, THISNM, THISOA
      CHARACTER*1   LOCCHA







      WIFPAR(1504)=WIFPAR(1504)+1



      IAATYP=INDAA3(THISAA)
      IF (IAATYP.EQ.0) THEN
         CALL GVSTTB ('?MOLC52')
         GOTO 998
      END IF
      IF (IAATYP.EQ.0) THEN
         CALL GVSTTB ('?MOLB95')
         GOTO 998
      END IF



      ISOUP=NUMSOU+1
      NUMSOU=ISOUP
      NUMAAT=NUMAAT+1
      SOUADM(1,ISOUP)=NUMAAT
      SOUADM(2,ISOUP)=NUMAAT
      SOUADM(3,ISOUP)=1
      SOUADM(4,ISOUP)=ATPRAA(IAATYP)
      SOUADM(5,ISOUP)=FAMTYP(IAATYP)
      NUMCOF=NUMCOF+1



      CHAINN(1,NUMAAT)=2
      CHAINN(2,NUMAAT)=ISOUP



      IF (NUMAAT.EQ.1) THEN
         PNTAAS(NUMAAT)=1
      ELSE
         PNTAAS(NUMAAT)=PNTAAE(NUMAAT-1)+1
      END IF
      MODNMB(NUMAAT)=WIFPAR(846)
      RESTYP(NUMAAT)=IAATYP
      ISSHIT(NUMAAT)=.TRUE.
      NOBOND(NUMAAT)=.FALSE.
      PNTAAC(NUMAAT)=PNTAAS(NUMAAT)
      PNTAAE(NUMAAT)=PNTAAS(NUMAAT)+ATPRAA(IAATYP)-1
      CALL GVSSTX (ONESA3(NUMAAT),THISAA)
      CALL GVSSTX (ONEORG(NUMAAT),THISOA)
      FUTURE(NUMAAT)=0
      SOUPNT(NUMAAT)=WIFPAR(491)
      PSTFLG(NUMAAT)=.FALSE.
      CUTFLG(NUMAAT)=.FALSE.
      NUMNAM(NUMAAT)=THISNM
      CHANAM(NUMAAT)=LOCCHA
      LOCHST(NUMAAT)=' '
      FIXRES(NUMAAT)=0.0
      INSRTC(NUMAAT)=' '
      ACCDON(NUMAAT)=.FALSE.
      WRK1TF(NUMAAT)=.FALSE.
      CHOSTF(NUMAAT)=.FALSE.
      SUMACC(NUMAAT)=0.0
      SUGREA(NUMAAT)=0
      SPHRAD(1,NUMAAT)=0.0
      SPHRAD(2,NUMAAT)=0.0
      SPHRAD(3,NUMAAT)=0.0
      SPHRAD(4,NUMAAT)=0.0



      NUMATF=NUMATF+ATPRAA(IAATYP)
      DO 10 NEWIAT=PNTAAS(NUMAAT),PNTAAE(NUMAAT)
         IATS=NEWIAT-PNTAAS(NUMAAT)+1
         CALL GVSSTX (ONESAT(NEWIAT),MUTROW4(IATS,IAATYP))
         CALL GVSSTX (MENDLV(NEWIAT),ONESAT(NEWIAT)(1:2))
         PINIAA(NEWIAT)=NEWIAT-PNTAAS(NUMAAT)+1
         CALL GVSSTX (ORGNAM(NEWIAT),ONESAT(NEWIAT))
         VDWRAD(NEWIAT)=WIFVDW(ONESAT(NEWIAT))
         XCOORD(NEWIAT)=0.0
         YCOORD(NEWIAT)=0.0
         ZCOORD(NEWIAT)=0.0
         ALTX(NEWIAT)=0.0
         ALTY(NEWIAT)=0.0
         ALTZ(NEWIAT)=0.0
         WEIGHT(NEWIAT)=0.0
         ALTWGT(NEWIAT)=0.0
         ATCOLR(NEWIAT)=0
         PINIAA(NEWIAT)=0
         PREVCOL(NEWIAT)=0
         PDBNUM(NEWIAT)=0
         NOBIAT(NEWIAT)=.FALSE.
         ATTVAL(NEWIAT)=0.0
         ACCESS(NEWIAT)=0.0
         USEAT(NEWIAT)=.FALSE.
         ISATOK(NEWIAT)=.FALSE.
         PROTON(NEWIAT)=ISPROTON(NEWIAT)
         XBFACT(NEWIAT)=FLOAT(WIFPAR(57))
         ALTXBF(NEWIAT)=FLOAT(WIFPAR(57))
         ALTATM(NEWIAT)=' '
         ALALAT(NEWIAT)=' '
         DO 5 IBND=1,8
            BOUND_TO(IBND,NEWIAT)=0
 5       CONTINUE
 10   CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL122 (ISOUP,NEWAAF,THISAA,THISNM,THISOA,LOCCHA,
     + ISHFAT,ALTRES)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HSTINC.INC'
      INCLUDE       'JUNIOR.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       NEWAAF, ISHFAT, ISOUP, NEWIAT, IATS, IBND, IERR,
     +              IAATYP, INDAA3
      LOGICAL       TXTPROTON
      REAL          WIFVDW
      CHARACTER*4   THISAA, THISNM, THISOA
      CHARACTER*1   LOCCHA, ALTRES







      WIFPAR(1504)=WIFPAR(1504)+1



      IAATYP=INDAA3(THISAA)



      IF (IAATYP.EQ.0) THEN
         PRINT*,'Go for TOP011 on:',ISOUP,NEWAAF,THISAA,THISNM,
     +    THISOA,LOCCHA,ISHFAT,ALTRES
         CALL TOP011 (THISAA,IERR)
         IF (IERR.EQ.0) IAATYP=INDAA3(THISAA)
      END IF



      IF (IAATYP.EQ.0) THEN
         CALL GVSTTB ('?MOLB95')
         CALL GVST6C ('?M1299',THISAA,.FALSE.)
         CALL GVSKIL
         GOTO 998
      END IF



      SOUADM(2,ISOUP)=SOUADM(2,ISOUP)+1
      SOUADM(3,ISOUP)=SOUADM(3,ISOUP)+1
      SOUADM(4,ISOUP)=SOUADM(4,ISOUP)+ISHFAT
      SOUADM(5,ISOUP)=FAMTYP(IAATYP)
      IF (FAMTYP(IAATYP).EQ.6) CALL GVSKIL



      IF (NEWAAF.EQ.1) THEN
         CHAINN(1,NEWAAF)=1
      ELSE
         CHAINN(1,NEWAAF)=2
      END IF
      CHAINN(2,NEWAAF)=ISOUP



      NUMAAT=NUMAAT+1
      NUMAAF=NUMAAF+1



      IF (NEWAAF.EQ.1) THEN
         PNTAAS(NEWAAF)=1
         MODNMB(NEWAAF)=0
      ELSE
         PNTAAS(NEWAAF)=PNTAAE(NEWAAF-1)+1
         MODNMB(NEWAAF)=MODNMB(NEWAAF-1)
      END IF
      ONESA3(NEWAAF)(1:1)=THISAA(1:1)
      ONESA3(NEWAAF)(2:2)=THISAA(2:2)
      ONESA3(NEWAAF)(3:3)=THISAA(3:3)
      ONESA3(NEWAAF)(4:4)=THISAA(4:4)
      ONEORG(NEWAAF)(1:1)=THISOA(1:1)
      ONEORG(NEWAAF)(2:2)=THISOA(2:2)
      ONEORG(NEWAAF)(3:3)=THISOA(3:3)
      ONEORG(NEWAAF)(4:4)=THISOA(4:4)
      RESTYP(NEWAAF)=INDAA3(ONESA3(NEWAAF))
      ISSHIT(NEWAAF)=.TRUE.
      NOBOND(NEWAAF)=.FALSE.
      PNTAAC(NEWAAF)=PNTAAS(NEWAAF)
      PNTAAE(NEWAAF)=PNTAAS(NEWAAF)+ISHFAT-1
      FUTURE(NEWAAF)=0
      SOUPNT(NEWAAF)=WIFPAR(491)
      PSTFLG(NEWAAF)=.FALSE.
      CUTFLG(NEWAAF)=.FALSE.
      NUMNAM(NEWAAF)=THISNM
      CHANAM(NEWAAF)=LOCCHA
      LOCHST(NEWAAF)=' '
      FIXRES(NEWAAF)=0.0
      INSRTC(NEWAAF)=ALTRES
      ACCDON(NEWAAF)=.FALSE.
      WRK1TF(NEWAAF)=.FALSE.
      CHOSTF(NEWAAF)=.FALSE.
      SUMACC(NEWAAF)=0.0
      SUGREA(NEWAAF)=0
      SPHRAD(1,NEWAAF)=0.0
      SPHRAD(2,NEWAAF)=0.0
      SPHRAD(3,NEWAAF)=0.0
      SPHRAD(4,NEWAAF)=0.0



      NUMATF=NUMATF+ISHFAT
      DO 10 NEWIAT=PNTAAS(NEWAAF),PNTAAE(NEWAAF)
         IATS=NEWIAT-PNTAAS(NEWAAF)+1
         ONESAT(NEWIAT)(1:1)=MUTROW4(IATS,IAATYP)(1:1)
         ONESAT(NEWIAT)(2:2)=MUTROW4(IATS,IAATYP)(2:2)
         ONESAT(NEWIAT)(3:3)=MUTROW4(IATS,IAATYP)(3:3)
         ONESAT(NEWIAT)(4:4)=MUTROW4(IATS,IAATYP)(4:4)
         ONESAT(NEWIAT)(5:5)=MUTROW4(IATS,IAATYP)(5:5)
         ORGNAM(NEWIAT)(1:1)=ONESAT(NEWIAT)(1:1)
         ORGNAM(NEWIAT)(2:2)=ONESAT(NEWIAT)(2:2)
         ORGNAM(NEWIAT)(3:3)=ONESAT(NEWIAT)(3:3)
         ORGNAM(NEWIAT)(4:4)=ONESAT(NEWIAT)(4:4)
         ORGNAM(NEWIAT)(5:5)=ONESAT(NEWIAT)(5:5)
         VDWRAD(NEWIAT)=WIFVDW(ONESAT(NEWIAT))
         XCOORD(NEWIAT)=0.0
         YCOORD(NEWIAT)=0.0
         ZCOORD(NEWIAT)=0.0
         ALTX(NEWIAT)=0.0
         ALTY(NEWIAT)=0.0
         ALTZ(NEWIAT)=0.0
         WEIGHT(NEWIAT)=0.0
         ALTWGT(NEWIAT)=0.0
         ATCOLR(NEWIAT)=0
         PINIAA(NEWIAT)=IATS
         PREVCOL(NEWIAT)=0
         MENDLV(NEWIAT)(1:1)=ONESAT(NEWIAT)(1:1)
         MENDLV(NEWIAT)(2:2)=ONESAT(NEWIAT)(2:2)
         IF (MENDLV(NEWIAT).EQ.'OE') CALL GVSKIL
         PDBNUM(NEWIAT)=0
         NOBIAT(NEWIAT)=.FALSE.
         ACCESS(NEWIAT)=0.0
         ATTVAL(NEWIAT)=0.0
         USEAT(NEWIAT)=.FALSE.
         ISATOK(NEWIAT)=.FALSE.
         PROTON(NEWIAT)=TXTPROTON(ONESAT(NEWIAT),MENDLV(NEWIAT))
         XBFACT(NEWIAT)=FLOAT(WIFPAR(57))
         ALTXBF(NEWIAT)=FLOAT(WIFPAR(57))
         ALTATM(NEWIAT)=' '
         ALALAT(NEWIAT)=' '
         DO 5 IBND=1,8
            BOUND_TO(IBND,NEWIAT)=0
 5       CONTINUE
 10   CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL123 (THISAA,THISNM,LOCCHA,TEXT,ITYPE,NBAT,ALTRES,
     + IERR)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IERR, ISET, INDAA3, GVFLEN, NBAT, ITYPE
      CHARACTER*4   THISAA, THISNM
      CHARACTER*1   LOCCHA, ALTRES
      CHARACTER*(*) TEXT







      WIFPAR(1504)=WIFPAR(1504)+1



      IF (NUMSOU.GT.MAXMOL-2) THEN
         CALL GVSTTI2 ('2) NUMSOU,MAXMOL=',NUMSOU,MAXMOL-2)
         CALL SHOSOU
         CALL TOOMANY ('?MOLC26')
         IERR=1
         GOTO 998
      END IF
      NUMSOU=NUMSOU+1



      IF (NUMAAT.GT.MAXAA-2) THEN
         CALL TOOMANY ('?MOLC23')
         IERR=1
         GOTO 998
      END IF
      NUMAAT=NUMAAT+1
      NUMCOF=NUMCOF+1



      IF (NUMATF+NBAT.GT.MAXAT-100) THEN
         CALL TOOMANY ('?MOLC24')
         IERR=1
         GOTO 998
      END IF



      IERR=0



      SOUADM(1,NUMSOU)=NUMAAT
      SOUADM(2,NUMSOU)=NUMAAT
      SOUADM(3,NUMSOU)=1
      SOUADM(4,NUMSOU)=NBAT
      SOUADM(5,NUMSOU)=ITYPE



      PNTAAS(NUMAAT)=NUMATF+1
      PNTAAC(NUMAAT)=NUMATF+1
      PNTAAE(NUMAAT)=NUMATF+NBAT
      IF (PNTAAE(NUMAAT).LT.PNTAAS(NUMAAT)) THEN
         CALL MOL010 ('PNTAAE too small in MOL123')
         PRINT*,'PNTAASE,NBAT=',PNTAAS(NUMAAT),PNTAAE(NUMAAT),NBAT
         PRINT*,'NUMAAT,ATF=',NUMAAT,NUMATF
      END IF
      CALL GVSSTX (ONESA3(NUMAAT),THISAA)
      IF (ITYPE.EQ.1.OR.ITYPE.EQ.3) THEN
         RESTYP(NUMAAT)=INDAA3(ONESA3(NUMAAT))
      ELSE
         RESTYP(NUMAAT)=0
      END IF
      NOBOND(NUMAAT)=.FALSE.
      MODNMB(NUMAAT)=WIFPAR(846)
      CALL GVSSTX (NUMNAM(NUMAAT),THISNM)
      FIXRES(NUMAAT)=0.0
      INSRTC(NUMAAT)=ALTRES
      CALL GVSSTX (CHANAM(NUMAAT),LOCCHA)
      CALL GVSSTX (ONEORG(NUMAAT),ONESA3(NUMAAT))
      CHAINN(1,NUMAAT)=0
      CHAINN(2,NUMAAT)=NUMSOU
      NUMATF=NUMATF+NBAT



      DO 10 ISET=1,MAXSET
         IF (SOUNAM(ISET).EQ.TEXT) THEN
            SOUPNT(NUMAAT)=ISET
            GOTO 11
         ELSE IF (GVFLEN(SOUNAM(ISET)).EQ.0) THEN
            CALL GVSSTX (SOUNAM(ISET),TEXT)
            SOUPNT(NUMAAT)=ISET
            GOTO 11
         END IF
   10 CONTINUE
   11 CONTINUE



      IF (WIFPAR(1180).NE.0) GOTO 998



      CALL MOL500



      CALL MOL201 (NUMAAT)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF088 (IAA1,IAA2)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HSTINC.INC'
      INCLUDE       'JUNIOR.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA1, IAA2, IATLOC, IAT1, IAT2, IAT







      WIFPAR(1504)=WIFPAR(1504)+1



      NUMNAM(IAA2)=NUMNAM(IAA1)
      SOUPNT(IAA2)=SOUPNT(IAA1)
      PSTFLG(IAA2)=PSTFLG(IAA1)
      CUTFLG(IAA2)=CUTFLG(IAA1)
      RESTYP(IAA2)=RESTYP(IAA1)
      ISSHIT(IAA2)=ISSHIT(IAA1)
      NOBOND(IAA2)=NOBOND(IAA1)
      MODNMB(IAA2)=MODNMB(IAA1)
      ONESA3(IAA2)=ONESA3(IAA1)
      ONEORG(IAA2)=ONEORG(IAA1)
      LOCHST(IAA2)=LOCHST(IAA1)
      FIXRES(IAA2)=FIXRES(IAA1)
      INSRTC(IAA2)=INSRTC(IAA1)
      ACCDON(IAA2)=ACCDON(IAA1)
      WRK1TF(IAA2)=WRK1TF(IAA1)
      CHOSTF(IAA2)=.FALSE.
      SUMACC(IAA2)=SUMACC(IAA1)
      SUGREA(IAA2)=SUGREA(IAA1)
      CHANAM(IAA2)=CHANAM(IAA1)
      CALL GVSCPR (SPHRAD(1,IAA2),SPHRAD(1,IAA1),4)



      DO 10 IAT=PNTAAS(IAA1),PNTAAE(IAA1)
         IATLOC=IAT-PNTAAS(IAA1)+1
         IAT1=PNTAAS(IAA1)+IATLOC-1
         IAT2=PNTAAS(IAA2)+IATLOC-1
         XCOORD(IAT2)=XCOORD(IAT1)
         YCOORD(IAT2)=YCOORD(IAT1)
         ZCOORD(IAT2)=ZCOORD(IAT1)
         ALTX(IAT2)=ALTX(IAT1)
         ALTY(IAT2)=ALTY(IAT1)
         ALTZ(IAT2)=ALTZ(IAT1)
         VDWRAD(IAT2)=VDWRAD(IAT1)
         ATCOLR(IAT2)=ATCOLR(IAT1)
         PREVCOL(IAT2)=PREVCOL(IAT1)
         MENDLV(IAT2)=MENDLV(IAT1)
         PDBNUM(IAT2)=PDBNUM(IAT1)
         NOBIAT(IAT2)=NOBIAT(IAT1)
         ISATOK(IAT2)=ISATOK(IAT1)
         ACCESS(IAT2)=ACCESS(IAT1)
         ATTVAL(IAT2)=ATTVAL(IAT1)
         WEIGHT(IAT2)=WEIGHT(IAT1)
         ALTWGT(IAT2)=ALTWGT(IAT1)
         XBFACT(IAT2)=XBFACT(IAT1)
         ALTXBF(IAT2)=ALTXBF(IAT1)
         ALTATM(IAT2)=ALTATM(IAT1)
         ALALAT(IAT2)=ALALAT(IAT1)
         ONESAT(IAT2)=ONESAT(IAT1)
         ORGNAM(IAT2)=ORGNAM(IAT1)
   10 CONTINUE





      RETURN
      END
      SUBROUTINE MOL199 (IFT1,IFT2)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IFT1, IFT2
      LOGICAL       WIFCOK, WIFIRN, WIFIRR, WIFIRI, WIFIRZ







      IF (WIFPAR(1100).NE.0) GOTO 998
      IF (.NOT.WIFIRI(IFT1)) THEN
         CALL GVSTTE ('?NEWE904')
         CALL GVSKIL
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(IFT1).AND.FAMTYP(RESTYP(IFT1)).NE.6) THEN
         CALL GVSTTI2 ('?M4524',IFT1,IFT2)
         CALL GVSKIL
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(IFT2).AND.FAMTYP(RESTYP(IFT2)).NE.6) THEN
         CALL GVSTTI2 ('?M4525',IFT1,IFT2)
         CALL GVSKIL
         GOTO 998
      END IF



      CALL CHI004



      DO 10 IAA=IFT1,IFT2
         IF ((.NOT.WIFIRR(IAA)).OR.WIFIRZ(IAA)) GOTO 10
         IF (WIFCOK(IAA)) THEN
            IF (RESTYP(IAA).EQ.18) THEN
               CALL MOL199VAL (IAA)
            ELSE IF (RESTYP(IAA).EQ.17) THEN
               CALL MOL199THR (IAA)
            ELSE IF (RESTYP(IAA).EQ.10) THEN
               CALL MOL199LEU (IAA)
            ELSE IF (RESTYP(IAA).EQ.15) THEN
               CALL MOL199ARG (IAA)
            ELSE IF (RESTYP(IAA).EQ.20) THEN
               CALL MOL199TYR (IAA)
            ELSE IF (RESTYP(IAA).EQ.8) THEN
               CALL MOL199ILE (IAA)
            ELSE IF (RESTYP(IAA).EQ.5) THEN
               CALL MOL199PHE (IAA)
            ELSE IF (RESTYP(IAA).EQ.3) THEN
               IF (WIFPAR(1825).EQ.0) CALL MOL199ASP (IAA)
            ELSE IF (RESTYP(IAA).EQ.4) THEN
               IF (WIFPAR(1825).EQ.0) CALL MOL199GLU (IAA)
            END IF
         END IF
         IF (WIFIRN(IAA)) CALL MOL199NA (IAA)
   10 CONTINUE



      CALL HAS001 (.FALSE.)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199VAL (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA
      REAL          V1(3), V2(3), V3(3), GVFDV3







      IF (RESTYP(IAA).NE.18) THEN
         CALL GVSTTB ('?R00267')
         GOTO 998
      END IF



      V1(1)=XCOORD(PNTAAS(IAA)+4)-XCOORD(PNTAAC(IAA))
      V1(2)=YCOORD(PNTAAS(IAA)+4)-YCOORD(PNTAAC(IAA))
      V1(3)=ZCOORD(PNTAAS(IAA)+4)-ZCOORD(PNTAAC(IAA))



      V2(1)=(XCOORD(PNTAAS(IAA)+5)+XCOORD(PNTAAS(IAA)+6))/2.0-
     +     XCOORD(PNTAAS(IAA)+4)
      V2(2)=(YCOORD(PNTAAS(IAA)+5)+YCOORD(PNTAAS(IAA)+6))/2.0-
     +     YCOORD(PNTAAS(IAA)+4)
      V2(3)=(ZCOORD(PNTAAS(IAA)+5)+ZCOORD(PNTAAS(IAA)+6))/2.0-
     +     ZCOORD(PNTAAS(IAA)+4)



      CALL GVSCP3 (V3,V2,V1)



      V1(1)=XCOORD(PNTAAS(IAA)+5)-XCOORD(PNTAAS(IAA)+4)
      V1(2)=YCOORD(PNTAAS(IAA)+5)-YCOORD(PNTAAS(IAA)+4)
      V1(3)=ZCOORD(PNTAAS(IAA)+5)-ZCOORD(PNTAAS(IAA)+4)



      V2(1)=XCOORD(PNTAAS(IAA)+6)-XCOORD(PNTAAS(IAA)+4)
      V2(2)=YCOORD(PNTAAS(IAA)+6)-YCOORD(PNTAAS(IAA)+4)
      V2(3)=ZCOORD(PNTAAS(IAA)+6)-ZCOORD(PNTAAS(IAA)+4)



      IF (GVFDV3(V1,V3).GT.GVFDV3(V2,V3)) THEN
         CALL MOL203 (PNTAAS(IAA)+5,PNTAAS(IAA)+6,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199ILE (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA
      REAL          V1(3), V2(3), V3(3), GVFDV3







      IF (RESTYP(IAA).NE.8) THEN
         CALL GVSTTB ('?R00267A')
         GOTO 998
      END IF



      V1(1)=XCOORD(PNTAAS(IAA)+4)-XCOORD(PNTAAC(IAA))
      V1(2)=YCOORD(PNTAAS(IAA)+4)-YCOORD(PNTAAC(IAA))
      V1(3)=ZCOORD(PNTAAS(IAA)+4)-ZCOORD(PNTAAC(IAA))



      V2(1)=(XCOORD(PNTAAS(IAA)+5)+XCOORD(PNTAAS(IAA)+6))/2.0-
     +     XCOORD(PNTAAS(IAA)+4)
      V2(2)=(YCOORD(PNTAAS(IAA)+5)+YCOORD(PNTAAS(IAA)+6))/2.0-
     +     YCOORD(PNTAAS(IAA)+4)
      V2(3)=(ZCOORD(PNTAAS(IAA)+5)+ZCOORD(PNTAAS(IAA)+6))/2.0-
     +     ZCOORD(PNTAAS(IAA)+4)



      CALL GVSCP3 (V3,V2,V1)



      V1(1)=XCOORD(PNTAAS(IAA)+5)-XCOORD(PNTAAS(IAA)+4)
      V1(2)=YCOORD(PNTAAS(IAA)+5)-YCOORD(PNTAAS(IAA)+4)
      V1(3)=ZCOORD(PNTAAS(IAA)+5)-ZCOORD(PNTAAS(IAA)+4)



      V2(1)=XCOORD(PNTAAS(IAA)+6)-XCOORD(PNTAAS(IAA)+4)
      V2(2)=YCOORD(PNTAAS(IAA)+6)-YCOORD(PNTAAS(IAA)+4)
      V2(3)=ZCOORD(PNTAAS(IAA)+6)-ZCOORD(PNTAAS(IAA)+4)



      IF (GVFDV3(V1,V3).LT.GVFDV3(V2,V3)) THEN
         CALL MOL203 (PNTAAS(IAA)+5,PNTAAS(IAA)+6,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199THR (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA
      REAL          V1(3), V2(3), V3(3), GVFDV3
      LOGICAL       HASPROTON







      IF (RESTYP(IAA).NE.17) THEN
         CALL GVSTTB ('?R00266')
         GOTO 998
      END IF




      IF (WIFPAR(1503).EQ.1) GOTO 998



      IF (WIFPAR(84).EQ.1) THEN
         IF (HASPROTON()) GOTO 998
      END IF



      V1(1)=XCOORD(PNTAAS(IAA)+4)-XCOORD(PNTAAC(IAA))
      V1(2)=YCOORD(PNTAAS(IAA)+4)-YCOORD(PNTAAC(IAA))
      V1(3)=ZCOORD(PNTAAS(IAA)+4)-ZCOORD(PNTAAC(IAA))



      V2(1)=(XCOORD(PNTAAS(IAA)+5)+XCOORD(PNTAAS(IAA)+6))/2.0-
     +     XCOORD(PNTAAS(IAA)+4)
      V2(2)=(YCOORD(PNTAAS(IAA)+5)+YCOORD(PNTAAS(IAA)+6))/2.0-
     +     YCOORD(PNTAAS(IAA)+4)
      V2(3)=(ZCOORD(PNTAAS(IAA)+5)+ZCOORD(PNTAAS(IAA)+6))/2.0-
     +     ZCOORD(PNTAAS(IAA)+4)



      CALL GVSCP3 (V3,V2,V1)



      V1(1)=XCOORD(PNTAAS(IAA)+5)-XCOORD(PNTAAS(IAA)+4)
      V1(2)=YCOORD(PNTAAS(IAA)+5)-YCOORD(PNTAAS(IAA)+4)
      V1(3)=ZCOORD(PNTAAS(IAA)+5)-ZCOORD(PNTAAS(IAA)+4)



      V2(1)=XCOORD(PNTAAS(IAA)+6)-XCOORD(PNTAAS(IAA)+4)
      V2(2)=YCOORD(PNTAAS(IAA)+6)-YCOORD(PNTAAS(IAA)+4)
      V2(3)=ZCOORD(PNTAAS(IAA)+6)-ZCOORD(PNTAAS(IAA)+4)



      IF (GVFDV3(V1,V3).LT.GVFDV3(V2,V3)) THEN
         CALL MOL203 (PNTAAS(IAA)+5,PNTAAS(IAA)+6,0)
         ISSHIT(IAA)=.TRUE.
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199LEU (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA
      REAL          V1(3), V2(3), V3(3), GVFDV3







      IF (RESTYP(IAA).NE.10) THEN
         CALL GVSTTB ('?R00265')
         GOTO 998
      END IF



      V1(1)=XCOORD(PNTAAS(IAA)+5)-XCOORD(PNTAAS(IAA)+4)
      V1(2)=YCOORD(PNTAAS(IAA)+5)-YCOORD(PNTAAS(IAA)+4)
      V1(3)=ZCOORD(PNTAAS(IAA)+5)-ZCOORD(PNTAAS(IAA)+4)



      V2(1)=(XCOORD(PNTAAS(IAA)+6)+XCOORD(PNTAAS(IAA)+7))/2.0-
     +     XCOORD(PNTAAS(IAA)+5)
      V2(2)=(YCOORD(PNTAAS(IAA)+6)+YCOORD(PNTAAS(IAA)+7))/2.0-
     +     YCOORD(PNTAAS(IAA)+5)
      V2(3)=(ZCOORD(PNTAAS(IAA)+6)+ZCOORD(PNTAAS(IAA)+7))/2.0-
     +     ZCOORD(PNTAAS(IAA)+5)



      CALL GVSCP3 (V3,V2,V1)



      V1(1)=XCOORD(PNTAAS(IAA)+6)-XCOORD(PNTAAS(IAA)+5)
      V1(2)=YCOORD(PNTAAS(IAA)+6)-YCOORD(PNTAAS(IAA)+5)
      V1(3)=ZCOORD(PNTAAS(IAA)+6)-ZCOORD(PNTAAS(IAA)+5)



      V2(1)=XCOORD(PNTAAS(IAA)+7)-XCOORD(PNTAAS(IAA)+5)
      V2(2)=YCOORD(PNTAAS(IAA)+7)-YCOORD(PNTAAS(IAA)+5)
      V2(3)=ZCOORD(PNTAAS(IAA)+7)-ZCOORD(PNTAAS(IAA)+5)



      IF (GVFDV3(V1,V3).GT.GVFDV3(V2,V3)) THEN
         CALL MOL203 (PNTAAS(IAA)+6,PNTAAS(IAA)+7,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199ARG (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CHIANG.INC'
      INTEGER       IAA, H1, H2
      REAL          GVFRTD, ANGLE, ALTANG, CHI001







      IF (RESTYP(IAA).NE.15) THEN
         CALL GVSTTB ('?R00264')
         GOTO 998
      END IF
      ANGLE=GVFRTD(CHIANG(8,IAA))



      H1=0
      H2=0
      IF (WIFPAR(84).NE.0) THEN
         IF (ISATOK(PNTAAS(IAA)+20)) H1=H1+1
         IF (ISATOK(PNTAAS(IAA)+21)) H1=H1+1
         IF (ISATOK(PNTAAS(IAA)+22)) H2=H2+1
         IF (ISATOK(PNTAAS(IAA)+23)) H2=H2+1
      END IF



      IF (WIFPAR(84).NE.0.AND.H1.EQ.H2) THEN
         IF (ABS(ANGLE).GT.90.0) THEN
            ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+6,PNTAAS(IAA)+7,
     +       PNTAAS(IAA)+8,PNTAAS(IAA)+10))
            IF (ABS(ALTANG).LT.ABS(ANGLE)) THEN
               CALL MOL203 (PNTAAS(IAA)+9,PNTAAS(IAA)+10,0)
               GOTO 10
            END IF
         END IF
      END IF



      IF (WIFPAR(84).EQ.0) THEN
         IF (ABS(ANGLE).GT.90.0) THEN
            ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+6,PNTAAS(IAA)+7,
     +       PNTAAS(IAA)+8,PNTAAS(IAA)+10))
            IF (ABS(ALTANG).LT.ABS(ANGLE)) THEN
               CALL MOL203 (PNTAAS(IAA)+9,PNTAAS(IAA)+10,0)
               GOTO 10
            END IF
         END IF
      END IF



      IF (H1.LT.H2) THEN
         IF (ABS(ANGLE).GT.90.0) THEN
            ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+6,PNTAAS(IAA)+7,
     +       PNTAAS(IAA)+8,PNTAAS(IAA)+10))
            IF (ABS(ALTANG).LT.ABS(ANGLE)) THEN
               CALL MOL203 (PNTAAS(IAA)+9,PNTAAS(IAA)+10,0)
               GOTO 10
            END IF
         END IF
      END IF
      IF (H1.GT.H2) THEN
         IF (ABS(ANGLE).LT.90.0) THEN
            ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+6,PNTAAS(IAA)+7,
     +       PNTAAS(IAA)+8,PNTAAS(IAA)+10))
            IF (ABS(ALTANG).GT.ABS(ANGLE)) THEN
               CALL MOL203 (PNTAAS(IAA)+9,PNTAAS(IAA)+10,0)
               GOTO 10
            END IF
         END IF
      END IF




   10 CONTINUE
      IF (WIFPAR(84).NE.0) THEN
         IF (ISATOK(PNTAAS(IAA)+20)) THEN
            ANGLE=CHI001(PNTAAS(IAA)+7,PNTAAS(IAA)+8,PNTAAS(IAA)+9,
     +       PNTAAS(IAA)+20)
            IF (ABS(GVFRTD(ANGLE)).GT.90) THEN
               CALL MOL203I (PNTAAS(IAA)+20,PNTAAS(IAA)+21,0)
            END IF
         ELSE IF (ISATOK(PNTAAS(IAA)+21)) THEN



            ANGLE=CHI001(PNTAAS(IAA)+7,PNTAAS(IAA)+8,PNTAAS(IAA)+9,
     +       PNTAAS(IAA)+21)
            IF (ABS(GVFRTD(ANGLE)).LT.90) THEN
               CALL MOL203I (PNTAAS(IAA)+20,PNTAAS(IAA)+21,0)
            END IF
         END IF
         IF (ISATOK(PNTAAS(IAA)+22)) THEN



            ANGLE=CHI001(PNTAAS(IAA)+7,PNTAAS(IAA)+8,PNTAAS(IAA)+10,
     +       PNTAAS(IAA)+22)
            IF (ABS(GVFRTD(ANGLE)).GT.90) THEN
               CALL MOL203I (PNTAAS(IAA)+22,PNTAAS(IAA)+23,0)
            END IF
         ELSE IF (ISATOK(PNTAAS(IAA)+23)) THEN



            ANGLE=CHI001(PNTAAS(IAA)+7,PNTAAS(IAA)+8,PNTAAS(IAA)+10,
     +       PNTAAS(IAA)+23)
            IF (ABS(GVFRTD(ANGLE)).LT.90) THEN
               CALL MOL203I (PNTAAS(IAA)+22,PNTAAS(IAA)+23,0)
            END IF
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199TYR (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CHIANG.INC'
      INTEGER       IAA
      REAL          GVFRTD, ANGLE, ALTANG, CHI001







      IF (RESTYP(IAA).NE.20) THEN
         CALL GVSTTB ('?R00263')
         GOTO 998
      END IF



      ANGLE=GVFRTD(CHIANG(5,IAA))
      IF (ABS(ANGLE).GT.90.0) THEN
         ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+1,PNTAAS(IAA)+4,PNTAAS(IAA)+5,
     +        PNTAAS(IAA)+7))
         IF (ABS(ALTANG).LT.ABS(ANGLE)) THEN
            CALL MOL203 (PNTAAS(IAA)+6,PNTAAS(IAA)+7,0)
            CALL MOL203 (PNTAAS(IAA)+8,PNTAAS(IAA)+9,0)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199PHE (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CHIANG.INC'
      INTEGER       IAA
      REAL          GVFRTD, CHI001, ANGLE, ALTANG







      IF (RESTYP(IAA).NE.5) THEN
         CALL GVSTTB ('?R00262')
         GOTO 998
      END IF



      ANGLE=GVFRTD(CHIANG(5,IAA))
      IF (ABS(ANGLE).GT.90.0) THEN
         ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+1,PNTAAS(IAA)+4,PNTAAS(IAA)+5,
     +        PNTAAS(IAA)+7))
         IF (ABS(ALTANG).LT.ABS(ANGLE)) THEN
            CALL MOL203 (PNTAAS(IAA)+6,PNTAAS(IAA)+7,0)
            CALL MOL203 (PNTAAS(IAA)+8,PNTAAS(IAA)+9,0)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199ASP (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CHIANG.INC'
      INTEGER       IAA, IHAT
      REAL          GVFRTD, ANGLE, ALTANG, CHI001







      IF (RESTYP(IAA).NE.3) THEN
         CALL GVSTTB ('?R00261')
         GOTO 998
      END IF



      IF (BOUND_TO(1,PNTAAS(IAA)+6).NE.0.AND.
     +     BOUND_TO(1,PNTAAS(IAA)+7).EQ.0) THEN
         CALL MOL203I (PNTAAS(IAA)+6,PNTAAS(IAA)+7,0)
      END IF



      IHAT=BOUND_TO(1,PNTAAS(IAA)+6)
      IF (IHAT.GT.0) THEN
         IF (PROTON(IHAT)) THEN
            CALL GVSSTX (ONESAT(IHAT),'Oeps')
         END IF
      END IF
      IHAT=BOUND_TO(1,PNTAAS(IAA)+7)
      IF (IHAT.GT.0) THEN
         IF (PROTON(IHAT)) THEN
            CALL GVSSTX (ONESAT(IHAT),SPCATM(9))
         END IF
      END IF



      IF (BOUND_TO(1,PNTAAS(IAA)+6).NE.0.OR.
     + BOUND_TO(1,PNTAAS(IAA)+7).NE.0) GOTO 998



      ANGLE=GVFRTD(CHIANG(5,IAA))
      ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+1,PNTAAS(IAA)+4,
     + PNTAAS(IAA)+5,PNTAAS(IAA)+7))
      IF (ABS(ANGLE).GT.90.0) THEN
         IF (ABS(ANGLE).GT.ABS(ALTANG)) THEN
            CALL MOL203 (PNTAAS(IAA)+6,PNTAAS(IAA)+7,0)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199GLU (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CHIANG.INC'
      REAL          GVFRTD, ANGLE, ALTANG, CHI001
      INTEGER       IAA, IHAT







      IF (RESTYP(IAA).NE.4) THEN
         CALL GVSTTB ('?R00260')
         GOTO 998
      END IF



      IF (BOUND_TO(1,PNTAAS(IAA)+7).NE.0.AND.
     +    BOUND_TO(1,PNTAAS(IAA)+8).EQ.0) THEN
         PRINT*,'BEFORE AND AFTER 203I SWAP IN 199GLU'
         CALL SHOIAA (IAA)
         CALL MOL203I (PNTAAS(IAA)+7,PNTAAS(IAA)+8,0)
         CALL SHOIAA (IAA)
      END IF



      IHAT=BOUND_TO(1,PNTAAS(IAA)+7)
      IF (IHAT.GT.0) THEN
         IF (PROTON(IHAT)) THEN
            CALL GVSSTX (ONESAT(IHAT),'Oeps')
         END IF
      END IF
      IHAT=BOUND_TO(1,PNTAAS(IAA)+8)
      IF (IHAT.GT.0) THEN
         IF (PROTON(IHAT)) THEN
            CALL GVSSTX (ONESAT(IHAT),SPCATM(10))
         END IF
      END IF



      IF (BOUND_TO(1,PNTAAS(IAA)+7).NE.0.OR.
     + BOUND_TO(1,PNTAAS(IAA)+8).NE.0) GOTO 998



      ANGLE=GVFRTD(CHIANG(6,IAA))
      IF (ABS(ANGLE).GT.90.0) THEN
         ALTANG=GVFRTD(CHI001(PNTAAS(IAA)+4,PNTAAS(IAA)+5,
     +    PNTAAS(IAA)+6,PNTAAS(IAA)+8))
         IF (ABS(ANGLE).GT.ABS(ALTANG)) THEN
            CALL MOL203 (PNTAAS(IAA)+7,PNTAAS(IAA)+8,0)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199NA (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4
      REAL          CHI001
      LOGICAL       WIFIRN, WIFIR1







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFIR1(IAA)) GOTO 998



      IAT1=PNTAAS(IAA-1)+2
      IAT2=PNTAAS(IAA)+3
      IAT3=PNTAAS(IAA)+4
      IAT4=PNTAAS(IAA)+5
      IF (CHI001(IAT1,IAT2,IAT3,IAT4).GE.-0.3) THEN
         CALL MOL203 (IAT2,IAT3,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199OADE (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4, IAT5
      REAL          CHI001, GVFRTD
      LOGICAL       WIFIRN







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFPAR(84).EQ.0) GOTO 998



      IAT1=PNTAAS(IAA)+17
      IAT2=PNTAAS(IAA)+15
      IAT3=PNTAAS(IAA)+16
      IAT4=PNTAAS(IAA)+30
      IAT5=PNTAAS(IAA)+31
      IF (ABS(GVFRTD(CHI001(IAT1,IAT2,IAT3,IAT4))).GE.90.0) THEN
         CALL MOL203 (IAT4,IAT5,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199DADE (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4, IAT5
      REAL          CHI001, GVFRTD
      LOGICAL       WIFIRN







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFPAR(84).EQ.0) GOTO 998



      IAT1=PNTAAS(IAA)+17
      IAT2=PNTAAS(IAA)+15
      IAT3=PNTAAS(IAA)+16
      IAT4=PNTAAS(IAA)+29
      IAT5=PNTAAS(IAA)+30
      IF (ABS(GVFRTD(CHI001(IAT1,IAT2,IAT3,IAT4))).GE.90.0) THEN
         CALL MOL203 (IAT4,IAT5,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199OCYT (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4, IAT5
      REAL          CHI001, GVFRTD
      LOGICAL       WIFIRN







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFPAR(84).EQ.0) GOTO 998



      IAT1=PNTAAS(IAA)+16
      IAT2=PNTAAS(IAA)+14
      IAT3=PNTAAS(IAA)+15
      IAT4=PNTAAS(IAA)+27
      IAT5=PNTAAS(IAA)+28
      IF (ABS(GVFRTD(CHI001(IAT1,IAT2,IAT3,IAT4))).GE.90.0) THEN
         CALL MOL203 (IAT4,IAT5,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199DCYT (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4, IAT5
      REAL          CHI001, GVFRTD
      LOGICAL       WIFIRN







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFPAR(84).EQ.0) GOTO 998



      IAT1=PNTAAS(IAA)+16
      IAT2=PNTAAS(IAA)+14
      IAT3=PNTAAS(IAA)+15
      IAT4=PNTAAS(IAA)+26
      IAT5=PNTAAS(IAA)+27
      IF (ABS(GVFRTD(CHI001(IAT1,IAT2,IAT3,IAT4))).GE.90.0) THEN
         CALL MOL203 (IAT4,IAT5,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199OGUA (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4, IAT5
      REAL          CHI001, GVFRTD
      LOGICAL       WIFIRN







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFPAR(84).EQ.0) GOTO 998



      IAT1=PNTAAS(IAA)+17
      IAT2=PNTAAS(IAA)+18
      IAT3=PNTAAS(IAA)+19
      IAT4=PNTAAS(IAA)+32
      IAT5=PNTAAS(IAA)+33
      IF (ABS(GVFRTD(CHI001(IAT1,IAT2,IAT3,IAT4))).GE.90.0) THEN
         CALL MOL203 (IAT4,IAT5,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL199DGUA (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT1, IAT2, IAT3, IAT4, IAT5
      REAL          CHI001, GVFRTD
      LOGICAL       WIFIRN







      IF (.NOT.WIFIRN(IAA)) THEN
         CALL GVSTTB ('?R00259')
         GOTO 998
      END IF
      IF (WIFPAR(84).EQ.0) GOTO 998



      IAT1=PNTAAS(IAA)+17
      IAT2=PNTAAS(IAA)+18
      IAT3=PNTAAS(IAA)+19
      IAT4=PNTAAS(IAA)+31
      IAT5=PNTAAS(IAA)+32
      IF (ABS(GVFRTD(CHI001(IAT1,IAT2,IAT3,IAT4))).GE.90.0) THEN
         CALL MOL203 (IAT4,IAT5,0)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL200



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'VECTOR.INC'
      INCLUDE       'CRDINC.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       ISOUP, IAA, IAT, OLDGRV, IOLD, OLD1504
      LOGICAL       GVFFOP, WIFISW, ISPROTON, WIFIRR, MOL009, NOBDON,
     +              WIFOXS
      SAVE          OLD1504
      DATA OLD1504  /-1/







      SUBUSE(1)=SUBUSE(1)+1




      IF (NUMAAF.LE.0) GOTO 998
      IF (WIFPAR(402).NE.0) GOTO 998
      IF (NUMSOU.LE.0) THEN
         CALL MOL500
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(1)) THEN
         IF (MOD(SUBUSE(1),100).EQ.1) CALL SHOWTEXT ('?M1518')
      END IF



      IF (WIFPAR(1204).LE.1) THEN
         WIFPAR(154)=0
         WIFPAR(1204)=2
      ELSE
         IOLD=WIFPAR(1204)
         IF (IOLD.EQ.0) IOLD=1
         WIFPAR(154)=1
         GOTO 999
      END IF



      WIFPAR(1179)=0



      IF (WIFPAR(1504).NE.OLD1504) THEN
         DO 3 IAT=1,NUMATF
            PROTON(IAT)=ISPROTON(IAT)
 3       CONTINUE
      ELSE
         DO 4 IAT=1,NUMATF
            PROTON(IAT)=MENDLV(IAT).EQ.' H'.OR.MENDLV(IAT).EQ.' D'
 4       CONTINUE
      END IF



      CALL MOL500




      CALL MOL202




      CALL MOL201A

      CALL MOL224 (NOBDON)
      IF (NOBDON) CALL MOL201A




      DO 100 ISOUP=1,NUMSOU



         IF (SOUADM(1,ISOUP).EQ.SOUADM(2,ISOUP)) THEN





            IF (WIFOXS(SOUADM(1,ISOUP))) THEN
               SOUADM(5,ISOUP)=4
               IAA=SOUADM(1,ISOUP)
               RESTYP(IAA)=0
            END IF
         END IF



         DO 20 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
            CALL MOL204 (IAA)
   20    CONTINUE



         DO 30 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
            CALL MOL211 (IAA)
   30    CONTINUE



         DO 10 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
            CALL MOL201 (IAA)
   10    CONTINUE



         IF (WIFISW(ISOUP)) THEN
            IF (.NOT.MOL009(ONESA3(SOUADM(1,ISOUP)))) THEN
               CALL GVSSTX (ONESA3(SOUADM(1,ISOUP)),'HOH ')
               RESTYP(SOUADM(1,ISOUP))=0
            END IF
         END IF
  100 CONTINUE




      CALL MOL212



      CALL MOL216



      CALL MOL214




      CALL MOL217



      CALL MOL200A




      CALL MOL215








      NUMCOF=0
      DO 210 ISOUP=1,NUMSOU
         IF (SOUADM(5,ISOUP).EQ.2.OR.SOUADM(5,ISOUP).EQ.4.OR.
     +    SOUADM(5,ISOUP).EQ.6) NUMCOF=NUMCOF+1
  210 CONTINUE



      CALL NOB003





         CALL MOL219





      IF (WIFPAR(1247).EQ.0) THEN
         IF (WIFPAR(281).EQ.0) THEN
            IF (WIFPAR(1208).GE.3) CALL GVSTT6 ('?M4554')
            CALL USEDD1
         END IF
      END IF




      CALL MOL223




      CALL MOL205




      OLDGRV=NUMGRV
      IF (USE300.AND.WIFPAR(904).GT.0.AND.WIFPAR(476).EQ.0.AND.
     +    (.NOT.GVFFOP(IU54))) THEN
         CALL IRI000
      END IF
      NUMGRV=OLDGRV



  999 CONTINUE
      NCRD=0
      WIFPAR(154)=0
      WIFPAR(1204)=0



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL200A

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'







      IF (WIFPAR(168).EQ.1.OR.WIFPAR(476).NE.0) GOTO 998
      IF (WIFPAR(168).EQ.2) THEN
         CALL GVSKIL
         GOTO 998
      END IF



      IF (NUMATF.LE.0.OR.NUMAAT.LE.0) GOTO 998



      IF (NUMAAT.LE.NUMAAF) GOTO 998



      CALL MOL214



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL200B (IFT1,IFT2)

















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







      IF (NUMSOU.LE.0) GOTO 998
      IF (.NOT.WIFIRI(IFT1)) THEN
         CALL GVSTTI3 ('?M4558',IFT1,IFT2,NUMAAT)
         CALL MOL010 ('?M4559')
         CALL GVSKIL
      END IF
      IF (.NOT.WIFIRI(IFT2)) THEN
         CALL GVSTTI3 ('?M4558',IFT1,IFT2,NUMAAT)
         CALL MOL010 ('?M4560')
         CALL GVSKIL
      END IF



      CALL GVSBTF (WRK1TF,MAXAA)
      FOUND=.FALSE.



      DO 130 IAA=IFT1,IFT2
         DO 120 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ATCOLR(IAT).EQ.0.OR.ATCOLR(IAT).EQ.360) THEN
               IF (WIFPAR(267).EQ.-1) THEN
                  WRK1TF(ATIAA(IAT))=.TRUE.
                  FOUND=.TRUE.
                  GOTO 130
               ELSE IF (WIFPAR(267).LE.360) THEN
                  ATCOLR(IAT)=WIFPAR(267)
               END IF
            END IF
  120    CONTINUE
  130 CONTINUE
      IF (FOUND) CALL COL002 (IFT1,IFT2)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL201 (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT, IAA
      REAL          D, WIFVDW, XYZMIN(3), XYZMAX(3), XYZCEN(3), NUMUSE







      IF (PNTAAS(IAA).GT.PNTAAE(IAA)) THEN
         CALL GVSTTB ('?MOLB96')
         GOTO 998
      END IF



      SPHRAD(1,IAA)=0.0
      SPHRAD(2,IAA)=0.0
      SPHRAD(3,IAA)=0.0
      SPHRAD(4,IAA)=1.0
      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         VDWRAD(IAT)=WIFVDW(ONESAT(IAT))
   10 CONTINUE




      XYZMIN(1)=99999.9
      XYZMIN(2)=99999.9
      XYZMIN(3)=99999.9
      XYZMAX(1)=-99999.9
      XYZMAX(2)=-99999.9
      XYZMAX(3)=-99999.9
      XYZCEN(1)=0.0
      XYZCEN(2)=0.0
      XYZCEN(3)=0.0
      NUMUSE=0.0



      IF (PNTAAE(IAA).GT.PNTAAS(IAA)) THEN
         DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ISATOK(IAT)) THEN
               XYZMIN(1)=MIN(XYZMIN(1),XCOORD(IAT)-VDWRAD(IAT))
               XYZMIN(2)=MIN(XYZMIN(2),YCOORD(IAT)-VDWRAD(IAT))
               XYZMIN(3)=MIN(XYZMIN(3),ZCOORD(IAT)-VDWRAD(IAT))
               XYZMAX(1)=MIN(XYZMIN(1),XCOORD(IAT)+VDWRAD(IAT))
               XYZMAX(2)=MIN(XYZMIN(2),YCOORD(IAT)+VDWRAD(IAT))
               XYZMAX(3)=MIN(XYZMIN(3),ZCOORD(IAT)+VDWRAD(IAT))
               XYZCEN(1)=XYZCEN(1)+XCOORD(IAT)
               XYZCEN(2)=XYZCEN(2)+YCOORD(IAT)
               XYZCEN(3)=XYZCEN(3)+ZCOORD(IAT)
               NUMUSE=NUMUSE+1.0
            END IF
 20      CONTINUE
      ELSE
         SPHRAD(1,IAA)=XCOORD(PNTAAS(IAA))
         SPHRAD(2,IAA)=YCOORD(PNTAAS(IAA))
         SPHRAD(3,IAA)=ZCOORD(PNTAAS(IAA))
         SPHRAD(4,IAA)=VDWRAD(PNTAAS(IAA))+1.0
      END IF
      IF (NUMUSE.GT.1.5) THEN
         SPHRAD(1,IAA)=XYZCEN(1)/NUMUSE
         SPHRAD(2,IAA)=XYZCEN(2)/NUMUSE
         SPHRAD(3,IAA)=XYZCEN(3)/NUMUSE



         DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ISATOK(IAT)) THEN
               D=SQRT((XCOORD(IAT)-SPHRAD(1,IAA))**2+
     +                (YCOORD(IAT)-SPHRAD(2,IAA))**2+
     +                (ZCOORD(IAT)-SPHRAD(3,IAA))**2)+VDWRAD(IAT)
               SPHRAD(4,IAA)=MAX(SPHRAD(4,IAA),D)
            END IF
 30      CONTINUE
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL201A 

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IAA, IAT, IBND, JAA, JAT, ISOU, IERR
      REAL          WIFDST, CUTOFF, ADDRAD
      LOGICAL       AREBOUND, WIFISA, WIFISW, WIFISN, WIFIRA







      IF (NUMAAT.LT.1) THEN
         CALL GVSTTB ('?MOLB97')
         GOTO 998
      END IF



      DO 2 IAA=1,NUMAAT
         DO 1 IAT=PNTAAS(IAA),PNTAAE(IAA)
            PINIAA(IAT)=IAT-PNTAAS(IAA)+1
    1    CONTINUE
    2 CONTINUE



      DO 20 IAA=1,NUMAAT




         IF (PNTAAS(IAA).LT.1.OR.PNTAAS(IAA).GT.PNTAAE(IAA).OR.
     +       PNTAAE(IAA).GT.NUMATF) THEN
            CALL SHOIAA (IAA)
            PRINT*,'NUMATF,S,E=',NUMATF,PNTAAS(IAA),PNTAAE(IAA)
            CALL MOL010 ('?M4526')
            WIFPAR(154)=1
            GOTO 998
         END IF
         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            ATIAA(IAT)=IAA
   10    CONTINUE
   20 CONTINUE




      IF (WIFPAR(448).NE.0) GOTO 998
      CALL DRG106 (IERR)
      IF (IERR.NE.0) GOTO 998
      DO 25 ISOU=1,NUMSOU
         IF (WIFPAR(1208).EQ.1) THEN
            CALL GVSTTI ('?M4527',ISOU)
            CALL GVST6C ('?M4528',ONESA3(SOUADM(1,ISOU)),.TRUE.)
         END IF
         CALL ENVPUSH (IERR)
         IF (IERR.NE.0) GOTO 998
         CALL ENVSET (ISOU)
         IAA=SOUADM(1,ISOU)
         IF (.NOT.WIFISA(ISOU).AND.(.NOT.WIFISW(ISOU)).AND.
     +      (.NOT.WIFISN(ISOU))) THEN
            IF (WIFPAR(1208).EQ.1) THEN
               CALL GVSTTI ('?M4529',ISOU)
            END IF
            CALL MOL004A (ISOU)
            IF (WIFPAR(1208).EQ.1) CALL SHOSOU
         END IF
         CALL ENVPOP (IERR)
         IF (IERR.NE.0) GOTO 998
 25   CONTINUE
      CALL DRG107 (IERR)



      CALL SYMBOUNDTO (IERR)



      DO 70 IAT=1,NUMATF
         IF (SOUADM(10,CHAINN(2,ATIAA(IAT))).EQ.2) GOTO 70
         IAA=ATIAA(IAT)
         ADDRAD=0.0
         IF (ONESAT(IAT)(1:2).EQ.' S') ADDRAD=MAX(ADDRAD,0.25)
         IF (ONESAT(IAT)(1:2).EQ.' P') ADDRAD=MAX(ADDRAD,0.25)
         DO 60 IBND=1,8
            JAT=BOUND_TO(IBND,IAT)
            IF (JAT.GT.0) THEN
               IF (PROTON(IAT).OR.PROTON(JAT)) THEN
                  CUTOFF=1.75
               ELSE
                  CUTOFF=2.75
               END IF
               IF (ONESAT(JAT)(1:2).EQ.' S') ADDRAD=MAX(ADDRAD,0.25)
               IF (ONESAT(JAT)(1:2).EQ.' P') ADDRAD=MAX(ADDRAD,0.25)
               JAA=ATIAA(JAT)
               CUTOFF=CUTOFF+ADDRAD
               IF (WIFDST(IAT,JAT).GT.CUTOFF.OR.
     +             (WIFIRA(IAA).AND.NOBOND(ATIAA(IAT)).AND.
     +             IAT.GT.PNTAAS(IAA)+3).OR.
     +             (WIFIRA(JAA).AND.NOBOND(ATIAA(JAT)).AND.
     +             JAT.GT.PNTAAS(JAA)+3).OR.
     +             NOBIAT(JAT).OR.NOBIAT(IAT)) THEN
                  
                  CALL SETUNBOUNDTO (IAT,JAT,IERR)
               END IF
            END IF
   60    CONTINUE
   70 CONTINUE



      IF (WIFPAR(84).GT.0) THEN
         DO 100 IAA=1,NUMAAT
            DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (PROTON(IAT).AND.XBFACT(IAT).LT.0.01) THEN
                  DO 80 JAT=PNTAAS(IAA),PNTAAE(IAA)
                     IF (AREBOUND(IAT,JAT)) THEN
                        XBFACT(IAT)=XBFACT(JAT)
                        GOTO 90
                     END IF
   80             CONTINUE
               END IF
   90       CONTINUE
  100    CONTINUE
      END IF



      DO 120 IAT=1,NUMATF
         CALL DWNBOUNDTO (IAT)
 120  CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL202






















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IMODNB, JSOUP, ISOU1, ISOUP
      LOGICAL       MOL209







      IF (NUMAAF.EQ.0) GOTO 998




      CALL MOL206




      DO 40 IAA=2,NUMAAF
         IF (.NOT.MOL209(IAA-1,IAA)) THEN
            CALL MOL208 (IAA)
            IF (WIFPAR(1510).EQ.1) GOTO 41
         END IF
   40 CONTINUE
   41 CONTINUE




      CALL MOL207




      IMODNB=MODNMB(1)
      DO 50 IAA=1,NUMAAF
         IF (MODNMB(IAA).NE.IMODNB) GOTO 61
   50 CONTINUE
      DO 60 IAA=1,NUMAAT
         MODNMB(IAA)=0
   60 CONTINUE
   61 CONTINUE









      ISOU1=1
      DO 100 ISOUP=1,CHAINN(2,NUMAAF)
         IF (MODNMB(SOUADM(1,MIN(ISOUP+1,NUMSOU))).NE.
     +       MODNMB(SOUADM(1,ISOU1)).OR.ISOUP.EQ.CHAINN(2,NUMAAF)) THEN
            DO 90 JSOUP=ISOU1,ISOUP
               SOUADM(8,JSOUP)=SOUADM(1,ISOU1)
               SOUADM(9,JSOUP)=SOUADM(2,ISOUP)
   90       CONTINUE
            ISOU1=ISOUP+1
         END IF
  100 CONTINUE




  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL203 (IAT1,IAT2,NAMTOO)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT1, IAT2, NAMTOO, NUMBND1, JAT1ARR(10),
     +              NUMBND2, JAT2ARR(10), IJAT
      LOGICAL       WIFITI







      IF ((.NOT.WIFITI(IAT1)).OR.(.NOT.WIFITI(IAT2))) THEN
         CALL GVSTTI2 ('?M4536',IAT1,IAT2)
         CALL GVSKIL
         GOTO 998
      END IF
      CALL MOL203I (IAT1,IAT2,NAMTOO)



      IF (WIFPAR(84).NE.0) THEN
         IF (.NOT.PROTON(IAT1).AND.(.NOT.PROTON(IAT2))) THEN



            CALL FBONDH (IAT1,JAT1ARR,10,NUMBND1)
            CALL FBONDH (IAT2,JAT2ARR,10,NUMBND2)
            IF (NUMBND1.EQ.0.OR.NUMBND2.EQ.0) GOTO 998
            IF (NUMBND1.NE.NUMBND2) GOTO 998



            CALL GVSIR1 (JAT1ARR,NUMBND1)
            CALL GVSIR1 (JAT2ARR,NUMBND2)



            DO 10 IJAT=1,NUMBND1
               IF (ISATOK(JAT1ARR(IJAT)).AND.ISATOK(JAT2ARR(IJAT))) THEN
                  CALL MOL203I (JAT1ARR(IJAT),JAT2ARR(IJAT),NAMTOO)
               END IF
 10         CONTINUE
         END IF
      END IF



  998 CONTINUE

         
      RETURN
      END
      SUBROUTINE MOL203A (IAT1,IAT2)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT1, IAT2, IBND







      ONESAT(IAT1)=ONESAT(IAT2)
      ORGNAM(IAT1)=ORGNAM(IAT2)
      XCOORD(IAT1)=XCOORD(IAT2)
      YCOORD(IAT1)=YCOORD(IAT2)
      ZCOORD(IAT1)=ZCOORD(IAT2)
      ALTX(IAT1)=ALTX(IAT2)
      ALTY(IAT1)=ALTY(IAT2)
      ALTZ(IAT1)=ALTZ(IAT2)
      ACCESS(IAT1)=ACCESS(IAT2)
      VDWRAD(IAT1)=VDWRAD(IAT2)
      ATCOLR(IAT1)=ATCOLR(IAT2)
      MENDLV(IAT1)=MENDLV(IAT2)
      PDBNUM(IAT1)=PDBNUM(IAT2)
      NOBIAT(IAT1)=NOBIAT(IAT2)
      ATTVAL(IAT1)=ATTVAL(IAT2)
      WEIGHT(IAT1)=WEIGHT(IAT2)
      XBFACT(IAT1)=XBFACT(IAT2)
      ALTWGT(IAT1)=ALTWGT(IAT2)
      ALTXBF(IAT1)=ALTXBF(IAT2)
      ALTATM(IAT1)=ALTATM(IAT2)
      ALALAT(IAT1)=ALALAT(IAT2)
      USEAT(IAT1)=USEAT(IAT2)
      ISATOK(IAT1)=ISATOK(IAT2)
      PROTON(IAT1)=PROTON(IAT2)
      DO 10 IBND=1,8
         BOUND_TO(IBND,IAT1)=BOUND_TO(IBND,IAT2)
 10   CONTINUE





      RETURN
      END
      SUBROUTINE MOL203I (IAT1,IAT2,NAMTOO)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INTEGER       IAT1, IAT2, NAMTOO, JAT, P, Q
      LOGICAL       WIFITI







      IF ((.NOT.WIFITI(IAT1)).OR.(.NOT.WIFITI(IAT2))) THEN
         CALL GVSTTI2 ('?M4537',IAT1,IAT2)
         CALL GVSKIL
         GOTO 998
      END IF



      CALL GVSWAP (XCOORD(IAT1),XCOORD(IAT2))
      CALL GVSWAP (YCOORD(IAT1),YCOORD(IAT2))
      CALL GVSWAP (ZCOORD(IAT1),ZCOORD(IAT2))
      CALL GVSWAP (ALTX(IAT1),ALTX(IAT2))
      CALL GVSWAP (ALTY(IAT1),ALTY(IAT2))
      CALL GVSWAP (ALTZ(IAT1),ALTZ(IAT2))
      CALL GVSWAP (ACCESS(IAT1),ACCESS(IAT2))
      CALL GVSWAP (VDWRAD(IAT1),VDWRAD(IAT2))
      CALL GVSWIP (ATCOLR(IAT1),ATCOLR(IAT2))
      CALL GVSWIP (PREVCOL(IAT1),PREVCOL(IAT2))
      CALL GVSWCP (MENDLV(IAT1),MENDLV(IAT2))
      CALL GVSWIP (PDBNUM(IAT1),PDBNUM(IAT2))
      CALL GVSWLP (NOBIAT(IAT1),NOBIAT(IAT2))
      CALL GVSWAP (ATTVAL(IAT1),ATTVAL(IAT2))
      CALL GVSWAP (WEIGHT(IAT1),WEIGHT(IAT2))
      CALL GVSWAP (XBFACT(IAT1),XBFACT(IAT2))
      CALL GVSWAP (ALTWGT(IAT1),ALTWGT(IAT2))
      CALL GVSWAP (ALTXBF(IAT1),ALTXBF(IAT2))
      CALL GVSWLP (USEAT(IAT1),USEAT(IAT2))
      CALL GVSWLP (ISATOK(IAT1),ISATOK(IAT2))
      CALL GVSWLP (PROTON(IAT1),PROTON(IAT2))
      CALL GVSWCP (ORGNAM(IAT1),ORGNAM(IAT2))
      CALL GVSWCP (ALTATM(IAT1),ALTATM(IAT2))
      CALL GVSWCP (ALALAT(IAT1),ALALAT(IAT2))




      IF (NAMTOO.GE.1) CALL GVSWCP (ONESAT(IAT1),ONESAT(IAT2))




      IF (IAT1.LE.PNTAAE(NUMAAF).AND.IAT2.GT.PNTAAE(NUMAAF)) GOTO 998
      IF (IAT2.LE.PNTAAE(NUMAAF).AND.IAT1.GT.PNTAAE(NUMAAF)) GOTO 998



      DO 10 P=1,8
         CALL GVSWIP (BOUND_TO(P,IAT1),BOUND_TO(P,IAT2))
   10 CONTINUE



      DO 20 P=1,8
         JAT=BOUND_TO(P,IAT1)
         IF (JAT.GT.0) THEN
            DO 30 Q=1,8
               IF (BOUND_TO(Q,JAT).EQ.IAT2) THEN
                  BOUND_TO(Q,JAT)=IAT1





                  GOTO 20
               END IF
   30       CONTINUE
         END IF
   20 CONTINUE
      DO 40 P=1,8
         JAT=BOUND_TO(P,IAT2)
         IF (JAT.GT.0) THEN
            DO 50 Q=1,8
               IF (BOUND_TO(Q,JAT).EQ.IAT1) THEN
                  BOUND_TO(Q,JAT)=IAT2





                  GOTO 40
               END IF
   50       CONTINUE
         END IF
   40 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL204 (IAA)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT
      LOGICAL       WIFITI, WIFIRI, WIFIRA, WIFIRZ, T54EQUAL







      IF (.NOT.WIFIRI(IAA)) THEN
         CALL GVSTTB ('?MOLB98')
         WIFPAR(154)=1
         GOTO 998
      END IF
      IF (.NOT.WIFITI(PNTAAS(IAA))) THEN
         CALL GVSTTB ('?MOLB99')
         WIFPAR(154)=1
         GOTO 998
      END IF
      IF (.NOT.WIFITI(PNTAAE(IAA))) THEN
         CALL GVSTTB ('?MOLC01')
         WIFPAR(154)=1
         GOTO 998
      END IF
      IF (PNTAAS(IAA).GT.PNTAAE(IAA)) THEN
         CALL GVSTTB ('?MOLC02')
         WIFPAR(154)=1
         GOTO 998
      END IF



      IF (WIFIRA(IAA)) THEN
         PNTAAC(IAA)=PNTAAS(IAA)+1
      ELSE 
         PNTAAC(IAA)=PNTAAS(IAA)
      END IF



      IF (WIFIRZ(IAA)) THEN
         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (T54EQUAL(ONESAT(IAT),' C4 ')) THEN
               PNTAAC(IAA)=IAT
               GOTO 11
            END IF
   10    CONTINUE
   11    CONTINUE
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL205


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       IAA, IAT, JAT, KAT, JATARR(6), NUM, MAT, MINAT, SP,
     +              NUMH, ILOOP, CHAOK, CHANOK, CHADIV, CHACNT(MAXMOL),
     +              IDRG, ISOUP, LAT, KILLAT, I1, HATARR(6), NUMA, HAT,
     +              SOUAD7
      REAL          WIFDST, DMIN, D1, D2, D3, WIFANG, OOP1, OOP2, OOP3,
     +              WIFPL4, D12
      LOGICAL       WIFIR1, WIFIRA, WIFIRW, AREBOUND, WIFIRR, WIF040,
     +              WIFISH
      CHARACTER*1   CHAOTH(MAXMOL)








      IF (WIFPAR(84).EQ.0) GOTO 80



      DO 10 IAA=1,NUMAAF




         IAT=PNTAAS(IAA)
         IF (ISATOK(IAT).AND.WIFIRA(IAA).AND.WIFIR1(IAA)) THEN



            KILLAT=0
            CALL FBONDAOK (IAT,JATARR,6,NUM)
            IF (RESTYP(IAA).EQ.13.OR.RESTYP(IAA).EQ.21) THEN
               IF (NUM.NE.3) GOTO 10
            ELSE
               IF (NUM.NE.2) GOTO 10
            END IF
            IF (WIFANG(JATARR(1),IAT,JATARR(2)).GT.105.25) THEN
               SP=2
            ELSE
               SP=3
            END IF



            CALL FBONDOK (IAT,JATARR,6,NUM)



            IF (SP.EQ.3) THEN
               IF (NUM.LE.4) GOTO 10




               JAT=BOUND_TO(1,IAT)
               KAT=BOUND_TO(2,IAT)
               LAT=BOUND_TO(3,IAT)
               MAT=PNTAAS(IAA)+HATPRA(RESTYP(IAA))
               IF (PROTON(JAT)) THEN
                  IF (.NOT.PROTON(KAT)) THEN
                     CALL GVSWIP (JAT,KAT)
                  ELSE IF (.NOT.PROTON(LAT)) THEN
                     CALL GVSWIP (JAT,LAT)
                  ELSE
                     CALL GVSTTE ('?M4539')
                  END IF
               END IF
               D1=WIFDST(JAT,KAT)
               D2=WIFDST(JAT,LAT)
               D3=WIFDST(JAT,MAT)
               IF (D1.LT.D2.AND.D1.LT.D3) THEN
                  KILLAT=KAT
               ELSE IF (D2.LT.D1.AND.D2.LT.D3) THEN
                  KILLAT=LAT
               ELSE IF (D3.LT.D1.AND.D3.LT.D2) THEN
                  KILLAT=MAT
               END IF
            END IF



            IF (SP.EQ.2) THEN
               IF (NUM.LE.3) GOTO 10




               IF (NUM.EQ.5) THEN
                  JAT=BOUND_TO(1,IAT)
                  KAT=BOUND_TO(2,IAT)
                  LAT=BOUND_TO(3,IAT)
                  MAT=PNTAAS(IAA)+HATPRA(RESTYP(IAA))
                  IF (PROTON(JAT)) THEN
                     IF (.NOT.PROTON(KAT)) THEN
                        CALL GVSWIP (JAT,KAT)
                     ELSE IF (.NOT.PROTON(LAT)) THEN
                        CALL GVSWIP (JAT,LAT)
                     ELSE
                        CALL GVSTTE ('?M4539')
                     END IF
                  END IF
                  OOP1=WIFPL4(IAT,IAT+1,JAT,KAT)
                  OOP2=WIFPL4(IAT,IAT+1,JAT,LAT)
                  OOP3=WIFPL4(IAT,IAT+1,JAT,MAT)
                  IF (OOP1.GT.OOP2.OR.OOP1.GT.OOP3) THEN
                     KILLAT=KAT
                  ELSE IF (OOP2.GT.OOP1.OR.OOP2.GT.OOP3) THEN
                     KILLAT=LAT
                  ELSE IF (OOP3.GT.OOP1.OR.OOP3.GT.OOP2) THEN
                     KILLAT=MAT
                  END IF




               ELSE IF (NUM.EQ.4) THEN
                  JAT=BOUND_TO(1,IAT)
                  KAT=BOUND_TO(2,IAT)
                  MAT=PNTAAS(IAA)+HATPRA(RESTYP(IAA))
                  IF (PROTON(JAT)) THEN
                     IF (.NOT.PROTON(KAT)) THEN
                        CALL GVSWIP (JAT,KAT)
                     ELSE
                        CALL GVSTTE ('?M4539')
                     END IF
                  END IF
                  OOP1=WIFPL4(IAT,IAT+1,JAT,KAT)
                  OOP3=WIFPL4(IAT,IAT+1,JAT,MAT)
                  IF (OOP1.GT.OOP3) THEN
                     KILLAT=KAT
                  ELSE 
                     KILLAT=MAT
                  END IF
               END IF               
            END IF




            IF (KILLAT.GT.0) THEN
               XCOORD(KILLAT)=0.0
               YCOORD(KILLAT)=0.0
               ZCOORD(KILLAT)=0.0
               ISATOK(KILLAT)=.FALSE.
            END IF
         END IF
 10   CONTINUE
      DO 70 IAA=1,NUMAAF
         DO 60 IAT=PNTAAS(IAA),PNTAAE(IAA)
            CALL FBONDOK (IAT,JATARR,6,NUM)
            IF (NUM.GT.4) THEN
               DO 50 I1=1,NUM-4
                  CALL FBONDAOK (IAT,JATARR,6,NUMA)
                  IF (NUMA.GT.4) GOTO 60
                  CALL FBONDHOK (IAT,HATARR,6,NUMH)
                  IF (NUMA.LE.0.OR.NUMA.LE.0) GOTO 60




                  DMIN=999.9
                  MINAT=0
                  DO 40 JAT=1,NUMA
                     DO 30 HAT=1,NUMH
                        D12=WIFDST(JATARR(JAT),HATARR(HAT))
                        IF (D12.LT.DMIN) THEN
                           MINAT=HATARR(HAT)
                           DMIN=D12
                        END IF
 30                  CONTINUE
 40               CONTINUE
                  XCOORD(MINAT)=0.0
                  YCOORD(MINAT)=0.0
                  ZCOORD(MINAT)=0.0
                  ISATOK(MINAT)=.FALSE.
 50            CONTINUE
            END IF
 60      CONTINUE
 70   CONTINUE



 80   CONTINUE
      IF (NUMAAF.EQ.NUMAAT.OR.FOR3DM) GOTO 201
      SOUAD7=0
      DO 200 ISOUP=1,NUMSOU
         IF (SOUAD7.GT.1) GOTO 200
         IDRG=SOUADM(1,ISOUP)
         IF (WIFIRW(IDRG)) GOTO 200
         IF (WIFIRR(IDRG)) GOTO 200



         CHAOK=0
         CHANOK=0
         CHADIV=0



         DO 180 IAA=1,NUMAAT
            IF (WIFIRW(IAA)) GOTO 180
            IF (IDRG.EQ.IAA) GOTO 180
            IF (MODNMB(IAA).NE.MODNMB(IDRG)) GOTO 180
            IF (SOUPNT(IAA).NE.SOUPNT(IDRG)) GOTO 180
            IF (.NOT.WIF040(IAA,IDRG,2.0)) GOTO 180



            DO 160 JAT=PNTAAS(IAA),PNTAAE(IAA)
               DO 150 IAT=PNTAAS(IDRG),PNTAAE(IDRG)
                  IF (AREBOUND(IAT,JAT)) THEN
                     IF (CHANAM(IAA).EQ.CHANAM(IDRG)) THEN
                        CHAOK=CHAOK+1
                     ELSE
                        CHANOK=CHANOK+1



                        IF (CHADIV.GT.0) THEN
                           DO 140 ILOOP=1,CHADIV
                              IF (CHANAM(IDRG).EQ.CHAOTH(ILOOP)) THEN
                                 CHACNT(ILOOP)=CHACNT(ILOOP)+1
                                 GOTO 150
                              END IF
 140                       CONTINUE
                        END IF
                        CHADIV=CHADIV+1
                        CHAOTH(CHADIV)=CHANAM(IAA)
                        CHACNT(CHADIV)=1
                        SOUAD7=SOUAD7+1
                     END IF
                  END IF
 150           CONTINUE
 160        CONTINUE
 180     CONTINUE



         IF (CHANOK.GT.CHAOK) THEN
            DO 190 ILOOP=1,CHADIV
               IF (CHACNT(ILOOP).GT.CHAOK) THEN
                  CHAOK=CHACNT(ILOOP)
                  CHANAM(IDRG)=CHAOTH(ILOOP)
               END IF
 190        CONTINUE
         END IF
 200  CONTINUE
 201  CONTINUE



      DO 300 ISOUP=NUMSOU,1,-1
         IF (WIFISH(ISOUP)) THEN
            DO 290 IAT=PNTAAS(SOUADM(1,ISOUP)),PNTAAE(SOUADM(2,ISOUP))
               IF (ISATOK(IAT)) GOTO 310
 290        CONTINUE
            CALL WIFPUSHPPP (402,1)
            CALL SHOIAA (SOUADM(1,ISOUP))
            CALL DIF008 ('?M4245',SOUADM(1,ISOUP))
            CALL MOL101A (ISOUP)
            CALL WIFPOPPPP (402)
         END IF
 300  CONTINUE
 310  CONTINUE






      RETURN
      END
      SUBROUTINE MOL206





















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       WIFISR







      IF (NUMSOU.LE.1) GOTO 998
      IF (.NOT.WIFISR(1)) GOTO 998



   10 CONTINUE
      IF (WIFISR(1).AND.WIFISR(2)) THEN
         CALL MOL213 (1,2)
         IF (NUMSOU.GT.1) GOTO 10
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL207


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA
      LOGICAL       MOL009, WIFOXS







      IF (NUMSOU.LT.1) THEN
         CALL GVSTTB ('?MOLC04')
         GOTO 998
      END IF



      DO 30 ISOUP=1,NUMSOU
         IF (SOUADM(1,ISOUP).LT.1.OR.SOUADM(2,ISOUP).LT.
     +       SOUADM(1,ISOUP)) THEN
            CALL GVSTTB ('?MOLC05')
            CALL GVSCOD (' ')
            GOTO 998
         END IF



         DO 10 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
            CHAINN(1,IAA)=2
            CHAINN(2,IAA)=ISOUP
   10    CONTINUE
         CHAINN(1,SOUADM(1,ISOUP))=1
         CHAINN(1,SOUADM(2,ISOUP))=3



         IF (RESTYP(SOUADM(1,ISOUP)).GT.0) THEN
            IF (WIFOXS(SOUADM(1,ISOUP))) GOTO 30
            SOUADM(5,ISOUP)=FAMTYP(RESTYP(SOUADM(1,ISOUP)))
            IF (MOL009(ONESA3(SOUADM(1,ISOUP)))) THEN
               SOUADM(5,ISOUP)=5
               RESTYP(SOUADM(1,ISOUP))=0
            END IF
         END IF
   30 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL208 (IAA)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, ISOU, IEND, IHFAA1, IHFAA2, IHFAT1, IHFAT2
      LOGICAL       WIFISO, WIFOXS







      IF ((.NOT.FAMTYP(RESTYP(IAA)).EQ.1).AND.
     +    (.NOT.FAMTYP(RESTYP(IAA)).EQ.3).AND.
     +    (.NOT.FAMTYP(RESTYP(IAA)).EQ.6).AND.
     +    (.NOT.FAMTYP(RESTYP(IAA)).EQ.7)) GOTO 998
      IF (CHAINN(2,IAA).NE.CHAINN(2,IAA-1)) GOTO 998



      ISOU=CHAINN(2,IAA)
      IEND=SOUADM(2,ISOU)
      IHFAA1=IAA-SOUADM(1,ISOU)
      IHFAA2=SOUADM(2,ISOU)-IAA+1
      IHFAT1=PNTAAS(IAA)-PNTAAS(SOUADM(1,ISOU))
      IHFAT2=PNTAAE(SOUADM(2,ISOU))-PNTAAS(IAA)+1
      IF (IHFAA1+IHFAA2.NE.SOUADM(3,ISOU)) THEN
         CALL GVSTTB ('?MOLC53')
         GOTO 998
      END IF
      IF (IHFAT1+IHFAT2.NE.SOUADM(4,ISOU)) THEN
         CALL GVSTTB ('?MOLC53')
         GOTO 998
      END IF



      IF (NUMSOU.GT.MAXMOL-10) THEN
         CALL GVSTTI2 ('1) NUMSOU,MAXMOL=',NUMSOU,MAXMOL-10)
         CALL SHOSOU
         CALL TOOMANY ('?MOLC26')
         GOTO 998
      END IF
      IF (ISOU.LT.NUMSOU) CALL MOL112 (ISOU+1,NUMSOU,0,0,1)



      SOUADM(2,ISOU)=IAA-1
      SOUADM(3,ISOU)=SOUADM(2,ISOU)-SOUADM(1,ISOU)+1
      IF (SOUADM(3,ISOU).NE.IHFAA1) CALL GVSTTB ('?MOLC53')
      SOUADM(4,ISOU)=PNTAAE(SOUADM(2,ISOU))-PNTAAS(SOUADM(1,ISOU))+1
      IF (SOUADM(4,ISOU).NE.IHFAT1) CALL GVSTTB ('?MOLC53')
      IF (FAMTYP(RESTYP(IAA-1)).EQ.1) THEN
         SOUADM(5,ISOU)=1
      ELSE IF (FAMTYP(RESTYP(IAA-1)).EQ.3) THEN
         SOUADM(5,ISOU)=3
      ELSE IF (.NOT.WIFISO(ISOU).AND.FAMTYP(RESTYP(IAA-1)).EQ.7) THEN
         SOUADM(5,ISOU)=7
         IF (WIFOXS(SOUADM(1,ISOU))) SOUADM(5,ISOU)=4

      ELSE
         SOUADM(5,ISOU)=0
      END IF




      NUMSOU=NUMSOU+1
      ISOU=ISOU+1



      SOUADM(1,ISOU)=IAA
      SOUADM(2,ISOU)=IEND
      SOUADM(3,ISOU)=SOUADM(2,ISOU)-SOUADM(1,ISOU)+1
      IF (SOUADM(3,ISOU).NE.IHFAA2) CALL GVSTTB ('?MOLC53')
      SOUADM(4,ISOU)=PNTAAE(SOUADM(2,ISOU))-PNTAAS(SOUADM(1,ISOU))+1
      IF (SOUADM(4,ISOU).NE.IHFAT2) CALL GVSTTB ('?MOLC53')
      IF (FAMTYP(RESTYP(IAA-1)).EQ.1) THEN
         SOUADM(5,ISOU)=1
      ELSE IF (FAMTYP(RESTYP(IAA-1)).EQ.3) THEN
         SOUADM(5,ISOU)=3
      ELSE IF (.NOT.WIFISO(ISOU).AND.FAMTYP(RESTYP(IAA-1)).EQ.7) THEN
         SOUADM(5,ISOU)=7
         IF (WIFOXS(SOUADM(1,ISOU))) SOUADM(5,ISOU)=4

      ELSE
         SOUADM(5,ISOU)=0
      END IF



      CALL MOL207



  998 CONTINUE


      RETURN
      END
      LOGICAL FUNCTION MOL209(JAA1,JAA2)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       JAA1, JAA2, IAA1, IAA2
      REAL          D, DCACA2, WIFDST
      LOGICAL       WIFIRR, WIFIRA, WIFIRNO









      IF (JAA2.GT.JAA1) THEN
         IAA1=JAA1
         IAA2=JAA2
      ELSE
         IAA1=JAA2
         IAA2=JAA1
      END IF



      MOL209=.TRUE.



      IF ((.NOT.WIFIRR(IAA1)).OR.(.NOT.WIFIRR(IAA2))) THEN
         CALL GVSTTB ('?MOLC54')
         CALL SHOSOU
         CALL SHOIAA (IAA1)
         CALL SHOIAA (IAA2)
         CALL GVSCOD ('C54 at 1')
         GOTO 998
      END IF
      IF (IABS(IAA1-IAA2).NE.1) THEN
         CALL GVSTTB ('?MOLC54A')
         CALL SHOSOU
         CALL SHOIAA (IAA1)
         CALL SHOIAA (IAA2)
         CALL GVSCOD ('C54 at 2')
         GOTO 998
      END IF



      IF (PSTFLG(IAA1)) GOTO 998



      IF (CUTFLG(IAA1)) THEN
         MOL209=.FALSE.
         GOTO 998
      END IF



      IF (SOUPNT(IAA1).NE.SOUPNT(IAA2)) THEN
         MOL209=.FALSE.
         GOTO 998
      END IF



      IF (MODNMB(IAA1).NE.MODNMB(IAA2)) THEN
         MOL209=.FALSE.
         GOTO 998
      END IF



      IF ((IAA1.GT.NUMAAF.AND.RESTYP(IAA1).GT.0).OR.
     +    (IAA2.GT.NUMAAF.AND.RESTYP(IAA2).GT.0)) THEN

         MOL209=.FALSE.
         GOTO 998
      END IF




      IF (WIFIRA(IAA1).AND.WIFIRNO(IAA2)) THEN
         D=(XCOORD(PNTAAS(IAA1)+2)-XCOORD(PNTAAS(IAA2)))**2+
     +     (YCOORD(PNTAAS(IAA1)+2)-YCOORD(PNTAAS(IAA2)))**2+
     +     (ZCOORD(PNTAAS(IAA1)+2)-ZCOORD(PNTAAS(IAA2)))**2
         IF (D.LT.4.0) THEN

            MOL209=.TRUE.
            GOTO 998
         END IF
      END IF




      DCACA2=4.5**2
      IF (ONESA3(IAA1).EQ.'IAS ') DCACA2=5.3**2
      IF (FAMTYP(RESTYP(IAA1)).EQ.1.AND.
     +    FAMTYP(RESTYP(IAA2)).EQ.1) THEN
         D=(XCOORD(PNTAAC(IAA1))-XCOORD(PNTAAC(IAA2)))**2+
     +     (YCOORD(PNTAAC(IAA1))-YCOORD(PNTAAC(IAA2)))**2+
     +     (ZCOORD(PNTAAC(IAA1))-ZCOORD(PNTAAC(IAA2)))**2
         IF (D.GT.DCACA2) THEN

            MOL209=.FALSE.
            GOTO 998
         END IF
         IF (ISATOK(PNTAAS(IAA1)+2).AND.ISATOK(PNTAAS(IAA2))) THEN
            D=(XCOORD(PNTAAS(IAA1)+2)-XCOORD(PNTAAS(IAA2)))**2+
     +        (YCOORD(PNTAAS(IAA1)+2)-YCOORD(PNTAAS(IAA2)))**2+
     +        (ZCOORD(PNTAAS(IAA1)+2)-ZCOORD(PNTAAS(IAA2)))**2
            IF (D.GT.2.4**2) THEN

               MOL209=.FALSE.
               GOTO 998
            END IF
         END IF
      END IF




      IF (CHANAM(IAA1).NE.CHANAM(IAA2)) THEN

         MOL209=.FALSE.
         GOTO 998
      END IF



      IF ((FAMTYP(RESTYP(IAA1)).NE.FAMTYP(RESTYP(IAA2)))) THEN

         MOL209=.FALSE.
         GOTO 998
      END IF




      IF (FAMTYP(RESTYP(IAA1)).EQ.3.AND.
     +    FAMTYP(RESTYP(IAA2)).EQ.3) THEN
         IF (ISATOK(PNTAAS(IAA1)+2).AND.ISATOK(PNTAAS(IAA2))) THEN
            D=SQRT((XCOORD(PNTAAS(IAA1)+2)-XCOORD(PNTAAS(IAA2)))**2+
     +             (YCOORD(PNTAAS(IAA1)+2)-YCOORD(PNTAAS(IAA2)))**2+
     +             (ZCOORD(PNTAAS(IAA1)+2)-ZCOORD(PNTAAS(IAA2)))**2)
         ELSE IF (ISATOK(PNTAAS(IAA1)+1).AND.
     +       ISATOK(PNTAAS(IAA2)+5)) THEN
            D=SQRT((XCOORD(PNTAAS(IAA1)+1)-XCOORD(PNTAAS(IAA2)+5))**2+
     +             (YCOORD(PNTAAS(IAA1)+1)-YCOORD(PNTAAS(IAA2)+5))**2+
     +             (ZCOORD(PNTAAS(IAA1)+1)-ZCOORD(PNTAAS(IAA2)+5))**2)
         ELSE
            D=999.9
         END IF
         IF (D.GT.6.5) THEN

            MOL209=.FALSE.
            GOTO 998
         END IF
      END IF




      IF (FAMTYP(RESTYP(IAA1)).EQ.7.AND.
     +    FAMTYP(RESTYP(IAA2)).EQ.7) THEN
         IF (NUMNAM(IAA1).NE.NUMNAM(IAA2)) THEN

            MOL209=.FALSE.
            GOTO 998
         END IF            
         IF (ISATOK(PNTAAS(IAA1)+2).AND.ISATOK(PNTAAS(IAA2))) THEN
            D=SQRT((XCOORD(PNTAAS(IAA1)+2)-XCOORD(PNTAAS(IAA2)))**2+
     +             (YCOORD(PNTAAS(IAA1)+2)-YCOORD(PNTAAS(IAA2)))**2+
     +             (ZCOORD(PNTAAS(IAA1)+2)-ZCOORD(PNTAAS(IAA2)))**2)
         ELSE
            D=999.9
         END IF
         IF (D.GT.2.5) THEN

            MOL209=.FALSE.
            GOTO 998
         END IF
      END IF




  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL211 (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, JAT, KAT, IBND, ICON, CNT(MAXTAT)
      REAL          WIFDST, DIJPREF
      LOGICAL       WIFIRC, WIFIRB, WIFIRD, WIFIR1, WIFIRA, GVFISN,
     +              WIFIRW







      IF (WIFPAR(448).GE.1) GOTO 998
      IF (IAA.GT.NUMAAT) GOTO 998



      DO 5 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (PROTON(IAT)) THEN
            MENDLV(IAT)(1:1)=' '
            MENDLV(IAT)(2:2)='H'
         ELSE IF (MENDLV(IAT).EQ.'  ') THEN
            MENDLV(IAT)(1:1)=ONESAT(IAT)(1:1)
            MENDLV(IAT)(2:2)=ONESAT(IAT)(2:2)
         END IF
         IF (GVFISN(MENDLV(IAT)(1:1))) MENDLV(IAT)(1:1)=' '
    5 CONTINUE



      IF (WIFIRC(IAA)) THEN
         DO 6 IAT=PNTAAS(IAA),PNTAAE(IAA)
            ISATOK(IAT)=.FALSE.
    6    CONTINUE
         ISATOK(PNTAAC(IAA))=.TRUE.
         GOTO 998
      END IF



      IF (WIFIRB(IAA)) THEN
         DO 7 IAT=PNTAAS(IAA),PNTAAE(IAA)
            ISATOK(IAT)=.FALSE.
    7    CONTINUE
         ISATOK(PNTAAC(IAA))=.TRUE.
         IF (PNTAAE(IAA).GT.PNTAAS(IAA)+3) ISATOK(PNTAAS(IAA)+4)=.TRUE.
         GOTO 998
      END IF



      IF (RESTYP(IAA).NE.0) THEN
         IF (ATPRAA(RESTYP(IAA)).LE.0) THEN
            CALL GVSTTI2 ('?M4561',RESTYP(IAA),ATPRAA(RESTYP(IAA)))
            CALL SHOIAA (IAA)
         END IF
         IF (ATPRAA(RESTYP(IAA)).LE.0) THEN
            CALL GVSIT0 (CNT,PNTAAE(IAA)-PNTAAS(IAA)+1)
         ELSE
            CALL GVSIT0 (CNT,ATPRAA(RESTYP(IAA)))
         END IF
      END IF



      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (ABS(XCOORD(IAT)).GT.0.0001.OR.
     +       ABS(YCOORD(IAT)).GT.0.0001.OR.
     +       ABS(ZCOORD(IAT)).GT.0.0001) THEN
            ISATOK(IAT)=.TRUE.
            IF (WEIGHT(IAT).LT.0.0001) ISATOK(IAT)=.FALSE.
         END IF
   10 CONTINUE



      IF (PNTAAE(IAA).GT.PNTAAS(IAA)) THEN
         DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)-1
            IF (.NOT.ISATOK(IAT)) GOTO 30
            DO 20 JAT=IAT+1,PNTAAE(IAA)
               IF (.NOT.ISATOK(JAT)) GOTO 20
               IF (ABS(XCOORD(IAT)-XCOORD(JAT)).LT.0.0001.AND.
     +             ABS(YCOORD(IAT)-YCOORD(JAT)).LT.0.0001.AND.
     +             ABS(ZCOORD(IAT)-ZCOORD(JAT)).LT.0.0001) THEN
                  ISATOK(JAT)=.FALSE.
               END IF
 20         CONTINUE
 30      CONTINUE
      END IF



      IF (WIFIRD(IAA).OR.WIFIRW(IAA).OR.RESTYP(IAA).LE.0) GOTO 998



      DO 60 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (.NOT.ISATOK(IAT)) GOTO 60
         DO 50 IBND=1,8
            JAT=BOUND_TO(IBND,IAT)
            IF (JAT.LE.0) GOTO 50
            DO 40 KAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.ISATOK(KAT)) GOTO 40
               IF (ABS(XCOORD(KAT)-XCOORD(JAT)).LT.0.0001.AND.
     +             ABS(YCOORD(KAT)-YCOORD(JAT)).LT.0.0001.AND.
     +             ABS(ZCOORD(KAT)-ZCOORD(JAT)).LT.0.0001) THEN
                  ISATOK(JAT)=.FALSE.
                  GOTO 50
               END IF
   40       CONTINUE
   50    CONTINUE
   60 CONTINUE
      DO 70 IAT=PNTAAS(IAA),PNTAAE(IAA)
         JAT=BOUND_TO(1,IAT)
         IF (JAT.LE.0) GOTO 70
         KAT=BOUND_TO(2,IAT)
         IF (KAT.LE.0) GOTO 70
         IF (ABS(XCOORD(KAT)-XCOORD(JAT)).LT.0.0001.AND.
     +       ABS(YCOORD(KAT)-YCOORD(JAT)).LT.0.0001.AND.
     +       ABS(ZCOORD(KAT)-ZCOORD(JAT)).LT.0.0001) THEN
            ISATOK(JAT)=.FALSE.
         END IF
   70 CONTINUE



      DO 80 ICON=1,MAXTAT
         IF (MUTCON(1,ICON,RESTYP(IAA)).EQ.0) GOTO 81
         IAT=PNTAAS(IAA)+MUTCON(1,ICON,RESTYP(IAA))-1
         JAT=PNTAAS(IAA)+MUTCON(2,ICON,RESTYP(IAA))-1
         IF (PROTON(IAT).OR.PROTON(JAT)) GOTO 80
         DIJPREF=DSTCON(ICON,RESTYP(IAA))
         IF (ABS(DIJPREF-WIFDST(IAT,JAT)).GT.1.0) THEN
         ELSE
            CNT(MUTCON(1,ICON,RESTYP(IAA)))=
     +       CNT(MUTCON(1,ICON,RESTYP(IAA)))+1
            CNT(MUTCON(2,ICON,RESTYP(IAA)))=
     +       CNT(MUTCON(2,ICON,RESTYP(IAA)))+1
         END IF
   80 CONTINUE
   81 CONTINUE



      DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
         ISATOK(IAT)=ISATOK(IAT).AND.(CNT(PINIAA(IAT)).GE.0)
   90 CONTINUE




      IF (PNTAAS(IAA).LE.0) CALL GVSKIL
      IF (PNTAAC(IAA)+1.LE.0) CALL GVSKIL
      DO 100 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (ABS(XCOORD(IAT)).LT.0.00001.AND.
     +       ABS(YCOORD(IAT)).LT.0.00001.AND.
     +       ABS(ZCOORD(IAT)).LT.0.00001) THEN
            IF (IAT.EQ.PNTAAS(IAA).AND.ISATOK(PNTAAC(IAA)).AND.
     +          WIFIR1(IAA).AND.WIFIRA(IAA)) THEN
               GOTO 100
            ELSE IF (IAT.EQ.PNTAAC(IAA).AND.ISATOK(PNTAAS(IAA)).AND.
     +          ISATOK(PNTAAC(IAA)+1).AND.WIFIR1(IAA).AND.
     +          WIFIRA(IAA)) THEN
               GOTO 100
            ELSE
               ISATOK(IAT)=.FALSE.
            END IF
         END IF
  100 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL212



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFFIP, NUMNP, ICYS1, ICYS2, ICYS
      LOGICAL       AREBOUND







      IF (NUMAAF.LE.0) GOTO 998











      NUMCYS=0
      NUMNP=0



      DO 20 ICYS1=1,NUMAAF



         IF (RESTYP(ICYS1).NE.2) GOTO 20



         DO 10 ICYS2=1,NUMAAF



            IF (ICYS2.EQ.ICYS1.OR.RESTYP(ICYS2).NE.2) GOTO 10



            IF (AREBOUND(PNTAAS(ICYS1)+5,PNTAAS(ICYS2)+5)) THEN
               IF (NUMCYS.GE.MAXCYS) THEN
                  CALL GVSTTE ('?MOLC56')
                  GOTO 998
               END IF
               NUMCYS=NUMCYS+1
               CYSCYS(1,NUMCYS)=ICYS1
               CYSCYS(2,NUMCYS)=ICYS2



               IF (WIFPAR(84).EQ.1) THEN
                  IF (PROTON(PNTAAE(ICYS1)).AND.ISATOK(PNTAAE(ICYS1)))
     +                THEN
                     IF (WIFPAR(1105).EQ.0.AND.WIFPAR(710).EQ.0) 
     +                CALL DIF008 ('?R00302',ICYS1)
                     ISATOK(PNTAAE(ICYS1))=.FALSE.
                     XCOORD(PNTAAE(ICYS1))=0.0
                     YCOORD(PNTAAE(ICYS1))=0.0
                     ZCOORD(PNTAAE(ICYS1))=0.0
                  END IF
                  IF (PROTON(PNTAAE(ICYS2)).AND.ISATOK(PNTAAE(ICYS2)))
     +                THEN
                     IF (WIFPAR(1105).EQ.0.AND.WIFPAR(710).EQ.0) 
     +                CALL DIF008 ('?R00302',ICYS2)
                     ISATOK(PNTAAE(ICYS2))=.FALSE.
                     XCOORD(PNTAAE(ICYS2))=0.0
                     YCOORD(PNTAAE(ICYS2))=0.0
                     ZCOORD(PNTAAE(ICYS2))=0.0
                  END IF
               END IF
               GOTO 20
            END IF
   10    CONTINUE
         NUMNP=NUMNP+1
   20 CONTINUE



      DO 30 ICYS=1,MAXCYS
         IF (FRCCYS(1,ICYS).EQ.0) GOTO 998
         IF (NUMCYS.GT.0) THEN
            IF (GVFFIP(CYSCYS,FRCCYS(1,ICYS),2*NUMCYS).NE.0.OR.
     +          GVFFIP(CYSCYS,FRCCYS(2,ICYS),2*NUMCYS).NE.0) THEN
               GOTO 30
            END IF
         END IF
         IF (NUMCYS.GE.MAXCYS) THEN
            CALL GVSTTE ('?MOLC56')
            GOTO 998
         END IF
         NUMCYS=NUMCYS+1
         CYSCYS(1,NUMCYS)=FRCCYS(1,ICYS)
         CYSCYS(2,NUMCYS)=FRCCYS(2,ICYS)
         NUMCYS=NUMCYS+1
         CYSCYS(1,NUMCYS)=FRCCYS(2,ICYS)
         CYSCYS(2,NUMCYS)=FRCCYS(1,ICYS)
   30 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL213 (ISOUP1,ISOUP2)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP1, ISOUP2
      LOGICAL       GVFIBN, WIFISR







      IF ((.NOT.GVFIBN(ISOUP1,1,NUMSOU)).OR.
     +    (.NOT.GVFIBN(ISOUP2,1,NUMSOU))) THEN
         CALL GVSTTB ('?MOLC57')
      END IF
      IF ((.NOT.WIFISR(ISOUP1)).OR.(.NOT.WIFISR(ISOUP2))) THEN
         CALL GVSTTB ('?MOLC58')
         GOTO 998
      END IF



      SOUADM(2,ISOUP1)=SOUADM(2,ISOUP2)
      SOUADM(3,ISOUP1)=SOUADM(3,ISOUP1)+SOUADM(3,ISOUP2)
      SOUADM(4,ISOUP1)=SOUADM(4,ISOUP1)+SOUADM(4,ISOUP2)
      IF (ISOUP2.LT.NUMSOU) CALL MOL112 (ISOUP2+1,NUMSOU,0,0,-1)
      NUMSOU=NUMSOU-1



      CALL MOL207



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL214

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT, IBND, JAT, JBND, KAT, LAT, IAA, JAA, IERR
      REAL          WIFDST
      LOGICAL       WIFITI







      IF (WIFPAR(1113).NE.0.OR.WIFPAR(448).NE.0) GOTO 998



      DO 10 IAT=1,NUMATF
         IAA=ATIAA(IAT)
         DO 8 IBND=1,8
            JAT=BOUND_TO(IBND,IAT)
            IF (WIFITI(JAT)) THEN
               JAA=ATIAA(JAT)
               IF (SOUPNT(IAA).NE.SOUPNT(JAA).OR.
     +             MODNMB(IAA).NE.MODNMB(JAA)) THEN
                  BOUND_TO(IBND,IAT)=0
                  DO 6 JBND=1,8
                     IF (BOUND_TO(JBND,JAT).EQ.IAT) THEN
                        BOUND_TO(JBND,JAT)=0
                     END IF
 6                CONTINUE
               END IF
            END IF
 8       CONTINUE
 10   CONTINUE




      DO 20 IAT=1,NUMATF
         IF (BOUND_TO(1,IAT).LE.0) GOTO 20
         IF (BOUND_TO(1,IAT).GT.NUMATF) THEN
            CALL DIF015 (6,'BOUND_TO OOR for',IAT)
            PRINT*,'REALAT',IAT,PNTAAS(ATIAA(IAT)),PNTAAE(ATIAA(IAT)),
     +       BOUND_TO(1,IAT)
            PRINT*,'LOCAT#',IAT-PNTAAS(ATIAA(IAT))+1,
     +       BOUND_TO(1,IAT)-PNTAAS(ATIAA(IAT))+1
            CALL GVSTTI3('IAT,BOUND,NUMATF:',IAT,BOUND_TO(1,IAT),NUMATF)
            CALL GVSCOD ('MOL214 triggers BOUND_TO -> zero')
            CALL GVSIT0 (BOUND_TO,8*MAXAT)
            CALL USEDD8 (IERR)
            GOTO 21
         END IF
 20   CONTINUE
 21   CONTINUE



      DO 40 IAT=1,NUMATF



         DO 30 IBND=1,8
            IF (BOUND_TO(IBND,IAT).NE.0) THEN
               IF (.NOT.WIFITI(BOUND_TO(IBND,IAT))) GOTO 30
               IF (.NOT.ISATOK(BOUND_TO(IBND,IAT))) GOTO 30
               IF (BOUND_TO(IBND,IAT).NE.0) THEN



                  IF (WIFDST(IAT,BOUND_TO(IBND,IAT)).GT.2.5) THEN
                     CALL GVSTT6 ('?M4562')
                     CALL DIF015 (6,'?M4563',IAT)
                     CALL DIF015 (6,'?M4563',BOUND_TO(IBND,IAT))
                     BOUND_TO(IBND,IAT)=0
                  END IF
               END IF
            END IF
   30    CONTINUE
   40 CONTINUE



      DO 80 IAA=1,NUMAAT
         DO 70 IAT=PNTAAS(IAA),PNTAAE(IAA)
            DO 60 IBND=8,2,-1
               KAT=BOUND_TO(IBND,IAT)
               IF (KAT.EQ.370) THEN
                  PRINT*,'370 FOUND',IAT,ONESAT(IAT),
     +             ' :',(BOUND_TO(JAT,IAT),JAT=1,8)
               END IF
               IF (KAT.NE.0) THEN
                  DO 50 JBND=1,IBND-1
                     LAT=BOUND_TO(JBND,IAT)
                     IF (LAT.EQ.KAT) THEN
                        PRINT*,'BEFORE',IAT,ONESAT(IAT),
     +                   ' :',(BOUND_TO(JAT,IAT),JAT=1,8)
                        BOUND_TO(IBND,IAT)=0
                        PRINT*,' AFTER',IAT,ONESAT(IAT),
     +                   ' :',(BOUND_TO(JAT,IAT),JAT=1,8)
                     END IF
                     GOTO 50
 50               CONTINUE
               END IF
 60         CONTINUE
 70      CONTINUE
 80   CONTINUE



      DO 120 IAA=1,NUMAAT
         DO 110 IAT=PNTAAS(IAA),PNTAAE(IAA)
            DO 100 IBND=1,7
               IF (BOUND_TO(IBND,IAT).EQ.0) THEN
                  DO 90 JBND=IBND+1,8
                     IF (BOUND_TO(JBND,IAT).NE.0) THEN
                        BOUND_TO(IBND,IAT)=KAT
                        BOUND_TO(JBND,IAT)=0
                        GOTO 100
                     END IF
 90               CONTINUE
               END IF
 100        CONTINUE
 110     CONTINUE
 120  CONTINUE



  998 CONTINUE

                        
      RETURN
      END   
      SUBROUTINE MOL215

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INTEGER       IAA, IBND,IAT,  JAT, JAA, IAT1, IAT2, IAT3, IAT4, 
     +              IAT5, IAT6, ISOUP, IERR
      REAL          WIFDST, ANGL1, ANGL2, CHI001, DOXT
      LOGICAL       WIFIRA, WIFIR3, WIFIRO, WIFIRN, WIFISH, WIFIR1,
     +              OXTOUT, T54EQUAL, XYZNUL







      IF (NUMAAF.LE.1) GOTO 998
      IF (WIFPAR(1071).NE.0) GOTO 998




      CALL MOL207




      CALL WIFPUSHPPP (111,1)
      DO 20 IAA=1,NUMAAF-1
         IF (.NOT.WIFIRA(IAA)) GOTO 20
         IF (.NOT.WIFIRA(IAA+1)) GOTO 20
         IF (WIFIR3(IAA)) GOTO 20
         IF (WIFDST(PNTAAC(IAA)+1,PNTAAS(IAA+1)).GT.2.5) GOTO 20
         DO 10 IBND=8,1,-1
            JAT=BOUND_TO(IBND,PNTAAC(IAA)+1)
            IF (JAT.NE.0) THEN
               JAA=ATIAA(JAT)
               IF (WIFIRO(JAA)) THEN
                  IF (RESTYP(JAA).LE.0) RESTYP(JAA)=RESTYP(IAA)
                  CALL MOL307C (IAA,IERR)
                  WIFPAR(154)=1
               END IF
            END IF
   10    CONTINUE
   20 CONTINUE 





      DO 80 IAA=NUMAAT,NUMAAF,-1



         IF (WIFIRO(IAA)) THEN
            ISOUP=CHAINN(2,IAA)
            IAT=PNTAAS(IAA)






            DO 60 IBND=1,8
               IF (BOUND_TO(IBND,IAT).NE.0) GOTO 80
 60         CONTINUE





            DO 70 JAA=1,NUMAAF
               IF (WIFDST(PNTAAS(JAA)+2,IAT).LT.2.0) GOTO 80
 70         CONTINUE






            IF (WIFPAR(919).EQ.0) CALL SHOWTEXT ('?M2398')




            OXTOUT=.FALSE.
            DO 75 JAA=1,NUMAAF
               IF (WIFIR3(JAA).AND.MODNMB(JAA).EQ.MODNMB(IAA).AND.
     +             CHANAM(JAA).EQ.CHANAM(IAA)) THEN
                  IF (ISATOK(PNTAAS(JAA)+2)) THEN
                     DOXT=WIFDST(IAT,PNTAAS(JAA)+2)
                     PRPVAL(JAA)=DOXT
                     CALL SHOIAA (JAA)
                     PRPVAL(JAA)=0.0
                     OXTOUT=.TRUE.
                  END IF
               END IF
 75         CONTINUE



            CALL MOL101A (ISOUP)
            CALL MOL200
            WIFPAR(154)=1



            IF (.NOT.OXTOUT) CALL GVSTT6 ('?M2410')
         END IF
 80   CONTINUE
      CALL WIFPOPPPP (111)




      DO 100 IAA=1,NUMAAF
         IF (.NOT.WIFIRA(IAA)) GOTO 100
         IF (.NOT.WIFIR3(IAA)) GOTO 100
         IAT1=PNTAAS(IAA)
         IAT2=PNTAAS(IAA)+1
         IAT3=PNTAAS(IAA)+2
         IAT4=PNTAAS(IAA)+3
         IAT5=BOUND_TO(1,IAT3)
         IF (IAT5.LE.0) GOTO 100
         IF (XYZNUL(IAT5)) GOTO 100
         IF (BOUND_TO(1,IAT4).NE.0) GOTO 100
         IF (BOUND_TO(2,IAT5).NE.0) GOTO 90
         IF ((.NOT.ISATOK(IAT1)).OR.(.NOT.ISATOK(IAT2)).OR.
     +       (.NOT.ISATOK(IAT3)).OR.(.NOT.ISATOK(IAT4)).OR.
     +       (.NOT.ISATOK(IAT5))) GOTO 100
         ANGL1=CHI001(IAT1,IAT2,IAT3,IAT4)
         ANGL2=CHI001(IAT1,IAT2,IAT3,IAT5)
         IF (ABS(ANGL1).GT.ABS(ANGL2)) THEN
            CALL HAS017A (IAT4,IAT5)
         END IF



   90    CONTINUE
         IF (WIFPAR(84).EQ.1) THEN
            IF (IAT5.NE.0) THEN
               IAT6=BOUND_TO(1,IAT4)
               IF (IAT6.NE.0) THEN
                  IF (BOUND_TO(1,IAT4).EQ.0) THEN
                     CALL HAS017A (IAT4,IAT5)
                  END IF
               END IF
            END IF
         END IF
  100 CONTINUE




      DO 110 ISOUP=1,NUMSOU
         IF (SOUADM(4,ISOUP).EQ.1.AND.WIFISH(ISOUP)) THEN
            IAT1=PNTAAS(SOUADM(1,ISOUP))
            IF (.NOT.ISATOK(IAT1)) GOTO 110
            IF (.NOT.PROTON(IAT1)) CALL GVSKIL
            IAT2=BOUND_TO(1,IAT1)
            IF (IAT2.LE.0) GOTO 110
            IF (WIFIRO(ATIAA(IAT2))) THEN
               CALL GVSSTX (ONESAT(IAT1)(1:2),' H')
               ONESAT(IAT1)(3:3)=''''
               ONESAT(IAT1)(4:4)=''''
            ELSE IF (WIFIRN(ATIAA(IAT2))) THEN
               IF (ONESAT(IAT2)(1:3).EQ.' O5'.AND.
     +             ONESAT(IAT2)(4:4).EQ.'''') THEN
                  CALL GVSSTX (ONESAT(IAT1)(2:4),'HO5')
                  ONESAT(IAT1)(1:1)=''''
               ELSE IF (ONESAT(IAT2)(1:3).EQ.' O3'.AND.
     +             ONESAT(IAT2)(4:4).EQ.'''') THEN
                  CALL GVSSTX (ONESAT(IAT1)(2:4),'HO3')
                  ONESAT(IAT1)(1:1)=''''
               END IF
            END IF
         END IF
  110 CONTINUE




      DO 120 ISOUP=1,NUMSOU



         IF (WIFISH(ISOUP)) THEN



            IF (SOUADM(4,ISOUP).NE.2) GOTO 120
            IAT=PNTAAS(SOUADM(1,ISOUP))
            IF (T54EQUAL(ONESAT(IAT),' H2 ').AND.
     +       T54EQUAL(ONESAT(IAT+1),' H3 ')) GOTO 120
            JAT=BOUND_TO(1,IAT)
            IF (JAT.LE.0) GOTO 120
            IF (.NOT.WIFIR1(ATIAA(JAT))) GOTO 120
            IF (JAT.EQ.BOUND_TO(1,IAT+1).OR.
     +          WIFDST(JAT,IAT+1).LT.1.3) THEN



               CALL GVSSTX (ONESAT(IAT),' H2 ')
               CALL GVSSTX (ONESAT(IAT+1),' H3 ')
               WIFPAR(154)=1
            END IF
         END IF
  120 CONTINUE




  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL216

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOU, IAT, IAA, JAT, JAA, IBND
      LOGICAL       FOUND, WIFIRO, WIFIRW, WIFIR3, WIFIRA







      FOUND=.FALSE.



      IF (WIFPAR(84).NE.0) THEN 
         DO 20 ISOU=1,NUMSOU
            IF (SOUADM(5,ISOU).EQ.5) THEN
               DO 10 IAT=PNTAAS(SOUADM(1,ISOU)),PNTAAE(SOUADM(2,ISOU))
                  IF (.NOT.PROTON(IAT)) THEN
                     CALL GVSSTX (ONESAT(IAT),SPCATM(6))
                     IF (WIFPAR(84).NE.0) THEN
                        IF (PROTON(IAT+1)) THEN
                           CALL GVSSTX (ONESAT(IAT+1),SPCATM(7))
                           IF (PROTON(IAT+2)) THEN
                              CALL GVSSTX (ONESAT(IAT+2),SPCATM(8))
                           END IF
                        END IF
                     END IF
                  END IF
 10            CONTINUE
            END IF
 20      CONTINUE
      END IF



      DO 40 IAA=MAX(1,NUMAAF),NUMAAT
         IF (WIFIRO(IAA)) THEN
            IAT=PNTAAS(IAA)
            DO 30 IBND=1,8
               JAT=BOUND_TO(IBND,IAT)
               IF (JAT.NE.0) THEN
                  JAA=ATIAA(JAT)
                  CALL GVSSTX (ONEORG(IAA),ONESA3(JAA))
                  CALL GVSSTX (ONESAT(IAT),SPCATM(5))
               END IF
   30       CONTINUE
         END IF
   40 CONTINUE



      DO 50 IAA=1,NUMAAT
         IF (ONEORG(IAA).EQ.'    ') THEN
            CALL GVSSTX (ONEORG(IAA),ONESA3(IAA))
            IF (.NOT.WIFIRW(IAA)) THEN
               FOUND=.TRUE.
            END IF
         END IF
   50 CONTINUE



      FOUND=.FALSE.
      DO 60 IAA=1,NUMAAT
         IF (ONESA3(IAA).EQ.'    ') THEN
            FOUND=.TRUE.
            CALL GVSSTX (ONESA3(IAA),ONEORG(IAA))
         END IF
   60 CONTINUE
      IF (FOUND) THEN
         FOUND=.FALSE.
         CALL GVSTTB ('?M2149')
      END IF



      DO 80 IAA=1,NUMAAF
         IF (WIFIRA(IAA)) THEN
            IF (WIFIR3(IAA)) THEN
               IAT=PNTAAS(IAA)+3
               DO 70 IBND=1,8
                  JAT=BOUND_TO(IBND,IAT)
                  IF (JAT.NE.0) THEN
                     JAA=ATIAA(JAT)
                     IF (WIFIRO(JAA)) THEN
                        CALL GVSSTX (ONESAT(PNTAAS(IAA)+3),SPCATM(4))
                        GOTO 80
                     END IF
                  END IF
 70            CONTINUE
            END IF
         END IF
 80   CONTINUE








































      RETURN
      END
      SUBROUTINE MOL217

















      IMPLICIT      NONE
      INCLUDE       'LABELS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ILAB, NLAB, ILAB1, ILAB2, GVFCBT, GVFLEN, MLAB
      LOGICAL       KILLAB(MAXLAB)
      EQUIVALENCE   (KILLAB(1),ESPACE(50001))







      CALL ESPSET (5001,5001+MAXLAB,27)



      CALL GVSBTF (KILLAB,MAXLAB)



      DO 10 ILAB=1,MAXLAB
         IF (GVFLEN(LABTXT(ILAB)).EQ.0) THEN
            NLAB=ILAB-1
            GOTO 11
         END IF
   10 CONTINUE
      NLAB=MAXLAB
   11 CONTINUE
      IF (NLAB.LE.1) GOTO 998



      DO 30 ILAB1=1,NLAB-1
         DO 20 ILAB2=ILAB1+1,NLAB
            IF (ABS(XIDA(1,ILAB1)-XIDA(1,ILAB2)).LT.0.01.AND.
     +          ABS(XIDA(2,ILAB1)-XIDA(2,ILAB2)).LT.0.01.AND.
     +          ABS(XIDA(3,ILAB1)-XIDA(3,ILAB2)).LT.0.01) THEN
               KILLAB(ILAB2)=.TRUE.
            END IF
   20    CONTINUE
   30 CONTINUE
      IF (GVFCBT(KILLAB,NLAB).LE.0) GOTO 998



      MLAB=NLAB
      DO 50 ILAB1=MLAB,1,-1
         IF (KILLAB(ILAB1)) THEN
            IF (ILAB1.LT.NLAB) THEN
               DO 40 ILAB2=ILAB1,NLAB-1
                  XIDA(1,ILAB2)=XIDA(1,ILAB2+1)
                  XIDA(2,ILAB2)=XIDA(2,ILAB2+1)
                  XIDA(3,ILAB2)=XIDA(3,ILAB2+1)
                  LABTXT(ILAB2)=LABTXT(ILAB2+1)
                  KILLAB(ILAB2)=KILLAB(ILAB2+1)
   40          CONTINUE
            END IF
            CALL GVSRT0 (XIDA(1,NLAB),3)
            CALL GVSCTB (LABTXT(NLAB),MAXLLN)
            NLAB=NLAB-1
         END IF
   50 CONTINUE



  998 CONTINUE


      RETURN
      END   

      SUBROUTINE MOL219

















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







      IERR=0



      DO 20 IAA=1,NUMAAT
         HASALT(IAA)=.FALSE.
         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ALALAT(IAT).NE.' ') THEN
               HASALT(IAA)=.TRUE.
               IF (WIFPAR(329).NE.0) PRINT*,'ALT NUM,PNT',
     +          ALALAT(IAT),ONESAT(IAT),ONESA3(IAA),ORGNAM(IAT)
            END IF
 10      CONTINUE
 20   CONTINUE



      IF (ALT100(IERR).LE.0) GOTO 998



      DO 270 IAA=1,NUMAAT
         HASALT(IAA)=.FALSE.
         DO 260 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ALALAT(IAT).NE.' ') THEN
               HASALT(IAA)=.TRUE.
               GOTO 270
            END IF
 260     CONTINUE
 270  CONTINUE



  998 CONTINUE


      RETURN
      END   

      SUBROUTINE MOL220

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, JAA, ICNT
      LOGICAL       MOL221, WIFIRW, CH4EQCH4







      IF (NUMAAT.LE.1) GOTO 998



      ICNT=0



      DO 100 IAA=1,NUMAAT-1
         DO 90 JAA=IAA+1,NUMAAT
            IF (CHAINN(2,IAA).EQ.CHAINN(2,JAA)) GOTO 90
            IF (CH4EQCH4(ONESA3(IAA),ONESA3(JAA))) GOTO 90
            IF (NUMNAM(IAA).NE.NUMNAM(JAA)) GOTO 90
            IF (CHANAM(IAA).NE.CHANAM(JAA)) GOTO 90
            IF (MODNMB(IAA).NE.MODNMB(JAA)) GOTO 90
            IF (WIFIRW(IAA).OR.WIFIRW(JAA)) GOTO 90
            IF (MOL221(IAA,JAA)) GOTO 90



            CALL MOL353
            ICNT=ICNT+1
            IF (ICNT.GE.5) THEN
               CALL GVSTT6 ('WARNING Check chain names for uniqueness')
               GOTO 998
            END IF
   90    CONTINUE
  100 CONTINUE



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION MOL221(IAA,JAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, JAA, IAT, IBND
      LOGICAL       GVFIBN







      IF (IAA.EQ.JAA) THEN
         MOL221=.TRUE.
         GOTO 998
      END IF



      MOL221=.FALSE.



      DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
         DO 10 IBND=1,8
            IF (GVFIBN(BOUND_TO(IBND,IAT),PNTAAS(JAA),PNTAAE(JAA))) THEN
               MOL221=.TRUE.
            END IF
 10      CONTINUE
 20   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL222

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFPOS, IAA, IAT, JAT, TEMP
      LOGICAL       WIFIRA, WIFIR1







      IF (WIFPAR(84).LE.0) GOTO 998



      DO 10 IAA=1,NUMAAF
         IF (WIFIR1(IAA).AND.WIFIRA(IAA)) THEN
            IAT=BOUND_TO(1,PNTAAS(IAA))
            JAT=BOUND_TO(2,PNTAAS(IAA))
            IF (IAT.NE.0.AND.JAT.NE.0) THEN
               CALL SHOIAA (IAA)
               CALL MOL010 ('Before')  
               PRINT*,ONESAT(IAT),GVFPOS(ONESAT(IAT),'3')
               PRINT*,ONESAT(JAT),GVFPOS(ONESAT(JAT),'2')
               IF (GVFPOS(ONESAT(IAT),'3').NE.0.AND.
     +             GVFPOS(ONESAT(JAT),'2').NE.0) THEN
                  TEMP=BOUND_TO(1,IAT)
                  BOUND_TO(1,IAT)=BOUND_TO(2,IAT)
                  BOUND_TO(2,IAT)=TEMP
               END IF
               CALL SHOIAA (IAA)
               CALL MOL010 ('After')  
            END IF
         END IF
 10   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL223

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, JAA, JAT, IBND, KAT, ISOUP, IERR
      REAL          WIFDST, DIJ
      LOGICAL       AREBOUND, WIFIR1, WIFIRA, WIFISH, GVFRIN







      IF (WIFPAR(84).LE.0) GOTO 998







      DO 10 IAA=1,NUMAAF
         IF (WIFIRA(IAA)) THEN
            IAT=PNTAAS(IAA)+HATPRA(RESTYP(IAA))
            IF (WIFIR1(IAA)) THEN
               IF (BOUND_TO(1,PNTAAS(IAA)).NE.0) THEN
                  CALL GVSSTX (ONESAT(IAT),' H   ')
               END IF
            ELSE IF (ONESAT(IAT).EQ.' H1  ') THEN
               CALL GVSSTX (ONESAT(IAT),' H   ')
            END IF
         END IF
 10   CONTINUE



      DO 100 IAA=1,NUMAAT
         IF (WIFIR1(IAA).AND.WIFIRA(IAA)) GOTO 100
         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.ISATOK(IAT).OR.PROTON(IAT)) GOTO 90
            DO 80 IBND=1,8
               JAT=BOUND_TO(IBND,IAT)
               IF (JAT.LE.0) GOTO 80
               IF (.NOT.ISATOK(JAT).OR.PROTON(JAT)) GOTO 80
               JAA=ATIAA(JAT)



               DO 70 KAT=PNTAAS(IAA),PNTAAE(IAA)
                  IF (KAT.EQ.IAT.OR.KAT.EQ.JAT) GOTO 70
                  IF (.NOT.PROTON(KAT)) GOTO 70
                  IF (AREBOUND(IAT,KAT)) THEN
                     IF (WIFDST(JAT,KAT).LT.1.5) THEN
                        ISATOK(KAT)=.FALSE.
                        ATTVL2(KAT)=77.777
                     END IF
                  END IF
 70            CONTINUE
 80         CONTINUE
 90      CONTINUE
 100  CONTINUE



      DO 200 ISOUP=1,NUMSOU
         IF (WIFISH(ISOUP)) THEN
            IAA=SOUADM(1,ISOUP)
            DO 190 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (BOUND_TO(1,IAT).NE.0) GOTO 200
               DO 180 JAA=1,NUMAAT
                  IF (JAA.EQ.SOUADM(1,ISOUP)) GOTO 180
                  DO 170 JAT=PNTAAS(JAA),PNTAAE(JAA)
                     DIJ=WIFDST(IAT,JAT)
                     IF (GVFRIN(DIJ,0.75,1.25)) THEN
                        CALL SETBOUNDTO (IAT,JAT,IERR)
                        GOTO 190
                     END IF
 170              CONTINUE
 180           CONTINUE
 190        CONTINUE
         END IF
 200  CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL224 (DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, JAA, IAT, JAT1, JAT2
      REAL          WIFDST, DI1, DI2
      LOGICAL       WIFITD, AREBOUND, AREB13, DONE







      DONE=.FALSE.



      DO 100 IAA=1,NUMAAF
         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)



            IF (BOUND_TO(2,IAT).NE.0) THEN
               JAT1=BOUND_TO(1,IAT)
               JAT2=BOUND_TO(2,IAT)



               JAA=ATIAA(JAT1)
               IF (JAA.EQ.IAA) GOTO 90
               IF (ATIAA(JAT2).EQ.IAA) GOTO 90



               IF (WIFITD(JAT1).AND.WIFITD(JAT2)) THEN



                  IF (AREBOUND(JAT1,JAT2).OR.AREB13(JAT1,JAT2,1)) THEN
                     CALL DIF015A (IAT,'Bound to 2 drug atoms:')
                     DI1=WIFDST(IAT,JAT1)
                     DI2=WIFDST(IAT,JAT2)
                     CALL DIF013 (6,JAT1,DI1)
                     CALL DIF013 (6,JAT2,DI2)



                     IF (DI2.GT.DI1) THEN
                        NOBIAT(JAT2)=.TRUE.
                        CALL DIF015A (JAT2,' First bond removed')
                     ELSE
                        NOBIAT(JAT1)=.TRUE.
                        CALL DIF015A (JAT1,' Second bond removed')
                     END IF
                     CALL GVSNL6 (1)
                     DONE=.TRUE.
                  END IF
               END IF
            END IF
 90      CONTINUE
 100  CONTINUE





      RETURN
      END   
