[UP]


Manual Reference Pages  - cshift (3)

NAME

cshift(3f) - [FORTRAN:INTRINSIC:TRANSFORMATIONAL FUNCTION] Circular shift elements of an array

SYNTAX

result = cshift(array, shift [, dim])

DESCRIPTION

cshift(array, shift [, dim]) performs a circular 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 type INTEGER in the range of 1 <= DIM <= n, where "n" is the rank of ARRAY. If the rank of ARRAY is one, then all elements of ARRAY 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 shifted back in the other end.

ARGUMENTS

ARRAY Shall be an array of any type.
SHIFT The type shall be INTEGER.
DIM The type shall be INTEGER.

RETURN VALUE

Returns an array of same type and rank as the ARRAY argument.

EXAMPLE

Sample program:

    program demo_cshift
    implicit none
    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 = cshift(a, SHIFT=[1, 2, -1], DIM=2)
        print *
        print ’(3i3)’, a(1,:)
        print ’(3i3)’, a(2,:)
        print ’(3i3)’, a(3,:)
    end program demo_cshift

STANDARD

[[Fortran 95]] and later

CLASS

Transformational function


cshift (3) March 11, 2021
Generated by manServer 1.08 from 722e009d-293d-478d-b36c-77ac6034de0c using man macros.