StopWatch is a Fortran 90 module for measuring execution time of program segments. Measuring execution time is an important part of software development, especially for benchmarking and performance tuning. Unfortunately, Fortran has never supported the measurement of execution time, except through non-portable vendor extensions. Fortran 90 introduced a subroutine for measuring wall clock time, but overlooked the more desirable CPU time. It is anticipated that the next Fortran standard, Fortran 95, will include a CPU time subroutine, but it does not break the time into ``user'' and ``system'' time like many CPU clock routines, and the standard still does not guarantee that either the wall clock or CPU clock routines will necessarily contain clock information. Moreover, direct use of the routines can be unwieldy, requiring multiple variables to keep track of returned values, differencing the returned values, and conversion of the values to useful units.
StopWatch is designed to be a portable, easy-to-use means of measuring execution time. It supports the wall clock, CPU clock, a breakdown of the CPU clock into user and system times, and returns all times in seconds. It provides a simple means of determining which clocks are available, and the precision of those clocks. It is written in a style that allows it to be used with the subset languages ELF90 and F, as well as full Fortran 90 and Fortran 95 compilers.
StopWatch is used by instrumenting your code with subroutine calls that mimic the operation of a stop watch. The primary routines are start_watch, stop_watch, reset_watch, read_watch and print_watch. StopWatch supports multiple watches, and provides the concept of watch groups to allow functions to operate on multiple watches simultaneously.