Basic timing routines for Fortran programs. As far as I can tell, all of the code is F2003 compliant.
An example is provided in main.f90 in this repository but the basic outline follows.
program main
use, intrinsic :: iso_fortran_env, only : stdout=>output_unit
use ftime
IMPLICIT NONE
call ftime_init()
call ftime_start('my_timer')
! ... do something ...
call ftime_stop('my_timer')
call ftime_print(stdout)
call ftime_cleanup()
endprogram mainThe source code in mod_ftime.f90 contains Doxygen style comments. Here is also a brief description. NOTE that all subroutines and function accept an optional error output parameter that will return a nonzero error code if an error is encountered.
ftime_initOptional. Stores the clock count rate but this will also be evaluated later if necessary.ftime_startStart a timer. Accepts a string as a timer name.ftime_stopStop a timer. Accepts a string as a timer name.ftime_timeFunction. Returns the elapsed time (in seconds) on a given timer. Note: does not stop a running timer.ftime_printStops all timers and prints elapsed time (in seconds).ftime_cleanupOptional. Deallocates used memory.
The code here is F2003 compliant and can should be usable with any standard-compliant compiler. Included in this repository is a Makefile and an example program in main.f90. The example can be compiled and ran with the following:
make && ./main.x
or in "debug-mode" with
METHOD=dbg make && ./main.x