PDA

View Full Version : Re: [LF] Circular usage of module


Lahey Support
08-15-2003, 01:33 AM
Sylvain Bergeron wrote:

>> I have a large program with about 25 modules (object oriented), in
>> which there is a circular usage. Module1 needs stuff in Module2,
>> and Module2 needs stuff in Module1.

The test program compiled with lf95 express 6.0b with "standards" warning
option (--f95) complains thus

3125-W: "circ.f90", line 34: Interface block which is use associated by
this USE statement containing an interface body for procedure
GetStuffFromModule2 defined by this subprogram is not standard-conforming.

Which means you shouldn't have an interface block for GetStuffFromModule2
USEd within GetStuffFromModule2. Adding an ONLY clause to avoid USEing
that interface block seems to make the compiler happy.
-----
function GetStuffFromModule2(Arg1)
use Module2, only: LocalSaved ! don't use the interface block
implicit none
real, intent(in) :: Arg1
real :: GetStuffFromModule2
GetStuffFromModule2 = Arg1 + LocalSaved * 2.
end function GetStuffFromModule2
-----
The unmodified code didn't compile on Compaq Fortran with default options.

Another, cleaner approach will be to take out the entities to be shared
from the two modules into a Module3, and use that from both Module1 and
Module2, I suppose.
--
Yasuki Arasaki
[address removed]
----------------------------------------------------------
To unsubscribe, send to [address removed] the following
as the first and only line of the message body:
unsubscribe fortran
----------------------------------------------------------