Manual Reference Pages  - storage_size (3fortran)

NAME

STORAGE_SIZE(3) - [BIT:INQUIRY] Storage size in bits

SYNOPSIS

result = storage_size(a [,KIND] )

         integer(kind=KIND) storage_size(a,KIND)

type(TYPE(kind=**)) :: a integer,intent(in),optional :: KIND

CHARACTERISTICS

o a kind designated as ** may be any supported kind for the type
o A may be of any type and kind. If it is polymorphic it shall not be an undefined pointer. If it is unlimited polymorphic or has any deferred type parameters, it shall not be an unallocated allocatable variable or a disassociated or undefined pointer.
o The kind type parameter of the returned value is that specified by the value of KIND; otherwise, the kind type parameter is that of default integer type.
o The result is an integer scalar of default kind unless KIND is specified, in which case it has the kind specified by KIND.

DESCRIPTION

STORAGE_SIZE(3) returns the storage size of argument A in bits.

OPTIONS

o A : The entity to determine the storage size of
o KIND : a scalar integer constant expression that defines the kind of the output value.

RESULT

The result value is the size expressed in bits for an element of an array that has the dynamic type and type parameters of A.

If the type and type parameters are such that storage association applies, the result is consistent with the named constants defined in the intrinsic module ISO_FORTRAN_ENV.

NOTE1

An array element might take "type" more bits to store than an isolated scalar, since any hardware-imposed alignment requirements for array elements might not apply to a simple scalar variable.

NOTE2

This is intended to be the size in memory that an object takes when it is stored; this might differ from the size it takes during expression handling (which might be the native register size) or when stored in a file. If an object is never stored in memory but only in a register, this function nonetheless returns the size it would take if it were stored in memory.

EXAMPLES

Sample program

    program demo_storage_size
    implicit none

! a default real, integer, and logical are the same storage size write(*,*)’size of integer ’,storage_size(0) write(*,*)’size of real ’,storage_size(0.0) write(*,*)’size of logical ’,storage_size(.true.) write(*,*)’size of complex ’,storage_size((0.0,0.0))

! note the size of an element of the array, not the storage size of ! the entire array is returned for array arguments write(*,*)’size of integer array ’,storage_size([0,1,2,3,4,5,6,7,8,9])

end program demo_storage_size

Results:

      > size of integer                 32
      > size of real                    32
      > size of logical                 32
      > size of complex                 64
      > size of integer array           32

STANDARD

Fortran 2008

SEE ALSO

C_SIZEOF(3)

Fortran intrinsic descriptions


Nemo Release 3.1 storage_size (3fortran) November 02, 2024
Generated by manServer 1.08 from ad5889dc-4254-4481-8480-bc8aa321f645 using man macros.