EOSHIFT (The GNU Fortran Compiler) (original) (raw)
Synopsis:
RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])
Description:
EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])
performs an end-off shift on elements of ARRAY along the dimension of DIM. If DIM is omitted it is taken to be 1
. DIM is a scalar of typeINTEGER
in the range of 1 \leq DIM \leq n) where n is the rank of ARRAY. If the rank of ARRAY is one, then all elements ofARRAY are shifted by SHIFT places. If rank is greater than one, then all complete rank one sections of ARRAY along the given dimension are shifted. Elements shifted out one end of each rank one section are dropped. IfBOUNDARY is present then the corresponding value of from BOUNDARYis copied back in the other end. If BOUNDARY is not present then the following are copied in depending on the type of ARRAY.
Array Type | Boundary Value |
---|---|
Numeric | 0 of the type and kind of ARRAY. |
Logical | .FALSE.. |
Character(len) | len blanks. |
Class:
Transformational function
Arguments:
ARRAY | May be any type, not scalar. |
---|---|
SHIFT | The type shall be INTEGER. |
BOUNDARY | Same type as ARRAY. |
DIM | The type shall be INTEGER. |
Notes:
ARRAY can also be UNSIGNED
.
Return value:
Returns an array of same type and rank as the ARRAY argument.
Example:
program test_eoshift
integer, dimension(3,3) :: a
a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print '(3i3)', a(3,:)
a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
print *
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print '(3i3)', a(3,:)
end program test_eoshift
Standard:
Fortran 90 and later, extension for UNSIGNED
(see Unsigned integers)