C
C       Swendsen-Wang Monte Carlo update of the Ising model
C       (Swendsen and Wang, Phys. Rev. Lett. 58 (1987) 86).
C
C    Based on the code in the book "Monte Carlo Simulation in Statistical
C    Physics", eds. K Binder and D.W. Heermann (Springer-Verlag, 1988).
C
C       Paul Coddington, August 1992
C

	PROGRAM SWCLUSTER
	INCLUDE "common.h"
	INTEGER i,seed(2),start
	REAL p

C ----  Read in the parameters.
	CALL input(seed,start)
 
C ----  Initialize the random number generator.
	CALL rmarin(seed(1),seed(2))
 
C ----  Initialize the spins.
	CALL init_spins(start)
 
C ----  Initialize the data.
	CALL init_measure
 
C ----  Set up periodic boundary conditions.
	CALL neighbors

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,p)

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

	STOP
	END

