program main c*********************************************************************72 c cc closest_point_brute_test() tests closest_point_brute(). c c Discussion: c c We are given R, a set of NR points in M dimensions. c c We are given S, a points in M dimensions. c c We seek the index J of the point R(J) c which is nearest to S over all points in R. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 15 August 2024 c c Author: c c John Burkardt c c Local: c c integer M, the spatial dimension. c c integer NR, the number of data points. c c double precision R(M,NR), the data points. c c double precision RT(NR,M), the transposed data points. c c double precision S(M), the sample point. c implicit none integer m double precision near_dist integer near_index integer nr double precision, allocatable :: r(:,:) double precision, allocatable :: s(:) double precision t1 double precision t2 call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'closest_point_brute_test():' write ( *, '(a)' ) ' Fortran77 version' write ( *, '(a)' ) ' Test closest_point_brute().' m = 2 write ( *, '(a,i2)' ) ' Spatial dimension m = ', m write ( *, '(a)' ) '' nr = 1 do while ( nr <= 65536 ) allocate ( r(1:nr,1:m) ) call random_number ( harvest = r ) allocate ( s(1:m) ) call random_number ( harvest = s ) call cpu_time ( t1 ) call closest_point_brute ( m, nr, r, s, near_index, near_dist ) call cpu_time ( t2 ) write ( *, '(i5,2x,i5,2x,g8.2,2x,g8.2)' ) & nr, near_index, near_dist, ( t2 - t1 ) deallocate ( r ) deallocate ( s ) nr = nr * 2 end do c c Terminate. c write ( *, '(a)' ) '' write ( *, '(a)' ) 'closest_point_brute_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) return end subroutine timestamp ( ) c*********************************************************************72 c cc timestamp() prints out the current YMDHMS date as a timestamp. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 12 January 2007 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, month(m), y, h, ':', n, ':', s, '.', mm, ampm return end