Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Private fields attribute

adamswetnam
Beginner
919 Views
Hi

If I try to compile this test code:
[fortran]module grandparent_mod
  implicit none
  
  type :: grandparent
    private
    integer, public :: a = 1
  end type grandparent
  
end module grandparent_mod

module parent_mod
  use grandparent_mod
  implicit none

  type, extends(grandparent) :: parent
    integer :: b = 2
  end type parent
end module parent_mod

module child_mod
  use parent_mod
  implicit none
  private

  type, public, extends(parent) :: child
    integer :: c = 3
  end type child
  
end module child_mod

program test
  use child_mod
  implicit none
  type(child) :: john
  
  print*, john%c
  print*, john%b
  print*, john%a

end program test[/fortran]
with ifort 11.1 20091012 i get

error #6292: The parent type of this field is use associated with the PRIVATE fields attribute
print*, john%a
---------------^

The compiler says that the variable 'a' is given the private attribute at some point but I can't see where. The default accessibility is set to private within the type grandparent but 'a' is explicitly made public. The default is also set to private in child_mod but I don't see how this should affect the accessibility...





0 Kudos
9 Replies
Ron_Green
Moderator
919 Views
It's a bug in the version of the compiler you are using. I don't see the error with the beta version of the compiler but I do see it in the latest 11.1 compiler.

Our F2003 implementation is still a work in progress with 11.1. The next major version will address many of the F03 shortcomings of 11.1.

I will send you a private note with instructions on how to try the beta version of the compiler.

ron
0 Kudos
pbkenned1
Employee
919 Views
It's a known defect witha PRIVATE statement in an extended type as described here. Fortran 2003 changed the PRIVATE statement to only set the default accessibility of the components, as opposed to actually setting the componentsas PRIVATE. As Ron said, it's already fixed in the next major version of the compiler.

Patrick Kennedy
Intel Developer Support
0 Kudos
adamswetnam
Beginner
919 Views
Thankyou both for your help.

I installed version 12 beta update 2 for linux in my home directory on our openSUSE 11.0 (x86_64) desktop and everything seemed to go fine but when i do:

ifort test.f90

i get:

Unknown option: GLOB_product_id_code
compilation aborted for test.f90 (code 1)

any ideas?
0 Kudos
Ron_Green
Moderator
919 Views
make sure to

source ~/intel/bin/ifortvars.sh intel64

The error you describe sounds like your PATH is pointing to the new 'ifort' command, but the LD_LIBRARY_PATH is picking up the dir for older .so libs from an older compiler. Check your PATH an LD_LIBRARY_PATH, INCLUDE, etc.

ron
0 Kudos
adamswetnam
Beginner
919 Views
Thanks again, I've started a new thread about an error message which has been introduced in by updating.
0 Kudos
Steven_L_Intel1
Employee
919 Views
Unfortunately, the original issue was not fixed in 12.0. The issue is already under investigation - the id is DPD200168299.
0 Kudos
Steven_L_Intel1
Employee
919 Views
This problem has been fixed for a future release.
0 Kudos
ai3us
Beginner
919 Views
Hello Steve I am encountering the same problem using 12.0. Has this issue been fixed? The guide for theIntel Fortran Composer XE 2011 forLinux*mentions it so I am not sure if it is fixed yet. If not, what future release can it be expected in and when can we expect this release?

Thanks

Jeremy
0 Kudos
Steven_L_Intel1
Employee
919 Views
A release later this year, not an update.
0 Kudos
Reply