Skip to content
/ fortime Public

ForTime - A Fortran library for measuring elapsed time, DATE_AND_TIME time, CPU time, OMP time and MPI time.

License

Notifications You must be signed in to change notification settings

gha3mi/fortime

Repository files navigation

GitHub Version Documentation License Build

ForTime: A Fortran library for measuring elapsed time, DATE_AND_TIME time, CPU time, OMP time and MPI time.

fpm dependency

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"}

Usage

Measuring elapsed time (system_clock)

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

Measuring elapsed time (date_and_time)

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

Measuring CPU time (cpu_time)

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

Measuring OpenMP time (omp_get_wtime)

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.

Measuring MPI time (mpi_wtime)

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.

Running Examples and Tests

Clone the Repository

First, clone the ForTime repository from GitHub and navigate to the project directory:

git clone https://github.com/gha3mi/fortime.git
cd fortime

Running Examples

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).

Running Tests

To execute tests, use the following command with your chosen compiler:

fpm test --compiler <compiler>

Replace <compiler> with the name of your Fortran compiler.

Documentation

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

Contributing

Contributions to ForTime are welcome! If you find any issues or would like to suggest improvements, please open an issue.