maxloc, minloc, and ... "loc"?

This is a general FORTRAN90 question, not particular to PGI. Hope that’s OK.

The routine maxloc(array,mask) will return the index of the maximum of the elements in “array” that fulfill the condition “mask”. minloc() returns the location of the minimum. It therefore occurs to me that there could be some kind of routine “loc” that returns all the locations in “array” that satisfy “mask”. Such a routine would certainly be useful for me. But I can’t find a discussion of such a thing anywhere. (I know about the “where” construct. It’s not going to do what I need. I actually need a list of indices where “mask” is fulfilled.) Does anyone know of such a thing? If there isn’t one, does anyone know why not? It seems to me that once we have maxloc and minloc, a “loc” routine would be a simple extension. Thanks.

Hi cablesb,

I can’t think of any intrinsic to do this, but it seems simple enough that you could write your own loop to perform the task.

Note that there is a non-standard “%LOC()” intrinsic, but this returns the address of a variable.

  • Mat