program main !*****************************************************************************80 ! !! MAIN is the main program for TABLE_IO_PRB. ! ! Discussion: ! ! TABLE_IO_PRB calls the TABLE_IO test routines. ! ! Modified: ! ! 21 July 2007 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TABLE_IO_PRB' write ( *, '(a)' ) ' FORTRAN90 version:' write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Test the routines in the TABLE_IO library.' call test01 ( ) call test02 ( ) call test03 ( ) call test04 ( ) call test05 ( ) call test06 ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TABLE_IO_PRB' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop end subroutine test01 ( ) !*****************************************************************************80 ! !! TEST01 tests DTABLE_WRITE. ! ! Modified: ! ! 26 September 2006 ! ! Author: ! ! John Burkardt ! implicit none integer ( kind = 4 ), parameter :: n = 20 integer ( kind = 4 ), parameter :: m = 5 logical header integer ( kind = 4 ) i integer ( kind = 4 ) j character ( len = 80 ) :: output_filename = 'dtable_05_00020.txt' real ( kind = 8 ) table(m,n) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a)' ) ' DTABLE_WRITE writes a double precision real TABLE file.' do i = 1, m do j = 1, n table(i,j) = real ( 100 * j + i, kind = 8 ) / 10.0D+00 end do end do write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Spatial dimension M = ', m write ( *, '(a,i8)' ) ' Number of points N = ', n call r8mat_print_some ( m, n, table, 1, 1, 5, 5, & ' 5x5 portion of the data written to file:' ) call r8mat_transpose_print_some ( m, n, table, 1, 1, 5, 5, & ' 5x5 portion of the TRANSPOSED data:' ) header = .true. call dtable_write ( output_filename, m, n, table, header ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Wrote the header and data for "' & // trim ( output_filename ) //'".' return end subroutine test02 ( ) !*****************************************************************************80 ! !! TEST02 tests DTABLE_HEADER_READ, DTABLE_DATA_READ. ! ! Modified: ! ! 26 September 2006 ! ! Author: ! ! John Burkardt ! implicit none character ( len = 80 ) :: input_filename = 'dtable_05_00020.txt' integer ( kind = 4 ) m integer ( kind = 4 ) n real ( kind = 8 ), allocatable, dimension ( :, : ) :: table write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST02' write ( *, '(a)' ) ' For double precision real data stored in a TABLE file,' write ( *, '(a)' ) ' DTABLE_HEADER_READ reads the header information' write ( *, '(a)' ) ' (about the dimensions of the data);' write ( *, '(a)' ) ' DTABLE_DATA_READ reads the data.' call dtable_header_read ( input_filename, m, n ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Read the header of "' // trim ( input_filename ) //'".' write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Spatial dimension M = ', m write ( *, '(a,i8)' ) ' Number of points N = ', n allocate ( table(1:m,1:n) ) call dtable_data_read ( input_filename, m, n, table ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Read the data in "' // trim ( input_filename ) //'".' call r8mat_print_some ( m, n, table, 1, 1, 5, 5, & ' 5x5 portion of data read from file:' ) deallocate ( table ) return end subroutine test03 ( ) !*****************************************************************************80 ! !! TEST03 tests ITABLE_WRITE. ! ! Modified: ! ! 26 September 2006 ! ! Author: ! ! John Burkardt ! implicit none integer ( kind = 4 ), parameter :: n = 20 integer ( kind = 4 ), parameter :: m = 5 logical header integer ( kind = 4 ) i integer ( kind = 4 ) j character ( len = 80 ) :: output_filename = 'itable_05_00020.txt' integer ( kind = 4 ) table(m,n) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST03' write ( *, '(a)' ) ' ITABLE_WRITE writes an integer TABLE file.' do i = 1, m do j = 1, n table(i,j) = 100 * j + i end do end do write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Spatial dimension M = ', m write ( *, '(a,i8)' ) ' Number of points N = ', n call i4mat_print_some ( m, n, table, 1, 1, 5, 5, & ' 5 x 5 portion of data written to file:' ) header = .true. call itable_write ( output_filename, m, n, table, header ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Wrote the header and data for "' & // trim ( output_filename ) //'".' return end subroutine test04 ( ) !*****************************************************************************80 ! !! TEST04 tests ITABLE_HEADER_READ, ITABLE_DATA_READ. ! ! Modified: ! ! 26 September 2006 ! ! Author: ! ! John Burkardt ! implicit none character ( len = 80 ) :: input_filename = 'itable_05_00020.txt' integer ( kind = 4 ) m integer ( kind = 4 ) n integer ( kind = 4 ), allocatable, dimension ( :, : ) :: table write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST04' write ( *, '(a)' ) ' For integer data stored in a TABLE file,' write ( *, '(a)' ) ' ITABLE_HEADER_READ reads the header information' write ( *, '(a)' ) ' (about the dimensions of the data);' write ( *, '(a)' ) ' ITABLE_DATA_READ reads the data.' call itable_header_read ( input_filename, m, n ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Read the header of "' // trim ( input_filename ) //'".' write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Spatial dimension M = ', m write ( *, '(a,i8)' ) ' Number of points N = ', n allocate ( table(1:m,1:n) ) call itable_data_read ( input_filename, m, n, table ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Read the data in "' // trim ( input_filename ) //'".' call i4mat_print_some ( m, n, table, 1, 1, 5, 5, & ' 5 x 5 portion of data read from file:' ) deallocate ( table ) return end subroutine test05 ( ) !*****************************************************************************80 ! !! TEST05 tests R8MAT_UNIFORM_01. ! ! Modified: ! ! 26 September 2006 ! ! Author: ! ! John Burkardt ! implicit none integer ( kind = 4 ), parameter :: m = 2 integer ( kind = 4 ), parameter :: n = 10 integer ( kind = 4 ) :: seed = 123456789 real ( kind = 8 ), dimension (m,n) :: table write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST05' write ( *, '(a)' ) ' R8MAT_UNIFORM_01 sets a random double precision' write ( *, '(a)' ) ' table dataset.' write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Spatial dimension M = ', m write ( *, '(a,i8)' ) ' Number of points N = ', n call r8mat_uniform_01 ( m, n, seed, table ) call r8mat_print_some ( m, n, table, 1, 1, 5, 10, & ' 5x10 portion of random real table dataset:' ) return end subroutine test06 ( ) !*****************************************************************************80 ! !! TEST06 tests ITABLE_DATA_BORDER_ADD, ITABLE_DATA_BORDER_CUT. ! ! Modified: ! ! 26 September 2006 ! ! Author: ! ! John Burkardt ! implicit none integer ( kind = 4 ), parameter :: m = 6 integer ( kind = 4 ), parameter :: n = 4 integer ( kind = 4 ), dimension (m,n) :: table integer ( kind = 4 ), dimension (m-2,n-2) :: table2 integer ( kind = 4 ), dimension (m,n) :: table3 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST06' write ( *, '(a)' ) ' ITABLE_DATA_BORDER_CUT cuts off the border;' write ( *, '(a)' ) ' ITABLE_DATA_BORDER_ADD adds a zero border.' write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Spatial dimension M = ', m write ( *, '(a,i8)' ) ' Number of points N = ', n call i4mat_indicator ( m, n, table ) call i4mat_print ( m, n, table, ' Initial dataset:' ) call itable_data_border_cut ( m, n, table, table2 ) call i4mat_print ( m-2, n-2, table2, ' "Cut" dataset:' ) call itable_data_border_add ( m-2, n-2, table2, table3 ) call i4mat_print ( m, n, table3, ' "Added" dataset:' ) return end