Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28744 Discussions

Incorrect output on minloc and maxloc of empty array

vzecca
Beginner
1,045 Views

!Incorrect output: must be compiled and run
program intrinsic_mmloc_4
integer, allocatable, dimension(:) :: d
integer, allocatable, dimension(:,:) :: a
integer, dimension(2) :: b

allocate (d(0))
if (maxloc (d, 1) .ne. 0) print *,'maxloc fails'
allocate (a(1, 0))
b = minloc (a)
if (any (b .ne. 0)) print *,'minloc fails'
end program

Labels (1)
0 Kudos
1 Solution
andrew_4619
Honored Contributor III
1,037 Views
0 Kudos
3 Replies
andrew_4619
Honored Contributor III
1,038 Views
0 Kudos
vzecca
Beginner
1,012 Views

Thank you, Andrew, for the suggestion.

The correct execution of the code requires opetion -assume nooldmaxminloc

which adheres to the Fortran standard.

Unfortunately the default option violates the standard.

Closing this issue.

0 Kudos
Steve_Lionel
Honored Contributor III
995 Views

You can use the option -standard-semantics to change defaults that don't match the standard. In all cases, these are situations where earlier versions of the standard were silent, and the developers chose an option that conflicted with a later revision. If existing code would break, or performance would suffer significantly, the default was left the same. 

See https://software.intel.com/content/www/us/en/develop/articles/intel-fortran-compiler-support-for-fortran-language-standards.html for a list of these conflicting defaults.

0 Kudos
Reply