Skip to content

Commit

Permalink
Update README, ford, fpm, example.
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed Jul 23, 2023
1 parent 669e0ff commit a88f394
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 91 deletions.
138 changes: 78 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,60 @@

**ForTime**: This module provides a timer object for measuring elapsed time. It includes procedures for starting and stopping the timer, as well as calculating and printing the elapsed time in seconds.

-----
## Table of Contents

- [](#)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [fpm](#fpm)
- [Type: `timer`](#type-timer)
- [Procedures:](#procedures)
- [Usage:](#usage)
- [Tests](#tests)
- [Example:](#example)
- [Documentation](#documentation)
- [Contributing](#contributing)
-----


## Installation

### fpm
ForTime can be cloned and then built using [fpm](https://github.com/fortran-lang/fpm), following the instructions provided in the documentation available on Fortran Package Manager.

```bash
git clone https://github.com/gha3mi/fortime.git
cd fortime
fpm install --prefix .
```
## How to Use ForTime

### Adding ForTime as an fpm Dependency

Or you can easily include this package as a dependency in your `fpm.toml` file.
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"}
```

-----
### Installation of ForTime Library

To use ForTime, follow the steps below:

- **Reuirements:**

Fortran Compiler

- **Clone the repository:**

You can clone the ForTime repository from GitHub using the following command:

```shell
git clone https://github.com/gha3mi/fortime.git
```

```shell
cd fortime
```

- **Build using the Fortran Package Manager (fpm):**

ForTime can be built using [fpm](https://github.com/fortran-lang/fpm).
Make sure you have fpm installed, and then execute the following command:

**GNU Fortran Compiler (gfortran)**

```shell
fpm install --prefix . --compiler gfortran
```

**Intel Fortran Compiler (ifort)**

```shell
fpm install --prefix . --compiler ifort
```

**Intel Fortran Compiler (ifx)**

```shell
fpm install --prefix . --compiler ifx
```

## Type: `timer`
A type representing a timer object with the following components:
Expand All @@ -53,7 +71,6 @@ A type representing a timer object with the following components:
- `timer_start(this)`: Starts the timer by recording the current processor clock value. This value is used to calculate the elapsed time later.
- `timer_stop(this, nloops, message)`: Stops the timer and calculates the elapsed time. Optionally, it can print a message along with the elapsed time.
- `timer_write(this, file_name)`: Writes the elapsed time to a file.
-----

## Usage:
1. Include the `fortime` module in your program.
Expand All @@ -62,34 +79,36 @@ A type representing a timer object with the following components:
4. Perform the desired operations.
5. Call the `timer_stop` procedure to stop the timer and calculate the elapsed time.
6. Optionally, call the `timer_write` procedure to write the elapsed time to a file.
-----

## Tests
## Running Examples Using fpm

The `tests` directory contains test programs to verify the functionality of the `fortime` module. To run the tests using `fpm`, you can use response files for specific compilers:
To run the examples using `fpm`, you can use response files for specific compilers:

- For Intel Fortran Compiler (ifort):
```bash
fpm @ifort
```
**Intel Fortran Compiler (ifort)**

- For Intel Fortran Compiler (ifx):
```bash
fpm @ifx
```
```bash
fpm @example-ift
```

- For NVIDIA Compiler (nvfortran):
```bash
fpm @nvidia
```
**Intel Fortran Compiler (ifx)**

- For GNU Fortran Compiler (gfortran):
```bash
fpm @gfortran
```
-----
```bash
fpm @example-ifx
```

## Example:
**NVIDIA Compiler (nvfortran)**

```bash
fpm @example-nv
```

**GNU Fortran Compiler (gfortran)**

```bash
fpm @example-gf
```

## Example
```fortran
program example
implicit none
Expand All @@ -109,17 +128,16 @@ program example
end program example
```
-----

## API Documentation

## Documentation
To generate the documentation for the `fortime` module using [ford](https://github.com/Fortran-FOSS-Programmers/ford) run the following command:
```bash
ford project.yml
```
To generate the API documentation for the `ForTime` module 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 or submit a pull request.
Contributions to `ForTime` are welcome! If you find any issues or would like to suggest improvements, please open an issue or submit a pull request.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
3 changes: 0 additions & 3 deletions elapsed_times_test1

This file was deleted.

1 change: 1 addition & 0 deletions example-gf.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
options run --example --all --compiler gfortran --flag "-Wno-line-truncation -Ofast -march=native"
1 change: 1 addition & 0 deletions example-ift.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
options run --example --all --compiler ifort --flag "-Ofast -xHost -mtune=native"
1 change: 1 addition & 0 deletions example-ifx.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
options run --example --all --compiler ifx --flag "-Ofast -xHost -mtune=native"
1 change: 1 addition & 0 deletions example-nv.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
options run --example --all --compiler nvfortran --flag "-O4 -mtune=native"
8 changes: 4 additions & 4 deletions test/test1.f90 → example/example1.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
program test1
program example1

use :: fortime
implicit none
Expand All @@ -10,10 +10,10 @@ program test1
call t%timer_start()

do i = 1,n
call sleep(2)
call sleep(1)
end do

call t%timer_stop(nloops = n, message = 'elapsed time:')
call t%timer_write('elapsed_times_test1')
call t%timer_write('example/example1_elapsed_times')

end program test1
end program example1
1 change: 1 addition & 0 deletions example/example1_elapsed_times
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.000267
6 changes: 5 additions & 1 deletion ford.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
project: fortime
version: v0.1.0
version: {!VERSION!}
year: 2023
project_github: https://github.com/gha3mi/fortime
author: Seyed Ali Ghasemi
email: info@gha3mi.com
github: https://github.com/gha3mi
src_dir: ./src
./test
output_dir: ./doc
source: true
graph: true
Expand All @@ -15,4 +16,7 @@ display: public
private
protected
print_creation_date: true
media_dir: ./media

{!README.md!}

33 changes: 18 additions & 15 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name = "fortime"
version = "0.1.0"
license = "license"
author = "Seyed Ali Ghasemi"
name = "fortime"
version = "VERSION"
author = "Seyed Ali Ghasemi"
maintainer = "info@gha3mi.com"
copyright = "Copyright 2023, Seyed Ali Ghasemi"
copyright = "Copyright 2023, Seyed Ali Ghasemi"
license = "LICENSE"

[build]
auto-executables = false
auto-tests = false
auto-examples = false
module-naming = false
auto-tests = false
auto-examples = false
module-naming = false

[install]
library = false
library = true

[fortran]
implicit-typing = false
implicit-typing = false
implicit-external = false
source-form = "free"
source-form = "free"

[[test]]
name="test1"
source-dir="test"
main="test1.f90"
[[example]]
name = "example1"
source-dir = "example"
main = "example1.f90"
2 changes: 0 additions & 2 deletions gfortran.rsp

This file was deleted.

2 changes: 0 additions & 2 deletions ifort.rsp

This file was deleted.

2 changes: 0 additions & 2 deletions ifx.rsp

This file was deleted.

2 changes: 0 additions & 2 deletions nvfortran.rsp

This file was deleted.

0 comments on commit a88f394

Please sign in to comment.