Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
27547 Discussions

maxloc and minloc return the wrong values for 0-sized arrays

NCarlson
Novice
272 Views

According to the standard, all elements of the result  of the intrinsic functions minloc and maxloc should be 0 if their array argument is 0-sized.  But with Intel Fortran the elements are 1 instead: 

integer, allocatable :: a(:), b(:,:)
allocate(a(0), b(2,0))
print *, maxloc(a)
print *, maxloc(b)
end

This should print

0
0 0

But instead I get

1
1 1

 This is with the latest 2021.5.0 version and goes back to at least 18.0

Labels (1)
0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
269 Views

/standard-semantics is your friend - sets /assume:noold_maxminloc.

View solution in original post

4 Replies
Steve_Lionel
Black Belt Retired Employee
270 Views

/standard-semantics is your friend - sets /assume:noold_maxminloc.

NCarlson
Novice
266 Views

Argh...  I don't know why that didn't occur to me (it's resolved "problems" in the past).  Thanks!  I need a config file so that that flag is always automatically included.  Is such a thing possible?

Steve_Lionel
Black Belt Retired Employee
262 Views

I'll comment that maxloc/minloc initially did not define the result in this case. It was clarified in F2008, I think.

Reply