program main !*****************************************************************************80 ! !! vectors() should be analyzed by GDB. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'VECTORS():' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' A program for analysis by GDB.' call vector_test ( ) ! ! Terminate. ! write ( *, '(a)' ) '' write ( *, '(a)' ) 'VECTORS:' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) stop end subroutine vector_test ( ) !*****************************************************************************80 ! !! VECTOR_TEST sets up some arrays, and calls VECTOR_PRINT and VECTOR_CHANGE. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! implicit none integer a(10) integer, allocatable :: b(:) integer c(1) integer i integer n do i = 1, 10 a(i) = 100 + i end do allocate ( b(1:10) ) do i = 1, 10 b(i) = 200 + i end do c(1) = 301 n = 10 call vector_print ( a, b, c, n ) call vector_change ( a, b, c ) deallocate ( b ) return end subroutine vector_print ( a, b, c, n ) !*****************************************************************************80 ! !! VECTOR_PRINT creates the heap array D, then prints A, B, C and D. ! ! Discussion: ! ! C is an array of size 1, but this function "thinks" it has size 10. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer A(10), B(10), C, N. ! implicit none integer n integer a(10) integer b(10) integer c(*) integer d(n) integer i do i = 1, 10 d(i) = 400 + i end do write ( *, '(a)' ) '' write ( *, '(a)' ) ' I A B C D' write ( *, '(a)' ) '' do i = 1, 10 write ( *, '(5i6)' ) i, a(i), b(i), c(i), d(i) end do return end subroutine vector_change ( a, b, c ) !*****************************************************************************80 ! !! VECTOR_CHANGE changes arrays A, B, C. ! ! Discussion: ! ! C is an array of size 1, but this function "thinks" it has size 10. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer A(10), B(10), C. ! implicit none integer, parameter :: n = 10 integer a(n) integer b(n) integer c(*) integer i do i = 1, n a(i) = ( a(i) - 1 ) * n + 1 b(i) = ( b(i) - 1 ) * n + 1 c(i) = ( c(i) - 1 ) * n + 1 end do write ( *, '(a)' ) '' write ( *, '(a)' ) ' I A B C' write ( *, '(a)' ) '' do i = 1, n write ( *, '(4i6)' ) i, a(i), b(i), c(i) end do 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 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