Intel® Fortran Compiler 16.0 User and Reference Guide
Transformational Intrinsic Function (Generic): Performs an end-off shift on a rank-one array, or performs end-off shifts on all the complete rank-one sections along a given dimension of an array of rank two or greater. Elements are shifted off at one end of a section and copies of a boundary value are filled in at the other end. Different sections can have different boundary values and can be shifted by different amounts and in different directions.
result = EOSHIFT (array,shift [,boundary][,dim])
The result is an array with the same type and kind parameters, and shape as array.
If array has rank one, the same shift is applied to each element. If an element is shifted off one end of the array, the boundary value is placed at the other end the array.
If array has rank greater than one, each section (s1, s2, ..., sdim-1, :, sdim+1, ..., sn) of the result is shifted as follows:
By the value of shift, if shift is scalar
According to the corresponding value in shift(s1, s2, ..., sdim-1, sdim+1, ..., sn), if shift is an array
If an element is shifted off one end of a section, the boundary value is placed at the other end of the section.
The value of shift determines the amount and direction of the end- off shift. A positive shift value causes a shift to the left (in rows) or up (in columns). A negative shift value causes a shift to the right (in rows) or down (in columns).
V is the integer array (1, 2, 3, 4, 5, 6).
EOSHIFT (V, SHIFT=2) shifts the elements in V to the left by 2 positions, producing the value (3, 4, 5, 6, 0, 0). 1 and 2 are shifted off the beginning and two elements with the default BOUNDARY value are placed at the end.
EOSHIFT (V, SHIFT= -3, BOUNDARY= 99) shifts the elements in V to the right by 3 positions, producing the value (99, 99, 99, 1, 2, 3). 4, 5, and 6 are shifted off the end and three elements with BOUNDARY value 99 are placed at the beginning.
M is the CHARACTER(LEN=1) array
[ 1 2 3 ] [ 4 5 6 ] [ 7 8 9 ].
EOSHIFT (M, SHIFT = 1, BOUNDARY = '*', DIM = 2) produces the result
[ 2 3 * ] [ 5 6 * ] [ 8 9 * ].
Each element in rows 1, 2, and 3 is shifted to the left by 1 position. This causes the first element in each row to be shifted off the beginning, and the BOUNDARY value to be placed at the end.
EOSHIFT (M, SHIFT = -1, DIM = 1) produces the result
[ ^ ^ ^ ] [ 1 2 3 ] [ 4 5 6 ].
Each element in columns 1, 2, and 3 is shifted down by 1 position. This causes the last element in each column to be shifted off the end and the BOUNDARY value (the default character boundary value <space>, represented by "^") to be placed at the beginning.
EOSHIFT (M, SHIFT = (/1, -1, 0/), BOUNDARY = (/ '*', '?', '/' /), DIM = 2) produces the result
[ 2 3 * ] [ ? 4 5 ] [ 7 8 9 ].
Each element in row 1 is shifted to the left by 1 position, causing the first element to be shifted off the beginning and the BOUNDARY value * to be placed at the end. Each element in row 2 is shifted to the right by 1 position, causing the last element to be shifted off the end and the BOUNDARY value ? to be placed at the beginning. No element in row 3 is shifted at all, so the specified BOUNDARY value is not used.
The following shows another example:
INTEGER shift(3) CHARACTER(1) array(3, 3), AR1(3, 3) array = RESHAPE ((/'A', 'D', 'G', 'B', 'E', 'H', & 'C', 'F', 'I'/), (/3,3/)) ! array is A B C ! D E F ! G H I shift = (/-1, 1, 0/) AR1 = EOSHIFT (array, shift, BOUNDARY = (/'*','?','#'/), DIM= 2) ! returns * A B ! E F ? ! G H I