I've been away from Fortran for a while (but am getting back to it), so
I hope someone can spot my obvious error.
I want to numerically integrate a function. Here's some pseudocode:
MODULE Q_FUNC
PRIVATE
PUBLIC Q
CONTAINS
FUNCTION Q(X)
Q = BLABLABLA(X)
END FUNCTION Q
END MODULE Q_FUNC
PROGRAM MAIN
USE Q_FUNC
INTEGRAL = INTEGRATOR(Q,START,END)
END PROGRAM MAIN
INTEGRATOR contains an INTERFACE for its dummy function argument. Q is
defined to correspond to this exactly.
The error I am gettting is:
%F90-E-ERROR, The characteristics of the associated actual function
result differ from the characteristics of the dummy function result.
(12.4.1.2, 12.2.2) [Q]
This is the DEC/Compaq/HP compiler on VMS (Alpha of course).
(I REALLY like the references to the standard in the error message; I
had a look in the standard but it doesn't help me here.)
My main question is, how can this even be possible? The MAIN program
has access to Q via USE association. I can't redeclare Q in the MAIN
program (gives an error). If I use different names (e.g. QQ for the
function in the Q_FUNC module), then I can write an interface for Q in
the main program, but still get the same error quoted above.
Obviously, I'm missing something obvious. :-)
Perhaps I don't understand the error message well enough.
It seems to me that the interface to Q_FUNC from MAIN is explicit, since
it is accessed via USE association.
Q_FUNC and MAIN are in the same file. Surely I don't have to compile
Q_FUNC separately first to get this to work?
(On a related note, my gut feeling is that in this case an internal
procedure would be more appropriate for Q_FUNC, but this is not allowed
(according to M&R, because of the way internal procedures might be
implemented); has this restriction been relaxed in Fortran 2003? It
seems to me that a MODULE used by just one program is a bit of overkill
(which is why I want to include it in the same file, to make it clear
that it is just a one-off thing for the function I want to integrate).)
|