MONC
coriolis.F90
Go to the documentation of this file.
1 
6  use state_mod, only : model_state_type
7  use grids_mod, only : z_index, y_index, x_index
8  implicit none
9 
10 #ifndef TEST_MODE
11  private
12 #endif
13 
15  real(kind=DEFAULT_PRECISION), dimension(:), allocatable :: geostrophic_wind_x, geostrophic_wind_y
16  real(kind=DEFAULT_PRECISION) :: fcoriol
17 
19 
20  contains
21 
25  coriolis_get_descriptor%name="coriolis"
26  coriolis_get_descriptor%version=0.1
29  end function coriolis_get_descriptor
30 
33  subroutine initialisation_callback(current_state)
34  type(model_state_type), target, intent(inout) :: current_state
35 
36  integer :: k
37 
38  baroclinicity_use_geostrophic_shear=options_get_logical(current_state%options_database, "baroclinicity_use_geostrophic_shear")
39  fcoriol=options_get_real(current_state%options_database, "fcoriol")
40  current_state%geostrophic_wind_rate_of_change_in_x=options_get_real(current_state%options_database, &
41  "geostrophic_wind_rate_of_change_in_x")
42  current_state%geostrophic_wind_rate_of_change_in_y=options_get_real(current_state%options_database, &
43  "geostrophic_wind_rate_of_change_in_y")
44  current_state%surface_geostrophic_wind_x=options_get_real(current_state%options_database, "surface_geostrophic_wind_x")
45  current_state%surface_geostrophic_wind_y=options_get_real(current_state%options_database, "surface_geostrophic_wind_y")
46 
47  allocate(geostrophic_wind_x(current_state%local_grid%size(z_index)), &
48  geostrophic_wind_y(current_state%local_grid%size(z_index)))
49 
50  do k=1,current_state%local_grid%size(z_index)
51  geostrophic_wind_x(k)=current_state%surface_geostrophic_wind_x
52  geostrophic_wind_y(k)=current_state%surface_geostrophic_wind_y
54  geostrophic_wind_x(k)=geostrophic_wind_x(k)+current_state%geostrophic_wind_rate_of_change_in_x*&
55  current_state%global_grid%configuration%vertical%zn(k)
56  geostrophic_wind_y(k)=geostrophic_wind_y(k)+current_state%geostrophic_wind_rate_of_change_in_y*&
57  current_state%global_grid%configuration%vertical%zn(k)
58  end if
59  end do
60  end subroutine initialisation_callback
61 
64  subroutine timestep_callback(current_state)
65  type(model_state_type), target, intent(inout) :: current_state
66 
67  integer :: k
68 
69  if (current_state%halo_column) then
70  if (.not. ((current_state%column_local_y == current_state%local_grid%halo_size(y_index) .and. &
71  current_state%column_local_x .le. current_state%local_grid%local_domain_end_index(x_index) .and. &
72  current_state%column_local_x .ge. current_state%local_grid%local_domain_start_index(x_index)-1) .or. &
73  (current_state%column_local_x == current_state%local_grid%halo_size(x_index) .and. &
74  current_state%column_local_y .ge. current_state%local_grid%local_domain_start_index(y_index) &
75  .and. current_state%column_local_y .le. current_state%local_grid%local_domain_end_index(y_index)) )) return
76  end if
77 
78  do k=2,current_state%local_grid%size(z_index)
79 #if defined(U_ACTIVE) && defined(V_ACTIVE)
80  current_state%su%data(k, current_state%column_local_y, current_state%column_local_x)=&
81  current_state%su%data(k, current_state%column_local_y, current_state%column_local_x)+fcoriol*&
82  (0.25_default_precision*(current_state%v%data(k, current_state%column_local_y, current_state%column_local_x)+&
83  current_state%v%data(k, current_state%column_local_y, current_state%column_local_x+1)+&
84  current_state%v%data(k, current_state%column_local_y-1, current_state%column_local_x)+&
85  current_state%v%data(k, current_state%column_local_y-1, current_state%column_local_x+1))+current_state%vgal-&
87 
88  current_state%sv%data(k, current_state%column_local_y, current_state%column_local_x)=&
89  current_state%sv%data(k, current_state%column_local_y, current_state%column_local_x)-fcoriol*&
90  (0.25_default_precision*(current_state%u%data(k, current_state%column_local_y, current_state%column_local_x)+&
91  current_state%u%data(k, current_state%column_local_y, current_state%column_local_x-1)+&
92  current_state%u%data(k, current_state%column_local_y+1, current_state%column_local_x)+&
93  current_state%u%data(k, current_state%column_local_y+1, current_state%column_local_x-1))+current_state%ugal-&
95 #endif
96  end do
97  end subroutine timestep_callback
98 end module coriolis_mod
real(kind=default_precision), dimension(:), allocatable geostrophic_wind_y
Definition: coriolis.F90:15
type(component_descriptor_type) function, public coriolis_get_descriptor()
Provides the descriptor back to the caller and is used in component registration. ...
Definition: coriolis.F90:25
subroutine timestep_callback(current_state)
For each none halo cell this will calculate the coriolis terms for su and sv fields.
Definition: coriolis.F90:65
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
Interfaces and types that MONC components must specify.
logical baroclinicity_use_geostrophic_shear
Definition: coriolis.F90:14
subroutine initialisation_callback(current_state)
Initialisation call back which will read in the coriolis configuration and set up the geostrophic win...
Definition: coriolis.F90:34
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
This calculates the coriolis and mean pressure gradient terms which impact su and sv fields...
Definition: coriolis.F90:2
Manages the options database. Contains administration functions and deduce runtime options from the c...
real(kind=default_precision) fcoriol
Definition: coriolis.F90:16
logical function, public options_get_logical(options_database, key, index)
Retrieves a logical value from the database that matches the provided key.
The model state which represents the current state of a run.
Definition: state.F90:2
integer, parameter, public y_index
Definition: grids.F90:14
integer, parameter, public x_index
Definition: grids.F90:14
real(kind=default_precision), dimension(:), allocatable geostrophic_wind_x
Definition: coriolis.F90:15