null character without reason in written files
Steve Kargl
sgk@troutmask.apl.washington.edu
Thu Oct 31 23:55:00 GMT 2013
On Thu, Oct 31, 2013 at 11:28:57PM +0000, N.M. Maclaren wrote:
> On Oct 31 2013, Janne Blomqvist wrote:
> >>
> >> Try Marsaglia's DIEHARD tests. I have some that are rather more
> >> stringent, though they test different aspects, and it doesn't fail
> >> them. I haven't run DIEHARD on it, but I assume that somebody has.
> >
> >I haven't tested myself, but I recall skimming through some paper
> >testing various PRNG's, and IIRC KISS (which is what gfortran uses)
> >passed DIEHARD, DIEHARDER(?), and TEST_U1(sp?).
>
> Oh, yes, it would. He wasn't sloppy that way and wouldn't publish anything
> that failed his own tests. The only questions are whether gfortran uses
> the right version and has coded it well. Marsaglias's main flaws were that
> his coding style was out of the ark (think Fortran 66), and he was very
> late in realising the importance of higher precisions.
gfortran uses 4 instances of Marsaglias's 32-bit KISS prng. There is a
long comment in libgfortran/intrinsics/random.c about the generator.
The part relevant here is
libgfortran currently uses George Marsaglia's KISS (Keep It Simple Stupid)
random number generator. This PRNG combines:
(1) The congruential generator x(n)=69069*x(n-1)+1327217885 with a period
of 2^32,
(2) A 3-shift shift-register generator with a period of 2^32-1,
(3) Two 16-bit multiply-with-carry generators with a period of
597273182964842497 > 2^59.
The overall period exceeds 2^123.
Why 4 instance? gfortran supports four real data types with
24, 53, 64, and 113 bits of precision. The first prng fills
the 24 bits of REAL or the first 32 bits of the other real types.
The 2nd kiss instance fills the next 21 bits of REAL(8) and the
or the 32 bits of REAL(10). The remaining 2 instances fill the
last 49 bits of REAL(16). This then allows one to change the
kind type parameter to test an algorithm for robustness where
there is some consistence between random_number calls.
program foo
implicit none
real(4) a
real(8) b
real(10) c
real(16) d
call random_seed ; call random_number(a) ; write(*,*) a
call random_seed ; call random_number(b) ; write(*,*) b
call random_seed ; call random_number(c) ; write(*,*) c
call random_seed ; call random_number(d) ; write(*,*) d
end program foo
troutmask:fvwm:kargl[214] gfortran -o z a.f90 && ./z
0.99755955
0.99755959009261719
0.99755959009261720041
0.99755959009261720044181150146400419
This is, of course, getting far afield to helping Daniel
find the reasons for the nulls in his output file. Daniel,
if you're still reading, if the version of gfortran you
currently have has the -fcheck=bounds option, can you try
to use it?
--
Steve
More information about the Fortran
mailing list