From abdef81151d23ac629bbd9e98fdf31fd478912f3 Mon Sep 17 00:00:00 2001 From: Bud Davis Date: Fri, 14 May 2004 12:21:22 +0000 Subject: [PATCH] re PR libfortran/15149 (problem computing Pi) PR fortran/15149 * gfortran.fortran-torture/execute/random_init.f90: New test. * libgfortan.h,intrinsics/random.c: Made random_seed visible. * runtime/main.c(init): Call random_seed as part of MAIN init. From-SVN: r81836 --- gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.fortran-torture/execute/random_init.f90 | 11 +++++++++++ libgfortran/ChangeLog | 6 ++++++ libgfortran/intrinsics/random.c | 1 - libgfortran/libgfortran.h | 6 ++++++ libgfortran/runtime/main.c | 2 ++ 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.fortran-torture/execute/random_init.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4ac96daa562..c3a62881fac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-05-14 Bud Davis + + PR fortran/15149 + * gfortran.fortran-torture/execute/random_init.f90: New test. + 2004-05-13 Paul Brook PR fortran/15314 diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/random_init.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/random_init.f90 new file mode 100644 index 00000000000..36394589d8b --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/execute/random_init.f90 @@ -0,0 +1,11 @@ +! pr 15149 +! verify the random number generator is functional + program test_random + implicit none + real :: r(5) = 0.0 + + call random_number(r) + if (all (r .eq. 0)) call abort + end program + + diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 7df9edf3f6c..bbf22d4d082 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2004-05-14 Bud Davis + + PR fortran/15149 + * libgfortan.h,intrinsics/random.c: Made random_seed visible. + * runtime/main.c(init): Call random_seed as part of MAIN init. + 2004-05-13 Tobias Schlüter * io/format.c: (parse_format_list): No comma is required after diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c index b578148f469..120c9517fa2 100644 --- a/libgfortran/intrinsics/random.c +++ b/libgfortran/intrinsics/random.c @@ -70,7 +70,6 @@ static unsigned int seed[N]; /* This is the routine which handles the seeding of the generator, and also reading and writing of the seed. */ -#define random_seed prefix(random_seed) void random_seed (GFC_INTEGER_4 * size, const gfc_array_i4 * put, const gfc_array_i4 * get) diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index 14a217a64f6..112fd075dcf 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -396,5 +396,11 @@ void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *); GFC_INTEGER_4 compare_string (GFC_INTEGER_4, const char *, GFC_INTEGER_4, const char *); +/* random.c */ + +#define random_seed prefix(random_seed) +void random_seed (GFC_INTEGER_4 * size, const gfc_array_i4 * put, + const gfc_array_i4 * get); + #endif diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c index 60c032b4fcb..e3eaf2b2ffc 100644 --- a/libgfortran/runtime/main.c +++ b/libgfortran/runtime/main.c @@ -100,6 +100,8 @@ init (void) #endif memory_init (); + random_seed(NULL,NULL,NULL); + } -- 2.30.2