



      SUBROUTINE SC1001 (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR







      IERR=0



      CALL TEXSECT ('?M2776')



      CALL SC1003




      CALL SC1004



      IF (WIFPAR(1503).EQ.1) CALL SC1005



      CALL SC1006



      CALL SC1007



      CALL SC1008A
      CALL SC1008



      CALL SC1009



      CALL SC1010



      IF (WIFPAR(84).EQ.1) CALL SC1011



      CALL SC1015A
      CALL SC1015



      CALL SC1014



      CALL SC1001A (IERR)
      CALL SC1001B (IERR)





      RETURN
      END   
      SUBROUTINE SC1001A (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, ICAA, ICCA, IRES, IERR
      LOGICAL       WIFIRC, WIFIRA







      ICAA=0
      ICCA=0
      IRES=0
      IERR=0
      CALL GVSRT0 (PRPVAL,NUMAAT)



      DO 10 IAA=1,NUMAAF
         IF (WIFIRA(IAA)) THEN
            ICAA=ICAA+1
            IF (WIFIRC(IAA)) THEN
               ICCA=ICCA+1
               CALL SHOIAA (IAA)
            END IF
         END IF
 10   CONTINUE



      IF (FLOAT(ICCA)/FLOAT(NUMAAF).GT.0.05) THEN
         CALL CDB013 ('CAONBAD','CAONNEU','CAONOK')
         DO 20 IAA=1,NUMAAF
            IF (WIFIRA(IAA)) THEN
               IF (WIFIRC(IAA)) THEN
                  PRPVAL(IAA)=1.0
                  CALL PDBC92 (IAA,0)
               END IF
            END IF
 20      CONTINUE
         CALL CDB012



      ELSE 
         CALL CDB013 ('CAONBAF','CAONNEU','CAONOK')
         DO 21 IAA=1,NUMAAF
            IF (WIFIRA(IAA)) THEN
               IF (WIFIRC(IAA)) THEN
                  PRPVAL(IAA)=1.0
                  CALL PDBC92 (IAA,0)
               END IF
            END IF
 21      CONTINUE
         CALL CDB012
      END IF





      RETURN
      END   
      SUBROUTINE SC1001B (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'GETMOL.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, IERR
      LOGICAL       WIFIRA, GVFIBN







      IERR=0
      CALL CDB013 ('NONCA','NONCANEU','NONCAOK')



      DO 40 IAA=1,NUMAAF
         IF (.NOT.WIFIRA(IAA)) GOTO 40
         IF (.NOT.GVFIBN(RESTYP(IAA),1,20)) THEN
            PRPVAL(IAA)=1.0
            IF (WIFPAR(279).NE.0) THEN
               CALL PDBC92 (IAA,0)
               CALL DIF008 ('?NONCATXT',IAA)
               FIXLST(7)=1.0
            ELSE
               CALL DIF008 ('?NONCATXT',IAA)
            END IF
         END IF
 40   CONTINUE



      CALL CDB012





      RETURN
      END   
      SUBROUTINE SC1002

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAA, ISOUP
      CHARACTER*20  REASON







      CALL CDB013 ('DRGTOPOS','DRGTOPNEU','DRGTOPOK')



      CALL GVSRT0 (PRPVAL,NUMAAT)
      DO 10 ISOUP=1,NUMSOU
         IF (SOUADM(5,ISOUP).EQ.2) THEN
            IAA=SOUADM(1,ISOUP)
            CALL GVSCTB (REASON,20)
            IF (SOUADM(13,ISOUP).EQ.1) CALL GVSSTX (REASON,'?M_R_1')
            IF (SOUADM(13,ISOUP).EQ.2) CALL GVSSTX (REASON,'?M_R_2')
            IF (SOUADM(13,ISOUP).EQ.3) CALL GVSSTX (REASON,'?M_R_3')
            IF (SOUADM(13,ISOUP).EQ.4) CALL GVSSTX (REASON,'?M_R_4')
            IF (SOUADM(13,ISOUP).EQ.5) CALL GVSSTX (REASON,'?M_R_5')



            PRPVAL(IAA)=1.0
            CALL PDBC92A (IAA,0)
            WRITE (LINE92,PDBFMT,ERR=999) LINE92(1:30),REASON
            CALL PDBC93 (LINE92)
         END IF
   10 CONTINUE



      CALL CDB012
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('SC1002')



 998  CONTINUE


      RETURN
      END
      SUBROUTINE SC1003



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAT, IAA, JAT, JAA, IBND
      LOGICAL       WIFIRR, WIFIRD, FOUND
      CHARACTER*28  IATS, JATS







      FOUND=.FALSE.



      CALL CDB013 ('INTCBAD','INTCNEU','INTCOK')



      CALL GVSRT0 (PRPVAL,NUMAAT)
      DO 100 IAT=1,NUMATF
         IAA=ATIAA(IAT)



         DO 90 IBND=1,8
            JAT=BOUND_TO(IBND,IAT)
            IF (JAT.LT.IAT) GOTO 90
            JAA=ATIAA(JAT)
            IF (CHANAM(IAA).EQ.CHANAM(JAA)) GOTO 90



            PRPVAL(IAA)=PRPVAL(IAA)+1.0
            PRPVAL(JAA)=PRPVAL(JAA)+1.0
            FOUND=.TRUE.
            CALL PDBC92A (IAA,IAT)
            CALL GVSSTX (IATS,LINE92(1:28))
            CALL PDBC92A (JAA,JAT)
            CALL GVSSTX (JATS,LINE92(1:28))
            WRITE (LINE92,PDBFMT,ERR=999) IATS,JATS
            CALL PDBC93 (LINE92)
 90      CONTINUE
 100  CONTINUE



      CALL CDB012




      IF (FOUND) THEN
         CALL CDB013 ('CORCBAD',' ','CORCOK')



         DO 200 IAT=1,NUMATF
            IAA=ATIAA(IAT)



            DO 190 IBND=1,8
               JAT=BOUND_TO(IBND,IAT)
               IF (JAT.LT.IAT) GOTO 190
               JAA=ATIAA(JAT)
               IF (CHANAM(IAA).EQ.CHANAM(JAA)) GOTO 190



               IF (WIFIRR(IAA).AND.WIFIRD(JAA)) THEN
                  CHANAM(JAA)=CHANAM(IAA)
                  CALL PDBC92 (JAA,0)
                  GOTO 200
               END IF
 190        CONTINUE
 200     CONTINUE



         CALL CDB012
      END IF
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('SC1003')



 998  CONTINUE


      RETURN
      END
      SUBROUTINE SC1004


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAT, IAA, JAT, JAA
      LOGICAL       WIFIRW, WIFIRR, CH5EQCH5
      CHARACTER*28  IATS, JATS







      CALL CDB013 ('DUPABAD','DUPANEU','DUPAOK')



      CALL GVSRT0 (ATTVAL,NUMATF)
      DO 100 IAA=NUMAAF,NUMAAT
         IF (WIFIRW(IAA).OR.WIFIRR(IAA)) GOTO 100
         IF (PNTAAE(IAA).GT.PNTAAS(IAA)) THEN
            DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)-1
               DO 80 JAT=IAT+1,PNTAAE(IAA)
                  IF (CH5EQCH5(ONESAT(IAT),ONESAT(JAT))) THEN



                     ATTVAL(IAT)=ATTVAL(IAT)+1.0
                     ATTVAL(JAT)=ATTVAL(JAT)+1.0
                     CALL PDBC92A (IAA,IAT)
                     CALL GVSSTX (IATS,LINE92(1:28))
                     CALL PDBC92A (JAA,JAT)
                     CALL GVSSTX (JATS,LINE92(1:28))
                     WRITE (LINE92,PDBFMT,ERR=999) IATS,JATS
                     CALL PDBC93 (LINE92)
                  END IF
 80            CONTINUE
 90         CONTINUE
         END IF
 100  CONTINUE



      CALL CDB012
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('SC1004')



 998  CONTINUE


      RETURN
      END   
      SUBROUTINE SC1005

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IERR, MODEL, IUNIT
      LOGICAL       GRTFILE, CH4EQCH4, GVFISF
      CHARACTER*4   CHAR4







      CALL CDB013 ('MA23BAD',' ','MA23OK')



      IF (.NOT.GVFISF('NMRALT.ATM')) GOTO 30
      IF (.NOT.GRTFILE(IUNIT,'NMRALT.ATM')) GOTO 30
 10   CONTINUE



         CALL GVSCTB (LINE,80)
         CALL GETLINE (IUNIT,LINE,IERR)
         IF (IERR.NE.0) GOTO 30
         CALL GVSTT6 (LINE)
         CALL GVSFMT ('?FMT755B')
         READ (LINE,FMT,ERR=30) CHAR4,MODEL



         DO 20 IAA=1,NUMAAT
            IF (MODNMB(IAA).EQ.MODEL) THEN
               IF (CH4EQCH4(NUMNAM(IAA),CHAR4)) THEN
                  IF (WIFPAR(279).NE.0) THEN
                     CALL PDBC92 (IAA,0)
                  ELSE
                     CALL DIF008 ('?MA23TXT',IAA)
                  END IF
               END IF
            END IF
 20      CONTINUE
      GOTO 10



 30   CONTINUE
      CALL CDB012
      GOTO 998



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1006

















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







      CALL CDB013 ('MA12BAD',' ','MA12OK')



      DO 100 IAA=1,NUMAAT




         CALL ALT051 (IAA,MIXED,IERR)
         IF (MIXED) THEN
            IF (WIFPAR(279).NE.0) THEN
               CALL PDBC92 (IAA,0)
            ELSE
               CALL DIF008 ('?M2785',IAA)
            END IF
            GOTO 100
         END IF



         CALL ALT052 (IAA,MIXED,IERR)
         IF (MIXED) THEN
            IF (WIFPAR(279).NE.0) THEN
               CALL PDBC92 (IAA,0)
            ELSE
               CALL DIF008 ('?M2785',IAA)
            END IF
            GOTO 100
         END IF
 100  CONTINUE



      CALL CDB012
      GOTO 998



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1007

















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







      CALL CDB013 ('MA16BAD',' ','MA16OK')



      DO 100 IAA=1,NUMAAT
         CALL SC1100 (IAA,CORREC,IERR)
         IF (CORREC) THEN
            IF (WIFPAR(279).NE.0) THEN
               CALL PDBC92 (IAA,0)
            ELSE
               CALL DIF008 ('?MA16TXT',IAA)
            END IF
         END IF
 100  CONTINUE



      CALL CDB012
      GOTO 998



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1008

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAA, JAA, IAT, JAT, NUMOUT
      REAL          WIFDST, FACI, FACJ
      LOGICAL       WIF040, WIFIRW







      CALL WIFPUSHPPP (56,-100)
      CALL GVSBTF (WRK3TF,NUMAAT)
      FIXLST(14)=0.0



      DO 100 IAA=NUMAAT,1,-1
         IF (WIFIRW(IAA).OR.WRK3TF(IAA).OR.
     +    PNTAAE(IAA)-PNTAAS(IAA).LE.2) GOTO 100
         IF (FIXRES(IAA).GT.9.5) GOTO 100
         DO 90 JAA=IAA+1,NUMAAT
            IF (MODNMB(IAA).NE.MODNMB(JAA)) GOTO 90
            IF (WIFIRW(JAA).OR.WRK3TF(JAA).OR.
     +       PNTAAE(JAA)-PNTAAS(JAA).LE.2) GOTO 90
            IF (FIXRES(JAA).GT.9.5) GOTO 90
            IF (WIF040(IAA,JAA,3.0)) THEN



               NUMOUT=0
               DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
                  IF (.NOT.ISATOK(IAT).OR.PROTON(IAT)) GOTO 80
                  DO 70 JAT=PNTAAS(JAA),PNTAAE(JAA)
                     IF (.NOT.ISATOK(JAT).OR.PROTON(JAT)) GOTO 70



                     IF (WIFDST(IAT,JAT).LT.2.0) THEN
                        NUMOUT=NUMOUT+1
                        IF (NUMOUT.GT.(PNTAAE(JAA)-PNTAAS(JAA))/2) THEN
                           CALL SC1101 (IAA,FACI)
                           CALL SC1101 (JAA,FACJ)
                           IF (FACI.GE.FACJ) THEN
                              WRK3TF(JAA)=.TRUE.
                              FIXRES(IAA)=FIXRES(IAA)+10.0
                           ELSE
                              WRK3TF(IAA)=.TRUE.
                              FIXRES(JAA)=FIXRES(JAA)+10.0
                           END IF
                           FIXLST(14)=FIXLST(14)+1.0
                           GOTO 100
                        END IF
                     END IF
 70               CONTINUE
 80            CONTINUE
            END IF
 90      CONTINUE
 100  CONTINUE



      IF (FIXLST(14).GT.0.5) THEN
         CALL CDB013 ('MA13BAD',' ','MA13OK')
         DO 110 IAA=1,NUMAAT
            IF (FIXRES(IAA).GT.9.5) THEN
               CALL PDBC92 (IAA,0)
               CALL DIF008 ('?M3479',IAA)
            END IF
 110     CONTINUE
         CALL CDB012
      END IF



      DO 200 IAA=NUMAAT,1,-1
         IF (WRK3TF(IAA)) THEN
            CALL MOL105 (IAA)
            CALL MOL200
         END IF
 200  CONTINUE



      CALL WIFPOPPPP (56)


      RETURN
      END   
      SUBROUTINE SC1008A

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IUNIT, IERR
      LOGICAL       GVFISF, GRTFILE







      IUNIT=0
      IF (.NOT.GVFISF('REMOVED.LIS')) GOTO 998
      IF (.NOT.GRTFILE(IUNIT,'REMOVED.LIS')) GOTO 998



      CALL CDB013 ('MA13ABAD',' ','MA13AOK')



 10   CONTINUE
         CALL GETLINE (IUNIT,LINE,IERR)
         IF (LINE(1:4).EQ.'*END') THEN
            CALL CDB012
            GOTO 998
         END IF
         IF (IERR.NE.0) GOTO 998
         CALL GVSCTB (LINE92,92)
         WRITE (LINE92,PDBFMT,ERR=999) LINE(1:28),LINE(29:56),
     +    LINE(60:69)
         CALL PDBC93 (LINE92)
         CALL GVSTT6 (LINE92)
      GOTO 10



 999  CONTINUE
      CALL GVSEIW ('SC1008A')



 998  CONTINUE
      IF (IUNIT.NE.0) CALL GVSCLF (IUNIT)


      RETURN
      END   
      SUBROUTINE SC1009

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, JAA, IAT, JAT, IBND, IERR
      LOGICAL       WIFISA, WIFIRD







      CALL CDB013 ('AALIGBAD','AALIGNEU','AALIGOK')



      CALL GVSRT0 (PRPVAL,NUMAAT)
      DO 100 ISOUP=1,NUMSOU
         CALL MOL309B (ISOUP,BIGLIN,IERR)
         IF (WIFISA(ISOUP)) THEN
            IF (SOUADM(3,ISOUP).LE.2) THEN
               DO 90 IAA=SOUADM(1,ISOUP),SOUADM(2,ISOUP)
                  DO 80 IAT=PNTAAS(IAA),PNTAAE(IAA)
                     DO 70 IBND=1,8
                        JAT=BOUND_TO(IBND,IAT)
                        IF (JAT.NE.0) THEN
                           JAA=ATIAA(JAT)
                           IF (WIFIRD(JAA)) THEN
                              PRPVAL(IAA)=1.0
                              CALL PDBC92 (IAA,0)
                              GOTO 100
                           END IF
                        END IF
 70                  CONTINUE
 80               CONTINUE
 90            CONTINUE
            END IF
         END IF
 100  CONTINUE



      CALL CDB012





      RETURN
      END   
      SUBROUTINE SC1010

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HBONDS.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAA, IAT, JAT, JAA
      LOGICAL       WIFIRW, WIFIR1, WIFIR6, HBO011
      CHARACTER*28  IATS, JATS







      CALL CDB013 ('LIGHBBAD','LIGHBNEU','LIGHBOK')



      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




            IF (WIFIR1(IAA).AND.IAT.EQ.PNTAAS(IAA)) GOTO 90
            IF (USABLE(IAT).AND.BOUND_TO(1,IAT).GT.0.AND.
     +          HBOTYP(RESTYP(IAA),PINIAA(IAT)).LT.5) THEN
               USABLE(IAT)=.FALSE.
               DONACC(IAT)=0
            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



      CALL GVSRT0 (PRPVAL,NUMAAT)



      DO 200 IAA=1,NUMAAF
         DO 190 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (USABLE(IAT)) THEN
               JAT=BOUND_TO(1,IAT)
               IF (JAT.NE.0) THEN
                  IF (PROTON(JAT)) GOTO 190
                  JAA=ATIAA(IAT)
                  PRPVAL(IAA)=1.0
                  CALL PDBC92A (IAA,IAT)
                  CALL GVSSTX (IATS,LINE92(1:28))
                  CALL PDBC92A (JAA,JAT)
                  CALL GVSSTX (JATS,LINE92(1:28))
                  WRITE (LINE92,PDBFMT,ERR=999) IATS,JATS
                  CALL PDBC93 (LINE92)
                  GOTO 200
               END IF
            END IF
 190     CONTINUE
         IF (RESTYP(IAA).EQ.3) THEN
            IAT=0
            IF (BOUND_TO(1,PNTAAS(IAA)+5).NE.0) THEN
               IAT=PNTAAS(IAA)+5
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+6).NE.0) THEN
               IAT=PNTAAS(IAA)+6
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+7).NE.0) THEN
               IAT=PNTAAS(IAA)+7
            END IF
            IF (IAT.NE.0) THEN
               PRPVAL(IAA)=1.0
               JAT=BOUND_TO(1,IAT)
               IF (JAT.NE.0) THEN
                  IF (PROTON(JAT)) GOTO 200
                  JAA=ATIAA(IAT)
                  PRPVAL(IAA)=1.0
                  CALL PDBC92A (IAA,IAT)
                  CALL GVSSTX (IATS,LINE92(1:28))
                  CALL PDBC92A (JAA,JAT)
                  CALL GVSSTX (JATS,LINE92(1:28))
                  WRITE (LINE92,PDBFMT,ERR=999) IATS,JATS
                  CALL PDBC93 (LINE92)
                  GOTO 200
               END IF
            END IF
         ELSE IF (RESTYP(IAA).EQ.4) THEN
            IAT=0
            IF (BOUND_TO(1,PNTAAS(IAA)+6).NE.0) THEN
               IAT=PNTAAS(IAA)+6
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+7).NE.0) THEN
               IAT=PNTAAS(IAA)+7
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+8).NE.0) THEN
               IAT=PNTAAS(IAA)+8
            END IF
            IF (IAT.NE.0) THEN
               PRPVAL(IAA)=1.0
               JAT=BOUND_TO(1,IAT)
               IF (JAT.NE.0) THEN
                  CALL PDBC92A (IAA,IAT)
                  CALL GVSSTX (IATS,LINE92(1:28))
                  CALL PDBC92A (JAA,JAT)
                  CALL GVSSTX (JATS,LINE92(1:28))
                  WRITE (LINE92,PDBFMT,ERR=999) IATS,JATS
                  CALL PDBC93 (LINE92)
                  GOTO 200
               END IF
            END IF
         ELSE IF (RESTYP(IAA).EQ.7) THEN
            IAT=0
            IF (BOUND_TO(1,PNTAAS(IAA)+5).NE.0) THEN
               IAT=PNTAAS(IAA)+5
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+6).NE.0) THEN
               IAT=PNTAAS(IAA)+6
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+7).NE.0) THEN
               IAT=PNTAAS(IAA)+7
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+8).NE.0) THEN
               IAT=PNTAAS(IAA)+8
            ELSE IF (BOUND_TO(1,PNTAAS(IAA)+9).NE.0) THEN
               IAT=PNTAAS(IAA)+9
            END IF
            IF (IAT.NE.0) THEN
               PRPVAL(IAA)=1.0
               JAT=BOUND_TO(1,IAT)
               IF (JAT.NE.0) THEN
                  CALL PDBC92A (IAA,IAT)
                  CALL GVSSTX (IATS,LINE92(1:28))
                  CALL PDBC92A (JAA,JAT)
                  CALL GVSSTX (JATS,LINE92(1:28))
                  WRITE (LINE92,PDBFMT,ERR=999) IATS,JATS
                  CALL PDBC93 (LINE92)
                  GOTO 200
               END IF
            END IF 
         END IF   
 200  CONTINUE



      CALL CDB012
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('SC1010')



 998  CONTINUE


      RETURN
      END   
      SUBROUTINE SC1011

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, JAT, JAT1ARR(6), JAT2ARR(6),
     +              NUMBND1, NUMBND2
      LOGICAL       CH5EQCH5







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



      CALL CDB013 ('MA17BAD',' ','MA17OK')



      DO 100 IAA=1,NUMAAT
         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)-1
            IF (.NOT.PROTON(IAT)) GOTO 90
            DO 80 JAT=IAT+1,PNTAAE(IAA)
               IF (.NOT.PROTON(JAT)) GOTO 80
               IF (CH5EQCH5(ONESAT(IAT),ORGNAM(JAT)).AND.
     +             CH5EQCH5(ONESAT(JAT),ORGNAM(IAT))) THEN
                  CALL FBONDA (IAT,JAT1ARR,6,NUMBND1)
                  CALL FBONDA (JAT,JAT2ARR,6,NUMBND2)
                  IF (NUMBND1.EQ.1.AND.NUMBND2.EQ.1) THEN
                     IF (CH5EQCH5(ONESAT(JAT1ARR(1)),
     +                   ORGNAM(JAT2ARR(1))).AND.
     +                   CH5EQCH5(ONESAT(JAT2ARR(1)),
     +                   ORGNAM(JAT1ARR(1)))) GOTO 80
                     IF (WIFPAR(279).NE.0) THEN
                        CALL PDBC92 (IAA,0)
                     ELSE
                        CALL DIF008 ('?MA17TXT',IAA)
                     END IF
                     GOTO 100
                  END IF
               END IF
 80         CONTINUE
 90      CONTINUE
 100  CONTINUE



      CALL CDB012



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1012




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'SYMINC.INC'
      REAL          TMP(3), TRF(3), VECDIF, D, IRED
      INTEGER       IAT, IAA, ISYM, IERR








      IF (.NOT.SYMHAS) GOTO 998



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



      IF (NUMSYM.LT.2) GOTO 998



      CALL CDB013 ('ATAXBAD','ATAXNEU','ATAXOK')
      CALL GVSRT0 (ATTVAL,NUMATF)



      DO 100 IAA=1,NUMAAT
         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.ISATOK(IAT)) GOTO 90
            TMP(1)=XCOORD(IAT)
            TMP(2)=YCOORD(IAT)
            TMP(3)=ZCOORD(IAT)
            IRED=1.0
            DO 80 ISYM=2,NUMSYM
               CALL GVSCPR (TRF,TMP,3)
               CALL GVSMPV (TRF,SYMMAT(1,1,ISYM),SYMVEC(1,ISYM))
               D=VECDIF(TMP,TRF)
               IF (D.LT.0.01*FLOAT(WIFPAR(1258))) IRED=IRED+1.0
  80        CONTINUE
            IF (IRED.GE.1.5) THEN
               IF (WEIGHT(IAT).GT.1.0/IRED) THEN
                  IF (WIFPAR(279).NE.0) THEN
                     ATTVAL(IAT)=1.0
                     CALL PDBC92 (IAA,IAT)
                  ELSE
                     CALL DIF015A (IAT,'?ATAXTXT')
                  END IF
               END IF
            END IF
  90     CONTINUE
 100  CONTINUE



      CALL CDB012



  998 CONTINUE


      RETURN
      END
      SUBROUTINE SC1012A



















      IMPLICIT      NONE

      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INCLUDE       'SYMINC.INC'
      INTEGER       IAT, IAA, ISYM, IERR
      REAL          TMP(3),TRF(3), VECDIF, D
      LOGICAL       WIFITW
      CHARACTER*28  IATS







      IF (.NOT.SYMHAS) THEN
         CALL PDBMES ('AXAMIS')
         GOTO 998
      END IF
      CALL SYMIPG (IERR,' ')
      IF (IERR.NE.0) THEN
         CALL PDBMES ('AXAIMP')
         GOTO 998
      END IF



      IF (NUMSYM.LT.2) GOTO 998



      



      CALL CDB013 ('AXANOK','AXANEU','AXAOK')
      CALL CDB014 (1,'SYM-AXIS','POOR')



      DO 100 IAA=1,NUMAAT
         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (.NOT.ISATOK(IAT)) GOTO 90
            IF (WEIGHT(IAT).LE.0.5) GOTO 90
            TMP(1)=XCOORD(IAT)
            TMP(2)=YCOORD(IAT)
            TMP(3)=ZCOORD(IAT)
            DO 80 ISYM=2,NUMSYM
               CALL GVSCPR (TRF,TMP,3)
               CALL GVSMPV (TRF,SYMMAT(1,1,ISYM),SYMVEC(1,ISYM))
               D=VECDIF(TMP, TRF)
               IF (D.LT.1.54) THEN
                  IF (D.GT.0.005.OR..NOT.WIFITW(IAT)) THEN
                     CALL PDBC92A (IAA,IAT)
                     CALL GVSSTX (IATS,LINE92(1:28))
                     CALL GVSCTB (LINE92,92)
                     WRITE (LINE92,PDBFMT,ERR=999) IATS,ISYM
                     CALL PDBC93 (LINE92)
                     FULTRG=.TRUE.
                     IF (WIFPAR(1257).GE.1) THEN
                        ATCOLR(IAT)=300
                        CALL GRTCRS (XCOORD(IAT),YCOORD(IAT),
     +                   ZCOORD(IAT),0.4,300,IERR)
                     END IF
                     GOTO 90
                  END IF
               END IF
 80         CONTINUE
 90      CONTINUE
 100  CONTINUE



      CALL CDB012
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('SC1012A')



  998 CONTINUE



      RETURN
      END
      SUBROUTINE SC1013

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA
      LOGICAL       WIFIRNO







      CALL CDB013 ('MA20BAD',' ','MA20OK')



      CALL GVSRT0 (PRPVAL,NUMAAT)



      DO 100 IAA=NUMAAF,2,-1



         IF (.NOT.WIFIRNO(IAA)) GOTO 100



         IF (WIFPAR(279).NE.0) THEN
            CALL PDBC92 (IAA,0)
         ELSE
            CALL DIF008 ('?MA20TXT',IAA)
         END IF



         SOUADM(11,CHAINN(2,IAA-1))=1
         CALL MOL105 (IAA)
         PRPVAL(IAA-1)=1.0
 100  CONTINUE



      IF (WIFPAR(279).NE.0) CALL CDB012
      GOTO 998



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1014

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'RESULT.INC'
      INTEGER       IAA, IAT, BCNT
      LOGICAL       WIFIRA, WIFIRNO, WIFIR3, WIFIRC







      CALL CDB013 ('BBCBAD','BBCNEU','BBCOK')



      GENIVL(15)=0



      DO 100 IAA=1,NUMAAF
         IF (PRPVAL(IAA).GT.0.5) GOTO 100
         IF (.NOT.WIFIRA(IAA)) GOTO 100
         IF (WIFIRNO(IAA).AND.WIFIR3(IAA)) GOTO 100
         IF (WIFIRC(IAA)) THEN
            GENIVL(15)=GENIVL(15)+1
            GOTO 100
         END IF
         DO 90 IAT=PNTAAS(IAA),PNTAAS(IAA)+3
            IF (.NOT.ISATOK(IAT)) THEN
               BCNT=BCNT+1
               IF (WIFPAR(279).NE.0) THEN
                  PRPVAL(IAA)=1
                  CALL PDBC92 (IAA,0)
               END IF
               CALL DIF008 ('?BBCTXT',IAA)
               GOTO 100
            END IF
 90      CONTINUE
 100  CONTINUE



      CALL CDB012





      RETURN
      END   
      SUBROUTINE SC1015

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAT, JAT, IAA, IERR, IEND
      REAL          PREFDST, SIGIJ, WIFDST, OLDW
      LOGICAL       GVFRIN, WIFIRA, WIFIRO, WIFIRNO, WIFIR3, XYZNUL,
     +              WIFIRW, WIFIRM







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



      CALL CDB013 ('MA21BAD',' ','MA21OK')



      IERR=0



      DO 100 IAA=1,NUMAAT
         IF (WIFIRW(IAA).OR.WIFIRM(IAA)) GOTO 100





         IEND=PNTAAS(IAA)+3
         IF (WIFPAR(1070).NE.0) IEND=PNTAAE(IAA)
         IF (WIFPAR(1070).EQ.0.AND.WIFIRNO(IAA).AND.WIFIR3(IAA))GOTO 100
         IF (WIFIRA(IAA)) THEN



            DO 90 IAT=PNTAAS(IAA),IEND
               IF (PROTON(IAT)) GOTO 90
               IF (WEIGHT(IAT).LT.0.03) THEN
                  DO 80 JAT=PNTAAS(IAA),PNTAAE(IAA)


                     IF (IAT.EQ.JAT) GOTO 80
                     IF (XYZNUL(IAT).AND.XYZNUL(JAT)) GOTO 90
                     IF (.NOT.ISATOK(JAT)) GOTO 80
                     IF (PROTON(JAT)) GOTO 80
                     CALL REFPREFDIST (IAT,JAT,IERR,PREFDST,SIGIJ)


                     IF (IERR.NE.0) GOTO 80
                     IF (.NOT.GVFRIN(WIFDST(IAT,JAT),
     +                PREFDST-3.0*SIGIJ,PREFDST+3.0*SIGIJ)) GOTO 90

 80               CONTINUE





                  WEIGHT(IAT)=1.0
                  ISATOK(IAT)=.TRUE.
                  XBFACT(IAT)=12.0
                  CALL MOL201 (IAA)
                  IF (WIFPAR(279).NE.0) THEN
                     CALL PDBC92A (IAA,IAT)
                     CALL PDBC93 (LINE92)
                  ELSE
                     CALL DIF015A (IAT,'?MA21TXT')
                  END IF
               END IF
 90         CONTINUE



         ELSE IF (WIFIRO(IAA)) THEN


            IAT=PNTAAS(IAA)
            IF (WEIGHT(IAT).LT.0.03) THEN
               OLDW=WEIGHT(IAT)
               WEIGHT(IAT)=1.0
               VDWRAD(IAT)=1.4
               ISATOK(IAT)=.TRUE.
               XBFACT(IAT)=12.0
               CALL DRG106 (IERR)
               CALL MOL004A (CHAINN(2,IAA))
               CALL DRG107 (IERR)
               CALL MOL200
               JAT=BOUND_TO(1,IAT)
               WEIGHT(IAT)=OLDW
               ISATOK(IAT)=.FALSE.
               IF (JAT.GT.0) THEN
                  IF (GVFRIN(WIFDST(IAT,JAT),1.171,1.291)) THEN
                     WEIGHT(IAT)=1.0
                     ISATOK(IAT)=.TRUE.
                     IF (WIFPAR(279).NE.0) THEN
                        CALL PDBC92A (IAA,IAT)
                        CALL PDBC93 (LINE92)
                     ELSE
                        CALL DIF015A (IAT,'?MA21TXT')
                     END IF
                  END IF
               END IF
            END IF
         END IF
 100  CONTINUE



      CALL CDB012




  998 CONTINUE


      RETURN
      END
      SUBROUTINE SC1015A

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAT, JAT, IAA, IERR, ISTART
      REAL          PREFDST, SIGIJ, WIFDST, OLDW
      LOGICAL       GVFRIN, WIFIRA, WIFIRO, XYZNUL







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



      CALL CDB013 ('MA21BADS',' ','MA21OKS')



      IERR=0
      CALL GVSRT0 (PRPVAL,NUMAAT)



      DO 100 IAA=1,NUMAAT





         ISTART=PNTAAS(IAA)+4
         IF (ISTART.GT.PNTAAE(IAA)) GOTO 100
         IF (WIFIRA(IAA)) THEN



            DO 90 IAT=ISTART,PNTAAE(IAA)
               IF (PROTON(IAT)) GOTO 90
               IF (WEIGHT(IAT).LT.0.03) THEN
                  DO 80 JAT=PNTAAS(IAA),PNTAAE(IAA)


                     IF (IAT.EQ.JAT) GOTO 80
                     IF (XYZNUL(IAT).AND.XYZNUL(JAT)) GOTO 90
                     IF (.NOT.ISATOK(JAT)) GOTO 80
                     IF (PROTON(JAT)) GOTO 80
                     CALL REFPREFDIST (IAT,JAT,IERR,PREFDST,SIGIJ)
                     PRINT*,ONESAT(IAT),'  ',ONESAT(JAT),
     +                WIFDST(IAT,JAT),PREFDST
                     IF (IERR.NE.0) GOTO 80
                     IF (.NOT.GVFRIN(WIFDST(IAT,JAT),
     +                PREFDST-3.0*SIGIJ,PREFDST+3.0*SIGIJ)) GOTO 90

 80               CONTINUE





                  WEIGHT(IAT)=1.0
                  ISATOK(IAT)=.TRUE.
                  XBFACT(IAT)=12.0
                  CALL MOL201 (IAA)
                  PRPVAL(IAA)=1.0
                  IF (WIFPAR(279).NE.0) THEN
                     CALL PDBC92A (IAA,IAT)
                     CALL PDBC93 (LINE92)
                  ELSE
                     CALL DIF015A (IAT,'?MA21TXT')
                  END IF
               END IF
 90         CONTINUE



         ELSE IF (WIFIRO(IAA)) THEN
            IAT=PNTAAS(IAA)
            IF (WEIGHT(IAT).LT.0.03) THEN
               OLDW=WEIGHT(IAT)
               WEIGHT(IAT)=1.0
               VDWRAD(IAT)=1.4
               ISATOK(IAT)=.TRUE.
               XBFACT(IAT)=12.0
               CALL DRG106 (IERR)
               CALL MOL004A (CHAINN(2,IAA))
               CALL DRG107 (IERR)
               CALL MOL200
               JAT=BOUND_TO(1,IAT)
               WEIGHT(IAT)=OLDW
               ISATOK(IAT)=.FALSE.
               IF (JAT.GT.0) THEN
                  IF (GVFRIN(WIFDST(IAT,JAT),1.171,1.291)) THEN
                     PRPVAL(ATIAA(JAT))=1.0
                     WEIGHT(IAT)=1.0
                     ISATOK(IAT)=.TRUE.
                     IF (WIFPAR(279).NE.0) THEN
                        CALL PDBC92A (IAA,IAT)
                        CALL PDBC93 (LINE92)
                     ELSE
                        CALL DIF015A (IAT,'?MA21TXT')
                     END IF
                  END IF
               END IF
            END IF
         END IF
 100  CONTINUE



      CALL CDB012



  998 CONTINUE


      RETURN
      END
      SUBROUTINE SC1016 (NNCNT)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, NNCNT
      LOGICAL       HASBB, POLY, LIKELY, VERY, WIFIRP, HASPROTEIN







      NNCNT=0
      IF (NUMAAF.GE.NUMAAT) GOTO 998
      IF (.NOT.HASPROTEIN()) THEN
         CALL PDBMES ('NOAAFND')
         GOTO 998
      END IF



      CALL CDB013 ('NOCABAD',' ','NOCAOK')



      CALL GVSRT0 (PRPVAL,NUMAAT)



      DO 100 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)
         IF ((SOUADM(5,ISOUP).NE.2.AND.SOUADM(5,ISOUP).NE.6).OR.
     +    WIFIRP(IAA)) GOTO 100



         CALL SC1017 (IAA,HASBB,POLY,LIKELY,VERY)



         IF (VERY) THEN
            IF (HASBB) THEN
               CALL GVSTT6 ('?M2240')
            ELSE
               CALL GVSTT6 ('?M2241')
            END IF
            IF (POLY) CALL GVSTT6 ('?M2242')
            CALL GVSTT6 ('?M2243')
            NNCNT=NNCNT+1
            IF (WIFPAR(279).NE.0) THEN
               CALL PDBC92 (IAA,0)
            ELSE
               CALL DIF008 ('?NOCATXT',IAA)
            END IF
            PRPVAL(IAA)=2



         ELSE IF (LIKELY) THEN
            CALL GVSTT6 ('?M2244')
            CALL GVSTT6 ('?M2245')
            NNCNT=NNCNT+1
            IF (WIFPAR(279).NE.0) THEN
               CALL PDBC92 (IAA,0)
            ELSE
               CALL DIF008 ('?NOCATXT',IAA)
            END IF
            PRPVAL(IAA)=1
         ELSE IF (POLY) THEN
            CALL GVSTT6 ('?M2242')
            CALL DIF008 ('?NOCATXT',IAA)
         END IF
 100  CONTINUE



      CALL CDB012



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1017 (IAA,HASBB,POLY,LIKELY,VERY)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, GVFCBT, IAA1, IAA2, JAT
      LOGICAL       BB(5), HASBB, POLY, LIKELY, VERY, T54EQUAL, WIFIRA







      CALL GVSBTF (BB,5)
      HASBB=.FALSE.
      POLY=.FALSE.
      LIKELY=.FALSE.
      VERY=.FALSE.



      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (T54EQUAL(ONESAT(IAT),' N  ')) BB(1)=.TRUE.
         IF (T54EQUAL(ONESAT(IAT),' CA ')) THEN
            BB(2)=.TRUE.
            IF (.NOT.ISATOK(IAT)) GOTO 998
         END IF
         IF (T54EQUAL(ONESAT(IAT),' C  ')) BB(3)=.TRUE.
         IF (T54EQUAL(ONESAT(IAT),' O  ')) BB(4)=.TRUE.
         IF (T54EQUAL(ONESAT(IAT),' CB ')) BB(5)=.TRUE.
 10   CONTINUE
      IF (GVFCBT(BB,5).EQ.5) HASBB=.TRUE.




      IAA1=0
      IAA2=0
      DO 20 IAT=PNTAAS(IAA),PNTAAE(IAA)
         JAT=BOUND_TO(1,IAT)
         IF (JAT.NE.0.AND.BOUND_TO(2,IAT).EQ.0) THEN
            IF (T54EQUAL(ONESAT(JAT),' N  ').OR.
     +         T54EQUAL(ONESAT(JAT),' CA ').OR.
     +         T54EQUAL(ONESAT(JAT),' C  ').OR.
     +         T54EQUAL(ONESAT(JAT),' O  ')) THEN
               IF (IAA1.EQ.0) THEN
                  IAA1=ATIAA(JAT)
               ELSE IF (IAA2.EQ.0) THEN
                  IF (ATIAA(JAT).NE.IAA1) THEN
                     IAA2=ATIAA(JAT)
                  END IF
               ELSE
                  POLY=.TRUE.
                  GOTO 21
               END IF
            END IF
         END IF
 20   CONTINUE
 21   CONTINUE



      IF (.NOT.POLY.AND.IAA2.NE.0) THEN
         IF (WIFIRA(IAA1).AND.WIFIRA(IAA2)) THEN
            LIKELY=.TRUE.
            IF (IAA2-IAA1.EQ.1.AND.CHANAM(IAA1).EQ.
     +          CHANAM(IAA2)) THEN
               VERY=.TRUE.
            END IF
         END IF
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1018

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INTEGER       IAA, IAT, JAA, JAT, CHRCNT(10), GVFFIP, IMAX, IERR,
     +              GVFIMX, IPOS, I, J, ILOOP, GVFIN0, IAT1, IAT2,
     +              JAT1, JAT2
      LOGICAL       WIFIRZ, WIFIRO, WIFIRH, IDONE, WIFIRF, WIFIRP, 
     +              WIFIRM, WIFIRA
      CHARACTER*1   OLDCHA(MAXAA), CHAR1A, CHAR1B(10)
      EQUIVALENCE   (OLDCHA,FUTURE)







      CALL CDB013 ('CBNDBAD','CBNDNEU','CBNDOK')





      CALL GVSRT0 (PRPVAL,NUMAAT)
      DO 10 IAA=1,NUMAAT
         OLDCHA(IAA)=CHANAM(IAA)
         IF (CHANAM(IAA).EQ.' ') CHANAM(IAA)='_'
 10   CONTINUE



      DO 20 IAA=NUMAAF,NUMAAT
         IF (WIFIRO(IAA)) THEN
            JAT=BOUND_TO(1,PNTAAS(IAA))



            IF (JAT.LE.0) THEN
               PRPVAL(IAA)=11.0
            ELSE
               JAA=ATIAA(JAT)



               IF (WIFIRA(JAA)) THEN
                  IF (CHANAM(IAA).NE.CHANAM(JAA)) THEN
                     PRPVAL(IAA)=1.0
                     CHANAM(IAA)=CHANAM(JAA)
                  END IF



               ELSE
                  PRPVAL(IAA)=10.0
               END IF
            END IF
         END IF
 20   CONTINUE



      DO 40 IAA=NUMAAF,NUMAAT
         IF (WIFIRH(IAA).OR.WIFIRP(IAA)) THEN
            CHAR1A=' '



            IF (PNTAAE(IAA).GT.PNTAAS(IAA)) THEN
               DO 32 IAT1=PNTAAS(IAA),PNTAAE(IAA)-1
                  JAT1=BOUND_TO(1,IAT1)
                  DO 30 IAT2=IAT1+1,PNTAAE(IAA)
                     JAT2=BOUND_TO(1,IAT2)
                     IF (JAT1.NE.JAT2) THEN
                        PRPVAL(IAA)=MAX(PRPVAL(IAA),9.0)
                        GOTO 40
                     END IF
 30               CONTINUE
 32            CONTINUE
            END IF



            DO 35 IAT=PNTAAS(IAA),PNTAAE(IAA)
               JAT=BOUND_TO(1,IAT)
               IF (JAT.EQ.0) THEN
                  PRPVAL(IAA)=MAX(PRPVAL(IAA),8.0)
                  GOTO 40
               END IF



               JAA=ATIAA(JAT)
               IF (CHANAM(IAA).NE.CHANAM(JAA)) THEN
                  PRPVAL(IAA)=1.0
                  CHANAM(IAA)=CHANAM(JAA)
                  GOTO 40
               END IF
 35         CONTINUE
         END IF
 40   CONTINUE




      DO 80 ILOOP=1,100
         IDONE=.FALSE.




         DO 70 IAA=1,NUMAAF
            IF ((WIFIRF(IAA).OR.WIFIRZ(IAA)).AND.PRPVAL(IAA).LT.0.5)THEN



               CALL GVSIT0 (CHRCNT,10)
               CALL GVSCTB (CHAR1B,10)
               DO 60 IAT=PNTAAS(IAA),PNTAAE(IAA)
                  JAT=BOUND_TO(1,IAT)
                  IF (JAT.GE.0) THEN
                     JAA=ATIAA(JAT)
                     DO 50 I=1,10
                        IF (CHANAM(JAA).EQ.CHAR1B(I)) THEN
                           CHRCNT(I)=CHRCNT(I)+1
                        ELSE IF (CHAR1B(I).EQ.' ') THEN
                           CHRCNT(I)=1
                           CHAR1B(I)=CHANAM(JAA)
                        END IF
 50                  CONTINUE
                  END IF
 60            CONTINUE



               IF (CHAR1B(1).NE.' ') THEN
                  IF (CHAR1B(10).NE.' ') THEN
                     PRPVAL(IAA)=11.0
                     GOTO 70



                  ELSE
                     IMAX=GVFIMX(CHRCNT,10)
                     IPOS=GVFFIP(CHRCNT,IMAX,10)
                     IF (CHANAM(JAA).NE.CHAR1B(IPOS)) THEN
                        PRPVAL(IAA)=MAX(FLOAT(GVFIN0(CHRCNT,10)),
     +                   PRPVAL(IAA))
                        CHANAM(IAA)=CHAR1B(IPOS)
                        IDONE=.TRUE.
                     END IF
                  END IF
               END IF
            END IF
 70      CONTINUE
         IF (.NOT.IDONE) GOTO 81
 80   CONTINUE
 81   CONTINUE



      DO 110 IAA=NUMAAF,NUMAAF
         IF (WIFIRM(IAA)) THEN



            CALL ENVTOT
            CALL SYMIPG (IERR,' ')
            CALL SYMNEA
            CALL FCONAT (PNTAAS(IAA),4.0)



            IF (NUMCONIAT.LE.0) THEN
               PRPVAL(IAA)=MAX(PRPVAL(IAA),11.0)



            ELSE
               CALL GVSIT0 (CHRCNT,10)
               CALL GVSCTB (CHAR1B,10)
               DO 100 J=1,NUMCONIAT
                  IF (CONDSTAT(J).LT.3.0) THEN
                     JAT=CONIAT(J)
                     JAA=ATIAA(JAT)
                     DO 90 I=1,10
                        IF (CHANAM(JAA).EQ.CHAR1B(I)) THEN
                           CHRCNT(I)=CHRCNT(I)+1
                        ELSE IF (CHAR1B(I).EQ.' ') THEN
                           CHRCNT(I)=1
                           CHAR1B(I)=CHANAM(JAA)
                        END IF
 90                  CONTINUE
                  END IF
 100           CONTINUE



               IF (CHAR1B(1).EQ.' ') THEN
                  PRPVAL(IAA)=MAX(PRPVAL(IAA),11.0)
                  GOTO 110



               ELSE
                  IF (CHAR1B(10).NE.' ') THEN
                     PRPVAL(IAA)=MAX(PRPVAL(IAA),10.0)
                     GOTO 110



                  ELSE
                     IMAX=GVFIMX(CHRCNT,10)
                     IPOS=GVFFIP(CHRCNT,IMAX,10)
                     IF (CHANAM(JAA).NE.CHAR1B(IPOS)) THEN
                        PRPVAL(IAA)=MAX(FLOAT(GVFIN0(CHRCNT,10)),
     +                   PRPVAL(IAA))
                        CHANAM(IAA)=CHAR1B(IPOS)
                     END IF
                  END IF
               END IF
            END IF
         END IF
 110  CONTINUE



      DO 120 IAA=1,NUMAAT
         IF(PRPVAL(IAA).GT.0.5) THEN
            CALL PDBC92 (IAA,0)
         END IF
 120  CONTINUE



      CALL CDB012



      DO 130 IAA=1,NUMAAT
         CHANAM(IAA)=OLDCHA(IAA)
 130  CONTINUE





      RETURN
      END
      SUBROUTINE SC1100 (IAA,ALTDIF,IERR)

















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







      ALTDIF=.FALSE.
      IERR=0



      IF (.NOT.HASALT(IAA)) GOTO 998





      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         IF (ALALAT(IAT).NE.' ') THEN
            IF (ALTATM(IAT).NE.' '.AND.ALALAT(IAT).EQ.' ') THEN
               ALTDIF=.TRUE.

               GOTO 998
            END IF
            IF (ALTATM(IAT).GT.ALALAT(IAT)) THEN
               ALTDIF=.TRUE.

               GOTO 998
            END IF
            IF (WEIGHT(IAT).LT.0.5.AND.ALTWGT(IAT).GT.0.5) THEN
               ALTDIF=.TRUE.

               GOTO 998
            END IF
            IF (WEIGHT(IAT)+0.2.LT.ALTWGT(IAT)) THEN
               ALTDIF=.TRUE.

               GOTO 998
            END IF
         END IF
 10   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE SC1101 (IAA,FACTOR)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT
      REAL          FACTOR, SCALE, WIFDST
      LOGICAL       WIFIRW, WIFIRA







      FACTOR=0.0
      IF (WIFIRW(IAA)) GOTO 998



      SCALE=1.0/FLOAT(PNTAAE(IAA)-PNTAAS(IAA)+1)



      DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
         FACTOR=FACTOR+SCALE*WEIGHT(IAT)-0.01*SCALE*XBFACT(IAT)
 10   CONTINUE



      IF (WIFIRA(IAA)) THEN
         IF (IAA.GE.2) THEN
            IF (WIFIRA(IAA-1)) THEN
               FACTOR=FACTOR-ABS(3.8-WIFDST(IAA-1,IAA))+1.0
            END IF
         END IF
         IF (IAA.LE.NUMAAF-1) THEN
            IF (WIFIRA(IAA+1)) THEN
               FACTOR=FACTOR-ABS(3.8-WIFDST(IAA+1,IAA))+1.0
            END IF
         END IF
      END IF







  998 CONTINUE


      RETURN
      END   
