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

      PRINT *, 'Length of the lattice? '
      READ *,  globside
      PRINT *, globside
      globisiz = globside
      globjsiz = globside
      globsites = globside * globside
      volume = FLOAT(globsites)
      WRITE(6,*) 'Volume = ', globsites

      PRINT *, 'Number of thermalization sweeps? '
      READ *,  therm_sweeps
      PRINT *, therm_sweeps

      PRINT *, 'Number of sweeps per measurement? '
      READ *,  sweeps
      PRINT *, sweeps

      PRINT *, 'Bin size? '
      READ *,  bin_size
      PRINT *, bin_size

      PRINT *, 'Number of bins? '
      READ *,  num_bins
      PRINT *, num_bins

      measurements = bin_size * num_bins
      PRINT *, 'Number of measurements = bin size x number of bins ='
      PRINT *, measurements

      PRINT *, 'Beta (inverse temperature)? '
      READ *,  beta
      PRINT *, beta

      PRINT *, 'Ordered (0) or random (1) start? '
      READ *,  start
      PRINT *, start

      PRINT *, 'Seed for the random number generator? '
      READ *,  seed
      PRINT *, seed

      RETURN 
      END


 
C----------------------------------------------------------------------C
C                                                                      C
C  Initialize the spins with an ordered or random start.               C
C                                                                      C
C----------------------------------------------------------------------C
 
	SUBROUTINE init_spins(start)
	INCLUDE "common.h"
	INTEGER start
	INTEGER i,j
	REAL rand
	
	IF (start.EQ.0) THEN
C ------  Ordered (cold) start
	  WRITE(6,*) 'Cold start'
	  DO i=1,isiz
	  DO j=1,jsiz
	    spin(i,j) = 1
	  ENDDO
	  ENDDO
	ELSE 
C ------  Random (hot) start
	  WRITE(6,*) 'Hot start'
	  DO i=1,isiz
	  DO j=1,jsiz
	    IF (rand() .LT. 0.5) THEN
	      spin(i,j) = 1
	    ELSE
	      spin(i,j) = -1
	    ENDIF
	  ENDDO
	  ENDDO
	ENDIF
	
C ----  Pass edges to neighboring processors.
        CALL spin_edges
	
	RETURN 
	END

