      subroutine potts_z0ln(nq,ns,nlink,namin,b,ha,hasum,zln_dif) 
c bernd berg, may 13 2002.
c potts model, normalization of the partition function z at beta0=0.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      dimension b(0:nlink),ha(0:nlink),hasum(0:nlink)
      data a/zero/, iact_old/0/ ! avoids compiler warning.
      ltest=.true.
      ltest=.false.
c
      iloop_ha=0 ! counts runs through the ha_iact.gt.half loop.
      beta0=zero
      z0ln=ns*log(one*nq)
      if(namin.le.0) stop "potts_z0ln: namin false."
      if(ltest) print*,"namin,iact_next =",namin,iact_next
      do iact=0,nlink
        ha_iact=hasum(iact)-ha(iact) ! jackknife histogram.
        if(ha_iact.gt.half) then
          iloop_ha=iloop_ha+1
          if(iloop_ha.eq.1) then
            a=-(beta0-b(iact))*namin ! ferdinand-fisher normalization.
            zln=log(ha_iact)+two*((beta0-b(iact))*iact+a)
          else
            a=a+(b(iact)-b(iact_old))*iact_old
            zln1=log(ha_iact)+two*((beta0-b(iact))*iact+a)
            zln=addln(zln,zln1)
          end if
          iact_old=iact
        end if
      end do
      zln_dif=z0ln-zln
      if(ltest) stop "potts_z0ln: ltest."
c
      return
      end
