- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I am just curious:
As "MAXLOC(V)" returns a vector, why is it not allowed to write "I=MAXLOC(V)(1)"? [I always use the shortcut "I=MAXVAL(MAXLOC(V))", but I am still curious.]
Kind regards,
Niels H. Veldhuijzen
Cito, Arnhem, The Netherlands
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hardly anyone sticks to f90 nowadays, when f95 added the option
I=MAXLOC(V,dim=1)
I=MAXLOC(V,1)
is permissible, but not recommended, due to its obscurity, and requirement to remember whether that is a DIM or a MASK argument.
Somewhere, I've seen comments from people who were there when the decisions were made. The consistency argument fall short for me, when an absent dim= defaults to 1 for other intrinsics, but to the rank(V) for maxloc and minloc.
Further mysteries about maxloc include the question: Why is it so difficult to parallelize a multiple dimension maxloc? -Qparallel can get a small advantage, but not as much as explicitly assigning a maxloc(V,dim=1) to each thread in an inner loop, with normal care taken to avoid races between the threads. So, maxloc has to be reduced to C++ style when efficient threading is needed.
I=MAXLOC(V,dim=1)
I=MAXLOC(V,1)
is permissible, but not recommended, due to its obscurity, and requirement to remember whether that is a DIM or a MASK argument.
Somewhere, I've seen comments from people who were there when the decisions were made. The consistency argument fall short for me, when an absent dim= defaults to 1 for other intrinsics, but to the rank(V) for maxloc and minloc.
Further mysteries about maxloc include the question: Why is it so difficult to parallelize a multiple dimension maxloc? -Qparallel can get a small advantage, but not as much as explicitly assigning a maxloc(V,dim=1) to each thread in an inner loop, with normal care taken to avoid races between the threads. So, maxloc has to be reduced to C++ style when efficient threading is needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no syntax in Fortran to reference an element of an array expression. You must assign it to a variable first. Tim points out the DIM argument which is probably what you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Tim18 & Steve,
Thank you both for your quick and lucid replies!
Kind regards,
Niels H. Veldhuijzen
Cito, Arnhem, The Netherlands

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page