From a88f39440e5a965f45d02a689c42c7ca3c2104a4 Mon Sep 17 00:00:00 2001 From: Seyed Ali Ghasemi Date: Sun, 23 Jul 2023 11:30:56 +0200 Subject: [PATCH] Update README, ford, fpm, example. --- README.md | 138 ++++++++++++++----------- VERSION | 1 + elapsed_times_test1 | 3 - example-gf.rsp | 1 + example-ift.rsp | 1 + example-ifx.rsp | 1 + example-nv.rsp | 1 + test/test1.f90 => example/example1.f90 | 8 +- example/example1_elapsed_times | 1 + ford.yml | 6 +- fpm.toml | 33 +++--- gfortran.rsp | 2 - ifort.rsp | 2 - ifx.rsp | 2 - nvfortran.rsp | 2 - 15 files changed, 111 insertions(+), 91 deletions(-) create mode 100644 VERSION delete mode 100644 elapsed_times_test1 create mode 100644 example-gf.rsp create mode 100644 example-ift.rsp create mode 100644 example-ifx.rsp create mode 100644 example-nv.rsp rename test/test1.f90 => example/example1.f90 (65%) create mode 100644 example/example1_elapsed_times delete mode 100644 gfortran.rsp delete mode 100644 ifort.rsp delete mode 100644 ifx.rsp delete mode 100644 nvfortran.rsp diff --git a/README.md b/README.md index f1aa370..68d0e91 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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. @@ -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 @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6c6aa7c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file diff --git a/elapsed_times_test1 b/elapsed_times_test1 deleted file mode 100644 index 5757548..0000000 --- a/elapsed_times_test1 +++ /dev/null @@ -1,3 +0,0 @@ -2.000333 -2.000367 -2.000333 diff --git a/example-gf.rsp b/example-gf.rsp new file mode 100644 index 0000000..2cb801a --- /dev/null +++ b/example-gf.rsp @@ -0,0 +1 @@ +options run --example --all --compiler gfortran --flag "-Wno-line-truncation -Ofast -march=native" \ No newline at end of file diff --git a/example-ift.rsp b/example-ift.rsp new file mode 100644 index 0000000..415f047 --- /dev/null +++ b/example-ift.rsp @@ -0,0 +1 @@ +options run --example --all --compiler ifort --flag "-Ofast -xHost -mtune=native" \ No newline at end of file diff --git a/example-ifx.rsp b/example-ifx.rsp new file mode 100644 index 0000000..4e39473 --- /dev/null +++ b/example-ifx.rsp @@ -0,0 +1 @@ +options run --example --all --compiler ifx --flag "-Ofast -xHost -mtune=native" \ No newline at end of file diff --git a/example-nv.rsp b/example-nv.rsp new file mode 100644 index 0000000..1f0f708 --- /dev/null +++ b/example-nv.rsp @@ -0,0 +1 @@ +options run --example --all --compiler nvfortran --flag "-O4 -mtune=native" \ No newline at end of file diff --git a/test/test1.f90 b/example/example1.f90 similarity index 65% rename from test/test1.f90 rename to example/example1.f90 index dcefc2c..11d95e2 100644 --- a/test/test1.f90 +++ b/example/example1.f90 @@ -1,4 +1,4 @@ -program test1 +program example1 use :: fortime implicit none @@ -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 \ No newline at end of file +end program example1 \ No newline at end of file diff --git a/example/example1_elapsed_times b/example/example1_elapsed_times new file mode 100644 index 0000000..ee00933 --- /dev/null +++ b/example/example1_elapsed_times @@ -0,0 +1 @@ +1.000267 diff --git a/ford.yml b/ford.yml index b6837e3..a07dbd8 100644 --- a/ford.yml +++ b/ford.yml @@ -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 @@ -15,4 +16,7 @@ display: public private protected print_creation_date: true +media_dir: ./media + +{!README.md!} diff --git a/fpm.toml b/fpm.toml index d61675b..528645f 100644 --- a/fpm.toml +++ b/fpm.toml @@ -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" diff --git a/gfortran.rsp b/gfortran.rsp deleted file mode 100644 index 04ecece..0000000 --- a/gfortran.rsp +++ /dev/null @@ -1,2 +0,0 @@ -@gfortran -options test --compiler gfortran --flag "-Wno-line-truncation -Ofast -march=native" \ No newline at end of file diff --git a/ifort.rsp b/ifort.rsp deleted file mode 100644 index 00e04ea..0000000 --- a/ifort.rsp +++ /dev/null @@ -1,2 +0,0 @@ -@ifort -options test --compiler ifort --flag "-Ofast -xHost -mtune=native" \ No newline at end of file diff --git a/ifx.rsp b/ifx.rsp deleted file mode 100644 index bd79064..0000000 --- a/ifx.rsp +++ /dev/null @@ -1,2 +0,0 @@ -@ifx -options test --compiler ifx --flag "-Ofast -xHost -mtune=native" \ No newline at end of file diff --git a/nvfortran.rsp b/nvfortran.rsp deleted file mode 100644 index 1a124be..0000000 --- a/nvfortran.rsp +++ /dev/null @@ -1,2 +0,0 @@ -@nvfortran -options test --compiler nvfortran --flag "-O4 -mtune=native" \ No newline at end of file