Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26729 Discussions

Intrinsic procedure minloc returns different values with different versions of ifort : possible mistake?

Jeremie_V_
Beginner
84 Views

Dear,

I have two versions of Intel compilers on our HPC: the version 14.0.3 and the version 17.0.0 .

The intrisic procedure minloc returns different values when the Fortran program is compiled with these 2 versions. It happens when using a mask and that this mask is false. With the version 14.0.3, it returns 0, while with the version 17.0.0., it returns 1.

Here is the Fortran code:

program minloctest
 implicit none
 integer::i,j,n,m(1)
 integer,allocatable::array(:)

 n=10
 allocate(array(10))
 array=(/(i,i=1,n)/)
 
 j=3
 m=0
 m=minloc(array,array.eq.j)
 print*,m
 j=11
 m=0
 m=minloc(array,array.eq.j)
 print*,m

end program

I compiled it using:

ifort minloctest.f90 -o minloctest

Using the version 14.0.3, I got:

3

0

Using the version 17.0.0, I got:

3

1

I do not understand why the answers are different. Could it be a bug? Could you help me, please?

In advance thank you.

Yours sincerely,

Jeremie

0 Kudos
2 Replies
Steven_L_Intel1
Employee
84 Views

I'm actually a bit puzzled by the 14.0 result, but that was long ago enough that I don't remember all the history here. You want -standard-semantics or -assume noold_maxminloc. This controls the behavior when all elements of the mask are false. The default is old_maxminloc which returns 1 in this case. This is described in our documentation of MINLOC.

Jeremie_V_
Beginner
84 Views

Thank you for the explanation.

Jeremie

Reply