      subroutine xy_met1 ! bernd berg, feb 13 2002.
c xy model: sequential metropolis updating. single angle variable.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      include 'lat.par'
      include 'mc.par'
      include '../../libs/fortran_par/common_lat.f'
      include '../../libs/fortran_par/common_xy1.f'
      amin=act
      amax=act
      do is=1,ms
        staold=sta(is)
        stanew=tpi*rmafun()
        dact=zero
        do id=1,nd
          staf=sta(ipf(id,is))
          dact=dact+cos(abs(staf-stanew))-cos(abs(staf-staold))
          stab=sta(ipb(id,is))
          dact=dact+cos(abs(stab-stanew))-cos(abs(stab-staold))
        end do
        if(dact.ge.zero .or. rmafun().lt.exp(beta*dact)) then
          act=act+dact
          acpt=acpt+one
          amin=min(amin,act)
          sta(is)=stanew
        end if
      end do
      a_min=min(a_min,amin)
      a_max=max(a_max,amax)
      return
      end
