Re: Derived type argument to subroutine



Hello,

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.

Endit. :-)

On 2008-04-17 08:12:49 -0400, Arno <arnoinperu@xxxxxxxxxxx> said:

1. The standard does not specify that *ANYTHING* is passed by reference.
In practice, they often, but not always are.

I also thought that in Fortran the default was passing arguments by
reference and that passing by value has to be explicitely stated. I
also thought that an argument changed in a subroutine is changed in
the caller as well. I make pretty often use of that, so I really hope
I can rely on the fact that arguments are passed by reference.

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, or is it undefined as the passing
of arguments can be either by reference or value, dependent on
compiler, platform etc.!?

Arno


--
Cheers!

Dan Nagle

.



Relevant Pages

  • Re: Derived type argument to subroutine
    ... I also thought that in Fortran the default was passing arguments by ... I can rely on the fact that arguments are passed by reference. ... subroutine mycalc ...
    (comp.lang.fortran)
  • Re: REQ: Help with hash reference to a module
    ... > You're passing a reference just fine. ... to a subroutine which has been explicitly prototyped as taking a hash as ... You're right about dereferencing the passed-in reference though. ...
    (comp.lang.perl.misc)
  • Re: Values Not coming in the subroutine parameters correctly...
    ... Generally passing a hash to a subroutine is not good. ... You may try to pass a hash's reference to the subroutine,this get things more clear. ...
    (perl.beginners)
  • Re: Pass hash to a subroutine
    ... In the example below I have passed the hash by reference. ... stack before it calls the subroutine (which can use up a lot of time if ... The only "drawback" of passing by reference is that you can ...
    (comp.lang.perl.misc)
  • Nonsense dialog box of "Sub or Function not defined"
    ... then based on the checked boxes on the ... I will be adding at least may be 15-18 more subroutine. ... .InsertBefore PLName ... Word 2007 Developer Reference> Visual Basic for Applications Language ...
    (microsoft.public.word.vba.general)