



      SUBROUTINE HBO000 (DONE)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INTEGER       IAA, IFT1, IFT2
      LOGICAL       DONE







      IF (.NOT.MENUSED(18)) THEN
         CALL HBO005 (3)
      END IF



      IF (OPTIN.EQ.MEN6COD(18)) GOTO 998
      CALL MEN006 (OPTIN,DONE)



      IF (OPTIN.EQ.'DEBUG ') THEN
         IF (WIFPAR(488).EQ.0) THEN
            WIFPAR(488)=1
            CALL GVSTT6 ('?DBGON')
         ELSE
            WIFPAR(488)=0
            CALL GVSTT6 ('?DBGOFF')
         END IF
         DONE=.TRUE.
      END IF




  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO001




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'NOTINC.INC'
      INTEGER       IFT1, IFT2, IAA, JFT1, JFT2, JAA, IAT, JAT,
     +              IWOSWO, IDOUBL, IERR
      REAL          XYZ1(3), XYZ2(3), CUTACC, DMIN, D12, ANGLA1, 
     +              ANGLA2,ANGLH1, ANGLH2, DIST1, DIST2
      LOGICAL       ISWAT, ISWAT1, ISWAT2, SAME12, WASIR6, WIFIRW,
     +              ISHBO1, ISHBO2







      IF (NUMAAF.LT.1) THEN
         CALL GVSTT6 ('?>2AA')
         GOTO 998
      END IF









      CALL GRTVIN
      CALL HBO004
      CUTACC=WIFPAR(481)/100.0



      IF (NOTOUT) THEN
         IFT1=1
         IFT2=NUMAAF
      ELSE
         CALL WIFGRN (IFT1,IFT2,'?RANGE1')
      END IF
      CALL GVSCTB (TPTXLN,LENTPT)
      IF (IFT1.EQ.0) GOTO 998
      IF (NOTOUT) THEN
         JFT1=1
         JFT2=NUMAAF
      ELSE
         CALL WIFGRN (JFT1,JFT2,'?RANGE2')
      END IF
      CALL GVSCTB (TPTXLN,LENTPT)
      IF (JFT1.EQ.0) GOTO 998



      SAME12=IFT1.EQ.JFT1.AND.IFT2.EQ.JFT2






      CALL HBO010



      WASIR6=IRSTAT(6).EQ.1
      IF (WASIR6) CALL GRTKON
      DO 100 IAA=IFT1,IFT2
         ISWAT1=WIFIRW(IAA)



         DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.USABLE(IAT)) GOTO 80



            DO 90 JAA=JFT1,JFT2
               ISWAT2=WIFIRW(JAA)
               ISWAT=ISWAT1.OR.ISWAT2



               IF (SAME12.AND.IAA.GT.JAA) GOTO 90



               DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +              (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +              (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
               IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+SPHRAD(4,JAA))**2) THEN
                  IF (.NOT.ISWAT) GOTO 90
               END IF



               DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  IF (.NOT.USABLE(JAT)) GOTO 70
                  IF (IAT.EQ.JAT) GOTO 70
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                  IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                  D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                     (YCOORD(IAT)-YCOORD(JAT))**2+
     +                     (ZCOORD(IAT)-ZCOORD(JAT))**2)
                  IF (D12.LT.CUTACC) THEN



                     CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



                     IF (ISHBO1) THEN
                        IF (IWOSWO.LE.1) THEN
                           CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        ELSE
                           CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        END IF
                     END IF
                  END IF
   70          CONTINUE
   90       CONTINUE
   80    CONTINUE



         CALL GRASAVE
  100 CONTINUE



      CALL GRAMOL (' ')



      IF (WASIR6) CALL GRTKOF



      CALL GVSFMT ('?FMT106')
      CALL GVSSTX (LINE,'?CALHBF')
      WRITE (LINE(50:80),FMT,ERR=999) IFT1,IFT2,JFT1,JFT2
      CALL SETHIS (LINE)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO001')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO001A





















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IAT, JAA, JAT, ITYPE, IWOSWO, IDOUBL, IERR
      LOGICAL       ISWAT, ISWAT1, ISWAT2, ISHBO1, ISHBO2, WIFIRW, TX
      REAL          XYZ1(3), XYZ2(3), CUTACC, DMIN, D12, ANGLA1, ANGLA2,
     +              ANGLH1, ANGLH2, DIST1, DIST2







      IF (NUMAAF.LT.1) THEN
         CALL GVSTT6 ('?>2AA')
         GOTO 998
      END IF









      CALL GRTVIN
      CALL HBO004
      CUTACC=WIFPAR(481)/100.0



      CALL GVSCLP
      CALL GVSNL6 (1)
      CALL WIFWTF ('?RANGES1',IERR)
      IF (IERR.NE.0) GOTO 998
      CALL GVSCPB (WRK2TF,WRK1TF,MAXAA)
      CALL GVSNL6 (1)
      CALL WIFPUSHPPP (845,0)
      CALL WIFWTF ('?RANGES2',IERR)
      IF (IERR.NE.0) GOTO 998
      CALL WIFPOPPPP (845)
      DO 5 IAA=1,MAXAA
         TX=WRK1TF(IAA)
         WRK1TF(IAA)=WRK2TF(IAA)
         WRK2TF(IAA)=TX
    5 CONTINUE






      CALL HBO010



      DO 100 IAA=1,NUMAAT
         IF (.NOT.WRK1TF(IAA)) GOTO 100
         ITYPE=SOUADM(5,CHAINN(2,IAA))
         IF (ITYPE.EQ.2.OR.ITYPE.EQ.4) GOTO 100
         ISWAT1=WIFIRW(IAA)



         DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.USABLE(IAT)) GOTO 80



            DO 90 JAA=1,NUMAAT
               IF (.NOT.WRK2TF(JAA)) GOTO 90
               ITYPE=SOUADM(5,CHAINN(2,JAA))
               IF (ITYPE.EQ.2.OR.ITYPE.EQ.4) GOTO 90
               ISWAT2=WIFIRW(JAA)
               ISWAT=ISWAT1.OR.ISWAT2



               IF (IAA.GT.JAA.AND.WRK2TF(IAA).AND.WRK1TF(JAA)) GOTO 90



               DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +              (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +              (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
               IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+SPHRAD(4,JAA))**2) THEN
                  IF (.NOT.ISWAT) GOTO 90
               END IF



               DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  IF (.NOT.USABLE(JAT)) GOTO 70
                  IF (IAT.EQ.JAT) GOTO 70
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                  IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                  D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                     (YCOORD(IAT)-YCOORD(JAT))**2+
     +                     (ZCOORD(IAT)-ZCOORD(JAT))**2)
                  IF (D12.LT.CUTACC) THEN



                     CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



                     IF (ISHBO1) THEN
                        IF (IWOSWO.LE.1) THEN
                           CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        ELSE
                           CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        END IF
                     END IF
                  END IF
   70          CONTINUE
   90       CONTINUE
   80    CONTINUE



         CALL GRASAVE
  100 CONTINUE



      CALL GRAMOL (' ')



      CALL GVSSTX (LINE,'?HBOH01')
      CALL SETHIS (LINE)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO001B



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IAT, JAA, JAT, IWOSWO, IDOUBL, ISOUP,
     +              IFT1, IFT2, JFT1, JFT2, IERR
      LOGICAL       ISWAT, ISWAT1, ISWAT2, SAME12, ISHBO1, ISHBO2, 
     +              WIFIRW
      REAL          XYZ1(3), XYZ2(3), CUTACC, DMIN, D12, ANGLA1, ANGLA2,
     +              ANGLH1, ANGLH2, DIST1, DIST2







      IF (NUMAAF.LT.1) THEN
         CALL GVSTT6 ('?>2AA')
         GOTO 998
      END IF











      DO 300 ISOUP=1,NUMSOU
         IF (SOUADM(5,ISOUP).EQ.2) GOTO 300
         CALL GVSFMT ('?FMT105')
         CALL GVSSTX (LINE,'?HBOHWM')
         WRITE (LINE(50:80),FMT,ERR=999) ISOUP
         CALL GVSRDB (LINE)
         CALL GVSBOX (LINE)
         CALL GRTVIN
         CALL HBO004
         CUTACC=WIFPAR(481)/100.0
         IFT1=SOUADM(1,ISOUP)
         IFT2=SOUADM(2,ISOUP)
         JFT1=IFT1
         JFT2=IFT2
         SAME12=.TRUE.






         CALL HBO010



         DO 100 IAA=IFT1,IFT2
            IF (RESTYP(IAA).EQ.0) GOTO 100
            ISWAT1=WIFIRW(IAA)



            DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.USABLE(IAT)) GOTO 80



               DO 90 JAA=JFT1,JFT2
                  IF (RESTYP(JAA).EQ.0) GOTO 90
                  ISWAT2=WIFIRW(JAA)
                  ISWAT=ISWAT1.OR.ISWAT2



                  IF (SAME12.AND.IAA.GT.JAA) GOTO 90



                  DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +                 (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +                 (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
                  IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+
     +                SPHRAD(4,JAA))**2) THEN
                     IF (.NOT.ISWAT) GOTO 90
                  END IF



                  DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                     IF (.NOT.USABLE(JAT)) GOTO 70
                     IF (IAT.EQ.JAT) GOTO 70
                     IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                     IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                     D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                        (YCOORD(IAT)-YCOORD(JAT))**2+
     +                        (ZCOORD(IAT)-ZCOORD(JAT))**2)
                     IF (D12.LT.CUTACC) THEN



                        CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                   DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                   XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



                        IF (ISHBO1) THEN
                           IF (IWOSWO.LE.1) THEN
                              CALL HBO007 (IAT,JAT,D12,DIST1,
     +                         DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                         XYZ1,XYZ2)
                           ELSE
                              CALL HBO007 (JAT,IAT,D12,DIST1,
     +                         DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                         XYZ1,XYZ2)
                           END IF
                        END IF
                     END IF
   70             CONTINUE
   90          CONTINUE
   80       CONTINUE
            CALL GRTVIN
  100    CONTINUE
  300 CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO001B')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO001C



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IAT, JAA, JAT, IWOSWO, IDOUBL, ISOUP,
     +              JSOUP, IFT1, IFT2, JFT1, JFT2, IERR
      LOGICAL       ISWAT, ISWAT1, ISWAT2, ISHBO1, ISHBO2, WIFIRW
      REAL          XYZ1(3), XYZ2(3), CUTACC, DMIN, D12, ANGLA1, ANGLA2,
     +              ANGLH1, ANGLH2, DIST1, DIST2







      IF (NUMSOU.LE.1) GOTO 998
      IF (SOUADM(5,2).NE.1) GOTO 998











      DO 300 ISOUP=1,NUMSOU-1
      DO 200 JSOUP=ISOUP+1,NUMSOU
         CALL GVSSTX (LINE,'?HBOHBM')
         CALL GVSFMT ('?FMT104')
         WRITE (LINE(50:80),FMT,ERR=999) ISOUP,JSOUP
         CALL GVSRDB (LINE)
         CALL GVSBOX (LINE)
         CALL GRTVIN
         CALL HBO004
         CUTACC=WIFPAR(481)/100.0
         IFT1=SOUADM(1,ISOUP)
         IFT2=SOUADM(2,ISOUP)
         JFT1=SOUADM(1,JSOUP)
         JFT2=SOUADM(2,JSOUP)






         CALL HBO010



         DO 100 IAA=IFT1,IFT2
            IF (RESTYP(IAA).EQ.0) GOTO 100
            ISWAT1=WIFIRW(IAA)



            DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.USABLE(IAT)) GOTO 80



               DO 90 JAA=JFT1,JFT2
                  IF (RESTYP(JAA).EQ.0) GOTO 90
                  ISWAT2=WIFIRW(JAA)
                  ISWAT=ISWAT1.OR.ISWAT2



                  DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +                 (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +                 (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
                  IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+
     +                SPHRAD(4,JAA))**2) THEN
                     IF (.NOT.ISWAT) GOTO 90
                  END IF



                  DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                     IF (.NOT.USABLE(JAT)) GOTO 70
                     IF (IAT.EQ.JAT) GOTO 70
                     IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                     IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                     D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                        (YCOORD(IAT)-YCOORD(JAT))**2+
     +                        (ZCOORD(IAT)-ZCOORD(JAT))**2)
                     IF (D12.LT.CUTACC) THEN



                        CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                   DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                   XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



                        IF (ISHBO1) THEN
                           IF (IWOSWO.LE.1) THEN
                              CALL HBO007 (IAT,JAT,D12,DIST1,
     +                         DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                         XYZ1,XYZ2)
                           ELSE
                              CALL HBO007 (JAT,IAT,D12,DIST1,
     +                         DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                         XYZ1,XYZ2)
                           END IF
                        END IF
                     END IF
   70             CONTINUE
   90          CONTINUE
   80       CONTINUE
            CALL GRTVIN
  100    CONTINUE
  200 CONTINUE
  300 CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO001C')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO001D




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, JFT1, JFT2, JAA, IAT, JAT, LOCJAT,
     +              IWOSWO, IDOUBL, IERR
      REAL          XYZ1(3), XYZ2(3), CUTACC, DMIN, D12, ANGLA1, 
     +              ANGLA2, ANGLH1, ANGLH2, DIST1, DIST2
      LOGICAL       WIFIRR, ISHBO1, ISHBO2







      IAA=WIFPAR(570)
      IF (.NOT.WIFIRR(IAA)) GOTO 998
      IF (RESTYP(IAA).EQ.1.OR.RESTYP(IAA).EQ.2.OR.
     +    RESTYP(IAA).EQ.5.OR.RESTYP(IAA).EQ.6.OR.
     +    RESTYP(IAA).EQ.8.OR.RESTYP(IAA).EQ.10.OR.
     +    RESTYP(IAA).EQ.11.OR.RESTYP(IAA).EQ.13.OR.
     +    RESTYP(IAA).EQ.18.OR.RESTYP(IAA).EQ.21) THEN
         GOTO 998
      END IF
      CUTACC=WIFPAR(481)/100.0






      JFT1=SOUADM(1,CHAINN(2,IAA))
      JFT2=SOUADM(2,CHAINN(2,IAA))



      DO 101 JAA=JFT1,JFT2
         DO 91 JAT=PNTAAS(JAA),PNTAAE(JAA)
            LOCJAT=JAT-PNTAAS(JAA)+1
            USABLE(JAT)=HBOPOS(RESTYP(JAA),LOCJAT)
            DONACC(JAT)=HBOPAR(RESTYP(JAA),LOCJAT)
   91    CONTINUE
  101 CONTINUE



      DO 80 IAT=PNTAAS(IAA)+4,PNTAAE(IAA)
         IF (.NOT.USABLE(IAT)) GOTO 80



         DO 90 JAA=JFT1,JFT2



            DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +           (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +           (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
            IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+SPHRAD(4,JAA))**2)
     +       GOTO 90



            DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
               IF (.NOT.USABLE(JAT)) GOTO 70
               IF (IAT.EQ.JAT) GOTO 70
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
               IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



               D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                  (YCOORD(IAT)-YCOORD(JAT))**2+
     +                  (ZCOORD(IAT)-ZCOORD(JAT))**2)
               IF (D12.LT.CUTACC) THEN



                  CALL HBO030A (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +             DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +             XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
               END IF
   70       CONTINUE
   90    CONTINUE
   80 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO001F




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'NOTINC.INC'
      INTEGER       IAA, JAA, IAT, JAT, IWOSWO, IDOUBL, IERR
      REAL          XYZ1(3), XYZ2(3), CUTACC, DMIN, D12, ANGLA1, 
     +              ANGLA2, ANGLH1, ANGLH2, DIST1, DIST2
      LOGICAL       ISWAT, WIFIRA, WIFIRW,
     +              ISHBO1, ISHBO2







      IF (NUMAAF.LT.1) THEN
         CALL GVSTT6 ('?>2AA')
         GOTO 998
      END IF









      CUTACC=WIFPAR(481)/100.0






      CALL HBO010



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



         DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.USABLE(IAT)) GOTO 80



            DO 90 JAA=1,NUMAAT



               ISWAT=WIFIRW(JAA)
               DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +              (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +              (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
               IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+SPHRAD(4,JAA))**2) THEN
                  IF (.NOT.ISWAT) GOTO 90
               END IF



               DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  IF (.NOT.USABLE(JAT)) GOTO 70
                  IF (IAT.EQ.JAT) GOTO 70
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                  IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                  D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                     (YCOORD(IAT)-YCOORD(JAT))**2+
     +                     (ZCOORD(IAT)-ZCOORD(JAT))**2)
                  IF (D12.LT.CUTACC) THEN



                     CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



                     IF (ISHBO1) THEN
                        USEAT(IAT)=.TRUE.
                        USEAT(JAT)=.TRUE.
                     END IF
                  END IF
   70          CONTINUE
   90       CONTINUE
   80    CONTINUE
  100 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO003

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      REAL          XYZH(3), XYZB(3), XYZC(3), XYZR(3)
      INTEGER       FIXED, IAA, IAT, IERR
      LOGICAL       GRAPON, REALH, USECONE, GVFYON, WIFIRW







      IF (.NOT.GRAPON()) GOTO 998



      CALL GRTVIN



      CALL SHOWTEXTIF ('?HBOMS1')
      CALL WIFWTF (' ',IERR)
      IF (IERR.GT.0) GOTO 998
      USECONE=GVFYON('?HBODCN',' ')



      CALL HBO010



      DO 20 IAA=1,NUMAAT
         IF (WIFIRW(IAA)) GOTO 20
         IF (.NOT.WRK1TF(IAA)) GOTO 20 



         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)



            IF (USABLE(IAT).AND.DONACC(IAT).GE.0) THEN





               CALL HBO012 (IAT,XYZH,XYZB,XYZC,FIXED,REALH)



               IF (FIXED.GT.0) THEN
                  CALL GRTLIN (XCOORD(IAT),YCOORD(IAT),ZCOORD(IAT),
     +             XYZH(1),XYZH(2),XYZH(3),ATCOLR(IAT)+10,IERR)
                  IF (FIXED.GT.1) THEN
                     CALL GRTLIN (XCOORD(IAT),YCOORD(IAT),ZCOORD(IAT),
     +                XYZB(1),XYZB(2),XYZB(3),ATCOLR(IAT)+10,IERR)
                     IF (FIXED.GT.2) THEN
                        CALL GRTLIN (XCOORD(IAT),YCOORD(IAT),
     +                   ZCOORD(IAT),XYZC(1),XYZC(2),XYZC(3),
     +                   ATCOLR(IAT)+10,IERR)
                     END IF
                  END IF
               ELSE





                  IF (USECONE) THEN
                     CALL HBO013 (IAT,XYZC,XYZR,IERR)



                     IF (IERR.EQ.0) CALL HBO014 (IAT,XYZC,XYZR)
                  END IF
               END IF
            END IF
   10    CONTINUE



         CALL GRASAVE
   20 CONTINUE



      CALL GRAMOL (' ')



      CALL SETHIS ('?HBOH02')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO004

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'







      CALL GVSNL6 (2)
      CALL GVSTT6 ('?HYDPAR')
      CALL GVSFMT ('?FMT413')

      CALL GVSSTX (LINE,'?HBOMDA')
      WRITE (LINE(70:80),FMT,ERR=999) WIFPAR(481)/100.0
      CALL GVSRDB (LINE)
      CALL GVSTT6 (LINE)

      CALL GVSSTX (LINE,'?HBOMHA')
      WRITE (LINE(70:80),FMT,ERR=999) WIFPAR(484)/100.0
      CALL GVSRDB (LINE)
      CALL GVSTT6 (LINE)

      CALL GVSSTX (LINE,'?HBOMAH')
      WRITE (LINE(70:80),FMT,ERR=999) FLOAT(WIFPAR(485))
      CALL GVSRDB (LINE)
      CALL GVSTT6 (LINE)

      CALL GVSSTX (LINE,'?HBOMAA')
      WRITE (LINE(70:80),FMT,ERR=999) FLOAT(WIFPAR(486))
      CALL GVSRDB (LINE)
      CALL GVSTT6 (LINE)

      IF (WIFPAR(1012).GT.0) THEN
         IF (WIFPAR(488).EQ.0) THEN
            CALL GVSTT6 ('?HDBOFF')
         ELSE
            CALL GVSTT6 ('?HDBON')
         END IF
      END IF
      CALL GVSNL6 (1)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO004')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO005 (INMODE)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       PARSET(4,6), MODE, INMODE
      LOGICAL       GVFIBN
      SAVE          PARSET
      DATA PARSET  /400,300,75,120,
     +              375,275,75,120,
     +              350,250,60,90,
     +              325,225,60,90,
     +              300,200,45,75,
     +              999,999,180,180/










      MODE=INMODE
      IF (.NOT.GVFIBN(MODE,1,6)) MODE=3










      WIFPAR(481)=PARSET(1,MODE)
      WIFPAR(484)=PARSET(2,MODE)
      WIFPAR(485)=PARSET(3,MODE)
      WIFPAR(486)=PARSET(4,MODE)
      WIFPAR(488)=0





      RETURN
      END
      SUBROUTINE HBO006



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IAA, IAT, JAA, JAT, IWOSWO, IDOUBL, IERR
      LOGICAL       ISHBO1, ISHBO2, GVFYON
      REAL          XYZ1(3), XYZ2(3), D12, ANGLA1, ANGLA2, 
     +              ANGLH1, ANGLH2, DIST1, DIST2, WIFDST
      CHARACTER*4   T4, CHAR4I, CHAR4J







      IF (USE300) THEN
         CALL GRTKOF
         CALL GRA009 (IAA,IAT,JAA,JAT)
         CALL GRTKON
         IF (IAA.EQ.0.OR.JAA.EQ.0) GOTO 998
      ELSE
         CALL GVSNL6 (1)
         CALL WIFGAT ('?ATOM-1',IAA,IAT,IERR)
         IF (IERR.NE.0) GOTO 998
         CALL GVSNL6 (1)
         CALL WIFGAT ('?ATOM-2',JAA,JAT,IERR)
         IF (IERR.NE.0) GOTO 998
      END IF



      CALL HBO010
      IF (RESTYP(IAA).EQ.7) THEN
         IF (IAT.GT.PNTAAS(IAA)+3) THEN
            CALL DIF015A (IAT,'?M3739')
            IF (GVFYON('?ISATDO',' ')) THEN
               DONACC(IAT)=1
            ELSE
               DONACC(IAT)=-1
            END IF
         END IF
      END IF
      IF (RESTYP(JAA).EQ.7) THEN
         IF (JAT.GT.PNTAAS(JAA)+3) THEN
            CALL DIF015A (JAT,'?M3739')
            IF (GVFYON('?ISATDO',' ')) THEN
               DONACC(JAT)=1
            ELSE
               DONACC(JAT)=-1
            END IF
         END IF
      END IF



      IF ((.NOT.USABLE(IAT)).OR.(.NOT.USABLE(JAT))) THEN
         CALL SHOWTEXT ('?HBOMS2')
         GOTO 998
      END IF
      IF (DONACC(IAT)*DONACC(JAT).EQ.1) THEN
         CALL GVSTT6 ('?HBOMS3')
         GOTO 998
      END IF




      CALL GRTVIN
      CALL HBO005 (6)
      CALL HBO004



      D12=WIFDST(IAT,JAT)



      CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,DIST1,DIST2,ANGLH1,
     + ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



      IF (IWOSWO.LE.1) THEN
         CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +    ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
      ELSE
         CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +    ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
      END IF



      CALL GRAMOL (' ')



      CALL HBO005 (3)
      CALL HBO004



      CALL GVSSTX (LINE,'?HBOPHB')
      CHAR4I=T4(ONESAT(IAT))
      CHAR4J=T4(ONESAT(JAT))
      CALL GVSFMT ('?FMT822')
      CALL GVSCTB (LINE,80)
      WRITE (LINE(50:80),FMT,ERR=999) IAA,CHAR4I,JAA,CHAR4J
      CALL SETHIS (LINE)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO006')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO007 (IAT,JAT,D12,DIST1,DIST2,ANGLH1,
     + ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)





















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'NOTINC.INC'
      INTEGER       IAT, JAT
      LOGICAL       HBO023, ISHBO1, ISHBO2
      REAL          XYZ1(3), XYZ2(3), D12, DIST1, DIST2, ANGLH1,
     +              ANGLH2, ANGLA1, ANGLA2
      CHARACTER*28 IATS, JATS, DIF000







      ISHBO1=HBO023(D12,DIST1,ANGLH1,ANGLA1)
      ISHBO2=HBO023(D12,DIST2,ANGLH2,ANGLA2)



      IF (.NOT.(ISHBO1.OR.ISHBO2)) GOTO 998



      IATS=DIF000(IAT)
      JATS=DIF000(JAT)



      IF (ISHBO2) THEN
         CALL GVSFMT ('?FMT824')
         CALL GVSCTB (BIGLIN,132)
         WRITE (BIGLIN,FMT,ERR=999) IATS,JATS
         CALL GVSTT6 (BIGLIN)

         CALL GVSFMT ('?FMT825')
         CALL GVSCTB (BIGLIN,132)
         WRITE (BIGLIN,FMT,ERR=999) D12,DIST1,ANGLH1,ANGLA1,XYZ1
         CALL GVSTT6 (BIGLIN)

         CALL GVSFMT ('?FMT825')
         CALL GVSCTB (BIGLIN,132)
         WRITE (BIGLIN,FMT,ERR=999) D12,DIST2,ANGLH2,ANGLA2,XYZ2
         CALL GVSTT6 (BIGLIN)

      ELSE
         CALL GVSFMT ('?FMT824')
         CALL GVSCTB (BIGLIN,132)
         WRITE (BIGLIN,FMT,ERR=999) IATS,JATS
         CALL GVSTT6 (BIGLIN)

         CALL GVSFMT ('?FMT825')
         CALL GVSCTB (BIGLIN,132)
         WRITE (BIGLIN,FMT,ERR=999) D12,DIST1,ANGLH1,ANGLA1,XYZ1
         CALL GVSTT6 (BIGLIN)

      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO007')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO008 (BOOLS)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       MX2
      PARAMETER     (MX2=200)
      INTEGER       CONIAT(MX2), CONSYM(MX2)
      INTEGER       IAA, IAT, JAT, ICON, SYMNEG, NUM, JSYM, ISYM
      LOGICAL       BOOLS(MAXAT), GVFYON, ISHBO
      REAL          HBOQVAL, CONDST(MX2)







      IF (NUMAAF.LT.2) THEN
         CALL GVSTT6 ('?SOUSML')
         GOTO 998
      END IF



      IF (WIFPAR(279).EQ.0) THEN
         IF (GVFYON('?HBOWTT',' ')) THEN
            CALL ENVTOT
         ELSE
            CALL ENVNOWAT
         END IF
      ELSE
         CALL ENVTOT
      END IF



      CALL GVSBTF (BOOLS,MAXAT)



      CALL HBO010



      DO 100 IAA=1,NUMAAT
         CALL GRTVIN



         DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.USABLE(IAT).OR.DONACC(IAT).GT.0) GOTO 80



            CALL FCONATI (IAT,3.0,CONIAT,CONSYM,CONDST,NUM,MX2)



            DO 55 ICON=1,NUM



               JAT=CONIAT(ICON)



               IF (PROTON(JAT).OR.(.NOT.ISATOK(JAT))) GOTO 55
               IF (.NOT.USABLE(JAT).OR.DONACC(JAT).LT.0) GOTO 55
               IF (BOOLS(JAT).AND.BOOLS(IAT)) GOTO 55
               JSYM=CONSYM(ICON)
               ISYM=SYMNEG(JSYM)
               ISHBO=(HBOQVAL(JAT,IAT,ISYM).GT.0.00001)
               BOOLS(JAT)=(BOOLS(JAT).OR.ISHBO)
               BOOLS(IAT)=(BOOLS(IAT).OR.ISHBO)
   55       CONTINUE
   80    CONTINUE
  100 CONTINUE



      CALL SETHIS ('?HBOROW')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO009





















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       ISHBO1, ISHBO2
      INTEGER       IATINIAA, WIF058, IWF481, IWF484, IWF485,
     +              IWF486, IAA, JAA, IAT, JAT, IWOSWO, IATLOC,
     +              JATLOC, IDOUBL, IERR, GVFPOS
      REAL          XYZ1(3), XYZ2(3), D12, DIST1, DIST2,
     +              ANGLH1, ANGLH2, ANGLA1, ANGLA2
      CHARACTER*4   RES1, RES2, ATM1, ATM2







      IF (NUMAAF.LT.1) THEN
         CALL GVSTT6 ('?SOULOW')
         GOTO 997
      END IF










      IWF481=WIFPAR(481)
      IWF484=WIFPAR(484)
      IWF485=WIFPAR(485)
      IWF486=WIFPAR(486)
      CALL GRTVIN
      CALL HBO004
      CALL HBO005 (6)



      CALL GETFILN (11,' ',' ',IERR)
      IF (IERR.NE.0) GOTO 997






      CALL HBO010



    2 CONTINUE
      CALL GVSFMT ('?FMT811')
      CALL GVSCTB (LINE,80)
      READ (11,FMT,END=100,ERR=999) LINE



      IF (LINE(1:1).EQ.'*') THEN
         CALL GVSTT6 (LINE)
         IF (LOGGER) CALL GVSTTU (16,LINE)
         GOTO 2
      END IF
      IF (GVFPOS(LINE,'END').NE.0) GOTO 100
      LINE2=LINE



      CALL GVSFMT ('?FMT823')
      READ (LINE,FMT,ERR=998,END=998) RES1,ATM1,RES2,ATM2
      IF (LOGGER) CALL GVSTTU (16,LINE)
      IAA=WIF058(RES1,0)
      JAA=WIF058(RES2,0)
      IF (IAA.EQ.0.OR.JAA.EQ.0) THEN
         CALL GVSTT6 ('?RESFNS')
         CALL GVSTT6 (LINE)
         GOTO 2
      END IF
      IATLOC=IATINIAA(IAA,ATM1)
      JATLOC=IATINIAA(JAA,ATM2)
      IF (IATLOC.EQ.0.OR.JATLOC.EQ.0) THEN
         CALL GVSTT6 ('?WRNGAT')
         CALL GVSTT6 (LINE)
         GOTO 2
      END IF
      IAT=PNTAAS(IAA)+IATLOC-1
      JAT=PNTAAS(JAA)+JATLOC-1



      D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +         (YCOORD(IAT)-YCOORD(JAT))**2+
     +         (ZCOORD(IAT)-ZCOORD(JAT))**2)
      IF (D12.LT.WIFPAR(481)/100.0) THEN



         CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
         IF (.NOT.ISHBO1.AND.ISHBO2) THEN
            CALL GVSTTB ('?BUGH18')
         END IF



         IF (.NOT.ISHBO1) CALL GVSTT6 ('?NOTHBO')
         IF (ISHBO1) THEN
            IF (IWOSWO.LE.1) THEN
               CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +          ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
            ELSE
               CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +          ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
            END IF
         END IF
      END IF
      GOTO 2



  100 CONTINUE
      CALL GVSCLF (11)



      CALL GVSCTB (LINE,80)
      CALL GVSSTX (LINE,'?HBOEVAFIL')
      CALL SETHIS (LINE)
  900 CONTINUE
      WIFPAR(481)=IWF481
      WIFPAR(484)=IWF484
      WIFPAR(485)=IWF485
      WIFPAR(486)=IWF486
      GOTO 997



  999 CONTINUE
      CALL GVSTT6 ('?ERFINP')
      CALL GVSCLF (11)
      GOTO 900



  998 CONTINUE
      CALL GVSTT6 ('?ERDINP')
      CALL GVSCLF (11)
      GOTO 900



  997 CONTINUE


      RETURN
      END
      SUBROUTINE HBO010



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IAT, OLD1504, OLD1509, JAT, IBND
      LOGICAL       WIFIRW, WIFIR1, WIFIR6, HBO011
      SAVE          OLD1504, OLD1509
      DATA OLD1504  /-1/
      DATA OLD1509  /-1/







      IF (NUMAAF.LT.1) THEN
         CALL GVSTTE ('?SOULOW')
         GOTO 998
      END IF



      IF (OLD1504.EQ.WIFPAR(1504).AND.OLD1509.EQ.WIFPAR(1509)) GOTO 998
      OLD1504=WIFPAR(1504)
      OLD1509=WIFPAR(1509)



      CALL GVSIT0 (DONACC,MAXAT)
      CALL GVSBTF (USABLE,MAXAT)



      IF (NUMAAT.GT.NUMAAF) THEN
         DO 20 IAA=NUMAAF+1,NUMAAT
            IF (WIFIRW(IAA)) THEN
               DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
                  IF (.NOT.PROTON(IAT).AND. WEIGHT(IAT)*100.GT.
     +               WIFPAR(1509).AND.ISATOK(IAT)) THEN
                    USABLE(IAT)=.TRUE.
                    DONACC(IAT)=0
                  ENDIF
   10          CONTINUE
            END IF
   20    CONTINUE
      END IF



      IF (NUMAAT.GT.NUMAAF) THEN
         DO 40 IAA=NUMAAF+1,NUMAAT
            IF (WIFIR6(IAA)) THEN
               DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)
                  IF (.NOT.PROTON(IAT).AND.ISATOK(IAT)) THEN
                     USABLE(IAT)=HBOPOS(RESTYP(IAA),PINIAA(IAT))
                     DONACC(IAT)=HBOPAR(RESTYP(IAA),PINIAA(IAT))
                  END IF
   30          CONTINUE
            END IF
   40    CONTINUE
      END IF



      DO 100 IAA=1,NUMAAF
         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.PROTON(IAT).AND.ISATOK(IAT)) THEN
               USABLE(IAT)=HBOPOS(RESTYP(IAA),PINIAA(IAT))
               DONACC(IAT)=HBOPAR(RESTYP(IAA),PINIAA(IAT))
            END IF
   90    CONTINUE



         IF (WIFIR1(IAA).AND.(RESTYP(IAA).EQ.13.OR.RESTYP(IAA).EQ.21)
     +        .AND.ISATOK(PNTAAS(IAA)).AND.
     +        BOUND_TO(1,PNTAAS(IAA)).LE.0) THEN
            USABLE(PNTAAS(IAA))=.TRUE.
            DONACC(PNTAAS(IAA))=1
         END IF



         IF (HBO011(IAA,PNTAAS(IAA)+2)) THEN
            DONACC(PNTAAS(IAA)+2)=0
            USABLE(PNTAAS(IAA)+2)=.TRUE.
         ELSE IF (HBO011(IAA,PNTAAS(IAA)+5)) THEN
            DONACC(PNTAAS(IAA)+5)=0
            USABLE(PNTAAS(IAA)+5)=.TRUE.
         END IF
  100 CONTINUE



      DO 200 IAA=1,NUMAAT
         DO 190 IAT=PNTAAS(IAA),PNTAAE(IAA)
            DO 185 IBND=1,8
               JAT=BOUND_TO(IBND,IAT)
               IF (JAT.NE.0) THEN
                  IF (.NOT.PROTON(JAT)) THEN
                     IF (SOUADM(10,CHAINN(2,IAA)).NE.2.OR.
     +                   ATIAA(JAT).NE.IAA) THEN
                        IF (ATIAA(JAT).NE.IAA) THEN
                           DONACC(IAT)=0
                           USABLE(IAT)=.FALSE.
                        END IF
                     END IF
                  END IF
               END IF
 185        CONTINUE
 190     CONTINUE
 200  CONTINUE



      CALL HBO010A



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO010A

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IAT, JAT
      LOGICAL       WIFIRW, ISPROTON, FIRST







      IF (NUMAAF.LT.NUMAAT) THEN
         DO 30 IAA=NUMAAF+1,NUMAAT
            IF (WIFIRW(IAA)) GOTO 30
            DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (USABLE(IAT).AND.(.NOT.ISPROTON(IAT)).AND.
     +             (.NOT.ISATOK(IAT))) THEN
                  CALL DIF015 (6,'?M4512',IAT)
                  CALL SHOIAA (IAA)
                  DO 10 JAT=PNTAAS(IAA),PNTAAE(IAA)
                     DONACC(IAT)=0
                     USABLE(IAT)=.FALSE.
 10               CONTINUE
                  GOTO 30
               END IF
 20         CONTINUE
 30      CONTINUE       
      END IF



      DO 45 IAA=1,NUMAAT
         FIRST=.TRUE.
         DO 40 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.ISATOK(IAT).AND.USABLE(IAT)) THEN
               CALL DIF015 (6,'?M4513',IAT)
               USABLE(IAT)=.FALSE.
               DONACC(IAT)=0
               IF (FIRST) THEN
                  FIRST=.FALSE.
                  CALL SHOIAA (IAA)
               END IF
            END IF
 40      CONTINUE
 45   CONTINUE



      IF (WIFPAR(1308).NE.0) CALL GVSTT6 ('?M4514')
      DO 50 IAT=1,NUMATF
         IF (PROTON(IAT)) THEN
            DONACC(IAT)=0
            USABLE(IAT)=.FALSE.
         ELSE
            IF (WIFPAR(1308).NE.0) THEN
               IF (ONESAT(IAT)(1:2).EQ.' O'.OR.ONESAT(IAT)(1:2).EQ.
     +             ' N') THEN
                  CALL GVSFMT ('?FMT1361')
                  WRITE (6,FMT,ERR=999) IAT,ONESA3(ATIAA(IAT)),
     +             NUMNAM(ATIAA(IAT)),ONESAT(IAT),DONACC(IAT),
     +             USABLE(IAT)
               END IF
            END IF
         END IF
 50   CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO010A')



  998 CONTINUE


      RETURN
      END   
      LOGICAL FUNCTION HBO011(IAA,IAT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, IATARR(4), NUM
      LOGICAL       WIFIRN







      HBO011=.FALSE.
      IF (IAT.GT.PNTAAE(IAA)) GOTO 998
      IF (.NOT.ISATOK(IAT)) GOTO 998
      IF (PROTON(IAT)) GOTO 998
      IF (IAT.NE.PNTAAS(IAA)+2.AND.IAT.NE.PNTAAS(IAA)+5) GOTO 998
      IF (.NOT.WIFIRN(IAA)) GOTO 998



      CALL FBONDA (IAT,IATARR,4,NUM)
      HBO011=NUM.EQ.1



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE HBO012 (IAT,XYZH,XYZB,XYZC,FIXED,REALH)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       FIXED, IERR, JAT1, JAT2, IAA, IAT, 
     +              IAATYP, JAT, JATARR(6), NJAT, I, ELMZ,
     +              IATARR(4), NUM1, HATARR(6), NUMH
      REAL          XYZH(3), XYZB(3), VECT(3), TVEC(3), GVFCOS,
     +              RMAT(3,3), GVFDTR, XYZC(3), GVFSIN
      LOGICAL       REALH, WIFIR1, WIFIRA, WIFIRN, CH4EQCH4







      FIXED=0
      REALH=.FALSE.
      IAA=ATIAA(IAT)
      IAATYP=RESTYP(IAA)



      IF (WIFPAR(1308).NE.0) CALL DIF015A (IAT,'?M4515')
      IF (IAATYP.EQ.0) GOTO 998
      IF (.NOT.ISATOK(IAT)) GOTO 998



      IF (WIFIR1(IAA).AND.IAT.EQ.PNTAAS(IAA).AND.WIFIRA(IAA)) THEN



         IF (RESTYP(IAA).EQ.13.OR.RESTYP(IAA).EQ.21) THEN
            FIXED=2
            XYZB(1)=XCOORD(IAT)-XCOORD(IAT+1)
            XYZB(2)=YCOORD(IAT)-YCOORD(IAT+1)
            XYZB(3)=ZCOORD(IAT)-ZCOORD(IAT+1)
            CALL GVSNM3 (XYZB)
            XYZC(1)=XCOORD(IAT)-XCOORD(IAT+6)
            XYZC(2)=YCOORD(IAT)-YCOORD(IAT+6)
            XYZC(3)=ZCOORD(IAT)-ZCOORD(IAT+6)
            CALL GVSNM3 (XYZC)
            CALL GVSCP3 (CV,XYZB,XYZC)
            CALL GVSBV3 (XYZ,XYZB,XYZC)
            CALL GVSSCV (XYZ,GVFCOS(GVFDTR(109.47/2.0)))
            CALL GVSSCV (CV,GVFSIN(GVFDTR(109.47/2.0)))
            CALL GVSBV3 (XYZH,XYZ,CV)
            CALL GVSTV3 (XYZB,XYZ,CV)
            XYZH(1)=XYZH(1)+XCOORD(IAT)
            XYZH(2)=XYZH(2)+YCOORD(IAT)
            XYZH(3)=XYZH(3)+ZCOORD(IAT)
            XYZB(1)=XYZB(1)+XCOORD(IAT)
            XYZB(2)=XYZB(2)+YCOORD(IAT)
            XYZB(3)=XYZB(3)+ZCOORD(IAT)
         ELSE
            FIXED=3
            CV(1)=XCOORD(IAT+1)-XCOORD(IAT)
            CV(2)=YCOORD(IAT+1)-YCOORD(IAT)
            CV(3)=ZCOORD(IAT+1)-ZCOORD(IAT)
            CALL GVSNM3 (CV)
            XYZH(1)=XCOORD(IAT+1)-XCOORD(IAT+2)
            XYZH(2)=YCOORD(IAT+1)-YCOORD(IAT+2)
            XYZH(3)=ZCOORD(IAT+1)-ZCOORD(IAT+2)
            CALL GVSCP3 (XYZ,CV,XYZH)
            CALL GVSMGM (MAT_1,XYZ,GVFDTR(109.47))
            CALL GVSMV3 (XYZH,MAT_1,CV)
            CALL GVSMGM (MAT_1,CV,GVFDTR(120.0))
            CALL GVSMV3 (XYZB,MAT_1,XYZH)
            CALL GVSMV3 (XYZC,MAT_1,XYZB)
            XYZH(1)=XYZH(1)+XCOORD(IAT)
            XYZH(2)=XYZH(2)+YCOORD(IAT)
            XYZH(3)=XYZH(3)+ZCOORD(IAT)
            XYZB(1)=XYZB(1)+XCOORD(IAT)
            XYZB(2)=XYZB(2)+YCOORD(IAT)
            XYZB(3)=XYZB(3)+ZCOORD(IAT)
            XYZC(1)=XYZC(1)+XCOORD(IAT)
            XYZC(2)=XYZC(2)+YCOORD(IAT)
            XYZC(3)=XYZC(3)+ZCOORD(IAT)
         END IF
         GOTO 998
      END IF



      IF (WIFIRN(IAA)) THEN
         IF (IAT.EQ.PNTAAS(IAA)+2.AND.ISATOK(IAT)) THEN
            CALL FBONDA (IAT,IATARR,4,NUM1)
            IF (NUM1.LE.1) GOTO 998
         END IF
         IF (IAT.EQ.PNTAAS(IAA)+5.AND.ISATOK(IAT)) THEN
            CALL FBONDA (IAT,IATARR,4,NUM1)
            IF (NUM1.LE.1) GOTO 998
         END IF
      END IF



      IF (HBOTYP(IAATYP,PINIAA(IAT)).EQ.1.AND.USABLE(IAT)) THEN
         IF (FAMTYP(IAATYP).EQ.1) THEN
            CALL FBONDHOK (PNTAAS(IAA),HATARR,6,NUMH)
            IF (NUMH.GE.1) ISATOK(HATARR(1))=.FALSE.
            CALL NMR110 (IAA,XYZH,IERR)
            IF (IERR.NE.0) THEN
               FIXED=0
               IERR=0
            ELSE
               FIXED=1
            END IF
         ELSE
            CALL GVSTTB ('?BUGH19')
         END IF



      ELSE IF ((HBOTYP(IAATYP,PINIAA(IAT)).EQ.2.OR.
     +    HBOTYP(IAATYP,PINIAA(IAT)).EQ.6).AND.USABLE(IAT)) THEN



         CALL FBONDA (IAT,JATARR,6,NJAT)
         IF (NJAT.NE.2) THEN
            CALL GVSTTE ('?HBOSTR6')
            CALL GVSTTI ('?M1012A',NJAT)
            CALL DIF015 (6,'?M1462',IAT)
            DO 110 FIXED=1,NJAT
               CALL DIF015 (6,'?M1463',JATARR(FIXED))
 110        CONTINUE
            FIXED=0
            GOTO 998
         END IF
         JAT1=JATARR(1)
         JAT2=JATARR(2)
         VECT(1)=2.0*XCOORD(IAT)-XCOORD(JAT1)-XCOORD(JAT2)
         VECT(2)=2.0*YCOORD(IAT)-YCOORD(JAT1)-YCOORD(JAT2)
         VECT(3)=2.0*ZCOORD(IAT)-ZCOORD(JAT1)-ZCOORD(JAT2)
         CALL GVSNM3 (VECT)
         XYZH(1)=XCOORD(IAT)+VECT(1)
         XYZH(2)=YCOORD(IAT)+VECT(2)
         XYZH(3)=ZCOORD(IAT)+VECT(3)
         FIXED=1



      ELSE IF (HBOTYP(IAATYP,PINIAA(IAT)).EQ.3.AND.USABLE(IAT)) THEN



         CALL FBONDA (IAT,JATARR,6,NJAT)
         IF (NJAT.NE.1) THEN
            CALL GVSTTE ('?HBOSTR3')
            CALL GVSTTI ('?M1012A',NJAT)
            CALL DIF015 (6,'?M1462',IAT)
            DO 111 FIXED=1,NJAT
               CALL DIF015 (6,'?M1463',JATARR(FIXED))
  111       CONTINUE
            FIXED=0
            GOTO 998
         END IF
         JAT1=JATARR(1)



         CALL FBONDA (JAT1,JATARR,6,NJAT)
         IF (NJAT.LT.2) THEN
            CALL GVSTTE ('?HBOSTR3')
            CALL GVSTTI ('?M1012A',NJAT)
            CALL DIF015 (6,'?M1462',IAT)
            CALL DIF015 (6,'JAT1=',JAT1)
            DO 112 FIXED=1,NJAT
               CALL DIF015 (6,'?M1463',JATARR(FIXED))
  112       CONTINUE
            FIXED=0
            GOTO 998
         END IF
         JAT2=0
         DO 60 I=1,NJAT
            JAT=JATARR(I)
            IF (JAT.NE.IAT) THEN
               IF (ELMZ(JAT).EQ.7.OR.ELMZ(JAT).EQ.8) JAT2=JAT
            END IF
   60    CONTINUE
         IF (JAT2.EQ.0) THEN
            CALL GVSTTE ('?HBOSTR3')
            CALL GVSTTI ('?M1012A',NJAT)
            CALL DIF015 (6,'?M1462',IAT)
            CALL DIF015 (6,'JAT1=',JAT1)
            DO 113 FIXED=1,NJAT
               CALL DIF015 (6,'?M1463',JATARR(FIXED))
  113       CONTINUE
            FIXED=0
            GOTO 998
         END IF
         VECT(1)=XCOORD(IAT)-XCOORD(JAT2)
         VECT(2)=YCOORD(IAT)-YCOORD(JAT2)
         VECT(3)=ZCOORD(IAT)-ZCOORD(JAT2)
         XYZH(1)=XCOORD(JAT1)-XCOORD(IAT)
         XYZH(2)=YCOORD(JAT1)-YCOORD(IAT)
         XYZH(3)=ZCOORD(JAT1)-ZCOORD(IAT)
         CALL GVSCP3 (TVEC,XYZH,VECT)
         CALL GVSNM3 (XYZH)
         CALL GVSMGM (RMAT,TVEC,GVFDTR(120.0))
         CALL GVSMV3 (XYZB,RMAT,XYZH)
         CALL GVSMV3 (XYZH,RMAT,XYZB)
         XYZH(1)=XYZH(1)+XCOORD(IAT)
         XYZH(2)=XYZH(2)+YCOORD(IAT)
         XYZH(3)=XYZH(3)+ZCOORD(IAT)
         XYZB(1)=XYZB(1)+XCOORD(IAT)
         XYZB(2)=XYZB(2)+YCOORD(IAT)
         XYZB(3)=XYZB(3)+ZCOORD(IAT)
         FIXED=2
      ELSE IF (HBOTYP(IAATYP,PINIAA(IAT)).EQ.7.AND.USABLE(IAT)) THEN



         IF (CH4EQCH4(ONESA3(IAA),' FMT').OR.
     +       CH4EQCH4(ONESA3(IAA),' CBX')) THEN
            FIXED=1
            VECT(1)=XCOORD(PNTAAS(IAA)+1)+XCOORD(PNTAAS(IAA)+2)
            VECT(2)=YCOORD(PNTAAS(IAA)+1)+YCOORD(PNTAAS(IAA)+2)
            VECT(3)=ZCOORD(PNTAAS(IAA)+1)+ZCOORD(PNTAAS(IAA)+2)
            CALL GVSNM3 (VECT)
            XYZH(1)=XCOORD(IAT)+VECT(1)
            XYZH(2)=YCOORD(IAT)+VECT(2)
            XYZH(3)=ZCOORD(IAT)+VECT(3)
            GOTO 998
         END IF



         CALL FBONDA (IAT,JATARR,6,NJAT)
         IF (NJAT.NE.1) THEN
            IF (FAMTYP(RESTYP(ATIAA(IAT))).EQ.1) THEN
               CALL SHOIAA (ATIAA(IAT))
               CALL GVSTT6 ('?HBOSTR7')
               CALL DIF015 (6,'?R00185',IAT)
               CALL GVSTTI ('?R00186',NJAT)
               DO 345 I=1,NJAT
                  CALL DIF015 (6,'?R00187',JATARR(I))
 345           CONTINUE
               CALL GVSTT6 ('?R00188')
            END IF





            FIXED=0
            GOTO 998
         END IF
         JAT1=JATARR(1)
         CALL FBONDA (JAT1,JATARR,6,NJAT)
         IF (NJAT.NE.3.AND.(.NOT.(NJAT.EQ.4.AND.
     +       (MENDLV(JAT1).EQ.' P'.OR.MENDLV(JAT1).EQ.' S')))) THEN
            CALL GVSTT6 ('?HBOSTR7')
            CALL DIF015 (6,'?R00185',IAT)
            CALL DIF015 (6,'?R00187',JAT1)
            CALL GVSTTI ('?R00189',NJAT)
            CALL SHOIAA (ATIAA(JAT1))
            DO 346 I=1,NJAT
               CALL DIF015 (6,'?R00187',JATARR(I))
  346       CONTINUE
            FIXED=0
            CALL GVSKIL
            GOTO 998
         END IF
         JAT2=0



         DO 123 I=1,NJAT
            IF (JATARR(I).NE.IAT.AND.JATARR(I).NE.JAT1) THEN
               IF (ELMZ(JATARR(I)).NE.8) THEN
                  JAT2=JATARR(I)
               END IF
            END IF
 123     CONTINUE



         IF (JAT2.EQ.0) THEN
            DO 124 I=1,NJAT
               IF (JATARR(I).NE.IAT.AND.JATARR(I).NE.JAT1) THEN
                  JAT2=JATARR(I)
               END IF
 124        CONTINUE
         END IF



         IF (JAT2.EQ.0) THEN
            CALL GVSTT6 ('?M3565')
            CALL DIF015 (6,'?M3566',IAT)
            CALL SHOIAA (ATIAA(IAT))
            FIXED=0
         ELSE
            FIXED=1
            VECT(1)=XCOORD(JAT1)-XCOORD(JAT2)
            VECT(2)=YCOORD(JAT1)-YCOORD(JAT2)
            VECT(3)=ZCOORD(JAT1)-ZCOORD(JAT2)
            CALL GVSNM3 (VECT)
            XYZH(1)=XCOORD(IAT)+VECT(1)
            XYZH(2)=YCOORD(IAT)+VECT(2)
            XYZH(3)=ZCOORD(IAT)+VECT(3)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO013 (IAT,XYZC,XYZR,IERR)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, JAT, JAT1, IERR
      REAL          XYZR(3), XYZN(3), XYZC(3), VECT(3), RMAT(3,3),
     +              GVFDTR
      LOGICAL       AREBOUND, WIFIRW







      IERR=0





      IAA=ATIAA(IAT)
      JAT1=0
      DO 10 JAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (JAT.EQ.IAT) GOTO 10
         IF (AREBOUND(IAT,JAT)) THEN
            IF (.NOT.PROTON(JAT)) THEN
               JAT1=JAT
               GOTO 11
            END IF
         END IF
   10 CONTINUE
   11 CONTINUE



      IF (JAT1.EQ.0) THEN
         IERR=1
         IF (WIFIRW(IAA)) THEN
            GOTO 998
         ELSE
            CALL GVSTT6 ('?BUGH13')
            CALL DIF015 (6,'?R00252',IAT)
            CALL SHOIAA (IAA)
            CALL GVSKIL
         END IF
      END IF



      XYZC(1)=XCOORD(IAT)-XCOORD(JAT1)
      XYZC(2)=YCOORD(IAT)-YCOORD(JAT1)
      XYZC(3)=ZCOORD(IAT)-ZCOORD(JAT1)
      CALL GVSNM3 (XYZC)
      CALL GVSCPR (XYZN,XYZC,3)
      CALL GVSNEG (XYZN,3)



      CALL GVSAOR (VECT,XYZC,1.0)
      CALL GVSMGM (RMAT,VECT,GVFDTR(120.0))
      CALL GVSCPR (XYZR,XYZN,3)
      CALL GVSMVV (XYZR,RMAT)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO013A (IATDON,XYZB)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IATDON, IERR
      REAL          XYZB(3), XYZC(3), XYZR(3)







      XYZB(1)=XCOORD(IATDON)+1.0
      XYZB(2)=YCOORD(IATDON)
      XYZB(3)=ZCOORD(IATDON)



      CALL HBO013 (IATDON,XYZC,XYZR,IERR)
      IF (IERR.NE.0) GOTO 998



      XYZB(1)=XYZR(1)+XCOORD(IATDON)
      XYZB(2)=XYZR(2)+YCOORD(IATDON)
      XYZB(3)=XYZR(3)+ZCOORD(IATDON)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE HBO014 (IAT,XYZC,XYZR)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'VECTOR.INC'
      INTEGER       IAT, ISTEP
      REAL          RMAT(3,3), XYZC(3), XYZR(3), GVFLNV, GVFDTR







      IF (ABS(1.0-GVFLNV(XYZR)).GT.0.1) THEN
         CALL GVSTT6 ('?BUGH14')
         GOTO 998
      END IF



      XMOL(1,NUMGRV+1)=XCOORD(IAT)+XYZR(1)
      XMOL(2,NUMGRV+1)=YCOORD(IAT)+XYZR(2)
      XMOL(3,NUMGRV+1)=ZCOORD(IAT)+XYZR(3)



      CALL GVSMGM (RMAT,XYZC,GVFDTR(10.0))



      DO 10 ISTEP=1,36



         CALL GVSMVV (XYZR,RMAT)



         NUMGRV=NUMGRV+1
         YMOL(1,NUMGRV)=XCOORD(IAT)+XYZR(1)
         YMOL(2,NUMGRV)=YCOORD(IAT)+XYZR(2)
         YMOL(3,NUMGRV)=ZCOORD(IAT)+XYZR(3)
         HUEVAL(NUMGRV)=ATCOLR(IAT)+20
         XMOL(1,NUMGRV+1)=XCOORD(IAT)+XYZR(1)
         XMOL(2,NUMGRV+1)=YCOORD(IAT)+XYZR(2)
         XMOL(3,NUMGRV+1)=ZCOORD(IAT)+XYZR(3)
   10 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO015S (IATDON,IATACC,XYZH,ISYM)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SYMINC.INC' 
      INTEGER       IATDON, IATACC, IERR, ISYM, SYMNEG, JSYM
      REAL          XYZH(3), XHALF, YHALF, ZHALF, GVFLNV, TMP(3),
     +              TMPH(3)









      IF (WIFPAR(487).EQ.2.OR.GVFLNV(XYZH).LT.0.001) THEN
         CALL DRW_DASH_L_SYM (IATDON,IATACC,15,ISYM)
         IF (ISYM.GT.1) THEN
            CALL DRW_DASH_L_SYM (IATACC,IATDON,15,SYMNEG(ISYM))
         END IF
         GOTO 998
      END IF
      TMP(1)=XCOORD(IATACC)
      TMP(2)=YCOORD(IATACC)
      TMP(3)=ZCOORD(IATACC)
      IF (ISYM.NE.1) CALL GVSMPV (TMP, SYMMAT(1,1,ISYM), 
     + SYMVEC(1,ISYM))



      WIFPAR(937)=2
      CALL GRTLIN (XCOORD(IATDON),YCOORD(IATDON),ZCOORD(IATDON),
     + XYZH(1),XYZH(2),XYZH(3),ATCOLR(IATDON)+10,IERR)
      IF (IERR.NE.0) GOTO 998



      XHALF=(XYZH(1)+TMP(1))/2.0
      YHALF=(XYZH(2)+TMP(2))/2.0
      ZHALF=(XYZH(3)+TMP(3))/2.0



      WIFPAR(937)=3
      CALL GRTDSH (XHALF,YHALF,ZHALF,XYZH(1),XYZH(2),XYZH(3),
     + ATCOLR(IATDON)+10,9,IERR)



      WIFPAR(937)=3
      CALL GRTDSH (XHALF,YHALF,ZHALF,TMP(1),TMP(2),TMP(3),
     + ATCOLR(IATACC)+10,9,IERR)



      IF (ISYM.GT.1) THEN
         TMP(1)=XCOORD(IATDON)
         TMP(2)=YCOORD(IATDON)
         TMP(3)=ZCOORD(IATDON)
         JSYM=SYMNEG(ISYM)
         CALL GVSMPV (TMP, SYMMAT(1,1,JSYM), SYMVEC(1,JSYM))
         TMPH(1)=XYZH(1)
         TMPH(2)=XYZH(2)
         TMPH(3)=XYZH(3)
         CALL GVSMPV (TMPH, SYMMAT(1,1,JSYM), SYMVEC(1,JSYM))



         WIFPAR(937)=2
         CALL GRTLIN (TMP(1),TMP(2),TMP(3),TMPH(1),TMPH(2),TMPH(3),
     +    ATCOLR(IATDON)+10,IERR)
         IF (IERR.NE.0) GOTO 998



         XHALF=(TMPH(1)+XCOORD(IATACC))/2.0
         YHALF=(TMPH(2)+YCOORD(IATACC))/2.0
         ZHALF=(TMPH(3)+ZCOORD(IATACC))/2.0



         WIFPAR(937)=3
         CALL GRTDSH (XHALF,YHALF,ZHALF,TMPH(1),TMPH(2),TMPH(3),
     +    ATCOLR(IATDON)+10,9,IERR)



         WIFPAR(937)=3
         CALL GRTDSH (XHALF,YHALF,ZHALF,XCOORD(IATACC),
     +    YCOORD(IATACC),ZCOORD(IATACC),ATCOLR(IATACC)+10,9,IERR)
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO016 (XYZH,IATACC,ANGL)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       JAT1, JAT, IAA, IATACC, JAT2
      REAL          XYZH(3), VECT1(3), VECT2(3), ANGL, GVFANG, GVFRTD
      LOGICAL       WIFITW, AREBOUND







      IF (WIFITW(IATACC)) GOTO 998
      IAA=ATIAA(IATACC)



      JAT1=0
      DO 10 JAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (JAT.EQ.IATACC) GOTO 10
         IF (AREBOUND(IATACC,JAT)) THEN
            JAT1=JAT
            GOTO 11
         END IF
   10 CONTINUE
   11 CONTINUE



      JAT2=0
      DO 20 JAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (JAT.EQ.IATACC) GOTO 20
         IF (JAT.EQ.JAT1) GOTO 20
         IF (AREBOUND(IATACC,JAT)) THEN
            JAT2=JAT
            GOTO 21
         END IF
   20 CONTINUE
   21 CONTINUE
      IF (JAT1.EQ.0) THEN
         CALL GVSTT6 ('?BUGH16')
         CALL GVSTTI2 ('IAA,IAT=',IAA,IATACC)
      ELSE
         VECT1(1)=XYZH(1)-XCOORD(IATACC)
         VECT1(2)=XYZH(2)-YCOORD(IATACC)
         VECT1(3)=XYZH(3)-ZCOORD(IATACC)
         IF (JAT2.EQ.0) THEN
            VECT2(1)=XCOORD(IATACC)-XCOORD(JAT1)
            VECT2(2)=YCOORD(IATACC)-YCOORD(JAT1)
            VECT2(3)=ZCOORD(IATACC)-ZCOORD(JAT1)
            ANGL=GVFRTD(GVFANG(VECT1,VECT2))
         ELSE
            VECT2(1)=2.0*XCOORD(IATACC)-XCOORD(JAT1)-XCOORD(JAT2)
            VECT2(2)=2.0*YCOORD(IATACC)-YCOORD(JAT1)-YCOORD(JAT2)
            VECT2(3)=2.0*ZCOORD(IATACC)-ZCOORD(JAT1)-ZCOORD(JAT2)
            ANGL=GVFRTD(GVFANG(VECT1,VECT2))
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO017




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      LOGICAL       ISHBO1, ISHBO2
      INTEGER       IAA, IAT, JAA, JAT, IWOSWO, IDOUBL, IERR, ICNT
      REAL          XYZ1(3), XYZ2(3), D12, DIST1, DIST2, ANGLH1,  
     +              ANGLH2, ANGLA1, ANGLA2







      IF (NUMAAF.LT.2) THEN
         CALL GVSTT6 ('?SOULOW')
         GOTO 998
      END IF



      CALL GRTVIN
      CALL HBO004



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



      CALL GVSNL6 (1)
      CALL GVSTT6 ('?A=AHBO')
      CALL GVSNL6 (1)



      CALL HBO010



      ICNT=0
      DO 100 IAA=1,NUMAAT
         IF (.NOT.WRK1TF(IAA)) GOTO 100
         JAA=IAA



         DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)-1
            IF (.NOT.USABLE(IAT)) GOTO 80
            DO 70 JAT=IAT+1,PNTAAE(IAA)
               IF (.NOT.USABLE(JAT)) GOTO 70
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70



               D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                  (YCOORD(IAT)-YCOORD(JAT))**2+
     +                  (ZCOORD(IAT)-ZCOORD(JAT))**2)
               IF (D12.LT.WIFPAR(481)/100.0) THEN



                  CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +             DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +             XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
                  IF (ISHBO1.OR.ISHBO2) ICNT=ICNT+1



                  IF (IWOSWO.LE.1) THEN



                     CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)



                  ELSE
                     CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                  END IF
               END IF
   70       CONTINUE
   80    CONTINUE
  100 CONTINUE



      IF (ICNT.LE.0) THEN
         CALL GVSTT6 ('?M0775')
      ELSE
         CALL GRAMOL (' ')
         CALL GRTVIN
      END IF



      CALL GVSNL6 (2)
      CALL GVSTT6 ('?A+1HBO')
      CALL GVSNL6 (1)
      CALL HBO010



      ICNT=0
      DO 200 IAA=1,NUMAAF
         IF (.NOT.WRK1TF(IAA)) GOTO 200
         DO 190 JAA=MAX(IAA-1,1),MIN(IAA+1,NUMAAF)



            IF (IAA.EQ.JAA) GOTO 190
            IF (WRK1TF(JAA).AND.JAA.LT.IAA) GOTO 190



            DO 180 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.USABLE(IAT)) GOTO 180
               DO 170 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  IF (.NOT.USABLE(JAT)) GOTO 170
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 170



                  D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                     (YCOORD(IAT)-YCOORD(JAT))**2+
     +                     (ZCOORD(IAT)-ZCOORD(JAT))**2)
                  IF (D12.LT.WIFPAR(481)/100.0) THEN



                     CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
                     IF (ISHBO1.OR.ISHBO2) ICNT=ICNT+1



                     IF (IWOSWO.LE.1) THEN



                        CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                   ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)



                     ELSE
                        CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                   ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                     END IF
                  END IF
  170          CONTINUE
  180       CONTINUE
  190    CONTINUE
  200 CONTINUE



      IF (ICNT.LE.0) THEN
         CALL GVSTT6 ('?M0775')
      ELSE
         CALL GRAMOL (' ')
      END IF



      CALL SETHIS ('?HBOIRN')



  998 CONTINUE

   
      RETURN
      END
      SUBROUTINE HBO018 (IATDON,IATACC,XYZH)























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IATDON, IATACC, ITODO
      REAL          XYZH(3), DISA, DISB, WIFDST







      IF (WIFPAR(84).EQ.1) THEN





         DISA=99.99
         ITODO=1
         IF(IATDON-2.GT.0)THEN
            IF (PROTON(IATDON-2)) THEN
               DISA=WIFDST(IATDON,IATDON-2)



               IF (DISA .LT. 1.5) THEN



                  ITODO=2
                  XYZH(1)=XCOORD(IATDON-2)
                  XYZH(2)=YCOORD(IATDON-2)
                  XYZH(3)=ZCOORD(IATDON-2)
               ENDIF
            ENDIF
         ENDIF



         DISB=99.99
         IF (IATDON-1.GT.0) THEN
            IF (PROTON(IATDON-1)) THEN
               DISB=WIFDST(IATDON,IATDON-1)

               IF (DISB .LT. 1.5) THEN


                  IF (ITODO .EQ. 2) THEN


                     IF (DISA .LT. DISB) GOTO 998
                     XYZH(1)=XCOORD(IATDON-1)
                     XYZH(2)=YCOORD(IATDON-1)
                     XYZH(3)=ZCOORD(IATDON-1)
                     GOTO 998
                  ENDIF

                  ITODO=2
                  XYZH(1)=XCOORD(IATDON-1)
                  XYZH(2)=YCOORD(IATDON-1)
                  XYZH(3)=ZCOORD(IATDON-1)
               ENDIF
            ENDIF
         ENDIF

         IF (IATDON+1.LE.NUMATF) THEN
            IF (PROTON(IATDON+1)) THEN
               DISA=WIFDST(IATDON,IATDON+1)
               IF (DISA .LT. 1.5) THEN
                  IF(ITODO.EQ.2) THEN
                    IF ( DISB.LT.DISA) GOTO 998
                    XYZH(1)=XCOORD(IATDON+1)
                    XYZH(2)=YCOORD(IATDON+1)
                    XYZH(3)=ZCOORD(IATDON+1)
                    GOTO 998
                 ENDIF
                 ITODO=2
                 XYZH(1)=XCOORD(IATDON+1)
                 XYZH(2)=YCOORD(IATDON+1)
                 XYZH(3)=ZCOORD(IATDON+1)
              ENDIF
           ENDIF
        ENDIF
        IF (IATDON+2.LE.NUMATF) THEN
           IF (PROTON(IATDON+2)) THEN
              DISB=WIFDST(IATDON,IATDON+2)
              IF (DISB .LT. 1.5) THEN
                 IF (ITODO .EQ.2) THEN
                    IF(DISA.LT.DISB) GOTO 998
                    XYZH(1)=XCOORD(IATDON+2)
                    XYZH(2)=YCOORD(IATDON+2)
                    XYZH(3)=ZCOORD(IATDON+2)
                    GOTO 998
                 ENDIF
                 XYZH(1)=XCOORD(IATDON+2)
                 XYZH(2)=YCOORD(IATDON+2)
                 XYZH(3)=ZCOORD(IATDON+2)
                 GOTO 998
              ENDIF
           ENDIF
         ENDIF
      ENDIF





      XYZH(1)=XCOORD(IATACC)-XCOORD(IATDON)
      XYZH(2)=YCOORD(IATACC)-YCOORD(IATDON)
      XYZH(3)=ZCOORD(IATACC)-ZCOORD(IATDON)
      CALL GVSNM3 (XYZH)
      XYZH(1)=XYZH(1)+XCOORD(IATDON)
      XYZH(2)=XYZH(2)+YCOORD(IATDON)
      XYZH(3)=XYZH(3)+ZCOORD(IATDON)



  998 CONTINUE


      RETURN
      END
      LOGICAL FUNCTION HBO023 (DDONAC,DHYDAC,ANGLH,ANGLA)























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      REAL          DDONAC, DHYDAC, ANGLH, ANGLA







      HBO023=.TRUE.



      IF (DDONAC.GT.WIFPAR(481)/100.0) HBO023=.FALSE.
      IF (DHYDAC.GT.WIFPAR(484)/100.0) HBO023=.FALSE.
      IF (ANGLH.GT.WIFPAR(485)) HBO023=.FALSE.
      IF (ANGLA.GT.WIFPAR(486)) HBO023=.FALSE.





      RETURN
      END
      SUBROUTINE HBO024


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IAA, IAT, JAA, JAT, IWOSWO, IDOUBL, IERR
      LOGICAL       ISHBO1, ISHBO2, ISWAT, ISWAT1, ISWAT2, WIFIRW
      REAL          XYZ1(3), XYZ2(3), D12, DIST1, DIST2, DMIN,
     +              ANGLH1, ANGLH2, ANGLA1, ANGLA2
      CHARACTER*28  DIF000







      CALL GRTVIN



      IF (USE300) THEN
         CALL GVSTT6 ('?PIC-AT')
         CALL GRTKOF
         CALL GRA008 (IAA,IAT)
         CALL GRTKON
      ELSE
         CALL WIFGAT ('?ASKAAT',IAA,IAT,IERR)
         IF (IERR.NE.0.OR.IAA.EQ.0) GOTO 998
      END IF
      CALL DIF015 (6,'?M1464',IAT)
      IF (IAA.EQ.0) GOTO 998



      CALL WIFWTF ('?RANGEC',IERR)
      IF (IERR.NE.0) GOTO 998



      CALL HBO010



      IF (.NOT.USABLE(IAT)) THEN
         CALL GVSTT6 ('?HBOANH')
         GOTO 998
      END IF



      CALL GVSNL6 (1)
      ISWAT1=WIFIRW(IAA)
      DO 90 JAA=1,NUMAAT
         IF (.NOT.WRK1TF(JAA)) GOTO 90
         ISWAT2=WIFIRW(JAA)
         ISWAT=ISWAT1.OR.ISWAT2



         DMIN=SQRT((SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +             (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +             (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2)-
     +              SPHRAD(4,IAA)-SPHRAD(4,JAA)

         IF (DMIN.GT.WIFPAR(481)/100.0) THEN
            IF (.NOT.ISWAT) GOTO 90
         END IF



         DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
            IF (.NOT.USABLE(JAT)) GOTO 70
            IF (IAT.EQ.JAT) GOTO 70
            IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
            IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



            D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +               (YCOORD(IAT)-YCOORD(JAT))**2+
     +               (ZCOORD(IAT)-ZCOORD(JAT))**2)
            IF (D12.LT.WIFPAR(481)/100.0) THEN



               CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +          DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +          XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
               IF (IERR.EQ.0.AND.ISHBO1) THEN



                  IF (IWOSWO.LE.1) THEN



                     CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)



                  ELSE
                     CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                  END IF
               END IF
            END IF
   70    CONTINUE
   90 CONTINUE



      CALL GRAMOL (' ')



      CALL GVSSTX (LINE,'?HBOEVA')
      LINE(30:80)=DIF000(IAT)
      CALL SETHIS (LINE)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO025 (IAAIN,SPHIN)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IAAIN, IAA, IAT, JAA, JAT, IWOSWO, IDOUBL, KAA,
     +              IERR, ISPHERE
      LOGICAL       WIFIRW, ISHBO1, ISWAT, ISWAT1, ISWAT2,
     +              GRAPON, ISHBO2
      REAL          XYZ1(3), XYZ2(3), SPHIN, D12, DIST1,
     +              DIST2, ANGLH1, ANGLH2, ANGLA1, ANGLA2, SPHERE,
     +              WIFDST, DMIN


      RETURN
      END
      SUBROUTINE HBO026



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'HSTINC.INC'
      INTEGER       IFT1, IFT2, JFT1, JFT2, IAA, JAA, IAT, JAT,
     +              IWOSWO, IDOUBL, IERR, GVFPOS
      CHARACTER*1   CHAR1,CHAR2
      CHARACTER*5   INDSSP
      LOGICAL       WIFIRW, ISWAT, ISWAT1, ISWAT2, SAME12,
     +              ISHBO1, ISHBO2
      REAL          XYZ1(3), XYZ2(3), DIST1, DIST2, ANGLH1, ANGLH2,
     +              ANGLA1, ANGLA2, DMIN, D12







      IF (NUMAAF.LT.2) THEN
         CALL GVSTTE ('?SOULOW')
         GOTO 998
      END IF



      CALL GRTVIN
      CALL DSP001 (.FALSE.)
      CALL HBO004



      CALL GVSCTB (INDSSP,5)
      CALL WIFSDS (INDSSP,IERR)
      IF (IERR.NE.0) GOTO 998



      CALL WIFGRN (IFT1,IFT2,'?RANGE1')
      IF (IFT1.EQ.0) GOTO 998
      CALL WIFGRN (JFT1,JFT2,'?RANGE2')
      IF (JFT1.EQ.0) GOTO 998
      SAME12=IFT1.EQ.JFT1.AND.IFT2.EQ.JFT2



      CALL HBO010



      CALL GVSNL6 (1)
      DO 100 IAA=IFT1,IFT2
         IF (INDSSP(1:1).NE.'*') THEN
            CHAR1=LOCHST(IAA)
            IF (LOCHST(IAA).EQ.' ') CHAR1='C'
            IF (GVFPOS(INDSSP,CHAR1).EQ.0) GOTO 100
         END IF
         ISWAT1=WIFIRW(IAA)
         DO 90 JAA=JFT1,JFT2
            IF (INDSSP(1:1).NE.'*') THEN
               CHAR2=LOCHST(JAA)
               IF (LOCHST(JAA).EQ.' ') CHAR2='C'
               IF (GVFPOS(INDSSP,CHAR2).EQ.0) GOTO 90
            END IF
            ISWAT2=WIFIRW(JAA)
            ISWAT=ISWAT1.OR.ISWAT2



            IF (SAME12.AND.JAA.LT.IAA) GOTO 90



            DMIN=SQRT((SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +                (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +                (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2)-
     +                 SPHRAD(4,IAA)-SPHRAD(4,JAA)
            IF (DMIN.GT.WIFPAR(481)/100.0-2.8) THEN
               IF (.NOT.ISWAT) GOTO 90
            END IF



            DO 80 IAT=PNTAAS(IAA),PNTAAS(IAA)+3
               IF (.NOT.USABLE(IAT)) GOTO 80
               DO 70 JAT=PNTAAS(JAA),PNTAAS(JAA)+3
                  IF (.NOT.USABLE(JAT)) GOTO 70
                  IF (IAT.EQ.JAT) GOTO 70
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                  IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                  D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                     (YCOORD(IAT)-YCOORD(JAT))**2+
     +                     (ZCOORD(IAT)-ZCOORD(JAT))**2)
                  IF (D12.LT.WIFPAR(481)/100.0) THEN



                     CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)



                     IF (IERR.EQ.0.AND.ISHBO1) THEN
                        IF (IWOSWO.LE.1) THEN
                           CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        ELSE
                           CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        END IF
                     END IF
                  END IF
   70          CONTINUE
   80       CONTINUE
   90    CONTINUE
  100 CONTINUE



      CALL GVST6C ('?M0053',INDSSP,.TRUE.)



      CALL GRAMOL (' ')



      CALL GVSSTX (LINE,'?HBOHST')
      CALL GVSCPC (LINE,INDSSP)
      CALL SETHIS (LINE)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,DIST1,DIST2,
     + ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IWOSWO, IDOUBL, IAA, IAT, JAA, JAT, IERR
      REAL          XYZ1(3), XYZ2(3), XYZNIL(3),
     +              XYZ3(3), XYZ4(3), DIST1, DIST2, ANGLH1, ANGLH2,
     +              ANGLA1, ANGLA2, DIST3, DIST4, ANGLH3, ANGLH4,
     +              ANGLA3, ANGLA4
      LOGICAL       ISHBO1, ISHBO2, ISHBO3, ISHBO4
      CHARACTER*4   T4, CHAR4I, CHAR4J
      SAVE          XYZNIL
      DATA XYZNIL   /0.0,0.0,0.0/







      IWOSWO=0
      IDOUBL=0
      IF (WIFPAR(488).EQ.1) THEN
         CHAR4I=T4(ONESAT(IAT))
         CHAR4J=T4(ONESAT(JAT))
         CALL GVSFMT ('?FMT821')
         WRITE (6,FMT,ERR=100) IAA,ONESA3(IAA),CHAR4I,DONACC(IAT),
     +    JAA,ONESA3(JAA),CHAR4J,DONACC(JAT)
      END IF



      IF (DONACC(IAT).EQ.1.AND.DONACC(JAT).LE.0)THEN
         CALL HBO031 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IERR)
         IWOSWO=1
         IF (ISHBO1) CALL HBO015S (IAT,JAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (IAT,JAT,XYZ2,1)
         GOTO 100



      ELSE IF (DONACC(IAT).EQ.0.AND.DONACC(JAT).LT.0)THEN
         CALL HBO031 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IERR)
         IWOSWO=1
         IF (ISHBO1) CALL HBO015S (IAT,JAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (IAT,JAT,XYZ2,1)
         GOTO 100



      ELSE IF (DONACC(JAT).EQ.1.AND.DONACC(IAT).LE.0)THEN
         CALL HBO031 (JAA,JAT,IAA,IAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IERR)
         IWOSWO=2
         IF (ISHBO1) CALL HBO015S (JAT,IAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (JAT,IAT,XYZ2,1)
         GOTO 100



      ELSE IF (DONACC(JAT).EQ.0.AND.DONACC(IAT).LT.0)THEN
         CALL HBO031 (JAA,JAT,IAA,IAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IERR)
         IWOSWO=2
         IF (ISHBO1) CALL HBO015S (JAT,IAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (JAT,IAT,XYZ2,1)
         GOTO 100





      ELSE IF (DONACC(IAT).EQ.0.AND.DONACC(JAT).EQ.0) THEN
         CALL HBO031 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,DIST1,DIST2,
     +    ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IERR)
         CALL HBO031 (JAA,JAT,IAA,IAT,ISHBO3,ISHBO4,DIST3,DIST4,
     +    ANGLH3,ANGLH4,ANGLA3,ANGLA4,XYZ3,XYZ4,IERR)
         IF (ISHBO1.AND.ISHBO2) CALL GVSTTB ('?HBOEXC1')
         IF (ISHBO3.AND.ISHBO4) CALL GVSTTB ('?HBOEXC2')




         IF ((.NOT.ISHBO1).AND.(.NOT.ISHBO3)) THEN
            IWOSWO=0
            ISHBO1=.FALSE.
            ISHBO2=.FALSE.
            XYZ1(1)=0.0
            XYZ1(2)=0.0
            XYZ1(3)=0.0
            ANGLA1=999.9
            ANGLH1=999.9
            DIST1=999.9
            XYZ2(1)=0.0
            XYZ2(2)=0.0
            XYZ2(3)=0.0
            ANGLA2=999.9
            ANGLH2=999.9
            DIST2=999.9
         ELSE IF (ISHBO1.AND.(.NOT.ISHBO3)) THEN
            IDOUBL=1
            IWOSWO=1
            ISHBO2=.FALSE.
            XYZ2(1)=0.0
            XYZ2(2)=0.0
            XYZ2(3)=0.0
            ANGLA2=999.9
            ANGLH2=999.9
            DIST2=999.9
            CALL HBO015S (IAT,JAT,XYZ1,1)
         ELSE IF (.NOT.ISHBO1.AND.ISHBO3) THEN
            IDOUBL=1
            IWOSWO=2
            ISHBO1=.TRUE.
            ISHBO2=.FALSE.
            CALL GVSCPR (XYZ1,XYZ3,3)
            XYZ2(1)=0.0
            XYZ2(2)=0.0
            XYZ2(3)=0.0
            ANGLA1=ANGLA3
            ANGLA2=999.9
            DIST1=DIST3
            DIST2=999.9
            ANGLH1=ANGLH3
            ANGLH2=999.9
            CALL HBO015S (JAT,IAT,XYZ1,1)
         ELSE IF (ISHBO1.AND.ISHBO3) THEN
            IDOUBL=2
            IWOSWO=0
            ISHBO1=.TRUE.
            ISHBO2=.TRUE.
            CALL GVSCPR (XYZ2,XYZ3,3)
            ANGLA2=ANGLA3
            DIST2=DIST3
            ANGLH2=ANGLH3
            CALL HBO015S (IAT,JAT,XYZNIL,1)
         END IF
      END IF
  100 CONTINUE





      RETURN
      END
      SUBROUTINE HBO030A (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,DIST1,DIST2,
     + ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IWOSWO, IDOUBL, IAA, IAT, JAA, JAT, IERR
      LOGICAL       ISHBO1, ISHBO2, ISHBO3, ISHBO4
      REAL          XYZ1(3), XYZ2(3), XYZNIL(3),
     +              XYZ3(3), XYZ4(3), DIST1, DIST2, ANGLH1, ANGLH2,
     +              ANGLA1, ANGLA2, DIST3, DIST4, ANGLH3, ANGLH4,
     +              ANGLA3, ANGLA4
      SAVE          XYZNIL
      DATA XYZNIL   /0.0,0.0,0.0/







      IWOSWO=0
      IDOUBL=0



      IF (DONACC(IAT).EQ.1.AND.DONACC(JAT).LE.0)THEN
         CALL HBO031 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IERR)
         IWOSWO=1
         IF (ISHBO1) CALL HBO015S (IAT,JAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (IAT,JAT,XYZ2,1)
         GOTO 100



      ELSE IF (DONACC(IAT).EQ.0.AND.DONACC(JAT).LT.0)THEN
         CALL HBO031 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IERR)
         IWOSWO=1
         IF (ISHBO1) CALL HBO015S (IAT,JAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (IAT,JAT,XYZ2,1)
         GOTO 100



      ELSE IF (DONACC(JAT).EQ.1.AND.DONACC(IAT).LE.0)THEN
         CALL HBO031 (JAA,JAT,IAA,IAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IERR)
         IWOSWO=2
         IF (ISHBO1) CALL HBO015S (JAT,IAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (JAT,IAT,XYZ2,1)
         GOTO 100



      ELSE IF (DONACC(JAT).EQ.0.AND.DONACC(IAT).LT.0)THEN
         CALL HBO031 (JAA,JAT,IAA,IAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IERR)
         IWOSWO=2
         IF (ISHBO1) CALL HBO015S (JAT,IAT,XYZ1,1)
         IF (ISHBO2) CALL HBO015S (JAT,IAT,XYZ2,1)
         GOTO 100





      ELSE IF (DONACC(IAT).EQ.0.AND.DONACC(JAT).EQ.0) THEN
         CALL HBO031 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,DIST1,DIST2,
     +    ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IERR)
         CALL HBO031 (JAA,JAT,IAA,IAT,ISHBO3,ISHBO4,DIST3,DIST4,
     +    ANGLH3,ANGLH4,ANGLA3,ANGLA4,XYZ3,XYZ4,IERR)




         IF ((.NOT.ISHBO1).AND.(.NOT.ISHBO3)) THEN
            IWOSWO=0
            ISHBO1=.FALSE.
            ISHBO2=.FALSE.
            XYZ1(1)=0.0
            XYZ1(2)=0.0
            XYZ1(3)=0.0
            ANGLA1=999.9
            ANGLH1=999.9
            DIST1=999.9
            XYZ2(1)=0.0
            XYZ2(2)=0.0
            XYZ2(3)=0.0
            ANGLA2=999.9
            ANGLH2=999.9
            DIST2=999.9
         ELSE IF (ISHBO1.AND.(.NOT.ISHBO3)) THEN
            IDOUBL=1
            IWOSWO=1
            ISHBO2=.FALSE.
            XYZ2(1)=0.0
            XYZ2(2)=0.0
            XYZ2(3)=0.0
            ANGLA2=999.9
            ANGLH2=999.9
            DIST2=999.9
            CALL HBO015S (IAT,JAT,XYZ1,1)
         ELSE IF (.NOT.ISHBO1.AND.ISHBO3) THEN
            IDOUBL=1
            IWOSWO=2
            ISHBO1=.TRUE.
            ISHBO2=.FALSE.
            CALL GVSCPR (XYZ1,XYZ3,3)
            XYZ2(1)=0.0
            XYZ2(2)=0.0
            XYZ2(3)=0.0
            ANGLA1=ANGLA3
            ANGLA2=999.9
            DIST1=DIST3
            DIST2=999.9
            ANGLH1=ANGLH3
            ANGLH2=999.9
            CALL HBO015S (JAT,IAT,XYZ1,1)
         ELSE IF (ISHBO1.AND.ISHBO3) THEN
            IDOUBL=2
            IWOSWO=0
            ISHBO1=.TRUE.
            ISHBO2=.TRUE.
            CALL GVSCPR (XYZ2,XYZ3,3)
            ANGLA2=ANGLA3
            DIST2=DIST3
            ANGLH2=ANGLH3
            CALL HBO015S (IAT,JAT,XYZNIL,1)
         END IF
      END IF
  100 CONTINUE





      RETURN
      END
      SUBROUTINE HBO031 (IAADON,IATDON,IAAACC,IATACC,ISHBO1,ISHBO2,
     + DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2,IERR)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAADON, IATDON, IAAACC, IATACC, IVL, IERR, FIXED
      REAL          XYZ1(3), XYZ2(3), VECT(3), TVEC(3), XYZC(3),
     +              XYZR(3), RMAT(3,3), VL1, VL2, DIST1, DIST2,
     +              ANGLH1, ANGLH2, ANGLA1, ANGLA2, D12, WIFDST,
     +              XYZ3(3), GVFANG, GVFLNV, GVFRTD, GVFDTR
      LOGICAL       ISHBO1, ISHBO2, WIFITW, HBO023, REALH







      XYZ1(1)=0.0
      XYZ1(2)=0.0
      XYZ1(3)=0.0
      XYZ2(1)=0.0
      XYZ2(2)=0.0
      XYZ2(3)=0.0
      XYZ3(1)=0.0
      XYZ3(2)=0.0
      XYZ3(3)=0.0
      IERR=0
      ISHBO1=.FALSE.
      ISHBO2=.FALSE.
      DIST1=999.9
      ANGLH1=999.9
      ANGLA1=999.9
      DIST2=999.9
      ANGLH2=999.9
      ANGLA2=999.9
      IF (WIFITW(IATACC)) THEN
         ANGLA1=0.0
         ANGLA2=0.0
      END IF
      D12=WIFDST(IATDON,IATACC)



      IF (DONACC(IATDON).EQ.-1) THEN
         CALL GVSTTB ('?BUGH23')
         GOTO 998
      END IF
      IF (DONACC(IATACC).EQ.1) THEN
         CALL GVSTTB ('?BUGH24')
         GOTO 998
      END IF






      IF (WIFITW(IATDON)) THEN
         CALL HBO018 (IATDON,IATACC,XYZ1)
         FIXED=1
         IF (WIFPAR(488).NE.0) CALL GVSTT6 ('?NEWT204')
      ELSE
         CALL HBO012 (IATDON,XYZ1,XYZ2,XYZ3,FIXED,REALH)
         IF (WIFPAR(488).NE.0) THEN
            VL1=GVFLNV(XYZ1)
            VL2=GVFLNV(XYZ2)
            IVL=0
            IF (ABS(VL1).GT.0.001) IVL=IVL+1
            IF (ABS(VL2).GT.0.001) IVL=IVL+1
            IF (IVL.NE.FIXED) THEN
               CALL GVSTTB ('?BUGH25')
               CALL SHOIAA (IAADON)
            END IF
         END IF
      END IF



      IF (FIXED.GT.0) THEN



         DIST1=SQRT((XYZ1(1)-XCOORD(IATACC))**2+
     +             (XYZ1(2)-YCOORD(IATACC))**2+
     +             (XYZ1(3)-ZCOORD(IATACC))**2)



         VECT(1)=XCOORD(IATDON)-XYZ1(1)
         VECT(2)=YCOORD(IATDON)-XYZ1(2)
         VECT(3)=ZCOORD(IATDON)-XYZ1(3)
         TVEC(1)=XCOORD(IATACC)-XYZ1(1)
         TVEC(2)=YCOORD(IATACC)-XYZ1(2)
         TVEC(3)=ZCOORD(IATACC)-XYZ1(3)
         ANGLH1=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))



         CALL HBO016 (XYZ1,IATACC,ANGLA1)



         ISHBO1=HBO023(D12,DIST1,ANGLH1,ANGLA1)
         IF (ISHBO1.AND.WIFPAR(488).GT.0) CALL GVSTT6 ('ISHBO1=.TRUE.')



         IF (FIXED.GT.1) THEN



            DIST2=SQRT((XYZ2(1)-XCOORD(IATACC))**2+
     +                 (XYZ2(2)-YCOORD(IATACC))**2+
     +                 (XYZ2(3)-ZCOORD(IATACC))**2)



            VECT(1)=XCOORD(IATDON)-XYZ2(1)
            VECT(2)=YCOORD(IATDON)-XYZ2(2)
            VECT(3)=ZCOORD(IATDON)-XYZ2(3)
            TVEC(1)=XCOORD(IATACC)-XYZ2(1)
            TVEC(2)=YCOORD(IATACC)-XYZ2(2)
            TVEC(3)=ZCOORD(IATACC)-XYZ2(3)
            ANGLH2=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))
            CALL HBO016 (XYZ2,IATACC,ANGLA2)



            ISHBO2=HBO023(D12,DIST2,ANGLH2,ANGLA2)
            IF (ISHBO2.AND.WIFPAR(488).GT.0) CALL GVSTT6 ('?M2608')



            IF ((.NOT.ISHBO1).AND.ISHBO2) THEN
               ISHBO1=.TRUE.
               ISHBO2=.FALSE.
               CALL GVSWAP (DIST1,DIST2)
               CALL GVSWAP (ANGLH1,ANGLH2)
               CALL GVSWAP (ANGLA1,ANGLA2)
               CALL GVSWAP (XYZ1(1),XYZ2(1))
               CALL GVSWAP (XYZ1(2),XYZ2(2))
               CALL GVSWAP (XYZ1(3),XYZ2(3))
            ELSE IF (ISHBO1.AND.ISHBO2) THEN
               IF (DIST2.LT.DIST1) THEN
                  CALL GVSWAP (DIST1,DIST2)
                  CALL GVSWAP (ANGLH1,ANGLH2)
                  CALL GVSWAP (ANGLA1,ANGLA2)
                  CALL GVSWAP (XYZ1(1),XYZ2(1))
                  CALL GVSWAP (XYZ1(2),XYZ2(2))
                  CALL GVSWAP (XYZ1(3),XYZ2(3))
               END IF
            END IF
            GOTO 998
         END IF
      ELSE









         IF (WIFPAR(488).GT.0) CALL GVSTTI2 ('FIXED=0',IAADON,IAAACC)
         CALL HBO013 (IATDON,XYZC,XYZR,IERR)
         IF (IERR.NE.0) GOTO 998
         CALL GVSNEG (XYZC,3)
         VECT(1)=XCOORD(IATDON)-XCOORD(IATACC)
         VECT(2)=YCOORD(IATDON)-YCOORD(IATACC)
         VECT(3)=ZCOORD(IATDON)-ZCOORD(IATACC)
         CALL GVSCP3 (TVEC,XYZC,VECT)
         CALL GVSMGM (RMAT,TVEC,GVFDTR(120.0))
         CALL GVSMV3 (XYZ1,RMAT,XYZC)
         CALL GVSNM3 (XYZ1)



         CALL GVSMGM (RMAT,TVEC,GVFDTR(-120.0))
         CALL GVSMV3 (XYZ2,RMAT,XYZC)
         CALL GVSNM3 (XYZ2)



         XYZ1(1)=XYZ1(1)+XCOORD(IATDON)
         XYZ1(2)=XYZ1(2)+YCOORD(IATDON)
         XYZ1(3)=XYZ1(3)+ZCOORD(IATDON)
         XYZ2(1)=XYZ2(1)+XCOORD(IATDON)
         XYZ2(2)=XYZ2(2)+YCOORD(IATDON)
         XYZ2(3)=XYZ2(3)+ZCOORD(IATDON)



         DIST1=SQRT((XYZ1(1)-XCOORD(IATACC))**2+
     +              (XYZ1(2)-YCOORD(IATACC))**2+
     +              (XYZ1(3)-ZCOORD(IATACC))**2)
         DIST2=SQRT((XYZ2(1)-XCOORD(IATACC))**2+
     +              (XYZ2(2)-YCOORD(IATACC))**2+
     +              (XYZ2(3)-ZCOORD(IATACC))**2)



         VECT(1)=XYZ1(1)-XCOORD(IATDON)
         VECT(2)=XYZ1(2)-YCOORD(IATDON)
         VECT(3)=XYZ1(3)-ZCOORD(IATDON)
         TVEC(1)=XYZ1(1)-XCOORD(IATACC)
         TVEC(2)=XYZ1(2)-YCOORD(IATACC)
         TVEC(3)=XYZ1(3)-ZCOORD(IATACC)
         ANGLH1=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))
         CALL HBO016 (XYZ1,IATACC,ANGLA1)
         VECT(1)=XYZ2(1)-XCOORD(IATDON)
         VECT(2)=XYZ2(2)-YCOORD(IATDON)
         VECT(3)=XYZ2(3)-ZCOORD(IATDON)
         TVEC(1)=XYZ2(1)-XCOORD(IATACC)
         TVEC(2)=XYZ2(2)-YCOORD(IATACC)
         TVEC(3)=XYZ2(3)-ZCOORD(IATACC)
         ANGLH2=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))
         CALL HBO016 (XYZ2,IATACC,ANGLA2)



         ISHBO1=HBO023(D12,DIST1,ANGLH1,ANGLA1)
         ISHBO2=HBO023(D12,DIST2,ANGLH2,ANGLA2)
         IF (WIFPAR(488).GT.0) THEN
            IF (ISHBO1) CALL GVSTT6 ('ISHBO1=.TRUE.')
            IF (ISHBO2) CALL GVSTT6 ('ISHBO2=.TRUE.')
         END IF



         IF ((.NOT.ISHBO1).AND.(.NOT.ISHBO2)) GOTO 998



         IF (ISHBO1.AND.(.NOT.ISHBO2)) GOTO 100



         IF (.NOT.ISHBO1.AND.ISHBO2) THEN
            CALL GVSWAP (DIST1,DIST2)
            CALL GVSWAP (ANGLH1,ANGLH2)
            CALL GVSWAP (ANGLA1,ANGLA2)
            CALL GVSWAP (XYZ1(1),XYZ2(1))
            CALL GVSWAP (XYZ1(2),XYZ2(2))
            CALL GVSWAP (XYZ1(3),XYZ2(3))
            GOTO 100
         END IF




         IF (ISHBO1.AND.ISHBO2) THEN
            IF (DIST1.GT.DIST2) THEN
               CALL GVSWAP (DIST1,DIST2)
               CALL GVSWAP (ANGLH1,ANGLH2)
               CALL GVSWAP (ANGLA1,ANGLA2)
               CALL GVSWAP (XYZ1(1),XYZ2(1))
               CALL GVSWAP (XYZ1(2),XYZ2(2))
               CALL GVSWAP (XYZ1(3),XYZ2(3))
            END IF
         END IF
  100    CONTINUE
         ISHBO1=.TRUE.
         ISHBO2=.FALSE.
         ANGLH2=999.9
         ANGLA2=999.9
         DIST2=999.9
         XYZ2(1)=0.0
         XYZ2(2)=0.0
         XYZ2(3)=0.0
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO031A (IATDON,IATACC,ISHBO)




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IATDON, IATACC, IERR, FIXED
      REAL          XYZ1(3), XYZ2(3), VECT(3), TVEC(3), XYZC(3),
     +              XYZR(3), RMAT(3,3), ANGLH1, ANGLH2, D12, DIST1,
     +              DIST2, ANGLA1, ANGLA2, WIFDST, XYZ3(3), GVFANG,
     +              GVFRTD, GVFDTR
      LOGICAL       ISHBO, WIFITW, HBO023, REALH







      CALL GVSRT0 (XYZ1,3)
      CALL GVSRT0 (XYZ2,3)
      IERR=0
      ISHBO=.FALSE.
      DIST1=999.9
      ANGLH1=999.9
      ANGLA1=999.9
      DIST2=999.9
      ANGLH2=999.9
      ANGLA2=999.9
      IF (WIFITW(IATACC)) THEN
         ANGLA1=0.0
         ANGLA2=0.0
      END IF
      D12=WIFDST(IATDON,IATACC)



      IF (DONACC(IATDON).EQ.-1) THEN
         CALL GVSTTB ('?BUGH26')
         GOTO 998
      END IF
      IF (DONACC(IATACC).EQ.1) THEN
         CALL GVSTTB ('?BUGH27')
         GOTO 998
      END IF






      IF (WIFITW(IATDON)) THEN
         CALL HBO018 (IATDON,IATACC,XYZ1)
         FIXED=1
      ELSE
         CALL HBO012 (IATDON,XYZ1,XYZ2,XYZ3,FIXED,REALH)
      END IF



      IF (FIXED.GT.0) THEN



         DIST1=SQRT((XYZ1(1)-XCOORD(IATACC))**2+
     +              (XYZ1(2)-YCOORD(IATACC))**2+
     +              (XYZ1(3)-ZCOORD(IATACC))**2)



         VECT(1)=XCOORD(IATDON)-XYZ1(1)
         VECT(2)=YCOORD(IATDON)-XYZ1(2)
         VECT(3)=ZCOORD(IATDON)-XYZ1(3)
         TVEC(1)=XCOORD(IATACC)-XYZ1(1)
         TVEC(2)=YCOORD(IATACC)-XYZ1(2)
         TVEC(3)=ZCOORD(IATACC)-XYZ1(3)
         ANGLH1=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))



         CALL HBO016 (XYZ1,IATACC,ANGLA1)



         ISHBO=HBO023(D12,DIST1,ANGLH1,ANGLA1)
         IF (ISHBO) GOTO 998



         IF (FIXED.GT.1) THEN



            DIST2=SQRT((XYZ2(1)-XCOORD(IATACC))**2+
     +                 (XYZ2(2)-YCOORD(IATACC))**2+
     +                 (XYZ2(3)-ZCOORD(IATACC))**2)



            VECT(1)=XCOORD(IATDON)-XYZ2(1)
            VECT(2)=YCOORD(IATDON)-XYZ2(2)
            VECT(3)=ZCOORD(IATDON)-XYZ2(3)
            TVEC(1)=XCOORD(IATACC)-XYZ2(1)
            TVEC(2)=YCOORD(IATACC)-XYZ2(2)
            TVEC(3)=ZCOORD(IATACC)-XYZ2(3)
            ANGLH2=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))
            CALL HBO016 (XYZ2,IATACC,ANGLA2)



            ISHBO=HBO023(D12,DIST2,ANGLH2,ANGLA2)
            IF (ISHBO) GOTO 998
            GOTO 998
         END IF
      ELSE









         CALL HBO013 (IATDON,XYZC,XYZR,IERR)
         IF (IERR.NE.0) GOTO 998
         CALL GVSNEG (XYZC,3)
         VECT(1)=XCOORD(IATDON)-XCOORD(IATACC)
         VECT(2)=YCOORD(IATDON)-YCOORD(IATACC)
         VECT(3)=ZCOORD(IATDON)-ZCOORD(IATACC)
         CALL GVSCP3 (TVEC,XYZC,VECT)
         CALL GVSMGM (RMAT,TVEC,GVFDTR(120.0))
         CALL GVSMV3 (XYZ1,RMAT,XYZC)
         CALL GVSNM3 (XYZ1)



         CALL GVSMGM (RMAT,TVEC,GVFDTR(-120.0))
         CALL GVSMV3 (XYZ2,RMAT,XYZC)
         CALL GVSNM3 (XYZ2)



         XYZ1(1)=XYZ1(1)+XCOORD(IATDON)
         XYZ1(2)=XYZ1(2)+YCOORD(IATDON)
         XYZ1(3)=XYZ1(3)+ZCOORD(IATDON)
         XYZ2(1)=XYZ2(1)+XCOORD(IATDON)
         XYZ2(2)=XYZ2(2)+YCOORD(IATDON)
         XYZ2(3)=XYZ2(3)+ZCOORD(IATDON)



         DIST1=SQRT((XYZ1(1)-XCOORD(IATACC))**2+
     +              (XYZ1(2)-YCOORD(IATACC))**2+
     +              (XYZ1(3)-ZCOORD(IATACC))**2)
         DIST2=SQRT((XYZ2(1)-XCOORD(IATACC))**2+
     +              (XYZ2(2)-YCOORD(IATACC))**2+
     +              (XYZ2(3)-ZCOORD(IATACC))**2)



         VECT(1)=XYZ1(1)-XCOORD(IATDON)
         VECT(2)=XYZ1(2)-YCOORD(IATDON)
         VECT(3)=XYZ1(3)-ZCOORD(IATDON)
         TVEC(1)=XYZ1(1)-XCOORD(IATACC)
         TVEC(2)=XYZ1(2)-YCOORD(IATACC)
         TVEC(3)=XYZ1(3)-ZCOORD(IATACC)
         ANGLH1=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))
         CALL HBO016 (XYZ1,IATACC,ANGLA1)
         ISHBO=HBO023(D12,DIST1,ANGLH1,ANGLA1)
         IF (ISHBO) GOTO 998



         VECT(1)=XYZ2(1)-XCOORD(IATDON)
         VECT(2)=XYZ2(2)-YCOORD(IATDON)
         VECT(3)=XYZ2(3)-ZCOORD(IATDON)
         TVEC(1)=XYZ2(1)-XCOORD(IATACC)
         TVEC(2)=XYZ2(2)-YCOORD(IATACC)
         TVEC(3)=XYZ2(3)-ZCOORD(IATACC)
         ANGLH2=ABS(180.0-ABS(GVFRTD(GVFANG(VECT,TVEC))))
         CALL HBO016 (XYZ2,IATACC,ANGLA2)
         ISHBO=HBO023(D12,DIST2,ANGLH2,ANGLA2)
         IF (ISHBO) GOTO 998
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO032 (IAA,HBOVAL)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IAA, IAT, JAA, JAT, ISOUP, GVFIN0
      REAL          HBOVAL, HBOQVAL
      LOGICAL       WIFIRR, WIFIRA







      HBOVAL=0.0



      IF (.NOT.WIFIRR(IAA)) THEN
         CALL GVSTTI ('?BUGH28',IAA)
         GOTO 998
      END IF
      IF (GVFIN0(USESOU,NUMSOU).EQ.0) THEN
         CALL GVSKIL
         GOTO 998
      END IF
      IF (RESTYP(IAA).EQ.1.OR.RESTYP(IAA).EQ.2.OR.
     +    RESTYP(IAA).EQ.5.OR.RESTYP(IAA).EQ.6.OR.
     +    RESTYP(IAA).EQ.8.OR.RESTYP(IAA).EQ.10.OR.
     +    RESTYP(IAA).EQ.11.OR.RESTYP(IAA).EQ.13.OR.
     +    RESTYP(IAA).EQ.18.OR.RESTYP(IAA).EQ.21) GOTO 998



      IF (WIFIRA(IAA).AND.PNTAAE(IAA).GE.PNTAAS(IAA)+4) THEN
         DO 10 IAT=PNTAAS(IAA)+4,PNTAAE(IAA)
            IF (BOUND_TO(1,IAT).NE.0.OR.BOUND_TO(2,IAT).NE.0.OR.
     +          BOUND_TO(3,IAT).NE.0.OR.BOUND_TO(4,IAT).NE.0.OR.
     +          BOUND_TO(5,IAT).NE.0.OR.BOUND_TO(6,IAT).NE.0.OR.
     +          BOUND_TO(7,IAT).NE.0.OR.BOUND_TO(8,IAT).NE.0) THEN
               HBOVAL=0.0
               GOTO 998
            END IF
 10      CONTINUE
      END IF



      DO 100 IAT=PNTAAS(IAA)+4,PNTAAE(IAA)
         IF (.NOT.USABLE(IAT)) GOTO 100



         DO 95 ISOUP=1,NUMSOU
            IF (USESOU(ISOUP).EQ.0) GOTO 95
            DO 90 JAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)



               DO 80 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  IF (.NOT.USABLE(JAT)) GOTO 80
                  IF (IAT.EQ.JAT) GOTO 80
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 80



                  IF (DONACC(IAT).EQ.1) THEN
                     HBOVAL=HBOVAL+HBOQVAL(IAT,JAT,1)
                     IF (WIFPAR(1012).NE.0.AND.WIFPAR(602).NE.0.AND.
     +                   HBOQVAL(IAT,JAT,1).GT.0.001) THEN
                        IF (USE300) CALL DRW051 (IAT,JAT,19)
                     END IF
                  ELSE IF (DONACC(IAT).EQ.0) THEN
                     HBOVAL=HBOVAL+MAX(HBOQVAL(IAT,JAT,1),
     +                HBOQVAL(JAT,IAT,1))
                     IF (WIFPAR(1012).NE.0.AND.WIFPAR(602).NE.0.AND.
     +                   HBOQVAL(IAT,JAT,1).GT.0.001) THEN
                        IF (USE300) CALL DRW051 (IAT,JAT,19)
                     END IF
                  ELSE IF (DONACC(IAT).EQ.-1) THEN
                     HBOVAL=HBOVAL+HBOQVAL(JAT,IAT,1)
                     IF (WIFPAR(1012).NE.0.AND.WIFPAR(602).NE.0.AND.
     +                   HBOQVAL(IAT,JAT,1).GT.0.001) THEN
                        IF (USE300) CALL DRW051 (IAT,JAT,19)
                     END IF
                  END IF
 80            CONTINUE
 90         CONTINUE
 95      CONTINUE
 100  CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO032A (IAA,JFT1,JFT2,HBOVAL)





















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, JFT1, JFT2, HBOVAL, IWOSWO1, IWOSWO2, IAT,
     +              JAA, JAT, IWOSWO
      REAL          CUTACC, D12, DMIN
      LOGICAL       LOCHBO1, LOCHBO2, WIFIRR







      HBOVAL=0
      IF (.NOT.WIFIRR(IAA)) THEN
         CALL GVSTTI ('?BUGH31',IAA)
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(JFT1)) THEN
         CALL GVSTTI ('?BUGH32',JFT1)
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(JFT2)) THEN
         CALL GVSTTI ('?BUGH33',JFT2)
         GOTO 998
      END IF
      IF (RESTYP(IAA).NE.7) THEN
         CALL GVSTTB ('?BUGH34')
         GOTO 998
      END IF









      CUTACC=WIFPAR(481)/100.0






      CALL HBO010
      IWOSWO1=0
      IWOSWO2=0
      CALL GRTVIN



      IAT=PNTAAS(IAA)+6
      IF (.NOT.USABLE(IAT)) THEN
         CALL GVSTTB ('?HBOHISD')
      ELSE



         DO 20 JAA=JFT1,JFT2
            IF (JAA.EQ.IAA) GOTO 20



            DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +           (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +           (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
            IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+SPHRAD(4,JAA))**2) GOTO 20



            DO 10 JAT=PNTAAS(JAA),PNTAAE(JAA)
               IF (.NOT.USABLE(JAT)) GOTO 10
               IF (IAT.EQ.JAT) GOTO 10
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 10



               D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                  (YCOORD(IAT)-YCOORD(JAT))**2+
     +                  (ZCOORD(IAT)-ZCOORD(JAT))**2)
               IF (D12.LT.CUTACC) THEN
                  CALL HBO032B (IAA,IAT,JAA,JAT,IWOSWO,LOCHBO1)
                  IF (.NOT.LOCHBO1) GOTO 10
                  IF (IWOSWO1.GT.0) THEN
                     IF (IWOSWO.NE.IWOSWO1) THEN

                        HBOVAL=0
                        GOTO 998
                     END IF
                  END IF
                  IWOSWO1=IWOSWO
               END IF
   10       CONTINUE
   20    CONTINUE
      END IF



      IAT=PNTAAS(IAA)+9
      IF (.NOT.USABLE(IAT)) THEN
         CALL GVSTTB ('*HBOHISE')
      ELSE



         DO 40 JAA=JFT1,JFT2
            IF (JAA.EQ.IAA) GOTO 40



            DMIN=(SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +           (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +           (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2
            IF (DMIN.GT.(CUTACC+SPHRAD(4,IAA)+SPHRAD(4,JAA))**2) GOTO 40



            DO 30 JAT=PNTAAS(JAA),PNTAAE(JAA)
               IF (.NOT.USABLE(JAT)) GOTO 30
               IF (IAT.EQ.JAT) GOTO 30
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 30



               D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                  (YCOORD(IAT)-YCOORD(JAT))**2+
     +                  (ZCOORD(IAT)-ZCOORD(JAT))**2)
               IF (D12.LT.CUTACC) THEN
                  CALL HBO032B (IAA,IAT,JAA,JAT,IWOSWO,LOCHBO2)
                  IF (.NOT.LOCHBO2) GOTO 30
                  IF (IWOSWO2.GT.0) THEN
                     IF (IWOSWO.NE.IWOSWO2) THEN

                        HBOVAL=0
                        GOTO 998
                     END IF
                  END IF
                  IWOSWO2=IWOSWO
               END IF
   30       CONTINUE
   40    CONTINUE
      END IF

















      IF (IWOSWO1.EQ.0.AND.IWOSWO2.EQ.0) HBOVAL=0
      IF (IWOSWO1.EQ.0.AND.IWOSWO2.EQ.1) HBOVAL=2
      IF (IWOSWO1.EQ.0.AND.IWOSWO2.EQ.2) HBOVAL=1
      IF (IWOSWO1.EQ.0.AND.IWOSWO2.EQ.3) HBOVAL=0
      IF (IWOSWO2.EQ.0.AND.IWOSWO1.EQ.1) HBOVAL=1
      IF (IWOSWO2.EQ.0.AND.IWOSWO1.EQ.2) HBOVAL=2
      IF (IWOSWO2.EQ.0.AND.IWOSWO1.EQ.3) HBOVAL=0
      IF (IWOSWO1.EQ.0.OR.IWOSWO1.EQ.0) GOTO 998

      IF (IWOSWO1.EQ.3.AND.IWOSWO2.EQ.3) THEN
         IF (LOCHBO1.AND.LOCHBO2) THEN
            CALL GVSTT6 ('?HBOHIS1')
         ELSE IF (LOCHBO1) THEN
            CALL GVSTT6 ('?HBOHIS2')
         ELSE IF (LOCHBO2) THEN
            CALL GVSTT6 ('?HBOHIS3')
         ELSE
            CALL GVSTT6 ('?HBOHIS4')
         END IF
         HBOVAL=0
      END IF
      IF (IWOSWO1.EQ.1.AND.IWOSWO2.EQ.3) HBOVAL=1
      IF (IWOSWO1.EQ.2.AND.IWOSWO2.EQ.3) HBOVAL=2

      IF (IWOSWO1.EQ.3.AND.IWOSWO2.EQ.1) HBOVAL=2
      IF (IWOSWO1.EQ.1.AND.IWOSWO2.EQ.1) THEN

         HBOVAL=0
      END IF
      IF (IWOSWO1.EQ.2.AND.IWOSWO2.EQ.1) HBOVAL=2

      IF (IWOSWO1.EQ.3.AND.IWOSWO2.EQ.2) HBOVAL=1
      IF (IWOSWO1.EQ.1.AND.IWOSWO2.EQ.2) HBOVAL=1
      IF (IWOSWO1.EQ.2.AND.IWOSWO2.EQ.2) THEN
         CALL GVSTT6 ('?HBOHIS6')
         HBOVAL=0
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO032B (IAA,IAT,JAA,JAT,IWOSWO,ISHBO)






















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IWOSWO, IAT, JAA, JAT, IDOUBL, IERR
      REAL          XYZ1(3), XYZ2(3), DIST1, DIST2,
     +              ANGLH1, ANGLH2, ANGLA1, ANGLA2
      LOGICAL       ISHBO, ISHBO1, ISHBO2







      IF (DONACC(IAT).NE.0.OR.DONACC(JAT).NE.0) THEN
         CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +    DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +    XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
         ISHBO=ISHBO1.OR.ISHBO2



      ELSE



         CALL HBO031A (IAT,JAT,ISHBO1)



         CALL HBO031A (JAT,IAT,ISHBO2)



         IF (ISHBO1) THEN
            IF (ISHBO2) THEN
               IWOSWO=3
            ELSE
               IWOSWO=1
            END IF
         ELSE
            IF (ISHBO2) THEN
               IWOSWO=2
            ELSE
               IWOSWO=0
            END IF
         END IF
         ISHBO=ISHBO1.OR.ISHBO2
      END IF





      RETURN
      END
      SUBROUTINE HBO032C (IAA,JFT1,JFT2,HBOVAL)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, JFT1, JFT2, IAT, JAA, JAT
      REAL          HBOVAL, HBOQVAL
      LOGICAL       WIFIRR







      HBOVAL=0.0



      IF (.NOT.WIFIRR(IAA)) THEN
         CALL GVSTTI ('?BUGH28',IAA)
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(JFT1)) THEN
         CALL GVSTTI ('?BUGH29',JFT1)
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(JFT2)) THEN
         CALL GVSTTI ('?BUGH30',JFT2)
         GOTO 998
      END IF



      DO 100 IAT=PNTAAS(IAA)+10,PNTAAE(IAA)
         IF (.NOT.USABLE(IAT)) GOTO 100



         DO 90 JAA=JFT1,JFT2



            DO 80 JAT=PNTAAS(JAA),PNTAAE(JAA)
               IF (.NOT.USABLE(JAT)) GOTO 80
               IF (IAT.EQ.JAT) GOTO 80
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 80
               HBOVAL=HBOVAL+
     +          MAX(HBOQVAL(IAT,JAT,1),HBOQVAL(JAT,IAT,1))
   80       CONTINUE
   90    CONTINUE
  100 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO032D (IAA,JFT1,JFT2,HBOVAL)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, JFT1, JFT2, IAT, JAA, JAT
      REAL          HBOVAL, HBOQVAL, HBOVAL1, HBOVAL2
      LOGICAL       WIFIRR







      HBOVAL=0.0
      CALL GVSRT0 (ATTVL2,NUMATF)



      IF (.NOT.WIFIRR(IAA)) THEN
         CALL GVSTTI ('?BUGH28',IAA)
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(JFT1)) THEN
         CALL GVSTTI ('?BUGH29',JFT1)
         GOTO 998
      END IF
      IF (.NOT.WIFIRR(JFT2)) THEN
         CALL GVSTTI ('?BUGH30',JFT2)
         GOTO 998
      END IF



      DO 100 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (.NOT.USABLE(IAT)) GOTO 100



         DO 90 JAA=JFT1,JFT2



            DO 80 JAT=PNTAAS(JAA),PNTAAE(JAA)
               IF (.NOT.USABLE(JAT)) GOTO 80
               IF (IAT.EQ.JAT) GOTO 80
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 80
               HBOVAL1=HBOQVAL(IAT,JAT,1)
               HBOVAL2=HBOQVAL(JAT,IAT,1)
               IF (DONACC(IAT).EQ.1) THEN
                  ATTVL2(IAT)=ATTVL2(IAT)+HBOVAL1
                  ATTVL2(JAT)=ATTVL2(JAT)+HBOVAL1
               ELSE IF (DONACC(IAT).EQ.0) THEN
                  ATTVL2(IAT)=ATTVL2(IAT)+MAX(HBOVAL1,HBOVAL2)
                  ATTVL2(JAT)=ATTVL2(JAT)+MAX(HBOVAL1,HBOVAL2)
               ELSE IF (DONACC(IAT).EQ.-1) THEN
                  ATTVL2(IAT)=ATTVL2(IAT)+HBOVAL2
                  ATTVL2(JAT)=ATTVL2(JAT)+HBOVAL2
               END IF
   80       CONTINUE
   90    CONTINUE
         HBOVAL=HBOVAL+ATTVL2(IAT)
  100 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO035

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INCLUDE       'HB2INC.INC'
      INTEGER       IERR







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



      CALL HB2INI



      CALL GVSNL6 (5)
      CALL GVSTTR ('?M0724',TOTVAL)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE HBO072



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IERR, IAA, IAT, JAA, JAT, IDOUBL,
     +              IWOSWO
      LOGICAL       ISHBO1, ISHBO2, WIFIRW, ISWAT, ISWAT1, ISWAT2
      REAL          XYZ1(3), XYZ2(3), DMIN, DIST1, DIST2, ANGLH1,
     +              ANGLH2, ANGLA1, ANGLA2, D12







      IF (NUMAAF.LT.2) THEN
         CALL GVSTTE ('?>2AA')
         GOTO 998
      END IF



      CALL HBO004
      CALL GRTVIN



      IF (USE300) THEN
         CALL GVSTT6 ('?NEWT205')
         CALL GRTKOF
         CALL GRA008 (IAA,IAT)
         CALL GRTKON
      ELSE
         CALL WIFGRS (IAA,' ')
      END IF
      IF (IAA.EQ.0) GOTO 998
      CALL WIFWTF (' ',IERR)
      IF (IERR.GT.0) GOTO 998






      CALL HBO010



      ISWAT1=WIFIRW(IAA)
      DO 90 JAA=1,NUMAAT
         IF (.NOT.WRK1TF(JAA)) GOTO 90
         ISWAT2=WIFIRW(JAA)
         ISWAT=ISWAT1.OR.ISWAT2



         IF (.NOT.ISWAT) THEN
            DMIN=SQRT((SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +                (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +                (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2)-
     +                 SPHRAD(4,IAA)-SPHRAD(4,JAA)

            IF (DMIN.GT.WIFPAR(481)/100.0) GOTO 90
         END IF



         DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.USABLE(IAT)) GOTO 80
            DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
               IF (.NOT.USABLE(JAT)) GOTO 70
               IF (IAT.EQ.JAT) GOTO 70
               IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
               IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



               D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                  (YCOORD(IAT)-YCOORD(JAT))**2+
     +                  (ZCOORD(IAT)-ZCOORD(JAT))**2)
               IF (D12.LT.WIFPAR(481)/100.0) THEN



                  CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +             DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +             XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)
                  IF (IERR.EQ.0.AND.ISHBO1) THEN
                     IF (IWOSWO.LE.1) THEN
                        CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                   ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                     ELSE
                        CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                   ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                     END IF
                  END IF
               END IF
   70       CONTINUE
   80    CONTINUE
   90 CONTINUE



      CALL GRAMOL (' ')



      CALL GVSFMT ('?FMT103')
      CALL GVSCTB (LINE,80)
      WRITE (LINE,FMT,ERR=999) IAA
      CALL SETHIS (LINE)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('HBO072')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO073



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IERR, IFT1, IFT2, JFT1, JFT2, IWOSWO,
     +              IDOUBL, IAT, JAT, JAA, IAA
      REAL          XYZ1(3), XYZ2(3), DIST1, DIST2, ANGLH1, ANGLH2,
     +              ANGLA1, ANGLA2, D12, DMIN
      LOGICAL       WIFIRW, ISWAT1, ISWAT2, BBB1, BBB2, 
     +              SAME12, ISHBO1, ISHBO2
      CHARACTER*2   BBBSSS







      IF (NUMAAF.LT.2) THEN
         CALL GVSTTE ('?>2AA')
         GOTO 998
      END IF



      CALL GRTVIN
      CALL HBO004



      CALL WIFGRN (IFT1,IFT2,'?RANGE1')
      CALL GVSCTB (TPTXLN,LENTPT)
      IF (IFT1.EQ.0) GOTO 998
      CALL WIFGRN (JFT1,JFT2,'?RANGE2')
      CALL GVSCTB (TPTXLN,LENTPT)
      IF (JFT1.EQ.0) GOTO 998
      SAME12=IFT1.EQ.JFT1.AND.IFT2.EQ.JFT2



   5  CONTINUE
      CALL GVSCTB (BBBSSS,2)
      CALL IPROMPT ('?NEWP38')
      CALL NEEDWORD (BBBSSS,' ',IERR)
      IF (IERR.NE.0) GOTO 998
      CALL GVSCUC (BBBSSS)
      IF (BBBSSS.NE.'BB'.AND.BBBSSS.NE.'BS'.AND.
     +    BBBSSS.NE.'SS') THEN
         CALL GVSTTE ('?NEWE124')
         CALL GVSTT6 ('?NEWT206')
         CALL GVSTT6 ('?NEWT207')
         CALL GVSTT6 ('?NEWT208')
         GOTO 5
      END IF



      CALL HBO010



      CALL GVSNL6 (1)
      DO 100 IAA=IFT1,IFT2
         ISWAT1=WIFIRW(IAA)
         IF (ISWAT1) GOTO 100
         DO 90 JAA=JFT1,JFT2
            ISWAT2=WIFIRW(JAA)
            IF (ISWAT2) GOTO 90



            IF (SAME12.AND.JAA.LT.IAA) GOTO 90



            DMIN=SQRT((SPHRAD(1,IAA)-SPHRAD(1,JAA))**2+
     +                (SPHRAD(2,IAA)-SPHRAD(2,JAA))**2+
     +                (SPHRAD(3,IAA)-SPHRAD(3,JAA))**2)-
     +                 SPHRAD(4,IAA)-SPHRAD(4,JAA)

            IF (DMIN.GT.WIFPAR(481)/100.0) GOTO 90



            DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
               IF (.NOT.USABLE(IAT)) GOTO 80
               BBB1=.FALSE.
               IF (IAT.LT.PNTAAS(IAA)+4) BBB1=.TRUE.
               IF (BBBSSS.EQ.'BB'.AND.(.NOT.BBB1)) GOTO 80
               IF (BBBSSS.EQ.'SS'.AND.BBB1) GOTO 80
               DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  BBB2=.FALSE.
                  IF (JAT.LT.PNTAAS(JAA)+4) BBB2=.TRUE.
                  IF (BBBSSS.EQ.'BB'.AND.(.NOT.BBB2)) GOTO 70
                  IF (BBBSSS.EQ.'SS'.AND.BBB2) GOTO 70
                  IF (BBBSSS.EQ.'BS'.OR.BBBSSS.EQ.'SB') THEN
                     IF (BBB1.AND.BBB2) GOTO 70
                     IF ((.NOT.BBB1).AND.(.NOT.BBB2)) GOTO 70
                  END IF
                  IF (.NOT.USABLE(JAT)) GOTO 70
                  IF (IAT.EQ.JAT) GOTO 70
                  IF (DONACC(IAT)*DONACC(JAT).EQ.1) GOTO 70
                  IF (IAA.EQ.JAA.AND.IAT.GE.JAT) GOTO 70



                  D12=SQRT((XCOORD(IAT)-XCOORD(JAT))**2+
     +                     (YCOORD(IAT)-YCOORD(JAT))**2+
     +                     (ZCOORD(IAT)-ZCOORD(JAT))**2)
                  IF (D12.LT.WIFPAR(481)/100.0) THEN



                     CALL HBO030 (IAA,IAT,JAA,JAT,ISHBO1,ISHBO2,
     +                DIST1,DIST2,ANGLH1,ANGLH2,ANGLA1,ANGLA2,
     +                XYZ1,XYZ2,IWOSWO,IDOUBL,IERR)








                     IF (ISHBO1) THEN
                        IF (IWOSWO.LE.1) THEN
                           CALL HBO007 (IAT,JAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        ELSE
                           CALL HBO007 (JAT,IAT,D12,DIST1,DIST2,
     +                      ANGLH1,ANGLH2,ANGLA1,ANGLA2,XYZ1,XYZ2)
                        END IF
                     END IF
                  END IF
   70          CONTINUE
   80       CONTINUE
   90    CONTINUE
  100 CONTINUE



      CALL GRAMOL (' ')



      CALL GVSCCC (LINE,'?M0699',BBBSSS)
      CALL SETHIS (LINE)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE HBO075 (IFT1,IFT2)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IERR, IFT1, IFT2, IAA, GVFCBT
      LOGICAL       GVFIBN, HASPROTON







      IF (WIFPAR(84).NE.1) THEN
         CALL GVSTTE ('?M2010')
         GOTO 998
      END IF
      IF (.NOT.HASPROTON()) THEN
         CALL GVSTTE ('?M2066')
         GOTO 998
      END IF



      CALL GVSBTF (WRK1TF,MAXAA)
      CALL GVSRT0 (ATTVAL,MAXAT)
      CALL HBO010



      IF (GVFIBN(IFT1,1,NUMAAF).AND.GVFIBN(IFT2,1,NUMAAF)) THEN
         DO 10 IAA=IFT1,IFT2
            WRK1TF(IAA)=.TRUE.
   10    CONTINUE
      ELSE
         CALL WIFWTF (' ',IERR)
         IF (IERR.NE.0) GOTO 998
      END IF
      IF (GVFCBT(WRK1TF,MAXAA).LE.0) GOTO 998



      CALL ENVINI
      DO 20 IAA=1,NUMAAF
         IF (WRK1TF(IAA)) USESOU(SOUPNT(IAA))=SOUPNT(IAA)
   20 CONTINUE



      DO 30 IAA=1,NUMAAF
         CALL HBO076 (IAA)
   30 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE HBO076 (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IAA, IAT, IATDON, IATACC, JAA, IATH, ISOUP
      REAL          HBOVAL, HBO1VAL, HYD(3)
      LOGICAL       WIFIRR, AREBOUND







      HBOVAL=0.0



      IF (.NOT.WIFIRR(IAA)) THEN
         CALL GVSTTI ('?BUGH28',IAA)
         GOTO 998
      END IF
      IF (WIFPAR(84).NE.1) THEN
         CALL GVSTTE ('?M2010')
         GOTO 998
      END IF



      DO 100 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (.NOT.PROTON(IAT)) GOTO 100
         DO 10 IATH=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.PROTON(IATH)) THEN
               IF (AREBOUND(IAT,IATH)) THEN
                  IATDON=IATH
                  GOTO 11
               END IF
            END IF
   10    CONTINUE
   11    CONTINUE
         IF (.NOT.USABLE(IATDON)) GOTO 100



         DO 90 ISOUP=1,NUMSOU
            IF (USESOU(ISOUP).EQ.0) GOTO 90
            DO 80 JAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)



               DO 70 IATACC=PNTAAS(JAA),PNTAAE(JAA)
                  IF (PROTON(IATACC)) GOTO 70
                  IF (.NOT.USABLE(IATACC)) GOTO 70
                  IF (IAT.EQ.IATACC.OR.IATDON.EQ.IATACC) GOTO 70
                  IF (DONACC(IATACC).NE.-1) GOTO 70
                  HYD(1)=XCOORD(IAT)
                  HYD(2)=YCOORD(IAT)
                  HYD(3)=ZCOORD(IAT)
                  HBOVAL=HBO1VAL(IATDON,HYD,IATACC,1,.TRUE.)
                  ATTVAL(IATDON)=ATTVAL(IATDON)+HBOVAL
                  ATTVAL(IATACC)=ATTVAL(IATACC)+HBOVAL
   70          CONTINUE
   80       CONTINUE
   90    CONTINUE
  100 CONTINUE



  998 CONTINUE


      RETURN
      END
      REAL FUNCTION HBO2VAL(IATDON,IATH)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'HBONDS.INC'
      INTEGER       IATDON, IATACC, JAA, IATH, ISOUP
      REAL          HBO1VAL, HYD(3), WIFDST
      LOGICAL       WIFIRR, AREBOUND, T54EQUAL







      HBO2VAL=0.0



      IF (.NOT.WIFIRR(ATIAA(IATDON))) THEN
         CALL GVSTTI ('?BUGH28',ATIAA(IATDON))
         GOTO 998
      END IF
      IF (WIFPAR(84).NE.1) THEN
         CALL GVSTTE ('?M2010')
         GOTO 998
      END IF
      IF (.NOT.ISATOK(IATDON).OR..NOT.ISATOK(IATH)) THEN




         GOTO 998
      END IF
      IF (.NOT.AREBOUND(IATDON,IATH)) THEN
         CALL GVSTTE ('?M2703')
         GOTO 998
      END IF



      IF (.NOT.USABLE(IATDON).OR..NOT.ISATOK(IATDON)) GOTO 998



      DO 90 ISOUP=1,NUMSOU
         IF (USESOU(ISOUP).EQ.0) GOTO 90
         DO 80 JAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)



            DO 70 IATACC=PNTAAS(JAA),PNTAAE(JAA)



               IF (T54EQUAL(ONESAT(IATACC),' N  ').OR.
     +             T54EQUAL(ONESAT(IATACC),' NH2')) GOTO 70
               IF (IATH.EQ.IATACC.OR.IATDON.EQ.IATACC) GOTO 70
               IF (DONACC(IATDON)*DONACC(IATACC).EQ.1) GOTO 70
               IF (WIFPAR(1858).EQ.1) THEN
                  IF (PROTON(IATACC)) THEN
                     IF (ATIAA(IATACC).EQ.ATIAA(IATH)) GOTO 70
                     IF (WIFDST(IATACC,IATH).LT.1.2) HBO2VAL=HBO2VAL-4.0
                  END IF
               END IF
               IF (.NOT.USABLE(IATACC)) GOTO 70
               HYD(1)=XCOORD(IATH)
               HYD(2)=YCOORD(IATH)
               HYD(3)=ZCOORD(IATH)
               IF (.NOT.T54EQUAL(ONESAT(IATACC),' NE2').AND.
     +             .NOT.T54EQUAL(ONESAT(IATACC),' ND2')) THEN
                  HBO2VAL=HBO2VAL+HBO1VAL(IATDON,HYD,IATACC,1,.TRUE.)
               END IF
 70         CONTINUE
 80      CONTINUE
 90   CONTINUE



  998 CONTINUE


      RETURN
      END
      REAL FUNCTION HBOTOT()


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, IATH, IATDON, IAT, IBND, JAT
      REAL          HBO2VAL
      LOGICAL       WIFIRA, AREBOUND







      HBOTOT=0.0



      DO 200 IAA=1, NUMAAT



         IF (.NOT.WIFIRA(IAA)) GOTO 200
         DO 100 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (PROTON(IAT)) THEN



               DO 10 IATDON=PNTAAS(IAA),PNTAAE(IAA)
                  IF (.NOT.PROTON(IATDON)) THEN
                     IF (AREBOUND(IAT,IATDON).AND.ISATOK(IAT).AND.
     +                    ISATOK(IATDON)) THEN
                        IATH=IAT
                        HBOTOT=HBOTOT+HBO2VAL(IATDON,IATH)
                     END IF
                  END IF
 10            CONTINUE
            ELSE



               DO 20 IBND=1,8
                  JAT=BOUND_TO(IBND,IAT)
                  IF (JAT.NE.0) THEN
                     IF(PROTON(JAT).AND.ISATOK(IAT).AND.ISATOK(JAT))THEN
                        IATH=BOUND_TO(1,IAT)
                        IATDON=IAT
                        HBOTOT=HBOTOT+HBO2VAL(IATDON,IATH)
                     END IF
                  END IF
 20            CONTINUE
            END IF
 100     CONTINUE
 200  CONTINUE
      IF (WIFPAR(1825).NE.1) CALL GVSTTR ('HBOTOT',HBOTOT)      





      RETURN
      END 
