




C

C





















































C


C


C


























































































C



C

C










C


C




C


C


C


C


C



C



























C



C














C
      SUBROUTINE CDB001 (MODE)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       GVFFOP
      CHARACTER*3   MODE







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



      IF (MODE.EQ.'NEW') THEN
         CALL GVSCLF (59)
         CALL GVSDEL ('?M4650')
      END IF




      IF (.NOT.GVFFOP(59)) OPEN (59,FILE='check.db',STATUS='UNKNOWN',
     + ACCESS='APPEND')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB003 (IAA,VALUE)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, LMODNMB
      REAL          VALUE
      LOGICAL       GVFFOP, WIFIRN, WIFIRW
      CHARACTER*1   LCHANAM, LINSRTC
      CHARACTER*4   LONESA3, LNUMNAM







      IF (.NOT.GVFFOP(59)) GOTO 998



      CALL GVSSTX (LONESA3,ONESA3(IAA))
      CALL GVSSTX (LNUMNAM,NUMNAM(IAA))
      LCHANAM=CHANAM(IAA)
      LMODNMB=MODNMB(IAA)
      LINSRTC=INSRTC(IAA)



      IF (WIFIRN(IAA)) THEN
         CALL COMNUC (LONESA3)
      ELSE IF (WIFIRW(IAA)) THEN
         GOTO 998
      END IF
      IF (LCHANAM.EQ.' ') LCHANAM='_'
      IF (LINSRTC.EQ.' ') LINSRTC='_'



      IF (WIFPAR(430).EQ.0) THEN
         CALL GVSFMT ('?FMT294R')
         WRITE (59,FMT,ERR=999) LMODNMB,LCHANAM,LNUMNAM,LONESA3, 
     +    LINSRTC
      ELSE
         CALL GVSFMT ('?FMT288N')
         WRITE (59,FMT,ERR=999) LNUMNAM,LONESA3(1:3),MODNMB(IAA)
      END IF
      CALL GVSFMT ('?FMT289')
      WRITE (59,FMT,ERR=999) VALUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('CDB003')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB003A (IAA,TVAL,QUAL)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, LMODNMB
      LOGICAL       GVFFOP, WIFIRN, WIFIRW, ISERR
      CHARACTER*1   LCHANAM, LINSRTC
      CHARACTER*4   LONESA3, LNUMNAM
      CHARACTER*(*) TVAL,QUAL







      IF (.NOT.GVFFOP(59)) GOTO 998



      ISERR=.FALSE.



      CALL GVSSTX (LONESA3,ONESA3(IAA))
      CALL GVSSTX (LNUMNAM,NUMNAM(IAA))
      LCHANAM=CHANAM(IAA)
      LMODNMB=MODNMB(IAA)
      LINSRTC=INSRTC(IAA)



      IF (WIFIRN(IAA)) THEN
         CALL COMNUC (LONESA3)
      ELSE IF (WIFIRW(IAA)) THEN
         CALL GVSTTE ('?M4866')
         ISERR=.TRUE.
         GOTO 998
      END IF
      IF (LCHANAM.EQ.' ') LCHANAM='_'
      IF (LINSRTC.EQ.' ') LINSRTC='_'



      IF (WIFPAR(430).EQ.0) THEN
         CALL GVSFMT ('?FMT294R')
         WRITE (59,FMT,ERR=999) LMODNMB,LCHANAM,LNUMNAM,LONESA3, 
     +    LINSRTC
         IF (ISERR) WRITE (6,FMT,ERR=999) LMODNMB,LCHANAM,LNUMNAM,
     +    LONESA3,LINSRTC
      ELSE
         CALL GVSFMT ('?FMT288N')
         WRITE (59,FMT,ERR=999) LNUMNAM,LONESA3(1:3),LMODNMB
         IF (ISERR) WRITE (6,FMT,ERR=999) LNUMNAM,LONESA3(1:3),LMODNMB
      END IF
      CALL GVSFMT ('?FMT290')
      WRITE (59,FMT,ERR=999) TVAL,QUAL
      IF (ISERR) WRITE (6,FMT,ERR=999) TVAL,QUAL
      GOTO 998



  999 CONTINUE
      CALL GVSTTB ('?M0197')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB004 (VALUE)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFLEN
      REAL          VALUE
      LOGICAL       GVFFOP







      IF (.NOT.GVFFOP(59)) GOTO 998



      CALL GVSFMT ('?FMT291')
      WRITE (59,FMT,ERR=999) FILNMS(91)(1:GVFLEN(FILNMS(91))),VALUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('CDB004')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB004A (VALUE,QUAL)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFLEN
      CHARACTER*(*) VALUE, QUAL
      LOGICAL       GVFFOP







      IF (.NOT.GVFFOP(59)) GOTO 998



      CALL GVSFMT ('?FMT292')
      WRITE (59,FMT,ERR=999) FILNMS(91)(1:GVFLEN(FILNMS(91))),VALUE,QUAL
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('CDB004A')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB005 (IAT,VALUE)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, LMODNMB
      REAL          VALUE
      LOGICAL       GVFFOP, WIFIRN, WIFIRW
      CHARACTER*1   LCHANAM, LALTATM, LINSRTC
      CHARACTER*4   LONESA3, T4, CHAR4, LNUMNAM







      IF (.NOT.GVFFOP(59)) GOTO 998



      IAA=ATIAA(IAT)



      CALL GVSSTX (LONESA3,ONESA3(IAA))
      CALL GVSSTX (LNUMNAM,NUMNAM(IAA))
      LCHANAM=CHANAM(IAA)
      CHAR4=T4(ONESAT(IAT))
      LMODNMB=MODNMB(IAA)
      LALTATM=ALTATM(IAT)
      LINSRTC=INSRTC(IAA)



      IF (WIFIRN(IAA)) THEN
         CALL COMNUC (LONESA3)
      ELSE IF (WIFIRW(IAA)) THEN
         CALL GVSSTX (LNUMNAM,ORGNAM(IAT))
      END IF
      IF (LCHANAM.EQ.' ') LCHANAM='_'
      IF (LALTATM.EQ.' ') LALTATM='_'
      IF (LINSRTC.EQ.' ') LINSRTC='_'



      IF (WIFPAR(430).EQ.0) THEN
         CALL GVSFMT ('?FMT294U')
         WRITE (59,FMT,ERR=999) LMODNMB,LCHANAM,LNUMNAM,LONESA3, 
     +    LINSRTC,CHAR4,LALTATM
      ELSE
         CALL GVSFMT ('?FMT294N')
         WRITE (59,FMT,ERR=999) LCHANAM,LNUMNAM,LONESA3(1:3), 
     +    CHAR4,LMODNMB
      END IF
      CALL GVSFMT ('?FMT289')
      WRITE (59,FMT,ERR=999) VALUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('CDB005')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB005A (IAT,TVAL,QUAL)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT, LMODNMB
      LOGICAL       GVFFOP, WIFIRW, WIFIRN
      CHARACTER*1   LCHANAM, LALTATM, LINSRTC
      CHARACTER*4   CHAR4, LONESA3, T4, LNUMNAM
      CHARACTER*(*) TVAL, QUAL







      IF (.NOT.GVFFOP(59)) GOTO 998



      IAA=ATIAA(IAT)



      CALL GVSSTX (LONESA3,ONESA3(IAA))
      CALL GVSSTX (LNUMNAM,NUMNAM(IAA))
      LCHANAM=CHANAM(IAA)
      CHAR4=T4(ONESAT(IAT))
      LMODNMB=MODNMB(IAA)
      LALTATM=ALTATM(IAT)
      LINSRTC=INSRTC(IAA)



      IF (WIFIRN(IAA)) THEN
         CALL COMNUC (LONESA3)
      ELSE IF (WIFIRW(IAA)) THEN
         CALL GVSSTX (LNUMNAM,ORGNAM(IAT))
      END IF
      IF (LCHANAM.EQ.' ') LCHANAM='_'
      IF (LALTATM.EQ.' ') LALTATM='_'
      IF (LINSRTC.EQ.' ') LINSRTC='_'



      IF (WIFPAR(430).EQ.0) THEN
         CALL GVSFMT ('?FMT294U')
         WRITE (59,FMT,ERR=999) LMODNMB,LCHANAM,LNUMNAM,LONESA3, 
     +    LINSRTC,CHAR4,LALTATM
      ELSE
         CALL GVSFMT ('?FMT294N')
         WRITE (59,FMT,ERR=999) LCHANAM,LNUMNAM,LONESA3(1:3), 
     +    CHAR4,LMODNMB
      END IF
      CALL GVSFMT ('?FMT290')
      WRITE (59,FMT,ERR=999) TVAL,QUAL
      GOTO 998



  999 CONTINUE
      CALL GVSTTB ('?M0197')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB012



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IERR, GVFLEN, I, NLINES, ICHAP, IAA, ISTR, IAT, L
      REAL          POOR, BAD
      LOGICAL       GVFFOP, BADGT
      CHARACTER*80  BUF(60)
      CHARACTER*10  LEVEL, TYPE, LOC1, DATESTR, OPTION
      CHARACTER*13  VERSION, GETVERSION







      IF (WIFPAR(1296).NE.0.OR.WIFPAR(318).NE.0) GOTO 997



      IF (WIFPAR(279).LE.0) GOTO 997



      CALL CGETTEXT (PDBERR,GVFLEN(PDBERR),BUF,NLINES,60)



      IF (INDEX(BUF(2),'ERRLNS').EQ.0) THEN
         CALL GVSTTB ('?M1051')
         GOTO 997
      END IF
      IF (NLINES.LT.7) THEN
         CALL GVSTTB ('?M1002')
         CALL GVST6C ('?M1599',PDBERR(2:),.TRUE.)
         GOTO 997
      END IF



      IF (GVFLEN(PDBGOO).NE.1.AND.GVFLEN(PDBERR).NE.1) THEN
         CALL PDBTND (IERR)
         IF (IERR.EQ.0) THEN
            CALL PDBMES (PDBERR(2:))
         ELSE
            CALL PDBMES (PDBGOO(2:))
         END IF
      END IF



      IF (GVFLEN(PDBNEU).EQ.1) GOTO 997



      CALL CDB100 (ICHAP,POOR,BAD,BADGT,TYPE,LEVEL,OPTION,BUF(4),IERR)
      IF (IERR.NE.0) GOTO 997



      IF (.NOT.GVFFOP(59)) CALL CDB001 ('OLD')



      IF (GVFFOP(59)) THEN
         CALL GVSTTU (59,'?M3300')
         L=GVFLEN(FILNMS(62))
         CALL GVSFMT ('?FMT367')
         WRITE (59,FMT,ERR=999) FILNMS(91)(1:MAX(1,L))
         CALL GVSFMT ('?FMT368')
         WRITE (59,FMT,ERR=999) OPTION(1:GVFLEN(OPTION))
         CALL GVSFMT ('?FMT369')
         WRITE (59,FMT,ERR=999)

            VERSION=WCVERSION



         CALL GVSFMT ('?FMT370')
         WRITE (59,FMT,ERR=999) VERSION
         CALL GVSFMT ('?FMT371')
         IF (GVFLEN(BUF(4)).GT.0) WRITE (59,FMT,ERR=999)
     +    BUF(4)(1:GVFLEN(BUF(4)))
         IF (ICHAP.GT.0) THEN
            CALL GVSFMT ('?FMT573')
            WRITE (59,FMT,ERR=999) ICHAP
         ELSE
            CALL GVSFMT ('?FMT372')
            WRITE (59,FMT,ERR=999)
         END IF

            LOC1=DATESTR()
            CALL GVSFMT ('?FMT373')
            WRITE (59,FMT,ERR=999) LOC1

         CALL GVSFMT ('?FMT374')
         WRITE (59,FMT,ERR=999) LEVEL



         CALL CGETTEXT (PDBNEU,GVFLEN(PDBNEU),BUF,NLINES,60)



         IF (INDEX(BUF(2),'ERRLNS').NE.0) THEN
            CALL GVSTTB ('?M1052')
            GOTO 997
         END IF
         IF (NLINES.LT.4) THEN
            CALL GVSTTB ('?M1002')
            CALL GVST6C ('?M1599',PDBNEU(2:),.TRUE.)
         END IF



         DO 20 I=4,NLINES
            L=GVFLEN(BUF(I))
            CALL GVSFMT ('?FMT375')
            WRITE (59,FMT,ERR=999) BUF(I)(1:MAX(1,L))
 20      CONTINUE
         CALL GVSFMT ('?FMT376')
         WRITE (59,FMT,ERR=999) TYPE
         IF (TYPE.NE.'TEXT') THEN
            IF (BADGT) THEN
               CALL GVSFMT ('?FMT377')
               WRITE (59,FMT,ERR=999) POOR
               CALL GVSFMT ('?FMT378')
               WRITE (59,FMT,ERR=999) BAD
            ELSE
               CALL GVSFMT ('?FMT379')
               WRITE (59,FMT,ERR=999) POOR
               CALL GVSFMT ('?FMT380')
               WRITE (59,FMT,ERR=999) BAD
            END IF
         END IF
      END IF



      IF (TYPE.EQ.'TEXT') THEN
         IF (LEVEL.EQ.'RESIDUE') THEN
            DO 40 IAA=1,NUMAAT
               ISTR=NINT(PRPVAL(IAA))
               IF (ISTR.GT.0.AND.ISTR.LE.NUMCDBSTR)
     +          CALL CDB003A (IAA,CDBSTR(ISTR),CDBQUA(ISTR))
 40         CONTINUE
         ELSE IF (LEVEL.EQ.'ATOM') THEN
            DO 60 IAT=1,NUMATF
               ISTR=NINT(ATTVAL(IAT))
               IF (ISTR.GT.0.AND.ISTR.LE.NUMCDBSTR)
     +          CALL CDB005A (IAT,CDBSTR(ISTR),CDBQUA(ISTR))
 60         CONTINUE
         ELSE IF (LEVEL.EQ.'STRUCTURE') THEN
            ISTR=NINT(STRVAL(1))
            IF (ISTR.GT.0.AND.ISTR.LE.NUMCDBSTR)
     +       CALL CDB004A (CDBSTR(ISTR),CDBQUA(ISTR))
         END IF
      ELSE
         IF (LEVEL.EQ.'RESIDUE') THEN
            DO 30 IAA=1,NUMAAT
               IF (PRPVAL(IAA).GT.-99.0)
     +          CALL CDB003 (IAA,PRPVAL(IAA))
 30         CONTINUE
         ELSE IF (LEVEL.EQ.'ATOM') THEN
            DO 50 IAT=1,NUMATF
               IF (ATTVAL(IAT).GT.-99.0)
     +          CALL CDB005 (IAT,ATTVAL(IAT))
 50         CONTINUE
         ELSE IF (LEVEL.EQ.'STRUCTURE') THEN
            IF (STRVAL(1).GT.-99.0)
     +       CALL CDB004 (STRVAL(1))
         END IF
      END IF
      GOTO 997
 999  CONTINUE
      CALL GVSTTB ('?M1001')



  997 CONTINUE


      RETURN
      END
      SUBROUTINE CDB013 (ERROR,NEUTRAL,GOOD)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       NLINES, I, GVFLEN, ICHAP, IERR
      REAL          POOR, BAD
      LOGICAL       BADGT
      CHARACTER*(*) ERROR, NEUTRAL, GOOD
      CHARACTER*10  LEVEL, TYPE, OPTION
      CHARACTER*16  TCHMES
      CHARACTER*80  BUF(60)








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



      IF (NEUTRAL(1:1).EQ.'?'.OR.ERROR(1:1).EQ.'?'.OR.
     +    GOOD(1:1).EQ.'?') THEN
         CALL GVSTTB ('?M0102')
         CALL GVSTT6 (NEUTRAL)
         CALL GVSTT6 (ERROR)
         CALL GVSTT6 (GOOD)
         GOTO 998
      END IF



      NUMCDBSTR=0
      CALL GVSCTB (CDBSTR,10*MAXCDBSTR)
      CALL GVSCTB (PDBERR,11)
      CALL GVSCTB (PDBNEU,11)
      CALL GVSCTB (PDBGOO,11)
      CALL GVSCTB (TCHMES,16)
      TCHMES(1:1)='?'
      TCHMES(2:2)='H'
      TCHMES(3:3)='_'
      DO 5 I=1,MIN(LEN(ERROR),13)
         TCHMES(I+3:I+3)=ERROR(I:I)
 5    CONTINUE



      PDBNEU(1:1)='?'
      DO 10 I=1,GVFLEN(NEUTRAL)
         PDBNEU(I+1:I+1)=NEUTRAL(I:I)
 10   CONTINUE
      PDBERR(1:1)='?'
      DO 11 I=1,GVFLEN(ERROR)
         PDBERR(I+1:I+1)=ERROR(I:I)
 11   CONTINUE
      PDBGOO(1:1)='?'
      DO 12 I=1,GVFLEN(GOOD)
         PDBGOO(I+1:I+1)=GOOD(I:I)
 12   CONTINUE



      CALL CGETTEXT (PDBERR,GVFLEN(PDBERR),BUF,NLINES,60)









      IF (INDEX(BUF(2),'ERRLNS').EQ.0) THEN
         CALL GVSTTB ('?M1053')
         GOTO 998
      END IF
      IF (NLINES.LT.7) THEN
         CALL GVSTTB ('?M1002')
         CALL GVST6C ('?M1599',PDBERR(2:),.TRUE.)
      END IF



      CALL CDB100 (ICHAP,POOR,BAD,BADGT,TYPE,LEVEL,OPTION,BUF(4),IERR)
      IF (IERR.NE.0) GOTO 998



      IF (GVFLEN(PDBGOO).NE.1.AND.GVFLEN(PDBERR).NE.1) THEN
         CALL PDBTAB (BUF(5))
      END IF



      CALL GVSSTX (PDBFMT,BUF(6))










      IF (WIFPAR(437).EQ.0) CALL PDBTCH (TCHMES)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE CDB014 (I,STR,QUA)



















      IMPLICIT      NONE
      INCLUDE       'PDBINC.INC'
      INTEGER       I
      CHARACTER*(*) STR,QUA





      IF (I.EQ.1.OR.I.EQ.NUMCDBSTR+1) THEN
         NUMCDBSTR=I
         CALL GVSSTX (CDBSTR(I),STR)
         CALL GVSSTX (CDBQUA(I),QUA)
      ELSE
         CALL GVSTTB ('?M1055')
      END IF





      RETURN
      END
      SUBROUTINE CDB100 (ICHAP,POOR,BAD,BADGT,TYPE,LEVEL,OPTION,BUF,
     + IERR)



















      IMPLICIT      NONE 
      INTEGER       ICHAP, GVFLEN, IERR
      REAL          POOR, BAD
      CHARACTER*(*) LEVEL, OPTION, TYPE, BUF
      LOGICAL       BADGT
      CHARACTER*80  WORD








      CALL SPLITLINE (BUF,WORD,BUF)
      IF (GVFLEN(WORD).EQ.0) THEN
         ICHAP=0
      ELSE
         READ (WORD,'(I9)',ERR=999) ICHAP
      END IF




      CALL SPLITLINE (BUF,WORD,BUF)
      IF (GVFLEN(WORD).EQ.0) THEN
         POOR=0
      ELSE
         READ (WORD,'(F9.0)',ERR=999) POOR
      END IF




      CALL SPLITLINE (BUF,WORD,BUF)
      IF (GVFLEN(WORD).EQ.0) THEN
         BAD=0
      ELSE
         READ (WORD,'(F9.0)',ERR=999) BAD
      END IF



      IF (POOR.LT.BAD) THEN
         BADGT=.TRUE.
      ELSE
         BADGT=.FALSE.
      END IF



      IF (ABS(BAD).LT.0.00001.AND.ABS(POOR).LT.0.00001) THEN
         TYPE='TEXT'
      ELSE
         TYPE='FLOAT'
      END IF



      CALL SPLITLINE (BUF,WORD,BUF)
      IF (GVFLEN(WORD).EQ.0) THEN
         CALL GVSSTX (LEVEL,'RESIDUE')
      ELSE
         CALL GVSSTX (LEVEL,WORD)
      END IF




      CALL SPLITLINE (BUF,WORD,BUF)
      IF (GVFLEN(WORD).EQ.0) THEN
         CALL GVSSTX (OPTION,'UNKNOWN')
      ELSE
         CALL GVSSTX (OPTION,WORD)
      END IF
      IERR=0

      GOTO 998



 999  CONTINUE
      CALL GVSTTB ('?M1056')
      IERR=1



  998 CONTINUE


      RETURN
      END

      SUBROUTINE CDBEND























      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       GVFFOP







      IF (GVFFOP(59)) THEN
         CALL GVSFMT ('?FMT276')
         WRITE (59,FMT,ERR=999)




         CALL GVSCLF (59)
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('CDBEND')



  998 CONTINUE


      RETURN
      END
