Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
98 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

Accepted Solutions
Highlighted
Valued Contributor III
90 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

0 Kudos
3 Replies
Highlighted
Valued Contributor III
91 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

0 Kudos
Highlighted
Beginner
65 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
Highlighted
Black Belt Retired Employee
48 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.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos