MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
VectorBase.f90
Go to the documentation of this file.
2  use kindmodule, only: i4b, dp, lgp
3  implicit none
4  private
5 
6  type, public, abstract :: vectorbasetype
7  logical(LGP) :: is_mem_managed
8  contains
9  procedure(create_mm_if), deferred :: create_mm
10  procedure(destroy_if), deferred :: destroy
11  procedure(get_array_if), deferred :: get_array
12  procedure(get_ownership_range_if), deferred :: get_ownership_range
13  procedure(get_size_if), deferred :: get_size
14  procedure(get_value_local_if), deferred :: get_value_local
15  procedure(zero_entries_if), deferred :: zero_entries
16  procedure(set_value_local_if), deferred :: set_value_local
17  procedure(axpy_if), deferred :: axpy
18  procedure(norm2_if), deferred :: norm2
19  procedure(print_if), deferred :: print
20  end type vectorbasetype
21 
22  abstract interface
23  subroutine create_mm_if(this, n, name, mem_path)
24  import vectorbasetype, i4b
25  class(vectorbasetype) :: this !< this vector
26  integer(I4B) :: n !< the nr. of elements in the (local) vector
27  character(len=*) :: name !< the variable name (for access through memory manager)
28  character(len=*) :: mem_path !< memory path for storing the underlying memory items
29  end subroutine create_mm_if
30  subroutine destroy_if(this)
31  import vectorbasetype
32  class(vectorbasetype) :: this !< this vector
33  end subroutine destroy_if
34  function get_array_if(this) result(array)
35  import vectorbasetype, dp
36  class(vectorbasetype) :: this !< this vector
37  real(dp), dimension(:), pointer, contiguous :: array
38  end function get_array_if
39  subroutine get_ownership_range_if(this, start, end)
40  import vectorbasetype, i4b
41  class(vectorbasetype) :: this !< this vector
42  integer(I4B) :: start, end !< local range in global numbering
43  end subroutine
44  function get_size_if(this) result(size)
45  import vectorbasetype, i4b
46  class(vectorbasetype) :: this !< this vector
47  integer(I4B) :: size !< the global vector size
48  end function
49  function get_value_local_if(this, idx) result(val)
50  import vectorbasetype, i4b, dp
51  class(vectorbasetype) :: this !< this vector
52  integer(I4B) :: idx !< index in local numbering
53  real(dp) :: val !< the value at the index
54  end function
55  subroutine zero_entries_if(this)
56  import vectorbasetype
57  class(vectorbasetype) :: this
58  end subroutine
59  subroutine set_value_local_if(this, idx, val)
60  import vectorbasetype, i4b, dp
61  class(vectorbasetype) :: this !< this vector
62  integer(I4B) :: idx !< index in local numbering
63  real(DP) :: val !< the value to set
64  end subroutine
65  subroutine axpy_if(this, alpha, vec_x)
66  import vectorbasetype, dp
67  class(vectorbasetype) :: this !< this vector y => alpha*x + y
68  real(DP) :: alpha !< the factor
69  class(vectorbasetype), pointer :: vec_x !< the vector to add
70  end subroutine
71  function norm2_if(this) result(n2)
72  import vectorbasetype, dp
73  class(vectorbasetype) :: this !< this vector
74  real(dp) :: n2 !< the calculated 2-norm
75  end function
76  subroutine print_if(this)
77  import vectorbasetype
78  class(vectorbasetype) :: this
79  end subroutine print_if
80  end interface
81 
82 end module vectorbasemodule
This module defines variable data types.
Definition: kind.f90:8