sort_int_1real Subroutine

public recursive subroutine sort_int_1real(g, d, itabref, rtab1)


Arguments

Type IntentOptional AttributesName
integer(kind=I4), intent(in) :: g
integer(kind=I4), intent(in) :: d
integer(kind=I4), intent(inout), dimension(:):: itabref
real(kind=R8), intent(inout), dimension(:):: rtab1

Contents

Source Code


Source Code

   recursive subroutine sort_int_1real(g, d, itabref, rtab1)
   implicit none
   integer(kind=I4), intent(in) :: g, d
   integer(kind=I4), dimension(:), intent(inout) :: itabref
   real(kind=R8), dimension(:), intent(inout)    :: rtab1
      integer(kind=I4) :: i, j, mil, cle, itmp
      real(kind=R8)    :: rtmp
      i = g
      j = d
      mil = (g+d)/2
      cle = itabref(mil)

      if (g>=d) return

      do while (i<=j)
         do while (itabref(i)<cle)
            i = i + 1
         enddo
         do while (itabref(j)>cle)
            j = j - 1
         enddo
         if (i<=j) then
            ! échange des éléments du tableau
            itmp       = itabref(i)
            itabref(i) = itabref(j)
            itabref(j) = itmp
            ! échange des éléments du vecteur 3
            rtmp     = rtab1(i)
            rtab1(i) = rtab1(j)
            rtab1(j) = rtmp

            i = i + 1
            j = j - 1
         endif
      enddo

      if (g<j) call sort_int_1real(g, j, itabref, rtab1)
      if (d>i) call sort_int_1real(i, d, itabref, rtab1)

   return
   endsubroutine sort_int_1real