source to correspond to
shape. If necessary, the new array may be padded with elements from
pad or permuted as defined by
Fortran 95 and later
result = reshape(source, shape[, pad, order])
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
order- (Optional) shall be of type
integerand an array of the same shape as
shape. Its values shall be a permutation of the numbers from 1 to n, where n is the size of
orderis absent, the natural ordering shall be assumed.
The result is an array of shape
shape with the same type as
program test_reshape integer, dimension(4) :: x write(*,*) shape(x) ! prints "4" write(*,*) shape(reshape(x, (/2, 2/))) ! prints "2 2" end program