Question about use and host association
From: Paul Van Delst (paul.vandelst_at_noaa.gov)
Date: 06/24/04
- Next message: Bil Kleb: "compiler heritage (was Re: Question about use and host association)"
- Previous message: J. R. Hosking: "Re: sin(x) for large x"
- Next in thread: Bil Kleb: "compiler heritage (was Re: Question about use and host association)"
- Reply: Bil Kleb: "compiler heritage (was Re: Question about use and host association)"
- Reply: Richard Maine: "Re: Question about use and host association"
- Reply: Robert Corbett: "Re: Question about use and host association"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Jun 2004 13:43:44 -0400
Hello,
Let's say I have a module that defines a data structure:
MODULE mytype_define
IMPLICIT NONE
PRIVATE
TYPE, PUBLIC :: mytype
INTEGER :: i
REAL :: x
...various other stuff...
END TYPE mytype
END MODULE mytype_define
I then have another module that does I/O for the structure:
MODULE mytype_io
USE mytype_define
IMPLICIT NONE
PRIVATE
PUBLIC :: mytype_Write
PUBLIC :: mytype_Read
CONTAINS
SUBROUTINE mytype_Write(myStructure,Filename)
TYPE(mytype),INTENT(IN) :: myStructure
CHARACTER(*),INTENT(IN) :: Filename
....
END SUBROUTINE mytype_Write
SUBROUTINE mytype_Read(Filename,myStructure)
CHARACTER(*),INTENT(IN) :: Filename
TYPE(mytype),INTENT(OUT) :: myStructure
....
END SUBROUTINE mytype_Read
END MODULE mytype_io
Nothing very complicated. But, do notice my use of the PRIVATE and PUBLIC statements in
the two modules above. I always use PRIVATE with an empty entity list and then make each
module entity I want to be public by using the PUBLIC statement for that entity.
I then have a program that uses both these modules,
PROGRAM mytype_create
USE mytype_define
USE mytype_io
IMPLICIT NONE
TYPE(mytype) :: myStructure
! -- Fill the structure with data
myStructure%i = 1
myStructure%x = -99.0
... etc...
! -- Write the structure
CALL mytype_Write(myStructure,'mytype.bin')
END PROGRAM mytype_create
For SGI, Sun, and Linux (using the Absoft compiler) systems I always get the following
"caution" message when the *program source file* is being compiled:
USE mytype_io
^
"mytype_create.f90", Line = 3, Column = 7: CAUTION: A module named "MYTYPE_DEFINE" has
already been directly or indirectly use associated into this scope.
Now, everything in mytype_io is PRIVATE except for the contained subprograms. Nothing from
the mytype_define USEd in mytype_io should be visible to the code that USEs the mytype_io
module, right?
Is this compiler message bogus, or am I misunderstanding something about use and/or host
association, or am I using the PRIVATE and PUBLIC statements incorrectly? Compilation on
IBM AIX and Linux (using either the PGI or Intel compiler) systems produces no such
message (with all the warning stuff turned on). The message doesn't prevent compilation on
any of the systems, and the code has always worked fine - but I wonder if there is some
latent bomb waiting to go off?
Thanx and cheers,
paulv
p.s. I wonder if the three compilers where I see this (SGI, Sun, and Absoft) have some
common heritage since the CAUTION message has almost exactly the same wording for all
three. I seem to recall a link between the SGI and Absoft compilers, but not between them
and the Sun compiler.
- Next message: Bil Kleb: "compiler heritage (was Re: Question about use and host association)"
- Previous message: J. R. Hosking: "Re: sin(x) for large x"
- Next in thread: Bil Kleb: "compiler heritage (was Re: Question about use and host association)"
- Reply: Bil Kleb: "compiler heritage (was Re: Question about use and host association)"
- Reply: Richard Maine: "Re: Question about use and host association"
- Reply: Robert Corbett: "Re: Question about use and host association"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|