      subroutine calout (mcaaat, atomin, seqcod, aacod3, hetcod, seqlen,CALO001
     &                   chstop, chstrt, seqbcd, mcser,  mcocc,  mcthrm,CALO002
     &                   extdat, nline,  extres, nrec)                  CALO003
c     generates output file for c-alpha only files                      CALO004
c                                                                       CALO005
      include 'brkcln.par'                                              CALO006
c                                                                       CALO007
      real      mcaaat(ncoord,mnchna,maxres), mcocc(mnchna,maxres),     CALO008
     &          mcthrm(mnchna,maxres)                                   CALO009
c                                                                       CALO010
      character aacod3*(abetsz*3), hetcod*63, chstop(maxres)*1,         CALO011
     &          seqbcd(maxres)*6, wkres*3, chstrt(maxres)*1,            CALO012
     &          extdat(maxlin)*66                                       CALO013
c                                                                       CALO014
      logical   atomin(mnchna,maxres)                                   CALO015
c                                                                       CALO016
      integer   seqcod(maxres), seqlen, mcser(mnchna,maxres), nxres, i, CALO017
     &          aacod, nathet, ii, nline, extres(maxlin), istart, nrec  CALO018
c                                                                       CALO019
 6000 format (a6, i5, 1x, a4, 1x, a3, 1x, a6, 3x, 3f8.3, 2f6.2, 1x, a1, CALO020
     & a1)                                                              CALO021
 6005 format (a66)                                                      CALO022
WINNT - proper MASTER record writes mumber of atoms in col 51-55        CALO023
c 6006 format ('MASTER',i6)                                             CALO024
 6006 format ('MASTER',44x,i6)                                          CALO025
WINNT - end                                                             CALO026
 6007 format ('END')                                                    CALO027
 6100 format (' WARNING: Number of atoms/hetatms in new file differs',  CALO028
     & ' from old file - ',/,                                           CALO029
     & 10X, ' new number = ',I5,/,                                      CALO030
     & 10X, ' old number = ',I5)                                        CALO031
c                                                                       CALO032
      nathet = 0                                                        CALO033
      if (nline .gt. 0) then                                            CALO034
         do 50 ii = 1, nline                                            CALO035
         if (extres(ii) .eq. 0) then                                    CALO036
            write (outfi, 6005) extdat(ii)                              CALO037
            if (extdat(ii)(1:keylen) .eq. atmkey .or.                   CALO038
     &          extdat(ii)(1:keylen) .eq. htakey) nathet = nathet + 1   CALO039
         else                                                           CALO040
            if (extres(ii) .gt. 0) then                                 CALO041
               istart = ii                                              CALO042
               goto 51                                                  CALO043
            end if                                                      CALO044
         end if                                                         CALO045
   50    continue                                                       CALO046
      end if                                                            CALO047
   51 continue                                                          CALO048
      do 5000 nxres = 1, seqlen                                         CALO049
      if (seqcod(nxres) .le. abetsz) then                               CALO050
         wkres = aacod3((seqcod(nxres)*3)-2:seqcod(nxres)*3)            CALO051
      else                                                              CALO052
         wkres = hetcod(((seqcod(nxres)-abetsz)*3)-2:                   CALO053
     &                   (seqcod(nxres)-abetsz)*3)                      CALO054
      end if                                                            CALO055
      aacod = seqcod(nxres)                                             CALO056
      if (atomin(2,nxres)) then                                         CALO057
         write (outfi, 6000) 'ATOM  ', mcser(calph,nxres), ' CA ',      CALO058
     &                        wkres, seqbcd(nxres),                     CALO059
     &                       (mcaaat(i,calph,nxres), i=1,ncoord),       CALO060
     &                        mcocc(calph,nxres), mcthrm(calph,nxres),  CALO061
     &                        chstop(nxres), chstrt(nxres)              CALO062
         nathet = nathet + 1                                            CALO063
      end if                                                            CALO064
      if (nline .gt. 0) then                                            CALO065
         do 4500 ii = istart, nline                                     CALO066
         if (extres(ii) .eq. nxres) then                                CALO067
            write (outfi, 6005) extdat(ii)                              CALO068
            if (extdat(ii)(1:keylen) .eq. atmkey .or.                   CALO069
     &          extdat(ii)(1:keylen) .eq. htakey) nathet = nathet + 1   CALO070
         else                                                           CALO071
            if (extres(ii) .gt. nxres) then                             CALO072
               istart = ii                                              CALO073
               goto 4510                                                CALO074
            end if                                                      CALO075
         end if                                                         CALO076
 4500    continue                                                       CALO077
      end if                                                            CALO078
 4510 continue                                                          CALO079
 5000 continue                                                          CALO080
      write (outfi, 6006) nathet                                        CALO081
      if (nathet .ne. nrec) then                                        CALO082
CHECK v.2.1.3-->                                                        CALO083
C         write (logfi, 6100) nathet, nrec                              CALO084
         write (*, 6100) nathet, nrec                                   CALO085
CHECK v.2.1.3<--                                                        CALO086
CHECK v.1.0-->                                                          CALO087
C         write (*,     6100) nathet, nrec                              CALO088
CHECK v.1.0<--                                                          CALO089
      end if                                                            CALO090
      write (outfi, 6007)                                               CALO091
c     call msgprt                                                       CALO092
      end                                                               CALO093
