- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you specify intent(in), the Intel Fortran help file says the actual argument must be an expression. In this example where the argument is just a variable (but still a legal expession). Is the argument A evaluated as an expression and the result sent to foo to prevent modification by foo?
It seams superfluous to copy the argument when the compiler has already made sure we don't modify the dummy argument and it is illegal to attempt to do so. If A was a large data structure, making a copy would be a serious problem. Thus intent(in) would best be avoided where we are passing simple variables.
Andy
program test
use fooMod
implicit none
real A
a = 1.0
call foo(A)
end program
module fooMod
implicit none
contains
subroutine foo(B)
real, intent(in) :: B
end subroutine
end module
It seams superfluous to copy the argument when the compiler has already made sure we don't modify the dummy argument and it is illegal to attempt to do so. If A was a large data structure, making a copy would be a serious problem. Thus intent(in) would best be avoided where we are passing simple variables.
Andy
program test
use fooMod
implicit none
real A
a = 1.0
call foo(A)
end program
module fooMod
implicit none
contains
subroutine foo(B)
real, intent(in) :: B
end subroutine
end module
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm. That "Any associated actual argument must be an expression" isn't correct. A variable is fine. INTENT(IN) says that the called procedure does not redefine or change the definition status of the argument. The compiler can use this information in optimization.
I will ask the writers to remove that text. Thanks for pointing it out.
I will ask the writers to remove that text. Thanks for pointing it out.

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