Hi Tobias, all, Am 29.11.21 um 21:56 schrieb Tobias Burnus:
The problem is that the standard does not really state what the bounds are :-(
I sort of expected that comment...
Usually, it ends up referring to LBOUND (with wordings like "each lower bound equal to the corresponding element of LBOUND (expr)") – albeit not in this case. Assuming that holds, the question is what's lbound(h(3))? gfortran gives [1] for that one. What does NAG yield? For lbound(h(3),dim=1), the standard has: "If DIM is present, ARRAY is a whole array, and either ARRAY is an assumed-size array of rank DIM or dimension DIM of ARRAY has nonzero extent, the result has a value equal to the lower bound for subscript DIM of ARRAY. Otherwise, if DIM is present, the result value is 1." Thus, the question is whether "h(3)" is a 'whole array' or not. That reads:
F2018: 9.5.2 Whole arrays
"A whole array is a named array or a structure component whose final part-ref is an array component name; no subscript list is appended." I think in "h(3)" there is not really a named array – thus I read it as if the "Otherwise ... result value is 1" applies.
If you read on in the standard: "The appearance of a whole array variable in an executable construct specifies all the elements of the array ..." which might make you/makes me think that the sentence before that one could need an official interpretation... I've submitted a reduced example to the Intel Fortran Forum: https://community.intel.com/t5/Intel-Fortran-Compiler/Allocate-with-SOURCE-and-bounds/m-p/1339992#M158535 There are good chances that Steve Lionel reads and comments on it. You're invited to add to that thread! Harald
Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955