!C----------------------------------------------------------------------C
!C                                                                      C
!C     Initialize the parallel HPF random number generator              C
!C                                                                      C
!C     Need to assign a different random seed to each abstract          C
!C     processor, so have to use a simple linear congruential           C
!C     generator just to set up the seed array.                         C
!C                                                                      C
!C----------------------------------------------------------------------C
      
      SUBROUTINE HPF_RANDOM_SEED(seed)
      IMPLICIT NONE
      INTEGER seed
      INTEGER i, n
      INTEGER, DIMENSION(:), ALLOCATABLE :: seed_array

      CALL random_seed(size=n)
      ALLOCATE( seed_array(n) )
      FORALL(i=1:n) seed_array(i) = MOD(i*4096+150889+seed,714025 )
      CALL random_seed( put=seed_array(1:n) )
      DEALLOCATE( seed_array )

!C     PRINT *, 'RNG: n = ', n

      RETURN
      END SUBROUTINE
 

      
!C----------------------------------------------------------------------C
!C                                                                      C
!C     Call the HPF parallel random number generator.                   C
!C                                                                      C
!C----------------------------------------------------------------------C

      SUBROUTINE HPF_RANDOM_NUMBER(randnum)
      USE global_variables
      REAL, DIMENSION(0:dimm1,0:dimm1) :: randnum 


      CALL RANDOM_NUMBER(randnum)


      RETURN
      END SUBROUTINE
 

      
!C----------------------------------------------------------------------C
!C                                                                      C
!C     Print out the random numbers.                                    C
!C                                                                      C
!C----------------------------------------------------------------------C

      SUBROUTINE print_rand
      USE global_variables
      INTEGER i,j

      DO i=0,dimm1
        DO j=0,dimm1
          WRITE(10,'(F9.6)') ranum(i,j)
        ENDDO
      ENDDO

      RETURN
      END SUBROUTINE




