MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
structarraymodule Module Reference

This module contains the StructArrayModule. More...

Data Types

type  structarraytype
 type for structured array More...
 

Functions/Subroutines

type(structarraytype) function, pointer, public constructstructarray (mf6_input, ncol, nrow, blocknum, mempath, component_mempath)
 constructor for a struct_array More...
 
subroutine, public destructstructarray (struct_array)
 destructor for a struct_array More...
 
subroutine mem_create_vector (this, icol, idt)
 create new vector in StructArrayType More...
 
integer(i4b) function count (this)
 
subroutine set_pointer (sv, sv_target)
 
type(structvectortype) function, pointer get (this, idx)
 
subroutine allocate_int_type (this, sv)
 allocate integer input type More...
 
subroutine allocate_dbl_type (this, sv)
 allocate double input type More...
 
subroutine allocate_charstr_type (this, sv)
 allocate charstr input type More...
 
subroutine allocate_int1d_type (this, sv)
 allocate int1d input type More...
 
subroutine allocate_dbl1d_type (this, sv)
 allocate dbl1d input type More...
 
subroutine load_deferred_vector (this, icol)
 
subroutine memload_vectors (this)
 load deferred vectors into managed memory More...
 
subroutine log_structarray_vars (this, iout)
 log information about the StructArrayType More...
 
subroutine check_reallocate (this)
 reallocate local memory for deferred vectors if necessary More...
 
subroutine write_struct_vector (this, parser, sv_col, irow, timeseries, iout, auxcol)
 
integer(i4b) function read_from_parser (this, parser, timeseries, iout)
 read from the block parser to fill the StructArrayType More...
 
integer(i4b) function read_from_binary (this, inunit, iout)
 read from binary input to fill the StructArrayType More...
 

Detailed Description

This module contains the routines for reading a structured list, which consists of a separate vector for each column in the list.

Function/Subroutine Documentation

◆ allocate_charstr_type()

