\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)
INTEGER :: N
INTEGER :: myArray(1:N)
....
CALL ForwardShift( myArray, N )
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 |
@}
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | myArray(1:N) | |||
integer, | intent(in) | :: | N |
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