Manual Reference Pages  - shape (3fortran)

NAME

SHAPE(3) - [ARRAY:INQUIRY] Determine the shape of an array or scalar

SYNOPSIS

result = shape( source [,kind] )

       integer(kind=KIND) function shape( source, KIND )

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

CHARACTERISTICS

o a kind designated as ** may be any supported kind for the type
o SOURCE is an array or scalar of any type. If SOURCE is a pointer it must be associated and allocatable arrays must be allocated. It shall not be an assumed-size array.
o KIND is a constant integer initialization expression.
o the result is an integer array of rank one with size equal to the rank of SOURCE of the kind specified by KIND if KIND is present, otherwise it has the default integer kind.

DESCRIPTION

SHAPE(3) queries the shape of an array.

OPTIONS

o SOURCE : an array or scalar of any type. If SOURCE is a pointer it must be associated and allocatable arrays must be allocated.
o KIND : indicates the kind parameter of the result.

RESULT

An integer array of rank one with as many elements as SOURCE has dimensions.

The elements of the resulting array correspond to the extent of SOURCE along the respective dimensions.

If SOURCE is a scalar, the result is an empty array (a rank-one array of size zero).

EXAMPLES

Sample program:

    program demo_shape
    implicit none
    character(len=*),parameter :: all=’(*(g0,1x))’
    integer, dimension(-1:1, -1:2) :: a
       print all, ’shape of array=’,shape(a)
       print all, ’shape of constant=’,shape(42)
       print all, ’size of shape of constant=’,size(shape(42))
       print all, ’ubound of array=’,ubound(a)
       print all, ’lbound of array=’,lbound(a)
    end program demo_shape

Results:

     > shape of array= 3 4
     > shape of constant=
     > size of shape of constant= 0
     > ubound of array= 1 2
     > lbound of array= -1 -1

STANDARD

Fortran 95 ; with KIND argument Fortran 2003

SEE ALSO

Array inquiry:
o SIZE(3) - Determine the size of an array
o RANK(3) - Rank of a data object
o UBOUND(3) - Upper dimension bounds of an array
o LBOUND(3) - Lower dimension bounds of an array
State Inquiry:
o ALLOCATED(3) - Status of an allocatable entity
o IS_CONTIGUOUS(3) - Test if object is contiguous
Kind Inquiry:
o KIND(3) - Kind of an entity
Bit Inquiry:
o STORAGE_SIZE(3) - Storage size in bits
o BIT_SIZE(3) - Bit size inquiry function
o BTEST(3) - Tests a bit of an integer value.
Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 shape (3fortran) November 02, 2024
Generated by manServer 1.08 from f5eef223-7396-41b4-9476-da469ef95293 using man macros.