A function with the same name as an user-defined operator confuses the compiler, and it issues a nonsense error. Example:
module func
implicit none
interface operator(.isclose.)
module procedure :: isclose_for_operator
end interface
contains
elemental function isclose_for_operator(a,b) result(res)
real, intent(in) :: a, b
logical :: res
res = abs(a-b) < 1.0
end function isclose_for_operator
! possibly unrelated function that just happens to have the same name as the operator
elemental function isclose(a,b,atol,rtol) result(res)
real, intent(in) :: a, b
real, intent(in) :: atol, rtol
logical :: res
res = abs(a-b) <= max(rtol*max(abs(a),abs(b)),atol)
end function isclose
end module func
program test
use func, only: operator(.isclose.)
implicit none
real :: A(3), B(3)
A = [1.0, 2.0, 3.0]
B = [1.1, 2.1, 3.1]
write(*,*) all(A == B)
write(*,*) all(A < B)
write(*,*) all(A .isclose. B)
end program test
When compiling:
$ nvfortran test.f90
NVFORTRAN-S-0074-Illegal number or type of arguments to all - keyword argument mask (test.f90: 37)
0 inform, 0 warnings, 1 severes, 0 fatal for test
$ nvfortran --version
nvfortran 21.7-0 64-bit target on x86-64 Linux -tp skylake
NVIDIA Compilers and Tools
Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
The problem is isclose and .isclose. have similar names, rename either of them and the error goes away. But I’m importing only operator(.isclose.), so there should be no ambiguity.