MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
ConvergenceSummary.f90
Go to the documentation of this file.
2  use kindmodule, only: i4b, dp
5 
6  implicit none
7  private
8 
9  public :: convergencesummarytype
10 
11  !> This structure stores the generic convergence info for a solution
12  !<
14  character(len=LENMEMPATH) :: memory_path !< the path for storing solution variables in the memory manager
15  integer(I4B) :: iter_cnt !< tracks the iteration number within the timestep
16  integer(I4B), pointer :: convnmod => null() !< number of models in the solution
17  integer(I4B), dimension(:), pointer :: model_bounds => null() !< the start and stop index of the models in the solution
18  integer(I4B), pointer :: nitermax => null() !< max. nr. of iterations in a timestep
19  integer(I4B), dimension(:), pointer, contiguous :: itinner => null() !< inner iteration number within each picard iteration
20  integer(I4B), dimension(:), pointer, contiguous :: locdv => null() !< location of the maximum dependent-variable change in the solution
21  real(dp), dimension(:), pointer, contiguous :: dvmax => null() !< maximum dependent-variable change in the solution
22  integer(I4B), dimension(:), pointer, contiguous :: locr => null() !< location of the maximum flow change in the solution
23  real(dp), dimension(:), pointer, contiguous :: rmax => null() !< maximum flow change in the solution
24  integer(I4B), pointer, dimension(:, :), contiguous :: convlocdv => null() !< location of the maximum dependent-variable change in each model in the solution
25  real(dp), pointer, dimension(:, :), contiguous :: convdvmax => null() !< maximum dependent-variable change for each model in the solution
26  integer(I4B), pointer, dimension(:, :), contiguous :: convlocr => null() !< location of the maximum flow change in each model in the solution
27  real(dp), pointer, dimension(:, :), contiguous :: convrmax => null() !< maximum flow change in each model in the solution
28  contains
29  procedure :: init
30  procedure :: reinit
31  procedure :: destroy
32  ! private
33  procedure, private :: set_defaults
34  end type convergencesummarytype
35 
36 contains
37 
38  !> @brief Initialize the convergence summary for a solution
39  subroutine init(this, nr_models, model_bounds, mem_path)
40  class(convergencesummarytype) :: this
41  integer(I4B) :: nr_models !< the number of models in the solution
42  integer(I4B), dimension(:), pointer :: model_bounds !< the start and stop index of the models
43  character(len=*) :: mem_path !< the memory path of the owning solution
44 
45  this%memory_path = 'TMP'//mem_path
46  this%iter_cnt = 0
47  this%model_bounds => model_bounds
48 
49  call mem_allocate(this%convnmod, 'CONVNMOD', this%memory_path)
50  call mem_allocate(this%nitermax, 'NITERMAX', this%memory_path)
51  this%convnmod = nr_models
52  this%nitermax = 0
53 
54  call mem_allocate(this%itinner, 0, 'ITINNER', this%memory_path)
55  call mem_allocate(this%locdv, this%convnmod, 'LOCDV', this%memory_path)
56  call mem_allocate(this%dvmax, this%convnmod, 'DVMAX', this%memory_path)
57  call mem_allocate(this%locr, this%convnmod, 'LOCDR', this%memory_path)
58  call mem_allocate(this%rmax, this%convnmod, 'DRMAX', this%memory_path)
59  call mem_allocate(this%convdvmax, this%convnmod, 0, 'CONVDVMAX', &
60  this%memory_path)
61  call mem_allocate(this%convlocdv, this%convnmod, 0, 'CONVLOCDV', &
62  this%memory_path)
63  call mem_allocate(this%convrmax, this%convnmod, 0, 'CONVDRMAX', &
64  this%memory_path)
65  call mem_allocate(this%convlocr, this%convnmod, 0, 'CONVLOCDR', &
66  this%memory_path)
67 
68  call this%set_defaults()
69 
70  end subroutine init
71 
72  subroutine reinit(this, niter_max)
73  class(convergencesummarytype) :: this
74  integer(I4B) :: niter_max !< max. nr. of iterations in a timestep
75 
76  this%nitermax = niter_max
77  call mem_reallocate(this%itinner, niter_max, 'ITINNER', this%memory_path)
78  call mem_reallocate(this%convdvmax, this%convnmod, niter_max, 'CONVDVMAX', &
79  this%memory_path)
80  call mem_reallocate(this%convlocdv, this%convnmod, niter_max, 'CONVLOCDV', &
81  this%memory_path)
82  call mem_reallocate(this%convrmax, this%convnmod, niter_max, 'CONVDRMAX', &
83  this%memory_path)
84  call mem_reallocate(this%convlocr, this%convnmod, niter_max, 'CONVLOCDR', &
85  this%memory_path)
86 
87  call this%set_defaults()
88 
89  end subroutine reinit
90 
91  subroutine set_defaults(this)
92  class(convergencesummarytype) :: this
93  ! local
94  integer(I4B) :: i, j
95 
96  do i = 1, this%convnmod
97  this%locr(i) = 0
98  this%dvmax(i) = dzero
99  this%locdv(i) = 0
100  this%rmax(i) = dzero
101  end do
102 
103  do i = 1, this%nitermax
104  this%itinner(i) = 0
105  do j = 1, this%convnmod
106  this%convdvmax(j, i) = dzero
107  this%convlocdv(j, i) = 0
108  this%convrmax(j, i) = dzero
109  this%convlocr(j, i) = 0
110  end do
111  end do
112 
113  end subroutine set_defaults
114 
115  !> @brief Cleanup
116  !<
117  subroutine destroy(this)
118  class(convergencesummarytype) :: this
119 
120  ! scalars
121  call mem_deallocate(this%convnmod)
122  call mem_deallocate(this%nitermax)
123 
124  call mem_deallocate(this%locr)
125  call mem_deallocate(this%rmax)
126  call mem_deallocate(this%locdv)
127  call mem_deallocate(this%dvmax)
128 
129  ! arrays
130  call mem_deallocate(this%itinner)
131  call mem_deallocate(this%convdvmax)
132  call mem_deallocate(this%convlocdv)
133  call mem_deallocate(this%convrmax)
134  call mem_deallocate(this%convlocr)
135 
136  end subroutine destroy
137 
138 end module convergencesummarymodule
subroutine init()
Definition: GridSorting.f90:24
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
subroutine reinit(this, niter_max)
subroutine destroy(this)
Cleanup.
This module defines variable data types.
Definition: kind.f90:8
This structure stores the generic convergence info for a solution.