support_functions_procedures Submodule

Contains the implementations of various support routines


Uses


Subroutines

pure recursive subroutine mergeSort(buffer, start, end, array)

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(inout), dimension(:) :: buffer
integer(kind=ik), intent(in) :: start
integer(kind=ik), intent(in) :: end
integer(kind=ik), intent(inout), dimension(:) :: array

pure subroutine merge(inputArray, start, mid, end, outputArray)

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(inout), dimension(:) :: inputArray
integer(kind=ik), intent(in) :: start
integer(kind=ik), intent(in) :: mid
integer(kind=ik), intent(in) :: end
integer(kind=ik), intent(inout), dimension(:) :: outputArray

Module Functions

pure module function findIndicesMatrix(mask) result(indices)

Find locations of .true. values in logical mask of rank 2

Arguments

Type IntentOptional Attributes Name
logical, intent(in), dimension(:,:) :: mask

Return Value integer(kind=ik), dimension(:,:), allocatable

pure module function findIndicesVector(mask) result(indices)

Find locations of .true. values in logical mask of rank 1

Arguments

Type IntentOptional Attributes Name
logical, intent(in), dimension(:) :: mask

Return Value integer(kind=ik), dimension(:), allocatable

pure module function allCombinations(array) result(res)

Convert IntArray(:) vector into a 2D array of shape (size(IntArray),:) containing all possible combination of IntArray(:)%entries. Works only for sizes 1 and 3

Arguments

Type IntentOptional Attributes Name
type(IntArray), intent(in), dimension(:) :: array

Return Value integer(kind=ik), dimension(:,:), allocatable

pure module function findNearestPointsInArray(array, point) result(pair)

Finds indices of two of the values nearest to a point in a monotonic array

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: array
real(kind=rk), intent(in) :: point

Return Value integer(kind=ik), dimension(2)

elemental module function expInt1(val) result(res)

Allan and Hastings approximation of E1 exponential integral, with coefficients from routine in: Shanjie Zhang, Jianming Jin, Computation of Special Functions, Wiley, 1996, ISBN: 0-471-11963-6, LC: QA351.C45.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: val

Return Value real(kind=rk)

pure module function removeDupeInts(array) result(uniques)

Returns sorted array of unique integer values

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in), dimension(:) :: array(:)

Return Value integer(kind=ik), dimension(:), allocatable

pure module function withinBounds(array, lowerBound, upperBound) result(res)

Returns map array >= lowerBound .and. array <= upperBound

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in), dimension(:) :: array
integer(kind=ik), intent(in) :: lowerBound
integer(kind=ik), intent(in) :: upperBound

Return Value logical, allocatable, dimension(:)

pure module function flatTensorProduct(array1, array2, array3) result(res)

Takes a 3-fold tensor product of rank-1 real arrays and flattens it

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: array1
real(kind=rk), intent(in), dimension(:) :: array2
real(kind=rk), intent(in), dimension(:) :: array3

Return Value real(kind=rk), dimension(:), allocatable

pure module function jaggedArray(array, mask) result(res)

Takes rank-2 array and optional mask and produces rank-1 array of realArrays - a jagged array - by masking the first dimension

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:,:) :: array
logical, intent(in), optional, dimension(:,:) :: mask

Return Value type(RealArray), dimension(:), allocatable

pure module function allPl(points, maxL) result(res)

Return rank-2 array of Legendre polynomials evaluated at given points. Result shape is (size(points),0:maxL). Uses recursion formula.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: points
integer(kind=ik), intent(in) :: maxL

Return Value real(kind=rk), allocatable, dimension(:,:)

pure elemental module function removeNameIntArray(input) result(output)

Remove name from named integer array and return IntArray

Arguments

Type IntentOptional Attributes Name
type(NamedIntegerArray), intent(in) :: input

Return Value type(IntArray)

pure elemental module function removeNameRealArray(input) result(output)

Remove name from named real array and return RealArray

Arguments

Type IntentOptional Attributes Name
type(NamedRealArray), intent(in) :: input

Return Value type(RealArray)

pure elemental module function removeNameLogicalArray(input) result(output)

Remove name from named logical array and return LogicalArray

Arguments

Type IntentOptional Attributes Name
type(NamedLogicalArray), intent(in) :: input

Return Value type(LogicalArray)

pure module function shiftedFlatTensorProduct(array1, array2, shiftArray, power) result(res)

Takes 2 arrays and produces a flattened tensor product, such that array1's dimension is the inner dimension. If present, shift array should conform to array2 and will be added to array1 as the product is taken The shifted array1 is then optionally raised to a power.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: array1
real(kind=rk), intent(in), dimension(:) :: array2
real(kind=rk), intent(in), optional, dimension(:) :: shiftArray
real(kind=rk), intent(in), optional :: power

Return Value real(kind=rk), dimension(:), allocatable

pure module function triangularIntArray(dim, lower) result(res)

Returns upper or lower triangular array pattern as IntArrays with dimension dim

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in) :: dim
logical, intent(in), optional :: lower

Return Value type(IntArray), dimension(:), allocatable