next up previous contents
Next: Modules Up: Procedures and Arrays Previous: Automatic Arrays

 

Array-valued Functions

Functions can return arrays, for example,

   PROGRAM Maian 
    IMPLICIT NONE
     INTEGER, PARAMETER      :: m = 6
     INTEGER, DIMENSION(M,M) :: im1, im2
      ...
     IM2 = funnie(IM1,1) ! invoke
   CONTAINS
    FUNCTION funnie(ima,scal)
     INTEGER, INTENT(IN) :: ima(:,:)
     INTEGER, INTENT(IN) :: scal
     INTEGER, DIMENSION(SIZE(ima,1),SIZE(ima,2)) &
                         :: funnie
     funnie(:,:) = ima(:,:)*scal
    END FUNCTION funnie
   END PROGRAM

Note how the DIMENSION attribute cannot appear in the function header.

For more information, click here gif

Now try this question gif

Now try this question gif


next up previous contents
Next: Modules Up: Procedures and Arrays Previous: Automatic Arrays

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.