PROCEDURE declarations
Tobias Burnus
burnus@net-b.de
Mon Aug 20 17:48:00 GMT 2007
Hi Janus,
Janus Weil wrote:
> So if I define a procedure in a program, I suppose the standard says
> the procedure must be external, and forbids this:
>
> program x
> procedure(real):: proc
> contains
> real function proc
> proc=3.0
> end function
> end program
>
Yes, that example is invalid. Here you define two procedures: One which
is host associated and one which is external as they have the same name
they clash and gfortran prints (for the equivalent "external proc; real
proc"):
Error: EXTERNAL attribute conflicts with FUNCTION attribute in 'proc' at (1)
In principle internally PROCEDURE(REAL) and "external proc; real proc"
can and probably should be treated identically.
But this is different from R1206 which you cited:
> R1206 procedure-stmt is [ MODULE ] PROCEDURE procedure-name-list
which talks about (generic) INTERFACES only. Thus
program x
INTERFACE generic_name
procedure proc
END INTERFACE generic_name
contains
real function proc
proc=3.0
end function
end program
is valid. Note additionally that in interfaces there "()" and "::" are
not allowed in this case.
Additionally, in an INTERFACE you need to have an explicit interface
(and thus "(...)" is not needed).
> module x
> procedure(real):: proc
> contains
> real function proc
>
This is also wrong (host associated + external procedure with the same
name).
> module x
> module procedure(real):: proc
> contains
> real function proc
>
"module procedure" may only be used in generic interfaces, they are
fully supported in gfortran (part of Fortran 90) and contrary to
"PROCEDURE" in a generic module, "MODULE PROCEDURE" may only refer to a
(host-associated) module procedure
Tobias,
who hopes that he got everything right despite not re-checking the
Fortran standard.
More information about the Fortran
mailing list