| Craig Dedo 2008-03-18, 7:21 pm |
| "Henrik Holst" <henrikholst80@gmail.com> wrote in message
news:0762ae68-b666-4ccc-8a95-809d088a0241@b64g2000hsa.googlegroups.com...
> Hello comp.lang.Fortran!
>
> I am writing to s ideas how to solve the "callback problem" problem
> in
> a modern fashion using whats available in the Fortran 95/2003
> compilers, today.
>
<snip>
>
> Background:
>
> I am implementing a library for various kind of numerical methods for
> solving
> ODEs. The basic framework requires the possibility to evaluate f(t,y)
> (y is any
> 0 to 7 dimensional array) at a given point in T x Y space. This poses
> a problem
> for me because usually the f function does not only depend on t and y
> but on
> other user definable parameters.
>
<snip example>
>
> Possible solutions to the problem:
>
> The solutions to the problem above has been suggested before. (With a
> short comment from me, to each of them.)
>
<snip #1>
>
> 2) COMMON BLOCKS, suck because global variables suck.
> My whole being says that global variables are evil. If they where not
> true evil
> before the days of multi-core computing, they must have increased
> their
> evilness by orders of magnitude today. (base 2)
>
<snip #3 - #5>
>
> Regards,
> --
> Henrik Holst, Sweden
> http://www.nada.kth.se/~holst/contact.shtml
Other posters have suggested a number of ways to solve your problem. I
would like to address a common misconception.
I would like you to take another look at the issue of the use of global
data, using an open mind. Global data is not evil. Using global data is
neutral; it is neither inherently good nor inherently evil.
There are several legitimate reasons to use global data. The most obvious
is when the data is conceptually a property of the whole program. If this is
the case, you should use global data and not try to hide the use of global data
through various subterfuges.
One of the most balanced treatments on the use of global data I have read is
section 13.3 (pp. 335-343) of Steve McConnell's Code Complete: A Practical
Handbook of Software Construction, 2nd ed. (ISBN 0-7356-1967-0). This section
covers the dangers of global data, reasons to use global data, and ways to
safely use global data.
In Fortran, one of the best ways to use global data is to put it into a
module that is used in the main program and in all of the procedures where you
need to use the global data. It also helps to use access procedures to obtain
values and change the values.
--
Craig Dedo
17130 W. Burleigh Place
P. O. Box 423
Brookfield, WI 53008-0423
Voice: (262) 783-5869
Fax: (262) 783-5928
Mobile: (414) 412-5869
E-mail: <cdedo@wi.rr.com> or <craig@ctdedo.com>
|