
!C----------------------------------------------------------------------C
!CC                                                                      C
!CC  Read in the parameters for the simulation.                          C
!CC                                                                      C
!CC----------------------------------------------------------------------C
 
      SUBROUTINE input(seed,start)
      USE global_variables
      INTEGER i, j
      INTEGER seed,start

!CC
!CC  Read in parameters.
!CC
      PRINT *, 'Number of processors:',NUMBER_OF_PROCESSORS()

      PRINT *, 'Lattice size is',dim,' x',dim,' =',dim*dim

      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


 
!CC----------------------------------------------------------------------C
!CC                                                                      C
!CC  Initialize the spins with an ordered or random start.               C
!CC                                                                      C
!CC----------------------------------------------------------------------C
 
      SUBROUTINE init_spins(start)
      USE global_variables
      INTEGER start
      INTEGER i,j
	
      IF (start.EQ.0) THEN
!C ----- Ordered (cold) start
        spin = 1
      ELSE
!C ----- Random (hot) start
        CALL HPF_RANDOM_NUMBER(ranum)
        WHERE (ranum .GE. 0.5)
          spin = 1
         ELSEWHERE
          spin = -1
        END WHERE
      END IF
 
      RETURN 
      END


 
!C----------------------------------------------------------------------C
!C                                                                      C
!C  Set up black/white checkerboard mask.                               C
!C                                                                      C
!C----------------------------------------------------------------------C
 
      SUBROUTINE checkerboard
      USE global_variables
      INTEGER i, j

      black_white = .FALSE.
      FORALL (i=0:dimm1, j=0:dimm1, MOD((i+j),2).EQ.0) &
     &  black_white(i,j) = .TRUE.

      RETURN 
      END


