-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module for handling version information of stdlib (#579)
Co-authored-by: Ivan Pribec <[email protected]> Co-authored-by: Carlos Une <[email protected]> Co-authored-by: Jeremie Vandenplas <[email protected]>
- Loading branch information
1 parent
57c41f9
commit 3af3259
Showing
13 changed files
with
168 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Version information | ||
--- | ||
|
||
# The `stdlib_version` module | ||
|
||
[TOC] | ||
|
||
## Introduction | ||
|
||
The `stdlib_version` module contains the version of the standard library. | ||
The version information can be used as a compile time constant or retrieved from a getter function at runtime. | ||
In case the standard library is dynamically linked, the version number retrieved from the getter might mismatch the compile time constants provided from the version built against. | ||
Therefore, it is recommended to retrieve the version information always at runtime. | ||
|
||
|
||
## Constants provided by `stdlib_version` | ||
|
||
### `stdlib_version_string` | ||
|
||
String constant representing the version number. | ||
|
||
### `stdlib_version_compact` | ||
|
||
Compact representation of the version string following the scheme: | ||
major * 10000 + minor * 100 + patch. | ||
|
||
|
||
### `get_stdlib_version` | ||
|
||
#### Status | ||
|
||
Experimental | ||
|
||
#### Description | ||
|
||
Getter function to retrieve version information | ||
|
||
#### Syntax | ||
|
||
`res = [[stdlib_version(module):get_stdlib_version(function)]] ([major], [minor], [patch], [string])` | ||
|
||
#### Class | ||
|
||
Pure subroutine. | ||
|
||
#### Argument | ||
|
||
`major`: shall be an intrinsic integer type. It is an optional, `intent(out)` argument. | ||
`minor`: shall be an intrinsic integer type. It is an optional, `intent(out)` argument. | ||
`patch`: shall be an intrinsic integer type. It is an optional, `intent(out)` argument. | ||
`string`: shall be a deferred length character type. It is an optional, `intent(out)` argument. | ||
|
||
#### Example | ||
|
||
```fortran | ||
program demo_version | ||
use stdlib_version, only : get_stdlib_version | ||
implicit none | ||
character(len=:), allocatable :: version | ||
call get_stdlib_version(string=version) | ||
print '(a)', version | ||
end program demo_version | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
! SPDX-Identifier: MIT | ||
|
||
#:include "common.fypp" | ||
|
||
!> Version information on stdlib | ||
module stdlib_version | ||
implicit none | ||
private | ||
|
||
public :: get_stdlib_version | ||
public :: stdlib_version_string, stdlib_version_compact | ||
|
||
|
||
!> String representation of the standard library version | ||
character(len=*), parameter :: stdlib_version_string = "${PROJECT_VERSION}$" | ||
|
||
!> Major version number of the above standard library version | ||
integer, parameter :: stdlib_major = ${PROJECT_VERSION_MAJOR}$ | ||
|
||
!> Minor version number of the above standard library version | ||
integer, parameter :: stdlib_minor = ${PROJECT_VERSION_MINOR}$ | ||
|
||
!> Patch version number of the above standard library version | ||
integer, parameter :: stdlib_patch = ${PROJECT_VERSION_PATCH}$ | ||
|
||
!> Compact numeric representation of the standard library version | ||
integer, parameter :: stdlib_version_compact = & | ||
& stdlib_major*10000 + stdlib_minor*100 + stdlib_patch | ||
|
||
|
||
contains | ||
|
||
|
||
!> Getter function to retrieve standard library version | ||
pure subroutine get_stdlib_version(major, minor, patch, string) | ||
|
||
!> Major version number of the standard library version | ||
integer, intent(out), optional :: major | ||
|
||
!> Minor version number of the standard library version | ||
integer, intent(out), optional :: minor | ||
|
||
!> Patch version number of the standard library version | ||
integer, intent(out), optional :: patch | ||
|
||
!> String representation of the standard library version | ||
character(len=:), allocatable, intent(out), optional :: string | ||
|
||
if (present(major)) then | ||
major = stdlib_major | ||
end if | ||
if (present(minor)) then | ||
minor = stdlib_minor | ||
end if | ||
if (present(patch)) then | ||
patch = stdlib_patch | ||
end if | ||
if (present(string)) then | ||
string = stdlib_version_string | ||
end if | ||
|
||
end subroutine get_stdlib_version | ||
|
||
|
||
end module stdlib_version |