MONC
pstep.F90
Go to the documentation of this file.
1 
5 module pstep_mod
8  use grids_mod, only : z_index
12  implicit none
13 
14 #ifndef TEST_MODE
15  private
16 #endif
17 
19 
20 contains
21 
25  pstep_get_descriptor%name="pstep"
26  pstep_get_descriptor%version=0.1
29  end function pstep_get_descriptor
30 
33  subroutine initialisation_callback(current_state)
34  type(model_state_type), target, intent(inout) :: current_state
35 
36  if (.not. is_component_enabled(current_state%options_database, "diverr")) then
37  call log_master_log(log_error, "The pstep component requires the diverr component to be enabled")
38  end if
39  end subroutine initialisation_callback
40 
43  subroutine timestep_callback(current_state)
44  type(model_state_type), target, intent(inout) :: current_state
45 
46  if (current_state%galilean_transformation) call perform_galilean_transformation(current_state, &
47  current_state%column_local_y, current_state%column_local_x)
48  if (.not. current_state%halo_column) call step_pressure_field(current_state)
49  end subroutine timestep_callback
50 
53  subroutine step_pressure_field(current_state)
54  type(model_state_type), target, intent(inout) :: current_state
55 
56  integer :: k, x_index, y_index
57  real(kind=DEFAULT_PRECISION) :: dtmtmp
58 
59  x_index=current_state%column_local_x
60  y_index=current_state%column_local_y
61 
62  dtmtmp=merge(current_state%dtm, 0.5_default_precision*current_state%dtm, current_state%field_stepping == centred_stepping)
63  do k=2,current_state%local_grid%size(z_index)
64 
65 #ifdef U_ACTIVE
66  current_state%zu%data(k, y_index, x_index)= current_state%zu%data(k, y_index, x_index)+ 2.0_default_precision*&
67  current_state%global_grid%configuration%horizontal%cx*dtmtmp*(current_state%p%data(k, y_index, x_index)-&
68  current_state%p%data(k, y_index, x_index+1))
69 #endif
70 #ifdef V_ACTIVE
71  current_state%zv%data(k, y_index, x_index)=&
72  current_state%zv%data(k, y_index, x_index)+2.0_default_precision*&
73  current_state%global_grid%configuration%horizontal%cy*dtmtmp*&
74  (current_state%p%data(k, y_index, x_index) - current_state%p%data(k, y_index+1, x_index))
75 #endif
76 #ifdef W_ACTIVE
77  if (k .lt. current_state%local_grid%size(z_index)) then
78  current_state%zw%data(k, y_index, x_index)=current_state%zw%data(k, y_index, x_index)+2.0_default_precision*&
79  current_state%global_grid%configuration%vertical%rdzn(k+1)*dtmtmp*(current_state%p%data(k, y_index, x_index)-&
80  current_state%p%data(k+1, y_index, x_index))
81  end if
82 #endif
83  end do
84  if (current_state%use_viscosity_and_diffusion .and. current_state%use_surface_boundary_conditions) then
85 #ifdef U_ACTIVE
86  current_state%zu%data(1, y_index, x_index)=-current_state%zu%data(2, y_index, x_index)-&
87  2.0_default_precision*current_state%ugal
88 #endif
89 #ifdef V_ACTIVE
90  current_state%zv%data(1, y_index, x_index)=-current_state%zv%data(2, y_index, x_index)-&
91  2.0_default_precision*current_state%vgal
92 #endif
93  else
94 #ifdef U_ACTIVE
95  current_state%zu%data(1, y_index, x_index)=current_state%zu%data(2, y_index, x_index)
96 #endif
97 #ifdef V_ACTIVE
98  current_state%zv%data(1, y_index, x_index)=current_state%zv%data(2, y_index, x_index)
99 #endif
100  end if
101  end subroutine step_pressure_field
102 
107  subroutine perform_galilean_transformation(current_state, y_index, x_index)
108  type(model_state_type), target, intent(inout) :: current_state
109  integer, intent(in) :: y_index, x_index
110 
111  integer :: k
112 
113  do k=1,current_state%local_grid%size(z_index)
114 #ifdef U_ACTIVE
115  current_state%u%data(k, y_index, x_index)= current_state%u%data(k, y_index, x_index)-current_state%ugal
116  current_state%zu%data(k, y_index, x_index)= current_state%zu%data(k, y_index, x_index)-current_state%ugal
117 #endif
118 #ifdef V_ACTIVE
119  current_state%v%data(k, y_index, x_index)= current_state%v%data(k, y_index, x_index)-current_state%vgal
120  current_state%zv%data(k, y_index, x_index)= current_state%zv%data(k, y_index, x_index)-current_state%vgal
121 #endif
122  end do
123  end subroutine perform_galilean_transformation
124 end module pstep_mod
subroutine step_pressure_field(current_state)
Does the actual stepping of the pressure field.
Definition: pstep.F90:54
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
subroutine timestep_callback(current_state)
Called each timestep, this will step the pressure field for the non halo columns. ...
Definition: pstep.F90:44
subroutine perform_galilean_transformation(current_state, y_index, x_index)
Performs Galilean transformation of flow current and z fields.
Definition: pstep.F90:108
Logging utility.
Definition: logging.F90:2
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17
integer, parameter, public z_index
Grid index parameters.
Definition: grids.F90:14
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
The ModelState which represents the current state of a run.
Definition: state.F90:39
integer, parameter, public centred_stepping
Stepping parameter values which determine centred or forward stepping.
Definition: state.F90:15
logical function, public is_component_enabled(options_database, component_name)
Determines whether or not a specific component is registered and enabled.
Definition: registry.F90:334
subroutine, public log_master_log(level, message)
Will log just from the master process.
Definition: logging.F90:47
Interfaces and types that MONC components must specify.
Stepping of the pressure field. Completes the time-stepping of the velocity fields by adding the pres...
Definition: pstep.F90:5
subroutine initialisation_callback(current_state)
Initialisation callback hook which will check the diverr component is enabled (as this allocates p) ...
Definition: pstep.F90:34
Functionality to support the different types of grid and abstraction between global grids and local o...
Definition: grids.F90:5
The model state which represents the current state of a run.
Definition: state.F90:2
type(component_descriptor_type) function, public pstep_get_descriptor()
Descriptor of this component for registration.
Definition: pstep.F90:25
MONC component registry.
Definition: registry.F90:5