MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
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 !> @return the global vector size
45 function get_size_if(this) result(size)
46 import vectorbasetype, i4b
47 class(vectorbasetype) :: this !< this vector
48 integer(I4B) :: size
49 end function
50 !> @return the value at the index
51 function get_value_local_if(this, idx) result(val)
52 import vectorbasetype, i4b, dp
53 class(vectorbasetype) :: this !< this vector
54 integer(I4B) :: idx !< index in local numbering
55 real(dp) :: val
56 end function
57 subroutine zero_entries_if(this)
58 import vectorbasetype
59 class(vectorbasetype) :: this
60 end subroutine
61 subroutine set_value_local_if(this, idx, val)
62 import vectorbasetype, i4b, dp
63 class(vectorbasetype) :: this !< this vector
64 integer(I4B) :: idx !< index in local numbering
65 real(DP) :: val !< the value to set
66 end subroutine
67 subroutine axpy_if(this, alpha, vec_x)
68 import vectorbasetype, dp
69 class(vectorbasetype) :: this !< this vector y => alpha*x + y
70 real(DP) :: alpha !< the factor
71 class(vectorbasetype), pointer :: vec_x !< the vector to add
72 end subroutine
73 !> @return the calculated 2-norm
74 function norm2_if(this) result(n2)
75 import vectorbasetype, dp
76 class(vectorbasetype) :: this !< this vector
77 real(dp) :: n2
78 end function
79 subroutine print_if(this)
80 import vectorbasetype
81 class(vectorbasetype) :: this
82 end subroutine print_if
83 end interface
84
85end module vectorbasemodule
This module defines variable data types.
Definition kind.f90:8