At 01:07 PM 9/3/98 +0200, Thorsten Ohl wrote:
>! I have a problem with meeting both the F restrictions and the
>! Fortran90/95 standard at the same time.
>!
>! The problem is that F requires PRIVATE statements in modules
>! USEing other modules. In the following example, doesn't the
>! PRIVATE statement in module OUTER give the accessibility PRIVATE
>! to INNER_TYPE as well? Then, according to the standard, OUTER_PROC
>! must not be public (which is very unfortunate, of course ...).
>
>module inner
> type, public :: inner_type
> integer :: i
> end type inner_type
>end module inner
>
>module outer
> use inner
> private ! required by F
> public :: outer_proc
>contains
> subroutine outer_proc (inner_arg)
> type(inner_type), intent(in) :: inner_arg
> print *, inner_arg%i
> end subroutine outer_proc
>end module outer
Malcolm answered the direct question, but I'll try to explain the
reasons for the F restrictions. Basically, F tries to avoid surprises
and makes the user declare everything. Especially for modules where we
think the Fortran 90 rules are pretty lax and let to many things
happen by magic. (Not everyone agrees with us here ;-> ). If you
want access to something from a module F requires you to specifically
"use" the module, not get it because some other module happened to
also "use" it. This is also sort of a side-effect of only allowing one
use statement for a module to be "visable"; which prevents strange use
of the "only" clause. That's the reason for requiring the "private"
statement.
To make it easy to manage large things we also allow what we call a
"public" module. This is a module that only contains "use" statements and
a single "public" statement. This allows you to collect things from
various sub-modules and present them all to the user in one module.
Dick Hendrickson
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|