4 module procedure realloc_c1
5 module procedure realloc_r
6 module procedure realloc_i
7 !! subroutine realloc_c1
(c
,n
,m
,istat
)
8 !! character(len
=1),pointer
,dimension(:) :: c
12 !! subroutine realloc_r
(c
,n
,m
,istat
)
13 !! real,pointer
,dimension(:) :: c
17 !! subroutine realloc_i
(c
,n
,m
,istat
)
18 !! integer,pointer
,dimension(:) :: c
26 subroutine realloc_c1
(c
,n
,m
,istat
)
27 character(len
=1),pointer
,dimension(:) :: c
28 integer,intent
(in
) :: n
,m
29 integer,intent
(out
) :: istat
31 character(len
=1),pointer
,dimension(:) :: tmp
34 if ( (n
<0) .OR
. (m
<=0) ) then
39 if ( .not
. associated
(c
) ) then
40 allocate
(c
(m
),stat
=istat
) ! allocate new memory
44 tmp
=>c
! save pointer
to original mem
46 allocate
(c
(m
),stat
=istat
) ! allocate new memory
47 if ( istat
/= 0 ) then
53 c
(1:num
)=tmp
(1:num
) ! copy data from orig mem
to new loc
.
55 deallocate
(tmp
) ! deallocate original memory
59 subroutine realloc_r
(c
,n
,m
,istat
)
60 real,pointer
,dimension(:) :: c
61 integer,intent
(in
) :: n
,m
62 integer,intent
(out
) :: istat
64 real,pointer
,dimension(:) :: tmp
67 if ( (n
<0) .OR
. (m
<=0) ) then
72 if ( .not
. associated
(c
) ) then
73 allocate
(c
(m
),stat
=istat
) ! allocate new memory
77 tmp
=>c
! save pointer
to original mem
79 allocate
(c
(m
),stat
=istat
) ! allocate new memory
80 if ( istat
/= 0 ) then
86 c
(1:num
)=tmp
(1:num
) ! copy data from orig mem
to new loc
.
88 deallocate
(tmp
) ! deallocate original memory
92 subroutine realloc_i
(c
,n
,m
,istat
)
93 integer,pointer
,dimension(:) :: c
94 integer,intent
(in
) :: n
,m
95 integer,intent
(out
) :: istat
97 integer,pointer
,dimension(:) :: tmp
100 if ( (n
<0) .OR
. (m
<=0) ) then
105 if ( .not
. associated
(c
) ) then
106 allocate
(c
(m
),stat
=istat
) ! allocate new memory
110 tmp
=>c
! save pointer
to original mem
112 allocate
(c
(m
),stat
=istat
) ! allocate new memory
113 if ( istat
/= 0 ) then
119 c
(1:num
)=tmp
(1:num
) ! copy data from orig mem
to new loc
.
121 deallocate
(tmp
) ! deallocate original memory