In article
<92398d99-ea4c-414f-8ef4-9dee6492fff7@[EMAIL PROTECTED]
>,
deltaquattro <deltaquattro@[EMAIL PROTECTED]
> wrote:
> However, the function to be integrated depends on many parameters, not
> only on x. How can I pass it to quad? Is it better to modify the
> interface in quad (and all the subroutines called by quad), or to
> create a module containing func and all the modules needed by it? Have
> you ever met a similar problem? Thanks
This is the standard interface problem. Do not modify your quad()
subroutine. If you do that, then you might as well not even use the
dummy subroutine, you could just hardwire the call to your specific
code, eliminating all advantages of having a modular reusable quad()
routine for numerical integration.
With f77, the usual approach was to put all of the other parameters
(other than x) into a common block. The actual function (associated
with the dummy func()) could than access and/or modify those common
block variables as appropriate.
With f90 and later, a better approach is to put all of the extra
parameters into a module, along with the actual function and any
auxiliary subroutines it might need. This gives you the ability to
use derived data types and all of the power of f90, such as explicit
interfaces, even though the dummy routine only has one variable "x"
in its argument list. If you need to integrate a dozen functions,
then you simply write a dozen modules, each sup****ting a specific
function, and your quad() routine works correctly with all of them.
$.02 -Ron Shepard


|