private type is exported!

Hi!

I have some code for a MODULE, where I define

MODULE LibSample
PRIVATE
PUBLIC :: SampleGrid

TYPE SampleType
----blabla
END TYPE

and

TYPE SampleGrid
TYPE(SampleType), DIMENSION(:,:), ALLOCATABLE :: Samples
Blablabla
END TYPE

CONTAINS

blablablablabla

END MODULE

Another MODULE uses this module and refers to a variable of type SampleGrid. No complaints! Even though the SampleType, the type of the component of SampleGrid, is NOT exported by module LibSample!

Why does the compiler not complain?

Regards,


Arjan

Hi,

When you say it is not exported, is this on windows? Are you talking about DLL?

Which compilers version do you use? Did you try latest release?


Hongyon

Please post a complete examples so that we can compile here.

Thank you,
Hongyon

Hi!

I’ll send you the info+code on monday. Here at home I don’t have access to all the stuff. We use the Linux version of pgf90 and probably not the latest release. There is no dll involved in my work. Just a bunch of .f90 files with 1 module per file and one main program.

To be continued.

Arjan

Hi!

The compiler we have is:

pgf90 6.1-4 32-bit target on x86-64 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2006, STMicroelectronics, Inc. All Rights Reserved.

When I do pgf90 -c libsample.f90 on the following code,
I get no problems with the compiler. In this code I declare
three public variables CoarsGrid, MesoGrid and FineGrid. The user-defined
type SampleType is defined as private and therefore no module or program that will use LibSample will know what to do with the Sample-component of the three global variables. I would have liked a warning/error message from the compiler like:


“TYPE(SampleType), DIMENSION(:,:), ALLOCATABLE :: Sample
^
Component Sample of SampleGridType will be invisible to
other units. Type SampleType is declared as private to this module.”

Maybe the compiler hopes that I will define SampleType in another module,
just like GridSpecsType, LocalMeteoGridType, Float and NuclideVector. Still, the fact that SampleGridType has a locally consistent, private meaning to this module should have triggered an alarm about its use outside the module.

Regards,


Arjan




MODULE LibSample

USE libxmath
USE libutil
USE libgrid
USE libdate
USE libcoordinate
USE liblookup
USE libmeteo
USE libnuclide

IMPLICIT NONE
!
! Principally everything is LOCAL...
!
PRIVATE
!
! ... except for the following:
!
PUBLIC :: SampleGridType,CoarseGrid,MesoGrid,FineGrid

TYPE SampleType
  TYPE(NuclideVector) :: Con,MomDep,Dep,ICon,IDep
END TYPE SampleType


TYPE SampleGridType
  INTEGER :: CoordinateSystem
  TYPE(GridSpecsType) :: GridSpecs
  REAL(Float) :: z
  TYPE(LocalMeteoGridType) :: Meteo
  TYPE(SampleType), DIMENSION(:,:), ALLOCATABLE :: Sample
END TYPE SampleGridType



TYPE(SampleGridType) :: CoarseGrid,MesoGrid,FineGrid



CONTAINS


END MODULE LibSample

Maybe the compiler hopes that I will define SampleType in another module,
just like GridSpecsType, LocalMeteoGridType, Float and NuclideVector.

ps. Even if this assumption about the definition of SampleType in another module were correct, then the linker should have seen that my main program will never work because no other module had done the job.

Hi Arjan,

You are using 6.1-4 which is quite old version. Please use our latest release 7.1. I believe this gets fixed in 6.2.

Hongyon