OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
itrimhpsort.F
Go to the documentation of this file.
1Copyright> OpenRadioss
2Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3Copyright>
4Copyright> This program is free software: you can redistribute it and/or modify
5Copyright> it under the terms of the GNU Affero General Public License as published by
6Copyright> the Free Software Foundation, either version 3 of the License, or
7Copyright> (at your option) any later version.
8Copyright>
9Copyright> This program is distributed in the hope that it will be useful,
10Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12Copyright> GNU Affero General Public License for more details.
13Copyright>
14Copyright> You should have received a copy of the GNU Affero General Public License
15Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16Copyright>
17Copyright>
18Copyright> Commercial Alternative: Altair Radioss Software
19Copyright>
20Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21Copyright> software under a commercial license. Contact Altair to discuss further if the
22Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23!||====================================================================
24!|| itrimhpsort ../starter/source/output/cluster/itrimhpsort.F
25!||--- called by ------------------------------------------------------
26!|| hm_read_cluster ../starter/source/output/cluster/hm_read_cluster.F
27!||====================================================================
28 SUBROUTINE itrimhpsort(TAB,LEN)
29C-----------------------------------------------
30c in place heap sort algorithm of integer table with elimination
31c of double entries. Returns the sorted table and final length.
32C-----------------------------------------------
33C I m p l i c i t T y p e s
34C-----------------------------------------------
35#include "implicit_f.inc"
36C-----------------------------------------------
37C D u m m y A r g u m e n t s
38C-----------------------------------------------
39 INTEGER :: LEN, TAB(LEN)
40C-----------------------------------------------
41C L o c a l V a r i a b l e s
42C-----------------------------------------------
43 INTEGER I,J,K,L,VAL
44c=======================================================================
45 IF (len < 2) RETURN
46 l = len/2 + 1
47 k = len
48c
49 !The index L will be decremented from its initial value during the
50 !"hKing" (heap creation) phase. Once it reaches 1, the index K
51 !will be decremented from its initial value down to 1 during the
52 !"retKement-and-promotion" (heap selection) phase.
53
54 DO ! main heap sort loop
55 IF (l > 1)THEN
56 l=l-1
57 val=tab(l)
58 ELSE
59 val=tab(k)
60 tab(k)=tab(1)
61 k=k-1
62 IF (k == 1) THEN
63 tab(1)=val
64 EXIT
65 END IF
66 END IF
67 i=l
68 j=l+l
69 DO WHILE (j <= k)
70 IF(j < k) THEN
71 IF (tab(j) < tab(j+1)) j=j+1
72 END IF
73 IF (val < tab(j)) THEN
74 tab(i)=tab(j)
75 i=j
76 j=j+j
77 ELSE
78 j=k+1
79 END IF
80 END DO
81 tab(i)=val
82 ENDDO ! main heap sort loop
83c
84c-----------
85c eliminate double entries
86c-----------
87 j = 1
88 val = tab(1)
89 DO i=2,len
90 IF (tab(i) == val) cycle
91 val = tab(i)
92 j = j+1
93 tab(j) = val
94 END DO
95 len = j
96c-----------
97 RETURN
98 END
99
100
101
102
103
104
105
106
107
108
109
subroutine itrimhpsort(tab, len)
Definition itrimhpsort.F:29