re PR fortran/78741 (ICE in gfc_get_symbol_decl, at fortran/trans-decl.c:1534)
[official-gcc.git] / gcc / testsuite / gfortran.dg / pr37286.f90
blobf84de049a6a62dc625a2e419b8ba574f8ca75d02
1 ! { dg-do compile }
2 ! { dg-require-visibility "" }
4 module general_rand
5 implicit none
6 private
8 integer, public, parameter :: GNDP = kind(1.0d0)
10 real(kind = GNDP), save :: &
11 gnc = 362436.0 / 16777216.0, &
12 gncd = 7654321.0 / 16777216.0, &
13 gncm = 16777213.0 / 16777216.0
14 integer, save :: &
15 gni97 = 97, &
16 gnj97 = 33
18 real(kind = GNDP), save :: gnu(97)
20 contains
21 subroutine gn_fatal(message)
22 character(len = *), intent(in) :: message
24 stop 1
25 end subroutine gn_fatal
27 function gn_monte_rand(min, max) result(monte)
28 real(kind = GNDP), intent(in) :: min
29 real(kind = GNDP), intent(in) :: max
30 real(kind = GNDP) :: monte
32 real :: monte_temp
34 if (min > max) then
35 call gn_fatal('gn_monte_rand: min > max')
36 else if (min == max) then
37 call gn_fatal('gn_monte_rand: min = max: returning min')
38 monte_temp = min
39 else
41 monte_temp = gnu(gni97) - gnu(gnj97)
42 if (monte_temp < 0.0) then
43 monte_temp = monte_temp + 1.0
44 end if
46 gnu(gni97) = monte_temp
47 gni97 = gni97 - 1
48 if (gni97 == 0) then
49 gni97 = 97
50 end if
51 end if
53 monte = min + monte_temp * (max - min)
55 end function gn_monte_rand
57 end module general_rand