MONC
Functions/Subroutines
diverr_mod Module Reference

Calculates the local divergence error. More...

Functions/Subroutines

type(component_descriptor_type) function, public diverr_get_descriptor ()
 Descriptor of this component for registration. More...
 
subroutine init_callback (current_state)
 The initialisation callback will allocate memory for the P field and initialise it. More...
 
subroutine timestep_callback (current_state)
 Called each timestep this will initialise P and update the local divergence error for the current column. More...
 
subroutine finalisation_callback (current_state)
 Called at finalisation this will deallocate the P field as the model shuts down. More...
 
subroutine find_max_divergence_error (current_state)
 Finds the maximum divergence error locally and writes this into the local variable. More...
 
subroutine handle_forward_stepping (current_state)
 Handles the calculation of P when the model is forward stepping. More...
 
subroutine handle_centred_stepping (current_state)
 Handles the calculation of P when the model is centred stepping. More...
 
subroutine calculate_p (current_state, p, u, v, w, timec, y_local, x_local)
 Calculates P based upon flow fields and the stepping. More...
 

Detailed Description

Calculates the local divergence error.

Function/Subroutine Documentation

◆ calculate_p()

subroutine diverr_mod::calculate_p ( type(model_state_type), intent(inout), target  current_state,
type(prognostic_field_type), intent(inout)  p,
type(prognostic_field_type), intent(inout)  u,
type(prognostic_field_type), intent(inout)  v,
type(prognostic_field_type), intent(inout)  w,
real(kind=default_precision), intent(in)  timec,
integer, intent(in)  y_local,
integer, intent(in)  x_local 
)
private

Calculates P based upon flow fields and the stepping.

Parameters
current_stateThe current model state
pThe P field to update
uThe U flow field
vThe V flow field
wThe W flow field
timecBased upon model dtm this depends on the stepping selected
y_localLocal Y dimension index
x_localLocal X dimension index

Definition at line 120 of file diverr.F90.

121  type(model_state_type), target, intent(inout) :: current_state
122  type(prognostic_field_type), intent(inout) :: u, v, w, p
123  real(kind=default_precision), intent(in) :: timec
124  integer, intent(in) :: y_local, x_local
125 
126  integer :: k
127 
128  p%data(:, y_local, x_local)=0.0_default_precision
129  do k=2,current_state%local_grid%size(z_index)
130 #ifdef U_ACTIVE
131  p%data(k, y_local, x_local)= p%data(k, y_local, x_local)+ &
132  current_state%global_grid%configuration%horizontal%cx*(u%data(k, y_local, x_local)-u%data(k, y_local, x_local-1))
133 #endif
134 #ifdef V_ACTIVE
135  p%data(k, y_local, x_local)= p%data(k, y_local, x_local)+ &
136  current_state%global_grid%configuration%horizontal%cy*(v%data(k, y_local, x_local)-v%data(k, y_local-1, x_local))
137 #endif
138 #ifdef W_ACTIVE
139  p%data(k, y_local, x_local)= p%data(k, y_local, x_local)+ &
140  4.0_default_precision*(current_state%global_grid%configuration%vertical%tzc2(k)*w%data(k, y_local, x_local)-&
141  current_state%global_grid%configuration%vertical%tzc1(k)* w%data(k-1, y_local, x_local))
142 #endif
143  p%data(k, y_local, x_local)=p%data(k, y_local, x_local) * timec
144  end do
Here is the caller graph for this function:

◆ diverr_get_descriptor()

type(component_descriptor_type) function, public diverr_mod::diverr_get_descriptor

Descriptor of this component for registration.

Returns
The diverr component descriptor

Definition at line 19 of file diverr.F90.

20  diverr_get_descriptor%name="diverr"
21  diverr_get_descriptor%version=0.1
22  diverr_get_descriptor%initialisation=>init_callback
23  diverr_get_descriptor%timestep=>timestep_callback
24  diverr_get_descriptor%finalisation=>finalisation_callback
Here is the call graph for this function:

◆ finalisation_callback()

subroutine diverr_mod::finalisation_callback ( type(model_state_type), intent(inout), target  current_state)
private

