next up previous contents
Next: Obtaining and Compiling Up: M_StopWatch User's Guide Previous: Introduction

Quick Start

This section provides just enough information to start using the basic features of M_StopWatch. If you run into trouble or want to learn about the advanced features, read the rest of the M_StopWatch User's Guide and the man pages.

1.
In each program unit that calls a M_StopWatch subroutine, insert the statement
      use M_stopwatch
      
2.
Declare one or more variables to be of type watchtype, for example
      type (watchtype) w
      
3.
Instrument your code as appropriate with subroutine calls:
      call create_watch(w)
      call start_watch(w)
      call stop_watch(w)
      call reset_watch(w)
      call print_watch(w)
      call read_watch(val,w,s)
      call destroy_watch(w)
    
where s in read_watch is one of the character strings 'cpu', 'user', 'sys', or 'wall', depending on what clock you want to read, and val is a real variable (of default kind) in which the clock value is returned.

   ! This program illustrates the simplest use of M_StopWatch
   program simple
   use M_stopwatch         ! You must have the "use" statement in each program unit
   implicit none
   type (watchtype) :: w   ! This declares w to be a watch
   
   call create_watch(w)    ! Watches must be created before they are used
   call start_watch(w)     ! This starts the watch
   
   ! code to be timed would be located here
   
   call stop_watch(w)      ! This stops the watch
   call print_watch(w)     ! This prints the measured time
   call destroy_watch(w)   ! Always destroy the watches to free up memory
   
   stop
   end program simple



william.mitchell@nist.gov