      SUBROUTINE MPCPOP(C,ICOK)
      implicit double precision (A-H,O-Z)
      include 'SIZES'
      include 'MOP6FILE'
C
C This subroutine calculates the total Mulliken populations on the
C   atoms by summing the diagonal elements from the  Mulliken
C   population analysis.
C
      common / MOLKST/ NUMAT,NAT(NUMATM),NFIRST(NUMATM),NMIDLE(NUMATM),
     1                NLAST(NUMATM), NORBS, NELECS,NALPHA,NBETA,
     2                NCLOSE,NOPEN,NDUMY,FRACT
      common /CORE/ CORE(107)
      dimension C(MORB2),POP(NUMATM),CHRG(NUMATM)
      write(MIOI,'(I4,5X,'' MULLIKEN POPULATION AND CHARGE'')',ERR=40)
     %       ICOK
C
C ICOK = 1 ==> PRINT POPULATIONS
C ICOK = 0 ==> KEYWORD mulliken = .f.
C         NO POPULATION ANALYSIS PERFORMED
C
      if (ICOK.NE.0) then
         do 20 I = 1,NUMAT
            IF = NFIRST(I)
            IL = NLAST(I)
            SUM = 0.0
            POP(I) = 0.0
            CHRG(I) = 0.0
            do 10 J = IF,IL
C
C    Diagonal element of mulliken matrix
C
               SUM = SUM + C((J*(J+1))/2)
   10       continue
            K = NAT(I)
C
C    Mulliken population for i'th atom
C
            POP(I) = SUM
            CHRG(I) = CORE(K) - POP(I)
   20    continue
         write(MIOB,'(///10X,''MULLIKEN POPULATIONS AND CHARGES'')')
         do 30 J = 1,NUMAT
            write(MIOB,60)     J, POP(J), CHRG(J)
            write(MIOI,70,ERR=40) POP(J), CHRG(J)
   30    continue
      end if
      return
   40 write(MIOB,'(A)') 'Error writing SYBYL Mulliken population output'
      return
   50 format(//,5X,'ATOM',8X,'POPULATION',6X,'CHARGE')
   60 format(5X,I4,4X,F11.6,6X,F11.6)
   70 format(2F12.6)
      end
