- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the compile error correct? It was not what I expected.
program fred implicit none integer :: n integer :: ip real :: harry(5) harry = [ 1.0, 2.0, 0.5, 4.0, 5.0 ] N = 3 ip = minloc( harry(1:n) ) ! error #6366: The shapes of the array expressions do not conform. [IP] ip = minloc( harry(1:n), dim = 1 ) ! ok end
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is correct. If you omit DIM=, the result of MINLOC is an array which does not conform to a scalar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK thanks I just read the notes on minloc again and I has missed that point first time. Is just seems strange that for a 1d array if I omit dim=1 I get an array result but with dim=1 I get a scalar! Still it is what it is....maybe it makes more sense when you start looking at more complex usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the argument to DIM was a 2-dimension array, you'd get an array of two values for both indices, etc. When you give DIM, you get only one value, a scalar, for the MINLOC along that dimension. Don't feel bad, this trips up a lot of programmers as most don't think about the less usual cases.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page