program main !*****************************************************************************80 ! !! halton_test() tests halton(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 11 August 2016 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'halton_test():' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' Test halton()' call halton_test ( ) call halton_sequence_test ( ) call halton_inverse_test ( ) call halton_base_test ( ) ! ! Terminate. ! write ( *, '(a)' ) '' write ( *, '(a)' ) 'halton_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) stop 0 end subroutine halton_test ( ) !*****************************************************************************80 ! !! halton_test() tests halton(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 11 August 2016 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer i integer m real ( kind = rk ) r(3) write ( *, '(a)' ) '' write ( *, '(a)' ) 'HALTON_TEST' write ( *, '(a)' ) ' HALTON returns the I-th element of an M-dimensional' write ( *, '(a)' ) ' Halton sequence.' write ( *, '(a)' ) '' write ( *, '(a)' ) ' I HALTON(I)' do m = 1, 3 write ( *, '(a)' ) '' write ( *, '(a,i2)' ) ' Use M = ', m write ( *, '(a)' ) '' do i = 0, 10 call halton ( i, m, r ) write ( *, '(2x,i3,3(2x,f14.8))' ) i, r(1:m) end do end do return end subroutine halton_base_test ( ) !*****************************************************************************80 ! !! halton_base_test() tests halton_base(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 11 August 2016 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer b(3) integer i integer m real ( kind = rk ) r(3) write ( *, '(a)' ) '' write ( *, '(a)' ) 'HALTON_BASE_TEST' write ( *, '(a)' ) ' HALTON_BASE returns the I-th element of an M-dimensional' write ( *, '(a)' ) ' Halton sequence, using user-specified bases.' m = 3 b = (/ 2, 3, 5 /) write ( *, '(a)' ) '' write ( *, '(a,i3)' ) ' M = ', m write ( *, '(a,3(2x,i14))' ) ' B:', b(1:m) do i = 0, 10 call halton_base ( i, m, b, r ) write ( *, '(2x,i3,3(2x,f14.8))' ) i, r(1:m) end do m = 3 b = (/ 3, 10, 2 /) write ( *, '(a)' ) '' write ( *, '(a,i3)' ) ' M = ', m write ( *, '(a,3(2x,i14))' ) ' B:', b(1:m) do i = 0, 10 call halton_base ( i, m, b, r ) write ( *, '(2x,i3,3(2x,f14.8))' ) i, r(1:m) end do return end subroutine halton_inverse_test ( ) !*****************************************************************************80 ! !! halton_inverse_test() tests halton_inverse(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 11 August 2016 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer i integer i2 integer m real ( kind = rk ) r(3) write ( *, '(a)' ) '' write ( *, '(a)' ) 'HALTON_INVERSE_TEST' write ( *, '(a)' ) ' HALTON_INVERSE inverts an element of a Halton sequence.' write ( *, '(a)' ) '' write ( *, '(a)' ) ' I R=HALTON(I,3) HALTON_INVERSE(R,3)' write ( *, '(a)' ) '' m = 3 do i = 0, 10 call halton ( i, m, r ) call halton_inverse ( r, m, i2 ) write ( *, '(2x,i3,3(2x,f14.8),2x,i3)' ) i, r(1:m), i2 end do return end subroutine halton_sequence_test ( ) !*****************************************************************************80 ! !! halton_sequence_test() tests halton_sequence(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 11 August 2016 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer m real ( kind = rk ) r(3,11) write ( *, '(a)' ) '' write ( *, '(a)' ) 'halton_sequence_test():' write ( *, '(a)' ) ' halton_sequence() returns the elements I1 through I2' write ( *, '(a)' ) ' of an M-dimensional Halton sequence.' do m = 1, 3 write ( *, '(a)' ) '' write ( *, '(a,i1,a)' ) ' HALTON_SEQUENCE(0,10,', m, ',R):' call halton_sequence ( 0, 10, m, r ) call r8mat_print ( m, 11, r, ' R:' ) end do m = 3 write ( *, '(a)' ) '' write ( *, '(a,i1,a)' ) ' HALTON_SEQUENCE(10,0,', m, ',R):' call halton_sequence ( 10, 0, m, r ) call r8mat_print ( m, 11, r, ' R:' ) 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