      subroutine scalar_act(phi,xmfactor,xla,ipf,ns,nd,
     &  sactnn,sact2,sact,phisum) ! Bernd Berg Feb 18 2012. 
C Action for scalar field configuration.
      include '../../Libs/Fortran/implicit.sta'
      include '../../Libs/Fortran/constants.par'
      dimension phi(ns),ipf(nd,ns)
      sactnn=zero
      sact2=zero
      phisum=zero
      do is=1,ns        
        phinn=zero
        do id=1,nd
          phinn=phinn+phi(ipf(id,is))
        enddo
        call sactphi1(actnn,aphi2,phinn,xmfactor,xla,phi(is))
        sactnn=sactnn+actnn
        sact2=sact2+aphi2
        phisum=phisum+phi(is)
      enddo
      sact=sactnn-sact2
      return
      end
