Joined: 21 Feb 2005
Location: Salford, UK
|Posted: Sat Dec 05, 2020 9:51 am Post subject:
|A general comment concerning the use of the POINTER attribute when declaring a dummy argument...
In this context, the POINTER attribute is almost identical to the ALLOCATABLE attribute. It amounts to the same thing from the compiler writers' point of view but has different rules in the Fortran Standard.
The POINTER attribute (on a dummy argument) is only needed when an associated ALLOCATE (to the pointer) is anticipated within the current routine (or within a routine that is called from the current routine).
In other situations, the POINTER attribute is allowed but has no effect other than to add an unnecessary overhead to the compiled code. It is tempting to assume that, if the corresponding actual argument has the POINTER attribute, then the dummy argument should also have it, but this is not the case.
When the POINTER attribute is used on a dummy argument, the compiler must provide a mechanism to pass the SHAPE of the ALLOCATEd object back to the calling routine. The SHAPE can be unknown to the calling routine and defined by a call to ALLOCATE within the current routine. This definition could be at compile time or at run time.
FTN95 can be used with /CHECK to provide runtime checks for pointers that have not been allocated.