https://github.com/gha3mi/fortime
ForTime - A Fortran library for measuring elapsed time, DATE_AND_TIME time, CPU time, OMP time and MPI time.
https://github.com/gha3mi/fortime
cpu-time date-and-time debug elapsed-time fortran fortran-package-manager mpi openmp profile time timer
Last synced: 8 months ago
JSON representation
ForTime - A Fortran library for measuring elapsed time, DATE_AND_TIME time, CPU time, OMP time and MPI time.
- Host: GitHub
- URL: https://github.com/gha3mi/fortime
- Owner: gha3mi
- License: bsd-3-clause
- Created: 2023-06-22T07:41:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-08T13:10:59.000Z (over 1 year ago)
- Last Synced: 2025-02-06T04:51:27.271Z (9 months ago)
- Topics: cpu-time, date-and-time, debug, elapsed-time, fortran, fortran-package-manager, mpi, openmp, profile, time, timer
- Language: Fortran
- Homepage: https://gha3mi.github.io/fortime/
- Size: 1.65 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/gha3mi/fortime)
[](https://github.com/gha3mi/fortime/releases/latest)
[](https://gha3mi.github.io/fortime/)
[](https://github.com/gha3mi/fortime/blob/main/LICENSE)
[](https://github.com/gha3mi/fortime/actions/workflows/CI_test.yml)
**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:
```toml
[dependencies]
fortime = {git="https://github.com/gha3mi/fortime.git"}
```
## Usage
### Measuring elapsed time (system_clock)
```fortran
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)
```fortran
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)
```fortran
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)
```fortran
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)
```fortran
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](https://github.com/gha3mi/fordebug).
## Running Examples and Tests
### Clone the Repository
First, clone the `ForTime` repository from GitHub and navigate to the project directory:
```shell
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:
```shell
fpm run --example --compiler
```
Replace `` with the name of the example file (excluding the `.f90` extension) and `` 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:
```shell
fpm test --compiler
```
Replace `` with the name of your Fortran compiler.
## Documentation
The most up-to-date API documentation for the master branch is available
[here](https://gha3mi.github.io/fortime/).
To generate the API documentation for `ForTime` using
[ford](https://github.com/Fortran-FOSS-Programmers/ford) run the following
command:
```shell
ford ford.yml
```
## Contributing
Contributions to `ForTime` are welcome! If you find any issues or would like to suggest improvements, please open an issue.