program main !*****************************************************************************80 ! !! wedge_monte_carlo_test() tests wedge_monte_carlo(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 17 August 2014 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'wedge_monte_carlo_test():' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' Test wedge_monte_carlo().' call test01 ( ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'WEDGE_MONTE_CARLO_TEST' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop 0 end subroutine test01 ( ) !*****************************************************************************80 ! !! TEST01 uses WEDGE01_SAMPLE with an increasing number of points. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 12 January 2014 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer, parameter :: m = 3 integer e(m) integer :: e_test(m,8) = reshape ( (/ & 0, 0, 0, & 1, 0, 0, & 0, 1, 0, & 0, 0, 1, & 2, 0, 0, & 1, 1, 0, & 0, 0, 2, & 3, 0, 0 /), (/ m, 8 /) ) integer j integer n real ( kind = rk ) result(8) real ( kind = rk ), allocatable :: value(:) real ( kind = rk ), allocatable :: x(:,:) real ( kind = rk ) wedge01_volume write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a)' ) ' Use WEDGE01_SAMPLE for a Monte Carlo estimate of an' write ( *, '(a)' ) ' integral over the interior of the unit wedge in 3D.' write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' N 1 X Y ' // & ' Z X^2 XY Z^2 ' // & ' X^3' write ( *, '(a)' ) ' ' n = 1 do while ( n <= 65536 ) allocate ( value(1:n) ) allocate ( x(1:m,1:n) ) call wedge01_sample ( n, x ) do j = 1, 8 e(1:m) = e_test(1:m,j) call monomial_value ( m, n, e, x, value ) result(j) = wedge01_volume ( ) * sum ( value(1:n) ) / real ( n, kind = rk ) end do write ( *, '(2x,i8,8(2x,g14.6))' ) n, result(1:8) deallocate ( value ) deallocate ( x ) n = 2 * n end do write ( *, '(a)' ) ' ' do j = 1, 8 e(1:m) = e_test(1:m,j) call wedge01_integral ( e, result(j) ) end do write ( *, '(2x,a8,8(2x,g14.6))' ) ' Exact', result(1:8) 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