      subroutine su3_init ! Alexei Bazavov / Bernd Berg Mar 6 2008.
C Initializes arrays needed for SU3 MCMC and Cabibbo-Marinari heatbath.
      include '../../Libs/Fortran/implicit.sta'
      character cd*1,clx*3,clt*3
      include '../../Libs/Fortran/constants.par'
      include '../../Libs/Fortran_par/lat.par'
      include '../../Libs/Fortran_par/mc.par'
      include '../../Libs/Fortran_par/common_lat.f'
      include '../../Libs/SU3_par/common_su3.f'
      dimension ix(nd)
C
C Prepare file name:
      write(cd,'(I1.1)') nd
      write(clx,'(I3.3)') nla(1)
      write(clt,'(I3.3)') nla(nd)
      write(cfile,'(A,"d",A,"x",A,"t")') cd,clx,clt
      write(iuo,'(1X,"Filename: ",2A,".D")') cfln,cfile
C Initialize:
      acpt=zero       ! Acceptance rate.
      a_min=one*mlink 
      a_max=zero
      call lat_init(ms,nd,ipf,ipb,nla,ix) ! Lattice.
      call rmaset(iuo,iud1,iseed1,iseed2,"nonexist")
      call ranmar(xr) ! Read first random number.
C
      write(iuo,'(/," su3_init: ")')
      write(iuo,'(3x,"Initial random number: xr =",1F12.6)') xr
      write(iuo,'(3X,"lat.par: nd,nla   =",1I2,3X,8I4)') nd,nla
      write(iuo,'(8X,"ms,mlink,mxs      =",3I10)') ms,mlink,np
      write(iuo,'(8X,"np,npspace,nptime =",3I10)') npspace,nptime
      write(iuo,'(3X,"mc.par:")')
      write(iuo,'(5X,"iuo,iud1,iseed1,iseed2,    beta")')
      write(iuo,'(3X,2I4,2I7,1F11.6)') iuo,iud1,iseed1,iseed2,beta
      write(iuo,'(3X,"nequi,nrpt,nmeas:",3I12)') nequi,nrpt,nmeas
      if(istart.eq.1) then
        write(iuo,'(" Ordered start, istart =",I2)') istart
        call su3_order ! Ordered start.
      elseif(istart.eq.2) then
        write(iuo,'(" Disordered start, istart =",I2)') istart
        call su3_ran ! Disordered start.
      else
        write(iuo,'(" False istart =",I6)') istart
      stop "su3_init: istart false."
      endif
      call su3_act(act) ! Initial action.
      write(iuo,'(" Initial action act,act/np:",2G18.9,/)') act,(act/np)
      return
      end
