MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
DistributedVariable.f90
Go to the documentation of this file.
3  use kindmodule, only: i4b
4  use listmodule, only: listtype
6 
7  implicit none
8  private
9 
10  public :: getdistvarfromlist
11 
12  ! types of variables
13  integer(I4B), public, parameter :: sync_scl = 0 !< synchronize as scalar
14  integer(I4B), public, parameter :: sync_nds = 1 !< synchronize over nodes
15  integer(I4B), public, parameter :: sync_con = 2 !< synchronize over connections
16  integer(I4B), public, parameter :: sync_exg = 3 !< synchronize as exchange variable
17 
18  type, public :: distvartype
19  character(len=LENVARNAME) :: var_name !< name of variable, e.g. "K11"
20  character(len=LENCOMPONENTNAME) :: subcomp_name !< subcomponent, e.g. "NPF"
21  character(len=LENCOMPONENTNAME) :: comp_name !< component, e.g. the model or exchange name
22  integer(I4B) :: map_type !< can be 0 = scalar, 1 = node based, 2 = connection based,
23  !! 3 = exchange based (connections crossing model boundaries)
24  character(len=LENVARNAME) :: exg_var_name !< needed for exchange variables, e.g. SIMVALS
25  integer(I4B), dimension(:), allocatable :: sync_stages !< when to sync, e.g. (/ BEFORE_AD, BEFORE_CF /)
26  end type distvartype
27 
28 contains
29 
30  function getdistvarfromlist(list, idx) result(res)
31  implicit none
32  type(listtype), intent(inout) :: list
33  integer(I4B), intent(in) :: idx
34  class(distvartype), pointer :: res
35  ! local
36  class(*), pointer :: obj
37 
38  obj => list%GetItem(idx)
39  res => castasdistvar(obj)
40  end function getdistvarfromlist
41 
42  function castasdistvar(obj) result(res)
43  implicit none
44  class(*), pointer, intent(inout) :: obj
45  class(distvartype), pointer :: res
46 
47  res => null()
48  if (.not. associated(obj)) return
49 
50  select type (obj)
51  class is (distvartype)
52  res => obj
53  end select
54  end function castasdistvar
55 
56 end module distvariablemodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lencomponentname
maximum length of a component name
Definition: Constants.f90:18
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
integer(i4b), parameter, public sync_scl
synchronize as scalar
class(distvartype) function, pointer, public getdistvarfromlist(list, idx)
integer(i4b), parameter, public sync_nds
synchronize over nodes
integer(i4b), parameter, public sync_exg
synchronize as exchange variable
integer(i4b), parameter, public sync_con
synchronize over connections
class(distvartype) function, pointer castasdistvar(obj)
This module defines variable data types.
Definition: kind.f90:8
A generic heterogeneous doubly-linked list.
Definition: List.f90:14