-
Notifications
You must be signed in to change notification settings - Fork 191
WIP: Addition of a subroutine get_other_scalar in stdlib_hashmap_wrappers #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
9a9fedb
b81e34f
e29fbd7
88e6f36
350f19b
8cb2d72
d66a3c3
05f3fe1
0afe611
1743d2c
5286c72
4d74978
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,10 @@ Procedures to manipulate `other_type` data: | |
* `get( other, value )` - extracts the contents of `other` into the | ||
`class(*)` variable `value`. | ||
|
||
* `get_other_scalar( other, value [, exists])` - extracts the content of | ||
`other` into the scalar variable `value` of a kind provided by the module | ||
`stdlib_kinds`. | ||
|
||
* `set( other, value )` - sets the content of `other` to the `class(*)` | ||
variable `value`. | ||
|
||
|
@@ -584,6 +588,75 @@ an allocatable of `class(*)`. It is an `intent(out)` argument. | |
end program demo_get | ||
``` | ||
|
||
#### `get_other_scalar` - extracts a scalar value from a derived type | ||
|
||
##### Status | ||
|
||
Experimental | ||
|
||
##### Description | ||
|
||
Extracts a scalar value from a `other_type` and stores it in the scalar variable | ||
`value`. | ||
|
||
##### Syntax | ||
|
||
`call [[stdlib_hashmap_wrappers:get_other_scalar]]( other[, value_char, | ||
value_int8, value_int16, value_int32, value_int64, value_sp, value_dp, value_csp, value_cdp, value_lk, | ||
exists] )` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I very much dislike this API. In which case do you need to retrieve both a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading it again now, I totally agree with you. I will change the code with multiple subroutines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For TOML Fortran I'm using the following |
||
|
||
##### Class | ||
|
||
Subroutine. | ||
|
||
##### Arguments | ||
|
||
`other`: shall be a scalar expression of type `other_type`. It | ||
is an `intent(in)` argument. | ||
|
||
`value_char`: shall be a scalar `character(len=:), allocatable) variable. It is an | ||
`intent(out)` `optional` argument. | ||
|
||
`value_int8`, `value_int16`, `value_int32`, `value_int64`: shall be a scalar | ||
`integer` of kind `int8`, `int16`, `int32`, `int64`, respectively. It is an | ||
`intent(out)` `optional` argument. | ||
|
||
`value_sp`, `value_dp`: shall be a scalar `real` of kind `sp`, `dp` respectively. | ||
It is an `intent(out)` `optional` argument. | ||
|
||
`value_csp`, `value_cdp`: shall be a scalar `complex` of kind `sp`, `dp` respectively. | ||
It is an `intent(out)` `optional` argument. | ||
|
||
`value_lk`: shall be a scalar `logical` of kind `lk`. It is an `intent(out)` | ||
`optional` argument. | ||
|
||
`exists`: shall be a scalar `logical`. It is an `intent(out)` `optional` | ||
argument. | ||
|
||
#### Result | ||
|
||
The provided scalar variable contains the value of the `other_type` if both are of | ||
the same type; otherwise the provided scalar variable is undefined. | ||
|
||
`exists` is `.true.` if the provided scalar variable and the value of the | ||
other_type are of the same type. Otherwise, `exists` is `.false.` | ||
|
||
##### Example | ||
|
||
```fortran | ||
program demo_get_other_scalar | ||
use stdlib_hashmap_wrappers, only: & | ||
get_other_scalar, other_type, set | ||
use stdlib_kinds, only: int32 | ||
implicit none | ||
integer(int32) :: value, result | ||
type(other_type) :: other | ||
value = 15 | ||
call set( other, value ) | ||
call get_other_scalar( other, result ) | ||
print *, 'RESULT == VALUE = ', ( value == result ) | ||
jvdp1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end program demo_get | ||
``` | ||
|
||
#### `hasher_fun`- serves aa a function prototype. | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.