Fortran elemental functions vs elemental subroutines

Viewed 3133

Fortan allows elemental subroutines to have intent(inout) and intent(out) arguments, but elemental functions are only allowed intent(in).

Why is that? Is it just a stylistic convention, or is there something generically different about invoking functions and calling subroutines?

In other words,

Elemental Integer Function FOO(i)
  Integer, intent(in) :: i
    ...
  FOO=something
End Function

and

Elemental Subroutine FOO(i, v)
  Integer, intent(in)  :: i
  Integer, intent(out) :: v
    ...
  v=something
End Subroutine

— are these implementations of FOO equivalently efficient?

1 Answers
Related