MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
arrayhandlersmodule::extendptrarray Interface Reference
Collaboration diagram for arrayhandlersmodule::extendptrarray:
Collaboration graph

Private Member Functions

subroutine extend_double (array, increment)
 
subroutine extend_integer (array, increment)
 
subroutine extend_string (array, increment)
 

Detailed Description

Definition at line 34 of file ArrayHandlers.f90.

Member Function/Subroutine Documentation

◆ extend_double()

subroutine arrayhandlersmodule::extendptrarray::extend_double ( real(dp), dimension(:), intent(inout), pointer, contiguous  array,
integer(i4b), intent(in), optional  increment 
)
private

Definition at line 350 of file ArrayHandlers.f90.

351  ! -- dummy
352  real(DP), dimension(:), pointer, contiguous, intent(inout) :: array
353  integer(I4B), optional, intent(in) :: increment
354  ! -- local
355  character(len=100) :: ermsg
356  integer(I4B) :: i, inc, lb, n, istat
357  real(DP), dimension(:), pointer, contiguous :: temp => null()
358 
359  ! -- default to expanding by 1
360  if (present(increment)) then
361  inc = increment
362  if (inc == 0) return
363  if (inc < 0) call pstop(1, "increment must be nonnegative")
364  else
365  inc = 1
366  end if
367 
368  ! -- expand array to the requested size, keeping
369  ! existing items and the existing lower bound,
370  ! or allocate the array if still unallocated
371  if (associated(array)) then
372  lb = lbound(array, 1)
373  n = size(array)
374  allocate (temp(lb:(lb + n + inc - 1)), stat=istat, errmsg=ermsg)
375  if (istat /= 0) &
376  call pstop(138, 'Error in ArrayHandlersModule, '// &
377  'could not increase array size:'//ermsg)
378  do i = lb, lb + n - 1
379  temp(i) = array(i)
380  end do
381  deallocate (array)
382  array => temp
383  else
384  allocate (array(inc))
385  end if
386 
Here is the call graph for this function:

◆ extend_integer()

subroutine arrayhandlersmodule::extendptrarray::extend_integer ( integer(i4b), dimension(:), intent(inout), pointer, contiguous  array,
integer(i4b), intent(in), optional  increment 
)
private

Definition at line 389 of file ArrayHandlers.f90.

390  ! -- dummy
391  integer(I4B), dimension(:), pointer, contiguous, intent(inout) :: array
392  integer(I4B), optional, intent(in) :: increment
393  ! -- local
394  character(len=100) :: ermsg
395  integer(I4B) :: i, inc, lb, n, istat
396  integer(I4B), dimension(:), pointer, contiguous :: temp => null()
397 
398  ! -- default to expanding by 1
399  if (present(increment)) then
400  inc = increment
401  if (inc == 0) return
402  if (inc < 0) call pstop(1, "increment must be nonnegative")
403  else
404  inc = 1
405  end if
406 
407  ! -- expand array to the requested size, keeping
408  ! existing items and the existing lower bound,
409  ! or allocate the array if still unallocated
410  if (associated(array)) then
411  lb = lbound(array, 1)
412  n = size(array)
413  allocate (temp(lb:(lb + n + inc - 1)), stat=istat, errmsg=ermsg)
414  if (istat /= 0) &
415  call pstop(138, 'Error in ArrayHandlersModule, '// &
416  'could not increase array size:'//ermsg)
417  do i = lb, lb + n - 1
418  temp(i) = array(i)
419  end do
420  deallocate (array)
421  array => temp
422  else
423  allocate (array(inc))
424  end if
425 
Here is the call graph for this function:

◆ extend_string()

subroutine arrayhandlersmodule::extendptrarray::extend_string ( character(len=*), dimension(:), pointer, contiguous  array,
integer(i4b), optional  increment 
)
private

Definition at line 428 of file ArrayHandlers.f90.

429  ! -- dummy
430  character(len=*), dimension(:), pointer, contiguous :: array
431  integer(I4B), optional :: increment
432  ! -- local
433  integer(I4B) :: inc, i, n
434  character(len=len(array)), dimension(:), pointer, contiguous :: temp
435 
436  if (present(increment)) then
437  inc = increment
438  if (inc == 0) return
439  if (inc < 0) call pstop(1, "increment must be nonnegative")
440  else
441  inc = 1
442  end if
443 
444  if (associated(array)) then
445  n = size(array)
446  temp => array
447  allocate (array(n + inc))
448  do i = 1, n
449  array(i) = temp(i)
450  end do
451  deallocate (temp)
452  else
453  allocate (array(inc))
454  end if
455 
Here is the call graph for this function:

The documentation for this interface was generated from the following file: