ForwardShift Subroutine

public subroutine ForwardShift(myArray, N)

\addtogroup SELF_SupportRoutines @{ \fn ForwardShift Shift an array integers by one index forward, moving the last index to the first.

Shifts the array entries as follows :
myArray(1) <-- myArray(N)
myArray(2) <-- myArray(1)
myArray(3) <-- myArray(2)

Usage :

INTEGER :: N INTEGER :: myArray(1:N)
....
CALL ForwardShift( myArray, N )

Parameters :

in/out myArray(1:N) INTEGER On output, the input array with elements shifted forward by one index.
in N INTEGER The number of elements in the array

@}

Arguments

TypeIntentOptionalAttributesName
integer, intent(inout) :: myArray(1:N)
integer, intent(in) :: N

Contents

Source Code


Source Code

  subroutine ForwardShift(myArray,N)

    implicit none
    integer,intent(in)    :: N
    integer,intent(inout) :: myArray(1:N)
    ! LOCAL
    integer :: temp(1:N)

    temp = myArray
    myArray(1) = temp(N)
    myArray(2:N) = temp(1:N-1)

  endsubroutine ForwardShift