OpenRadioss
2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
itrimhpsort.F
Go to the documentation of this file.
1
Copyright> OpenRadioss
2
Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3
Copyright>
4
Copyright> This program is free software: you can redistribute it and/or modify
5
Copyright> it under the terms of the GNU Affero General Public License as published by
6
Copyright> the Free Software Foundation, either version 3 of the License, or
7
Copyright> (at your option) any later version.
8
Copyright>
9
Copyright> This program is distributed in the hope that it will be useful,
10
Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11
Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
Copyright> GNU Affero General Public License for more details.
13
Copyright>
14
Copyright> You should have received a copy of the GNU Affero General Public License
15
Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16
Copyright>
17
Copyright>
18
Copyright> Commercial Alternative: Altair Radioss Software
19
Copyright>
20
Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21
Copyright> software under a commercial license. Contact Altair to discuss further if the
22
Copyright> 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)
29
C-----------------------------------------------
30
c in place heap sort algorithm of integer table with elimination
31
c of double entries. Returns the sorted table and final length.
32
C-----------------------------------------------
33
C I m p l i c i t T y p e s
34
C-----------------------------------------------
35
#include "implicit_f.inc"
36
C-----------------------------------------------
37
C D u m m y A r g u m e n t s
38
C-----------------------------------------------
39
INTEGER
:: LEN, TAB(LEN)
40
C-----------------------------------------------
41
C L o c a l V a r i a b l e s
42
C-----------------------------------------------
43
INTEGER
I,J,K,L,VAL
44
c=======================================================================
45
IF
(len < 2)
RETURN
46
l = len/2 + 1
47
k = len
48
c
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
83
c
84
c-----------
85
c eliminate double entries
86
c-----------
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
96
c-----------
97
RETURN
98
END
99
100
101
102
103
104
105
106
107
108
109
itrimhpsort
subroutine itrimhpsort(tab, len)
Definition
itrimhpsort.F:29
starter
source
output
cluster
itrimhpsort.F
Generated by
1.15.0