program main c*****************************************************************************80 c cc tsp_display_test() tests tsp_display(). c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 17 June 2026 c c Author: c c John Burkardt c implicit none integer, parameter :: n = 42 integer i integer i2 integer, save, dimension ( n ) :: order = (/ & 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, & 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, & 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, & 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, & 2, 1 /) c c Stupid Fortran requires me to COUNT the size of a string. c character ( len = 9 ) :: prefix = 'dantzig42' c c Awkward Fortran convention means we list matrix data as though it were c (nx2) row-wise, but it will be stored as (2xn). c double precision, save, dimension ( 2, n ) :: x = reshape ( (/ & 170.0, 85.0, & 166.0, 88.0, & 133.0, 73.0, & 140.0, 70.0, & 142.0, 55.0, & 126.0, 53.0, & 125.0, 60.0, & 119.0, 68.0, & 117.0, 74.0, & 99.0, 83.0, & 73.0, 79.0, & 72.0, 91.0, & 37.0, 94.0, & 6.0, 106.0, & 3.0, 97.0, & 21.0, 82.0, & 33.0, 67.0, & 4.0, 66.0, & 3.0, 42.0, & 27.0, 33.0, & 52.0, 41.0, & 57.0, 59.0, & 58.0, 66.0, & 88.0, 65.0, & 99.0, 67.0, & 95.0, 55.0, & 89.0, 55.0, & 83.0, 38.0, & 85.0, 25.0, & 104.0, 35.0, & 112.0, 37.0, & 112.0, 24.0, & 113.0, 13.0, & 125.0, 30.0, & 135.0, 32.0, & 147.0, 18.0, & 147.5, 36.0, & 154.5, 45.0, & 157.0, 54.0, & 158.0, 61.0, & 172.0, 82.0, & 174.0, 87.0 /), (/ 2, n /) ) double precision, allocatable :: x2(:,:) call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'tsp_display_test():' write ( *, '(a)' ) ' Fortran90 version.' write ( *, '(a)' ) ' Display cities and route for a traveling' write ( *, '(a)' ) ' salesman problem (TSP).' write ( *, '(a)' ) ' Dataset is "' // prefix // '"' c c Create the circuit data with transposition, reordering and wrap-around. c allocate ( x2 ( 1 : n + 1, 1 : 2 ) ) do i2 = 1, n + 1 if ( i2 <= n ) then i = order(i2) else i = order(1) end if x2(i2,1:2) = x(1:2,i) end do c c Send the data to the plotter. c call tsp_display ( prefix, n + 1, x2 ) deallocate ( x2 ) c c Terminate. c write ( *, '(a)' ) '' write ( *, '(a)' ) 'tsp_display_test():' write ( *, '(a)' ) ' Normal end of execution.' call timestamp ( ) stop end subroutine timestamp ( ) c*********************************************************************72 c cc timestamp() prints the YMDHMS date as a timestamp. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 12 June 2014 c c Author: c c John Burkardt c implicit none character * ( 8 ) ampm integer d character * ( 8 ) date integer h integer m integer mm character * ( 9 ) month(12) integer n integer s character * ( 10 ) time integer y save month data month / & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' / call date_and_time ( date, time ) read ( date, '(i4,i2,i2)' ) y, m, d read ( time, '(i2,i2,i2,1x,i3)' ) h, n, s, mm if ( h .lt. 12 ) then ampm = 'AM' else if ( h .eq. 12 ) then if ( n .eq. 0 .and. s .eq. 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h .lt. 12 ) then ampm = 'PM' else if ( h .eq. 12 ) then if ( n .eq. 0 .and. s .eq. 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, & '(i2,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