      subroutine read_steb0(nrpt,iud,norm,nlink,ha,ham,hae,actl)
c bernd berg jan 21 2002.
c reads nrpt times the array ha() from unit iud and calculates the
c       histogram mean values ham() and their error bars hae().
c further, the nrpt action variable averages are calculated.
c norm=0:  no normalization of the ha histogram, otherwise normalization.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      dimension ha(0:nlink),ham(0:nlink),hae(0:nlink),actl(nrpt)
c
      call razero(ham,izero,nlink)
      factor=one
      do irpt=1,nrpt
        read(iud) ha
	if(norm.ne.0) then ! normalization of ha() to hasum=nlink.
          hasum=zero
          do ilink=0,nlink
            hasum=hasum+ha(ilink)
          end do
          factor=nlink/hasum
          do ilink=0,nlink ! normalization of ha() to hasum=nlink.
            ha(ilink)=factor*ha(ilink)
          end do
        end if
        actl(irpt)=potts_actl(nlink,ha) ! mean action variable.
        do ilink=0,nlink
          ham(ilink)=ham(ilink)+ha(ilink)
        end do
      end do
      do ilink=0,nlink
        ham(ilink)=ham(ilink)/nrpt
      end do
c
      do irpt=1,nrpt
        backspace iud
      end do
c
      call razero(hae,izero,nlink)
      do irpt=1,nrpt
        read(iud) ha
        do ilink=0,nlink
          hae(ilink)=hae(ilink)+(factor*ha(ilink)-ham(ilink))**2
        end do
      end do
      do ilink=0,nlink
        hae(ilink)=sqrt(hae(ilink)/(nrpt*(nrpt-1)))
      end do
c
      return
      end
