IBM Extension

SIZEOF(A)

Purpose

Returns the size of an argument in bytes.

Class

Inquiry function

Argument type and attributes

A
is a data object that cannot be any of the following:
  • A Fortran 90 pointer
  • An automatic object
  • An allocatable object
  • A derived object or record structure that has an allocatable or a Fortran 90 pointer component
  • An array section
  • An array constructor
  • An assumed-shape array
  • A whole assumed-size array
  • A zero-sized array
  • A derived object or record structure containing components not accessible within the scoping unit

SIZEOF must not be passed as an argument to a subprogram.

Result type and attributes

Default integer scalar.

Result value

The size of the argument in bytes.

Examples

The following example assumes that -qintsize=4.

    INTEGER ARRAY(10)
    INTEGER*8, PARAMETER :: p = 8
    STRUCTURE /STR/
      INTEGER I
      COMPLEX C
    END STRUCTURE
    RECORD /STR/ R
    CHARACTER*10 C
    TYPE DTYPE
      INTEGER ARRAY(10)
    END TYPE
    TYPE (DTYPE) DOBJ
    PRINT *, SIZEOF(ARRAY), SIZEOF (ARRAY(3)), SIZEOF(P) ! Array, array
                                                         ! element ref,
                                                         ! named constant

    PRINT *, SIZEOF (R), SIZEOF(R.C)                     ! record structure
                                                         ! entity, record
                                                         ! structure
                                                         ! component

    PRINT *, SIZEOF (C(2:5)), SIZEOF(C)                  ! character
                                                         ! substring,
                                                         ! character
                                                         ! variable

    PRINT *, SIZEOF (DOBJ), SIZEOF(DOBJ%ARRAY)           ! derived type
                                                         ! object, structure
                                                         ! component

The following is sample output generated by the program above:

    40   4   8
    16   8
     4  10
    40  40

Related information

See the XL Fortran Compiler Reference for details about the -qintsize compiler option.

End of IBM Extension