subroutine structarraymodule::allocate_charstr_type ( class(structarraytype this,
type(structvectortype), intent(inout)  sv 
)
private
Parameters
thisStructArrayType

Definition at line 275 of file StructArray.f90.

276  class(StructArrayType) :: this !< StructArrayType
277  type(StructVectorType), intent(inout) :: sv
278  type(CharacterStringType), dimension(:), pointer, contiguous :: charstr1d
279  integer(I4B) :: j
280  !
281  if (this%deferred_shape) then
282  allocate (charstr1d(this%deferred_size_init))
283  else
284  call mem_allocate(charstr1d, linelength, this%nrow, &
285  sv%idt%mf6varname, this%mempath)
286  end if
287  !
288  do j = 1, this%nrow
289  charstr1d(j) = ''
290  end do
291  !
292  sv%memtype = 3
293  sv%charstr1d => charstr1d
294  !
295  ! -- return
296  return

◆ allocate_dbl1d_type()

subroutine structarraymodule::allocate_dbl1d_type ( class(structarraytype this,
type(structvectortype), intent(inout)  sv 
)
Parameters
thisStructArrayType

Definition at line 389 of file StructArray.f90.

390  use memorymanagermodule, only: get_isize
391  class(StructArrayType) :: this !< StructArrayType
392  type(StructVectorType), intent(inout) :: sv
393  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
394  integer(I4B), pointer :: naux, nseg, nseg_1
395  integer(I4B) :: nseg1_isize, n, m
396  !
397  if (sv%idt%shape == 'NAUX') then
398  call mem_setptr(naux, sv%idt%shape, this%mempath)
399  !
400  call mem_allocate(dbl2d, naux, this%nrow, sv%idt%mf6varname, this%mempath)
401  !
402  ! -- initialize
403  do m = 1, this%nrow
404  do n = 1, naux
405  dbl2d(n, m) = dzero
406  end do
407  end do
408  !
409  sv%memtype = 6
410  sv%dbl2d => dbl2d
411  sv%intshape => naux
412  !
413  else if (sv%idt%shape == 'NSEG-1') then
414  call mem_setptr(nseg, 'NSEG', this%mempath)
415  !
416  call get_isize('NSEG_1', this%mempath, nseg1_isize)
417  !
418  if (nseg1_isize < 0) then
419  call mem_allocate(nseg_1, 'NSEG_1', this%mempath)
420  nseg_1 = nseg - 1
421  else
422  call mem_setptr(nseg_1, 'NSEG_1', this%mempath)
423  end if
424  !
425  call mem_allocate(dbl2d, nseg_1, this%nrow, sv%idt%mf6varname, this%mempath)
426  !
427  ! -- initialize
428  do m = 1, this%nrow
429  do n = 1, nseg_1
430  dbl2d(n, m) = dzero
431  end do
432  end do
433  !
434  sv%memtype = 6
435  sv%dbl2d => dbl2d
436  sv%intshape => nseg_1
437  !
438  else
439  errmsg = 'IDM unimplemented. StructArray::allocate_dbl1d_type &
440  & unsupported shape "'//trim(sv%idt%shape)//'".'
441  call store_error(errmsg, terminate=.true.)
442  end if
443  !
444  ! -- return
445  return
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
Here is the call graph for this function:

◆ allocate_dbl_type()

subroutine structarraymodule::allocate_dbl_type ( class(structarraytype this,
type(structvectortype), intent(inout)  sv 
)
private
Parameters
thisStructArrayType

Definition at line 245 of file StructArray.f90.

246  class(StructArrayType) :: this !< StructArrayType
247  type(StructVectorType), intent(inout) :: sv
248  real(DP), dimension(:), pointer, contiguous :: dbl1d
249  integer(I4B) :: j, nrow
250  !
251  if (this%deferred_shape) then
252  ! -- shape not known, allocate locally
253  nrow = this%deferred_size_init
254  allocate (dbl1d(this%deferred_size_init))
255  else
256  ! -- shape known, allocate in managed memory
257  nrow = this%nrow
258  call mem_allocate(dbl1d, this%nrow, sv%idt%mf6varname, this%mempath)
259  end if
260  !
261  ! -- initialize
262  do j = 1, nrow
263  dbl1d(j) = dzero
264  end do
265  !
266  sv%memtype = 2
267  sv%dbl1d => dbl1d
268  !
269  ! -- return
270  return

◆ allocate_int1d_type()

subroutine structarraymodule::allocate_int1d_type ( class(structarraytype this,
type(structvectortype), intent(inout)  sv 
)
private
Parameters
thisStructArrayType

Definition at line 301 of file StructArray.f90.

302  use constantsmodule, only: lenmodelname
305  class(StructArrayType) :: this !< StructArrayType
306  type(StructVectorType), intent(inout) :: sv
307  integer(I4B), dimension(:, :), pointer, contiguous :: int2d
308  type(STLVecInt), pointer :: intvector
309  integer(I4B), pointer :: ncelldim, exgid
310  character(len=LENMEMPATH) :: input_mempath
311  character(len=LENMODELNAME) :: mname
312  type(CharacterStringType), dimension(:), contiguous, &
313  pointer :: charstr1d
314  integer(I4B) :: nrow, n, m
315  !
316  if (sv%idt%shape == 'NCELLDIM') then
317  !
318  ! -- if EXCHANGE set to NCELLDIM of appropriate model
319  if (this%mf6_input%component_type == 'EXG') then
320  !
321  ! -- set pointer to EXGID
322  call mem_setptr(exgid, 'EXGID', this%mf6_input%mempath)
323  !
324  ! -- set pointer to appropriate exchange model array
325  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
326  !
327  if (sv%idt%tagname == 'CELLIDM1') then
328  call mem_setptr(charstr1d, 'EXGMNAMEA', input_mempath)
329  else if (sv%idt%tagname == 'CELLIDM2') then
330  call mem_setptr(charstr1d, 'EXGMNAMEB', input_mempath)
331  end if
332  !
333  ! -- set the model name
334  mname = charstr1d(exgid)
335  !
336  ! -- set ncelldim pointer
337  input_mempath = create_mem_path(component=mname, context=idm_context)
338  call mem_setptr(ncelldim, sv%idt%shape, input_mempath)
339  else
340  !
341  call mem_setptr(ncelldim, sv%idt%shape, this%component_mempath)
342  end if
343  !
344  if (this%deferred_shape) then
345  ! -- shape not known, allocate locally
346  nrow = this%deferred_size_init
347  allocate (int2d(ncelldim, this%deferred_size_init))
348  !
349  else
350  ! -- shape known, allocate in managed memory
351  nrow = this%nrow
352  call mem_allocate(int2d, ncelldim, this%nrow, &
353  sv%idt%mf6varname, this%mempath)
354  end if
355  !
356  ! -- initialize
357  do m = 1, nrow
358  do n = 1, ncelldim
359  int2d(n, m) = izero
360  end do
361  end do
362  !
363  sv%memtype = 5
364  sv%int2d => int2d
365  sv%intshape => ncelldim
366  !
367  else
368  !
369  ! -- allocate intvector object
370  allocate (intvector)
371  !
372  ! -- initialize STLVecInt
373  call intvector%init()
374  !
375  sv%memtype = 4
376  sv%intvector => intvector
377  sv%size = -1
378  !
379  ! -- set pointer to dynamic shape
380  call mem_setptr(sv%intvector_shape, sv%idt%shape, this%mempath)
381  end if
382  !
383  ! -- return
384  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition: Constants.f90:21
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=linelength) idm_context
Here is the call graph for this function:

◆ allocate_int_type()

subroutine structarraymodule::allocate_int_type ( class(structarraytype this,
type(structvectortype), intent(inout)  sv 
)
private
Parameters
thisStructArrayType

Definition at line 215 of file StructArray.f90.

216  class(StructArrayType) :: this !< StructArrayType
217  type(StructVectorType), intent(inout) :: sv
218  integer(I4B), dimension(:), pointer, contiguous :: int1d
219  integer(I4B) :: j, nrow
220  !
221  if (this%deferred_shape) then
222  ! -- shape not known, allocate locally
223  nrow = this%deferred_size_init
224  allocate (int1d(this%deferred_size_init))
225  else
226  ! -- shape known, allocate in managed memory
227  nrow = this%nrow
228  call mem_allocate(int1d, this%nrow, sv%idt%mf6varname, this%mempath)
229  end if
230  !
231  ! -- initialize vector values
232  do j = 1, nrow
233  int1d(j) = izero
234  end do
235  !
236  sv%memtype = 1
237  sv%int1d => int1d
238  !
239  ! -- return
240  return

◆ check_reallocate()

subroutine structarraymodule::check_reallocate ( class(structarraytype this)
private
Parameters
thisStructArrayType

Definition at line 698 of file StructArray.f90.

699  class(StructArrayType) :: this !< StructArrayType
700  integer(I4B) :: i, j, k, newsize
701  integer(I4B), dimension(:), pointer, contiguous :: p_int1d
702  integer(I4B), dimension(:, :), pointer, contiguous :: p_int2d
703  real(DP), dimension(:), pointer, contiguous :: p_dbl1d
704  type(CharacterStringType), dimension(:), pointer, contiguous :: p_charstr1d
705  integer(I4B) :: reallocate_mult
706  !
707  ! -- set growth rate
708  reallocate_mult = 2
709  !
710  do j = 1, this%ncol
711  !
712  ! -- reallocate based on memtype
713  select case (this%struct_vectors(j)%memtype)
714  !
715  case (1) ! -- memtype integer
716  !
717  ! -- check if more space needed
718  if (this%nrow > this%struct_vectors(j)%size) then
719  !
720  ! -- calculate new size
721  newsize = this%struct_vectors(j)%size * reallocate_mult
722  !
723  ! -- allocate new vector
724  allocate (p_int1d(newsize))
725  !
726  ! -- copy from old to new
727  do i = 1, this%struct_vectors(j)%size
728  p_int1d(i) = this%struct_vectors(j)%int1d(i)
729  end do
730  !
731  ! -- deallocate old vector
732  deallocate (this%struct_vectors(j)%int1d)
733  !
734  ! -- update struct array object
735  this%struct_vectors(j)%int1d => p_int1d
736  this%struct_vectors(j)%size = newsize
737  end if
738  !
739  case (2) ! -- memtype real
740  if (this%nrow > this%struct_vectors(j)%size) then
741  !
742  newsize = this%struct_vectors(j)%size * reallocate_mult
743  !
744  allocate (p_dbl1d(newsize))
745  !
746  do i = 1, this%struct_vectors(j)%size
747  p_dbl1d(i) = this%struct_vectors(j)%dbl1d(i)
748  end do
749  !
750  deallocate (this%struct_vectors(j)%dbl1d)
751  !
752  this%struct_vectors(j)%dbl1d => p_dbl1d
753  this%struct_vectors(j)%size = newsize
754  end if
755  !
756  case (3) ! -- memtype charstring
757  if (this%nrow > this%struct_vectors(j)%size) then
758  !
759  newsize = this%struct_vectors(j)%size * reallocate_mult
760  !
761  allocate (p_charstr1d(newsize))
762  !
763  do i = 1, this%struct_vectors(j)%size
764  p_charstr1d(i) = this%struct_vectors(j)%charstr1d(i)
765  end do
766  !
767  deallocate (this%struct_vectors(j)%charstr1d)
768  !
769  this%struct_vectors(j)%charstr1d => p_charstr1d
770  this%struct_vectors(j)%size = newsize
771  end if
772  case (5)
773  if (this%nrow > this%struct_vectors(j)%size) then
774  !
775  newsize = this%struct_vectors(j)%size * reallocate_mult
776  !
777  allocate (p_int2d(this%struct_vectors(j)%intshape, newsize))
778  !
779  do i = 1, this%struct_vectors(j)%size
780  do k = 1, this%struct_vectors(j)%intshape
781  p_int2d(k, i) = this%struct_vectors(j)%int2d(k, i)
782  end do
783  end do
784  !
785  deallocate (this%struct_vectors(j)%int2d)
786  !
787  this%struct_vectors(j)%int2d => p_int2d
788  this%struct_vectors(j)%size = newsize
789  end if
790  ! TODO: case (6)
791  case default
792  errmsg = 'IDM unimplemented. StructArray::check_reallocate &
793  &unsupported memtype.'
794  call store_error(errmsg, terminate=.true.)
795  end select
796  end do
797  !
798  ! -- return
799  return
Here is the call graph for this function:

◆ constructstructarray()

type(structarraytype) function, pointer, public structarraymodule::constructstructarray ( type(modflowinputtype), intent(in)  mf6_input,
integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
integer(i4b), intent(in)  blocknum,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  component_mempath 
)
Parameters
[in]ncolnumber of columns in the StructArrayType
[in]nrownumber of rows in the StructArrayType
[in]blocknumvalid block number or 0
[in]mempathmemory path for storing the vector
Returns
new StructArrayType

Definition at line 72 of file StructArray.f90.

74  type(ModflowInputType), intent(in) :: mf6_input
75  integer(I4B), intent(in) :: ncol !< number of columns in the StructArrayType
76  integer(I4B), intent(in) :: nrow !< number of rows in the StructArrayType
77  integer(I4B), intent(in) :: blocknum !< valid block number or 0
78  character(len=*), intent(in) :: mempath !< memory path for storing the vector
79  character(len=*), intent(in) :: component_mempath
80  type(StructArrayType), pointer :: struct_array !< new StructArrayType
81  !
82  ! -- allocate StructArrayType
83  allocate (struct_array)
84  !
85  ! -- set description of input
86  struct_array%mf6_input = mf6_input
87  !
88  ! -- set number of arrays
89  struct_array%ncol = ncol
90  !
91  ! -- set rows if known or set deferred
92  struct_array%nrow = nrow
93  if (struct_array%nrow == 0) then
94  struct_array%deferred_shape = .true.
95  end if
96  !
97  ! -- set blocknum
98  if (blocknum > 0) then
99  struct_array%blocknum = blocknum
100  else
101  struct_array%blocknum = 0
102  end if
103  !
104  !
105  struct_array%mempath = mempath
106  struct_array%component_mempath = component_mempath
107  !
108  ! -- allocate StructVectorType objects
109  allocate (struct_array%struct_vectors(ncol))
110  allocate (struct_array%startidx(ncol))
111  allocate (struct_array%numcols(ncol))
Here is the caller graph for this function:

◆ count()

integer(i4b) function structarraymodule::count ( class(structarraytype this)
private
Parameters
thisStructArrayType

Definition at line 194 of file StructArray.f90.

195  class(StructArrayType) :: this !< StructArrayType
196  integer(I4B) :: count
197  count = size(this%struct_vectors)

◆ destructstructarray()

subroutine, public structarraymodule::destructstructarray ( type(structarraytype), intent(inout), pointer  struct_array)
Parameters
[in,out]struct_arrayStructArrayType to destroy

Definition at line 116 of file StructArray.f90.

117  type(StructArrayType), pointer, intent(inout) :: struct_array !< StructArrayType to destroy
118 
119  deallocate (struct_array%struct_vectors)
120  deallocate (struct_array%startidx)
121  deallocate (struct_array%numcols)
122  deallocate (struct_array)
123  nullify (struct_array)
Here is the caller graph for this function:

◆ get()

type(structvectortype) function, pointer structarraymodule::get ( class(structarraytype this,
integer(i4b), intent(in)  idx 
)
private
Parameters
thisStructArrayType

Definition at line 206 of file StructArray.f90.

207  class(StructArrayType) :: this !< StructArrayType
208  integer(I4B), intent(in) :: idx
209  type(StructVectorType), pointer :: sv
210  call set_pointer(sv, this%struct_vectors(idx))
Here is the call graph for this function:

◆ load_deferred_vector()

subroutine structarraymodule::load_deferred_vector ( class(structarraytype this,
integer(i4b), intent(in)  icol 
)
Parameters
thisStructArrayType

Definition at line 448 of file StructArray.f90.

449  use memorymanagermodule, only: get_isize
450  class(StructArrayType) :: this !< StructArrayType
451  integer(I4B), intent(in) :: icol
452  integer(I4B) :: i, j, isize
453  integer(I4B), dimension(:), pointer, contiguous :: p_int1d
454  integer(I4B), dimension(:, :), pointer, contiguous :: p_int2d
455  real(DP), dimension(:), pointer, contiguous :: p_dbl1d
456  type(CharacterStringType), dimension(:), pointer, contiguous :: p_charstr1d
457  character(len=LENVARNAME) :: varname
458  !
459  ! -- set varname
460  varname = this%struct_vectors(icol)%idt%mf6varname
461  !
462  ! -- check if already mem managed variable
463  call get_isize(varname, this%mempath, isize)
464  !
465  ! -- allocate and load based on memtype
466  select case (this%struct_vectors(icol)%memtype)
467  !
468  case (1) ! -- memtype integer
469  !
470  if (isize > -1) then
471  ! -- variable exists, reallocate and append
472  call mem_setptr(p_int1d, varname, this%mempath)
473  ! -- Currently deferred vectors are appended to managed
474  ! memory vectors when they are already allocated
475  ! (e.g. SIMNAM SolutionGroup)
476  call mem_reallocate(p_int1d, this%nrow + isize, varname, this%mempath)
477 
478  do i = 1, this%nrow
479  p_int1d(isize + i) = this%struct_vectors(icol)%int1d(i)
480  end do
481  else
482  !
483  ! -- allocate memory manager vector
484  call mem_allocate(p_int1d, this%nrow, varname, this%mempath)
485  !
486  ! -- load local vector to managed memory
487  do i = 1, this%nrow
488  p_int1d(i) = this%struct_vectors(icol)%int1d(i)
489  end do
490  end if
491  !
492  ! -- deallocate local memory
493  deallocate (this%struct_vectors(icol)%int1d)
494  !
495  ! -- update structvector
496  this%struct_vectors(icol)%int1d => p_int1d
497  this%struct_vectors(icol)%size = this%nrow
498  !
499  case (2) ! -- memtype real
500  !
501  if (isize > -1) then
502  call mem_setptr(p_dbl1d, varname, this%mempath)
503  call mem_reallocate(p_dbl1d, this%nrow + isize, varname, &
504  this%mempath)
505  !
506  do i = 1, this%nrow
507  p_dbl1d(isize + i) = this%struct_vectors(icol)%dbl1d(i)
508  end do
509  else
510  call mem_allocate(p_dbl1d, this%nrow, varname, this%mempath)
511  !
512  do i = 1, this%nrow
513  p_dbl1d(i) = this%struct_vectors(icol)%dbl1d(i)
514  end do
515  end if
516  !
517  deallocate (this%struct_vectors(icol)%dbl1d)
518  !
519  this%struct_vectors(icol)%dbl1d => p_dbl1d
520  this%struct_vectors(icol)%size = this%nrow
521  !
522  case (3) ! -- memtype charstring
523  !
524  if (isize > -1) then
525  call mem_setptr(p_charstr1d, varname, this%mempath)
526  call mem_reallocate(p_charstr1d, linelength, this%nrow + isize, varname, &
527  this%mempath)
528 
529  do i = 1, this%nrow
530  p_charstr1d(isize + i) = this%struct_vectors(icol)%charstr1d(i)
531  end do
532  else
533  !
534  call mem_allocate(p_charstr1d, linelength, this%nrow, varname, &
535  this%mempath)
536  !
537  do i = 1, this%nrow
538  p_charstr1d(i) = this%struct_vectors(icol)%charstr1d(i)
539  end do
540  end if
541  !
542  deallocate (this%struct_vectors(icol)%charstr1d)
543  !
544  this%struct_vectors(icol)%charstr1d => p_charstr1d
545  this%struct_vectors(icol)%size = this%nrow
546  !
547  case (4) ! -- memtype intvector
548  ! no-op
549  case (5)
550  if (isize > -1) then
551  call mem_setptr(p_int2d, varname, this%mempath)
552  call mem_reallocate(p_int2d, this%struct_vectors(icol)%intshape, &
553  this%nrow, varname, this%mempath)
554 
555  do i = 1, this%nrow
556  do j = 1, this%struct_vectors(icol)%intshape
557  p_int2d(j, isize + i) = this%struct_vectors(icol)%int2d(j, i)
558  end do
559  end do
560  else
561  call mem_allocate(p_int2d, this%struct_vectors(icol)%intshape, &
562  this%nrow, varname, this%mempath)
563  !
564  do i = 1, this%nrow
565  do j = 1, this%struct_vectors(icol)%intshape
566  p_int2d(j, i) = this%struct_vectors(icol)%int2d(j, i)
567  end do
568  end do
569  end if
570  !
571  deallocate (this%struct_vectors(icol)%int2d)
572  !
573  this%struct_vectors(icol)%int2d => p_int2d
574  this%struct_vectors(icol)%size = this%nrow
575  !
576  ! TODO: case (6)
577  case default
578  errmsg = 'IDM unimplemented. StructArray::load_deferred_vector &
579  &unsupported memtype.'
580  call store_error(errmsg, terminate=.true.)
581  end select
582  !
583  ! -- return
584  return
Here is the call graph for this function:

◆ log_structarray_vars()

subroutine structarraymodule::log_structarray_vars ( class(structarraytype this,
integer(i4b), intent(in)  iout 
)
private
Parameters
thisStructArrayType
[in]ioutunit number for output

Definition at line 634 of file StructArray.f90.

635  class(StructArrayType) :: this !< StructArrayType
636  integer(I4B), intent(in) :: iout !< unit number for output
637  integer(I4B) :: j
638  integer(I4B), dimension(:), pointer, contiguous :: int1d
639  !
640  ! -- idm variable logging
641  do j = 1, this%ncol
642  !
643  ! -- log based on memtype
644  select case (this%struct_vectors(j)%memtype)
645  !
646  case (1) ! -- memtype integer
647  !
648  call idm_log_var(this%struct_vectors(j)%int1d, &
649  this%struct_vectors(j)%idt%tagname, &
650  this%mempath, iout)
651  !
652  case (2) ! -- memtype real
653  !
654  if (this%struct_vectors(j)%ts_strlocs%count() > 0) then
655  call idm_log_var(this%struct_vectors(j)%idt%tagname, &
656  this%mempath, iout, .false.)
657  else
658  call idm_log_var(this%struct_vectors(j)%dbl1d, &
659  this%struct_vectors(j)%idt%tagname, &
660  this%mempath, iout)
661  end if
662  !
663  case (4) ! -- memtype intvector
664  !
665  call mem_setptr(int1d, this%struct_vectors(j)%idt%mf6varname, &
666  this%mempath)
667  !
668  call idm_log_var(int1d, this%struct_vectors(j)%idt%tagname, &
669  this%mempath, iout)
670  !
671  case (5) ! -- memtype int2d
672  !
673  call idm_log_var(this%struct_vectors(j)%int2d, &
674  this%struct_vectors(j)%idt%tagname, &
675  this%mempath, iout)
676  !
677  case (6) ! -- memtype dbl2d
678  !
679  if (this%struct_vectors(j)%ts_strlocs%count() > 0) then
680  call idm_log_var(this%struct_vectors(j)%idt%tagname, &
681  this%mempath, iout, .false.)
682  else
683  call idm_log_var(this%struct_vectors(j)%dbl2d, &
684  this%struct_vectors(j)%idt%tagname, &
685  this%mempath, iout)
686  end if
687  !
688  end select
689  !
690  end do
691  !
692  ! -- return
693  return

◆ mem_create_vector()

subroutine structarraymodule::mem_create_vector ( class(structarraytype this,
integer(i4b), intent(in)  icol,
type(inputparamdefinitiontype), pointer  idt 
)
private
Parameters
thisStructArrayType
[in]icolcolumn to create

Definition at line 128 of file StructArray.f90.

129  class(StructArrayType) :: this !< StructArrayType
130  integer(I4B), intent(in) :: icol !< column to create
131  type(InputParamDefinitionType), pointer :: idt
132  type(StructVectorType) :: sv
133  integer(I4B) :: numcol
134  !
135  numcol = 1
136  !
137  sv%idt => idt
138  sv%icol = icol
139  !
140  ! -- set size
141  if (this%deferred_shape) then
142  sv%size = this%deferred_size_init
143  else
144  sv%size = this%nrow
145  end if
146  !
147  ! -- allocate array memory for StructVectorType
148  select case (idt%datatype)
149  !
150  case ('INTEGER')
151  !
152  call this%allocate_int_type(sv)
153  !
154  case ('DOUBLE')
155  !
156  call this%allocate_dbl_type(sv)
157  !
158  case ('STRING', 'KEYWORD')
159  !
160  call this%allocate_charstr_type(sv)
161  !
162  case ('INTEGER1D')
163  !
164  call this%allocate_int1d_type(sv)
165  if (sv%memtype == 5) then
166  numcol = sv%intshape
167  end if
168  !
169  case ('DOUBLE1D')
170  !
171  call this%allocate_dbl1d_type(sv)
172  numcol = sv%intshape
173  !
174  case default
175  errmsg = 'IDM unimplemented. StructArray::mem_create_vector &
176  &type='//trim(idt%datatype)
177  call store_error(errmsg, .true.)
178  end select
179  !
180  ! -- set the object in the Struct Array
181  this%struct_vectors(icol) = sv
182  !
183  this%numcols(icol) = numcol
184  if (icol == 1) then
185  this%startidx(icol) = 1
186  else
187  this%startidx(icol) = this%startidx(icol - 1) + this%numcols(icol - 1)
188  end if
189  !
190  ! -- return
191  return
Here is the call graph for this function:

◆ memload_vectors()

subroutine structarraymodule::memload_vectors ( class(structarraytype this)
Parameters
thisStructArrayType

Definition at line 589 of file StructArray.f90.

590  class(StructArrayType) :: this !< StructArrayType
591  integer(I4B) :: icol, j
592  integer(I4B), dimension(:), pointer, contiguous :: p_intvector
593  character(len=LENVARNAME) :: varname
594  !
595  do icol = 1, this%ncol
596  !
597  ! -- set varname
598  varname = this%struct_vectors(icol)%idt%mf6varname
599  !
600  if (this%struct_vectors(icol)%memtype == 4) then
601  ! -- intvectors always need to be loaded
602  !
603  ! -- size intvector to number of values read
604  call this%struct_vectors(icol)%intvector%shrink_to_fit()
605  !
606  ! -- allocate memory manager vector
607  call mem_allocate(p_intvector, &
608  this%struct_vectors(icol)%intvector%size, &
609  varname, this%mempath)
610  !
611  ! -- load local vector to managed memory
612  do j = 1, this%struct_vectors(icol)%intvector%size
613  p_intvector(j) = this%struct_vectors(icol)%intvector%at(j)
614  end do
615  !
616  ! -- cleanup local memory
617  call this%struct_vectors(icol)%intvector%destroy()
618  deallocate (this%struct_vectors(icol)%intvector)
619  nullify (this%struct_vectors(icol)%intvector_shape)
620  !
621  else if (this%deferred_shape) then
622  !
623  ! -- load as shape wasn't known
624  call this%load_deferred_vector(icol)
625  end if
626  end do
627  !
628  ! -- return
629  return

◆ read_from_binary()

integer(i4b) function structarraymodule::read_from_binary ( class(structarraytype this,
integer(i4b), intent(in)  inunit,
integer(i4b), intent(in)  iout 
)
private
Parameters
thisStructArrayType
[in]inunitunit number for binary input
[in]ioutunit number for output

Definition at line 957 of file StructArray.f90.

958  class(StructArrayType) :: this !< StructArrayType
959  integer(I4B), intent(in) :: inunit !< unit number for binary input
960  integer(I4B), intent(in) :: iout !< unit number for output
961  integer(I4B) :: irow, ierr
962  integer(I4B) :: j, k
963  integer(I4B) :: intval, numval
964  character(len=LINELENGTH) :: fname
965  character(len=*), parameter :: fmtlsterronly = &
966  "('Error reading LIST from file: ',&
967  &1x,a,1x,' on UNIT: ',I0)"
968  !
969  ! -- set error and exit if deferred shape
970  if (this%deferred_shape) then
971  !
972  errmsg = 'IDM unimplemented. StructArray::read_from_binary deferred shape &
973  &not supported for binary inputs.'
974  call store_error(errmsg, terminate=.true.)
975  !
976  end if
977  !
978  ! -- initialize
979  irow = 0
980  ierr = 0
981  !
982  readloop: do
983  !
984  ! -- update irow index
985  irow = irow + 1
986  !
987  ! -- handle line reads by column memtype
988  do j = 1, this%ncol
989  !
990  select case (this%struct_vectors(j)%memtype)
991  !
992  case (1) ! -- memtype integer
993  read (inunit, iostat=ierr) this%struct_vectors(j)%int1d(irow)
994  case (2) ! -- memtype real
995  read (inunit, iostat=ierr) this%struct_vectors(j)%dbl1d(irow)
996  case (3) ! -- memtype charstring
997  !
998  errmsg = 'IDM unimplemented. StructArray::read_from_binary string &
999  &types not supported for binary inputs.'
1000  call store_error(errmsg, terminate=.true.)
1001  !
1002  case (4) ! -- memtype intvector
1003  !
1004  ! -- get shape for this row
1005  numval = this%struct_vectors(j)%intvector_shape(irow)
1006  !
1007  ! -- read and store row values
1008  do k = 1, numval
1009  if (ierr == 0) then
1010  read (inunit, iostat=ierr) intval
1011  call this%struct_vectors(j)%intvector%push_back(intval)
1012  end if
1013  end do
1014  !
1015  case (5) ! -- memtype int2d
1016  !
1017  ! -- read and store row values
1018  do k = 1, this%struct_vectors(j)%intshape
1019  if (ierr == 0) then
1020  read (inunit, iostat=ierr) this%struct_vectors(j)%int2d(k, irow)
1021  end if
1022  end do
1023  !
1024  case (6) ! -- memtype dbl2d
1025  do k = 1, this%struct_vectors(j)%intshape
1026  if (ierr == 0) then
1027  read (inunit, iostat=ierr) this%struct_vectors(j)%dbl2d(k, irow)
1028  end if
1029  end do
1030  end select
1031  !
1032  ! -- handle error cases
1033  select case (ierr)
1034  case (0)
1035  ! no error
1036  case (:-1)
1037  !
1038  ! -- End of block was encountered
1039  irow = irow - 1
1040  exit readloop
1041  !
1042  case (1:)
1043  !
1044  ! -- Error
1045  inquire (unit=inunit, name=fname)
1046  write (errmsg, fmtlsterronly) trim(adjustl(fname)), inunit
1047  call store_error(errmsg, terminate=.true.)
1048  !
1049  case default
1050  end select
1051  !
1052  end do
1053  !
1054  if (irow == this%nrow) exit readloop
1055  !
1056  end do readloop
1057  !
1058  ! -- Stop if errors were detected
1059  !if (count_errors() > 0) then
1060  ! call store_error_unit(inunit)
1061  !end if
1062  !
1063  ! -- if deferred shape vectors were read, load to input path
1064  call this%memload_vectors()
1065  !
1066  ! -- log loaded variables
1067  if (iout > 0) then
1068  call this%log_structarray_vars(iout)
1069  end if
1070  !
1071  ! -- return
1072  return
Here is the call graph for this function:

◆ read_from_parser()

integer(i4b) function structarraymodule::read_from_parser ( class(structarraytype this,
type(blockparsertype parser,
logical(lgp), intent(in)  timeseries,
integer(i4b), intent(in)  iout 
)
private
Parameters
thisStructArrayType
parserblock parser to read from
[in]ioutunit number for output

Definition at line 902 of file StructArray.f90.

903  class(StructArrayType) :: this !< StructArrayType
904  type(BlockParserType) :: parser !< block parser to read from
905  logical(LGP), intent(in) :: timeseries
906  integer(I4B), intent(in) :: iout !< unit number for output
907  integer(I4B) :: irow, j
908  logical(LGP) :: endOfBlock
909  !
910  ! -- initialize index irow
911  irow = 0
912  !
913  ! -- read entire block
914  do
915  !
916  ! -- read next line
917  call parser%GetNextLine(endofblock)
918  !
919  if (endofblock) then
920  ! -- no more lines
921  exit
922  !
923  else if (this%deferred_shape) then
924  !
925  ! -- shape unknown, track lines read
926  this%nrow = this%nrow + 1
927  !
928  ! -- check and update memory allocation
929  call this%check_reallocate()
930  end if
931  !
932  ! -- update irow index
933  irow = irow + 1
934  !
935  ! -- handle line reads by column memtype
936  do j = 1, this%ncol
937  !
938  call this%write_struct_vector(parser, j, irow, timeseries, iout)
939  !
940  end do
941  end do
942  !
943  ! -- if deferred shape vectors were read, load to input path
944  call this%memload_vectors()
945  !
946  ! -- log loaded variables
947  if (iout > 0) then
948  call this%log_structarray_vars(iout)
949  end if
950  !
951  ! -- return
952  return

◆ set_pointer()

subroutine structarraymodule::set_pointer ( type(structvectortype), pointer  sv,
type(structvectortype), target  sv_target 
)
private

Definition at line 200 of file StructArray.f90.

201  type(StructVectorType), pointer :: sv
202  type(StructVectorType), target :: sv_target
203  sv => sv_target
Here is the caller graph for this function:

◆ write_struct_vector()

subroutine structarraymodule::write_struct_vector ( class(structarraytype this,
type(blockparsertype), intent(inout)  parser,
integer(i4b), intent(in)  sv_col,
integer(i4b), intent(in)  irow,
logical(lgp), intent(in)  timeseries,
integer(i4b), intent(in)  iout,
integer(i4b), intent(in), optional  auxcol 
)
private
Parameters
thisStructArrayType
[in,out]parserblock parser to read from
[in]ioutunit number for output

Definition at line 802 of file StructArray.f90.

804  class(StructArrayType) :: this !< StructArrayType
805  type(BlockParserType), intent(inout) :: parser !< block parser to read from
806  integer(I4B), intent(in) :: sv_col
807  integer(I4B), intent(in) :: irow
808  logical(LGP), intent(in) :: timeseries
809  integer(I4B), intent(in) :: iout !< unit number for output
810  integer(I4B), optional, intent(in) :: auxcol
811  integer(I4B) :: n, intval, numval, icol
812  character(len=LINELENGTH) :: str
813  character(len=:), allocatable :: line
814  logical(LGP) :: preserve_case
815  !
816  select case (this%struct_vectors(sv_col)%memtype)
817  !
818  case (1) ! -- memtype integer
819  !
820  ! -- if reloadable block and first col, store blocknum
821  if (sv_col == 1 .and. this%blocknum > 0) then
822  ! -- store blocknum
823  this%struct_vectors(sv_col)%int1d(irow) = this%blocknum
824  else
825  ! -- read and store int
826  this%struct_vectors(sv_col)%int1d(irow) = parser%GetInteger()
827  end if
828  !
829  case (2) ! -- memtype real
830  !
831  if (this%struct_vectors(sv_col)%idt%timeseries .and. timeseries) then
832  call parser%GetString(str)
833  if (present(auxcol)) then
834  icol = auxcol
835  else
836  icol = 1
837  end if
838  this%struct_vectors(sv_col)%dbl1d(irow) = &
839  this%struct_vectors(sv_col)%read_token(str, this%startidx(sv_col), &
840  icol, irow)
841  else
842  this%struct_vectors(sv_col)%dbl1d(irow) = parser%GetDouble()
843  end if
844  !
845  case (3) ! -- memtype charstring
846  !
847  if (this%struct_vectors(sv_col)%idt%shape /= '') then
848  ! -- if last column with any shape, store rest of line
849  if (sv_col == this%ncol) then
850  call parser%GetRemainingLine(line)
851  this%struct_vectors(sv_col)%charstr1d(irow) = line
852  deallocate (line)
853  end if
854  else
855  !
856  ! -- read string token
857  preserve_case = (.not. this%struct_vectors(sv_col)%idt%preserve_case)
858  call parser%GetString(str, preserve_case)
859  this%struct_vectors(sv_col)%charstr1d(irow) = str
860  end if
861  !
862  case (4) ! -- memtype intvector
863  !
864  ! -- get shape for this row
865  numval = this%struct_vectors(sv_col)%intvector_shape(irow)
866  !
867  ! -- read and store row values
868  do n = 1, numval
869  intval = parser%GetInteger()
870  call this%struct_vectors(sv_col)%intvector%push_back(intval)
871  end do
872  !
873  case (5) ! -- memtype int2d
874  !
875  ! -- read and store row values
876  do n = 1, this%struct_vectors(sv_col)%intshape
877  this%struct_vectors(sv_col)%int2d(n, irow) = parser%GetInteger()
878  end do
879  !
880  case (6) ! -- memtype dbl2d
881  !
882  ! -- read and store row values
883  do n = 1, this%struct_vectors(sv_col)%intshape
884  if (this%struct_vectors(sv_col)%idt%timeseries .and. timeseries) then
885  call parser%GetString(str)
886  icol = this%startidx(sv_col) + n - 1
887  this%struct_vectors(sv_col)%dbl2d(n, irow) = &
888  this%struct_vectors(sv_col)%read_token(str, icol, n, irow)
889  else
890  this%struct_vectors(sv_col)%dbl2d(n, irow) = parser%GetDouble()
891  end if
892  end do
893  !
894  end select
895  !
896  ! -- return
897  return