RESHAPE — Function to reshape an array#
-
RESHAPE(SOURCE, SHAPE, PAD, ORDER)#
Reshapes
SOURCEto correspond toSHAPE. If necessary, the new array may be padded with elements fromPADor permuted as defined byORDER.- Parameters:
SOURCE – Shall be an array of any type.
SHAPE – Shall be of type
INTEGERand an array of rank one. Its values must be positive or zero.PAD – (Optional) shall be an array of the same type as
SOURCE.ORDER – (Optional) shall be of type
INTEGERand an array of the same shape asSHAPE. Its values shall be a permutation of the numbers from 1 to n, where n is the size ofSHAPE. IfORDERis absent, the natural ordering shall be assumed.
- Returns:
The result is an array of shape
SHAPEwith the same type asSOURCE.
- Standard:
Fortran 90 and later
- Class:
Transformational function
- Syntax:
RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])
- Example:
PROGRAM test_reshape INTEGER, DIMENSION(4) :: x WRITE(*,*) SHAPE(x) ! prints "4" WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2" END PROGRAM
- See also: