- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The PRIVATE applies to everything in the module not explicitly given the PUBLIC attribute.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page