
 
C  Read in the parameters for the simulation.
 
	SUBROUTINE input(seed,start)
	INCLUDE "common.h"
	INTEGER seed(2),start

  1     WRITE(6,50) 'Length of the lattice (must be <= ',MAX_SIDE,')? '
  50    FORMAT(A,I4,A)
	READ(5,*)  side
	WRITE(6,*) side
	IF ( (side.GT.MAX_SIDE).OR.(side.LT.1) ) THEN
	  WRITE(6,*) 'You entered a bogus length - try again.'
	  GOTO 1
	ENDIF
	sites = side * side
	volume = FLOAT(sites)
	WRITE(6,*) 'Volume = ', sites

	WRITE(6,*) 'Number of thermalization sweeps? '
	READ(5,*)  therm_sweeps
	WRITE(6,*) therm_sweeps

	WRITE(6,*) 'Number of sweeps per measurement? '
	READ(5,*)  sweeps
	WRITE(6,*) sweeps

	WRITE(6,*) 'Number of measurements? '
	READ(5,*)  measurements
	WRITE(6,*) measurements

	WRITE(6,*) 'Beta (inverse temperature)? '
	READ(5,*)  beta
	WRITE(6,*) beta

	WRITE(6,*) 'Ordered (0) or random (1) start? '
	READ(5,*)  start
	WRITE(6,*) start

	WRITE(6,*) '2 seeds for the random number generator? '
	READ(5,*)  seed(1), seed(2)
	WRITE(6,*) seed(1), seed(2)

	RETURN 
	END


C--------------------------------------------------------------------------

 
C  Initialize the spins with an ordered or random start.
 
	SUBROUTINE init_spins(start)
	INCLUDE "common.h"
	INTEGER start
	INTEGER i,j
	REAL ranmar
	
	IF (start.EQ.0) THEN
 
C ------  Ordered (cold) start
 
	  DO i=1,side
	  DO j=1,side
	    spin(i,j) = 1
	  ENDDO
	  ENDDO
	ELSE 
 
C ------  Random (hot) start
 
	  DO i=1,side
	  DO j=1,side
	    IF (ranmar() .LT. 0.5) THEN
	      spin(i,j) = 1
	    ELSE
	      spin(i,j) = -1
	    ENDIF
	  ENDDO
	  ENDDO
	ENDIF
	RETURN 
	END


C--------------------------------------------------------------------------

 
C  Look-up table of neighbors to impose periodic boundary conditions.
 
	SUBROUTINE neighbors
	INCLUDE "common.h"
	INTEGER i
	DO i=1,side
	  pos(i) = MOD(i,side) + 1
	  neg(i) = MOD(i+side-2,side) + 1 
	ENDDO
	RETURN 
	END


