33 integer(i_byte),
dimension(:),
allocatable,
intent(inout) :: arr
34 integer(i_llong),
intent(in) :: addl_num_entries
36 integer(i_byte),
dimension(:),
allocatable :: tmp
37 integer(i_llong) :: new_size
39 integer(i_byte) :: alloc_err
40 character(len=100) :: err_msg
42 new_size =
size(arr) + addl_num_entries
44 allocate(tmp(new_size), stat=alloc_err)
45 if (alloc_err /= 0)
then 46 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
47 call nclayer_error(trim(err_msg))
49 tmp(1:
size(arr)) = arr
51 allocate(arr(new_size))
63 integer(i_short),
dimension(:),
allocatable,
intent(inout) :: arr
64 integer(i_llong),
intent(in) :: addl_num_entries
66 integer(i_short),
dimension(:),
allocatable :: tmp
67 integer(i_llong) :: new_size
69 integer(i_byte) :: alloc_err
70 character(len=100) :: err_msg
72 new_size =
size(arr) + addl_num_entries
74 allocate(tmp(new_size), stat=alloc_err)
75 if (alloc_err /= 0)
then 76 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
77 call nclayer_error(trim(err_msg))
79 tmp(1:
size(arr)) = arr
81 allocate(arr(new_size))
93 integer(i_long),
dimension(:),
allocatable,
intent(inout) :: arr
94 integer(i_llong),
intent(in) :: addl_num_entries
96 integer(i_long),
dimension(:),
allocatable :: tmp
97 integer(i_llong) :: new_size
99 integer(i_byte) :: alloc_err
100 character(len=100) :: err_msg
103 call nclayer_debug(
"Reallocating long array...")
106 new_size =
size(arr) + addl_num_entries
109 print *,
"REALLOCATOR: new_size is ", new_size
112 allocate(tmp(new_size), stat=alloc_err)
113 if (alloc_err /= 0)
then 114 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
115 call nclayer_error(trim(err_msg))
118 tmp(1:
size(arr)) = arr
120 allocate(arr(new_size))
124 print *,
"REALLOCATOR: final actual size is ",
size(arr)
125 call nclayer_debug(
"Realloc finished for long")
137 integer(i_llong),
dimension(:),
allocatable,
intent(inout) :: arr
138 integer(i_llong),
intent(in) :: addl_num_entries
140 integer(i_llong),
dimension(:),
allocatable :: tmp
141 integer(i_llong) :: new_size
143 integer(i_byte) :: alloc_err
144 character(len=100) :: err_msg
147 call nclayer_debug(
"Reallocating long array...")
150 new_size =
size(arr) + addl_num_entries
152 allocate(tmp(new_size), stat=alloc_err)
153 if (alloc_err /= 0)
then 154 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
155 call nclayer_error(trim(err_msg))
158 tmp(1:
size(arr)) = arr
160 allocate(arr(new_size))
164 call nclayer_debug(
"Realloc finished for long")
176 real(r_single),
dimension(:),
allocatable,
intent(inout) :: arr
177 integer(i_llong),
intent(in) :: addl_num_entries
179 real(r_single),
dimension(:),
allocatable :: tmp
180 integer(i_llong) :: new_size
182 integer(i_byte) :: alloc_err
183 character(len=100) :: err_msg
185 new_size =
size(arr) + addl_num_entries
187 allocate(tmp(new_size), stat=alloc_err)
188 if (alloc_err /= 0)
then 189 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
190 call nclayer_error(trim(err_msg))
192 tmp(1:
size(arr)) = arr
194 allocate(arr(new_size))
206 real(r_double),
dimension(:),
allocatable,
intent(inout) :: arr
207 integer(i_llong),
intent(in) :: addl_num_entries
209 real(r_double),
dimension(:),
allocatable :: tmp
210 integer(i_llong) :: new_size
212 integer(i_byte) :: alloc_err
213 character(len=100) :: err_msg
215 new_size =
size(arr) + addl_num_entries
217 allocate(tmp(new_size), stat=alloc_err)
218 if (alloc_err /= 0)
then 219 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
220 call nclayer_error(trim(err_msg))
222 tmp(1:
size(arr)) = arr
224 allocate(arr(new_size))
236 character(len=*),
dimension(:),
allocatable,
intent(inout) :: arr
237 integer(i_llong),
intent(in) :: addl_num_entries
239 character(len=len(arr(1))),
dimension(:),
allocatable :: tmp
240 integer(i_llong) :: new_size
242 integer(i_byte) :: alloc_err
243 character(len=100) :: err_msg
246 integer :: string_len, string_arr_size
248 string_len = len(arr(1))
249 string_arr_size =
size(arr)
251 call nclayer_debug(
"[string] Length of string to allocate to:")
254 call nclayer_debug(
"[string] Allocating from...")
255 print *, string_arr_size
257 call nclayer_debug(
"[string] ...to size...")
258 print *, (string_arr_size + addl_num_entries)
261 new_size =
size(arr) + addl_num_entries
263 allocate(tmp(new_size), stat=alloc_err)
264 if (alloc_err /= 0)
then 265 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
266 call nclayer_error(trim(err_msg))
268 tmp(1:
size(arr)) = arr
270 allocate(arr(new_size))
282 logical,
dimension(:),
allocatable,
intent(inout) :: arr
283 integer(i_llong),
intent(in) :: addl_num_entries
285 logical,
dimension(:),
allocatable :: tmp
286 integer(i_llong) :: new_size
288 integer(i_llong) :: logical_arr_size
289 logical_arr_size =
size(arr)
291 new_size = logical_arr_size + addl_num_entries
294 call nclayer_debug(
"[logical] Allocating from...")
295 print *, logical_arr_size
297 call nclayer_debug(
"[logical] ...to size...")
298 print *, (logical_arr_size + addl_num_entries)
301 allocate(tmp(new_size))
302 tmp(1:logical_arr_size) = arr
304 allocate(arr(new_size))
307 call nclayer_debug(
"[logical] Final size:")
subroutine nc_diag_realloc_short(arr, addl_num_entries)
integer, parameter, public i_byte
subroutine nc_diag_realloc_string(arr, addl_num_entries)
integer, parameter, public i_long
subroutine nc_diag_realloc_llong(arr, addl_num_entries)
subroutine nc_diag_realloc_rdouble(arr, addl_num_entries)
subroutine nc_diag_realloc_logical(arr, addl_num_entries)
subroutine nc_diag_realloc_rsingle(arr, addl_num_entries)
integer, parameter, public i_short
subroutine nc_diag_realloc_byte(arr, addl_num_entries)
subroutine nclayer_error(err)
subroutine nc_diag_realloc_long(arr, addl_num_entries)
integer, parameter, public r_double
integer, parameter, public r_single
integer, parameter, public i_llong