|
From: Arno on 17 Apr 2008 10:15 Thanks for the answers. Very clear and luckily no need to change my programs! Cheers! Arno
From: glen herrmannsfeldt on 17 Apr 2008 14:04 Dan Nagle wrote: > You are very badly confusing mechanism > with effect. > Argument association, as it's called, is > a set of rules regarding the relationship > between actual arguments and dummy arguments. > Said rules are specified. > The mechanism by which those the relationship > is made to occur is not specified. > An applications programmer is entitled > to use the specified rules as needed. > The compiler is entitled to create > the illusion as it prefers. More specifically, call by value result (also called copy-in copy-out) is sometimes used. Depending on the specifics, it may be slower or faster than call by reference. Operating on a contiguous array is often faster than a discontiguous one. Inside a loop it is easily possible to make up the time needed for the copy. For assumed shape, call by descriptor is about the only way that gets all the needed data to the called routine. -- glen
From: glen herrmannsfeldt on 17 Apr 2008 14:16 Arno wrote: > See for instance below: > program test > integer :: i > i = 2 > call mycalc(i) > write(*,*) i > end program > subroutine mycalc(val) > integer :: val > val = val*2 > end subroutine > Would the printed value always be 4? Yes, it would be 4. Consider: program test common i i = 2 call mycalc(i) end program subroutine mycalc(val) common i integer val val = val*2 write(*,*) i end subroutine This program may print either 2 or 4, and is non-standard. If executed using the OS/360 Fortran compilers it will print 2. (If you change the write statement, program statement and end statements...) -- glen
First
|
Prev
|
Pages: 1 2 Prev: generic interface real function vs real Next: Problems in passing a function to a subroutine |