Version that gives an error message
program hello
integer a(9)
integer index; ! note no dimension here
a=(/1, 3, 4, 5, 6, 7, 8, 9, 10/)
index = MINLOC(a, MASK=(a > 5))
Print *, index
end program Hello
Error message
main.f95:5.3:
index = MINLOC(a, MASK=(a > 5)) 1 Error: Incompatible ranks 0 and 1 in assignment at (1)
Working version
program hello
integer a(9)
integer index(1) ! note dimension 1 here which looks redundant at first
a=(/1, 3, 4, 5, 6, 7, 8, 9, 10/)
index = MINLOC(a, MASK=(a > 5))
Print *, index
end program Hello
Search
Here I could find related discussion but I don't find it sufficiently verbose for me to understand the difference.