realArrEq Function

public function realArrEq(res, tgt) result(comp)

Test if two real arrays are exactly equal. Arrays must be of the same length and have the same values in the same positions. Uses epsilon value to account for floating point error.

Arguments

Type IntentOptional AttributesName
real(kind=wp), intent(in), dimension(:):: res

Real value result being tested.

real(kind=wp), intent(in), dimension(:):: tgt

Target real value to compare result to.

Return Value logical


Contents

Source Code


Source Code

function realArrEq(res, tgt) result(comp)
    !! Test if two real arrays are _exactly_ equal. Arrays must be of the
    !! same length and have the same values in the same positions. Uses
    !! epsilon value to account for floating point error.

    real(kind=wp), dimension(:), intent(in) :: res
        !! Real value result being tested. 
    real(kind=wp), dimension(:), intent(in) :: tgt
        !! Target real value to compare result to.
    logical :: comp

    if (size(res) /= size(tgt)) then
        comp = .false.
        return
    end if

    comp = all(abs(res-tgt) < eps)
end function realArrEq