OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
realloc_mod Module Reference

Functions/Subroutines

integer function, dimension(:), pointer ireallocate (ptr, new_size)
pointer jreallocate (ptr, new_size)

Function/Subroutine Documentation

◆ ireallocate()

integer function, dimension(:), pointer realloc_mod::ireallocate ( integer, dimension(:), pointer ptr,
integer, intent(in) new_size )

Definition at line 38 of file realloc_mod.F.

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
#define min(a, b)
Definition macros.h:20

◆ jreallocate()

pointer realloc_mod::jreallocate ( pointer ptr,
integer, intent(in) new_size )

Definition at line 68 of file realloc_mod.F.

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
#define my_real
Definition cppsort.cpp:32