Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Error message about multiple PRIVATE statements not being allowed

Arjen_Markus
Honored Contributor II
601 Views

I am experimenting with a generic programming technique - via rename clauses, see the code below - and I get an error message about multiple PRIVATE statements being used. I do not quite understand why because the two statements are in separate modules:

module quaternion_def_basic
    implicit none

    type quaternion
        !type(complex) :: c(2)
        complex :: c(2)
    end type quaternion
end module quaternion_def_basic

module quaternion_def
    use quaternion_def_basic, only: T => quaternion
end module quaternion_def

module octonion_def
    use quaternion_def, T2 => T

    implicit none

    private :: T2

    type T
        type(T2) :: c(2)
    end type T
end module octonion_def

module sedenion_def
    use octonion_def, T2 => T

    implicit none

    private :: T2

    type T
        type(T2) :: c(2)
    end type T
end module sedenion_def

If I comment out the PRIVATE statement in the sedenion_def module, the code is accepted. Can anyone point out whether this is a genuine programming error or something that is wrong in the compiler. FYI: gfortran does accept the code.

I am using Intel Fortran 2015 for this.

0 Kudos
3 Replies
Kevin_D_Intel
Employee
601 Views

This appears to be a defect so I reported it to Development. It is also reproducible with PSXE 2016 (16.0 compiler). The clash appears to only involve the symbol. Tinkering with the test case to use a different name inside sedenion_def, I find that T2 from octonion_def is not accessible.

(Internal tracking id: DPD200376628)

0 Kudos
andrew_4619
Honored Contributor III
601 Views

error #6265: This symbol has multiple PRIVATE statement/attribute declarations which is not allowed.   [T2]

It look OK to me. If in sedenion_def your change t2 to t3 the problem goes away suggesting there is some namespace pollution from octonion_def in sedenion_def.

On another note the cascade of re-definitions using the USE rename feature I found really confusing. I had to read the code three times before I understood it. Do you really want to do such a thing?

0 Kudos
Arjen_Markus
Honored Contributor II
601 Views

Kevin, thanks for taking care of this.

app4619, I use the renaming bit to get a kind of templates within the current Fortran standard. If I were to use this in actual code, then I would chose more descriptive names, but this was a small illustration only :). It requires some careful thinking, I agree, but it seems a useful tool to set up generic code.

0 Kudos
Reply