program main !*****************************************************************************80 ! !! ARRAYS should be analyzed by GDB. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 19 February 2017 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'ARRAYS:' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' A program for analysis by GDB.' call array_test ( ) ! ! Terminate. ! write ( *, '(a)' ) '' write ( *, '(a)' ) 'ARRAYS:' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) stop end subroutine array_test ( ) !*****************************************************************************80 ! !! ARRAY_TEST sets up some arrays, and calls ARRAY_PRINT and ARRAY_CHANGE. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! implicit none integer a(3,2) integer, allocatable :: b(:,:) integer c(1,1) integer i integer j integer m integer n m = 3 n = 2 do i = 1, m do j = 1, n a(i,j) = 10 * i + j end do end do allocate ( b(m,n) ) do i = 1, m do j = 1, n b(i,j) = 100 * i + j end do end do c(1,1) = 1000 * 1 + 1 call array_print ( a, b, c, m, n ) call array_change ( a, b, c, m, n ) deallocate ( b ) return end subroutine array_print ( a, b, c, m, n ) !*****************************************************************************80 ! !! ARRAY_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(M,N), B(M,N), C(1,1), M, N. ! implicit none integer m integer n integer a(m,n) integer b(m,n) integer c(m,n) integer d(m,n) integer i integer j do i = 1, m do j = 1, n d(i,j) = 10000 * i + j end do end do write ( *, '(a)' ) '' write ( *, '(a)' ) ' I J A B C D' write ( *, '(a)' ) '' do i = 1, m do j = 1, n write ( *, '(6i6)' ) i, j, a(i,j), b(i,j), c(i,j), d(i,j) end do end do return end subroutine array_change ( a, b, c, m, n ) !*****************************************************************************80 ! !! ARRAY_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 m integer n integer a(m,n) integer b(m,n) integer c(m,n) integer i integer j do i = 1, m do j = 1, n a(i,j) = a(i,j) + 1 b(i,j) = b(i,j) + 1 c(i,j) = c(i,j) + 1 end do end do write ( *, '(a)' ) '' write ( *, '(a)' ) ' I J A B C ' write ( *, '(a)' ) '' do i = 1, m do j = 1, n write ( *, '(5i6)' ) i, j, a(i,j), b(i,j), c(i,j) end do 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