Re: Scope question (gfortran odd-man out)
- From: kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx (Steven G. Kargl)
- Date: Mon, 2 Jul 2007 21:15:39 +0000 (UTC)
In article <1183409425.977263.53210@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
awgreynolds@xxxxxxxxxxxxx writes:
Consider the following code fragment:
subroutine main
:
call internal
:
contains
subroutine internal
do i=...
if (...) return
enddo
end subroutine
end
Should the undeclared variable "i" be in the scope of "main", i.e.
should it have the right do loop value in "main" after the call?
Admittedly this is somewhat "sloppy" coding, but all the Fortran-95
compilers I use except Gfortran answer "yes" to the question.
Gfortran requires me to put an "integer i" declaration at the top of
main.
I think you'll need to show actual code because it works for
me (for some definition of 'works').
troutmask:kargl[233] cat k.f90
program a
call internal
print '(A,I0)', '6 --> ', i
contains
subroutine internal
do i = 1, 5
print '(A4,I0)', 'i = ', i
end do
end subroutine internal
end program a
troutmask:kargl[234] gfc -o z k.f90
troutmask:kargl[235] ./z
i = 1
i = 2
i = 3
i = 4
i = 5
6 --> 6
--
Steve
http://troutmask.apl.washington.edu/~kargl/
.
- Follow-Ups:
- Re: Scope question (gfortran odd-man out)
- From: awgreynolds
- Re: Scope question (gfortran odd-man out)
- References:
- Scope question (gfortran odd-man out)
- From: awgreynolds
- Scope question (gfortran odd-man out)
- Prev by Date: Re: Scope question (gfortran odd-man out)
- Next by Date: Re: Scope question (gfortran odd-man out)
- Previous by thread: Re: Scope question (gfortran odd-man out)
- Next by thread: Re: Scope question (gfortran odd-man out)
- Index(es):
Relevant Pages
|