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

PROTECTED attribute

Svein-Atle_Engeseth
577 Views

Hi,
I believe there is an error in the latest Fortran Compiler,
please see the short program below:

      MODULE TEST_PROTECTED_MODULE
      IMPLICIT NONE
      INTEGER :: A = 10
      PRIVATE
      PROTECTED :: A
      SAVE
      END MODULE TEST_PROTECTED_MODULE
      !
      PROGRAM TEST_PROTECTED
      USE, NON_INTRINSIC :: TEST_PROTECTED_MODULE
      IMPLICIT NONE
      INTEGER :: B = 20
      PRINT*, "B = ",B, "  A = ", A
      END PROGRAM TEST_PROTECTED

The compiler complains that A does not have a type and compilation aborts.
If I comment out the PRIVATE statement, the program compiles and works as expected.

My compiler is Intel(R) Compiler 16.0 (package 110)

Regards,

Svein-Atle Engeseth

0 Kudos
3 Replies
andrew_4619
Honored Contributor III
577 Views

The PRIVATE applies to everything in the module not explicitly given the PUBLIC attribute.   

0 Kudos
Svein-Atle_Engeseth
577 Views

Hi,
So what you are saying is that PROTECTED does not mean PUBLIC and protected from being changed?
That makes the use of PROTECTED very awkward as you have to specify PRIVATE on any entity you want to keep private,
instead of having all PRIVATE and explicitly naming those you want to be PUBLIC or PROTECTED.

Regards

Svein-Atle Engeseth

 

0 Kudos
Svein-Atle_Engeseth
577 Views

Hi,
Please disregard my previous comment.
I just read in the Fortran 2003 Handbook that the specification is like this:
INTEGER, PUBLIC, PROTECTED :: A 
or
INTEGER :: A
PUBLIC :: A
PROTECTED :: A

I apologize for my confusion.

Svein-Atle Engeseth

 

 

 

0 Kudos
Reply