- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Similarly, if any part of the actual argument is defined through a dummy argument, the actual argument can only be referenced through that dummy argument during execution of the procedure. For example, if the following statements are specified:
MODULE MOD_A
REAL :: A, B, C, D
END MODULE MOD_A
PROGRAM TEST
USE MOD_A
CALL SUB_1 (B)
...
END PROGRAM TEST
SUBROUTINE SUB_1 (F)
USE MOD_A
...
WRITE (*,*) F
END SUBROUTINE SUB_1
Variable B must not be directly referenced during the execution of SUB_1 because it is being defined through dummy argument F. However, B can be indirectly referenced through F (and directly referenced when SUB_1 completes execution)."
why then does this program work?
MODULE MOD_A
REAL :: A, B, C, D
END MODULE MOD_A
PROGRAM TEST
USE MOD_A
b=1.0
CALL SUB_1 (B)
write(*,*)B
END PROGRAM TEST
SUBROUTINE SUB_1 (F)
USE MOD_A
B=2.0
WRITE (*,*) B,F
f=3.0
END SUBROUTINE SUB_1
3.000000
Press any key to continue . . .
should it not give an error? I have written code like subroutine SUB_1 and I am concerned that it is incorrect, even though it seems to work. Have I been getting away with something that is wrong?
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In MOST cases, when you change a setting for a source file and the behavior changes, it means that there is an issue for that source file. But not always...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jarvuslunt,
>>
Node = 5
NodeArray(3) = NodeArray(3) + 10
<<
The compiler is free to reorder statements when the code does not exhibit a temporal dependency. In the above example the first statement could occur after the 2nd statement as well as occur within the second statement.
Consider:
Node = 5
NodeArray(3) = NodeArray(3) + 10
Node = 6
The optimized code will likely not perform the Node=5 as it will assume it is non-functional.
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »