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

Private Member Functions

subroutine expand_integer (array, increment)
 
subroutine expand_double (array, increment)
 
subroutine expand_logical (array, increment)
 
subroutine expand_character (array, increment)
 

Detailed Description

Definition at line 17 of file ArrayHandlers.f90.

Member Function/Subroutine Documentation

◆ expand_character()

subroutine arrayhandlersmodule::expandarray::expand_character ( character(len=*), dimension(:), intent(inout), allocatable  array,
integer(i4b), intent(in), optional  increment 
)
private

Definition at line 205 of file ArrayHandlers.f90.

206  ! -- dummy
207  character(len=*), allocatable, intent(inout) :: array(:)
208  integer(I4B), optional, intent(in) :: increment
209  ! -- local
210  character(len=MAXCHARLEN), allocatable, dimension(:) :: temp
211  integer(I4B) :: i, inc, nold, nnew, lenc
212 
213  ! -- check character length
214  lenc = len(array)
215  if (lenc > maxcharlen) &
216  call pstop(138, 'Error in ArrayHandlersModule: '// &
217  'Need to increase MAXCHARLEN. Stopping...')
218 
219  ! -- default to expanding by 1
220  if (present(increment)) then
221  inc = increment
222  if (inc == 0) return
223  if (inc < 0) call pstop(1, "increment must be nonnegative")
224  else
225  inc = 1
226  end if
227 
228  ! -- expand array to the requested size, keeping
229  ! existing items, or allocate if still needed
230  ! TODO: may be able to use mold here, e.g.:
231  ! allocate(values(num), mold=proto)
232  if (allocated(array)) then
233  nold = size(array)
234  nnew = nold + inc
235  allocate (temp(nold))
236  do i = 1, nold
237  temp(i) = array(i)
238  end do
239  deallocate (array)
240  allocate (array(nnew))
241  do i = 1, nold
242  array(i) = temp(i)
243  end do
244  do i = nold + 1, nnew
245  array(i) = ''
246  end do
247  deallocate (temp)
248  else
249  allocate (array(inc))
250  end if
251 
Here is the call graph for this function:

◆ expand_double()

subroutine arrayhandlersmodule::expandarray::expand_double ( real(dp), dimension(:), intent(inout), allocatable  array,
integer(i4b), intent(in), optional  increment 
)
private

Definition at line 139 of file ArrayHandlers.f90.

140  ! -- dummy
141  real(DP), allocatable, intent(inout) :: array(:)
142  integer(I4B), optional, intent(in) :: increment
143  ! -- local
144  integer(I4B) :: inc, lb, n
145  real(DP), allocatable, dimension(:) :: temp
146 
147  ! -- default to expanding by 1
148  if (present(increment)) then
149  inc = increment
150  if (inc == 0) return
151  if (inc < 0) call pstop(1, "increment must be nonnegative")
152  else
153  inc = 1
154  end if
155 
156  ! -- expand array to the requested size, keeping
157  ! existing items and the existing lower bound,
158  ! or allocate the array if still unallocated
159  if (allocated(array)) then
160  lb = lbound(array, 1)
161  n = size(array)
162  allocate (temp(lb:(lb + n + inc - 1)))
163  temp(lb:(lb + n - 1)) = array
164  deallocate (array)
165  call move_alloc(temp, array)
166  else
167  allocate (array(inc))
168  end if
169 
Here is the call graph for this function:

◆ expand_integer()

subroutine arrayhandlersmodule::expandarray::expand_integer ( integer(i4b), dimension(:), intent(inout), allocatable  array,
integer(i4b), intent(in), optional  increment 
)
private

Definition at line 107 of file ArrayHandlers.f90.

108  ! -- dummy
109  integer(I4B), allocatable, intent(inout) :: array(:)
110  integer(I4B), optional, intent(in) :: increment
111  ! -- local
112  integer(I4B) :: inc, lb, n
113  integer(I4B), allocatable, dimension(:) :: temp
114 
115  ! -- default to expanding by 1
116  if (present(increment)) then
117  inc = increment
118  if (inc == 0) return
119  if (inc < 0) call pstop(1, "increment must be nonnegative")
120  else
121  inc = 1
122  end if
123 
124  ! -- expand array to the requested size, keeping
125  ! existing items and the existing lower bound,
126  ! or allocate the array if still unallocated
127  if (allocated(array)) then
128  lb = lbound(array, 1)
129  n = size(array)
130  allocate (temp(lb:(lb + n + inc - 1)))
131  temp(lb:(lb + n - 1)) = array
132  deallocate (array)
133  call move_alloc(temp, array)
134  else
135  allocate (array(inc))
136  end if
Here is the call graph for this function:

◆ expand_logical()

subroutine arrayhandlersmodule::expandarray::expand_logical ( logical(lgp), dimension(:), intent(inout), allocatable  array,
integer(i4b), intent(in), optional  increment 
)
private

Definition at line 172 of file ArrayHandlers.f90.

173  ! -- dummy
174  logical(LGP), allocatable, intent(inout) :: array(:)
175  integer(I4B), optional, intent(in) :: increment
176  ! -- local
177  integer(I4B) :: inc, lb, n
178  logical(LGP), allocatable, dimension(:) :: temp
179 
180  ! -- default to expanding by 1
181  if (present(increment)) then
182  inc = increment
183  if (inc == 0) return
184  if (inc < 0) call pstop(1, "increment must be nonnegative")
185  else
186  inc = 1
187  end if
188 
189  ! -- expand array to the requested size, keeping
190  ! existing items and the existing lower bound,
191  ! or allocate the array if still unallocated
192  if (allocated(array)) then
193  lb = lbound(array, 1)
194  n = size(array)
195  allocate (temp(lb:(lb + n + inc - 1)))
196  temp(lb:(lb + n - 1)) = array
197  deallocate (array)
198  call move_alloc(temp, array)
199  else
200  allocate (array(inc))
201  end if
202 
Here is the call graph for this function:

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