OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
double_linked_list.F
Go to the documentation of this file.
1C
2C This file is part of MUMPS 5.5.1, released
3C on Tue Jul 12 13:17:24 UTC 2022
4C
5C
6C Copyright 1991-2022 CERFACS, CNRS, ENS Lyon, INP Toulouse, Inria,
7C Mumps Technologies, University of Bordeaux.
8C
9C This version of MUMPS is provided to you free of charge. It is
10C released under the CeCILL-C license
11C (see doc/CeCILL-C_V1-en.txt, doc/CeCILL-C_V1-fr.txt, and
12C https://cecill.info/licences/Licence_CeCILL-C_V1-en.html)
13C
15 IMPLICIT NONE
17 TYPE ( idll_node_t ), POINTER :: next, prev
18 INTEGER elmt
19 END TYPE idll_node_t
20 TYPE idll_t
21 TYPE ( idll_node_t ), POINTER :: front, back
22 END TYPE idll_t
23 CONTAINS
24 FUNCTION idll_create(DLL)
25 INTEGER :: idll_create
26#if defined(mumps_f2003)
27 TYPE ( idll_t ), POINTER, INTENT ( OUT ) :: dll
28#else
29 TYPE ( idll_t ), POINTER :: dll
30#endif
31 INTEGER ierr
32 ALLOCATE ( dll, stat=ierr )
33 IF ( ierr .NE. 0 ) THEN
34 idll_create = -2
35 RETURN
36 END IF
37 NULLIFY ( dll%FRONT )
38 NULLIFY ( dll%BACK )
39 idll_create = 0
40 RETURN
41 END FUNCTION idll_create
42 FUNCTION idll_destroy(DLL)
43 INTEGER :: idll_destroy
44#if defined(mumps_f2003)
45 TYPE ( idll_t ), POINTER, INTENT ( OUT ) :: dll
46#else
47 TYPE ( idll_t ), POINTER :: dll
48#endif
49 TYPE ( idll_node_t ), POINTER :: aux
50 IF ( .NOT. associated ( dll ) ) THEN
51 idll_destroy = -1
52 RETURN
53 END IF
54 DO WHILE ( associated ( dll%FRONT ) )
55 aux => dll%FRONT
56 dll%FRONT => dll%FRONT%NEXT
57 DEALLOCATE( aux )
58 END DO
59 DEALLOCATE( dll )
60 idll_destroy = 0
61 END FUNCTION idll_destroy
62 FUNCTION idll_push_front(DLL, ELMT)
63 INTEGER :: idll_push_front
64#if defined(mumps_f2003)
65 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
66#else
67 TYPE ( idll_t ), POINTER :: dll
68#endif
69 INTEGER, INTENT ( IN ) :: elmt
70 TYPE ( idll_node_t ), POINTER :: node
71 INTEGER ierr
72 IF ( .NOT. associated ( dll ) ) THEN
74 RETURN
75 END IF
76 ALLOCATE( node, stat=ierr )
77 IF ( ierr .NE. 0 ) THEN
79 RETURN
80 END IF
81 node%ELMT = elmt
82 node%NEXT => dll%FRONT
83 NULLIFY ( node%PREV )
84 IF ( associated ( dll%FRONT ) ) THEN
85 dll%FRONT%PREV => node
86 END IF
87 dll%FRONT => node
88 IF ( .NOT. associated ( dll%BACK ) ) THEN
89 dll%BACK => node
90 END IF
92 END FUNCTION idll_push_front
93 FUNCTION idll_pop_front(DLL, ELMT)
94 INTEGER :: idll_pop_front
95#if defined(mumps_f2003)
96 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
97#else
98 TYPE ( idll_t ), POINTER :: dll
99#endif
100 INTEGER, INTENT ( OUT ) :: elmt
101 TYPE ( idll_node_t ), POINTER :: AUX
102 IF ( .NOT. associated ( dll ) ) THEN
103 idll_pop_front = -1
104 RETURN
105 END IF
106 IF ( .NOT. associated ( dll%FRONT ) ) THEN
107 idll_pop_front = -3
108 RETURN
109 END IF
110 elmt = dll%FRONT%ELMT
111 aux => dll%FRONT
112 dll%FRONT => dll%FRONT%NEXT
113 IF ( associated ( dll%FRONT ) ) THEN
114 NULLIFY ( dll%FRONT%PREV )
115 END IF
116 IF ( associated ( dll%BACK, aux ) ) THEN
117 NULLIFY ( dll%BACK )
118 END IF
119 DEALLOCATE ( aux )
121 END FUNCTION idll_pop_front
122 FUNCTION idll_push_back(DLL, ELMT)
123 INTEGER :: idll_push_back
124#if defined(mumps_f2003)
125 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
126#else
127 TYPE ( idll_t ), POINTER :: dll
128#endif
129 INTEGER, INTENT ( IN ) :: elmt
130 TYPE ( idll_node_t ), POINTER :: node
131 INTEGER ierr
132 IF ( .NOT. associated ( dll ) ) THEN
133 idll_push_back = -1
134 RETURN
135 END IF
136 ALLOCATE( node, stat=ierr )
137 IF ( ierr .NE. 0 ) THEN
138 idll_push_back = -2
139 RETURN
140 END IF
141 node%ELMT = elmt
142 NULLIFY ( node%NEXT )
143 node%PREV => dll%BACK
144 IF ( associated ( dll%BACK ) ) THEN
145 dll%BACK%NEXT => node
146 END IF
147 dll%BACK => node
148 IF ( .NOT. associated ( dll%FRONT ) ) THEN
149 dll%FRONT => node
150 END IF
152 END FUNCTION idll_push_back
153 FUNCTION idll_pop_back(DLL, ELMT)
154 INTEGER :: idll_pop_back
155#if defined(mumps_f2003)
156 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
157#else
158 TYPE ( idll_t ), POINTER :: dll
159#endif
160 INTEGER, INTENT ( OUT ) :: elmt
161 TYPE ( idll_node_t ), POINTER :: aux
162 IF ( .NOT. associated ( dll ) ) THEN
163 idll_pop_back = -1
164 RETURN
165 END IF
166 IF ( .NOT. associated ( dll%BACK ) ) THEN
167 idll_pop_back = -3
168 RETURN
169 END IF
170 elmt = dll%BACK%ELMT
171 aux => dll%BACK
172 dll%BACK => dll%BACK%PREV
173 IF ( associated ( dll%BACK ) ) THEN
174 NULLIFY ( dll%BACK%NEXT )
175 END IF
176 IF ( associated ( dll%FRONT, aux ) ) THEN
177 NULLIFY ( dll%FRONT )
178 END IF
179 DEALLOCATE ( aux )
180 idll_pop_back = 0
181 END FUNCTION idll_pop_back
182 FUNCTION idll_insert(DLL, POS, ELMT)
183 INTEGER :: idll_insert
184#if defined(mumps_f2003)
185 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
186#else
187 TYPE ( idll_t ), POINTER :: dll
188#endif
189 INTEGER, INTENT ( IN ) :: pos, elmt
190 TYPE ( idll_node_t ), POINTER :: node
191 TYPE ( idll_node_t ), POINTER :: new_ptr, old_ptr
192 INTEGER :: ierr, cpt
193 IF ( .NOT. associated ( dll ) ) THEN
194 idll_insert = -1
195 RETURN
196 END IF
197 IF ( pos .LE. 0 ) THEN
198 idll_insert = -4
199 RETURN
200 END IF
201 cpt = 1
202 new_ptr => dll%FRONT
203 NULLIFY ( old_ptr )
204 DO WHILE ( ( cpt .LT. pos ) .AND.
205 & ( associated ( new_ptr ) ) )
206 old_ptr => new_ptr
207 new_ptr => new_ptr%NEXT
208 cpt = cpt + 1
209 END DO
210 ALLOCATE ( node, stat=ierr )
211 IF ( ierr .NE. 0 ) THEN
212 idll_insert = -2
213 RETURN
214 END IF
215 node%ELMT = elmt
216 IF ( .NOT. associated ( old_ptr ) ) THEN
217 IF ( .NOT. associated ( new_ptr ) ) THEN
218 NULLIFY ( node%PREV )
219 NULLIFY ( node%NEXT )
220 dll%FRONT => node
221 dll%BACK => node
222 ELSE
223 NULLIFY ( node%PREV )
224 node%NEXT => new_ptr
225 new_ptr%PREV => node
226 dll%FRONT => node
227 END IF
228 ELSE
229 IF ( .NOT. associated ( new_ptr ) ) THEN
230 node%PREV => old_ptr
231 NULLIFY ( node%NEXT )
232 old_ptr%NEXT => node
233 dll%BACK => node
234 ELSE
235 node%PREV => old_ptr
236 node%NEXT => new_ptr
237 old_ptr%NEXT => node
238 new_ptr%PREV => node
239 END IF
240 END IF
241 idll_insert = 0
242 END FUNCTION idll_insert
243 FUNCTION idll_insert_before(DLL, NODE_AFTER, ELMT)
244 INTEGER :: idll_insert_before
245#if defined(mumps_f2003)
246 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
247 TYPE ( idll_node_t ), POINTER, INTENT ( IN ) :: node_after
248#else
249 TYPE ( idll_t ), POINTER :: dll
250 TYPE ( idll_node_t ), POINTER :: node_after
251#endif
252 INTEGER, INTENT ( IN ) :: elmt
253 TYPE ( idll_node_t ), POINTER :: node_before
254 INTEGER :: ierr
255 ALLOCATE ( node_before, stat=ierr )
256 IF ( ierr .NE. 0 ) THEN
258 RETURN
259 END IF
260 node_before%ELMT = elmt
261 IF ( .NOT. associated ( node_after%PREV ) ) THEN
262 node_after%PREV => node_before
263 node_before%NEXT => node_after
264 NULLIFY ( node_before%PREV )
265 dll%FRONT => node_before
266 ELSE
267 node_before%NEXT => node_after
268 node_before%PREV => node_after%PREV
269 node_after%PREV => node_before
270 node_before%PREV%NEXT => node_before
271 END IF
273 END FUNCTION idll_insert_before
274 FUNCTION idll_insert_after(DLL, NODE_BEFORE, ELMT)
275 INTEGER :: idll_insert_after
276#if defined(mumps_f2003)
277 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
278 TYPE ( idll_node_t ), POINTER, INTENT ( IN ) :: node_before
279#else
280 TYPE ( idll_t ), POINTER :: dll
281 TYPE ( idll_node_t ), POINTER :: node_before
282#endif
283 INTEGER, INTENT ( IN ) :: elmt
284 TYPE ( idll_node_t ), POINTER :: node_after
285 INTEGER :: ierr
286 ALLOCATE ( node_after, stat=ierr )
287 IF ( ierr .NE. 0 ) THEN
289 RETURN
290 END IF
291 node_after%ELMT = elmt
292 IF ( .NOT. associated ( node_before%NEXT ) ) THEN
293 node_before%NEXT => node_after
294 node_after%PREV => node_before
295 NULLIFY ( node_after%NEXT )
296 dll%BACK => node_after
297 ELSE
298 node_after%PREV => node_before
299 node_after%NEXT => node_before%NEXT
300 node_before%NEXT => node_after
301 node_after%NEXT%PREV => node_after
302 END IF
304 END FUNCTION idll_insert_after
305 FUNCTION idll_lookup (DLL, POS, ELMT)
306 INTEGER :: idll_lookup
307#if defined(mumps_f2003)
308 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
309#else
310 TYPE ( idll_t ), POINTER :: dll
311#endif
312 INTEGER, INTENT ( IN ) :: pos
313 INTEGER, INTENT ( OUT ) :: elmt
314 TYPE ( idll_node_t ), POINTER :: aux
315 INTEGER :: cpt
316 IF ( .NOT. associated ( dll ) ) THEN
317 idll_lookup = -1
318 RETURN
319 END IF
320 IF ( pos .LE. 0 ) THEN
321 idll_lookup = -4
322 RETURN
323 END IF
324 cpt = 1
325 aux => dll%FRONT
326 DO WHILE ( ( cpt .LT. pos ) .AND. ( associated ( aux ) ) )
327 cpt = cpt + 1
328 aux => aux%NEXT
329 END DO
330 IF ( .NOT. associated ( aux ) ) THEN
331 idll_lookup = -3
332 RETURN
333 END IF
334 elmt = aux%ELMT
335 idll_lookup = 0
336 END FUNCTION idll_lookup
337 FUNCTION idll_remove_pos(DLL, POS, ELMT)
338 INTEGER :: idll_remove_pos
339#if defined(mumps_f2003)
340 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
341#else
342 TYPE ( idll_t ), POINTER :: dll
343#endif
344 INTEGER, INTENT ( IN ) :: pos
345 INTEGER, INTENT ( OUT ) :: elmt
346 TYPE ( idll_node_t ), POINTER :: aux
347 INTEGER :: cpt
348 IF ( .NOT. associated ( dll ) ) THEN
349 idll_remove_pos = -1
350 RETURN
351 END IF
352 cpt = 1
353 aux => dll%FRONT
354 DO WHILE ( ( associated ( aux ) ) .AND.
355 & ( cpt .LT. pos ) )
356 cpt = cpt + 1
357 aux => aux%NEXT
358 END DO
359 IF ( associated ( aux ) ) THEN
360 IF ( .NOT. associated ( aux%PREV ) ) THEN
361 IF ( .NOT. associated ( aux%NEXT ) ) THEN
362 NULLIFY ( dll%FRONT )
363 NULLIFY ( dll%BACK )
364 ELSE
365 NULLIFY ( aux%NEXT%PREV )
366 dll%FRONT => aux%NEXT
367 END IF
368 ELSE
369 IF ( .NOT. associated ( aux%NEXT ) ) THEN
370 NULLIFY ( aux%PREV%NEXT )
371 dll%BACK => aux%PREV
372 ELSE
373 aux%PREV%NEXT => aux%NEXT
374 aux%NEXT%PREV => aux%PREV
375 END IF
376 END IF
377 elmt = aux%ELMT
378 DEALLOCATE ( aux )
379 ELSE
380 idll_remove_pos = -3
381 RETURN
382 END IF
384 END FUNCTION idll_remove_pos
385 FUNCTION idll_remove_elmt(DLL, ELMT, POS)
386 INTEGER :: idll_remove_elmt
387#if defined(mumps_f2003)
388 TYPE ( idll_t ), POINTER, INTENT ( INOUT ) :: dll
389#else
390 TYPE ( idll_t ), POINTER :: dll
391#endif
392 INTEGER, INTENT ( IN ) :: elmt
393 INTEGER, INTENT ( OUT ) :: pos
394 TYPE ( idll_node_t ), POINTER :: aux
395 INTEGER :: cpt
396 IF ( .NOT. associated ( dll ) ) THEN
398 RETURN
399 END IF
400 cpt = 1
401 aux => dll%FRONT
402 DO WHILE ( ( associated ( aux ) ) .AND.
403 & ( aux%ELMT .NE. elmt ) )
404 cpt = cpt + 1
405 aux => aux%NEXT
406 END DO
407 IF ( associated ( aux ) ) THEN
408 IF ( .NOT. associated ( aux%PREV ) ) THEN
409 IF ( .NOT. associated ( aux%NEXT ) ) THEN
410 NULLIFY ( dll%FRONT )
411 NULLIFY ( dll%BACK )
412 ELSE
413 NULLIFY ( aux%NEXT%PREV )
414 dll%FRONT => aux%NEXT
415 END IF
416 ELSE
417 IF ( .NOT. associated ( aux%NEXT ) ) THEN
418 NULLIFY ( aux%PREV%NEXT )
419 dll%BACK => aux%PREV
420 ELSE
421 aux%PREV%NEXT => aux%NEXT
422 aux%NEXT%PREV => aux%PREV
423 END IF
424 END IF
425 pos = cpt
426 DEALLOCATE ( aux )
427 ELSE
429 RETURN
430 END IF
432 END FUNCTION idll_remove_elmt
433 FUNCTION idll_length(DLL)
434 INTEGER :: IDLL_LENGTH
435#if defined(mumps_f2003)
436 TYPE ( idll_t ), POINTER, INTENT ( IN ) :: DLL
437#else
438 TYPE ( idll_t ), POINTER :: dll
439#endif
440 INTEGER :: length
441 TYPE ( idll_node_t ), POINTER :: aux
442 length = 0
443 IF ( .NOT. associated ( dll ) ) THEN
444 idll_length = -1
445 RETURN
446 END IF
447 aux => dll%FRONT
448 DO WHILE ( associated ( aux ) )
449 length = length + 1
450 aux => aux%NEXT
451 END DO
452 idll_length = length
453 END FUNCTION idll_length
454 FUNCTION idll_iterator_begin(DLL, PTR)
455 INTEGER :: idll_iterator_begin
456#if defined(mumps_f2003)
457 TYPE ( idll_t ), POINTER, INTENT ( IN ) :: dll
458 TYPE ( idll_node_t ), POINTER, INTENT ( OUT ) :: ptr
459#else
460 TYPE ( idll_t ), POINTER :: dll
461 TYPE ( IDLL_NODE_T ), POINTER :: ptr
462#endif
463 IF ( .NOT. associated ( dll ) ) THEN
465 RETURN
466 END IF
467 ptr => dll%FRONT
469 END FUNCTION idll_iterator_begin
470 FUNCTION idll_iterator_end(DLL, PTR)
471 INTEGER :: idll_iterator_end
472#if defined(mumps_f2003)
473 TYPE ( idll_t ), POINTER, INTENT ( IN ) :: dll
474 TYPE ( idll_node_t ), POINTER, INTENT ( OUT ) :: ptr
475#else
476 TYPE ( idll_t ), POINTER :: dll
477 TYPE ( idll_node_t ), POINTER :: ptr
478#endif
479 IF ( .NOT. associated ( dll ) ) THEN
481 RETURN
482 END IF
483 ptr => dll%BACK
485 END FUNCTION idll_iterator_end
486 FUNCTION idll_is_empty(DLL)
487 LOGICAL :: idll_is_empty
488#if defined(mumps_f2003)
489 TYPE ( idll_t ), POINTER, INTENT ( IN ) :: dll
490#else
491 TYPE ( idll_t ), POINTER :: dll
492#endif
493 idll_is_empty = ( associated ( dll%FRONT ) )
494 END FUNCTION idll_is_empty
495 FUNCTION idll_2_array(DLL, ARRAY, LENGTH)
496 INTEGER :: idll_2_array
497#if defined(mumps_f2003)
498 TYPE ( idll_t ), POINTER, INTENT ( IN ) :: dll
499 INTEGER, POINTER, DIMENSION (:), INTENT ( OUT ) :: array
500#else
501 TYPE ( idll_t ), POINTER :: dll
502 INTEGER, POINTER, DIMENSION (:) :: array
503#endif
504 INTEGER, INTENT ( OUT ) :: length
505 TYPE ( idll_node_t ), POINTER :: AUX
506 INTEGER :: i, ierr
507 IF ( .NOT. associated ( dll ) ) THEN
508 idll_2_array = -1
509 RETURN
510 END IF
511 length = idll_length(dll)
512 ALLOCATE ( array( max(1,length) ), stat=ierr )
513 IF ( ierr .NE. 0 ) THEN
514 idll_2_array = -2
515 RETURN
516 END IF
517 i = 1
518 aux => dll%FRONT
519 DO WHILE ( associated ( aux ) )
520 array( i ) = aux%ELMT
521 i = i + 1
522 aux => aux%NEXT
523 END DO
524 idll_2_array = 0
525 END FUNCTION idll_2_array
526 END MODULE mumps_idll
528 IMPLICIT NONE
530 TYPE ( ddll_node_t ), POINTER :: NEXT, prev
531 DOUBLE PRECISION :: elmt
532 END TYPE ddll_node_t
534 TYPE ( ddll_node_t ), POINTER :: front, back
535 END TYPE ddll_t
536 CONTAINS
537 FUNCTION ddll_create(DLL)
538 INTEGER :: ddll_create
539#if defined(mumps_f2003)
540 TYPE ( ddll_t ), POINTER, INTENT ( OUT ) :: dll
541#else
542 TYPE ( ddll_t ), POINTER :: dll
543#endif
544 INTEGER ierr
545 ALLOCATE ( dll, stat=ierr )
546 IF ( ierr .NE. 0 ) THEN
547 ddll_create = -2
548 RETURN
549 END IF
550 NULLIFY ( dll%FRONT )
551 NULLIFY ( dll%BACK )
552 ddll_create = 0
553 RETURN
554 END FUNCTION ddll_create
555 FUNCTION ddll_destroy(DLL)
556 INTEGER :: DDLL_DESTROY
557#if defined(mumps_f2003)
558 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
559#else
560 TYPE ( ddll_t ), POINTER :: dll
561#endif
562 TYPE ( ddll_node_t ), POINTER :: aux
563 IF ( .NOT. associated ( dll ) ) THEN
564 ddll_destroy = -1
565 RETURN
566 END IF
567 DO WHILE ( associated ( dll%FRONT ) )
568 aux => dll%FRONT
569 dll%FRONT => dll%FRONT%NEXT
570 DEALLOCATE( aux )
571 END DO
572 DEALLOCATE( dll )
573 ddll_destroy = 0
574 END FUNCTION ddll_destroy
575 FUNCTION ddll_push_front(DLL, ELMT)
576 INTEGER :: ddll_push_front
577#if defined(mumps_f2003)
578 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
579#else
580 TYPE ( ddll_t ), POINTER :: dll
581#endif
582 DOUBLE PRECISION, INTENT ( IN ) :: elmt
583 TYPE ( ddll_node_t ), POINTER :: node
584 INTEGER ierr
585 IF ( .NOT. associated ( dll ) ) THEN
586 ddll_push_front = -1
587 RETURN
588 END IF
589 ALLOCATE( node, stat=ierr )
590 IF ( ierr .NE. 0 ) THEN
591 ddll_push_front = -2
592 RETURN
593 END IF
594 node%ELMT = elmt
595 node%NEXT => dll%FRONT
596 NULLIFY ( node%PREV )
597 IF ( associated ( dll%FRONT ) ) THEN
598 dll%FRONT%PREV => node
599 END IF
600 dll%FRONT => node
601 IF ( .NOT. associated ( dll%BACK ) ) THEN
602 dll%BACK => node
603 END IF
605 END FUNCTION ddll_push_front
606 FUNCTION ddll_pop_front(DLL, ELMT)
607 INTEGER :: ddll_pop_front
608#if defined(mumps_f2003)
609 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
610#else
611 TYPE ( ddll_t ), POINTER :: dll
612#endif
613 DOUBLE PRECISION, INTENT ( OUT ) :: elmt
614 TYPE ( ddll_node_t ), POINTER :: aux
615 IF ( .NOT. associated ( dll ) ) THEN
616 ddll_pop_front = -1
617 RETURN
618 END IF
619 IF ( .NOT. associated ( dll%FRONT ) ) THEN
620 ddll_pop_front = -3
621 RETURN
622 END IF
623 elmt = dll%FRONT%ELMT
624 aux => dll%FRONT
625 dll%FRONT => dll%FRONT%NEXT
626 IF ( associated ( dll%FRONT ) ) THEN
627 NULLIFY ( dll%FRONT%PREV )
628 END IF
629 IF ( associated ( dll%BACK, aux ) ) THEN
630 NULLIFY ( dll%BACK )
631 END IF
632 DEALLOCATE ( aux )
634 END FUNCTION ddll_pop_front
635 FUNCTION ddll_push_back(DLL, ELMT)
636 INTEGER :: ddll_push_back
637#if defined(mumps_f2003)
638 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
639#else
640 TYPE ( ddll_t ), POINTER :: DLL
641#endif
642 DOUBLE PRECISION, INTENT ( IN ) :: elmt
643 TYPE ( ddll_node_t ), POINTER :: node
644 INTEGER ierr
645 IF ( .NOT. associated ( dll ) ) THEN
646 ddll_push_back = -1
647 RETURN
648 END IF
649 ALLOCATE( node, stat=ierr )
650 IF ( ierr .NE. 0 ) THEN
651 ddll_push_back = -2
652 RETURN
653 END IF
654 node%ELMT = elmt
655 NULLIFY ( node%NEXT )
656 node%PREV => dll%BACK
657 IF ( associated ( dll%BACK ) ) THEN
658 dll%BACK%NEXT => node
659 END IF
660 dll%BACK => node
661 IF ( .NOT. associated ( dll%FRONT ) ) THEN
662 dll%FRONT => node
663 END IF
665 END FUNCTION ddll_push_back
666 FUNCTION ddll_pop_back(DLL, ELMT)
667 INTEGER :: ddll_pop_back
668#if defined(mumps_f2003)
669 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
670#else
671 TYPE ( ddll_t ), POINTER :: dll
672#endif
673 DOUBLE PRECISION, INTENT ( OUT ) :: elmt
674 TYPE ( ddll_node_t ), POINTER :: aux
675 IF ( .NOT. associated ( dll ) ) THEN
676 ddll_pop_back = -1
677 RETURN
678 END IF
679 IF ( .NOT. associated ( dll%BACK ) ) THEN
680 ddll_pop_back = -3
681 RETURN
682 END IF
683 elmt = dll%BACK%ELMT
684 aux => dll%BACK
685 dll%BACK => dll%BACK%PREV
686 IF ( associated ( dll%BACK ) ) THEN
687 NULLIFY ( dll%BACK%NEXT )
688 END IF
689 IF ( associated ( dll%FRONT, aux ) ) THEN
690 NULLIFY ( dll%FRONT )
691 END IF
692 DEALLOCATE ( aux )
693 ddll_pop_back = 0
694 END FUNCTION ddll_pop_back
695 FUNCTION ddll_insert(DLL, POS, ELMT)
696 INTEGER :: ddll_insert
697#if defined(mumps_f2003)
698 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
699#else
700 TYPE ( ddll_t ), POINTER :: dll
701#endif
702 INTEGER, INTENT ( IN ) :: pos
703 DOUBLE PRECISION , INTENT ( IN ) :: elmt
704 TYPE ( ddll_node_t ), POINTER :: node
705 TYPE ( ddll_node_t ), POINTER :: new_ptr, old_ptr
706 INTEGER :: ierr, cpt
707 IF ( .NOT. associated ( dll ) ) THEN
708 ddll_insert = -1
709 RETURN
710 END IF
711 IF ( pos .LE. 0 ) THEN
712 ddll_insert = -4
713 RETURN
714 END IF
715 cpt = 1
716 new_ptr => dll%FRONT
717 NULLIFY ( old_ptr )
718 DO WHILE ( ( cpt .LT. pos ) .AND.
719 & ( associated ( new_ptr ) ) )
720 old_ptr => new_ptr
721 new_ptr => new_ptr%NEXT
722 cpt = cpt + 1
723 END DO
724 ALLOCATE ( node, stat=ierr )
725 IF ( ierr .NE. 0 ) THEN
726 ddll_insert = -2
727 RETURN
728 END IF
729 node%ELMT = elmt
730 IF ( .NOT. associated ( old_ptr ) ) THEN
731 IF ( .NOT. associated ( new_ptr ) ) THEN
732 NULLIFY ( node%PREV )
733 NULLIFY ( node%NEXT )
734 dll%FRONT => node
735 dll%BACK => node
736 ELSE
737 NULLIFY ( node%PREV )
738 node%NEXT => new_ptr
739 new_ptr%PREV => node
740 dll%FRONT => node
741 END IF
742 ELSE
743 IF ( .NOT. associated ( new_ptr ) ) THEN
744 node%PREV => old_ptr
745 NULLIFY ( node%NEXT )
746 old_ptr%NEXT => node
747 dll%BACK => node
748 ELSE
749 node%PREV => old_ptr
750 node%NEXT => new_ptr
751 old_ptr%NEXT => node
752 new_ptr%PREV => node
753 END IF
754 END IF
755 ddll_insert = 0
756 END FUNCTION ddll_insert
757 FUNCTION ddll_insert_before(DLL, NODE_AFTER, ELMT)
758 INTEGER :: ddll_insert_before
759#if defined(mumps_f2003)
760 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
761 TYPE ( ddll_node_t ), POINTER, INTENT ( IN ) :: node_after
762#else
763 TYPE ( ddll_t ), POINTER :: dll
764 TYPE ( ddll_node_t ), POINTER :: node_after
765#endif
766 DOUBLE PRECISION, INTENT ( IN ) :: elmt
767 TYPE ( ddll_node_t ), POINTER :: node_before
768 INTEGER :: ierr
769 ALLOCATE ( node_before, stat=ierr )
770 IF ( ierr .NE. 0 ) THEN
772 RETURN
773 END IF
774 node_before%ELMT = elmt
775 IF ( .NOT. associated ( node_after%PREV ) ) THEN
776 node_after%PREV => node_before
777 node_before%NEXT => node_after
778 NULLIFY ( node_before%PREV )
779 dll%FRONT => node_before
780 ELSE
781 node_before%NEXT => node_after
782 node_before%PREV => node_after%PREV
783 node_after%PREV => node_before
784 node_before%PREV%NEXT => node_before
785 END IF
787 END FUNCTION ddll_insert_before
788 FUNCTION ddll_insert_after(DLL, NODE_BEFORE, ELMT)
789 INTEGER :: ddll_insert_after
790#if defined(mumps_f2003)
791 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
792 TYPE ( ddll_node_t ), POINTER, INTENT ( IN ) :: node_before
793#else
794 TYPE ( ddll_t ), POINTER :: dll
795 TYPE ( ddll_node_t ), POINTER :: node_before
796#endif
797 DOUBLE PRECISION, INTENT ( IN ) :: elmt
798 TYPE ( ddll_node_t ), POINTER :: node_after
799 INTEGER :: ierr
800 ALLOCATE ( node_after, stat=ierr )
801 IF ( ierr .NE. 0 ) THEN
803 RETURN
804 END IF
805 node_after%ELMT = elmt
806 IF ( .NOT. associated ( node_before%NEXT ) ) THEN
807 node_before%NEXT => node_after
808 node_after%PREV => node_before
809 NULLIFY ( node_after%NEXT )
810 dll%BACK => node_after
811 ELSE
812 node_after%PREV => node_before
813 node_after%NEXT => node_before%NEXT
814 node_before%NEXT => node_after
815 node_after%NEXT%PREV => node_after
816 END IF
818 END FUNCTION ddll_insert_after
819 FUNCTION ddll_lookup (DLL, POS, ELMT)
820 INTEGER :: ddll_lookup
821#if defined(mumps_f2003)
822 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
823#else
824 TYPE ( DDLL_T ), POINTER :: dll
825#endif
826 INTEGER, INTENT ( IN ) :: pos
827 DOUBLE PRECISION, INTENT ( OUT ) :: elmt
828 TYPE ( ddll_node_t ), POINTER :: aux
829 INTEGER :: cpt
830 IF ( .NOT. associated ( dll ) ) THEN
831 ddll_lookup = -1
832 RETURN
833 END IF
834 IF ( pos .LE. 0 ) THEN
835 ddll_lookup = -4
836 RETURN
837 END IF
838 cpt = 1
839 aux => dll%FRONT
840 DO WHILE ( ( cpt .LT. pos ) .AND. ( associated ( aux ) ) )
841 cpt = cpt + 1
842 aux => aux%NEXT
843 END DO
844 IF ( .NOT. associated ( aux ) ) THEN
845 ddll_lookup = -3
846 RETURN
847 END IF
848 elmt = aux%ELMT
849 ddll_lookup = 0
850 END FUNCTION ddll_lookup
851 FUNCTION ddll_remove_pos(DLL, POS, ELMT)
852 INTEGER :: ddll_remove_pos
853#if defined(mumps_f2003)
854 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
855#else
856 TYPE ( DDLL_T ), POINTER :: dll
857#endif
858 INTEGER, INTENT ( IN ) :: pos
859 DOUBLE PRECISION, INTENT ( OUT ) :: elmt
860 TYPE ( ddll_node_t ), POINTER :: aux
861 INTEGER :: cpt
862 IF ( .NOT. associated ( dll ) ) THEN
863 ddll_remove_pos = -1
864 RETURN
865 END IF
866 cpt = 1
867 aux => dll%FRONT
868 DO WHILE ( ( associated ( aux ) ) .AND.
869 & ( cpt .LT. pos ) )
870 cpt = cpt + 1
871 aux => aux%NEXT
872 END DO
873 IF ( associated ( aux ) ) THEN
874 IF ( .NOT. associated ( aux%PREV ) ) THEN
875 IF ( .NOT. associated ( aux%NEXT ) ) THEN
876 NULLIFY ( dll%FRONT )
877 NULLIFY ( dll%BACK )
878 ELSE
879 NULLIFY ( aux%NEXT%PREV )
880 dll%FRONT => aux%NEXT
881 END IF
882 ELSE
883 IF ( .NOT. associated ( aux%NEXT ) ) THEN
884 NULLIFY ( aux%PREV%NEXT )
885 dll%BACK => aux%PREV
886 ELSE
887 aux%PREV%NEXT => aux%NEXT
888 aux%NEXT%PREV => aux%PREV
889 END IF
890 END IF
891 elmt = aux%ELMT
892 DEALLOCATE ( aux )
893 ELSE
894 ddll_remove_pos = -3
895 RETURN
896 END IF
898 END FUNCTION ddll_remove_pos
899 FUNCTION ddll_remove_elmt(DLL, ELMT, POS)
900 INTEGER :: ddll_remove_elmt
901#if defined(mumps_f2003)
902 TYPE ( ddll_t ), POINTER, INTENT ( INOUT ) :: dll
903#else
904 TYPE ( ddll_t ), POINTER :: dll
905#endif
906 DOUBLE PRECISION, INTENT ( IN ) :: elmt
907 INTEGER, INTENT ( OUT ) :: POS
908 TYPE ( ddll_node_t ), POINTER :: aux
909 INTEGER :: cpt
910 IF ( .NOT. associated ( dll ) ) THEN
912 RETURN
913 END IF
914 cpt = 1
915 aux => dll%FRONT
916 DO WHILE ( ( associated ( aux ) ) .AND.
917 & ( aux%ELMT .NE. elmt ) )
918 cpt = cpt + 1
919 aux => aux%NEXT
920 END DO
921 IF ( associated ( aux ) ) THEN
922 IF ( .NOT. associated ( aux%PREV ) ) THEN
923 IF ( .NOT. associated ( aux%NEXT ) ) THEN
924 NULLIFY ( dll%FRONT )
925 NULLIFY ( dll%BACK )
926 ELSE
927 NULLIFY ( aux%NEXT%PREV )
928 dll%FRONT => aux%NEXT
929 END IF
930 ELSE
931 IF ( .NOT. associated ( aux%NEXT ) ) THEN
932 NULLIFY ( aux%PREV%NEXT )
933 dll%BACK => aux%PREV
934 ELSE
935 aux%PREV%NEXT => aux%NEXT
936 aux%NEXT%PREV => aux%PREV
937 END IF
938 END IF
939 pos = cpt
940 DEALLOCATE ( aux )
941 ELSE
943 RETURN
944 END IF
946 END FUNCTION ddll_remove_elmt
947 FUNCTION ddll_length(DLL)
948 INTEGER :: ddll_length
949#if defined(mumps_f2003)
950 TYPE ( ddll_t ), POINTER, INTENT ( IN ) :: dll
951#else
952 TYPE ( ddll_t ), POINTER :: dll
953#endif
954 INTEGER :: length
955 TYPE ( ddll_node_t ), POINTER :: aux
956 IF ( .NOT. associated ( dll ) ) THEN
957 ddll_length = -1
958 RETURN
959 END IF
960 length = 0
961 aux => dll%FRONT
962 DO WHILE ( associated ( aux ) )
963 length = length + 1
964 aux => aux%NEXT
965 END DO
966 ddll_length = length
967 END FUNCTION ddll_length
968 FUNCTION ddll_iterator_begin(DLL, PTR)
969 INTEGER :: ddll_iterator_begin
970#if defined(mumps_f2003)
971 TYPE ( ddll_t ), POINTER, INTENT ( IN ) :: dll
972 TYPE ( ddll_node_t ), POINTER, INTENT ( OUT ) :: ptr
973#else
974 TYPE ( ddll_t ), POINTER :: dll
975 TYPE ( ddll_node_t ), POINTER :: ptr
976#endif
977 IF ( .NOT. associated ( dll ) ) THEN
979 RETURN
980 END IF
981 ptr => dll%FRONT
983 END FUNCTION ddll_iterator_begin
984 FUNCTION ddll_iterator_end(DLL, PTR)
985 INTEGER :: ddll_iterator_end
986#if defined(mumps_f2003)
987 TYPE ( ddll_t ), POINTER, INTENT ( IN ) :: dll
988 TYPE ( ddll_node_t ), POINTER, INTENT ( OUT ) :: ptr
989#else
990 TYPE ( ddll_t ), POINTER :: dll
991 TYPE ( ddll_node_t ), POINTER :: ptr
992#endif
993 IF ( .NOT. associated ( dll ) ) THEN
995 RETURN
996 END IF
997 ptr => dll%BACK
999 END FUNCTION ddll_iterator_end
1000 FUNCTION ddll_is_empty(DLL)
1001 LOGICAL :: ddll_is_empty
1002#if defined(mumps_f2003)
1003 TYPE ( ddll_t ), POINTER, INTENT ( IN ) :: dll
1004#else
1005 TYPE ( ddll_t ), POINTER :: dll
1006#endif
1007 ddll_is_empty = ( associated ( dll%FRONT ) )
1008 END FUNCTION ddll_is_empty
1009 FUNCTION ddll_2_array(DLL, ARRAY, LENGTH)
1010 INTEGER :: ddll_2_array
1011#if defined(mumps_f2003)
1012 TYPE ( ddll_t ), POINTER, INTENT ( IN ) :: dll
1013 DOUBLE PRECISION, POINTER, DIMENSION(:), INTENT(OUT) :: array
1014#else
1015 TYPE ( ddll_t ), POINTER :: dll
1016 DOUBLE PRECISION, POINTER, DIMENSION(:) :: array
1017#endif
1018 INTEGER, INTENT ( OUT ) :: length
1019 TYPE ( ddll_node_t ), POINTER :: aux
1020 INTEGER :: i, ierr
1021 IF ( .NOT. associated ( dll ) ) THEN
1022 ddll_2_array = -1
1023 RETURN
1024 END IF
1025 length = ddll_length(dll)
1026 ALLOCATE ( array( max(1,length) ), stat=ierr )
1027 IF ( ierr .NE. 0 ) THEN
1028 ddll_2_array = -2
1029 RETURN
1030 END IF
1031 i = 1
1032 aux => dll%FRONT
1033 DO WHILE ( associated ( aux ) )
1034 array( i ) = aux%ELMT
1035 i = i + 1
1036 aux => aux%NEXT
1037 END DO
1038 ddll_2_array = 0
1039 END FUNCTION ddll_2_array
1040 END MODULE mumps_ddll
if(complex_arithmetic) id
#define max(a, b)
Definition macros.h:21
integer function ddll_pop_front(dll, elmt)
integer function ddll_length(dll)
integer function ddll_remove_pos(dll, pos, elmt)
integer function ddll_insert_after(dll, node_before, elmt)
integer function ddll_create(dll)
integer function ddll_push_front(dll, elmt)
integer function ddll_iterator_begin(dll, ptr)
integer function ddll_lookup(dll, pos, elmt)
integer function ddll_remove_elmt(dll, elmt, pos)
integer function ddll_pop_back(dll, elmt)
integer function ddll_destroy(dll)
logical function ddll_is_empty(dll)
integer function ddll_2_array(dll, array, length)
integer function ddll_push_back(dll, elmt)
integer function ddll_insert(dll, pos, elmt)
integer function ddll_iterator_end(dll, ptr)
integer function ddll_insert_before(dll, node_after, elmt)
integer function idll_push_back(dll, elmt)
integer function idll_lookup(dll, pos, elmt)
integer function idll_length(dll)
integer function idll_2_array(dll, array, length)
integer function idll_insert_after(dll, node_before, elmt)
integer function idll_iterator_begin(dll, ptr)
integer function idll_insert(dll, pos, elmt)
integer function idll_create(dll)
integer function idll_remove_elmt(dll, elmt, pos)
integer function idll_remove_pos(dll, pos, elmt)
integer function idll_iterator_end(dll, ptr)
integer function idll_destroy(dll)
integer function idll_pop_front(dll, elmt)
integer function idll_insert_before(dll, node_after, elmt)
logical function idll_is_empty(dll)
integer function idll_pop_back(dll, elmt)
integer function idll_push_front(dll, elmt)