problem with function as argument of procedure

From: Phillip Helbig---remove CLOTHES to reply (helbig_at_astro.multiCLOTHESvax.de)
Date: 11/14/04


Date: Sun, 14 Nov 2004 07:43:46 +0000 (UTC)

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.

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).)



Relevant Pages

  • Re: Layhey77 to Compaq
    ... > I have a big piece of Layhey Fortran 77 code I made long ago. ... > converter that can do a conversion, reducing my work load, before I go ... INCLUDE was added in the Fortran 90 standard, ... error message from CVF? ...
    (comp.lang.fortran)
  • Re: A few syntax questions
    ... I think putting them in the 'action-stmt' syntax rule ... If I were to redo the bnf from scratch, ... I guess that means that a standard conforming compiler is supposed to overflow. ... I am hoping that F2003 features will regain some respect for Fortran in CS departments,, and not just be coinsidered an old archaic language for old programs, but such strong support of archaic Fortran standards is a major reason why Fortran popularity continues to dwindle. ...
    (comp.lang.fortran)
  • Re: Form k = i + j and test for overflow.
    ... Last night you suggested I was forgetting that overflow violates ... the Fortran standard. ... test that wouldn't work on the most common of implementations. ... that conforms to the Fortran standard. ...
    (comp.lang.fortran)
  • Re: conditional compile for gFortran (GCC?): newbie question
    ... The official standard for a Fortran pre-processor is Part 3, "Conditional Compilation", informally known as CoCo. ... As I mentioned in a message in this thread yesterday, there are free implementations of CoCo available on the Internet. ... Obviously, CPP and its derivatives are widely used for Fortran, but I am not sure that the usage is so universal that it counts as a "de-facto standard", except perhaps in the Unix world. ... the capabilities and behavior of the Fortran pre-processor would be under the control of either the C or C++ committee. ...
    (comp.lang.fortran)
  • Re: FOR070.DAT files appearing
    ... IMPLICIT NONE has been Standard Fortran since 1993 when the Fortran 90 ... When F90 was approved, it became the ... I'd also challenge you to find a commercial Fortran 77 compiler ...
    (comp.os.vms)