52 integer(I4B),
intent(in) :: nsize
53 integer(I4B),
allocatable,
intent(inout) :: array(:)
54 integer(I4B),
intent(in),
optional :: minvalue
55 logical(LGP),
intent(in),
optional :: loginc
57 logical(LGP) :: log_increment
58 integer(I4B) :: minimum_increment
59 integer(I4B) :: increment
64 if (
present(minvalue))
then
65 minimum_increment = minvalue
67 minimum_increment = 100
69 if (
present(loginc))
then
70 log_increment = loginc
72 log_increment = .false.
79 if (nsize > isize)
then
84 increment = int(log10(real(nsize, dp)), i4b)
85 increment = int(
dten**increment, i4b)
90 increment = int(nsize * 0.2_dp)
91 increment = max(minimum_increment, increment)
98 do n = isize + 1,
size(array)
109 integer(I4B),
allocatable,
intent(inout) :: array(:)
110 integer(I4B),
optional,
intent(in) :: increment
112 integer(I4B) :: inc, lb, n
113 integer(I4B),
allocatable,
dimension(:) :: temp
116 if (
present(increment))
then
119 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
127 if (
allocated(array))
then
128 lb = lbound(array, 1)
130 allocate (temp(lb:(lb + n + inc - 1)))
131 temp(lb:(lb + n - 1)) = array
133 call move_alloc(temp, array)
135 allocate (array(inc))
141 real(DP),
allocatable,
intent(inout) :: array(:)
142 integer(I4B),
optional,
intent(in) :: increment
144 integer(I4B) :: inc, lb, n
145 real(DP),
allocatable,
dimension(:) :: temp
148 if (
present(increment))
then
151 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
159 if (
allocated(array))
then
160 lb = lbound(array, 1)
162 allocate (temp(lb:(lb + n + inc - 1)))
163 temp(lb:(lb + n - 1)) = array
165 call move_alloc(temp, array)
167 allocate (array(inc))
174 logical(LGP),
allocatable,
intent(inout) :: array(:)
175 integer(I4B),
optional,
intent(in) :: increment
177 integer(I4B) :: inc, lb, n
178 logical(LGP),
allocatable,
dimension(:) :: temp
181 if (
present(increment))
then
184 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
192 if (
allocated(array))
then
193 lb = lbound(array, 1)
195 allocate (temp(lb:(lb + n + inc - 1)))
196 temp(lb:(lb + n - 1)) = array
198 call move_alloc(temp, array)
200 allocate (array(inc))
207 character(len=*),
allocatable,
intent(inout) :: array(:)
208 integer(I4B),
optional,
intent(in) :: increment
210 character(len=MAXCHARLEN),
allocatable,
dimension(:) :: temp
211 integer(I4B) :: i, inc, nold, nnew, lenc
216 call pstop(138,
'Error in ArrayHandlersModule: '// &
217 'Need to increase MAXCHARLEN. Stopping...')
220 if (
present(increment))
then
223 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
232 if (
allocated(array))
then
235 allocate (temp(nold))
240 allocate (array(nnew))
244 do i = nold + 1, nnew
249 allocate (array(inc))
258 integer(I4B),
allocatable,
intent(inout) :: array(:, :)
259 integer(I4B),
optional,
intent(in) :: increment1
260 integer(I4B),
optional,
intent(in) :: increment2
262 integer(I4B) :: inc1, inc2, lb1, lb2, n1, n2
263 integer(I4B),
allocatable,
dimension(:, :) :: temp
266 if (
present(increment1))
then
271 if (
present(increment2))
then
276 if (inc1 == 0 .and. inc2 == 0)
return
277 if (inc1 < 0 .or. inc2 < 0) &
278 call pstop(1,
"increments must be nonnegative")
283 if (
allocated(array))
then
284 lb1 = lbound(array, 1)
285 lb2 = lbound(array, 2)
289 lb1:(lb1 + n1 + inc1 - 1), &
290 lb2:(lb2 + n2 + inc2 - 1)))
292 lb1:(lb1 + n1 - 1), &
293 lb2:(lb2 + n2 - 1)) = array
295 call move_alloc(temp, array)
297 allocate (array(inc1, inc2))
304 real(DP),
allocatable,
intent(inout) :: array(:, :)
305 integer(I4B),
optional,
intent(in) :: increment1
306 integer(I4B),
optional,
intent(in) :: increment2
308 integer(I4B) :: inc1, inc2, lb1, lb2, n1, n2
309 real(DP),
allocatable,
dimension(:, :) :: temp
312 if (
present(increment1))
then
317 if (
present(increment2))
then
322 if (inc1 == 0 .and. inc2 == 0)
return
323 if (inc1 < 0 .or. inc2 < 0) &
324 call pstop(1,
"increments must be nonnegative")
329 if (
allocated(array))
then
330 lb1 = lbound(array, 1)
331 lb2 = lbound(array, 2)
335 lb1:(lb1 + n1 + inc1 - 1), &
336 lb2:(lb2 + n2 + inc2 - 1)))
338 lb1:(lb1 + n1 - 1), &
339 lb2:(lb2 + n2 - 1)) = array
341 call move_alloc(temp, array)
343 allocate (array(inc1, inc2))
352 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: array
353 integer(I4B),
optional,
intent(in) :: increment
355 character(len=100) :: ermsg
356 integer(I4B) :: i, inc, lb, n, istat
357 real(DP),
dimension(:),
pointer,
contiguous :: temp => null()
360 if (
present(increment))
then
363 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
371 if (
associated(array))
then
372 lb = lbound(array, 1)
374 allocate (temp(lb:(lb + n + inc - 1)), stat=istat, errmsg=ermsg)
376 call pstop(138,
'Error in ArrayHandlersModule, '// &
377 'could not increase array size:'//ermsg)
378 do i = lb, lb + n - 1
384 allocate (array(inc))
391 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(inout) :: array
392 integer(I4B),
optional,
intent(in) :: increment
394 character(len=100) :: ermsg
395 integer(I4B) :: i, inc, lb, n, istat
396 integer(I4B),
dimension(:),
pointer,
contiguous :: temp => null()
399 if (
present(increment))
then
402 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
410 if (
associated(array))
then
411 lb = lbound(array, 1)
413 allocate (temp(lb:(lb + n + inc - 1)), stat=istat, errmsg=ermsg)
415 call pstop(138,
'Error in ArrayHandlersModule, '// &
416 'could not increase array size:'//ermsg)
417 do i = lb, lb + n - 1
423 allocate (array(inc))
430 character(len=*),
dimension(:),
pointer,
contiguous :: array
431 integer(I4B),
optional :: increment
433 integer(I4B) :: inc, i, n
434 character(len=len(array)),
dimension(:),
pointer,
contiguous :: temp
436 if (
present(increment))
then
439 if (inc < 0)
call pstop(1,
"increment must be nonnegative")
444 if (
associated(array))
then
447 allocate (array(n + inc))
453 allocate (array(inc))
460 integer(I4B),
dimension(:),
pointer,
contiguous :: array
461 integer(I4B),
dimension(:),
pointer,
contiguous :: array_to_add
467 do i = 1,
size(array_to_add)
468 array(n + i) = array_to_add(i)
477 character(len=*),
dimension(:) :: array
478 character(len=*) :: str
483 findloop:
do i = 1,
size(array)
484 if (array(i) == str)
then
504 findloop:
do i = 1,
size(array)
505 if (array(i) == str)
then
517 integer(I4B),
dimension(:) :: iarray
523 findloop:
do i = 1,
size(iarray)
524 if (iarray(i) == ival)
then
534 character(len=*),
allocatable,
intent(inout) :: array(:)
535 integer(I4B),
intent(in) :: ipos
537 character(len=MAXCHARLEN),
allocatable,
dimension(:) :: temp
538 integer(I4B) :: i, inew, n
542 call pstop(138,
'Error in ArrayHandlersModule: '// &
543 'Need to increase MAXCHARLEN. Stopping...')
557 allocate (array(n - 1))
561 array(inew) = temp(i)
subroutine concat_integer(array, array_to_add)
Concatenate integer arrays.
subroutine expand_integer_2d(array, increment1, increment2)
subroutine expand_character(array, increment)
subroutine expand_double(array, increment)
subroutine expand_double_2d(array, increment1, increment2)
subroutine, public remove_character(array, ipos)
Remove the element at ipos from the array.
subroutine extend_integer(array, increment)
subroutine extend_string(array, increment)
integer(i4b) function ifind_integer(iarray, ival)
Find the first element containing ival, or -1 if not found.
subroutine extend_double(array, increment)
subroutine expand_integer_wrapper(nsize, array, minvalue, loginc)
integer(i4b) function ifind_character(array, str)
Find the 1st array element containing str, or -1 if not found.
subroutine expand_integer(array, increment)
subroutine expand_logical(array, increment)
integer(i4b) function ifind_charstring(array, str)
Find the 1st array element containing str, or -1 if not found.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dzero
real constant zero
real(dp), parameter dten
real constant 10
integer(i4b), parameter maxcharlen
maximum length of char string
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
This module defines variable data types.
This class is used to store a single deferred-length character string. It was designed to work in an ...