Malcolm Cohen (of NAG Ltd) wrote:
>Aleksandar Donev said:
>> routine DOUBLE RHS(I), for INTEGER I. Why on earth would someone make the
>> routine this way, instead of explicitly passing this function as an
>EXTERNAL
>> argument?
>
>I think it's just poor design. There may be extenuating circumstances
>(the original machine might have been very slow with dummy procedures, or
>the author might not have known about or liked dummy procedures), but
>most likely just a design mistake. These things happen (and are more
>obvious in retrospect than at the original time).
>
>> My problem is that I always put functions in a MODULE, and in this case I
>> can not do that because the module functions have a different name in the
>> object file than a non-module procedure would. So I am just wondering where
>> this design comes from and if there is any F90 way to handle it.
>
>There is nothing non-F90 about it. The badness has not increased by moving
>to F90, just conserved. You can
>(a) rewrite the code to pass dummy procedures around instead of using RHS
>or
>(b) write a function that is not in a module.
>
>Not much else you can do, really.
This method, of having the user write a certain named routine to be called by
a library routine, is used by the NAG library. Examples occur in the D02
integration chapter. Here the user must provide a routine FCN which evaluates
the derivatives of the state variables at each time step. The problem
seemingly arises because of the many levels within the library routines, thus
making it cumbersome to pass the user function as an argument. It creates a
further problem that the derivatives will use other variables not known by the
integration routines so these had to be loaded into COMMON areas to be used
within FCN.
It is really very little different from how one's own routine layout could
look: A calls B calls C calls D calls E ca11s FCN. Variables used only within
A and FCN would be in COMMON or a USEd module and FCN would not normally be
passed as an argument through the chain unless there could be several
different FCNs in the application. The problem ("poor design") is when B, C
and D are "black-box"
Regards, Paddy
Paddy O'Brien,
Transmission Development,
TransGrid,
PO Box A1000, Sydney South,
NSW 2000, Australia
Tel: +61 2 9284-3063
Fax: +61 2 9284-3050
Email: [log in to unmask]
Either "\'" or "\s" (to escape the apostrophe) seems to work for most people,
but that little whizz-bang apostrophe gives me little spam.
|