      subroutine xy_init(lpr) ! bernd berg, feb 15 2002.
c initializes arrays needed for xy model metropolis calculations.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      parameter(n=2)
      include 'lat.par'
      include 'mc.par'
      include '../../libs/fortran_par/common_lat.f'
      include '../../libs/on_par/common_on.f'
      dimension ix(nd)
      ns=nsfun(nla,nd) ! consistency check.
      if(ns.gt.ms) stop "potts_init.f: ns.gt.ms."
c
c initialize:
      if(lpr) call rmaset(iuo,iud1,iseed1,iseed2,'nexiste.pa') ! ran-num
      if(.not.lpr) call rmaset(-iuo,iud1,iseed1,iseed2,'nexiste.pa') 
      call ranmar(xr)                            ! first random number.
      acpt=zero                                  ! acceptance rate.
      a_min=one*mlink
      a_max=zero
      call lat_init(ms,nd,ipf,ipb,nla,ix)        ! lattice.
      if(istart.eq.1) call xy_order(sta,ms,zero) ! ordered start.
      if(istart.eq.2) call xy_ran(sta,ms)        ! random start.
      if(istart.ne.1.and.istart.ne.2) stop "xy_init: istart false."
      call xy_act(sta,ipf,ms,nd,act)             ! xy action.
c
      if(.not.lpr) return
      write(iuo,'(" initial randon number: xr =",1f12.6)') xr
      write(iuo,'(" lat.par: nd,nla         =",1i2,3x,8i4)') nd,nla
      write(iuo,'("          ms,mlink =     =",2i10)') ms,mlink
      write(iuo,'(" mc.par:")')
      write(iuo,'(1x,"iuo,iud1,iseed1,iseed2,    beta")')
      write(iuo,'(        2i4,          2i7,     1f11.6)')
     &                      iuo,iud1,iseed1,iseed2,beta
      if(istart.eq.1) write(iuo,'(" ordered start istart=",i4)') istart
      if(istart.eq.2) write(iuo,'(" random start istart=",i4)') istart
      write(iuo,'(" initial action:  act =",g15.6)') act
      return
      end
