42 integer(i_byte),
dimension(:),
allocatable,
intent(inout) :: arr
43 integer(i_long),
intent(in) :: addl_num_entries
45 integer(i_byte),
dimension(:),
allocatable :: tmp
46 integer(i_long) :: new_size
48 integer(i_byte) :: alloc_err
49 character(len=100) :: err_msg
51 new_size =
size(arr) + addl_num_entries
53 allocate(tmp(new_size), stat=alloc_err)
54 if (alloc_err /= 0)
then 55 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
58 tmp(1:
size(arr)) = arr
60 allocate(arr(new_size))
72 integer(i_short),
dimension(:),
allocatable,
intent(inout) :: arr
73 integer(i_long),
intent(in) :: addl_num_entries
75 integer(i_short),
dimension(:),
allocatable :: tmp
76 integer(i_long) :: new_size
78 integer(i_byte) :: alloc_err
79 character(len=100) :: err_msg
81 new_size =
size(arr) + addl_num_entries
83 allocate(tmp(new_size), stat=alloc_err)
84 if (alloc_err /= 0)
then 85 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
88 tmp(1:
size(arr)) = arr
90 allocate(arr(new_size))
102 integer(i_long),
dimension(:),
allocatable,
intent(inout) :: arr
103 integer(i_long),
intent(in) :: addl_num_entries
105 integer(i_long),
dimension(:),
allocatable :: tmp
106 integer(i_long) :: new_size
108 integer(i_byte) :: alloc_err
109 character(len=100) :: err_msg
112 call debug(
"Reallocating long array...")
115 new_size =
size(arr) + addl_num_entries
118 print *,
"REALLOCATOR: new_size is ", new_size
121 allocate(tmp(new_size), stat=alloc_err)
122 if (alloc_err /= 0)
then 123 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
127 tmp(1:
size(arr)) = arr
129 allocate(arr(new_size))
133 print *,
"REALLOCATOR: final actual size is ",
size(arr)
134 call debug(
"Realloc finished for long")
146 real(r_single),
dimension(:),
allocatable,
intent(inout) :: arr
147 integer(i_long),
intent(in) :: addl_num_entries
149 real(r_single),
dimension(:),
allocatable :: tmp
150 integer(i_long) :: new_size
152 integer(i_byte) :: alloc_err
153 character(len=100) :: err_msg
155 new_size =
size(arr) + addl_num_entries
157 allocate(tmp(new_size), stat=alloc_err)
158 if (alloc_err /= 0)
then 159 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
162 tmp(1:
size(arr)) = arr
164 allocate(arr(new_size))
176 real(r_double),
dimension(:),
allocatable,
intent(inout) :: arr
177 integer(i_long),
intent(in) :: addl_num_entries
179 real(r_double),
dimension(:),
allocatable :: tmp
180 integer(i_long) :: 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
192 tmp(1:
size(arr)) = arr
194 allocate(arr(new_size))
206 character(len=*),
dimension(:),
allocatable,
intent(inout) :: arr
207 integer(i_long),
intent(in) :: addl_num_entries
209 character(len=len(arr(1))),
dimension(:),
allocatable :: tmp
210 integer(i_long) :: new_size
212 integer(i_byte) :: alloc_err
213 character(len=100) :: err_msg
216 integer(i_long) :: string_len, string_arr_size
218 string_len = len(arr(1))
219 string_arr_size =
size(arr)
221 call debug(
"[string] Length of string to allocate to:")
224 call debug(
"[string] Allocating from...")
225 print *, string_arr_size
227 call debug(
"[string] ...to size...")
228 print *, (string_arr_size + addl_num_entries)
231 new_size =
size(arr) + addl_num_entries
233 allocate(tmp(new_size), stat=alloc_err)
234 if (alloc_err /= 0)
then 235 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
238 tmp(1:
size(arr)) = arr
240 allocate(arr(new_size))
252 logical,
dimension(:),
allocatable,
intent(inout) :: arr
253 integer(i_long),
intent(in) :: addl_num_entries
255 logical,
dimension(:),
allocatable :: tmp
256 integer(i_long) :: new_size
258 integer(i_long) :: logical_arr_size
259 logical_arr_size =
size(arr)
261 new_size = logical_arr_size + addl_num_entries
264 call debug(
"[logical] Allocating from...")
265 print *, logical_arr_size
267 call debug(
"[logical] ...to size...")
268 print *, (logical_arr_size + addl_num_entries)
271 allocate(tmp(new_size))
272 tmp(1:logical_arr_size) = arr
274 allocate(arr(new_size))
277 call debug(
"[logical] Final size:")
290 type(nc_diag_cat_dim_names),
dimension(:),
allocatable,
intent(inout) :: arr
291 integer(i_long),
intent(in) :: addl_num_entries
293 type(nc_diag_cat_dim_names),
dimension(:),
allocatable :: tmp
294 integer(i_long) :: new_size
296 integer(i_byte) :: alloc_err
297 character(len=100) :: err_msg
299 new_size =
size(arr) + addl_num_entries
301 allocate(tmp(new_size), stat=alloc_err)
302 if (alloc_err /= 0)
then 303 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
306 tmp(1:
size(arr)) = arr
308 allocate(arr(new_size))
313 character(len=*),
intent(in) :: err
314 #ifdef ERROR_TRACEBACK 315 integer(i_long) :: div0
317 write(*,
"(A)")
" ** ERROR: " // err
318 #ifdef ERROR_TRACEBACK 319 write(*,
"(A)")
" ** Failed to concatenate NetCDF4." 320 write(*,
"(A)")
" (Traceback requested, triggering div0 error...)" 322 write(*,
"(A)")
" Couldn't trigger traceback, ending gracefully." 323 write(*,
"(A)")
" (Ensure floating point exceptions are enabled," 324 write(*,
"(A)")
" and that you have debugging (-g) and tracebacks" 325 write(*,
"(A)")
" compiler flags enabled!)" 328 stop
" ** Failed to concatenate NetCDF4."
integer, parameter, public i_byte
subroutine nc_diag_realloc_logical(arr, addl_num_entries)
integer, parameter, public i_long
subroutine nc_diag_realloc_short(arr, addl_num_entries)
subroutine nc_diag_realloc_rdouble(arr, addl_num_entries)
subroutine nc_diag_realloc_long(arr, addl_num_entries)
subroutine nc_diag_realloc_string(arr, addl_num_entries)
integer, parameter, public i_short
subroutine nc_diag_realloc_error(err)
subroutine nc_diag_realloc_rsingle(arr, addl_num_entries)
subroutine nc_diag_realloc_byte(arr, addl_num_entries)
subroutine nc_diag_realloc_ncdcdn(arr, addl_num_entries)
integer, parameter, public r_double
integer, parameter, public r_single