The Elk Code
sort.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2024 J. K. Dewhurst and S. Sharma.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 !BOP
7 ! !ROUTINE: sort
8 ! !INTERFACE:
9 subroutine sort(n,x)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! n : number of elements in array (in,integer)
12 ! x : real array (inout,real(n))
13 ! !DESCRIPTION:
14 ! Sorts elements of a real array into ascending order. See {\tt sortidx}.
15 !
16 ! !REVISION HISTORY:
17 ! Created May 2024 (JKD)
18 !EOP
19 !BOC
20 implicit none
21 integer, intent(in) :: n
22 real(8), intent(inout) :: x(n)
23 ! automatic arrays
24 integer idx(n)
25 real(8) xt(n)
26 xt(1:n)=x(1:n)
27 ! find the permutation index
28 call sortidx(n,xt,idx)
29 x(1:n)=xt(idx(1:n))
30 end subroutine
31 !EOC
32 
pure subroutine sortidx(n, x, idx)
Definition: sortidx.f90:10
subroutine sort(n, x)
Definition: sort.f90:10