next up previous contents
Next: Pointer Valued Functions Up: Pointers and Targets Previous: Pointers to Arrays vs   Contents

Pointers and Procedures

Pointers can be passed as actual and dummy arguments in much the same way as non-pointer variables (dummies and actuals must match in type, kind and rank). Note that a POINTER variable cannot have the INYTENT attribute.

If a pointer or target is used as a dummy argument, then an explicit interface is required at the place of call. The reason is that a pointer argument can be interpreted in two ways:

In the folowing example Pint2 is dereferenced before being passed to Beer, Pint1 is not:

program Brew 
  integer, pointer :: Pint1, Pint2
  call Beer(Pint1,Pint2) 
  ...
contains  
  subroutine Beer(arg1,arg2) 
    integer, pointer    :: arg1 
    integer, intent(in) :: arg2 
    ...
  end subroutine Beer 
end program Brew
Pint1 in the calling unit and arg1 in Beer reffer to the same space; however, if an unassociated pointer is the actual argument, and is associated in the procedure, it is not guaranteed that the pointer will still be associated after return.


next up previous contents
Next: Pointer Valued Functions Up: Pointers and Targets Previous: Pointers to Arrays vs   Contents
Adrian Sandu 2001-08-26