MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
TimeArray.f90
Go to the documentation of this file.
2 
3  use kindmodule, only: dp, i4b
4  use listmodule, only: listtype
5  use simvariablesmodule, only: errmsg
6  use simmodule, only: store_error
7 
8  implicit none
9  private
10  public :: timearraytype, constructtimearray, &
13 
14  type :: timearraytype
15  ! -- Public members
16  real(dp), public :: tatime
17  real(dp), dimension(:), pointer, contiguous, public :: taarray => null()
18 
19  contains
20 
21  ! -- Public procedures
22  ! -- When gfortran adds support for finalization, the
23  ! following declaration could be: final :: finalize
24  procedure, public :: da => ta_da
25  end type timearraytype
26 
27 contains
28 
29  !> @brief Construct time array
30  !!
31  !! Allocate and assign members of a new TimeArrayType object. Allocate space
32  !! for the array so that this subroutine can be called repeatedly with the
33  !! same array (but with different contents).
34  !<
35  subroutine constructtimearray(newTa, modelname)
36  ! -- modules
37  use constantsmodule, only: lenmempath
40  ! -- dummy
41  type(timearraytype), pointer, intent(out) :: newta
42  character(len=*), intent(in) :: modelname
43  ! -- local
44  integer(I4B), dimension(:), contiguous, &
45  pointer :: mshape
46  character(len=LENMEMPATH) :: mempath
47  integer(I4B) :: isize
48  !
49  ! -- initialize
50  nullify (mshape)
51  !
52  ! -- create mempath
53  mempath = create_mem_path(component=modelname, subcomponent='DIS')
54  !
55  ! -- set mshape pointer
56  call mem_setptr(mshape, 'MSHAPE', mempath)
57  !
58  ! Get dimensions for supported discretization type
59  if (size(mshape) == 2) then
60  isize = mshape(2)
61  else if (size(mshape) == 3) then
62  isize = mshape(2) * mshape(3)
63  else
64  errmsg = 'Time array series is not supported for discretization type'
65  call store_error(errmsg, terminate=.true.)
66  end if
67  !
68  allocate (newta)
69  allocate (newta%taArray(isize))
70  !
71  ! -- Return
72  return
73  end subroutine constructtimearray
74 
75  !> @brief Cast an unlimited polymorphic object as TimeArrayType
76  !<
77  function castastimearraytype(obj) result(res)
78  ! -- dummy
79  class(*), pointer, intent(inout) :: obj
80  ! -- return
81  type(timearraytype), pointer :: res
82  !
83  res => null()
84  if (.not. associated(obj)) return
85  !
86  select type (obj)
87  type is (timearraytype)
88  res => obj
89  end select
90  !
91  ! -- Return
92  return
93  end function castastimearraytype
94 
95  !> @brief Add a time array to a to list
96  !<
97  subroutine addtimearraytolist(list, timearray)
98  ! -- dummy
99  type(listtype), intent(inout) :: list
100  type(timearraytype), pointer, intent(inout) :: timearray
101  ! -- local
102  class(*), pointer :: obj
103  !
104  obj => timearray
105  call list%Add(obj)
106  !
107  ! -- Return
108  return
109  end subroutine addtimearraytolist
110 
111  !> @brief Retrieve a time array from a list
112  !<
113  function gettimearrayfromlist(list, indx) result(res)
114  ! -- dummy
115  type(listtype), intent(inout) :: list
116  integer(I4B), intent(in) :: indx
117  ! -- return
118  type(timearraytype), pointer :: res
119  ! -- local
120  class(*), pointer :: obj
121  !
122  obj => list%GetItem(indx)
123  res => castastimearraytype(obj)
124  !
125  ! -- Return
126  return
127  end function gettimearrayfromlist
128 
129  !> @brief Deallocate memory
130  !<
131  subroutine ta_da(this)
132  ! -- dummy
133  class(timearraytype) :: this
134  !
135  deallocate (this%taArray)
136  this%taArray => null()
137  !
138  ! -- Return
139  return
140  end subroutine ta_da
141 
142 end module timearraymodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
This module defines variable data types.
Definition: kind.f90:8
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
type(timearraytype) function, pointer, public castastimearraytype(obj)
Cast an unlimited polymorphic object as TimeArrayType.
Definition: TimeArray.f90:78
type(timearraytype) function, pointer, public gettimearrayfromlist(list, indx)
Retrieve a time array from a list.
Definition: TimeArray.f90:114
subroutine, public constructtimearray(newTa, modelname)
Construct time array.
Definition: TimeArray.f90:36
subroutine, public addtimearraytolist(list, timearray)
Add a time array to a to list.
Definition: TimeArray.f90:98
subroutine ta_da(this)
Deallocate memory.
Definition: TimeArray.f90:132
A generic heterogeneous doubly-linked list.
Definition: List.f90:10