From owner-sc22wg5  Mon Aug  6 18:09:44 2001
Received: from nameserv.rl.ac.uk (nameserv.rl.ac.uk [130.246.135.129])
	by dkuug.dk (8.9.2/8.9.2) with ESMTP id SAA69132
	for <SC22WG5@dkuug.dk>; Mon, 6 Aug 2001 18:09:44 +0200 (CEST)
	(envelope-from jkr@jkr.cc.rl.ac.uk)
Received: from jkr.cc.rl.ac.uk (jkr.cc.rl.ac.uk [130.246.8.20])
	by nameserv.rl.ac.uk (8.8.8/8.8.8) with ESMTP id RAA09911
	for <SC22WG5@dkuug.dk>; Mon, 6 Aug 2001 17:09:43 +0100
Received: (from jkr@localhost)
	by jkr.cc.rl.ac.uk (8.8.8+Sun/8.8.8) id RAA23326
	for SC22WG5@dkuug.dk; Mon, 6 Aug 2001 17:11:53 +0100 (BST)
Date: Mon, 6 Aug 2001 17:11:53 +0100 (BST)
From: John Reid <jkr@rl.ac.uk>
Message-Id: <200108061611.RAA23326@jkr.cc.rl.ac.uk>
To: SC22WG5@dkuug.dk
Subject: Interpretation F90/000164
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

The WG5 interps subgroup worked on F90/000164 after the WG5 meeting in
London had finished, and I acted as scribe. 

I have since found what I think is an error. In ANSWER, Example 2, at
the end of (a), we had: 'However, no access to the component COMP of
such an object is permissible in MAIN.'. I have deleted this since this
is contradicted by Example 2, (b).

I also noticed that in the question, there were two places where 
END MODULE was written in place of END PROGRAM. I have corrected this. 

Rather than send this directly to J3, I prefer to invite everyone to comment
on the present version. 

Thanks,

John.


                                                       J3/01-xxx

Date:    6 July 2001
To:      J3
From:    WG5 interps subgroup in London
Subject: Interpretation F90/000164 (Use of ONLY with multipart definitions)


NUMBER: F90/000164
TITLE: Use of ONLY with multipart definitions
KEYWORDS: ONLY, module, derived type
DEFECT TYPE:
STATUS: J3 consideration in progress

QUESTION: Sections 11.3.1 and 11.3.2, among others, describe how accessibility
of data objects, derived type definitions, etc.  can be controlled via the ONLY
clause of the USE statement and via the PUBLIC and PRIVATE accessibility
attributes/statements.  But these sections do not describe what happens when a
definition consists of multiple parts and only some of the parts have their
accessibility controlled.  Examples include, but are not limited, to the
following:

Example 1:
              MODULE MOD
              INTEGER, PARAMETER :: MAX_SIZE = 100
              INTEGER, DIMENSION(MAX_SIZE) :: ARRAY
              END MODULE

              PROGRAM MAIN
              USE MOD, ONLY: ARRAY
              ...
              END PROGRAM

Since the declaration of ARRAY depends on the value of MAX_SIZE, is it valid to
only allow access to ARRAY?  Is the array constructor for ARRAY, for example,
accessible to the main program?

Example 2:
              MODULE MOD

              TYPE INNER
                INTEGER I
              END TYPE

              TYPE OUTER
                INTEGER K
                TYPE(INNER) COMP
              END TYPE

              END MODULE

              PROGRAM MAIN
                USE MOD, ONLY: OUTER
                ...
              END PROGRAM

The derived type OUTER in module MOD has a component of derived type INNER.
However, when the main program accesses the module, it restricts access to only
derived type OUTER.  Since OUTER depends on the definition of INNER, is it valid
to only allow access to OUTER?  If it is not valid, is it only an error if
something in the main program actually tries to use OUTER?  Can you write a
structure constructor for OUTER in the main program?  If it is valid, can
component I of substructure COMP be referenced?

Example 3:
              MODULE MOD

              TYPE DEF
                INTEGER K
                REAL    R
              END TYPE

              TYPE(DEF) VAR

              END MODULE

              PROGRAM MAIN
                USE MOD, ONLY: VAR
                ...
              END PROGRAM

In this example, only the variable VAR from the module is accessible; its type
is not.  Is this valid?  If it is valid, can only the structure name VAR be
referenced or can its components also be referenced?  If only the structure name
VAR can be referenced, what is the meaning when the structure name is included
in a namelist object list for input and/or output?

Example 4:
              MODULE MOD
              INTEGER, PARAMETER :: MAX_SIZE = 100
              INTEGER, DIMENSION(MAX_SIZE) :: ARRAY
              PRIVATE MAX_SIZE
              END MODULE

              PROGRAM MAIN
              USE MOD
              ...
              END PROGRAM

Another way to limit access to items in modules is via the PRIVATE
attribute/statement.  Since the declaration of ARRAY depends on the value of
MAX_SIZE, is it valid to only allow access to ARRAY?  Is the array constructor
for ARRAY, for example, accessible to the main program?

ANSWER:

Example 1: Yes, ARRAY is accessible, including its size, so an array constructor
of size 100 may be used in an assignment statement for ARRAY.

Example 2: 
  (a) Yes, it is valid to access only OUTER and declare objects of type
      OUTER. 
  (b) Yes, the constructor constructor may be used in the main program.
      For example,
              TYPE(OUTER) X,Y
              X%COMP%I = 65
              Y = OUTER(13,X%COMP)
  (c) Yes, component I substructure COMP may be referenced.

Example 3: 
  (a) Yes, there is no requirement that a type be accessible for a entity 
      of that type to be accessible.
  (b) Both VAR and its components may be referenced.
  (c) Not applicable.
These questions were resolved by interpretation 85, which made a clarifying 
edit to 14.1.2.5.

Example 4: Yes, it is valid to allow access only to ARRAY. ARRAY is accessible, 
including its size, so an array constructor of size 100 may be used in an 
assignment statement for ARRAY.

EDIT: None. 

SUBMITTED BY: Larry Rolison

HISTORY: 94-038 m128 submitted





