MONC
damping.F90
Go to the documentation of this file.
1 
2 module damping_mod
4  use grids_mod, only : z_index
5  use state_mod, only : model_state_type
6  use collections_mod, only : map_type
11  implicit none
12 
13 #ifndef TEST_MODE
14  private
15 #endif
16 
17  real(kind=DEFAULT_PRECISION) :: dmptim,& !< Layer timescale
18  zdmp,& !< The point (m) where the damping starts
19  hdmp
20 
22 
23 contains
24 
28  damping_get_descriptor%name="damping"
29  damping_get_descriptor%version=0.1
32  end function damping_get_descriptor
33 
36  subroutine init_callback(current_state)
37  type(model_state_type), target, intent(inout) :: current_state
38 
39  integer :: k
40 
41  if (.not. is_component_enabled(current_state%options_database, "mean_profiles")) then
42  call log_master_log(log_error, "Damping requires the mean profiles component to be enabled")
43  end if
44 
45  dmptim=options_get_real(current_state%options_database, "dmptim")
46  zdmp=options_get_real(current_state%options_database, "zdmp")
47  hdmp=options_get_real(current_state%options_database, "hdmp")
48 
49  allocate(current_state%global_grid%configuration%vertical%dmpco(current_state%local_grid%size(z_index)), &
50  current_state%global_grid%configuration%vertical%dmpcoz(current_state%local_grid%size(z_index)))
51  current_state%global_grid%configuration%vertical%dmpco(:)=0.
52  current_state%global_grid%configuration%vertical%dmpcoz(:)=0.
53  do k=current_state%local_grid%size(z_index),1,-1
54  current_state%global_grid%configuration%vertical%kdmpmin=k
55  if (current_state%global_grid%configuration%vertical%zn(k) .ge. zdmp) then
56  current_state%global_grid%configuration%vertical%dmpco(k)=dmptim*(exp((&
57  current_state%global_grid%configuration%vertical%zn(k)-zdmp)/hdmp)-1.0)
58  end if
59  if (current_state%global_grid%configuration%vertical%z(k) .ge. zdmp) then
60  current_state%global_grid%configuration%vertical%dmpcoz(k)=dmptim*(exp((&
61  current_state%global_grid%configuration%vertical%z(k)-zdmp)/hdmp)-1.0)
62  end if
63  if(current_state%global_grid%configuration%vertical%zn(k).lt. zdmp) exit
64  end do
65  end subroutine init_callback
66 
69  subroutine timestep_callback(current_state)
70  type(model_state_type), target, intent(inout) :: current_state
71 
72  integer :: k, i
73 
74  if (current_state%halo_column .and. current_state%timestep <3) return
75 
76  do k=current_state%global_grid%configuration%vertical%kdmpmin,current_state%local_grid%size(z_index)
77 #ifdef U_ACTIVE
78  current_state%su%data(k, current_state%column_local_y, current_state%column_local_x)=current_state%su%data(k, &
79  current_state%column_local_y, current_state%column_local_x)-&
80  current_state%global_grid%configuration%vertical%dmpco(k)*(current_state%zu%data(k, current_state%column_local_y, &
81  current_state%column_local_x)- (current_state%global_grid%configuration%vertical%olzubar(k)-current_state%ugal))
82 #endif
83 #ifdef V_ACTIVE
84  current_state%sv%data(k, current_state%column_local_y, current_state%column_local_x)=current_state%sv%data(k, &
85  current_state%column_local_y, current_state%column_local_x)-&
86  current_state%global_grid%configuration%vertical%dmpco(k)*(current_state%zv%data(k, current_state%column_local_y, &
87  current_state%column_local_x)-(current_state%global_grid%configuration%vertical%olzvbar(k)-current_state%vgal))
88 #endif
89  if (current_state%th%active) then
90  current_state%sth%data(k, current_state%column_local_y, current_state%column_local_x)=current_state%sth%data(k, &
91  current_state%column_local_y, current_state%column_local_x)-&
92  current_state%global_grid%configuration%vertical%dmpco(k)*(current_state%zth%data(k, current_state%column_local_y, &
93  current_state%column_local_x)-current_state%global_grid%configuration%vertical%olzthbar(k))
94  end if
95 
96  do i=1,current_state%number_q_fields
97  if (current_state%q(i)%active) then
98  current_state%sq(i)%data(k, current_state%column_local_y, current_state%column_local_x)=current_state%sq(i)%data(k, &
99  current_state%column_local_y, current_state%column_local_x)-&
100  current_state%global_grid%configuration%vertical%dmpco(k)*&
101  (current_state%zq(i)%data(k, current_state%column_local_y, current_state%column_local_x)-&
102  current_state%global_grid%configuration%vertical%olzqbar(k,i))
103  end if
104  end do
105  end do
106 #ifdef W_ACTIVE
107  do k=current_state%global_grid%configuration%vertical%kdmpmin,current_state%local_grid%size(z_index)-1
108  current_state%sw%data(k, current_state%column_local_y, current_state%column_local_x)=current_state%sw%data(k, &
109  current_state%column_local_y, current_state%column_local_x)-&
110  current_state%global_grid%configuration%vertical%dmpcoz(k)*&
111  current_state%zw%data(k, current_state%column_local_y, current_state%column_local_x)
112  end do
113 #endif
114  end subroutine timestep_callback
115 end module damping_mod
real(kind=default_precision) hdmp
The height (m) of the damping layer.
Definition: damping.F90:17
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
Logging utility.
Definition: logging.F90:2
type(component_descriptor_type) function, public damping_get_descriptor()
Descriptor of this component for registration.
Definition: damping.F90:28
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
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
subroutine timestep_callback(current_state)
For each data column will calculate the damping term and apply this to the source term for that field...
Definition: damping.F90:70
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
Interfaces and types that MONC components must specify.
Collection data structures.
Definition: collections.F90:7
real(kind=default_precision) dmptim
Layer timescale.
Definition: damping.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
Manages the options database. Contains administration functions and deduce runtime options from the c...
Damping applied to the W field at some point to stop stuff flying up and off.
Definition: damping.F90:2
subroutine init_callback(current_state)
On initialisation will set up data structures and field values.
Definition: damping.F90:37
real(kind=default_precision) zdmp
The point (m) where the damping starts.
Definition: damping.F90:17
The model state which represents the current state of a run.
Definition: state.F90:2
MONC component registry.
Definition: registry.F90:5