OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
realloc_mod.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!|| realloc_mod ../engine/share/modules/realloc_mod.F
25!||--- called by ------------------------------------------------------
26!|| i11trivox ../engine/source/interfaces/intsort/i11trivox.F
27!|| i22get_prev_data ../engine/source/interfaces/int22/i22get_prev_data.F
28!|| i22intersect ../engine/source/interfaces/int22/i22intersect.F
29!|| i22trivox ../engine/source/interfaces/intsort/i22trivox.F
30!|| i25trivox_edg ../engine/source/interfaces/intsort/i25trivox_edg.F
31!||====================================================================
32 MODULE realloc_mod
33 CONTAINS
34
35!||====================================================================
36!|| ireallocate ../engine/share/modules/realloc_mod.F
37!||--- called by ------------------------------------------------------
38!|| i11trivox ../engine/source/interfaces/intsort/i11trivox.F
39!|| i22trivox ../engine/source/interfaces/intsort/i22trivox.F
40!|| i25trivox_edg ../engine/source/interfaces/intsort/i25trivox_edg.F
41!||====================================================================
42 FUNCTION ireallocate(ptr, new_size)
43!reallocate INTEGER ARRAY
44C-----------------------------------------------
45C I n c l u d e s
46C-----------------------------------------------
47#include "implicit_f.inc"
48C-----------------------------------------------
49C D u m m y a r g u m e n t s
50C-----------------------------------------------
51 INTEGER, DIMENSION(:),POINTER :: ptr,IREALLOCATE
52 INTEGER, intent(in) :: new_size
53C-----------------------------------------------
54C L o c a l V a r i a b l e s
55C-----------------------------------------------
56 INTEGER :: old_size, ierr
57C-----------------------------------------------
58C P r e c o n d i t i o n s
59C-----------------------------------------------
60 !Precondition : le pointeur doit etre affecte
61 IF(.NOT. ASSOCIATED(ptr)) RETURN
62
63 !il reste suffisamment de memoire
64 ALLOCATE(ireallocate(1:new_size), stat=ierr)
65 IF(ierr /= 0) stop "memory allocation error"
66C-----------------------------------------------
67 old_size = min(SIZE(ptr), new_size)
68 ireallocate(1:old_size) = ptr(1:old_size)
69 DEALLOCATE(ptr) ! a ne surtout pas oublier
70
71 END FUNCTION ireallocate
72C-----------------------------------------------
73
74
75
76
77!||====================================================================
78!|| jreallocate ../engine/share/modules/realloc_mod.F
79!||====================================================================
80 FUNCTION jreallocate(ptr, new_size)
81!reallocate MY_REAL ARRAY
82C-----------------------------------------------
83C I n c l u d e s
84C-----------------------------------------------
85#include "implicit_f.inc"
86C-----------------------------------------------
87C D u m m y a r g u m e n t s
88C-----------------------------------------------
90 .,DIMENSION(:),POINTER :: ptr,jreallocate
91 INTEGER, intent(in) :: new_size
92C-----------------------------------------------
93C L o c a l V a r i a b l e s
94C-----------------------------------------------
95 INTEGER :: old_size, ierr
96C-----------------------------------------------
97C P r e c o n d i t i o n s
98C-----------------------------------------------
99 !Precondition : le pointeur doit etre affecte
100 IF(.NOT. ASSOCIATED(ptr)) RETURN
101
102 !il reste suffisamment de memoire
103 ALLOCATE(jreallocate(1:new_size), stat=ierr)
104 IF(ierr /= 0) stop "memory allocation error"
105C-----------------------------------------------
106 old_size = min(SIZE(ptr), new_size)
107 jreallocate(1:old_size) = ptr(1:old_size)
108 DEALLOCATE(ptr) ! a ne surtout pas oublier
109
110 END FUNCTION jreallocate
111C-----------------------------------------------
112
113
114
115 END MODULE realloc_mod
#define my_real
Definition cppsort.cpp:32
#define min(a, b)
Definition macros.h:20
pointer jreallocate(ptr, new_size)
Definition realloc_mod.F:69
integer function, dimension(:), pointer ireallocate(ptr, new_size)
Definition realloc_mod.F:39