V3FIT
GTOVMI
Sources
Akima
ssort.f
1
2
SUBROUTINE
ssort (x, iy, n)
3
USE
precision
4
IMPLICIT NONE
5
6
c
7
c example of an insertion sort
8
c
9
c***begin prologue ssort
10
c***purpose sort an array and make the same inTerchanges in
11
c an auxiliary array. the array is sorted in
12
c decreasing order.
13
c***keywords sort, sorting
14
c
15
c description of parameters
16
c x - array of values to be sorted (usually abscissas)
17
c iy - array to be carried with x (ALL swaps of x elements are
18
c matched in iy . after the sort iy(j) CONTAINS the original
19
c postition of the value x(j) in the unsorted x array.
20
c n - number of values in array x to be sorted
21
c
22
c***revision history (yymmdd)
23
c 950310 date written
24
c john mahaffy
25
c***end prologue ssort
26
c .. scalar arguments ..
27
INTEGER
n
28
c .. array arguments ..
29
REAL
(rprec) x(*)
30
INTEGER
iy(*)
31
c .. local scalars ..
32
REAL
(rprec) temp
33
INTEGER
i, j, k, itemp
34
c
35
c***first executable statement ssort
36
c
37
DO
100 i=2,n
38
IF
( x(i) .GT. x(i-1) )
THEN
39
DO
50 j=i-2,1,-1
40
IF
(x(i) .LT. x(j))
GOTO
70
41
50
CONTINUE
42
j=0
43
70 temp=x(i)
44
itemp=iy(i)
45
DO
90 k=i,j+2,-1
46
iy(k)=iy(k-1)
47
90 x(k)=x(k-1)
48
x(j+1)=temp
49
iy(j+1)=itemp
50
ENDIF
51
100
CONTINUE
52
END SUBROUTINE
ssort
53
Generated on Thu Mar 5 2020 15:49:23 for V3FIT by
1.8.17