Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

protected variables

Roman1
New Contributor I
95 Views

This might be a stupid question, but does it make sense for a variable to be both PROTECTED and PRIVATE ?  I would have thought that PROTECTED variables are already PUBLIC.  For example, the following program would not compile unless the PROTECTED variable is explicitly made PUBLIC.

module mymod
   integer,protected:: a = 1
   private
   !public a
end module mymod   
   
!------------------------------------------   
   
program test_public
   use mymod, only: a
   implicit none
   write(*,*) a
   stop
end program test_public

 

0 Kudos
1 Reply
Steve_Lionel
Black Belt Retired Employee
95 Views

No, that combination doesn't make sense, though I cannot find words in the standard prohibiting it. I would think that the combination should be allowed though the PROTECTED attribute would never come into play.

Reply