OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
sort_sets.F File Reference
#include "implicit_f.inc"

Go to the source code of this file.

Functions/Subroutines

subroutine sort_set (lsubmodel, map_tables, set_list, set, clause)

Function/Subroutine Documentation

◆ sort_set()

subroutine sort_set ( type(submodel_data), dimension(*), intent(in) lsubmodel,
type(mapping_struct_) map_tables,
integer, dimension(nsets) set_list,
type (set_), dimension(nsets), intent(inout) set,
type (set_) clause )

Definition at line 44 of file sort_sets.F.

45C-----------------------------------------------
46C ROUTINE DESCRIPTION :
47C ===================
48C Main Routine to Sort SETs according to their dependencies (/SET of /SET)
49C If a SET has SET clause (child SETs), ensure that those are treated before.
50C
51C All Sets are parsed to find Child Sets, fill a Graph with SET & Childs
52C Go through the Graph to generate the list
53C-----------------------------------------------
54C DUMMY ARGUMENTS DESCRIPTION:
55C ===================
56C
57C NAME DESCRIPTION
58C LSUBMODEL SUBMODEL Structure
59C MAP_TABLES Mapping table structure
60C SET_LIST List of sorted SETs
61C SET SET Structure / ACTIV Flag will be defined for /SET/COLLECT
62C===========================================================================================
63C-----------------------------------------------
64C D e f i n i t i o n s
65C-----------------------------------------------
66C-----------------------------------------------
67C M o d u l e s
68C-----------------------------------------------
69 USE submodel_mod
71 USE setdef_mod
74 USE set_mod , ONLY : set_add
75C-----------------------------------------------
76C I m p l i c i t T y p e s
77C-----------------------------------------------
78#include "implicit_f.inc"
79C-----------------------------------------------
80C D u m m y A r g u m e n t s
81C-----------------------------------------------
82 TYPE(SUBMODEL_DATA),INTENT(IN)::LSUBMODEL(*)
83 TYPE(MAPPING_STRUCT_) :: MAP_TABLES
84 TYPE (SET_), DIMENSION(NSETS),INTENT(INOUT) :: SET
85 INTEGER SET_LIST(NSETS)
86 TYPE (SET_) :: CLAUSE
87C-----------------------------------------------
88C L o c a l V a r i a b l e s
89C-----------------------------------------------
90 INTEGER IGS, IGS2, ID1, ID2, IG, I, J, SET_CLAUSE_SIZE, SET_ARRAY_SIZE, NEW_SIZE, IERROR, T, ID
91 INTEGER SET_ID, ISET_TYPE, CLAUSES_MAX, SETCOL_ARRAY_SIZE
92 INTEGER OPT_D,OPT_O,OPT_G,OPT_B,OPT_A,OPT_E,OPT_I,OPT_C
93 INTEGER IDEBUG
94 LOGICAL IS_AVAILABLE
95 INTEGER, DIMENSION(:),ALLOCATABLE :: SET_ARRAY,SET_CLAUSE_ARRAY,RESULT,SETCOL_ARRAY
96 INTEGER, DIMENSION(:),ALLOCATABLE :: COLLECT_LIST,IS_COLLECT
97
98C-----------------------------------------------
99C Characters
100 CHARACTER MESS*40
101 CHARACTER(LEN=NCHARFIELD) :: KEYSET,SET_TYPE,KEY_TYPE
102 CHARACTER(LEN=NCHARTITLE) :: TITLE,TITLE2,SET_TITLE
103 CHARACTER(LEN=NCHARKEY) :: KEYPART,KEY
104C-----------------------------------------------
105 idebug=0
106
107 IF (idebug == 1)THEN
108 print*,' '
109 print*,' '
110 print*,' -----------------------------------------------'
111 print*,' SORTING SETS'
112 print*,' -----------------------------------------------'
113 print*,' '
114 ENDIF
115
116 ALLOCATE(set_array(nsets))
117 ALLOCATE(setcol_array(nsets))
118 ALLOCATE(set_clause_array(nsets))
119 ALLOCATE(is_collect(nsets))
120 ALLOCATE(result(nsets))
121 ALLOCATE(collect_list(map_tables%NSET_COLLECT))
122
123
124 !-------------------------------------------------
125 ! SET%IS_ACTIVE & /SET/COLLECT
126 ! ----------------------------
127 ! Loops to define which set is active
128 ! In /SET/COLLECT only one SET of the SERIES is active
129 ! And assembled by the others.
130 ! All secondary SETs needs to be treated before the
131 ! the active SET.
132 ! /SET/GENERAL : all SETs are active
133 !-------------------------------------------------
134
135 DO igs=1,nsets
136 set(igs)%SET_ACTIV=-1
137 is_collect(igs)=0
138 ENDDO
139
140 IF (map_tables%NSET_COLLECT > 0)THEN
141
142 igs = map_tables%ISETCOLM(1,2)
143 is_collect(igs)=1
144 set(igs)%SET_ACTIV=1
145
146 DO i=2,map_tables%NSET_COLLECT
147 igs = map_tables%ISETCOLM(i,2)
148 igs2 = map_tables%ISETCOLM(i-1,2)
149
150 id1 = map_tables%ISETCOLM(i,1)
151 id2 = map_tables%ISETCOLM(i-1,1)
152
153 is_collect(igs)=1
154 IF(id1 /= id2) THEN
155 set(igs)%SET_ACTIV=1
156 ELSE
157 set(igs)%SET_ACTIV=0
158 ENDIF
159 ENDDO
160 ENDIF
161 DO igs=1,nsets
162 IF(is_collect(igs) == 0) set(igs)%SET_ACTIV=1
163 ENDDO
164 !-------------------------------------------------
165
166 CALL hm_option_start('/SET')
167
168 DO igs=1,nsets
169
170 set_array_size=0
171
172 CALL hm_option_read_key (lsubmodel,
173 . option_id = set_id,
174 . option_titr = set_title,
175 . keyword2 = key)
176
177
178 CALL hm_get_string('set_Type' , set_type ,ncharfield, is_available)
179 CALL hm_get_intv ('iset_Type', iset_type,is_available,lsubmodel)
180
181 CALL hm_get_intv('clausesmax',clauses_max,is_available,lsubmodel)
182
183
184
185
186 ! Parse all clauses find SET clauses
187 ! -------------------------
188 DO j=1,clauses_max ! max KEY's of the current /SET
189 CALL hm_get_string_index('KEY_type', keyset, j, ncharline, is_available)
190
191 CALL hm_get_int_array_index('opt_D',opt_d,j,is_available,lsubmodel)
192 CALL hm_get_int_array_index('opt_O',opt_o,j,is_available,lsubmodel)
193 CALL hm_get_int_array_index('opt_G',opt_g,j,is_available,lsubmodel)
194 CALL hm_get_int_array_index('opt_B',opt_b,j,is_available,lsubmodel)
195 CALL hm_get_int_array_index('opt_A',opt_a,j,is_available,lsubmodel)
196 CALL hm_get_int_array_index('opt_E',opt_e,j,is_available,lsubmodel)
197 CALL hm_get_int_array_index('opt_i',OPT_I,J,IS_AVAILABLE,LSUBMODEL)
198 CALL HM_GET_INT_ARRAY_INDEX('opt_c',OPT_C,J,IS_AVAILABLE,LSUBMODEL)
199
200
201 IF(TRIM(KEYSET) == 'set' )THEN
202
203 ! get the list of SETs for the current clause
204 ! ---------------------------------------------
205 SET_CLAUSE_SIZE = 0
206 CALL CREATE_SET_ARRAY(SET_CLAUSE_ARRAY , SET_CLAUSE_SIZE,
207 . MAP_TABLES%ISETM , MAP_TABLES%NSET_GENERAL,
208 . J ,OPT_G ,IS_AVAILABLE ,
209 . LSUBMODEL,CLAUSE,0)
210
211 IF( SET_CLAUSE_SIZE > 0 ) THEN
212
213 NEW_SIZE = 0
214 CALL SET_MERGE_SIMPLE( SET_ARRAY , SET_ARRAY_SIZE ,
215 * SET_CLAUSE_ARRAY, SET_CLAUSE_SIZE ,
216 * RESULT , NEW_SIZE ,
217 * SET_ADD )
218
219 SET_ARRAY(1:NEW_SIZE) = RESULT(1:NEW_SIZE)
220 SET_ARRAY_SIZE = NEW_SIZE
221 ENDIF
222
223 ELSEIF (TRIM(KEYSET) == 'setcol' )THEN
224 CALL CREATE_SETCOL_ARRAY(SET,SETCOL_ARRAY,SETCOL_ARRAY_SIZE ,
225 * MAP_TABLES%ISETCOLM,MAP_TABLES%NSET_COLLECT,
226 * J,OPT_G ,IS_AVAILABLE ,
227 * LSUBMODEL)
228
229 IF(SETCOL_ARRAY_SIZE > 0 ) THEN
230
231 NEW_SIZE = 0
232 CALL SET_MERGE_SIMPLE( SET_ARRAY , SET_ARRAY_SIZE ,
233 * SETCOL_ARRAY , SETCOL_ARRAY_SIZE ,
234 * RESULT , NEW_SIZE ,
235 * SET_ADD )
236
237 SET_ARRAY(1:NEW_SIZE) = RESULT(1:NEW_SIZE)
238 SET_ARRAY_SIZE = NEW_SIZE
239 ENDIF
240
241
242 ENDIF
243
244
245 ENDDO ! DO J=1,CLAUSES_MAX
246
247
248 IF(TRIM(KEY) == 'collect')THEN ! SET COLLECT - find all other SETs with Same ID.
249
250 IF (SET(IGS)%SET_ACTIV==1 ) THEN
251
252 DO J=1,MAP_TABLES%NSET_COLLECT ! Find all SET with same ID but "inactive" / set them as dependent from this SET.
253
254 ID = MAP_TABLES%ISETCOLM(J,1)
255 IG = MAP_TABLES%ISETCOLM(J,2)
256
257 IF (ID > SET_ID) EXIT ! ISETCOLM is sorted by UID, when ID is greater we have finished.
258
259
260.AND. IF( ID == SET_ID SET(IG)%SET_ACTIV==0)THEN
261 SET_ARRAY_SIZE = SET_ARRAY_SIZE + 1
262 SET_ARRAY(SET_ARRAY_SIZE)=IG
263 ENDIF
264
265 ENDDO
266 ENDIF
267
268 ENDIF
269
270 IF (IDEBUG == 1)THEN
271 WRITE(6,'(a,i8,a,i8,a,i8)') 'set ',SET_ID,'-> ',IGS,' number of child list : ',SET_ARRAY_SIZE
272 WRITE(6,'(a, 100i8)') 'child list ',( SET_ARRAY(T), T=1,SET_ARRAY_SIZE)
273 WRITE(6,'(a)') ' '
274 ENDIF
275
276 ! Create an Edge in the Dependency Graph
277 CALL SET_GRAPH_ADD_SET ( IGS, SET_ARRAY, SET_ARRAY_SIZE)
278
279
280 ENDDO
281
282 ! ALL Edges are done
283 ! --------------------
284 CALL SET_GRAPH_SORT ( SET_LIST , IERROR)
285
286 IF (IERROR < 0) THEN
287 print*,'error circular dependency on set ',-IERROR
288 CALL ARRET(2)
289 ENDIF
290
291 IF (IDEBUG == 1)THEN
292 print*,' '
293 print*,' -----------------------------------------------'
294 WRITE(6,'(a)') 'sorted sets'
295 print*,SET_LIST(1:NSETS)
296 print*,' '
297 print*,' -----------------------------------------------'
298 print*,' '
299 ENDIF
300
301 CALL SET_GRAPH_CLEAN()
302
subroutine collect(a, itab, weight, nodglob)
Definition collect.F:31
subroutine hm_get_int_array_index(name, ival, index, is_available, lsubmodel)
subroutine hm_get_intv(name, ival, is_available, lsubmodel)
subroutine hm_get_string(name, sval, size, is_available)
subroutine hm_get_string_index(name, sval, index, size, is_available)
subroutine hm_option_start(entity_type)
integer, parameter nchartitle
integer, parameter ncharkey
integer, parameter ncharfield
integer, parameter ncharline
integer, parameter set_add
add operator
Definition set_mod.F:47
type(set_), dimension(:), allocatable, target set
Definition set_mod.F:54
integer nsets
Definition setdef_mod.F:120