function r8_random ( s1, s2, s3 ) !*****************************************************************************80 ! !! R8_RANDOM returns a pseudorandom number between 0 and 1. ! ! Discussion: ! ! This function returns a pseudo-random number rectangularly distributed ! between 0 and 1. The cycle length is 6.95E+12. (See page 123 ! of Applied Statistics (1984) volume 33), not as claimed in the ! original article. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 08 July 2008 ! ! Author: ! ! FORTRAN77 original version by Brian Wichman, David Hill. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Brian Wichman, David Hill, ! Algorithm AS 183: An Efficient and Portable Pseudo-Random ! Number Generator, ! Applied Statistics, ! Volume 31, Number 2, 1982, pages 188-190. ! ! Parameters: ! ! Input/output, integer S1, S2, S3, three values used as the ! seed for the sequence. These values should be positive ! integers between 1 and 30,000. ! ! Output, real ( kind = rk ) R8_RANDOM, the next value in the sequence. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer s1 integer s2 integer s3 real ( kind = rk ) r8_random s1 = mod ( 171 * s1, 30269 ) s2 = mod ( 172 * s2, 30307 ) s3 = mod ( 170 * s3, 30323 ) r8_random = mod ( real ( s1, kind = rk ) / 30269.0D+00 & + real ( s2, kind = rk ) / 30307.0D+00 & + real ( s3, kind = rk ) / 30323.0D+00, 1.0D+00 ) return end function r8_uni ( s1, s2 ) !*****************************************************************************80 ! !! R8_UNI returns a pseudorandom number between 0 and 1. ! ! Discussion: ! ! This function generates uniformly distributed pseudorandom numbers ! between 0 and 1, using the 32-bit generator from figure 3 of ! the article by L'Ecuyer. ! ! The cycle length is claimed to be 2.30584E+18. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 08 July 2008 ! ! Author: ! ! Original Pascal original version by Pierre L'Ecuyer ! FORTRAN90 version by John Burkardt ! ! Reference: ! ! Pierre LEcuyer, ! Efficient and Portable Combined Random Number Generators, ! Communications of the ACM, ! Volume 31, Number 6, June 1988, pages 742-751. ! ! Parameters: ! ! Input/output, integer S1, S2, two values used as the ! seed for the sequence. On first call, the user should initialize ! S1 to a value between 1 and 2147483562; S2 should be initialized ! to a value between 1 and 2147483398. ! ! Output, real ( kind = rk ) R8_UNI, the next value in the sequence. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer k real ( kind = rk ) r8_uni integer s1 integer s2 integer z k = s1 / 53668 s1 = 40014 * ( s1 - k * 53668 ) - k * 12211 if ( s1 < 0 ) then s1 = s1 + 2147483563 end if k = s2 / 52774 s2 = 40692 * ( s2 - k * 52774 ) - k * 3791 if ( s2 < 0 ) then s2 = s2 + 2147483399 end if z = s1 - s2 if ( z < 1 ) then z = z + 2147483562 end if r8_uni = real ( z, kind = rk ) / 2147483563.0D+00 return end subroutine timestamp ( ) !*****************************************************************************80 ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! implicit none character ( len = 8 ) ampm integer d integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer n integer s integer values(8) integer y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end