program rollcall ! !******************************************************************************* ! !! ROLLCALL has each thread print out its ID. ! ! ! Discussion: ! ! This program uses Open MP parallelization directives. ! ! Parallel execution is accomplished by having multiple threads. ! ! The number of threads available is determined by the externally ! defined environment variable OMP_NUM_THREADS. ! ! Each thread is assigned a unique identifier from 0 to OMP_NUM_THREADS-1. ! ! The Open MP library function OMP_GET_THREAD_NUM returns the value ! of the identifier for a given thread. ! ! Modified: ! ! 29 March 2002 ! ! Author: ! ! John Burkardt ! call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'ROLLCALL' write ( *, '(a)' ) ' Have each parallel thread identify itself.' write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' (If the program is compiled for sequential' write ( *, '(a)' ) ' execution, no values will appear.)' !$omp parallel !$write ( *, '(i3)' ) omp_get_thread_num ( ) !$omp end parallel write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'ROLLCALL' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop end subroutine timestamp ( ) ! !******************************************************************************* ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! ! Example: ! ! May 31 2001 9:45:54.872 AM ! ! Modified: ! ! 31 May 2001 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! character ( len = 8 ) ampm integer d character ( len = 8 ) date 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 character ( len = 10 ) time integer values(8) integer y character ( len = 5 ) zone ! call date_and_time ( date, time, zone, 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 ( *, '(a,1x,i2,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & trim ( month(m) ), d, y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end