allocatable, optional

I’m migrating my f90(95) code from intel ifort to Portland compiler and encountered some language features intel supports and pgf90 seems not.

  1. pgf90 gives error on power operation in parameter intialization, i.e

real(DP), parameter :: x=2.2**3.1

is not allowed

  1. pgf90 gives error if dummy variable has both optional and allocatable attribute, or intent() and allocatable attribute. I.e

subroutine (x)
real(DP), intent(inout), allocatable, dimension(:) :: x

or
subroutine (x)
real(DP), optional, allocatable, dimension(:) :: x

generates

PGF90-S-0134-Illegal attribute - conflict with allocatable (…)


I looked through f95 reference books, and could not find any restriction on such combinations (plus ifort handles them fine). Yes, intent cannot be used with pointers, but not allocatable arrays. But even if ‘intent’ indeed may have little sense for allocatable arrays, ‘optional and allocatable’ is definitely useful.

Hi,

It looks like we’re missing an opportunity with regards to initilization using the power operation. I’ll go ahead an submit a TPR to have this fixed.

However, using “allocatable” as part of a dummy argument is illegal. From Fortran 95 Handbook: Complete ISO/ANSI Reference by Jeanne C. Adams, … [et al] 1997, page 120. The “Rule and restrictions” section of “5.3.3 ALLOCATABLE Attribute Statement” states:

  1. The array must not be a dummy argument or function result.

I’m not sure why Intel allows it.

Thanks,
Mat

Yes, you are right, allocatable dummy arguments are not part of Fortran95 per se.
However they are the part of the extension from “Technical Report ISO/IEC 15581: 1998(E)”
Let me quote from the reference 'M. Metcalf and J. Reed, Fortran 90/95 explained, Oxford University Press, 1999", who have the whole chapter 13 devoted to these extensions.

p. 271
“Chapter 13: Allocatable arrays extensions”

The subject of this Chapter is another extension (ref to tech report above) of Fortran 95.
It involves the use of allocatable arrays as dummy arguments, function results, and components of structures. Pointer arrays may be used instead in Fortran 90/95, but there are significant advantages for memory management and execution speed in using allocatable arrays when the added functionality of pointers is not needed.
This is another extension that WG5 has promised will be included in the next revision of the Fortran standard (…) . Again the intention is that this promise will encourage vendors to implement the feature in their compilers, confident that their efforts will have a secure future.

End of quote.


Intel compiler is very good in implementing all the extensions described in this chapter.
In particular allocatable dummy variables (so that allocation can be done inside subroutine),
and even more - allocatable structure objects, are very useful, and I know lots of code which use those features a lot.

So I think it is an important direction for future development.

BTW, pgf90 DOES NOT generate an error on plain

subroutine (x)
real(DP), allocatable, dimension(:) :: x

for me, hust when allocatbale was mixed with optional or intent attribute.

I guess that’s one problem with programing using non-stanard language extensions, portability can prove difficult. Anyway, we currently do not support this extension, which I believe is now part of Fortran 2003. While PGI will probably adopt it, I don’t know when.

I agree that:

subroutine (x)
real(DP), allocatable, dimension(:) :: x

should be an error so I submitted TPR 3050 to have it fixed. Also, I submitted TPR 3048 for the problem with the power operation not being allowed for parameter.

We do appreciate you pointing out these issues. F95 is new in release 5.2 and although we do extensive testing, some problems are bound to slip through.

Thanks,
Mat

Yes, I understand that even f95 support is new in PGI. Thank you very much for your work and quick reply !