      subroutine xy_act1(sta,ipf,ns,nd,act) ! bernd berg feb 21 2002.
c calculates action value act of xy model (planar rotator). angle stored.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      dimension sta(ns),ipf(nd,ns)
      act=zero
      do is=1,ns
        ph1=sta(is)
        do id=1,nd
          act=act+cos(abs(sta(ipf(id,is))-ph1))
        end do
      end do
      return
      end
