Re: Derived type argument to subroutine
- From: Arno <arnoinperu@xxxxxxxxxxx>
- Date: Thu, 17 Apr 2008 05:12:49 -0700 (PDT)
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
.
- Follow-Ups:
- Re: Derived type argument to subroutine
- From: glen herrmannsfeldt
- Re: Derived type argument to subroutine
- From: Dan Nagle
- Re: Derived type argument to subroutine
- From: *** Hendrickson
- Re: Derived type argument to subroutine
- References:
- Derived type argument to subroutine
- From: Gib Bogle
- Re: Derived type argument to subroutine
- From: Richard Maine
- Derived type argument to subroutine
- Prev by Date: Re: Problems in passing a function to a subroutine
- Next by Date: Re: Fortran templates
- Previous by thread: Re: Derived type argument to subroutine
- Next by thread: Re: Derived type argument to subroutine
- Index(es):