Re: MODULEand USE versus Argument Passing
- From: harper@xxxxxxxxxxxxx (John Harper)
- Date: 30 Jun 2005 09:44:23 +1200
In article <d9us2s$ncr$1@xxxxxxxxxxxxxxxxxx>,
E. Robert Tisdale <E.Robert.Tisdale@xxxxxxxxxxxx> wrote:
>
>Global variables are *always* a bad idea.
>Never pass function arguments through modules or common storage.
Really? Suppose I am using one of the NAG routines, e.g. d01akf, to
calculate integral from a to b of f(x,y) dx for various values of y.
The NAG specification says (irrelevant detail omitted; and REAL should
be replaced by REAL(kind(1.0d0)) with many compilers)
SUBROUTINE d01akf(f,a,b, ...)
REAL f,a,b, ...
EXTERNAL f
and f must be declared as EXTERNAL in the (sub)program from which
d01akf is called, and it must be declared as a REAL(DP) function of
one REAL(DP) variable, not two.
I had thought the way to get y into f was by COMMON before f90, and by
using a module nowadays. What would Robert have me do?
In www.nag.com/numeric/fl/manual/pdf/D01/d01akf.pdf is NAG's manual
for d01akf; its example of how to use d01akf uses an integer variable
in COMMON to count the number of evaluations of the function f.
John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.
- Follow-Ups:
- Re: MODULEand USE versus Argument Passing
- From: glen herrmannsfeldt
- Re: MODULEand USE versus Argument Passing
- From: E. Robert Tisdale
- Re: MODULEand USE versus Argument Passing
- From: James Van Buskirk
- Re: MODULEand USE versus Argument Passing
- References:
- MODULEand USE versus Argument Passing
- From: Herman D . Knoble
- Re: MODULEand USE versus Argument Passing
- From: E. Robert Tisdale
- MODULEand USE versus Argument Passing
- Prev by Date: Re: MODULEand USE versus Argument Passing
- Next by Date: Re: MODULEand USE versus Argument Passing
- Previous by thread: Re: MODULEand USE versus Argument Passing
- Next by thread: Re: MODULEand USE versus Argument Passing
- Index(es):