Utility routines.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | max_size_for_insertion_sort | = | 20 |
max size for using insertion sort. |
Add elements to the integer vector in chunks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout), | dimension(:), allocatable | :: | vec | ||
integer, | intent(inout) | :: | n |
counter for last element added to |
||
integer, | intent(in) | :: | chunk_size |
allocate |
||
integer, | intent(in), | optional | :: | val |
the value to add to |
|
logical, | intent(in), | optional | :: | finished |
set to true to return |
Add elements to the real vector in chunks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:), allocatable | :: | vec | ||
integer, | intent(inout) | :: | n |
counter for last element added to |
||
integer, | intent(in) | :: | chunk_size |
allocate |
||
real(kind=wp), | intent(in), | optional | :: | val |
the value to add to |
|
logical, | intent(in), | optional | :: | finished |
set to true to return |
Returns only the unique elements of the vector (sorted in ascending order).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(:) | :: | vec |
a vector of integers |
|
integer, | intent(in) | :: | chunk_size |
chunk size for adding to arrays |
unique elements of ivec
Returns only the unique elements of the vector (sorted in ascending order).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | vec |
a vector of integers |
|
integer, | intent(in) | :: | chunk_size |
chunk size for adding to arrays |
unique elements of ivec
Sorts an integer array ivec
in increasing order.
Uses a basic recursive quicksort
(with insertion sort for partitions with 20 elements).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout), | dimension(:) | :: | ivec |
Sorts a real array ivec
in increasing order.
Uses a basic recursive quicksort
(with insertion sort for partitions with 20 elements).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | ivec |
Swap two integer values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | i1 | |||
integer, | intent(inout) | :: | i2 |
Swap two integer values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout) | :: | i1 | |||
real(kind=wp), | intent(inout) | :: | i2 |
Returns only the unique elements of the vector (sorted in ascending order).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(:) | :: | vec |
a vector of integers |
|
integer, | intent(in) | :: | chunk_size |
chunk size for adding to arrays |
unique elements of ivec
Returns only the unique elements of the vector (sorted in ascending order).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | vec |
a vector of integers |
|
integer, | intent(in) | :: | chunk_size |
chunk size for adding to arrays |
unique elements of ivec
Returns true if the values in the array are the same (to within the specified absolute tolerance).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | vals |
a set of values |
|
real(kind=wp), | intent(in) | :: | tol |
a positive tolerance value |
true if they are equal within the tolerance
Returns a set of slightly randomized equally-spaced points that divide an interval.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | num_points |
the number of points in the interval |
the resultant vector
Add elements to the integer vector in chunks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout), | dimension(:), allocatable | :: | vec | ||
integer, | intent(inout) | :: | n |
counter for last element added to |
||
integer, | intent(in) | :: | chunk_size |
allocate |
||
integer, | intent(in), | optional | :: | val |
the value to add to |
|
logical, | intent(in), | optional | :: | finished |
set to true to return |
Add elements to the real vector in chunks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:), allocatable | :: | vec | ||
integer, | intent(inout) | :: | n |
counter for last element added to |
||
integer, | intent(in) | :: | chunk_size |
allocate |
||
real(kind=wp), | intent(in), | optional | :: | val |
the value to add to |
|
logical, | intent(in), | optional | :: | finished |
set to true to return |
Sorts an integer array ivec
in increasing order.
Uses a basic recursive quicksort
(with insertion sort for partitions with 20 elements).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout), | dimension(:) | :: | ivec |
Sorts a real array ivec
in increasing order.
Uses a basic recursive quicksort
(with insertion sort for partitions with 20 elements).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | ivec |
Swap two integer values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | i1 | |||
integer, | intent(inout) | :: | i2 |
Swap two integer values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout) | :: | i1 | |||
real(kind=wp), | intent(inout) | :: | i2 |