source: trunk/MagicSoft/Simulation/Corsika/Mmcs/flpsor.f@ 18679

Last change on this file since 18679 was 286, checked in by harald, 25 years ago
This is the start point for further developments of the Magic Monte Carlo Simulation written by Jose Carlos Gonzales. Now it is under control of one CVS repository for the whole collaboration. Everyone should use this CVS repository for further developments.
File size: 1.5 KB
Line 
1 SUBROUTINE FLPSOR(A,N)
2
3C-----------------------------------------------------------------------
4C CERN PROGLIB# M103 FLPSOR .VERSION KERNFOR 3.15 820113
5C ORIG. 29/04/78
6C-----------------------------------------------------------------------
7C SORT THE ONE-DIMENSIONAL FLOATING POINT ARRAY A(1),...,A(N) BY
8C INCREASING VALUES
9C
10C PROGRAM M103 TAKEN FROM CERN PROGRAM LIBRARY, 29-APR-78
11C-----------------------------------------------------------------------
12
13 DIMENSION A(*)
14 COMMON /SLATE/ LT(20),RT(20)
15 INTEGER R,RT
16C-----------------------------------------------------------------------
17
18 LEVEL=1
19 LT(1)=1
20 RT(1)=N
21 10 L=LT(LEVEL)
22 R=RT(LEVEL)
23 LEVEL=LEVEL-1
24 20 IF(R.GT.L) GO TO 200
25 IF(LEVEL) 50,50,10
26C
27C SUBDIVIDE THE INTERVAL L,R
28C L : LOWER LIMIT OF THE INTERVAL (INPUT)
29C R : UPPER LIMIT OF THE INTERVAL (INPUT)
30C J : UPPER LIMIT OF LOWER SUB-INTERVAL (OUTPUT)
31C I : LOWER LIMIT OF UPPER SUB-INTERVAL (OUTPUT)
32C
33 200 I=L
34 J=R
35 M=(L+R)/2
36 X=A(M)
37 220 IF(A(I).GE.X) GO TO 230
38 I=I+1
39 GO TO 220
40 230 IF(A(J).LE.X) GO TO 231
41 J=J-1
42 GO TO 230
43C
44 231 IF(I.GT.J) GO TO 232
45 W=A(I)
46 A(I)=A(J)
47 A(J)=W
48 I=I+1
49 J=J-1
50 IF(I.LE.J) GO TO 220
51C
52 232 LEVEL=LEVEL+1
53 IF((R-I).GE.(J-L)) GO TO 30
54 LT(LEVEL)=L
55 RT(LEVEL)=J
56 L=I
57 GO TO 20
58 30 LT(LEVEL)=I
59 RT(LEVEL)=R
60 R=J
61 GO TO 20
62 50 RETURN
63 END
Note: See TracBrowser for help on using the repository browser.