program main !*****************************************************************************80 ! !! array3d() should be analyzed by gdb. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 19 February 2017 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'ARRAY3D:' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' A program for analysis by GDB.' call array3d_test ( ) ! ! Terminate. ! write ( *, '(a)' ) '' write ( *, '(a)' ) 'ARRAY3D:' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) stop end subroutine array3d_test ( ) !*****************************************************************************80 ! !! ARRAY3d_TEST calls ARRAY3D_PRINT and ARRAY3D_CHANGE. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! implicit none integer a(3,2,2) integer, allocatable :: b(:,:,:) integer c(1,1,1) integer i integer j integer k integer l integer m integer n l = 3 m = 2 n = 2 do i = 1, l do j = 1, m do k = 1, n a(i,j,k) = 100 * i + 10 * j + k end do end do end do allocate ( b(l,m,n) ) do i = 1, l do j = 1, m do k = 1, n b(i,j,k) = 100 * i + 10 * j + k end do end do end do c(1,1,1) = 100 * 1 + 10 * 1 + 1 call array3d_print ( a, b, c, l, m, n ) call array3d_change ( a, b, c, l, m, n ) deallocate ( b ) return end subroutine array3d_print ( a, b, c, l, m, n ) !*****************************************************************************80 ! !! ARRAY3D_PRINT creates the heap array D, then prints A, B, C and D. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! implicit none integer l integer m integer n integer a(l,m,n) integer b(l,m,n) integer c(l,m,n) integer d(l,m,n) integer i integer j integer k do i = 1, l do j = 1, m do k = 1, n d(i,j,k) = 100 * i + 10 * j + k end do end do end do write ( *, '(a)' ) '' write ( *, '(a)' ) ' I J K A B C D' write ( *, '(a)' ) '' do i = 1, l do j = 1, m do k = 1, n write ( *, '(7i6)' ) i, j, k, a(i,j,k), b(i,j,k), c(i,j,k), d(i,j,k) end do end do end do return end subroutine array3d_change ( a, b, c, l, m, n ) !*****************************************************************************80 ! !! ARRAY3D_CHANGE changes arrays A, B, C. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 February 2017 ! ! Author: ! ! John Burkardt ! implicit none integer l integer m integer n integer a(l,m,n) integer b(l,m,n) integer c(l,m,n) integer i integer j integer k do i = 1, l do j = 1, m do k = 1, n a(i,j,k) = a(i,j,k) + 1 b(i,j,k) = b(i,j,k) + 1 c(i,j,k) = c(i,j,k) + 1 end do end do end do write ( *, '(a)' ) '' write ( *, '(a)' ) ' I J K A B C ' write ( *, '(a)' ) '' do i = 1, l do j = 1, m do k = 1, n write ( *, '(6i6)' ) i, j, k, a(i,j,k), b(i,j,k), c(i,j,k) end do 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