I'm trying to write a subroutine to reverse the rows of an array. The following works, but explicitly declares the type of its input arr. Thus I'd need a separate subroutine to do the same thing for an array of type real. Surely there's a way to make it accept an array of arbitrary type - could someone help me with the syntax? Thanks!
SUBROUTINE flipud(arr)
integer, dimension(:,:), intent(inout) :: arr
integer, dimension(:,:), allocatable :: tmp
integer i, j, nrow, ncol, ierr
nrow = size(arr, 1)
ncol = size(arr, 2)
allocate(tmp(nrow, ncol), STAT=ierr)
tmp(:,:) = arr(nrow:1:-1, :)
arr = tmp
deallocate(tmp)
END SUBROUTINE flipud
arr = arr(nrow:1:-1, :)