35 character(len=100),
dimension(:),
allocatable :: dim_names
36 integer(i_long),
dimension(:),
allocatable :: output_dim_ids
37 integer(i_long) :: num_names = 0
49 integer(i_byte),
dimension(:),
allocatable,
intent(inout) :: arr
50 integer(i_long),
intent(in) :: addl_num_entries
52 integer(i_byte),
dimension(:),
allocatable :: tmp
53 integer(i_long) :: new_size
55 integer(i_byte) :: alloc_err
56 character(len=100) :: err_msg
58 new_size =
size(arr) + addl_num_entries
60 allocate(tmp(new_size), stat=alloc_err)
61 if (alloc_err /= 0)
then 62 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
65 tmp(1:
size(arr)) = arr
67 allocate(arr(new_size))
79 integer(i_short),
dimension(:),
allocatable,
intent(inout) :: arr
80 integer(i_long),
intent(in) :: addl_num_entries
82 integer(i_short),
dimension(:),
allocatable :: tmp
83 integer(i_long) :: new_size
85 integer(i_byte) :: alloc_err
86 character(len=100) :: err_msg
88 new_size =
size(arr) + addl_num_entries
90 allocate(tmp(new_size), stat=alloc_err)
91 if (alloc_err /= 0)
then 92 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
95 tmp(1:
size(arr)) = arr
97 allocate(arr(new_size))
109 integer(i_long),
dimension(:),
allocatable,
intent(inout) :: arr
110 integer(i_long),
intent(in) :: addl_num_entries
112 integer(i_long),
dimension(:),
allocatable :: tmp
113 integer(i_long) :: new_size
115 integer(i_byte) :: alloc_err
116 character(len=100) :: err_msg
119 call debug(
"Reallocating long array...")
122 new_size =
size(arr) + addl_num_entries
125 print *,
"REALLOCATOR: new_size is ", new_size
128 allocate(tmp(new_size), stat=alloc_err)
129 if (alloc_err /= 0)
then 130 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
134 tmp(1:
size(arr)) = arr
136 allocate(arr(new_size))
140 print *,
"REALLOCATOR: final actual size is ",
size(arr)
141 call debug(
"Realloc finished for long")
153 real(r_single),
dimension(:),
allocatable,
intent(inout) :: arr
154 integer(i_long),
intent(in) :: addl_num_entries
156 real(r_single),
dimension(:),
allocatable :: tmp
157 integer(i_long) :: new_size
159 integer(i_byte) :: alloc_err
160 character(len=100) :: err_msg
162 new_size =
size(arr) + addl_num_entries
164 allocate(tmp(new_size), stat=alloc_err)
165 if (alloc_err /= 0)
then 166 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
169 tmp(1:
size(arr)) = arr
171 allocate(arr(new_size))
183 real(r_double),
dimension(:),
allocatable,
intent(inout) :: arr
184 integer(i_long),
intent(in) :: addl_num_entries
186 real(r_double),
dimension(:),
allocatable :: tmp
187 integer(i_long) :: new_size
189 integer(i_byte) :: alloc_err
190 character(len=100) :: err_msg
192 new_size =
size(arr) + addl_num_entries
194 allocate(tmp(new_size), stat=alloc_err)
195 if (alloc_err /= 0)
then 196 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
199 tmp(1:
size(arr)) = arr
201 allocate(arr(new_size))
213 character(len=*),
dimension(:),
allocatable,
intent(inout) :: arr
214 integer(i_long),
intent(in) :: addl_num_entries
216 character(len=len(arr(1))),
dimension(:),
allocatable :: tmp
217 integer(i_long) :: new_size
219 integer(i_byte) :: alloc_err
220 character(len=100) :: err_msg
223 integer(i_long) :: string_len, string_arr_size
225 string_len = len(arr(1))
226 string_arr_size =
size(arr)
228 call debug(
"[string] Length of string to allocate to:")
231 call debug(
"[string] Allocating from...")
232 print *, string_arr_size
234 call debug(
"[string] ...to size...")
235 print *, (string_arr_size + addl_num_entries)
238 new_size =
size(arr) + addl_num_entries
240 allocate(tmp(new_size), stat=alloc_err)
241 if (alloc_err /= 0)
then 242 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
245 tmp(1:
size(arr)) = arr
247 allocate(arr(new_size))
259 logical,
dimension(:),
allocatable,
intent(inout) :: arr
260 integer(i_long),
intent(in) :: addl_num_entries
262 logical,
dimension(:),
allocatable :: tmp
263 integer(i_long) :: new_size
265 integer(i_long) :: logical_arr_size
266 logical_arr_size =
size(arr)
268 new_size = logical_arr_size + addl_num_entries
271 call debug(
"[logical] Allocating from...")
272 print *, logical_arr_size
274 call debug(
"[logical] ...to size...")
275 print *, (logical_arr_size + addl_num_entries)
278 allocate(tmp(new_size))
279 tmp(1:logical_arr_size) = arr
281 allocate(arr(new_size))
284 call debug(
"[logical] Final size:")
297 type(ncdr_file),
dimension(:),
allocatable,
intent(inout) :: arr
298 integer(i_long),
intent(in) :: addl_num_entries
300 type(ncdr_file),
dimension(:),
allocatable :: tmp
301 integer(i_long) :: new_size
303 integer(i_byte) :: alloc_err
304 character(len=100) :: err_msg
306 new_size =
size(arr) + addl_num_entries
308 allocate(tmp(new_size), stat=alloc_err)
309 if (alloc_err /= 0)
then 310 write(err_msg,
"(A, I0)")
"Reallocator was unable to reallocate memory! Error code: ", alloc_err
313 tmp(1:
size(arr)) = arr
315 allocate(arr(new_size))
320 character(len=*),
intent(in) :: err
321 #ifdef ERROR_TRACEBACK 324 write(*,
"(A)")
" ** ERROR: " // err
325 #ifdef ERROR_TRACEBACK 326 write(*,
"(A)")
" ** Failed to process data/write NetCDF4." 327 write(*,
"(A)")
" (Traceback requested, triggering div0 error...)" 329 write(*,
"(A)")
" Couldn't trigger traceback, ending gracefully." 330 write(*,
"(A)")
" (Ensure floating point exceptions are enabled," 331 write(*,
"(A)")
" and that you have debugging (-g) and tracebacks" 332 write(*,
"(A)")
" compiler flags enabled!)" 335 stop
" ** Failed to read data/write NetCDF4." subroutine ncdr_realloc_rsingle(arr, addl_num_entries)
subroutine ncdr_realloc_long(arr, addl_num_entries)
subroutine ncdr_realloc_byte(arr, addl_num_entries)
integer, parameter, public i_byte
subroutine ncdr_realloc_file_type(arr, addl_num_entries)
integer, parameter, public i_long
subroutine ncdr_realloc_error(err)
subroutine ncdr_realloc_string(arr, addl_num_entries)
integer, parameter, public i_short
subroutine ncdr_realloc_short(arr, addl_num_entries)
integer, parameter, public r_double
integer, parameter, public r_single
subroutine ncdr_realloc_rdouble(arr, addl_num_entries)
subroutine ncdr_realloc_logical(arr, addl_num_entries)