The Elk Code
 
Loading...
Searching...
No Matches
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:
9subroutine 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
20implicit none
21integer, intent(in) :: n
22real(8), intent(inout) :: x(n)
23! automatic arrays
24integer idx(n)
25real(8) xt(n)
26xt(1:n)=x(1:n)
27! find the permutation index
28call sortidx(n,xt,idx)
29x(1:n)=xt(idx(1:n))
30end subroutine
31!EOC
32
subroutine sort(n, x)
Definition sort.f90:10
pure subroutine sortidx(n, x, idx)
Definition sortidx.f90:10