next up previous contents
Next: Pointers and Derived Types Up: Pointers and Targets Previous: Pointers and Procedures   Contents

Pointer Valued Functions

F90 allows functions to be pointer-valued. For example,
function largest(a,b)  
implicit none 
integer,target,intent(in) :: a,b 
integer,pointer :: largest 
if ( then 
 largest  => a 
 largest  => b 
end if 
end function largest

Using the generalized pointer assignment form

pointer => ptr_expression
(ptr_expression returns a pointer result), the function name must identify a target by being the LHS of a pointer assignment
integer, pointer :: greater 
greater => largest(a,b)
The interface of an external pointer valued function must always be explicit.

Adrian Sandu 2001-08-26