An illustrative code example in F90 using the performance timer API is shown below (and is also available in the examples directory from a top-level install). This example illustrates basic timer usage.
program main
use grvy
implicit none
integer :: Foo_Sleep = 1
integer :: Bar_Sleep = 2
integer :: Boo_Sleep = 3
integer :: Max_Iters = 2
integer :: i
real*8 :: igot,igot2
character :: timestring*50 = ''
call grvy_asci_time(timestring)
write(*,'(a,a26)') 'Run on: ',trim(timestring)
do i = 1,max_iters
print*,'Main iteration loop = ',i
call foo(foo_sleep)
print*,'Elapsed time since global init is: ',igot
call bar(bar_sleep)
call boo(boo_sleep)
enddo
print*,' '
print*,'Expecting ',max_iters*(foo_sleep+boo_sleep+bar_sleep),' secs '
call sleep(1)
print*,' '
print*,'Measured ',igot2-igot,' secs (expected approximately 1.0)'
print*,' '
print*,'The total elapsed time since init is: ',igot
print*,' '
print*,'Query individual timers - should match summary'
print*,' '
print*,'Query individual timer stats - should match summary'
print*,' '
print*,'Query individual timers (inclusive values)'
print*,' '
print*,'Query individual timer stats (inclusive values for boo)'
stop
end program main
subroutine foo(isleep)
use grvy
integer isleep
call sleep(isleep);
return
end subroutine foo
subroutine bar(isleep)
use grvy
integer isleep
call sleep(isleep);
return
end subroutine bar
subroutine boo(isleep)
use grvy
integer isleep
call sleep(isleep);
return
end subroutine boo