Community
cancel
Showing results for 
Search instead for 
Did you mean: 
vzecca
Beginner
234 Views

Incorrect output on minloc and maxloc of empty array

Jump to solution

!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 I
226 Views

There are a number of topic on this area. see this one linked beklow and other linked topics maybe that will help. I didn't study your case specificaly.

https://community.intel.com/t5/Intel-Fortran-Compiler/Change-in-result-of-MINLOC-MAXLOC-functions-wh...

https://community.intel.com/t5/Intel-Fortran-Compiler/Unhelpful-MINLOC-MAXLOC-documentation/m-p/1006...

 

View solution in original post

3 Replies
andrew_4619
Honored Contributor I
227 Views

There are a number of topic on this area. see this one linked beklow and other linked topics maybe that will help. I didn't study your case specificaly.

https://community.intel.com/t5/Intel-Fortran-Compiler/Change-in-result-of-MINLOC-MAXLOC-functions-wh...

https://community.intel.com/t5/Intel-Fortran-Compiler/Unhelpful-MINLOC-MAXLOC-documentation/m-p/1006...

 

View solution in original post

vzecca
Beginner
201 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.

Steve_Lionel
Black Belt Retired Employee
184 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-for... for a list of these conflicting defaults.

Reply