MONC
Data Types | Functions/Subroutines | Variables
q_indices_mod Module Reference

This manages the Q variables and specifically the mapping between names and the index that they are stored at. More...

Data Types

type  q_metadata_type
 
type  standard_q_names_type
 

Functions/Subroutines

subroutine, public set_q_index (index, name)
 Sets a Q index to be active at a specific index and sets the name. More...
 
integer function, public get_max_number_q_indices ()
 Gets the maximum number of Q indicies. More...
 
integer function, public get_number_active_q_indices ()
 Gets the number of active Q indicies (i.e. those allocated to specific uses) More...
 
type(q_metadata_type) function, public get_indices_descriptor (i)
 Retrieves the indicies descriptor at a specific location. More...
 
integer function, public get_q_index (name, assigning_component)
 Add in a new entry into the register if the name does not already exist or return the index of the pre-existing variable. More...
 

Variables

integer, parameter n_maxqs =100
 Maximum number of Q variables to manage. More...
 
integer, parameter n_maxqname =100
 Length to allocate for a Q variable name. More...
 
type(q_metadata_type), dimension(n_maxqsq_register
 
type(standard_q_names_type), public standard_q_names
 

Detailed Description

This manages the Q variables and specifically the mapping between names and the index that they are stored at.

Function/Subroutine Documentation

◆ get_indices_descriptor()

type(q_metadata_type) function, public q_indices_mod::get_indices_descriptor ( integer  i)

Retrieves the indicies descriptor at a specific location.

Parameters
iThe index to retrieve the descriptor at
Returns
The corresponding descriptor

Definition at line 99 of file q_indices.F90.

100  integer :: i
101  type(q_metadata_type) :: get_indices_descriptor
102 
103  get_indices_descriptor=q_register(i)
Here is the caller graph for this function:

◆ get_max_number_q_indices()

integer function, public q_indices_mod::get_max_number_q_indices

Gets the maximum number of Q indicies.

Returns
The maximum number of Q indicies

Definition at line 80 of file q_indices.F90.

81  get_max_number_q_indices=n_maxqs
Here is the caller graph for this function:

◆ get_number_active_q_indices()

integer function, public q_indices_mod::get_number_active_q_indices

Gets the number of active Q indicies (i.e. those allocated to specific uses)

Returns
The number of active Q indicies

Definition at line 86 of file q_indices.F90.

87 
88  integer :: i
89 
90  get_number_active_q_indices=0
91  do i=1, n_maxqs
92  if (q_register(i)%l_used) get_number_active_q_indices=get_number_active_q_indices+1
93  end do
Here is the caller graph for this function:

◆ get_q_index()

integer function, public q_indices_mod::get_q_index ( character(*), intent(in)  name,
character(*), optional  assigning_component 
)

Add in a new entry into the register if the name does not already exist or return the index of the pre-existing variable.

Parameters
namevariable name
assigning_componentname of component which is assigning this variable
Returns
The variable index

Definition at line 111 of file q_indices.F90.

112  character(*), intent(in) :: name
113  character(*), optional :: assigning_component
114 
115  integer :: iname, i_unused
116 
117  i_unused=0
118 
119  do iname=n_maxqs, 1, -1
120  if (trim(name) == trim(q_register(iname)%name)) then
121  ! Here we find the variable has already been added
122  get_q_index=iname
123  return
124  end if
125  ! Counting backwards we will eventually find the first open slot
126  if (.not. q_register(iname)%l_used) then
127  i_unused=iname
128  end if
129  end do
130 
131  if (i_unused == 0) then
132  call log_master_log(log_error, 'Somehow we need to extend q_register')
133  end if
134 
135  ! Not already defined, so populate the empty slot
136  get_q_index=i_unused
137  q_register(get_q_index)%name = adjustr(trim(name))
138  q_register(get_q_index)%l_used = .true.
139 
140  if (present(assigning_component)) then
141  call log_master_log(log_info, 'q variable #'//trim(conv_to_string(get_q_index))//' is assigned to '//trim(name)//&
142  '. Assigned from component: '//trim(assigning_component))
143  else
144  call log_master_log(log_info, 'q variable #'//trim(conv_to_string(get_q_index))//' is assigned to '//trim(name))
145  end if
146 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_q_index()

subroutine, public q_indices_mod::set_q_index ( integer, intent(in)  index,
character(len=*), intent(in)  name 
)

Sets a Q index to be active at a specific index and sets the name.

Parameters
indexThe index to set the Q index at
nameThe name to set as the Q index name

Definition at line 70 of file q_indices.F90.

71  integer, intent(in) :: index
72  character(len=*), intent(in) :: name
73 
74  q_register(index)%name=adjustr(trim(name))
75  q_register(index)%l_used=.true.
Here is the caller graph for this function:

Variable Documentation

◆ n_maxqname

integer, parameter q_indices_mod::n_maxqname =100
private

Length to allocate for a Q variable name.

Internal storage type for tracking the Q variable states

Definition at line 12 of file q_indices.F90.

12  integer, parameter :: n_maxqname=100

◆ n_maxqs

integer, parameter q_indices_mod::n_maxqs =100
private

Maximum number of Q variables to manage.

Definition at line 11 of file q_indices.F90.

11  integer, parameter :: n_maxqs=100

◆ q_register

type(q_metadata_type), dimension(n_maxqs) q_indices_mod::q_register
private

Definition at line 21 of file q_indices.F90.

21  type(q_metadata_type) :: q_register(n_maxqs)

◆ standard_q_names

type(standard_q_names_type), public q_indices_mod::standard_q_names

Definition at line 59 of file q_indices.F90.

59  type(standard_q_names_type) :: standard_q_names
logging_mod::log_error
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
logging_mod::log_info
integer, parameter, public log_info
Log INFO, WARNING and ERROR messages.
Definition: logging.F90:13
logging_mod::log_master_log
subroutine, public log_master_log(level, message)
Will log just from the master process.
Definition: logging.F90:47