Re: Fortran refactoring
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Wed, 28 Jun 2006 14:55:02 -0700
phillip.news@xxxxxxxxx <phillip.news@xxxxxxxxx> wrote:
[much elided]
One of the key benefits of contained subroutines is that they're scoped
so that they can see all of the variables available in the containing
program. If you keep all of the variable declarations at the
containing routine level, the variables are automatically shared
between all contained subroutines.
One caveat. This works fine *IF* all the variables are explcitly
declared. Of course, that is a good idea (and the more so for larger
codes), but you didsay you were talking about old and messy (not your
words) code, where I can imagine that this won't necesssarily be the
case.
If a variables is not explicitly declared and you move all of the code
that refers to that variable out of the host, then the scope of the
variable will also move out of the host. If two of your contained
subroutines refer to it, they will now be referring to two separate
variables, which will likely be a bad thing. Even if all the code
referring to the variable moves into a single contained procedure, the
new scope might cause the variable to loose its value between calls to
the contained procedure.
All of which suggests that possibly a prior step should be to add
"implicit none" and fix up any problems that shows... which isn't a bad
idea anyway.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: Fortran refactoring
- From: phillip.news@xxxxxxxxx
- Re: Fortran refactoring
- References:
- Fortran refactoring
- From: phillip.news@xxxxxxxxx
- Fortran refactoring
- Prev by Date: Re: heap allocation of arrays
- Next by Date: Re: Fortran refactoring
- Previous by thread: Fortran refactoring
- Next by thread: Re: Fortran refactoring
- Index(es):
Relevant Pages
|