J3/06-166 Date: 22 April 2006 To: J3 From: Aleksandar Donev Subject: STORAGE_SIZE Ref: Rewrite of J3/06-147. Also see: J3-004, 05-239, 05-250 Detailed Specification: Create a procedure to return the size in bits of its argument. Syntax: STORAGE_SIZE (X [,KIND]) returns the storage size in bits that a nonpointer nonallocatable scalar of the same dynamic type of X would have. A new concept of "storage context" is defined since objects of certain derived types may not appear in storage association contexts, through which we currently define storage units. The result value is the size in bits of the storage unit (16.4.3.1) in a storage (association) context for a nonpointer nonallocatable scalar with a declared type and type parameters that are the same as the dynamic type of X. If KIND is present, the result is an integer of kind KIND; otherwise, the result is default integer. Edits: The edits are against 04-007. ___________________ [415:39] Replace the first sentence of the paragraph with: "Storage sequences are used to describe relationships that exist among variables, common blocks, and result variables, as well as the physical representation storage requirements for objects that occupy physical storage." ___________________ DONEV: Should there be a connection between file storage and physical storage sequences? [416:6+] Add new paragraph and note: A storage context occurs when an object occupies a physical storage sequence. The size of the storage sequence occupied by a scalar nonpointer nonalloctable object in a storage context can be obtained from the intrinsic function STORAGE_SIZE (13.7.115+) and is the same for all objects with the same dynamic type and type parameters. Whether an object occupies physical storage is processor-dependent. NOTE 16.13+: Physical storage is typically hardware memory and consists of a sequence of bits grouped into bytes. Variables will typically occupy virtual memory, and they may or may not occupy physical memory. Additionally, processors may optimize programs by not storing certain variables at all. There is no mechanism for a user to tell whether a variable occupies physical memory, however, the user can estimate what the necessary storage requirements would be with the intrinsic function STORAGE_SIZE (13.7.115+). Note that pointer and allocatable objects occupy storage indendent of their association or allocation status. When an allocatable object is allocated, the allocation occupies a storage sequence distinct from that of the allocatable object itself. [End Note] ___________________ [416:7] Replace "In a storage association context" with "In a storage context or a storage association context" ___________________ [416: 24+] Add a new item to the list: (9) An allocatable object occupies a single unspecified storage unit that is different from that of any nonallocatable object and is different for each combination of type, type parameters, and rank. ___________________ Edits to add STORAGE_SIZE: [296:19+] Add a table entry: "STORAGE_SIZE (A) Size in bits" [354:9+] Add a new section: "13.7.115+ STORAGE_SIZE (X [, KIND]) <> Returns the storage size in bits that a nonpointer nonallocatable scalar of the same dynamic type of X would have. <> Inquiry function. <> X may be of intrinsic or derived type and it may be polymorphic. It may be a scalar or an array. If it is has either the POINTER or the ALLOCATABLE attribute and it is either polymorphic or its type has any deferred type parameters, it shall be a pointer that is associated or an allocatable object that is allocated. KIND (optional) shall be a scalar integer initialization expression. <> Integer scalar. If KIND is present, the kind type parameter is that specified by the value of KIND; otherwise, the kind type parameter is that of default integer type. <> The result value is the size in bits of the storage unit (16.4.3.1) in a storage context or a storage association context for a nonpointer nonallocatable scalar with a declared type and type parameters that are the same as the dynamic type of X. <> STORAGE_SIZE(1.0) returns the number of bits required to store an entity of type default real. Similarly, SIZE(A)*STORAGE_SIZE(A) gives the number of bits required to store the nonpointer nonallocatable array A, the target of an associated array pointer A, or the allocation of an allocated allocatable array A. These edits do not collide with existing edits in 05-014r1.