Called at finalisation this will deallocate the P field as the model shuts down.

Parameters
current_stateThe current model state

Definition at line 61 of file diverr.F90.

62  type(model_state_type), target, intent(inout) :: current_state
63 
64  current_state%p%active=.false.
65  deallocate(current_state%p%data)
Here is the caller graph for this function:

◆ find_max_divergence_error()

subroutine diverr_mod::find_max_divergence_error ( type(model_state_type), intent(inout), target  current_state)
private

Finds the maximum divergence error locally and writes this into the local variable.

Parameters
current_stateThe current model state

Definition at line 70 of file diverr.F90.

71  type(model_state_type), target, intent(inout) :: current_state
72 
73  integer :: k
74 
75  if (current_state%first_timestep_column) current_state%local_divmax=0.0_default_precision
76 
77  do k=2,current_state%local_grid%size(z_index)
78  if (abs(current_state%p%data(k, current_state%column_local_y, current_state%column_local_x)) .gt. &
79  current_state%local_divmax) then
80  current_state%local_divmax=abs(current_state%p%data(k,current_state%column_local_y, current_state%column_local_x))
81  end if
82  end do
Here is the caller graph for this function:

◆ handle_centred_stepping()

subroutine diverr_mod::handle_centred_stepping ( type(model_state_type), intent(inout), target  current_state)
private

Handles the calculation of P when the model is centred stepping.

Parameters
current_stateThe current model state

Definition at line 100 of file diverr.F90.

101  type(model_state_type), target, intent(inout) :: current_state
102 
103  real(kind=default_precision) :: timec
104 
105  timec=1.0_default_precision/(2.0_default_precision*current_state%dtm)
106 
107  call calculate_p(current_state, current_state%p, current_state%zu, current_state%zv, current_state%zw, timec, &
108  current_state%column_local_y, current_state%column_local_x)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_forward_stepping()

subroutine diverr_mod::handle_forward_stepping ( type(model_state_type), intent(inout), target  current_state)
private

Handles the calculation of P when the model is forward stepping.

Parameters
current_stateThe current model state

Definition at line 87 of file diverr.F90.

88  type(model_state_type), target, intent(inout) :: current_state
89 
90  real(kind=default_precision) :: timec
91 
92  timec=1.0_default_precision/current_state%dtm
93 
94  call calculate_p(current_state, current_state%p, current_state%u, current_state%v, current_state%w, timec, &
95  current_state%column_local_y, current_state%column_local_x)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_callback()

subroutine diverr_mod::init_callback ( type(model_state_type), intent(inout), target  current_state)
private

The initialisation callback will allocate memory for the P field and initialise it.

Parameters
current_stateThe current model state

Definition at line 29 of file diverr.F90.

30  type(model_state_type), target, intent(inout) :: current_state
31 
32  if (.not. allocated(current_state%p%data)) then
33  ! If we are loading from a checkpoint file then this is already present
34  allocate(current_state%p%data(current_state%local_grid%size(z_index) + current_state%local_grid%halo_size(z_index) * 2, &
35  current_state%local_grid%size(y_index) + current_state%local_grid%halo_size(y_index) * 2, &
36  current_state%local_grid%size(x_index) + current_state%local_grid%halo_size(x_index) * 2))
37  current_state%p%data=0.0_default_precision
38  current_state%p%active=.true.
39  end if
Here is the caller graph for this function:

◆ timestep_callback()

subroutine diverr_mod::timestep_callback ( type(model_state_type), intent(inout), target  current_state)
private

Called each timestep this will initialise P and update the local divergence error for the current column.

Parameters
current_stateThe current model state

Definition at line 44 of file diverr.F90.

45  type(model_state_type), target, intent(inout) :: current_state
46 
47  current_state%p%data(:, current_state%column_local_y, current_state%column_local_x) = 0.0_default_precision
48 
49  if (current_state%halo_column) return
50 
51  if (current_state%field_stepping == forward_stepping) then
52  call handle_forward_stepping(current_state)
53  else
54  call handle_centred_stepping(current_state)
55  end if
56  call find_max_divergence_error(current_state)
Here is the call graph for this function:
Here is the caller graph for this function:
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17