



      SUBROUTINE MOL001


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR







      IF (WIFPAR(1510).EQ.1) THEN
         CALL SHOWTEXT ('?R00300')
         GOTO 998
      END IF



      CALL MOL700 (' ',IERR)
      IF (IERR.NE.0) GOTO 998



      CALL MOL007



      CALL MOL002



  998 CONTINUE
      CALL KLONKCLEAN


      RETURN
      END
      SUBROUTINE MOL002



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ANISOU.INC'
      INTEGER       NUMDN1, IERR
      LOGICAL       GVFFOP







      WIFPAR(144)=0
      WIFPAR(927)=0
      WIFPAR(462)=0
      CALL WIFPUSHPPP (1176,1)



      IF (.NOT.GVFFOP(11)) THEN
         CALL GVSTTB ('?MOLC49')
         GOTO 998
      END IF




      CALL MOL703 (IERR)
      IF (IERR.NE.0) GOTO 998





      CALL WIFPUSHPPP (269,1)
      CALL WIFPUSHPPP (1052,0)
      CALL MOL003 (NUMDN1,IERR)
      CALL WIFPOPPPP (1052)
      CALL WIFPOPPPP (269)
      IF (IERR.NE.0) GOTO 998
      IF (NUMDN1.EQ.0.AND.WIFPAR(75).EQ.0) CALL GVSTT6 ('?MOLC39')




      IF (WIFPAR(1510).LE.0) THEN
         CALL WIFPUSHPPP (269,1)
         CALL WIFPUSHPPP (1052,0)
         CALL KLONKDOWN
         CALL WIFPOPPPP (1052)
         CALL WIFPOPPPP (269)
      ELSE
         CALL GVSTTE ('?M2794')
      END IF



      CALL KLONKEND
      CALL KLONKCLEAN
      CALL GVSCLF (11)
      CALL GVSCLF (13)
      CALL MOL200




      CALL MOL042




      CALL USEDD1












  998 CONTINUE
      CALL WIFPOPPPP (1176)



      RETURN
      END
      SUBROUTINE MOL002A

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ANISOU.INC'
      INTEGER       NUMDN1, IERR







      CALL WIFPUSHPPP (75,1)
      CALL WIFPUSHPPP (269,1)
      CALL WIFPUSHPPP (1052,0)



      CALL GVSCLF (11)
      CALL GETFILE (11,' ','SELF.PDB',IERR)
      IF (IERR.NE.0) GOTO 998



      CALL KLONKSTART (IERR)
      IF (IERR.NE.0) GOTO 998




      CALL MOL703 (IERR)
      IF (IERR.NE.0) GOTO 998





      CALL MOL003 (NUMDN1,IERR)
      IF (IERR.NE.0) GOTO 998



      CALL KLONKDOWN
      CALL KLONKEND












  998 CONTINUE
      CALL WIFPOPPPP (1052)
      CALL WIFPOPPPP (269)
      CALL WIFPOPPPP (75)
      CALL GVSCLF (11)
      CALL GVSCLF (12)
      CALL GVSCLF (13)
      CALL MOL200


      RETURN
      END
      SUBROUTINE GETENT (IHSKIP,IUNIT,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IHSKIP, IUNIT, IW491, IW846, I, IT, GVFLFI,
     +              ITTLST, ITTTO

      LOGICAL       GVFFOP, KLONKEXIST, JUMP, ISOXT, ISWAT, MOL009, X
      CHARACTER*80  LOCLIN
      SAVE          ITTLST







      IF (.NOT.GVFFOP(IUNIT)) THEN
         CALL GVSTTI ('?MOLB10',IUNIT)
         IERR=1
         GOTO 998
      END IF
      IF (.NOT.KLONKEXIST()) THEN
         IERR=1
         GOTO 998
      END IF



      ITTTO=MAX(ITT,ITTLST)
      IF (ITTTO.GE.1) THEN
         DO 2 IT=1,ITTTO
            DO 1 I=1,80
               READIN(IT)(I:I)=' '
               READN2(IT)(I:I)=' '
 1          CONTINUE
 2       CONTINUE
      END IF
      ITT=0
      ITTLST=0



      CALL MOL056 (IERR)



      WIFPAR(1506)=-1



   10 CONTINUE



         CALL PDBLIN (LOCLIN,IUNIT,IERR)








         IF (IERR.EQ.2) GOTO 900
         IF (IERR.EQ.1) GOTO 999



         IF (LOCLIN(1:5).EQ.'KLONK') THEN
            IF (ITT.LE.0) THEN
               CALL GVSFMT ('?FMT504')
               READ (LOCLIN,FMT,ERR=998) WIFPAR(491),WIFPAR(846)



               GOTO 10
            ELSE
               CALL GVSFMT ('?FMT504')
               READ (LOCLIN,FMT,ERR=998) IW491,IW846



               IERR=0
               GOTO 900
            END IF
         END IF
         IF (LOCLIN(1:5).EQ.'EMPTY'.OR.LOCLIN(1:3).EQ.'TER'.OR.
     +       LOCLIN(1:3).EQ.'END') THEN
            IF (ITT.LE.0) GOTO 10
            GOTO 900
         END IF
         IF (LOCLIN(1:5).EQ.'MODEL') THEN
            IF (ITT.GT.0) THEN
               IF (IUNIT.EQ.11) THEN
                  PDBPNT=PDBPNT-1
               ELSE IF (IUNIT.EQ.13) THEN
                  MCFPNT=MCFPNT-1
               ELSE
                  CALL GVSTTI ('?M2723',IUNIT)
               END IF
               IERR=0
               GOTO 900
            END IF
            I=GVFLFI(1,WIFPAR(846),LOCLIN(1:40))


            IF (IUNIT.EQ.11)CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
            IF (I.NE.1) THEN
               CALL GVSTTE ('?M2724')
               CALL GVSTT6 (LOCLIN)
               IERR=1
               GOTO 999
            END IF
         END IF
         IF (LOCLIN(1:4).NE.'ATOM'.AND.LOCLIN(1:6).NE.'HETATM') GOTO 10







         DO 11 I=1,80
            LOCDN2(I:I)=' '
 11      CONTINUE
         CALL MOL003C (LOCLIN,IERR)
         IF (IERR.NE.0) THEN


            GOTO 10
         END IF
         ISWAT=MOL009(THISAA).OR.MOL009(THISOA).OR.MOL009(THISNM)
         ISOXT=(THISAT.EQ.SPCATM(5).AND.THISFAM.EQ.1)











         CALL MOL061 (IUNIT,IHSKIP,JUMP)
         IF (JUMP) THEN


            GOTO 10
         END IF



         ITT=ITT+1
         ITTLST=ITT
         IF (ITT.EQ.1) THEN



            IF (THISNM.EQ.LASTNM.AND.THISAA.EQ.LASTAA.AND.
     +          THISIC.EQ.LASTIC.AND.THISCH.EQ.LASTCH) THEN
               CALL GVST6C ('?MOLB14',LASTNM,.FALSE.)
               CALL SHOWTEXT ('?MOLB13')
            END IF



            IF (ISOXT) THEN



                  READIN(ITT)=LOCLIN

               CALL MOL056 (IERR)
               IERR=0
               GOTO 900
            END IF
         END IF



         IF (ISWAT) THEN
            X=(LASTAA.EQ.'$$$$'.OR.(LASTAA.EQ.THISAA
     +       .AND.LASTCH.EQ.THISCH.AND.LASTIC.EQ.THISIC).AND.
     +       (.NOT.(ISOXT.AND.IUNIT.EQ.13)))
         ELSE
            X=(LASTAA.EQ.'$$$$'.OR.(LASTNM.EQ.THISNM.AND.
     +       LASTAA.EQ.THISAA.AND.LASTCH.EQ.THISCH.AND.
     +       LASTIC.EQ.THISIC).AND.(.NOT.(ISOXT.AND.IUNIT.EQ.13)))
         END IF


         IF (X) THEN



               READIN(ITT)=LOCLIN










               LASTNM=THISNM

            LASTAT=THISAT







               LASTAA=THISAA

            LASTAL=THISAL
            LASTCH=THISCH
            LASTIC=THISIC



            IF (THISFAM.EQ.3) THEN
               IF (THISAT.EQ.' O2*'.OR.THISAT.EQ.'O2* '.OR.
     +          (THISAT(1:3).EQ.' O2'.AND.THISAT(4:4).EQ.'''').OR.
     +          (THISAT(1:2).EQ.'O2'.AND.THISAT(3:3).EQ.'''').AND.
     +          THISAT(4:4).EQ.' ')  WIFPAR(1506)=0
            ELSE
               WIFPAR(1506)=0
            END IF



            GOTO 10
         ELSE
            IF (IUNIT.EQ.11) THEN
               PDBPNT=PDBPNT-1
            ELSE IF (IUNIT.EQ.13) THEN
               MCFPNT=MCFPNT-1
            ELSE
               CALL GVSTTI ('?M3367',IUNIT)
            END IF
            ITT=ITT-1
            ITTLST=ITT
            IERR=0
            GOTO 900
         END IF




      IERR=2




  900 CONTINUE




      IF (IERR.NE.1.AND.ITT.GT.1) THEN
         CALL MOL060




           IF (WIFPAR(334).EQ.0) CALL ALT003




      END IF
      WIFPAR(1506)=-WIFPAR(1506)
      IF (IERR.EQ.3) IERR=0


      GOTO 998



  999 CONTINUE
      CALL GVSTTE ('?CHIB18')
      IERR=1
      CALL GVSCLF (11)
      CALL GVSCLF (13)
      CALL MOL200



  998 CONTINUE


      RETURN
      END
      SUBROUTINE PDBLIN (LOCLIN,IUNIT,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IUNIT, I
      CHARACTER*80  LOCLIN
      LOGICAL       GVFFOP







      IF (.NOT.GVFFOP(IUNIT)) THEN
         CALL GVSTTB ('?M0966')
         CALL GVSKIL
         GOTO 999
      END IF



      IERR=0
      DO 10 I=1,80
         LOCLIN(I:I)=' '
 10   CONTINUE



      IF (IUNIT.EQ.11) THEN
         PDBPNT=PDBPNT+1
         IF (PDBPNT.GT.PDBCNT(1)) GOTO 100
         READ (12,REC=PDBPNT,ERR=999) LOCLIN



      ELSE
         MCFPNT=MCFPNT+1
         IF (MCFPNT.GT.MCFCNT(1)) GOTO 100
         READ (13,REC=MCFPNT,ERR=999) LOCLIN


      END IF




      IF (LOCLIN(1:4).NE.'ATOM') THEN
         IF (WIFPAR(69).NE.0) CALL GVST6C ('69:',LOCLIN,.TRUE.)
      END IF
      GOTO 998



  100 CONTINUE


      IERR=2
      GOTO 998



  999 CONTINUE
      CALL GVSTTE ('?M3368')
      IERR=1



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SETALT (IAT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAT







      IF (ABS(THISX).LT.0.0001.AND.ABS(THISY).LT.0.0001.AND.
     + ABS(THISZ).LT.0.0001) GOTO 998
      IF (LOCDN2(1:10).EQ.'          ') GOTO 998



      ALTX(IAT)=THISAX
      ALTY(IAT)=THISAY
      ALTZ(IAT)=THISAZ
      ALTXBF(IAT)=THISAB
      ALTWGT(IAT)=THISAW
      ALALAT(IAT)=THISLA
      IF (ALALAT(IAT).EQ.' ') ALALAT(IAT)='!'



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL003 (NUMDON,IERR)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, NUMDON, LOCAAF, IHSKIP, I

      LOGICAL       GVFFOP
      CHARACTER*80  LOCLIN







      WIFPAR(1504)=WIFPAR(1504)+1



      CALL ESPSET (1,21001,27)



      NUMDON=0
      IERR=0
      IF (.NOT.GVFFOP(11)) THEN
         CALL GVSTTB ('?MOLB05')
         CALL GVSKIL
         IERR=1
         GOTO 998
      END IF










      LOCAAF=0
      IHSKIP=0
      WIFPAR(1030)=0
      WIFPAR(1174)=NUMAAT
      WIFPAR(1175)=NUMATF
      WIFPAR(1185)=0
      WIFPAR(1186)=0
      WIFPAR(1276)=0
      CALL WIFPUSHPPP (1176,1)
      CALL GVSCTB (READIN,80*MAXRIN)
      CALL GVSCTB (READN2,80*MAXRIN)



      CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)



      CALL WIFPUSHPPP (1071,1)




      ITT=0
 10   CONTINUE
         CALL MOL059 (IERR)
         IF (IERR.NE.0) GOTO 20



         CALL GETENT (IHSKIP,11,IERR)
         IF (ITT.LE.0.AND.IERR.NE.0) GOTO 20
         IF (IERR.EQ.1) THEN
            CALL SHOWTEXT ('?MOLB07')
            GOTO 20
         END IF




         DO 15 I=1,ITT+2
            USED(I)=.FALSE.
 15      CONTINUE
         CALL MOL003A (LOCAAF,NUMDON)
      GOTO 10



 20   CONTINUE
      IERR=0
      IF (LOCAAF.EQ.0) THEN
         IF (WIFPAR(75).EQ.0) CALL SHOWTEXT ('?MOLNPD')
      ELSE
         IF (NUMAAF.GT.0) THEN
            IF (MOD(LOCAAF,10).NE.0) THEN
               CALL GVSFMT ('?FMT243')
               WRITE (LOCLIN,FMT,ERR=700)
     +          LOCAAF-MOD(LOCAAF,10)+1,LOCAAF,(ONESA3(I),
     +          I=LOCAAF-MOD(LOCAAF,10)+1,LOCAAF)
               IF (WIFPAR(642).EQ.0.AND.WIFPAR(363).EQ.0) CALL GVSTT6 
     +          (LOCLIN)
            END IF
         END IF
      END IF



      IF (WIFPAR(84).EQ.0.AND.WIFPAR(919).EQ.0) THEN
         IF (IHSKIP.GT.0) CALL GVSTTI ('?MOLC25',IHSKIP)
      END IF



      IF (WIFPAR(1186).GT.0) CALL GVSTTI ('?MOLC25A',WIFPAR(1186))



      IF (WIFPAR(1030).NE.0) CALL GVSTTI ('?M0965',WIFPAR(1030))



      IF (WIFPAR(642).EQ.0.AND.WIFPAR(363).EQ.0.and.WIFPAR(198).GT.0) 
     +    THEN
         CALL GVSTTI ('?M2206',WIFPAR(198))
         CALL GVSTT6 ('?M2207')
         WIFPAR(198)=0
      END IF
      GOTO 998



  700 CONTINUE
      CALL GVSEIW ('MOL003')
      CALL KLONKEND
      CALL GVSCLF (11)
      IERR=1




  998 CONTINUE
      IF (ALTUNT.GE.1) CALL GVSCLF (ALTUNT)
      ALTUNT=0
      CALL WIFPOPPPP (1071)
      CALL WIFPOPPPP (1176)


      RETURN
      END
      SUBROUTINE MOL003A (LOCAAF,NUMDON)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IJ, IH, IK, LOCIK, IU, IERR, LOCAAF, NUMDON, IV,
     +              IAT, JAT, GVFCBT, IUSED, IMISS, NUMINI
      REAL          DISTA, Z1, Z2
      LOGICAL       JUMP, USE(MAXTAT), DIDWARN, 
     +              TXTPROTON, SETDONE, FIRST, T54EQUAL, MOL003B
      CHARACTER*1   FIRSTCHARAT
      CHARACTER*4   T4







      IF (ITT.LE.0) GOTO 998



      IERR=0
      FIRST=.TRUE.
      NUMINI=NUMDON



      DO 10 IJ=1,ITT






            LOCDN2=READN2(IJ)

         CALL MOL003C (READIN(IJ),IERR)
         IF (IERR.NE.0) THEN
            GOTO 10
         END IF



         CALL MOL051 (IJ,JUMP)
         IF (JUMP) THEN
            GOTO 10
         END IF



         IF (FIRST) THEN
            CALL MOL121 (THISAA,THISNM,THISOA,THISCH,THISIC)
            ISSHIT(NUMAAF)=.FALSE.
            FIRST=.FALSE.
         END IF



         IF (HATOM) GOTO 10



         IF (NUMAAF.LE.0) GOTO 10
         LOCAAF=NUMAAF
         USED(IJ)=.TRUE.
         NUMDON=NUMDON+1
         CALL MOL006 (LOCAAF,DIDWARN)
         IF (DIDWARN) THEN
            USED(IJ)=.FALSE.
            NUMDON=NUMDON-1
         END IF
         MODNMB(LOCAAF)=WIFPAR(846)



         IF (.NOT.DIDWARN) CALL MOL058 (LOCAAF,.TRUE.,IJ)
 10   CONTINUE



      IF (WIFPAR(84).EQ.0) THEN
         DO 20 IJ=1,ITT
            IF (USED(IJ)) GOTO 20
            CALL MOL003C (READIN(IJ),IERR)
            IF (HATOM) THEN
               USED(IJ)=.TRUE.
               GOTO 20
            END IF
 20      CONTINUE
         GOTO 101
      END IF



      IK=0
      CALL GVSBTF (USE,ITT+2)
      SETDONE=.FALSE.



      DO 100 IJ=1,ITT



         IF (USED(IJ)) GOTO 100
         CALL GVSSTX (LOCDN2,READN2(IJ))
         CALL MOL003C (READIN(IJ),IERR)
         IF (.NOT.HATOM.OR.IERR.NE.0) GOTO 100
         LOCAAF=NUMAAF





         DO 25 IK=PNTAAS(LOCAAF)+HATPRA(THISTP),PNTAAE(LOCAAF)
            LOCIK=IK-PNTAAS(LOCAAF)+1
            IF (T54EQUAL(ONESAT(IK),THISAT).AND.(.NOT.USE(LOCIK))) 
     +       GOTO 30
 25      CONTINUE
         GOTO 60



 30      CONTINUE
         IH=0
         DO 40 IU=1,MAXTAT
            IF (MUTCON(1,IU,THISTP).LE.0) GOTO 60
            IF (MUTCON(2,IU,THISTP).EQ.LOCIK) THEN
               IH=PNTAAS(LOCAAF)+MUTCON(1,IU,THISTP)-1
               GOTO 50
            END IF      
 40      CONTINUE
         GOTO 60



 50      CONTINUE
         DISTA=SQRT((XCOORD(IH)-THISX)**2+(YCOORD(IH)-THISY)**2+
     +    (ZCOORD(IH)-THISZ)**2)




         IF (DISTA.LT.0.5.OR.DISTA.GT.2.0) THEN
            CALL GVSTT6 ('?R00309')
            CALL GVSTTI ('?R00310',LOCAAF)
            CALL GVST6C ('?R00310B',THISNM,.TRUE.)
            CALL GVST6C ('?R00310A',THISAA,.TRUE.)
            CALL GVST6C ('?R00311',THISAT,.TRUE.)
            CALL GVSTTR ('?R00310C',DISTA)
         END IF
         USE(LOCIK)=.TRUE.
         USED(IJ)=.TRUE.
         CALL MOL006 (LOCAAF,DIDWARN)
         IF (DIDWARN) THEN
            USED(IJ)=.FALSE.
            USE(LOCIK)=.FALSE.
         END IF
         NUMDON=NUMDON+1
         GOTO 100





 60      CONTINUE
         DO 90 IK=PNTAAS(LOCAAF),PNTAAS(LOCAAF)+HATPRA(THISTP)-1
             DISTA=SQRT((XCOORD(IK)-THISX)**2+(YCOORD(IK)-THISY)**2+
     +       (ZCOORD(IK)-THISZ)**2)




            IF ((DISTA.LT.1.1.OR.(FIRSTCHARAT(IK).EQ.'S'.AND.
     +          DISTA.LT.1.4)).AND.DISTA.GT.0.9) THEN




               DO 70 IU=1,MAXTAT
                  IF (MUTCON(1,IU,THISTP).LE.0) GOTO 90
                  IF (MUTCON(1,IU,THISTP).EQ.IK-PNTAAS(LOCAAF)+1) THEN
                     IV=MUTCON(2,IU,THISTP)
                     IF (USE(IV)) GOTO 70
                     IF (.NOT.TXTPROTON(MUTROW4(IV,THISTP),
     +                MUTROW4(IV,THISTP)(1:2))) GOTO 70
                     THISAT=T4(MUTROW4(IV,THISTP))
                     GOTO 80
                  END IF
 70            CONTINUE
               GOTO 90
 80            CONTINUE
               IF (.NOT.USE(IV)) THEN






                  USE(IV)=.TRUE.
                  USED(IJ)=.TRUE.
                  CALL MOL006 (LOCAAF,DIDWARN)
                  IF (DIDWARN) THEN
                     USED(IJ)=.FALSE.
                     USE(IV)=.FALSE.
                  END IF
                  NUMDON=NUMDON+1
                  GOTO 100
               ELSE
                  CALL GVSTT6 ('?M1940')
               END IF



               GOTO 100
            END IF
 90      CONTINUE
 100  CONTINUE
 101  CONTINUE
      IF (NUMDON.LE.NUMINI) GOTO 998



      IMISS=0
      DO 110 IAT=PNTAAS(LOCAAF),PNTAAE(LOCAAF)
         IF (.NOT.ISATOK(IAT)) IMISS=IMISS+1
 110  CONTINUE
      IUSED=GVFCBT(USED,ITT)




      IF (IMISS.EQ.1.AND.ITT-IUSED.EQ.1) THEN
         DO 130 IJ=1,ITT
            IF (.NOT.USED(IJ)) THEN



               CALL MOL003C (READIN(IJ),IERR) 
               IF (IERR.NE.0) THEN
                  GOTO 998
               END IF



               DO 120 IAT=PNTAAS(LOCAAF),PNTAAE(LOCAAF)
                  IF (.NOT.ISATOK(IAT)) THEN
                     IF (MENDLV(IAT).EQ.THISMV) THEN
                        IF (MOL003B(IJ,LOCAAF,IAT)) THEN
                           IF (ONESAT(IAT)(5:5).EQ.' ') THEN






                                 THISAT=ONESAT(IAT)(1:4)

                           ELSE






                                 THISAT=ONESAT(IAT)(2:5)

                           END IF
                           CALL MOL006 (LOCAAF,DIDWARN)
                           IF (DIDWARN) GOTO 998
                           CALL MOL003D (IJ)
                           USED(IJ)=.TRUE.
                        END IF
                     END IF
                  END IF
 120           CONTINUE
            END IF
 130     CONTINUE
      END IF







      DO 150 IAT=PNTAAS(LOCAAF),PNTAAE(LOCAAF)-1
         DO 140 JAT=IAT+1,PNTAAE(LOCAAF)
            IF (ORGNAM(IAT).EQ.ORGNAM(JAT)) THEN
               CALL BND003A (LOCAAF,Z1)
               CALL MOL203 (IAT,JAT,0)
               CALL BND003A (LOCAAF,Z2)
               IF (Z2+0.01.GT.Z1) THEN
                  CALL MOL203 (IAT,JAT,0)
               ELSE
                  CALL GVSFMT ('?FMT998')
                  CALL GVSCTB (LINE,80)
                  WRITE (LINE,FMT,ERR=999) ONESAT(IAT),ONESAT(JAT)
                  CALL GVSTT6 (LINE)
               END IF
            END IF
 140     CONTINUE
 150  CONTINUE





      DO 200 IJ=1,ITT
         IF (.NOT.USED(IJ)) THEN
            CALL MOL003C (READIN(IJ),IERR)
            IF (WIFPAR(329).NE.0) PRINT*,'KLONK IN 003A:'
            CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
            CALL KLONKTOD ('ATOM  ',THISAT,THISORG,THISAL,THISAA,
     +       THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,
     +       THISBF,THISMV,THISPN,THISOA,0,IERR)
         END IF
 200  CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL003A')



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION MOL003B(IJ,IAA,JAT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IJ, IAA, IAT, JAT, IC1, IC2, ICON, IERR
      REAL          D12, D12MIN, D12MIS







      IERR=0
      MOL003B=.FALSE.



      D12MIN=999.9
      D12MIS=999.9



      CALL MOL003C (READIN(IJ),IERR) 
      IF (IERR.NE.0) GOTO 998



      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (.NOT.PROTON(IAT).AND.ISATOK(IAT)) THEN
            D12=SQRT((XCOORD(IAT)-THISX)**2+
     +               (YCOORD(IAT)-THISY)**2+
     +               (ZCOORD(IAT)-THISZ)**2)
            D12MIN=MIN(D12MIN,D12)
         END IF
 10   CONTINUE




      DO 20 ICON=1,MAXTAT
         IF (MUTCON(1,ICON,RESTYP(IAA)).EQ.0) GOTO 21
         IC1=PNTAAS(IAA)+MUTCON(1,ICON,RESTYP(IAA))-1
         IC2=PNTAAS(IAA)+MUTCON(2,ICON,RESTYP(IAA))-1
         IF (IC1.EQ.JAT) THEN
            D12MIS=SQRT((XCOORD(IC2)-THISX)**2+
     +                  (YCOORD(IC2)-THISY)**2+
     +                  (ZCOORD(IC2)-THISZ)**2)
            GOTO 21
         ELSE IF (IC2.EQ.JAT) THEN
            D12MIS=SQRT((XCOORD(IC1)-THISX)**2+
     +                  (YCOORD(IC1)-THISY)**2+
     +                  (ZCOORD(IC1)-THISZ)**2)
            GOTO 21
         END IF
 20   CONTINUE
 21   CONTINUE



      IF (D12MIS.LT.D12MIN.AND.D12MIS.LT.2.0) MOL003B=.TRUE.



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL003C (LOCLIN,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, INDAA3
     +              , GVFPOS
      REAL          GVFRNG
      CHARACTER*4   CHAR4
      CHARACTER*80  FMT1, FMT2, FMT3, FMT4
      CHARACTER*(*) LOCLIN
      LOGICAL       GVFIBN, TXTPROTON, MOL009, FIRST
      DATA FIRST    /.TRUE./
      SAVE          FIRST, FMT1, FMT2, FMT3, FMT4







      IERR=0
      THISPN=0
      THISAL=' '
      THISLA=' '
      THISCH=' '
      THISIC=' '
      THISX=0.0
      THISY=0.0
      THISZ=0.0
      THISAX=0.0
      THISAY=0.0
      THISAZ=0.0
      THISWT=0.0
      THISBF=0.0
      THISMV='  '
      IF (FIRST) THEN
         FIRST=.FALSE.
         CALL GVSCTB (FMT1,80)
         CALL GVSCTB (FMT2,80)
         CALL GVSCTB (FMT3,80)
         CALL GVSCTB (FMT4,80)
         CALL GVSFMTL (FMT1,'?FMT501B')
         CALL GVSFMTL (FMT2,'?FMT501')
         CALL GVSFMTL (FMT3,'?FMT501A')
         CALL GVSFMTL (FMT4,'?FMT501')
      END IF






















      IF (LOCLIN(1:6).EQ.'ANISOU') THEN
         READ (LOCLIN,FMT1,ERR=999,END=999) THISAT,THISAL,
     +    THISOA,THISCH,THISNM,THISIC,THSANI



      ELSE
         READ (LOCLIN,FMT2,ERR=10,END=10) THISPN,THISAT,THISAL,THISOA,
     +    THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,THISBF,THISOR,
     +    THISMV
      END IF
      IF (LOCDN2(1:10).NE.'          ') THEN
         READ (LOCDN2,FMT3,ERR=10,END=10) THISLA,THISAX,THISAY,THISAZ,
     +    THISAW,THISAB
      END IF
      GOTO 20



 10   CONTINUE
         READ (LOCLIN,FMT4,ERR=999,END=999) THISPN,THISAT,THISAL,
     +    THISOA,THISCH,THISNM,THISIC,THISX,THISY,THISZ
         WIFPAR(1030)=WIFPAR(1030)+1
         THISWT=1.0
         THISBF=FLOAT(WIFPAR(57))
         CALL GVSTT6 ('Read error corrected:')
         CALL GVSTT6 (LOCLIN)
   20 CONTINUE



      IF (THISAT(2:4).EQ.THISOR(1:3)) THEN






            THISAT=THISOR

      END IF









         THISAA=THISOA

      IF (MOL009(THISAA)) THEN






            THISORG=THISNM

      ELSE






            THISORG=THISOR

      END IF
      THISORG(5:5)=' '



      IF (THISAA.EQ.'    ') CALL GVSSTX (THISAA,THISAT)






         CHAR4=THISAA

      CALL GVSSHL (CHAR4)
      IF (CHAR4(4:4).NE.' ') THEN
         CHAR4=' '
         IF (GVFIBN(INDAA3(CHAR4),1,20)) THEN






               THISAA=CHAR4

         END IF
      END IF
      IF (ICHAR(THISAA(1:1)).NE.ICHAR(' ').AND.
     +    ICHAR(THISAA(4:4)).NE.ICHAR(' ')) THEN






            CHAR4(1:3)=THISAA(1:3)

      END IF
      THISWT=GVFRNG(THISWT,999.9,0.0)
      THISBF=GVFRNG(THISBF,999.9,0.0)
      HATOM=TXTPROTON(THISAT,THISMV)
      THISTP=GVFPOS(' ALA CYS ASP GLE PHE GLY HIS ILE LYS LEU',
     + THISAA)
      IF (THISTP.LE.0) THISTP=GVFPOS
     + (' MET ASN PRO GLN ARG SER THR VAL TRP TYR',THISAA)
      IF (THISTP.NE.0) THEN
         THISTP=(THISTP+3)/4
      ELSE
         THISTP=INDAA3(THISAA)
      END IF
      THISFAM=FAMTYP(THISTP)
      GOTO 995



  999 CONTINUE
      CALL SHOWTEXT ('?MOLB07')
      CALL GVSTT6 ('?M0708')
      CALL GVSTT6 (LOCLIN)
      CALL GVSKIL
      IERR=1



  995 CONTINUE


      RETURN
      END
      SUBROUTINE MOL003D (IJ)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IJ







      CALL GVSFMT ('?FMT997')
      CALL GVSCTB (LINE,80)
      WRITE (LINE,FMT,ERR=999) READIN(IJ)(13:16),THISAT
      CALL GVSTT6 (LINE)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL003D')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL004

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       INDAA3, IERR, IHSKIP, IAT, ITTCNT

      CHARACTER*80  LOCLIN
      LOGICAL       KLONKEXIST, DIDWARN, MOL009, TXTPROTON








      CALL CHKBOUNDTO ('MOL004 at 1')
      WIFPAR(1504)=WIFPAR(1504)+1
      CALL WIFPUSHPPP (175,1)



      CALL MOL056 (IERR)
      IHSKIP=0
      MCFPNT=0
      CALL CHKBOUNDTO ('MOL004 at 2')



      IF (.NOT.KLONKEXIST()) THEN
         CALL GVSTT6 ('?M3668')
         GOTO 996
      END IF



      MCFPNT=0
      WIFPAR(491)=0
      WIFPAR(846)=0





 1    CONTINUE
         CALL CHKBOUNDTO ('MOL004 at 3')



         CALL GETENT (IHSKIP,13,IERR)







         IF (IERR.EQ.3.AND.ITT.LE.0) GOTO 1
         IF (IERR.EQ.1) GOTO 900
         IF (IERR.NE.0.AND.ITT.LE.0) GOTO 900





            LOCDN2=READN2(1)


         CALL MOL003C (READIN(1),IERR)
         IF (IERR.NE.0) GOTO 900
         CALL CHKBOUNDTO ('MOL004 at 4')





         IF (MOL009(THISAA).OR.MOL009(THISNM)) THEN


            GOTO 1
         ELSE


         END IF



         IF (THISNM.EQ.'DDRG') THEN

            GOTO 1
         END IF



         IF (NUMAAT.GT.MAXAA-1000) THEN
            CALL TOOMANY ('?MOLC23')
            CALL MOL200

            GOTO 997
         END IF
         CALL CHKBOUNDTO ('MOL004 at 5')
         IF (NUMATF.GT.MAXAT-2500) THEN
            CALL TOOMANY ('?MOLC24')

            GOTO 997
         END IF
         IF (NUMSOU.GE.MAXMOL-100) THEN
            CALL TOOMANY ('?MOLC26')
            CALL SHOSOU
            CALL TOOMANY ('?MOLC26')

            GOTO 997
         END IF
         CALL CHKBOUNDTO ('MOL004 at 6')



         IF (FAMTYP(INDAA3(THISAA)).EQ.6) THEN


            CALL MOL121A (THISAA,THISNM,THISOA,THISCH)



         ELSE


            CALL WIFPUSHPPP (1180,1)
            IF (ITT.EQ.1) THEN
               CALL MOL123 (THISAA,THISNM,THISCH,FILNMS(91),4,ITT,' ',
     +          IERR)
            ELSE
               CALL MOL123 (THISAA,THISNM,THISCH,FILNMS(91),2,ITT,' ',
     +          IERR)
            END IF
            CALL WIFPOPPPP (1180)
            SOUPNT(NUMAAT)=WIFPAR(491)
            MODNMB(NUMAAT)=WIFPAR(846)
         END IF



         DO 100 ITTCNT=1,ITT









               LOCLIN=READIN(ITTCNT)
               LOCDN2=READN2(ITTCNT)



            CALL MOL003C (LOCLIN,IERR)





            IF (IERR.NE.0) THEN
               CALL GVSTT6 ('?M2795')
               CALL GVSTT6 (LOCLIN)
               GOTO 100
            END IF



            IF (FAMTYP(INDAA3(THISAA)).EQ.6) THEN



               CALL MOL006 (NUMAAT,DIDWARN)




            ELSE


               IAT=PNTAAS(NUMAAT)-1+ITTCNT
               IF (IAT.GT.PNTAAE(NUMAAT)) THEN
                  CALL GVSTT6 (LOCLIN)
                  GOTO 100
               END IF
               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
               CALL GVSSTX (ONESAT(IAT),THISAT)
               CALL GVSSTX (ORGNAM(IAT),THISORG)
               XCOORD(IAT)=THISX
               YCOORD(IAT)=THISY
               ZCOORD(IAT)=THISZ
               WEIGHT(IAT)=THISWT
               XBFACT(IAT)=THISBF
               PROTON(IAT)=TXTPROTON(THISAT,THISMV)
               ATIAA(IAT) =NUMAAT
               PINIAA(IAT)=ITTCNT
               ALTATM(IAT)=THISAL
               MENDLV(IAT)=THISMV
               PDBNUM(IAT)=THISPN
               ISATOK(IAT)=.TRUE.
               ALALAT(IAT)=' '
               CALL SETALT (IAT)

            END IF
 100     CONTINUE
         CALL CHKBOUNDTO ('MOL004 at 7')



      GOTO 1



  900 CONTINUE
      GOTO 996



  997 CONTINUE
      CALL KLONKEND
      CALL GVSCLF (11)
      GOTO 900



  996 CONTINUE
      CALL WIFPOPPPP (175)


      RETURN
      END
      SUBROUTINE MOL004A (ISOUP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INTEGER       MX2
      PARAMETER     (MX2=200)
      INTEGER       NUM, ICONT, CONSYM(MX2), ISOUP, IAT, JAT, IERR,
     +              IAA, JAA, JATMIN1, JATMIN2, JATMIN3, JATMIN4, 
     +              ELMZ, IBND, K, K1, K2
      REAL          CONDST(MX2), DISTMIN1, DISTMIN2, DISTMIN3, 
     +              DISTMIN4, DLIM, DLM2
      LOGICAL       WIFIRI, XYZNUL, WIFISA, WIFISN, WIFISW, ISSULPHUR,
     +              WIFIRR, ISMETAL, ISPSEUDOH, ISPHOSPHOR, TXTPROTON,
     +              WIFITC, WIFISH, WIFITI, CH4EQCH4, GVFIBN







      IF (WIFPAR(1208).EQ.1) THEN
         CALL GVSTTI ('?M3369',ISOUP)
         CALL GVSTTI3('?M3370',NUMAAF,NUMAAT,NUMATF)
         CALL SHOIAA (SOUADM(1,ISOUP))
         CALL GVSCOD ('MOL004A')
      END IF



      IF (WIFISA(ISOUP).OR.WIFISN(ISOUP).OR.WIFISW(ISOUP)) GOTO 998
      IF (WIFPAR(168).EQ.1) GOTO 998
      IF (WIFPAR(168).EQ.2) CALL GVSKIL
      IF (NUMAAF.LE.0) GOTO 998
      IF ((.NOT.WIFIRI(SOUADM(1,ISOUP))).OR.
     +    (.NOT.WIFIRI(SOUADM(2,ISOUP)))) THEN
         CALL MOL010 ('MOL004A')
         CALL GVSKIL
         GOTO 998
      END IF
      IF (WIFPAR(1208).GE.1) CALL GVSTT6 ('?M3371')



      CALL WIFPUSHPPP (846,0)
      DO 2 IAT=PNTAAS(SOUADM(1,ISOUP)),PNTAAE(SOUADM(2,ISOUP))
         DO 1 IBND=1,8
            IF (BOUND_TO(IBND,IAT).LT.PNTAAS(SOUADM(1,ISOUP)).OR.
     +       BOUND_TO(IBND,IAT).GT.PNTAAE(SOUADM(2,ISOUP))) 
     +       BOUND_TO(IBND,IAT)=0
 1       CONTINUE
 2    CONTINUE
      DO 4 IAT=1,NUMATF
         IF (GVFIBN(IAT,PNTAAS(SOUADM(1,ISOUP)),
     +    PNTAAE(SOUADM(2,ISOUP)))) GOTO 4
         DO 3 IBND=1,8
            IF (BOUND_TO(IBND,IAT).GE.PNTAAS(SOUADM(1,ISOUP)).AND.
     +       BOUND_TO(IBND,IAT).LE.PNTAAE(SOUADM(2,ISOUP))) 
     +       BOUND_TO(IBND,IAT)=0
    3    CONTINUE
    4 CONTINUE
      CALL ENVSET (ISOUP)



      IF (SOUADM(4,ISOUP).EQ.1) THEN
         IAA=SOUADM(1,ISOUP)
         IAT=PNTAAS(IAA)
         IF (ISATOK(IAT).AND.ELMZ(IAT).EQ.8) THEN
            IF (WIFPAR(1208).EQ.1) CALL DIF015 (6,'?M3372',IAT)
            CALL WIFPUSHPPP (187,1)
            CALL WIFPUSHPPP (643,1)
            CALL WIFPUSHPPP (590,0)
            CALL FCONATI (IAT,0.5,CONIAT,CONSYM,CONDST,NUM,MX2)
            CALL WIFPOPPPP (590)
            CALL WIFPOPPPP (643)
            CALL WIFPOPPPP (187)
            IF (NUM.GT.0) THEN
               IF (WIFPAR(1208).EQ.1) THEN
                  CALL GVSTTI ('?M3373',NUM)
                  IF (NUM.GT.0) THEN
                     DO 123 K=1,NUM
                        K1=CONIAT(K)
                        IF (.NOT.WIFITI(K1)) GOTO 123
                        K2=ATIAA(K1)
                        IF (.NOT.WIFIRI(K2)) GOTO 123
                        CALL DIF013 (6,K1,CONDST(K))
 123                 CONTINUE
                  END IF
               END IF



               DO 6 ICONT=1,NUM
                  JAT=CONIAT(ICONT)
                  IF (TXTPROTON(ONESAT(JAT),MENDLV(JAT))) GOTO 6
                  IF (.NOT.WIFITC(JAT)) GOTO 6
                  JAA=ATIAA(JAT)
                  IF (CHANAM(IAA).NE.CHANAM(JAA)) GOTO 6
                  IF (WIFPAR(1208).EQ.1) PRINT*,'at 4',ICONT,
     +             JAA,JAT,ISATOK(JAT),WIFIRR(JAA),SOUPNT(IAA),
     +             SOUPNT(JAA),CONDST(ICONT)
                  IF (ISATOK(JAT).AND.WIFIRR(JAA).AND.
     +                SOUPNT(IAA).EQ.SOUPNT(JAA)) THEN
                     IF (CONDST(ICONT).LT.2.0.AND.
     +                   CONDST(ICONT).GT.0.1) THEN
                        CALL SETBOUNDTO (IAT,JAT,IERR)
                        GOTO 900
                     END IF
                  END IF
    6          CONTINUE



               DO 7 ICONT=1,NUM
                  JAT=CONIAT(ICONT)
                  IF (TXTPROTON(ONESAT(JAT),MENDLV(JAT))) GOTO 7
                  JAA=ATIAA(JAT)
                  IF (CHANAM(IAA).NE.CHANAM(JAA)) GOTO 7
                  IF (WIFPAR(1208).EQ.1) PRINT*,'at 5',ICONT,
     +             JAA,JAT,ISATOK(JAT),WIFIRR(JAA),SOUPNT(IAA),
     +             SOUPNT(JAA),CONDST(ICONT)
                  IF (ISATOK(JAT).AND.WIFIRR(JAA).AND.
     +                SOUPNT(IAA).EQ.SOUPNT(JAA)) THEN
                     IF (CONDST(ICONT).LT.1.8.AND.
     +                   CONDST(ICONT).GT.0.1) THEN
                        CALL SETBOUNDTO (IAT,JAT,IERR)
                        GOTO 900
                     END IF
                  END IF
    7          CONTINUE



               DO 8 ICONT=1,NUM
                  JAT=CONIAT(ICONT)
                  JAA=ATIAA(JAT)
                  IF (CHANAM(IAA).NE.CHANAM(JAA)) GOTO 8
                  IF (ISATOK(JAT).AND.SOUPNT(IAA).EQ.SOUPNT(JAA)) THEN
                     IF (CONDST(ICONT).LT.1.8) THEN
                        CALL SETBOUNDTO (IAT,JAT,IERR)
                        GOTO 900
                     END IF
                  END IF
    8          CONTINUE
            END IF
         END IF
      END IF
      IF (WIFPAR(1208).GE.1) THEN
         CALL GVST6C ('?M3374',ONESA3(SOUADM(1,ISOUP)),.TRUE.)
      END IF



      IF (WIFISH(ISOUP)) THEN
         IAA=SOUADM(1,ISOUP)
         IF (WIFPAR(1208).EQ.1) CALL GVSTTI2 ('?M3375',ISOUP,IAA)
         DO 19 IAT=PNTAAS(IAA),PNTAAE(IAA)
            CALL WIFPUSHPPP (11,0)
            CALL WIFPUSHPPP (187,1)
            CALL WIFPUSHPPP (590,0)
            CALL FCONATI (IAT,-0.1,CONIAT,CONSYM,CONDST,NUM,MX2)
            CALL WIFPOPPPP (590)
            CALL WIFPOPPPP (187)
            CALL WIFPOPPPP (11)
            IF (WIFPAR(1208).EQ.1) CALL GVSTTI ('?M3377',NUM)
            IF (NUM.GT.0) THEN



               DO 16 ICONT=1,NUM
                  JAT=CONIAT(ICONT)
                  IF (WIFPAR(1208).EQ.1) PRINT*,ONESAT(JAT),
     +             ATIAA(JAT),ONESA3(ATIAA(JAT)),
     +             MODNMB(ATIAA(JAT)),CONDST(ICONT), 
     +             xcoord(iat),ycoord(iat),zcoord(iat),
     +             xcoord(jat),ycoord(jat),zcoord(jat)
                  IF (TXTPROTON(ONESAT(JAT),MENDLV(JAT))) GOTO 16
                  JAA=ATIAA(JAT)
                  IF (CHANAM(IAA).NE.CHANAM(JAA)) GOTO 16
                  IF (CH4EQCH4(ONESA3(IAA),ONESA3(JAA))) GOTO 16
                  IF (ISATOK(JAT).AND.WIFIRR(JAA).AND.
     +                 SOUPNT(IAA).EQ.SOUPNT(JAA)) THEN
                     IF (CONDST(ICONT).LT.1.2.AND.
     +                    CONDST(ICONT).GT.0.8) THEN
                        CALL SETBOUNDTO (IAT,JAT,IERR)
                        GOTO 19
                     END IF
                  END IF
 16            CONTINUE



               DO 17 ICONT=1,NUM
                  JAT=CONIAT(ICONT)
                  IF (TXTPROTON(ONESAT(JAT),MENDLV(JAT))) GOTO 17
                  JAA=ATIAA(JAT)
                  IF (CHANAM(IAA).NE.CHANAM(JAA)) GOTO 17
                  IF (ISATOK(JAT).AND.WIFIRR(JAA).AND.
     +                 SOUPNT(IAA).EQ.SOUPNT(JAA)) THEN
                     IF (CONDST(ICONT).LT.1.5.AND.
     +                    CONDST(ICONT).GT.0.5) THEN
                        CALL SETBOUNDTO (IAT,JAT,IERR)
                        GOTO 19
                     END IF
                  END IF
 17            CONTINUE
            END IF
 19      CONTINUE
      END IF
      IF (WIFPAR(1208).GE.1) CALL GVST6C ('MOL004A at 3',
     + ONESA3(SOUADM(1,ISOUP)),.TRUE.)



      DO 50 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
         IF (WIFPAR(1208).GE.1) THEN
            CALL GVSTTI ('SOUPNT(SOUADM(1,ISOUP))=',
     +        SOUPNT(SOUADM(1,ISOUP)))
            CALL GVSTTI ('SOUPNT(IAA)=',SOUPNT(IAA))
         END IF
         DO 40 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (WIFPAR(1208).GE.1) THEN
               PRINT*,'IAA,IAT=',IAA,IAT
               CALL GVST6C ('?M3378',ONESAT(IAT),.TRUE.)
            END IF
            DLIM=0.1



            IF (ISSULPHUR(IAT).OR.ISPHOSPHOR(IAT)) DLIM=DLIM+0.25
            ATIAA(IAT)=IAA
            IF (XYZNUL(IAT)) THEN
               IF (WIFPAR(1208).GE.1) CALL GVST6C ('?M3379',
     +          ONESAT(IAT),.TRUE.)
               GOTO 40
            END IF



            CALL WIFPUSHPPP (11,1)
            CALL WIFPUSHPPP (391,1)
            CALL FCONATI (IAT,0.1,CONIAT,CONSYM,CONDST,NUM,MX2)
            CALL WIFPOPPPP (391)
            CALL WIFPOPPPP (11)
            IF (WIFPAR(1208).GE.1) CALL DIF013C (6,IAT,NUM)
            IF (NUM.LE.0) GOTO 40



            DISTMIN1=9999.9
            DISTMIN2=9999.9
            DISTMIN3=9999.9
            DISTMIN4=9999.9
            JATMIN1=0
            JATMIN2=0
            JATMIN3=0
            JATMIN4=0
            DO 30 ICONT=1,NUM
               JAT=CONIAT(ICONT)
               IF (WIFPAR(1208).GE.1) THEN
                  PRINT*,'TRY CONTACT WITH:',JAT,ATIAA(JAT)
                  CALL DIF013C (6,JAT,ICONT)
               END IF
               IF (.NOT.ISATOK(JAT)) GOTO 30
               JAA=ATIAA(JAT)
               IF (JAA.EQ.IAA) GOTO 30
               IF (PROTON(IAT).AND.PROTON(JAT)) GOTO 30




               IF (SOUPNT(IAA).NE.SOUPNT(JAA)) GOTO 30
               DLM2=DLIM



               IF (ISSULPHUR(JAT).OR.ISPHOSPHOR(JAT)) DLM2=DLM2+0.25







               IF (CONDST(ICONT)-0.5*(VDWRAD(IAT)+VDWRAD(JAT)).LT.
     +             DLM2) THEN




                  IF (CONDST(ICONT).LT.0.7) THEN
                     IF (WIFPAR(1172).NE.0) THEN
                        IF (.NOT.ISPSEUDOH(IAT)) GOTO 30
                     ELSE
                        GOTO 30
                     END IF
                  END IF
                  IF (CONDST(ICONT).LT.1.0.AND.(.NOT.PROTON(IAT)).AND.
     +             (.NOT.PROTON(JAT))) GOTO 30
                  IF (ISMETAL(IAT).AND.CONDST(ICONT).GT.1.4) GOTO 30



                  IF (CONDST(ICONT).LT.DISTMIN1) THEN
                     DISTMIN4=DISTMIN3
                     JATMIN4=JATMIN3
                     DISTMIN3=DISTMIN2
                     JATMIN3=JATMIN2
                     DISTMIN2=DISTMIN1
                     JATMIN2=JATMIN1
                     DISTMIN1=CONDST(ICONT)
                     JATMIN1=JAT
                  ELSE IF (CONDST(ICONT).LT.DISTMIN2) THEN
                     DISTMIN4=DISTMIN3
                     JATMIN4=JATMIN3
                     DISTMIN3=DISTMIN2
                     JATMIN3=JATMIN2
                     DISTMIN2=CONDST(ICONT)
                     JATMIN2=JAT
                  ELSE IF (CONDST(ICONT).LT.DISTMIN3) THEN
                     DISTMIN4=DISTMIN3
                     JATMIN4=JATMIN3
                     DISTMIN3=CONDST(ICONT)
                     JATMIN3=JAT
                  ELSE IF (CONDST(ICONT).LT.DISTMIN4) THEN
                     DISTMIN4=CONDST(ICONT)
                     JATMIN4=JAT
                  END IF

               END IF
   30       CONTINUE



            IF (ISMETAL(IAT)) THEN
               IF (JATMIN1.NE.0) THEN
                  CALL SETBOUNDTO (IAT,JATMIN1,IERR)
               END IF
               IF (JATMIN2.NE.0) THEN
                  CALL SETBOUNDTO (IAT,JATMIN2,IERR)
               END IF
               IF (JATMIN3.NE.0) THEN
                  CALL SETBOUNDTO (IAT,JATMIN3,IERR)
               END IF
               IF (JATMIN4.NE.0) THEN
                  CALL SETBOUNDTO (IAT,JATMIN4,IERR)
               END IF
            ELSE
               IF (JATMIN1.NE.0) THEN
                  CALL SETBOUNDTO (IAT,JATMIN1,IERR)
               END IF
            END IF               
   40    CONTINUE
   50 CONTINUE
      IF (WIFPAR(1208).GE.1)CALL GVSTTI2('At 4',WIFPAR(644),WIFPAR(645))



  900 CONTINUE



      CALL WIFPOPPPP (846)



  998 CONTINUE

      
      RETURN
      END
      SUBROUTINE MOL004B (ISOUP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, IAT, JAT, JATLOC
      LOGICAL       CH5EQCH5







      IAA=SOUADM(1,ISOUP)



      DO 100 JATLOC=1,MAXTAT
         JAT=JATLOC+PNTAAS(IAA)-1



         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (CH5EQCH5(ONESAT(IAT),MUTROW4(JATLOC,RESTYP(IAA)))) THEN
               IF (IAT.NE.JAT) CALL MOL203 (IAT,JAT,2)
            END IF
   90    CONTINUE
  100 CONTINUE





      RETURN
      END   
      SUBROUTINE MOL004Z (IAT,IERR)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'GETMOL.INC'
      INTEGER       IAT, IERR, IBND

      REAL          WIFVDW
      LOGICAL       ATSTAT

      CHARACTER*1   FSTALT








      IF (IAT.GT.PNTAAS(NUMAAT)) THEN
         FSTALT=ALTATM(PNTAAS(NUMAAT))
      ELSE
         FSTALT='$'
      END IF



      IERR=0
      ATSTAT=.TRUE.





















            ONESAT(IAT)=THISAT









         ORGNAM(IAT)=THISORG

      XCOORD(IAT)=THISX
      YCOORD(IAT)=THISY
      ZCOORD(IAT)=THISZ
      WEIGHT(IAT)=THISWT
      XBFACT(IAT)=THISBF
      ALTATM(IAT)=THISAL
      ISATOK(IAT)=ATSTAT
      PDBNUM(IAT)=THISPN

      IF (THISMV.NE.'  ') THEN
         CALL GVSSTX (MENDLV(IAT),THISMV)




            MENDLV(IAT)=THISMV

      ELSE
         WIFPAR(1276)=WIFPAR(1276)+1
      END IF

      VDWRAD(IAT)=WIFVDW(THISAT)
      IF (THISWT.LT.0.01) ISATOK(IAT)=.FALSE.
      ATTVAL(IAT)=0.0
      DO 10 IBND=1,8
         BOUND_TO(IBND,IAT)=0
 10   CONTINUE
      ACCESS(IAT)=0.0
      ATCOLR(IAT)=0
      ALALAT(IAT)=' '
      CALL SETALT (IAT)
      USEAT(IAT)=.FALSE.
      IF (XCOORD(IAT).GT.9900.0.AND.
     +    YCOORD(IAT).GT.9900.0.AND.
     +    ZCOORD(IAT).GT.9900.0) ISATOK(IAT)=.FALSE.





      RETURN
      END
      SUBROUTINE MOL005

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, ITTCNT, IHSKIP
      LOGICAL       MOL009, FIRST, ISPROTON, TXTPROTON

      CHARACTER*80  LOCLIN







      MCFPNT=0




 1    CONTINUE
      FIRST=.TRUE.



      CALL GETENT (IHSKIP,13,IERR)




      IF (IERR.EQ.3.AND.ITT.LE.0) GOTO 1
      IF (IERR.EQ.1) GOTO 998
      IF (IERR.NE.0.AND.ITT.LE.0) GOTO 998







         LOCDN2=READN2(1)

      CALL MOL003C (READIN(1),IERR)
      IF (IERR.NE.0) GOTO 998


      IF (MOL009(THISAA).OR.MOL009(THISNM)) THEN



      ELSE
         GOTO 1
      END IF




      DO 50 ITTCNT=1,ITT
         NUMATF=NUMATF+1




            LOCLIN=READIN(ITTCNT)
            LOCDN2=READN2(ITTCNT)

         CALL MOL003C (LOCLIN,IERR)
         IF (IERR.NE.0) THEN
            NUMATF=NUMATF-1


            GOTO 50
         END IF



         ORGNAM(NUMATF)(5:5)=' '
         ISATOK(NUMATF)=.TRUE.






         IF (WIFPAR(84).EQ.0) THEN
            IF (MOL009(THISAA)) THEN
               IF (ISPROTON(NUMATF).OR.TXTPROTON(THISAT,THISMV)) THEN
                  NUMATF=NUMATF-1


                  GOTO 50
               END IF
            END IF
         END IF









         IF (FIRST) THEN


            FIRST=.FALSE.
            NUMSOU=NUMSOU+1
            NUMAAT=NUMAAT+1
            SOUPNT(NUMAAT)=WIFPAR(491)
            MODNMB(NUMAAT)=WIFPAR(846)
            SOUADM(1,NUMSOU)=NUMAAT
            SOUADM(2,NUMSOU)=NUMAAT
            SOUADM(3,NUMSOU)=1
            SOUADM(4,NUMSOU)=1
            SOUADM(5,NUMSOU)=5
            CHAINN(1,NUMAAT)=0
            CHAINN(2,NUMAAT)=NUMSOU







               ONESAT(NUMATF)=THISAT
               ORGNAM(NUMATF)=THISORG(1:4)
               ONESA3(NUMAAT)=THISAA
               ONEORG(NUMAAT)=THISOA
               NUMNAM(NUMAAT)='HOH '

            CHANAM(NUMAAT)=THISCH
            PNTAAS(NUMAAT)=NUMATF
            PNTAAC(NUMAAT)=NUMATF
            PNTAAE(NUMAAT)=NUMATF


         ELSE


            PNTAAE(NUMAAT)=NUMATF
            SOUADM(4,NUMSOU)=SOUADM(4,NUMSOU)+1
         END IF





         IF (THISCH.EQ.LASTCH) THEN
            CALL MOL004Z (NUMATF,IERR)



               ONESAT(NUMATF)=THISAT

            IF (IERR.NE.0) THEN
               NUMATF=NUMATF-1


               GOTO 50
            END IF
         END IF



            LASTAA=THISAA




 50   CONTINUE

      GOTO 1



 998  CONTINUE


      RETURN
      END
      SUBROUTINE MOL006 (LOCAAF,DIDWARN)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DRGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       LOCAAF, IAT, IERR, IPOS
      REAL          WIFVDW
      CHARACTER*4   THSLOC
      CHARACTER*80  LOCLIN
      LOGICAL       TXTPROTON, DIDWARN, CH5EQCH4, CH4EQCH4, WIFIC1,
     +              WIFIC2







      DIDWARN=.FALSE.



      IF (FAMTYP(RESTYP(LOCAAF)).NE.6) THEN
         IF (WIFPAR(84).EQ.0.AND.TXTPROTON(THISAT,THISMV)) GOTO 998
      END IF







      DO 10 IAT=PNTAAS(LOCAAF),PNTAAE(LOCAAF)
         IPOS=IAT-PNTAAS(LOCAAF)+1
         IF (CH5EQCH4(MUTROW4(IPOS,RESTYP(LOCAAF)),THISAT).OR.
     +       MUTROW4(IPOS,RESTYP(LOCAAF))(2:5).EQ.THISOR) THEN



            IF (ISATOK(IAT)) THEN
               CALL SHOIAA (LOCAAF)
               CALL GVSFMT ('?FMT241')
               WRITE (LOCLIN,FMT,ERR=999) LOCAAF,THISAT,ONESA3(LOCAAF),
     +          NUMNAM(LOCAAF),CHANAM(LOCAAF)
               CALL GVSTT6 (LOCLIN)
               WIFPAR(927)=WIFPAR(927)+1
               DIDWARN=.TRUE.
               GOTO 998
            END IF





            CALL MOL004Z (IAT,IERR)


            IF (IERR.NE.0) THEN
               NUMATF=NUMATF-1
               GOTO 10
            END IF



            VDWRAD(IAT)=WIFVDW(THISAT)
            PINIAA(IAT)=IAT-PNTAAS(LOCAAF)+1
            PROTON(IAT)=TXTPROTON(THISAT,THISMV)
            ATIAA(IAT)=LOCAAF
            GOTO 998
         END IF
   10 CONTINUE



      IF (THISAT(4:4).EQ.'*') THEN
         CALL GVSSTX (THSLOC,THISAT)
         THSLOC(4:4)=''''
         DO 20 IAT=PNTAAS(LOCAAF),PNTAAE(LOCAAF)
            IF (CH5EQCH4(ONESAT(IAT),THSLOC)) THEN
               IF (ISATOK(IAT)) GOTO 998
               CALL MOL004Z (IAT,IERR)
               IF (IERR.NE.0) THEN
                  NUMATF=NUMATF-1
                  GOTO 20
               END IF
               VDWRAD(IAT)=WIFVDW(THISAT)
               PINIAA(IAT)=IAT-PNTAAS(LOCAAF)+1
               PROTON(IAT)=TXTPROTON(THISAT,THISMV)
               ATIAA(IAT)=LOCAAF
               GOTO 998
            END IF
 20      CONTINUE
      END IF





      IF (LOCAAF.EQ.NUMAAT.AND.HASML2) GOTO 998
      IF (FAMTYP(RESTYP(LOCAAF)).EQ.3) THEN
         IF (CH4EQCH4(THISAT,' OP3').OR.
     +       CH4EQCH4(THISAT,' OP5')) GOTO 998
      END IF
      IF (CH4EQCH4(ONESA3(LOCAAF),' UNK')) GOTO 998
      IF (.NOT.TXTPROTON(THISAT,THISMV)) THEN
         IF (.NOT.WIFIC1(THISAT).AND..NOT.WIFIC2(THISAT)) THEN

            CALL GVSFMT ('?FMT242')
            WRITE (LOCLIN,FMT,ERR=999) THISAT,THISOR,ONESA3(LOCAAF),
     +       NUMNAM(LOCAAF),CHANAM(LOCAAF),MODNMB(LOCAAF)
            CALL GVSTT6 (LOCLIN)
            IF (WIFPAR(400).GE.1) CALL GVSTTU (WIFPAR(400),LOCLIN)





         END IF
      END IF




      WIFPAR(144)=WIFPAR(144)+1
      DIDWARN=.TRUE.
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL006')
      CALL GVSKIL



  998 CONTINUE


      RETURN
      END
      INTEGER FUNCTION HASHX(S,NBIN)



















      IMPLICIT      NONE
      CHARACTER*(*) S
      INTEGER       NBIN,I





      HASHX=56487
      DO 10 I=1,LEN(S)
         HASHX=MOD(1003*HASHX+ICHAR(S(I:I)),NBIN)
   10 CONTINUE





      RETURN
      END
      LOGICAL FUNCTION MOL009(TEXT)

















      IMPLICIT      NONE
      CHARACTER*(*) TEXT
      CHARACTER*4   OLDTXT
      LOGICAL       OLDRESULT
      SAVE          OLDTXT, OLDRESULT
      DATA OLDTXT   /'    '/
      DATA OLDRESULT /.FALSE./







      IF (ICHAR(OLDTXT(1:1)).EQ.ICHAR(TEXT(1:1))) THEN
         IF (OLDTXT.EQ.TEXT(1:4)) THEN
            MOL009=OLDRESULT
            GOTO 998
         END IF
      END IF
      MOL009=INDEX(
     +' OH2 H2O DOD HOH OHH WAT TIP D2O OW SOL OW1 AHOH BHOH CHOH',
     + TEXT(1:4)).GT.0



      OLDTXT=TEXT(1:4)
      OLDRESULT=MOL009



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL013 (FILE,IERR)

















      IMPLICIT      NONE
      INTEGER       IERR
      CHARACTER*(*) FILE







      CALL KLONKCLEAN
      IERR=0



      CALL WIFPUSHPPP (377,1)
      CALL MOL015 (FILE)
      CALL WIFPOPPPP (377)





      RETURN
      END
      SUBROUTINE MOL014 (LLINE,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR
      CHARACTER*(*) LLINE
      CHARACTER*80  LOCLIN







      CALL GVSCTB (LOCLIN,80)
      CALL MOL702 (LLINE,LOCLIN,IERR)
      IF (IERR.NE.0) THEN
         CALL GVSTTE ('?NEWE137')
         CALL GVSTT6 (LLINE)
         GOTO 998
      END IF



      IERR=0
      WIFPAR(491)=1
      CALL GVSSTX (SOUNAM(1),LLINE)



      CALL GVSCLF (11)
      CALL GETFILE (11,' ',LOCLIN,IERR)
      IF (IERR.NE.0) THEN
         CALL GVSTTE ('?M2411')
         CALL GVSTT6 (LLINE)
         GOTO 998
      ELSE
         CALL GVST6C ('?M1316',LOCLIN,.TRUE.)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE MOL015 (TEXT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ANISOU.INC'
      INTEGER       IERR, NUMDN1
      LOGICAL       GVFISF
      CHARACTER*80  LLINE
      CHARACTER*(*) TEXT







      IF (WIFPAR(377).EQ.0) CALL MOL100



      CALL GVSSTX (LLINE,TEXT)
      CALL KLONKCLEAN
      IF (.NOT.GVFISF(TEXT)) THEN
         CALL MOL715 (LLINE(1:4),IERR)
         IF (IERR.NE.0) THEN
            CALL GVSTTB ('?MOLC38')
            GOTO 999
         END IF
      END IF
      CALL MOL014 (LLINE,IERR)
      IF (IERR.NE.0) THEN
         CALL GVSTTB ('?MOLC38')
         GOTO 999
      END IF



      CALL MOL007




      CALL GVSSTX (SOUNAM(1),'DBASE')
      WIFPAR(491)=1
      CALL MOL703 (IERR)
      IF (IERR.NE.0) GOTO 998




      NUMDN1=0
      CALL WIFPUSHPPP (269,1)
      CALL WIFPUSHPPP (1052,0)
      CALL MOL003 (NUMDN1,IERR)
      IF (NUMDN1.EQ.0) CALL GVSTT6 ('?MOLB39')



      CALL KLONKDOWN
      CALL KLONKEND
      CALL WIFPOPPPP (1052)
      CALL GVSCLF (11)
      CALL GVSCLF (13)
      CALL MOL200



      CALL MOL042
      CALL WIFPOPPPP (269)



      CALL WIFPUSHPPP (1081,1)
      CALL USEDD1
      CALL WIFPOPPPP (1081)
      CALL MOL200









      CALL GVSCLF (12)
      GOTO 998



 999  CONTINUE
      CALL GVSEIR ('MOL015')



 998  CONTINUE


      RETURN
      END
      SUBROUTINE MOL016

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, JAAARR(2), JAASYM(2), NUM, IAA
      LOGICAL       WIFISR, WIFISO







      IF (NUMAAT.LE.NUMAAF) GOTO 998



      CALL ENVPROT



      DO 100 ISOUP=NUMSOU,1,-1
         IF (WIFISR(ISOUP)) GOTO 100
         IF (WIFISO(ISOUP)) GOTO 100
         DO 90 IAA=SOUADM(2,ISOUP),SOUADM(1,ISOUP)
            CALL FCONAAI (IAA,2.0,.FALSE.,JAAARR,JAASYM,NUM,2)
            IF (NUM.LE.0) THEN
               CALL GVSTT6 ('Delete entity that contacts no protein:')
               CALL SHOIAA (IAA)
               CALL MOL305A (IAA)
            END IF
   90    CONTINUE
  100 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL020 (INFILE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFLEN, IPOS, GVFPOS
      LOGICAL       GVFISF
      CHARACTER*80  LOCFIL, LIN, INFILE







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



      CALL GVSCTB (LOCFIL,80)
      CALL GVSSTX (LOCFIL,INFILE)
      CALL GVSSHL (LOCFIL)
      IF (GVFLEN(LOCFIL).NE.4) THEN
         IPOS=GVFPOS(LOCFIL,'_besttls')
         IF (IPOS.EQ.5) CALL GVSCTB (LOCFIL(5:80),76)
         IPOS=GVFPOS(LOCFIL,'.')
         IF (IPOS.EQ.5) CALL GVSCTB (LOCFIL(5:80),76)
      END IF
      IF (GVFLEN(LOCFIL).NE.4) THEN
         IF (WIFPAR(498).EQ.2) THEN
            CALL GVSTT6 ('File name not competible with PDB_REDO')
         END IF
         GOTO 998
      END IF
      CALL GVSCLC (LOCFIL)



      CALL GVSCTB (LINE,80)
      CALL GVSCCC (LINE,LOCFIL(1:4),'.pdb')
      IF (GVFISF(LINE)) CALL GVSDEL (LINE)



      CALL GVSCTB (LIN,80)
      CALL GVSCCC (LIN,LOCFIL(1:4),'_besttls.pdb')
      IF (.NOT.GVFISF(LIN)) THEN
         CALL GVSCTB (LINE,80)
         CALL GVSSTX (LINE,'wget http://www.cmbi.ru.nl/pdb_redo/')
         CALL GVSCPC (LINE,LOCFIL(2:3))
         CALL GVSCPC (LINE,'/')
         CALL GVSCPC (LINE,LOCFIL(1:4))
         CALL GVSCPC (LINE,'/')
         CALL GVSCPC (LINE,LOCFIL(1:4))
         CALL GVSCPC (LINE,'_besttls.pdb')
         CALL GVSCBC (LINE,LOCFIL(1:4))
         CALL GVSCPC (LINE,'.pdb')
         CALL GVSTT6 (LINE)
         CALL GVSSPL (LINE)
      END IF



      IF (GVFISF(LIN)) THEN
         CALL GVSCTB (LINE,80)
         CALL GVSSTX (LINE,'cp')
         CALL GVSCBC (LINE,LIN)
         CALL GVSCBC (LINE,LOCFIL(1:4))
         CALL GVSCPC (LINE,'.pdb')
         CALL GVSTT6 (LINE)
         CALL GVSSPL (LINE)
      ELSE
         IF (WIFPAR(498).EQ.2) THEN
            CALL GVSTT6 ('PDB_REDO file not found')
            GOTO 998
         END IF
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL037

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, IAT
      LOGICAL       WIFISO, WIFISH, WIFISA







      DO 100 ISOUP=NUMSOU,1,-1
         IF (WIFISO(ISOUP).OR.WIFISH(ISOUP)) GOTO 100
         IF (WIFISA(ISOUP)) GOTO 998
         DO 90 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
            DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (ISATOK(IAT).AND.WEIGHT(IAT).GE.0.5) GOTO 100
 80         CONTINUE
 90      CONTINUE
         CALL MOL101 (ISOUP)
         CALL MOL200
 100  CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL038

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'







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



      CALL GVSFMT ('?FMT1136')
      CALL GVSCTB (LINE,80)
      WRITE (LINE,FMT,ERR=999) WIFPAR(1276)
      CALL GVSTT6 (LINE)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL038')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL039

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ICNT, IMODEL, GVFPOS







      IF (WIFPAR(297).NE.0) THEN
         GOTO 998
      END IF



      IMODEL=0
      CALL GVSFMT ('?FMT1150')




      DO 10 ICNT=1,PDBCNT(1)

         READ (12,REC=ICNT,ERR=999) LINE
         IF (LINE(1:5).EQ.'MODEL') THEN
            IF (GVFPOS(LINE(1:40),' 0 ').NE.0) CALL SHOWTEXT ('?M2228')
            IMODEL=IMODEL+1
            WRITE (LINE,FMT,ERR=999) IMODEL
            WRITE (12,REC=ICNT,ERR=999) LINE
         END IF
 10   CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL039')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL051 (IJ,JUMP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IJ, GVFPOS
      LOGICAL       JUMP, ISNMRATOM, WRTSET, TOP007
      CHARACTER*1   PREVCH
      CHARACTER*4   PREVAA, PREVNM, PREVOA
      CHARACTER*6   ATMSTR
      SAVE          PREVAA, PREVNM, PREVOA, PREVCH
      DATA PREVAA   /'++++'/
      DATA PREVNM   /'++++'/
      DATA PREVOA   /'++++'/
      DATA PREVCH   /'='/







      JUMP=.FALSE.

         ATMSTR='ATOM  '




      IF (FAMTYP(THISTP).EQ.1) THEN
         IF (.NOT.TOP007(READIN(IJ)).AND.
     +       (THISAT(1:4).EQ.'OXT '.OR.THISAT(1:4).EQ.'O2  '.OR.
     +        THISAT(1:4).EQ.' O2 '.OR.THISAT(1:4).EQ.' OXT'.OR.
     +        THISAT(1:4).EQ.'  O2'.OR.THISAT(1:4).EQ.'  OT'.OR.
     +        THISAT(1:4).EQ.' OT '.OR.THISAT(1:4).EQ.' OT2'.OR.
     +        THISAT(1:4).EQ.'OT  '.OR.THISAT(1:4).EQ.'OT2 '.OR.
     +        (THISAT(1:2).EQ.' O'.AND.THISAT(3:3).EQ.''''.AND.
     +        THISAT(4:4).EQ.''''))) THEN
            USED(IJ)=.TRUE.
            CALL GVSCTB (LOCDN2,80)
            CALL MOL003C (READIN(IJ),IERR)
            IF (WIFPAR(329).NE.0) CALL GVSTT6 ('?M4635')
            CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
            CALL KLONKTOD (ATMSTR,THISAT,THISORG,THISAL,THISAA,
     +       THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,
     +       THISBF,THISMV,THISPN,THISOA,0,IERR)
            JUMP=.TRUE.
            GOTO 998
         END IF



      ELSE IF (FAMTYP(THISTP).EQ.3) THEN
         IF (THISAT.EQ.' O3P') THEN
            USED(IJ)=.TRUE.
            CALL GVSCTB (LOCDN2,80)
            CALL MOL003C (READIN(IJ),IERR)
            IF (WIFPAR(329).NE.0) CALL GVSTT6 ('?M4635')
            CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
            CALL KLONKTOD (ATMSTR,THISAT,THISORG,THISAL,THISAA,
     +       THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,
     +       THISBF,THISMV,THISPN,THISOA,0,IERR)
            JUMP=.TRUE.
            GOTO 998
         END IF




         IF (THISAT.EQ.' O1 '.OR.THISAT.EQ.' OXT') THEN
            USED(IJ)=.TRUE.
            CALL GVSCTB (LOCDN2,80)
            CALL MOL003C (READIN(IJ),IERR)
            IF (WIFPAR(329).NE.0) CALL GVSTT6 ('?M4635')
            CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
            CALL KLONKTOD (ATMSTR,THISAT,THISORG,THISAL,THISAA,
     +       THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,
     +       THISBF,THISMV,THISPN,THISOA,0,IERR)
            JUMP=.TRUE.
            GOTO 998
         END IF
      END IF



      IF ((FAMTYP(THISTP).EQ.1.OR.FAMTYP(THISTP).EQ.3.OR.
     +     FAMTYP(THISTP).EQ.7).AND.WIFPAR(1172).NE.0.AND.
     +     WIFPAR(84).NE.0) THEN
         IF (ISNMRATOM(THISTP,THISAT)) THEN
            USED(IJ)=.TRUE.
            CALL GVSCTB (LOCDN2,80)
            CALL MOL003C (READIN(IJ),IERR)
            IF (WIFPAR(329).NE.0) CALL GVSTT6 ('?M4635')
            CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
            CALL KLONKTOD (ATMSTR,THISAT,THISORG,THISAL,THISAA,
     +       THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,
     +       THISBF,THISMV,THISPN,THISOA,0,IERR)
            JUMP=.TRUE.
            GOTO 998
         END IF
      END IF




      IF (FAMTYP(THISTP).NE.1.AND.FAMTYP(THISTP).NE.3.AND.
     +    FAMTYP(THISTP).NE.7) THEN
         USED(IJ)=.TRUE.
         IF (GVFPOS(PREVAA,'HOH').EQ.0) THEN
            WRTSET=PREVAA.NE.THISAA.OR.PREVNM.NE.THISNM.OR.
     +             PREVOA.NE.THISOA.OR.PREVCH.NE.THISCH
         ELSE
            WRTSET=PREVAA.NE.THISAA.OR.PREVOA.NE.THISOA.OR.
     +             PREVCH.NE.THISCH
         END IF
         IF (WIFPAR(329).NE.0) CALL GVSTT6 ('?M4635')
         IF (WRTSET) THEN
            CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)

               PREVAA=THISAA
               PREVNM=THISNM
               PREVOA=THISOA

            PREVCH=THISCH
         END IF
         CALL KLONKTOD (READIN(IJ)(1:6),THISAT,THISORG,THISAL,
     +    THISAA,THISCH,THISNM,THISIC,THISX,THISY,THISZ,
     +    THISWT,THISBF,THISMV,THISPN,THISOA,0,IERR)
         JUMP=.TRUE.
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL056 (IERR)

















      IMPLICIT      NONE
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR







      IERR=0





      LASTAA='$$$$'
      LASTAT='$$$$'
      LASTNM='$$$$'
      LASTCH='$'
      LASTIC='$'
      LASTAL='$'
      ALTUSE='$'      





      RETURN
      END   
      SUBROUTINE MOL058 (LOCAAF,ATM_IS_OK,IJ)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       LOCAAF, IJ, I
      LOGICAL       ATM_IS_OK








      IF (IJ.EQ.1) THEN
         IF (WIFPAR(642).EQ.0.AND.WIFPAR(363).EQ.0) THEN
            IF (MOD(LOCAAF,10).EQ.0) THEN
               CALL GVSFMT ('?FMT243')
               CALL GVSCTB (LINE,80)
               WRITE (LINE,FMT,ERR=999) LOCAAF-9,LOCAAF,
     +              (ONESA3(I),I=LOCAAF-9,LOCAAF)
               CALL GVSTT6 (LINE)
            END IF
         END IF
      END IF



      IF (.NOT.ATM_IS_OK) THEN
         ISATOK(PNTAAS(LOCAAF)+IJ-1)=.FALSE.
         CALL GVSTO6 ('?MOLB08')
         CALL GVSFMT ('?FMT500')
         CALL GVSCTB (LINE,80)
         WRITE (LINE,FMT,ERR=999) LOCAAF,THISAA,THISNM,THISAT
         CALL GVSTT6 (LINE)
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('MOL058')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL059 (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR
      LOGICAL       INTERRUPTED







      IERR=0



      IF (NUMAAF.GT.MAXAA-100) THEN
         CALL TOOMANY ('?MOLC23')
         CALL MOL200
         IERR=1
         GOTO 998
      END IF
      IF (NUMATF.GT.MAXAT-1000) THEN
         CALL TOOMANY ('?MOLC24')
         IERR=1
         GOTO 998
      END IF



      IF (INTERRUPTED()) IERR=1



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL060X

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       CNT, CNTA, IT, JT, FT, F1(MAXTAT), IFOUND, INDAA3,
     +              ILOOP, ICHA, IAATYP, KT
      REAL          GVFDV3
      LOGICAL       GVFISC, GVFISN, GVFIBN, DONE, ARE_PAIR, MOL009
      CHARACTER*1   C1(MAXTAT), C2(MAXTAT)







      IF (ITT.LE.1) GOTO 998
      IF (WIFPAR(162).NE.0) GOTO 998
      IAATYP=INDAA3(READIN(1)(18:21))
      IF (GVFIBN(IAATYP,1,20)) GOTO 998
      IF (MOL009(READIN(1)(18:21))) GOTO 998



      CNT=0
      CNTA=0
      IFOUND=0
      CALL GVSIT0 (F1,MAXTAT)
      CALL GVSCTB (C1,MAXTAT)



      DO 20 IT=1,ITT



         IF (READIN(IT)(13:13).EQ.'H'.AND.
     +    (GVFISN(READIN(IT)(15:15)).OR.READIN(IT)(15:15).EQ.'''').AND.
     +    (GVFISN(READIN(IT)(16:16)).OR.READIN(IT)(16:16).EQ.'''')) 
     +    GOTO 20
         IF (READIN(IT)(77:77).EQ.' ') THEN
            IF (READIN(IT)(13:13).EQ.READIN(IT)(78:78)) GOTO 20
         ELSE
            IF (READIN(IT)(13:14).EQ.READIN(IT)(77:78)) GOTO 20
         END IF



         IF (GVFISC(READIN(IT)(13:13))) THEN
            IF (IFOUND.GT.0) THEN
               DO 10 FT=1,IFOUND
                  IF (READIN(IT)(13:14).EQ.READIN(IT)(77:78)) GOTO 10
                  IF (READIN(IT)(13:13).EQ.C1(FT).AND.
     +                READIN(IT)(17:17).EQ.C2(FT)) THEN
                     IF (READIN(IT)(13:14).EQ.'FE') GOTO 10
                     IF (READIN(IT)(13:14).EQ.'CL') GOTO 10
                     IF (READIN(IT)(13:14).EQ.'SE') GOTO 10
                     F1(FT)=F1(FT)+1
                     GOTO 20
                  END IF
 10            CONTINUE
            END IF
            IFOUND=IFOUND+1
            C1(IFOUND)=READIN(IT)(13:13)
            C2(IFOUND)=READIN(IT)(17:17)
            F1(IFOUND)=1
         END IF
 20   CONTINUE







      IF (IFOUND.GE.1) THEN
         DO 40 FT=1,IFOUND
            IF (F1(FT).GE.5) THEN
               DO 30 IT=1,ITT
                  IF (READIN(IT)(13:14).EQ.READIN(IT)(77:78)) GOTO 30
                  IF (READIN(IT)(13:13).EQ.C1(FT).AND.C1(FT).NE.'''') 
     +             READIN(IT)(13:13)=' '
 30            CONTINUE
            END IF
 40      CONTINUE
      END IF



      DO 60 IT=2,ITT
         DO 50 JT=1,IT-1
            IF (READIN(JT)(13:16).EQ.READIN(IT)(13:16)) THEN
               CNT=CNT+1
               CALL GVSFMT ('?FMT672')
               READ (READIN(IT),FMT,ERR=998) CV(1),CV(2),CV(3)
               READ (READIN(JT),FMT,ERR=998) XYZ(1),XYZ(2),XYZ(3)
               IF (GVFDV3(XYZ,CV).LT.2.5) CNTA=CNTA+1
               GOTO 60
            END IF
 50      CONTINUE
 60   CONTINUE



      ICHA=0
      DO 100 ILOOP=1,ITT
         DONE=.FALSE.
         DO 90 IT=1,ITT-1
            DO 80 JT=IT+1,ITT
               IF (READIN(JT)(13:17).EQ.READIN(IT)(13:17)) THEN
                  IF (ARE_PAIR(IT,JT)) GOTO 80
                  ICHA=MOD(ICHA+1,37)+1
                  IF (JT.LT.ITT) THEN
                     DO 70 KT=JT+1,ITT
                        IF (ARE_PAIR(JT,KT)) THEN
                           CALL DISAMB (KT,ICHA)
                           DONE=.TRUE.
                        END IF
 70                  CONTINUE
                  END IF
                  CALL DISAMB (JT,ICHA)
                  DONE=.TRUE.
               END IF
 80         CONTINUE
 90      CONTINUE
         IF (.NOT.DONE) GOTO 998
 100  CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL060

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IT, JT, INDAA3, ILOOP, ICHA, IAATYP, KT, IAT
      LOGICAL       GVFIBN, DONE, ARE_PAIR, MOL009







      IF (ITT.LE.1) GOTO 998
      IF (WIFPAR(162).NE.0) GOTO 998
      IAATYP=INDAA3(READIN(1)(18:21))
      IF (GVFIBN(IAATYP,1,20)) GOTO 998
      IF (MOL009(READIN(1)(18:21))) GOTO 998



      DO 10 IAT=1,ITT
         IF (READIN(IAT)(13:14).EQ.READIN(IAT)(77:78)) GOTO 10
         IF (READIN(IAT)(14:14).EQ.READIN(IAT)(78:78)) THEN
            IF (READIN(IAT)(77:77).EQ.' ') THEN
               READIN(IAT)(13:13)=' '
            ELSE
               CALL GVSTT6 (READIN(IAT)(1:79))
               CALL GVSCOD ('What is the atom name in the line above?')
            END IF
         ELSE
            
         END IF
 10   CONTINUE



      ICHA=0
      DO 100 ILOOP=1,ITT
         DONE=.FALSE.
         DO 90 IT=1,ITT-1
            DO 80 JT=IT+1,ITT
               IF (READIN(JT)(13:17).EQ.READIN(IT)(13:17).AND.
     +             READIN(JT)(73:76).EQ.READIN(IT)(73:76)) THEN
                  IF (ARE_PAIR(IT,JT)) GOTO 80
                  ICHA=MOD(ICHA+1,37)+1
                  IF (JT.LT.ITT) THEN
                     DO 70 KT=JT+1,ITT
                        IF (ARE_PAIR(JT,KT)) THEN
                           CALL DISAMB (KT,ICHA)
                           DONE=.TRUE.
                        END IF
 70                  CONTINUE
                  END IF
                  CALL DISAMB (JT,ICHA)
                  DONE=.TRUE.
               END IF
 80         CONTINUE
 90      CONTINUE
         IF (.NOT.DONE) GOTO 998
 100  CONTINUE



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION ARE_PAIR(IT,JT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IT, JT
      REAL          IO, JO
      LOGICAL       GVFRIN







      ARE_PAIR=.FALSE.



      IF (READIN(IT)(13:16).NE.READIN(JT)(13:16)) GOTO 998



      IF (READIN(IT)(17:17).NE.' '.AND.READIN(IT)(17:17).EQ.
     + READIN(JT)(17:17)) GOTO 998



      READ (READIN(IT)(57:60),'(F4.2)',ERR=999) IO
      READ (READIN(JT)(57:60),'(F4.2)',ERR=999) JO
      IF (.NOT.GVFRIN(IO+JO,0.9,1.1)) GOTO 998



      ARE_PAIR=.TRUE.
      GOTO 998



  999 CONTINUE
      CALL GVSEIR ('ARE_PAIR')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE DISAMB (ILINE,ICHA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ILINE, ICHA
      LOGICAL       GVFIBN







      IF (.NOT.GVFIBN(ILINE,1,ITT)) GOTO 999



      IF (READIN(ILINE)(15:15).EQ.' ') THEN
         READIN(ILINE)(15:15)=CHADEF2(ICHA:ICHA)
         IF (READIN(ILINE+1)(1:6).EQ.'ANISOU') 
     +    READIN(ILINE+1)(15:15)=CHADEF2(ICHA:ICHA)
      ELSE
         READIN(ILINE)(16:16)=CHADEF2(ICHA:ICHA)
         IF (READIN(ILINE+1)(1:6).EQ.'ANISOU') 
     +    READIN(ILINE+1)(16:16)=CHADEF2(ICHA:ICHA)
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('DISAMB')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE MOL061 (IUNIT,IHSKIP,JUMP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IUNIT, IHSKIP
      LOGICAL       JUMP, WRTSET, MOL009, PREVWAT
      CHARACTER*1   PREVCH
      CHARACTER*4   PREVAA, PREVNM, PREVOA
      SAVE          PREVAA, PREVNM, PREVOA, PREVCH
      DATA PREVAA   /'++++'/
      DATA PREVNM   /'++++'/
      DATA PREVOA   /'++++'/
      DATA PREVCH   /'='/







      JUMP=.FALSE.











      IF (WIFPAR(1505).NE.0.AND.(THISAT(2:2).EQ.'Q'.OR.
     +    THISAT(2:2).EQ.'M').AND.THISAT(1:1).EQ.' ') THEN
         WIFPAR(1186)=WIFPAR(1186)+1

         JUMP=.TRUE.
         GOTO 998
      END IF



      IF (WIFPAR(84).EQ.0) THEN
         IF (THISFAM.EQ.1.OR.THISFAM.EQ.3.OR.THISFAM.EQ.7) THEN
            IF (HATOM) THEN
               IHSKIP=IHSKIP+1

               JUMP=.TRUE.
               GOTO 998
            END IF
         END IF
      END IF



      IF (WIFPAR(277).NE.0) THEN
         IF (THISFAM.EQ.3.OR.THISFAM.EQ.7) THEN

            JUMP=.TRUE.
            GOTO 998
         END IF
      END IF




      IF (IUNIT.NE.13) THEN
         PREVWAT=MOL009(PREVAA)


         IF (THISFAM.NE.1.AND.THISFAM.NE.3.AND.THISFAM.NE.6.AND.
     +       THISFAM.NE.7) THEN
            IF (.NOT.PREVWAT) THEN
               WRTSET=PREVAA.NE.THISAA.OR.PREVNM.NE.THISNM.OR.
     +                PREVOA.NE.THISOA.OR.PREVCH.NE.THISCH
            ELSE
               WRTSET=PREVAA.NE.THISAA.OR.PREVOA.NE.THISOA.OR.
     +                PREVCH.NE.THISCH
            END IF
            IF (WIFPAR(329).NE.0) PRINT*,'KLONK IN 061:'
            IF (WRTSET) THEN
               CALL KLONKSET (WIFPAR(491),WIFPAR(846),IERR)
               CALL GVSSTX (PREVAA,THISAA)
               CALL GVSSTX (PREVNM,THISNM)
               CALL GVSSTX (PREVOA,THISOA)
               CALL GVSSTX (PREVCH,THISCH)
            END IF
            CALL KLONKTOD ('ATOM  ',THISAT,THISORG,THISAL,THISAA,
     +       THISCH,THISNM,THISIC,THISX,THISY,THISZ,THISWT,THISBF,
     +       THISMV,THISPN,THISOA,0,IERR)
            JUMP=.TRUE.
         END IF
      END IF



  998 CONTINUE


      RETURN
      END   
      CHARACTER*4 FUNCTION T4(CHAR5)

















      IMPLICIT      NONE
      CHARACTER*5   CHAR5
      CHARACTER*4   CHAR4







      CALL GVSSTX (CHAR4,'?M4632')



      IF (CHAR5(1:1).NE.' '.AND.CHAR5(5:5).NE.' ') THEN
         CALL GVST6C ('?M4633',CHAR5,.FALSE.)
         PRINT*,' Iow: |',CHAR5,'|'
         CALL GVSKIL
         CALL GVSSTX (CHAR4,CHAR5(1:4))
         GOTO 998
      END IF



      IF (CHAR5(5:5).EQ.' ') THEN
         CALL GVSSTX (CHAR4,CHAR5(1:4))
      ELSE
         CALL GVSSTX (CHAR4,CHAR5(2:5))
      END IF



  998 CONTINUE
      T4=CHAR4


      RETURN
      END   
      LOGICAL FUNCTION T54EQUAL(CHAR5,CHAR4)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      CHARACTER*4   CHAR4, T4, TEMP
      CHARACTER*5   CHAR5
      LOGICAL       CH4EQCH4, T54E, WIFIC1, WIFIC2







      TEMP=T4(CHAR5)



      T54E=CH4EQCH4(TEMP,CHAR4)



      IF (WIFPAR(175).EQ.0) THEN
         IF (.NOT.T54E) T54E=(WIFIC1(TEMP).AND.WIFIC1(CHAR4))
         IF (.NOT.T54E) THEN
            T54E=(WIFIC2(TEMP).AND.WIFIC2(CHAR4))
         END IF
      END IF



      T54EQUAL=T54E


      RETURN
      END   
      LOGICAL FUNCTION T54EQUAL2(CHAR5,CHAR4)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      CHARACTER*4   CHAR4, T4, TEMP
      CHARACTER*5   CHAR5
      LOGICAL       CH4EQCH4, T54E, WIFIC1, WIFIC2







      TEMP=T4(CHAR5)



      T54E=CH4EQCH4(TEMP,CHAR4)



      IF (WIFPAR(175).EQ.0) THEN
         IF (.NOT.T54E) T54E=(WIFIC1(TEMP).AND.WIFIC1(CHAR4))
         IF (.NOT.T54E) THEN
            T54E=(WIFIC2(TEMP).AND.WIFIC2(CHAR4))
         END IF
      END IF



      T54EQUAL2=T54E


      RETURN
      END   
      SUBROUTINE BNDKIL (TEXT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, IBND, ICNT
      CHARACTER*(*) TEXT
      LOGICAL       CH4EQCH4







      DO 30 IAA=1,NUMAAT
         DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
            ICNT=0
            DO 10 IBND=1,8
               IF (BOUND_TO(IBND,IAT).NE.0) ICNT=ICNT+1
               IF (ICNT.GE.3) THEN
                  CALL GVST6C ('?M4594',TEXT,.TRUE.)
                  CALL GVSKIL
               END IF
 10         CONTINUE
 20      CONTINUE
 30   CONTINUE



      IF (NUMSOU.GE.3) THEN
         IAA=SOUADM(1,3)
         IAT=PNTAAS(IAA)
         IF (CH4EQCH4(ONESAT(IAT),' O2 ').AND.
     +       CH4EQCH4(ONESA3(IAA),' HOH')) THEN
            CALL SHOIAA (IAA)
            CALL DIF025 (IAT)
            CALL GVST6C ('?M4595',TEXT,.TRUE.)
            CALL GVSKIL
         END IF
      END IF





      RETURN
      END   
