MONC
thadvection.F90
Go to the documentation of this file.
1 
5  use state_mod, only : model_state_type
6  use grids_mod, only : z_index
7  use science_constants_mod, only : g
10 implicit none
11 
12 #ifndef TEST_MODE
13  private
14 #endif
15 
19 
21 contains
22 
26  thadvection_get_descriptor%name="th_advection"
27  thadvection_get_descriptor%version=0.1
30  end function thadvection_get_descriptor
31 
34  subroutine initialisation_callback(current_state)
35  type(model_state_type), target, intent(inout) :: current_state
36 
37  baroclinicity_use_geostrophic_shear=options_get_logical(current_state%options_database, "baroclinicity_use_geostrophic_shear")
38  fcoriol=options_get_real(current_state%options_database, "fcoriol")
39  rate_change_geostrophic_wind_x=options_get_real(current_state%options_database, "rate_change_geostrophic_wind_x")
40  rate_change_geostrophic_wind_y=options_get_real(current_state%options_database, "rate_change_geostrophic_wind_y")
44  end subroutine initialisation_callback
45 
48  subroutine timestep_callback(current_state)
49  type(model_state_type), target, intent(inout) :: current_state
50 
51  call vertical_advection_of_reference_state(current_state, current_state%column_local_y, current_state%column_local_x)
52  call advection_of_mean_baroclinicity(current_state, current_state%column_local_y, current_state%column_local_x)
53  end subroutine timestep_callback
54 
64  subroutine vertical_advection_of_reference_state(current_state, local_y, local_x)
65  type(model_state_type), target, intent(inout) :: current_state
66  integer, intent(in) :: local_y, local_x
67 
68  integer :: k
69  real(kind=DEFAULT_PRECISION) :: sctmp1, sctmp2
70 
71  if (current_state%use_anelastic_equations) then
72  ! This code only needs to be executed if anelastic, otherwise THREF is constant and the increment calculated here is zero
73  do k=2, current_state%local_grid%size(z_index)
74  sctmp1=current_state%global_grid%configuration%vertical%tzc1(k)*2.0_default_precision*&
75  current_state%global_grid%configuration%vertical%dthref(k-1)
76  sctmp2=current_state%global_grid%configuration%vertical%tzc2(k)*2.0_default_precision*&
77  current_state%global_grid%configuration%vertical%dthref(k)
78  current_state%sth%data(k, local_y, local_x)=current_state%sth%data(k, local_y, local_x)-(sctmp1*&
79  current_state%w%data(k-1, local_y, local_x) + sctmp2*current_state%w%data(k, local_y, local_x))
80  end do
81  end if
83 
88  subroutine advection_of_mean_baroclinicity(current_state, local_y, local_x)
89  type(model_state_type), target, intent(inout) :: current_state
90  integer, intent(in) :: local_y, local_x
91 
92  integer :: k
93 
95  if (current_state%passive_q) then
96  if (current_state%use_anelastic_equations) then
97  do k=2, current_state%local_grid%size(z_index)
98  current_state%sth%data(k, local_y, local_x)=current_state%sth%data(k, local_y, local_x)+&
99  current_state%global_grid%configuration%vertical%thref(k)*fcoriol_over_g*&
100  ((current_state%v%data(k, local_y, local_x) + current_state%vgal) * rate_change_geostrophic_wind_x-&
101  (current_state%u%data(k, local_y, local_x) + current_state%ugal) * rate_change_geostrophic_wind_y)
102  end do
103  else
104  do k=2, current_state%local_grid%size(z_index)
105  current_state%sth%data(k, local_y, local_x)=current_state%sth%data(k, local_y, local_x)+&
106  ((current_state%v%data(k, local_y, local_x) + current_state%vgal) * multiplicative_factor_x-&
107  (current_state%u%data(k, local_y, local_x) + current_state%ugal) * multiplicative_factor_y)
108  end do
109  end if
110  else
111  call log_master_log(log_error, "The combination if baroclinicity and active q is not yet allowed")
112  end if
113  end if
114  end subroutine advection_of_mean_baroclinicity
115 end module thadvection_mod
real(kind=default_precision) fcoriol
Definition: thadvection.F90:17
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
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
real(kind=default_precision), public g
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
subroutine, public log_master_log(level, message)
Will log just from the master process.
Definition: logging.F90:47
real(kind=default_precision) rate_change_geostrophic_wind_y
Definition: thadvection.F90:17
real(kind=default_precision) rate_change_geostrophic_wind_x
Definition: thadvection.F90:17
subroutine initialisation_callback(current_state)
Initialisation callback to set up the variables and data needed by the component. ...
Definition: thadvection.F90:35
real(kind=default_precision) multiplicative_factor_x
Definition: thadvection.F90:17
logical baroclinicity_use_geostrophic_shear
Definition: thadvection.F90:16
subroutine timestep_callback(current_state)
Timestep callback, will call the two separate procedures to do their advection if needed...
Definition: thadvection.F90:49
Scientific constant values used throughout simulations. Each has a default value and this can be over...
subroutine vertical_advection_of_reference_state(current_state, local_y, local_x)
Vertical advection of the reference state. It doesn't seem consistent to do the advection in this way...
Definition: thadvection.F90:65
Interfaces and types that MONC components must specify.
real(kind=default_precision) multiplicative_factor_y
Definition: thadvection.F90:17
real(kind=default_precision) function, public options_get_real(options_database, key, index)
Retrieves a real value from the database that matches the provided key.
Functionality to support the different types of grid and abstraction between global grids and local o...
Definition: grids.F90:5
Specific theta advection, which involves the vertical advection of reference state and advection of m...
Definition: thadvection.F90:2
Manages the options database. Contains administration functions and deduce runtime options from the c...
real(kind=default_precision) fcoriol_over_g
Definition: thadvection.F90:17
logical function, public options_get_logical(options_database, key, index)
Retrieves a logical value from the database that matches the provided key.
type(component_descriptor_type) function, public thadvection_get_descriptor()
Provides a description of this component for the core to register.
Definition: thadvection.F90:26
subroutine advection_of_mean_baroclinicity(current_state, local_y, local_x)
Performs advection of the mean baroclinicity if appropriate.
Definition: thadvection.F90:89
The model state which represents the current state of a run.
Definition: state.F90:2