- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If we have a dummy derived type with intent in, does the caller pass a copy of the whole data structure to ensure no data is changed by the callee or do you rely on the compiler to check for assignments?
I am wondering if we would get better performance if we avoided INTENT(IN) for derived types.
I am wondering if we would get better performance if we avoided INTENT(IN) for derived types.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTENT(IN) does not change how an argument is passed.
Derived types can be passed by value, and a copy is therefore made, but that doesn't seem to be the issue here.
Derived types can be passed by value, and a copy is therefore made, but that doesn't seem to be the issue here.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Andrew Smith
If we have a dummy derived type with intent in, does the caller pass a copy of the whole data structure to ensure no data is changed by the callee or do you rely on the compiler to check for assignments?
I am wondering if we would get better performance if we avoided INTENT(IN) for derived types.
I am wondering if we would get better performance if we avoided INTENT(IN) for derived types.
If this doesn't help, please give a working example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Andrew Smith
If we have a dummy derived type with intent in, does the caller pass a copy of the whole data structure to ensure no data is changed by the callee or do you rely on the compiler to check for assignments?
I am wondering if we would get better performance if we avoided INTENT(IN) for derived types.
I am wondering if we would get better performance if we avoided INTENT(IN) for derived types.
It does not make a copy; it relies solely on the compiler check. It is akin to C++ const-by-reference argument. Thus, you can actually modify an INTENT(IN) argument, by means of cheating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran is pass by reference. A reference (pointer) to the derived type will be passed regardless of INTENT.
The compiler will, within the subroutine/function, assure use conformes with INTENT.
The IVF help does not state what happens with combination of VALUE and derived type. It states:
"Character values, substrings, assumed-size arrays, and adjustable arrays cannot be passed by value."
This said, a derived type is of arbitrary size, but the convention for VALUE of derived type might permit pass of temporary copy of derived type. The documentation is not clear on this issue.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTENT(IN) does not change how an argument is passed.
Derived types can be passed by value, and a copy is therefore made, but that doesn't seem to be the issue here.
Derived types can be passed by value, and a copy is therefore made, but that doesn't seem to be the issue here.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page