Sort 1D arrays, real or integer, according the first one
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(inout), | dimension(n) | :: | tab_inout |
reference array to sort |
|
integer(kind=I4), | intent(inout), | optional, | dimension(n) | :: | tab0 |
second array to sort according the order of the first one |
class(*), | intent(inout), | optional, | dimension(n) | :: | tab1 |
third array to sort according the order of the first one |
class(*), | intent(inout), | optional, | dimension(n) | :: | tab2 |
4th array to sort according the order of the first one |
class(*), | intent(inout), | optional, | dimension(n) | :: | tab3 |
5th array to sort according the order of the first one |
integer(kind=I4), | intent(in) | :: | n |
size of the arrays |
subroutine sort_array2(tab_inout, tab0, tab1, tab2, tab3, n) !! Sort 1D arrays, real or integer, according the first one implicit none integer(kind=I4), intent(in) :: n !! *size of the arrays* class(*) , intent(inout), dimension(n) :: tab_inout !! *reference array to sort* integer(kind=I4), intent(inout), dimension(n), optional :: tab0 !! *second array to sort according the order of the first one* class(*) , intent(inout), dimension(n), optional :: tab1 !! *third array to sort according the order of the first one* class(*) , intent(inout), dimension(n), optional :: tab2 !! *4th array to sort according the order of the first one* class(*) , intent(inout), dimension(n), optional :: tab3 !! *5th array to sort according the order of the first one* integer(kind=I4), allocatable, dimension(:) :: tab_order allocate( tab_order(1:n) ) if ( .not.present(tab0) ) then call init_order(order = tab_order(1:n), n = n) else tab_order(1:n) = tab0(1:n) endif select type(tab_inout) type is( integer(kind=I4) ) call sort_array_integer_with_order(g = 1, d = n, itabref = tab_inout(1:n), order = tab_order(1:n)) type is( real(kind=R8) ) call sort_array_real_with_order (g = 1, d = n, rtabref = tab_inout(1:n), order = tab_order(1:n)) endselect if ( present(tab1) ) call change_array_order(tab_inout = tab1(1:n), order = tab_order(1:n), n = n) if ( present(tab2) ) call change_array_order(tab_inout = tab2(1:n), order = tab_order(1:n), n = n) if ( present(tab3) ) call change_array_order(tab_inout = tab3(1:n), order = tab_order(1:n), n = n) if ( present(tab0) ) then tab0(1:n) = tab_order(1:n) endif deallocate( tab_order ) return endsubroutine sort_array2