top of page
Writer's pictureAdisorn O.

Using result() in F90 function to return single array variable

The function with result() in f90 is developed to consistent with high level language like MATLAB. It's rather return the value of function to output variable rather than the function itself.


The rules are

  1. We declare the output variables as an allocatable dummy array in both main and function.

  2. We must allocate the dimension of output array inside the function.

  3. We must allocate and assign input arrays at main before sending.

  4. It should be noted that the function with result() returns only one variable (array or scalar).

  5. For returning more than one variable, use subroutine to perform such a task.



Consider this lesson example


By concatenating arrays a and b, array c is sent to add to itself




9 views
bottom of page