This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Size intrinsic and related problems


Hi all!

I noticed that the size intrinsic does not seem to follow the Fortran standard, from my reading of it I would expect the following pseudo Fortran to print -7:

arr(7,*)
call sub(arr)

subroutine sub(a)
a(..)

print *, size(a)

It prints 0.

In fact the size intrinsic will never return negative values as it is my understanding the Fortran standard requires.

This seemed an easy thing to fix, but what is the protocol for "special" arrays, like assumed size and zero sized arrays?

One possibility could be:

Zero sized   (arr(0)) lbound:1 ubound:0   so that extent is  0
Assumed-size (arr(*)) lbound:l ubound:l-2 so that extent is -1

This is likely documented somewhere, but I could not find it. And, probably I am misunderstanding something, but usage in the code seems inconsistent.

Then there is another related problem

arr(*)
call sub(arr(l:u))

subroutine sub(a)
a(..)

print *, size(a)

which again prints 0 and not u-l+1 has I expected.

This seems to be caused by the array section being explicitly marked as an assumed-size array, by setting ubound to -1. I would expect the array section to be passed as an explicit shape array, is my interpretation correct?

If I understood correctly the meaning of the array types demanding that the array type is AR_FULL would fix this, but OpenMP seems to need to know if the section is from an assumed-size array...

The first point seems to be a clear bug report, but in order to try to patch anything one would need an "official" position on the protocol to use... The last one I am not positively sure if it is a bug and I have no idea on how to pass the info to OpenMP.

Thank you very much.

Best regards,
José Rui


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]