MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
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  end subroutine construct
71 
72  !> @ brief Fill the arrays from parser
73  !!
74  !! Use the provided block parser to fill the input arrays.
75  !!
76  !<
77  subroutine read_from_parser(this, parser, nmvr, modelname)
78  ! -- dummy
79  class(gwfmvrperioddatatype) :: this !< GwfMvrPeriodDataType
80  type(blockparsertype), intent(inout) :: parser !< block parser
81  integer(I4B), intent(out) :: nmvr !< number of mover entries read
82  character(len=LENMODELNAME), intent(in) :: modelname !< name of model or empty string
83  ! -- local
84  integer(I4B) :: i
85  integer(I4B) :: maxmvr
86  logical :: endOfBlock
87  character(len=LINELENGTH) :: line
88  character(len=12) :: mvrtype_char
89  !
90  ! -- Initialize
91  i = 1
92  maxmvr = size(this%id1)
93  !
94  ! -- Read each mover entry
95  do
96  call parser%GetNextLine(endofblock)
97  if (endofblock) exit
98  !
99  ! -- Raise error if movers exceeds maxmvr
100  if (i > maxmvr) then
101  call parser%GetCurrentLine(line)
102  write (errmsg, '(a,a)') 'Movers exceed MAXMVR on line: ', &
103  trim(adjustl(line))
104  call store_error(errmsg)
105  call parser%StoreErrorUnit()
106  end if
107  !
108  ! -- modelname, package name, id for provider
109  if (modelname == '') then
110  call parser%GetStringCaps(this%mname1(i))
111  else
112  this%mname1(i) = modelname
113  end if
114  call parser%GetStringCaps(this%pname1(i))
115  this%id1(i) = parser%GetInteger()
116  !
117  ! -- modelname, package name, id for receiver
118  if (modelname == '') then
119  call parser%GetStringCaps(this%mname2(i))
120  else
121  this%mname2(i) = modelname
122  end if
123  call parser%GetStringCaps(this%pname2(i))
124  this%id2(i) = parser%GetInteger()
125  !
126  ! -- Mover type and value
127  call parser%GetStringCaps(mvrtype_char)
128  select case (mvrtype_char)
129  case ('FACTOR')
130  this%imvrtype(i) = 1
131  case ('EXCESS')
132  this%imvrtype(i) = 2
133  case ('THRESHOLD')
134  this%imvrtype(i) = 3
135  case ('UPTO')
136  this%imvrtype(i) = 4
137  case default
138  call store_error('Invalid mover type: '//trim(mvrtype_char))
139  call parser%StoreErrorUnit()
140  end select
141  this%value(i) = parser%GetDouble()
142  i = i + 1
143  end do
144  nmvr = i - 1
145  end subroutine read_from_parser
146 
147  !> @ brief Destroy memory
148  !!
149  !! Deallocate memory from the memory manager.
150  !!
151  !<
152  subroutine destroy(this)
153  ! -- modules
155  ! -- dummy
156  class(gwfmvrperioddatatype) :: this !< GwfMvrPeriodDataType
157 
158  ! -- character arrays
159  deallocate (this%mname1)
160  deallocate (this%pname1)
161  deallocate (this%mname2)
162  deallocate (this%pname2)
163 
164  ! -- integer and real
165  call mem_deallocate(this%id1)
166  call mem_deallocate(this%id2)
167  call mem_deallocate(this%imvrtype)
168  call mem_deallocate(this%value)
169  end subroutine destroy
170 
171 end module gwfmvrperioddatamodule
172 
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:45
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition: Constants.f90:22
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition: Constants.f90:23
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:27
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.