[patch, fortran, documentation] random_seed, random_number

Daniel Franke franke.daniel@gmail.com
Thu Apr 5 22:10:00 GMT 2007


On Thursday 05 April 2007 23:52:04 Jerry DeLisle wrote:
> Daniel Franke wrote:
> > On Thursday 05 April 2007 23:17:03 FX Coudert wrote:
> >>> 2007-04-05  Daniel Franke  <franke.daniel@gmail.com>
> >>>
> >>> 	PR fortran/31234
> >>> 	* intrinsic.texi (RANDOM_SEED, RANDOM_NUMBER): New.
> >>
> >> Looks good. If you're a native speaker, please go ahead and commit,
> >> otherwise I'd prefer you get a review from someone who is :)
> >
> > Then we have to wait for another review.
> > Thanks nevertheless =)
>
> This OK.  Did you get my minor comments.  I was having a bit of trouble
> with my email?

Yes. Replying here.


> +you should consider to employ a dedicated parallel
> +random number generator instead.
>
> change to :  you should consider employing a dedicated ...

Done.

> +@code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
> +the array must be larger or equal to number returned by the @var{SIZE}
> +argument.
>
> change to:  equal to the number returned by ....  This is in two places.

Done to avoid confusion.

Nonetheless, I didn't make the "larger or equal" up, it's specifically 
mentioned in the standard (final draft), section 13.14.86: "shall be a 
default integer array of rank one and size >= N". The examples then have: 
	CALL RANDOM_SEED (SIZE = K)
	CALL RANDOM_SEED (PUT = SEED (1 : K))

Thus, as I understand it, the array may be larger, but the section passed to 
should/must(?) equal the size. Gfortran actually accepts larger arrays, e. g.

  INTEGER :: n, seed(16)
  CALL RANDOM_SEED(size=n)
  write(*,*) n
  seed = -1
  CALL RANDOM_SEED(GET=seed)
  write(*,*) seed
  end

gives, on i686/linux (output formatting mine):

           8
   123456789   362436069   521288629   316191069
   987654321   458629013   582859209   438195021    
          -1          -1          -1          -1
          -1          -1          -1          -1

Bug or feature? Sidenote: smaller arrays result in a runtime error.


	Daniel



More information about the Gcc-patches mailing list