GetRandomFloat.F
c****************************************************************
#include "author.inc"
c* $Id: GetRandomFloat.F,v 1.8 1995/07/30 17:57:24 turner Exp $
c*
c* Function to return random values.
c*
#ifdef cray
c* This version can be used on Cray machines running UNICOS.
#else
#ifdef sun
c* This version is for Sun workstations.
#else
c* This version is for Hewlett-Packard and IBM RS/6000
c* workstations (and probably others).
#endif
#endif
c*
c* <PARAMETER LIST>
c*
c* Input:
c* iflag - control integer:
c* 0 ==> generator returns next random number in
c* sequence
c* 1 ==> generator is restarted and the first random
c* value is returned
c* otherwise, iflag is used as a new seed and the first
c* new random value is returned
c*
c* Output:
c* JT_GetRandomFloat - random value
c* status - return status
c*
#include "copyright.inc"
c****************************************************************
real function JT_GetRandomFloat(iflag, status)
implicit none
c
c ... Input:
#ifdef cray
integer iflag
c
c ... Local:
integer iseed
real RanF
#else
# ifdef sun
integer*4 iflag
c
c ... Local:
# if bytes_per_real==8
real*8 dRand
# else
real*4 Rand
# endif
# else
integer iflag
c
c ... Local:
real Rand
# endif
#endif
c
c ... Output:
integer status
c
#ifdef cray
if (iflag .eq. 1) then
call RanGet (iseed)
call RanSet (iseed)
elseif (iflag .ne. 0) then
call RanSet (iflag)
endif
JT_GetRandomFloat = RanF()
#else
# ifdef sun
# if bytes_per_real==8
JT_GetRandomFloat = dRand(iflag)
# else
JT_GetRandomFloat = Rand(iflag)
# endif
# else
JT_GetRandomFloat = Rand()
# endif
#endif
c
status = 0
return
end