change_array_order Subroutine

private subroutine change_array_order(tab_inout, order, n)

Given an order vector, sort a real or integer vector

Arguments

Type IntentOptional Attributes Name
class(*), intent(inout), dimension(n) :: tab_inout

array to sort

integer(kind=I4), intent(inout), dimension(n) :: order

order vector

integer(kind=I4), intent(in) :: n

size of the arrays


Called by

proc~~change_array_order~~CalledByGraph proc~change_array_order change_array_order proc~sort_array2 sort_array2 proc~sort_array2->proc~change_array_order proc~from_elemental_to_assembled from_elemental_to_assembled proc~from_elemental_to_assembled->proc~sort_array2 proc~melange melange proc~melange->proc~sort_array2 proc~read_surf~2 read_surf proc~read_surf~2->proc~sort_array2 program~main main program~main->proc~sort_array2 proc~convert_matrice_format convert_matrice_format proc~convert_matrice_format->proc~from_elemental_to_assembled program~test_algen test_algen program~test_algen->proc~melange program~test_surfile test_surfile program~test_surfile->proc~read_surf~2 program~test_solvers test_solvers program~test_solvers->proc~convert_matrice_format

Source Code

   subroutine change_array_order(tab_inout, order, n)
   !! Given an order vector, sort a real or integer vector
   implicit none
   integer(kind=I4), intent(in)                  :: n          !! *size of the arrays*
   class(*)        , intent(inout), dimension(n) :: tab_inout  !! *array to sort*
   integer(kind=I4), intent(inout), dimension(n) :: order      !! *order vector*

      integer(kind=I4) :: i

      integer(kind=I4), allocatable, dimension(:) :: tab_int
      real(kind=R8),    allocatable, dimension(:) :: tab_real


      select type(tab_inout)

         type is( integer(kind=I4) )

            allocate( tab_int(1:n) )

            tab_int(1:n) = tab_inout(1:n)

            do i = 1, n

               tab_inout( i ) = tab_int( order(i) )

            enddo

            deallocate( tab_int )

         type is( real(kind=R8) )

            allocate( tab_real(1:n) )

            tab_real(1:n) = tab_inout(1:n)

            do i = 1, n

               tab_inout( i ) = tab_real( order(i) )

            enddo

            deallocate( tab_real )

      endselect

   return
   endsubroutine change_array_order