MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
GwfMvrPeriodData.f90
Go to the documentation of this file.
1 !> @brief This module contains the GwfMvrPeriodDataModule Module
2 !!
3 !! This module contains the code for storing and reading
4 !! stress period data for the GwfMvr Package.
5 !!
6 !<
8  use kindmodule, only: dp, i4b
11  use simvariablesmodule, only: errmsg
12  use simmodule, only: store_error
14 
15  implicit none
16  private
18 
19  !> @brief Derived type for GwfMvrPeriodDataType
20  !!
21  !! This derived type contains information and methods for
22  !! the data read for the GwfMvr Package.
23  !!
24  !<
26  character(len=LENMODELNAME), &
27  dimension(:), pointer, contiguous :: mname1 => null() !< provider model name
28  character(len=LENPACKAGENAME), &
29  dimension(:), pointer, contiguous :: pname1 => null() !< provider package name
30  character(len=LENMODELNAME), &
31  dimension(:), pointer, contiguous :: mname2 => null() !< receiver model name
32  character(len=LENPACKAGENAME), &
33  dimension(:), pointer, contiguous :: pname2 => null() !< receiver package name
34  integer(I4B), dimension(:), pointer, contiguous :: id1 => null() !< provider reach number
35  integer(I4B), dimension(:), pointer, contiguous :: id2 => null() !< receiver reach number
36  integer(I4B), dimension(:), pointer, contiguous :: imvrtype => null() !< mover type (1, 2, 3, 4) corresponds to mvrtypes
37  real(dp), dimension(:), pointer, contiguous :: value => null() !< factor or rate depending on mvrtype
38  contains
39  procedure :: construct
40  procedure :: read_from_parser
41  procedure :: destroy
42  end type gwfmvrperioddatatype
43 
44 contains
45 
46  !> @ brief Construct arrays
47  !!
48  !! Allocate maximum space for mover input.
49  !!
50  !<
51  subroutine construct(this, maxsize, memoryPath)
52  ! -- modules
54  ! -- dummy
55  class(gwfmvrperioddatatype) :: this !< GwfMvrPeriodDataType
56  integer(I4B), intent(in) :: maxsize !< size of arrays
57  character(len=LENMEMPATH), intent(in) :: memoryPath !< memory manager path
58 
59  ! -- character arrays
60  allocate (this%mname1(maxsize))
61  allocate (this%pname1(maxsize))
62  allocate (this%mname2(maxsize))
63  allocate (this%pname2(maxsize))
64 
65  ! -- integer and real
66  call mem_allocate(this%id1, maxsize, 'ID1', memorypath)
67  call mem_allocate(this%id2, maxsize, 'ID2', memorypath)
68  call mem_allocate(this%imvrtype, maxsize, 'IMVRTYPE', memorypath)
69  call mem_allocate(this%value, maxsize, 'VALUE', memorypath)
70 
71  return
72  end subroutine construct
73 
74  !> @ brief Fill the arrays from parser
75  !!
76  !! Use the provided block parser to fill the input arrays.
77  !!
78  !<
79  subroutine read_from_parser(this, parser, nmvr, modelname)
80  ! -- dummy
81  class(gwfmvrperioddatatype) :: this !< GwfMvrPeriodDataType
82  type(blockparsertype), intent(inout) :: parser !< block parser
83  integer(I4B), intent(out) :: nmvr !< number of mover entries read
84  character(len=LENMODELNAME), intent(in) :: modelname !< name of model or empty string
85  ! -- local
86  integer(I4B) :: i
87  integer(I4B) :: maxmvr
88  logical :: endOfBlock
89  character(len=LINELENGTH) :: line
90  character(len=12) :: mvrtype_char
91  !
92  ! -- Initialize
93  i = 1
94  maxmvr = size(this%id1)
95  !
96  ! -- Read each mover entry
97  do
98  call parser%GetNextLine(endofblock)
99  if (endofblock) exit
100  !
101  ! -- Raise error if movers exceeds maxmvr
102  if (i > maxmvr) then
103  call parser%GetCurrentLine(line)
104  write (errmsg, '(a,a)') 'Movers exceed MAXMVR on line: ', &
105  trim(adjustl(line))
106  call store_error(errmsg)
107  call parser%StoreErrorUnit()
108  end if
109  !
110  ! -- modelname, package name, id for provider
111  if (modelname == '') then
112  call parser%GetStringCaps(this%mname1(i))
113  else
114  this%mname1(i) = modelname
115  end if
116  call parser%GetStringCaps(this%pname1(i))
117  this%id1(i) = parser%GetInteger()
118  !
119  ! -- modelname, package name, id for receiver
120  if (modelname == '') then
121  call parser%GetStringCaps(this%mname2(i))
122  else
123  this%mname2(i) = modelname
124  end if
125  call parser%GetStringCaps(this%pname2(i))
126  this%id2(i) = parser%GetInteger()
127  !
128  ! -- Mover type and value
129  call parser%GetStringCaps(mvrtype_char)
130  select case (mvrtype_char)
131  case ('FACTOR')
132  this%imvrtype(i) = 1
133  case ('EXCESS')
134  this%imvrtype(i) = 2
135  case ('THRESHOLD')
136  this%imvrtype(i) = 3
137  case ('UPTO')
138  this%imvrtype(i) = 4
139  case default
140  call store_error('Invalid mover type: '//trim(mvrtype_char))
141  call parser%StoreErrorUnit()
142  end select
143  this%value(i) = parser%GetDouble()
144  i = i + 1
145  end do
146  nmvr = i - 1
147  return
148  end subroutine read_from_parser
149 
150  !> @ brief Destroy memory
151  !!
152  !! Deallocate memory from the memory manager.
153  !!
154  !<
155  subroutine destroy(this)
156  ! -- modules
158  ! -- dummy
159  class(gwfmvrperioddatatype) :: this !< GwfMvrPeriodDataType
160 
161  ! -- character arrays
162  deallocate (this%mname1)
163  deallocate (this%pname1)
164  deallocate (this%mname2)
165  deallocate (this%pname2)
166 
167  ! -- integer and real
168  call mem_deallocate(this%id1)
169  call mem_deallocate(this%id2)
170  call mem_deallocate(this%imvrtype)
171  call mem_deallocate(this%value)
172 
173  return
174  end subroutine destroy
175 
176 end module gwfmvrperioddatamodule
177 
This module contains block parser methods.
Definition: BlockParser.f90:7
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition: Constants.f90:21
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition: Constants.f90:22
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
This module contains the GwfMvrPeriodDataModule Module.
subroutine destroy(this)
@ brief Destroy memory
subroutine read_from_parser(this, parser, nmvr, modelname)
@ brief Fill the arrays from parser
subroutine construct(this, maxsize, memoryPath)
@ brief Construct arrays
This module defines variable data types.
Definition: kind.f90:8
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
Derived type for GwfMvrPeriodDataType.