Fortran prefix (inout) pass a copy of the value or a pointer / reference to the RAM address?

As header states, I want to know if Fortran (inout) intends to pass a copy of the value or a pointer / reference to the RAM address? The reason I need to know this is to pass a (relatively) large data matrix. If it creates a local copy that gives me problems. Thank!

+3


source to share


1 answer


Fortran does not provide details on how function and subroutine arguments are passed, but it does require that if the procedure changes the argument intent(out)

or intent(inout)

, then the changes will be visible to the caller after the procedure returns. Usually compilers use this requirement by passing arguments by reference, but this is not the only option - the main alternative is copying to / copy out.

You can usually rely on the compiler to implement the fastest behavior that can be defined correctly, which is usually by reference. There are times when this may not work, such as passing a non-overlapping array as an argument of the estimated size, and sometimes there are times when copy / copy is faster (perhaps on some large multiprocessor systems with segmented memory architectures).



The bottom line is that although you are asking a good question, there is no answer. As is often the case, your best bet is to do it first and then do it faster if needed. Keep the question of copying the array to the back of your head, but don't worry about it until you can check.

+4


source







All Articles