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

module access control

Li_Dong
Beginner
635 Views
Hi, all,

I am wondering how to write a module with different access control. For example, module A and B use module C. I want some entries in C can be accessed by A, but not B. And I hope I needn't to write only list explicitly in B.

Cheers,

DONG Li
0 Kudos
1 Reply
mecej4
Honored Contributor III
635 Views
Although what you want is not directly possible (for obvious reasons: an item is either public or private, subject to the additional requirements imposed by host association; you cannot have have something private for B but public for A), you can achieve the desired results in a few ways.

1. If the entries to be made unavailable to B are few, you can declare in module B:

use C, except1 => C1, except2 => C2, ...

and remember not to use 'except1' and 'except2' anywhere else in module B.

2. You can create a modules CB which declares USE C and, in addition, declares as PRIVATE those items to which you wish to prohibit access from C. Then, in module B, use USE CB instead of USE C
0 Kudos
Reply