Avoid temporary arrays when using derived types

How does one decide between the solution above and an internal subroutine, as illustrated below? I assume compilers would not make copies of the
intent(in out) arguments.

subroutine bar(D)
   type(DT), intent(inout) :: D
   call foo(D%A,D%B)
   contains
   subroutine foo(A,B)
   real, intent(in out) :: A(:,:), B(:,:)
   ! modify A and B
   end suboutine calc
end subroutine bar
2 Likes