MONC
lwrad_exponential.F90
Go to the documentation of this file.
1 
12  use grids_mod, only : z_index, y_index, x_index
13  use science_constants_mod, only : cp
17 
18  implicit none
19 
20  ! Indices for cloud
21  integer :: iql
22  ! Index for the top of the domain
23  integer :: k_top, x_local, y_local
24 
25  ! local column longwave flux variables, calculated using prescribed values from
26  ! the global/user_config file
28  ! local column liquid water content
29  real(default_precision), allocatable :: qc_col(:)
30  ! local density factor and raidiation factor used in conversions
31  real(default_precision), allocatable :: density_factor(:), radiation_factor(:)
32  ! declare radiative heating rate for longwave. This is declared as a 3D array so
33  ! that the heating rates can be stored for diagnostics or use when the radiation
34  ! timestep is longer than the model timestep
35  real(default_precision), allocatable :: sth_lw(:,:,:)
36 
37  ! declare radiative flux variables that are read for global or user_config
39 
40 
42 contains
43 
47  lwrad_exponential_get_descriptor%name="lwrad_exponential"
53 
57  subroutine initialisation_callback(current_state)
58  type(model_state_type), target, intent(inout) :: current_state
59 
60  integer :: kkp, k ! look counter
61 
62 
63  k_top = current_state%local_grid%size(z_index) + current_state%local_grid%halo_size(z_index) * 2
64  x_local = current_state%local_grid%size(x_index) + current_state%local_grid%halo_size(x_index) * 2
65  y_local = current_state%local_grid%size(y_index) + current_state%local_grid%halo_size(x_index) * 2
66 
67  if (is_component_enabled(current_state%options_database, "socrates_couple")) then
68  call log_master_log &
69  (log_error, "Socrates and lwrad_exponential both enabled, switch off one in config - STOP")
70  endif
71 
72  allocate(lwrad_flux_top(k_top))
73  allocate(lwrad_flux_base(k_top))
74  allocate(lwrad_flux(k_top))
75  allocate(qc_col(k_top))
76  allocate(density_factor(k_top))
77  allocate(radiation_factor(k_top))
78  ! NOTE: this may be the wrong declaration as sth_lw may need to declared on the whole domain
79  allocate(sth_lw(k_top,y_local,x_local))
80 
81  iql=get_q_index(standard_q_names%CLOUD_LIQUID_MASS, 'lwrad_exponential')
82 
83  longwave_exp_decay=options_get_real(current_state%options_database, "longwave_exp_decay")
84  cltop_longwave_flux=options_get_real(current_state%options_database, "cltop_longwave_flux")
85  clbase_longwave_flux=options_get_real(current_state%options_database, "clbase_longwave_flux")
86 
87  density_factor(:) = current_state%global_grid%configuration%vertical%rhon(:)* &
88  current_state%global_grid%configuration%vertical%dz(:)
89 
92 
93  end subroutine initialisation_callback
94 
98  subroutine timestep_callback(current_state)
99  type(model_state_type), target, intent(inout) :: current_state
100 
101  integer :: k ! Loop counter
102  integer :: icol, jcol ! Shorthand column indices
103 
104  real(DEFAULT_PRECISION) :: dtm ! Local timestep variable
105 
106  if (current_state%halo_column) return
107 
108  dtm = current_state%dtm*2.0
109  if (current_state%field_stepping == forward_stepping) dtm=current_state%dtm! Should this be revised to scalar_stepping
110 
111  icol=current_state%column_local_x
112  jcol=current_state%column_local_y
113 
114  ! set the column liquid water content
115  if (current_state%field_stepping == forward_stepping) then ! Should this be revised to scalar_stepping
116  qc_col(:) = current_state%q(iql)%data(:, jcol, icol) + current_state%sq(iql)%data(:, jcol, icol)*dtm
117  else
118  qc_col(:)= current_state%zq(iql)%data(:, jcol, icol) + current_state%sq(iql)%data(:, jcol, icol)*dtm
119 
120  end if
121 
122  ! initialise the flux top and base to 0.0
123  lwrad_flux_top(:) = 0.0
124  lwrad_flux_base(:) = 0.0
125 
126  ! First workout cloud top cooling
128 
129  do k = k_top-1, 1, -1
130  if (qc_col(k+1) > 1.e-10) then
131  lwrad_flux_top(k) = lwrad_flux_top(k+1)* &
133  else
135  endif
136  enddo
137 
138  ! Second workout the cloud base warming
139  do k = 2, k_top
140  if (qc_col(k) > 1.e-10) then
141  lwrad_flux_base(k) = lwrad_flux_base(k-1)* &
143  else
145  endif
146  enddo
147 
148  ! Next, sum the fluxes
149  do k = 1, k_top
151  enddo
152 
153  ! workout radiative heating rate, and stored on the processors local grid - is this correct??
154  ! or should the declaration be on the global grid?
155  do k = 2, k_top
156  sth_lw(k, jcol, icol) = -(lwrad_flux(k) - lwrad_flux(k-1))*radiation_factor(k)
157  enddo
158 
159  ! update the current_state sth
160  current_state%sth%data(:, jcol, icol) = current_state%sth%data(:, jcol, icol) + sth_lw(:, jcol, icol)
161 
162  end subroutine timestep_callback
163 
164  subroutine finalisation_callback(current_state)
165 
166  type(model_state_type), target, intent(inout) :: current_state
168 
169  end subroutine finalisation_callback
170 
171 end module lwrad_exponential_mod
registry_mod::is_component_enabled
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
logging_mod::log_error
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
lwrad_exponential_mod::finalisation_callback
subroutine finalisation_callback(current_state)
Definition: lwrad_exponential.F90:165
lwrad_exponential_mod::lwrad_flux_base
real(default_precision), dimension(:), allocatable lwrad_flux_base
Definition: lwrad_exponential.F90:27
lwrad_exponential_mod::density_factor
real(default_precision), dimension(:), allocatable density_factor
Definition: lwrad_exponential.F90:31
grids_mod::x_index
integer, parameter, public x_index
Definition: grids.F90:14
grids_mod::y_index
integer, parameter, public y_index
Definition: grids.F90:14
lwrad_exponential_mod::lwrad_flux
real(default_precision), dimension(:), allocatable lwrad_flux
Definition: lwrad_exponential.F90:27
lwrad_exponential_mod::qc_col
real(default_precision), dimension(:), allocatable qc_col
Definition: lwrad_exponential.F90:29
lwrad_exponential_mod::timestep_callback
subroutine timestep_callback(current_state)
Called for each column per timestep this will apply a forcing term to the aerosol fields.
Definition: lwrad_exponential.F90:99
science_constants_mod::cp
real(kind=default_precision), public cp
Definition: scienceconstants.F90:13
monc_component_mod
Interfaces and types that MONC components must specify.
Definition: monc_component.F90:6
lwrad_exponential_mod::cltop_longwave_flux
real(default_precision) cltop_longwave_flux
Definition: lwrad_exponential.F90:38
lwrad_exponential_mod::sth_lw
real(default_precision), dimension(:,:,:), allocatable sth_lw
Definition: lwrad_exponential.F90:35
lwrad_exponential_mod::longwave_exp_decay
real(default_precision) longwave_exp_decay
Definition: lwrad_exponential.F90:38
lwrad_exponential_mod::y_local
integer y_local
Definition: lwrad_exponential.F90:23
science_constants_mod
Scientific constant values used throughout simulations. Each has a default value and this can be over...
Definition: scienceconstants.F90:3
grids_mod::z_index
integer, parameter, public z_index
Grid index parameters.
Definition: grids.F90:14
lwrad_exponential_mod::iql
integer iql
Definition: lwrad_exponential.F90:21
lwrad_exponential_mod::k_top
integer k_top
Definition: lwrad_exponential.F90:23
q_indices_mod::standard_q_names
type(standard_q_names_type), public standard_q_names
Definition: q_indices.F90:59
state_mod::model_state_type
The ModelState which represents the current state of a run.
Definition: state.F90:39
lwrad_exponential_mod::clbase_longwave_flux
real(default_precision) clbase_longwave_flux
Definition: lwrad_exponential.F90:38
state_mod::forward_stepping
integer, parameter, public forward_stepping
Definition: state.F90:15
lwrad_exponential_mod
Simple exponential scheme to calculate the longwave radiation associated with cloud....
Definition: lwrad_exponential.F90:7
lwrad_exponential_mod::x_local
integer x_local
Definition: lwrad_exponential.F90:23
q_indices_mod::get_q_index
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 pr...
Definition: q_indices.F90:112
logging_mod
Logging utility.
Definition: logging.F90:2
lwrad_exponential_mod::lwrad_flux_top
real(default_precision), dimension(:), allocatable lwrad_flux_top
Definition: lwrad_exponential.F90:27
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
logging_mod::log_master_log
subroutine, public log_master_log(level, message)
Will log just from the master process.
Definition: logging.F90:47
lwrad_exponential_mod::initialisation_callback
subroutine initialisation_callback(current_state)
The initialisation callback sets up the prescribed longwave fluxes and the exponential decay factor.
Definition: lwrad_exponential.F90:58
q_indices_mod
This manages the Q variables and specifically the mapping between names and the index that they are s...
Definition: q_indices.F90:2
registry_mod
MONC component registry.
Definition: registry.F90:5
lwrad_exponential_mod::radiation_factor
real(default_precision), dimension(:), allocatable radiation_factor
Definition: lwrad_exponential.F90:31
grids_mod
Functionality to support the different types of grid and abstraction between global grids and local o...
Definition: grids.F90:5
optionsdatabase_mod
Manages the options database. Contains administration functions and deduce runtime options from the c...
Definition: optionsdatabase.F90:7
monc_component_mod::component_descriptor_type
Description of a component.
Definition: monc_component.F90:42
optionsdatabase_mod::options_get_real
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.
Definition: optionsdatabase.F90:91
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
state_mod
The model state which represents the current state of a run.
Definition: state.F90:2
lwrad_exponential_mod::lwrad_exponential_get_descriptor
type(component_descriptor_type) function, public lwrad_exponential_get_descriptor()
Provides the descriptor back to the caller and is used in component registration.
Definition: lwrad_exponential.F90:47