ForTime: A Fortran library for measuring elapsed time, DATE_AND_TIME time, CPU time, OMP time and MPI time.
If you want to use ForTime
as a dependency in your own fpm project,
you can easily include it by adding the following line to your fpm.toml
file:
[dependencies]
fortime = {git="https://github.com/gha3mi/fortime.git"}
use fortime
type(timer) :: t
call t%timer_start()
! Your code or section to be timed
call t%timer_stop(nloops, message, print, color) ! nloops, message, print and color are optional
call t%timer_write(file_name) ! Optionally, write the result to a file
use fortime
type(timer) :: t
call t%dtimer_start()
! Your code or section to be timed
call t%dtimer_stop(nloops, message, print, color) ! nloops, message, print and color are optional
call t%dtimer_write(file_name) ! Optionally, write the result to a file
use fortime
type(timer) :: t
call t%ctimer_start()
! Your code or section to be timed
call t%ctimer_stop(nloops, message, print, color) ! nloops, message, print and color are optional
call t%ctimer_write(file_name) ! Optionally, write the result to a file
use fortime
type(timer) :: t
call t%otimer_start()
! Your code or section to be timed
call t%otimer_stop(nloops, message, print, color) ! nloops, message, print and color are optional
call t%otimer_write(file_name) ! Optionally, write the result to a file
Note: Compile with the -DUSE_OMP
option when using the OpenMP timer.
use fortime
type(timer) :: t
call t%mtimer_start()
! Your code or section to be timed
call t%mtimer_stop(nloops, message, print, color) ! nloops, message, print and color are optional
call t%mtimer_write(file_name) ! Optionally, write the result to a file
Note: Compile with the -DUSE_MPI
option when using the MPI timer.
To measure elapsed time within a pure procedure, use ForDebug.
First, clone the ForTime
repository from GitHub and navigate to the project directory:
git clone https://github.com/gha3mi/fortime.git
cd fortime
To run a specific example from the example
directory using your preferred Fortran compiler, use the following command:
fpm run --example <example_name> --compiler <compiler>
Replace <example_name>
with the name of the example file (excluding the .f90
extension) and <compiler>
with the name of your Fortran compiler (e.g., ifx
, ifort
, gfortran
, nvfortran
).
To execute tests, use the following command with your chosen compiler:
fpm test --compiler <compiler>
Replace <compiler>
with the name of your Fortran compiler.
The most up-to-date API documentation for the master branch is available
here.
To generate the API documentation for ForTime
using
ford run the following
command:
ford ford.yml
Contributions to ForTime
are welcome! If you find any issues or would like to suggest improvements, please open an issue.