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 ../starter/share/modules1/realloc_mod.F
25!||--- called by ------------------------------------------------------
26!|| i11trivox1 ../starter/source/interfaces/inter3d1/i11trivox1.F
27!|| i25trivox_edg ../starter/source/interfaces/inter3d1/i25trivox_edg.F
28!||====================================================================
30 CONTAINS
31
32!||====================================================================
33!|| ireallocate ../starter/share/modules1/realloc_mod.F
34!||--- called by ------------------------------------------------------
35!|| i11trivox1 ../starter/source/interfaces/inter3d1/i11trivox1.F
36!|| i25trivox_edg ../starter/source/interfaces/inter3d1/i25trivox_edg.F
37!||====================================================================
38 FUNCTION ireallocate(ptr, new_size)
39!reallocate INTEGER ARRAY
40C-----------------------------------------------
41C I n c l u d e s
42C-----------------------------------------------
43#include "implicit_f.inc"
44C-----------------------------------------------
45C D u m m y a r g u m e n t s
46C-----------------------------------------------
47 INTEGER, DIMENSION(:),POINTER :: ptr,ireallocate
48 INTEGER, intent(in) :: new_size
49C-----------------------------------------------
50C L o c a l V a r i a b l e s
51C-----------------------------------------------
52 INTEGER :: old_size, ierr
53C-----------------------------------------------
54 IF(.NOT. ASSOCIATED(ptr)) RETURN
55 ALLOCATE(ireallocate(1:new_size), stat=ierr)
56 IF(ierr /= 0) stop "memory allocation error"
57C-----------------------------------------------
58 old_size = min(SIZE(ptr), new_size)
59 ireallocate(1:old_size) = ptr(1:old_size)
60 DEALLOCATE(ptr)
61
62 END FUNCTION ireallocate
63C-----------------------------------------------
64
65!||====================================================================
66!|| jreallocate ../starter/share/modules1/realloc_mod.F
67!||====================================================================
68 FUNCTION jreallocate(ptr, new_size)
69!reallocate MY_REAL ARRAY
70C-----------------------------------------------
71C I n c l u d e s
72C-----------------------------------------------
73#include "implicit_f.inc"
74C-----------------------------------------------
75C D u m m y a r g u m e n t s
76C-----------------------------------------------
78 . ,DIMENSION(:),POINTER :: ptr,jreallocate
79 INTEGER, intent(in) :: new_size
80C-----------------------------------------------
81C L o c a l V a r i a b l e s
82C-----------------------------------------------
83 INTEGER :: old_size, ierr
84C-----------------------------------------------
85 IF(.NOT. ASSOCIATED(ptr)) RETURN
86
87 ALLOCATE(jreallocate(1:new_size), stat=ierr)
88 IF(ierr /= 0) stop "memory allocation error"
89C-----------------------------------------------
90 old_size = min(SIZE(ptr), new_size)
91 jreallocate(1:old_size) = ptr(1:new_size)
92 DEALLOCATE(ptr)
93
94 END FUNCTION jreallocate
95C-----------------------------------------------
96 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