Compilation error

Paul Richard Thomas paul.richard.thomas@gmail.com
Mon Oct 3 17:54:00 GMT 2011


Dear Daniel,

> Is it ok to ask "user" questions here? I'm back at school doing research. I
> have a piece of code that used to work and now refuses to compile. I'm using
> GFortran 4.4.3.

Are you sure that it used to work exactly as it is now?

....snip....

> In other words, this routine takes a function as its third parameter and
> uses it to do a Runge-Kutta 4 step. The calling code looks like this:
>
>    call ode_rk4(t, P, dP, h)
> ...
>    pure function dP(t, P)
>        real(wp), intent(in) :: t, P(4)
>        real(wp) :: dP(4)
>
>        dP = (/ 1, 2, 3, 4 /)
>    end function
>
>
> When I try to compile my program, I get the following error:
>
> -------------------//-----------------
>            call ode_rk4(t, P, dP, h)
>                               1
> Error: Internal procedure 'dp' is not allowed as an actual argument at (1)
> -------------------//-----------------

This is absolutely clear - an internal procedure is one which is
contained in the same program unit as the subroutine call.

By 12.4 of the Fortran 95 standard;

Constraint: A procedure-name actual-arg shall not be the name of an
internal procedure or of a statement function and shall not be the
generic name of a procedure unless it is also a specific name
(12.3.2.1, 13.1).

Take dP out of the program unit, declare it to be EXTERNAL or give it
an explicit interface by putting it in a module.

We prefer you to use comp.lang.fortran for what you call "user"
questions.  This list is dedicated to the development of gfortran.

Cheers

Paul



More information about the Fortran mailing list