C----------------------------------------------------------------------C
C                                                                      C
C       Swendsen-Wang Monte Carlo update of the Ising model            C
C       (Swendsen and Wang, Phys. Rev. Lett. 58 (1987) 86).            C
C                                                                      C
C       Self-labeling (sequential local algorithm plus local           C
C       label propagation of edges between processors) is used         C
C       to do the parallel component labeling. See Clive Baillie       C
C       and Paul Coddington, Concurrency: Practice and Experience      C
C       3, 129 (1991).                                                 C
C                                                                      C
C       Paul Coddington, August 1992                                   C
C                                                                      C
C----------------------------------------------------------------------C

	PROGRAM SWcluster
        INCLUDE "common.h"
	INCLUDE "cluster.h"
	INTEGER i,seed,start

C ----  Initialize some Express stuff.
	CALL KXINIT

C ----  Read in the parameters.
	CALL input(seed,start)

C ----  Do domain decomposition of the lattice over the nodes.
	CALL decompose
 
C ----  Initialize the random number generator.
	CALL rand_init(seed)
 
C ----  Initialize the spins.
	CALL init_spins(start)
 
C ----  Initialize the data.
	CALL init_measure

C ----  Probability for connecting sites. 
	p = 1. - EXP(-2.*beta)
	WRITE(6,5) 'Swendsen-Wang probability is ',p
   5    FORMAT(A,F8.6)

C ----  Thermalize.
	CALL SWupdate(therm_sweeps)

C ----  Do the update, with a measurement every 'sweeps' iterations.
	DO i=1,measurements
	  CALL SWupdate(sweeps)
	  CALL measure
	ENDDO
 
C ----  Print out the results.
	CALL output

	STOP
	END

