[UP]


Manual Reference Pages  - reshape (3)

NAME

reshape(3f) - [FORTRAN:INTRINSIC:ARRAY RESHAPE] Function to reshape an array

CONTENTS

Syntax
Description
Arguments
Return Value
Example
Standard
Class
See Also

SYNTAX

result = reshape(source, shape[, pad, order])

DESCRIPTION

Reshapes array SOURCE to correspond to SHAPE. If necessary, the new array may be padded with elements from PAD or permuted as defined by ORDER.

ARGUMENTS

SOURCE - an array of any type.
SHAPE - an array of rank one and type INTEGER. Its values must be positive or zero.
PAD - (Optional) an array of the same type as SOURCE.
ORDER - (Optional) an array of type INTEGER and the same shape as SHAPE. Its values shall be a permutation of the numbers from 1 to n, where n is the size of SHAPE. If ORDER is absent, the natural ordering shall be assumed.

RETURN VALUE

The result is an array of shape SHAPE with the same type as SOURCE.

EXAMPLE

Sample program:

    program demo_reshape
      integer, dimension(4) :: x=[(i,i=10,40,10)]
      ! X is originally a vector with four elements
      write(*,*) shape(x)                     ! prints "4"
      write(*,*) shape(reshape(x, [2, 2]))    ! prints "2 2"
    end program demo_reshape

Results: 4
2

STANDARD

[[Fortran 95]] and later

CLASS

Transformational function

SEE ALSO

[[shape]]


reshape (3) March 19, 2019
Generated by manServer 1.08 from 2ceac4b1-979d-44cd-97a3-69af95f7bff3 using man macros.