program main !*****************************************************************************80 ! !! humps_test() tests humps(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 06 August 2019 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'humps_test():' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' Test humps().' call humps_antideriv_test ( ) call humps_fun_test ( ) call humps_deriv_test ( ) call humps_deriv2_test ( ) ! ! Terminate. ! write ( *, '(a)' ) '' write ( *, '(a)' ) 'humps_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) stop 0 end subroutine humps_antideriv_test ( ) !*****************************************************************************80 ! !! humps_antideriv_test tests humps_antideriv. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 06 August 2019 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) real ( kind = rk8 ) a real ( kind = rk8 ) b real ( kind = rk8 ) humps_antideriv integer i integer n real ( kind = rk8 ), allocatable :: x(:) real ( kind = rk8 ), allocatable :: y(:) write ( *, '(a)' ) '' write ( *, '(a)' ) 'humps_antideriv_test():' write ( *, '(a)' ) ' Test humps_antideriv().' a = -0.5D+00 b = 2.0D+00 n = 101 allocate ( x(1:n) ) allocate ( y(1:n) ) do i = 1, n x(i) = ( ( n - i ) * a + i * b ) / ( n - 1 ) y(i) = humps_antideriv ( x(i) ) end do call plot_xy ( n, x, y, 'humps_antideriv' ) deallocate ( x ) deallocate ( y ) return end subroutine humps_fun_test ( ) !*****************************************************************************80 ! !! humps_fun_test tests humps_fun. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 06 August 2019 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) real ( kind = rk8 ) a real ( kind = rk8 ) b real ( kind = rk8 ) humps_fun integer i integer n real ( kind = rk8 ), allocatable :: x(:) real ( kind = rk8 ), allocatable :: y(:) write ( *, '(a)' ) '' write ( *, '(a)' ) 'humps_fun_test():' write ( *, '(a)' ) ' Test humps_fun().' a = -0.5D+00 b = 2.0D+00 n = 101 allocate ( x(1:n) ) allocate ( y(1:n) ) do i = 1, n x(i) = ( ( n - i ) * a + i * b ) / ( n - 1 ) y(i) = humps_fun ( x(i) ) end do call plot_xy ( n, x, y, 'humps_fun' ) deallocate ( x ) deallocate ( y ) return end subroutine humps_deriv_test ( ) !*****************************************************************************80 ! !! humps_deriv_test tests humps_deriv. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 06 August 2019 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) real ( kind = rk8 ) a real ( kind = rk8 ) b real ( kind = rk8 ) humps_deriv integer i integer n real ( kind = rk8 ), allocatable :: x(:) real ( kind = rk8 ), allocatable :: y(:) write ( *, '(a)' ) '' write ( *, '(a)' ) 'humps_deriv_test():' write ( *, '(a)' ) ' Test humps_deriv().' a = -0.5D+00 b = 2.0D+00 n = 101 allocate ( x(1:n) ) allocate ( y(1:n) ) do i = 1, n x(i) = ( ( n - i ) * a + i * b ) / ( n - 1 ) y(i) = humps_deriv ( x(i) ) end do call plot_xy ( n, x, y, 'humps_deriv' ) deallocate ( x ) deallocate ( y ) return end subroutine humps_deriv2_test ( ) !*****************************************************************************80 ! !! humps_deriv2_test tests humps_deriv2. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 06 August 2019 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) real ( kind = rk8 ) a real ( kind = rk8 ) b real ( kind = rk8 ) humps_deriv2 integer i integer n real ( kind = rk8 ), allocatable :: x(:) real ( kind = rk8 ), allocatable :: y(:) write ( *, '(a)' ) '' write ( *, '(a)' ) 'humps_deriv2_test()' write ( *, '(a)' ) ' Test humps_deriv2().' a = -0.5D+00 b = 2.0D+00 n = 101 allocate ( x(1:n) ) allocate ( y(1:n) ) do i = 1, n x(i) = ( ( n - i ) * a + i * b ) / ( n - 1 ) y(i) = humps_deriv2 ( x(i) ) end do call plot_xy ( n, x, y, 'humps_deriv2' ) deallocate ( x ) deallocate ( y ) 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 ! ! Parameters: ! ! None ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) 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.2,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