Invert a given array 1 2 3 4 5 -> 5 4 3 2 1
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk), | intent(inout) | :: | me(:,:) |
array to invert |
||
integer, | intent(in) | :: | nElems |
number of elements in the array |
subroutine tem_invertRealRkArray( me, nElems ) ! --------------------------------------------------------------------------- !> array to invert real(kind=rk), intent(inout) :: me(:,:) !> number of elements in the array integer, intent(in) :: nElems ! --------------------------------------------------------------------------- real(kind=rk) :: tmp_entry(3) integer :: maxPos, minPos ! --------------------------------------------------------------------------- minPos = 1 maxPos = nElems do while( minPos .lt. maxPos ) tmp_entry = me( :, minPos ) me( :, minPos ) = me( :, maxPos ) me( :, maxPos ) = tmp_entry minPos = minPos + 1 maxPos = maxPos - 1 end do end subroutine tem_invertRealRkArray