Function results may also have the
POINTER attribute; this is
useful if the
result size depends on calculations performed in the function, as in
USE data_handler REAL x(100) REAL, POINTER :: y(:) : y => compact(x)where the module
FUNCTION compact(x) REAL, POINTER :: compact(:) REAL x(:) ! A procedure to remove duplicates from the array x INTEGER n : ! Find the number of distinct values, n ALLOCATE(compact(n)) : ! Copy the distinct values into compact END FUNCTION compactThe result can be used in an expression (but must be associated with a defined target).