!****h* /stream_aux ! NAME ! stream_aux ! COPYRIGHT ! Copyright (c) 2005 Janne Blomqvist ! Permission is hereby granted, free of charge, to any person obtaining ! a copy of this software and associated documentation files (the ! "Software"), to deal in the Software without restriction, including ! without limitation the rights to use, copy, modify, merge, publish, ! distribute, sublicense, and/or sell copies of the Software, and to ! permit persons to whom the Software is furnished to do so, subject to ! the following conditions: ! ! The above copyright notice and this permission notice shall be ! included in all copies or substantial portions of the Software. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ! LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ! OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! PURPOSE ! STREAM auxiliary functions, implemented using portable ! Fortran 90+ intrinsics. !**** !****f* stream_aux/realsize ! PURPOSE ! Calculate how many bytes of storage a double precision ! number requires. !**** function realsize() implicit none integer :: size, ioli, ioldp, realsize size = 0 size = bit_size (size) inquire (iolength=ioli) size inquire (iolength=ioldp) 1.0d0 realsize = ioldp / ioli * size / 8 write (*,FMT='(a)') & '----------------------------------------------' write (*,FMT='(1x,i2,a)') realsize, ' bytes per double precision word.' write (*, '(a)') & '----------------------------------------------' end function realsize !****f* stream_aux/checktick ! PURPOSE ! Determine the granularity of the wall clock in microseconds ! between ticks. !**** function checktick() implicit none integer :: count_rate, checktick ! Clockrate in ticks per second of the wall clock. call system_clock (count_rate = count_rate) checktick = 1000000 / count_rate end function checktick !****f* stream_aux/mysecond ! PURPOSE ! Return a double precision number representing the wallclock time. !**** function mysecond() implicit none integer, parameter :: dp = kind (1.0d0) real(dp) :: mysecond, rc, rr integer :: count, rate call system_clock (count = count, count_rate = rate) rc = real (count, dp) rr = real (rate, dp) mysecond = rc / rr end function mysecond !!$program test !!$ implicit none !!$ integer, parameter :: dp = kind (1.0d0) !!$ integer :: realsize, checktick, i !!$ real(dp) :: mysecond !!$ i = realsize() !!$ print *, 'Granularity is ', checktick(), ' microseconds betweem ticks.' !!$ print *, mysecond() !!$end program test