MOM6
Rossby_front_2d_initialization.F90
Go to the documentation of this file.
1 !> Initial conditions for the 2D Rossby front test
3 
4 ! This file is part of MOM6. See LICENSE.md for the license.
5 
8 use mom_get_input, only : directories
9 use mom_grid, only : ocean_grid_type
10 use mom_io, only : close_file, fieldtype, file_exists
11 use mom_io, only : open_file, read_data, read_axis_data, single_file
12 use mom_io, only : write_field, slasher, vardesc
19 
20 implicit none ; private
21 
22 #include <MOM_memory.h>
23 
24 ! Private (module-wise) parameters
25 character(len=40) :: mdl = "Rossby_front_2d_initialization" !< This module's name.
26 ! This include declares and sets the variable "version".
27 #include "version_variable.h"
28 
32 
33 ! Parameters defining the initial conditions of this test case
34 real, parameter :: frontfractionalwidth = 0.5 !< Width of front as fraction of domain
35 real, parameter :: hmlmin = 0.25 !< Shallowest ML as fractional depth of ocean
36 real, parameter :: hmlmax = 0.75 !< Deepest ML as fractional depth of ocean
37 
38 contains
39 
40 !> Initialization of thicknesses in 2D Rossby front test
41 subroutine rossby_front_initialize_thickness(h, G, GV, param_file, just_read_params)
42  type(ocean_grid_type), intent(in) :: G !< Grid structure
43  type(verticalgrid_type), intent(in) :: GV !< Vertical grid structure
44  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
45  intent(out) :: h !< The thickness that is being initialized, in m.
46  type(param_file_type), intent(in) :: param_file !< A structure indicating the open file
47  !! to parse for model parameter values.
48  logical, optional, intent(in) :: just_read_params !< If present and true, this call will
49  !! only read parameters without changing h.
50 
51  integer :: i, j, k, is, ie, js, je, nz
52  real :: Tz, Dml, eta, stretch, h0
53  real :: min_thickness, T_range, dRho_dT
54  logical :: just_read ! If true, just read parameters but set nothing.
55  character(len=40) :: verticalCoordinate
56 
57  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
58 
59  just_read = .false. ; if (present(just_read_params)) just_read = just_read_params
60 
61  if (.not.just_read) &
62  call mom_mesg("Rossby_front_2d_initialization.F90, Rossby_front_initialize_thickness: setting thickness")
63 
64  if (.not.just_read) call log_version(param_file, mdl, version, "")
65  ! Read parameters needed to set thickness
66  call get_param(param_file, mdl, "MIN_THICKNESS", min_thickness, &
67  'Minimum layer thickness',units='m',default=1.e-3, do_not_log=just_read)
68  call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalcoordinate, &
69  default=default_coordinate_mode, do_not_log=just_read)
70  call get_param(param_file, mdl, "T_RANGE", t_range, 'Initial temperature range', &
71  units='C', default=0.0, do_not_log=just_read)
72  call get_param(param_file, mdl, "DRHO_DT", drho_dt, default=-0.2, do_not_log=.true.)
73 
74  if (just_read) return ! All run-time parameters have been read, so return.
75 
76  tz = t_range / g%max_depth
77 
78  select case ( coordinatemode(verticalcoordinate) )
79 
80  case (regridding_layer, regridding_rho)
81  do j = g%jsc,g%jec ; do i = g%isc,g%iec
82  dml = hml( g, g%geoLatT(i,j) )
83  eta = -( -drho_dt / gv%Rho0 ) * tz * 0.5 * ( dml * dml )
84  stretch = ( ( g%max_depth + eta ) / g%max_depth )
85  h0 = ( g%max_depth / real(nz) ) * stretch
86  do k = 1, nz
87  h(i,j,k) = h0
88  enddo
89  end do ; end do
90 
91  case (regridding_zstar, regridding_sigma)
92  do j = g%jsc,g%jec ; do i = g%isc,g%iec
93  dml = hml( g, g%geoLatT(i,j) )
94  eta = -( -drho_dt / gv%Rho0 ) * tz * 0.5 * ( dml * dml )
95  stretch = ( ( g%max_depth + eta ) / g%max_depth )
96  h0 = ( g%max_depth / real(nz) ) * stretch
97  do k = 1, nz
98  h(i,j,k) = h0
99  enddo
100  end do ; end do
101 
102  case default
103  call mom_error(fatal,"Rossby_front_initialize: "// &
104  "Unrecognized i.c. setup - set REGRIDDING_COORDINATE_MODE")
105 
106  end select
107 
109 
110 
111 !> Initialization of temperature and salinity in the Rossby front test
112 subroutine rossby_front_initialize_temperature_salinity(T, S, h, G, &
113  param_file, eqn_of_state, just_read_params)
114  type(ocean_grid_type), intent(in) :: G !< Grid structure
115  real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(out) :: T !< Potential temperature [deg C]
116  real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(out) :: S !< Salinity [ppt]
117  real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(in) :: h !< Thickness
118  type(param_file_type), intent(in) :: param_file !< Parameter file handle
119  type(eos_type), pointer :: eqn_of_state !< Equation of state structure
120  logical, optional, intent(in) :: just_read_params !< If present and true, this call will
121  !! only read parameters without changing h.
122 
123  integer :: i, j, k, is, ie, js, je, nz
124  real :: T_ref, S_ref ! Reference salinity and temerature within surface layer
125  real :: T_range ! Range of salinities and temperatures over the vertical
126  real :: y, zc, zi, dTdz
127  logical :: just_read ! If true, just read parameters but set nothing.
128  character(len=40) :: verticalCoordinate
129  real :: PI ! 3.1415926... calculated as 4*atan(1)
130 
131  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
132 
133  just_read = .false. ; if (present(just_read_params)) just_read = just_read_params
134 
135  call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalcoordinate, &
136  default=default_coordinate_mode, do_not_log=just_read)
137  call get_param(param_file, mdl,"S_REF",s_ref,'Reference salinity', units='1e-3', &
138  fail_if_missing=.not.just_read, do_not_log=just_read)
139  call get_param(param_file, mdl,"T_REF",t_ref,'Reference temperature',units='C',&
140  fail_if_missing=.not.just_read, do_not_log=just_read)
141  call get_param(param_file, mdl,"T_RANGE",t_range,'Initial temperature range',&
142  units='C', default=0.0, do_not_log=just_read)
143 
144  if (just_read) return ! All run-time parameters have been read, so return.
145 
146  t(:,:,:) = 0.0
147  s(:,:,:) = s_ref
148  dtdz = t_range / g%max_depth
149 
150  do j = g%jsc,g%jec ; do i = g%isc,g%iec
151  zi = 0.
152  do k = 1, nz
153  zi = zi - h(i,j,k) ! Bottom interface position
154  zc = zi - 0.5*h(i,j,k) ! Position of middle of cell
155  zc = min( zc, -hml(g, g%geoLatT(i,j)) ) ! Bound by depth of mixed layer
156  t(i,j,k) = t_ref + dtdz * zc ! Linear temperature profile
157  enddo
158  end do ; end do
159 
161 
162 
163 !> Initialization of u and v in the Rossby front test
164 subroutine rossby_front_initialize_velocity(u, v, h, G, GV, param_file, just_read_params)
165  type(ocean_grid_type), intent(in) :: G !< Grid structure
166  type(verticalgrid_type), intent(in) :: GV !< Vertical grid structure
167  real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), intent(out) :: u !< i-component of velocity [m/s]
168  real, dimension(SZI_(G),SZJB_(G),SZK_(G)), intent(out) :: v !< j-component of velocity [m/s]
169  real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(in) :: h !< Thickness [H]
170  type(param_file_type), intent(in) :: param_file !< A structure indicating the
171  !! open file to parse for model
172  !! parameter values.
173  logical, optional, intent(in) :: just_read_params !< If present and true, this call will
174  !! only read parameters without changing h.
175 
176  real :: y ! Non-dimensional coordinate across channel, 0..pi
177  real :: T_range ! Range of salinities and temperatures over the vertical
178  real :: dUdT ! Factor to convert dT/dy into dU/dz, g*alpha/f
179  real :: dRho_dT, zi, zc, zm, f, Ty, Dml, hAtU
180  integer :: i, j, k, is, ie, js, je, nz
181  logical :: just_read ! If true, just read parameters but set nothing.
182  character(len=40) :: verticalCoordinate
183 
184  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
185 
186  just_read = .false. ; if (present(just_read_params)) just_read = just_read_params
187 
188  call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalcoordinate, &
189  default=default_coordinate_mode, do_not_log=just_read)
190  call get_param(param_file, mdl, "T_RANGE", t_range, 'Initial temperature range', &
191  units='C', default=0.0, do_not_log=just_read)
192  call get_param(param_file, mdl, "DRHO_DT", drho_dt, default=-0.2, do_not_log=.true.)
193 
194  if (just_read) return ! All run-time parameters have been read, so return.
195 
196  v(:,:,:) = 0.0
197  u(:,:,:) = 0.0
198 
199  do j = g%jsc,g%jec ; do i = g%isc-1,g%iec+1
200  f = 0.5*( g%CoriolisBu(i,j) + g%CoriolisBu(i,j-1) )
201  dudt = 0.0 ; if (abs(f) > 0.0) &
202  dudt = ( gv%g_Earth * drho_dt ) / ( f * gv%Rho0 )
203  dml = hml( g, g%geoLatT(i,j) )
204  ty = dtdy( g, t_range, g%geoLatT(i,j) )
205  zi = 0.
206  do k = 1, nz
207  hatu = 0.5*(h(i,j,k)+h(i+1,j,k))
208  zi = zi - hatu ! Bottom interface position
209  zc = zi - 0.5*hatu ! Position of middle of cell
210  zm = max( zc + dml, 0. ) ! Height above bottom of mixed layer
211  u(i,j,k) = dudt * ty * zm ! Thermal wind starting at base of ML
212  enddo
213  enddo ; enddo
214 
216 
217 !> Pseudo coordinate across domain used by Hml() and dTdy()
218 !! returns a coordinate from -PI/2 .. PI/2 squashed towards the
219 !! center of the domain.
220 real function ypseudo( G, lat )
221  type(ocean_grid_type), intent(in) :: G !< Grid structure
222  real, intent(in) :: lat !< Latitude
223  ! Local
224  real :: y, PI
225 
226  pi = 4.0 * atan(1.0)
227  ypseudo = ( ( lat - g%south_lat ) / g%len_lat ) - 0.5 ! -1/2 .. 1/.2
228  ypseudo = pi * max(-0.5, min(0.5, ypseudo / frontfractionalwidth))
229 end function ypseudo
230 
231 
232 !> Analytic prescription of mixed layer depth in 2d Rossby front test
233 real function hml( G, lat )
234  type(ocean_grid_type), intent(in) :: G !< Grid structure
235  real, intent(in) :: lat !< Latitude
236  ! Local
237  real :: dHML, HMLmean
238 
239  dhml = 0.5 * ( hmlmax - hmlmin ) * g%max_depth
240  hmlmean = 0.5 * ( hmlmin + hmlmax ) * g%max_depth
241  hml = hmlmean + dhml * sin( ypseudo(g, lat) )
242 end function hml
243 
244 
245 !> Analytic prescription of mixed layer temperature gradient in 2d Rossby front test
246 real function dtdy( G, dT, lat )
247  type(ocean_grid_type), intent(in) :: G !< Grid structure
248  real, intent(in) :: dT !< Top to bottom temperature difference
249  real, intent(in) :: lat !< Latitude
250  ! Local
251  real :: PI, dHML, dHdy
252  real :: km = 1.e3 ! AXIS_UNITS = 'k' (1000 m)
253 
254  pi = 4.0 * atan(1.0)
255  dhml = 0.5 * ( hmlmax - hmlmin ) * g%max_depth
256  dhdy = dhml * ( pi / ( frontfractionalwidth * g%len_lat * km ) ) * cos( ypseudo(g, lat) )
257  dtdy = -( dt / g%max_depth ) * dhdy
258 
259 end function dtdy
260 
261 
262 !> \namespace rossby_front_2d_initialization
263 !!
264 !! \section section_Rossby_front_2d Description of the 2d Rossby front initial conditions
265 !!
266 !! Consistent with a linear equation of state, the system has a constant stratification
267 !! below the mixed layer, stratified in temperature only. Isotherms are flat below the
268 !! mixed layer and vertical within. Salinity is constant. The mixed layer has a half sine
269 !! form so that there are no mixed layer or temperature gradients at the side walls.
270 !!
271 !! Below the mixed layer the potential temperature, \f$\theta(z)\f$, is given by
272 !! \f[ \theta(z) = \theta_0 - \Delta \theta \left( z + h_{ML} \right) \f]
273 !! where \f$ \theta_0 \f$ and \f$ \Delta \theta \f$ are external model parameters.
274 !!
275 !! The depth of the mixed layer, \f$H_{ML}\f$ is
276 !! \f[ h_{ML}(y) = h_{min} + \left( h_{max} - h_{min} \right) \cos{\pi y/L} \f].
277 !! The temperature in mixed layer is given by the reference temperature at \f$z=h_{ML}\f$
278 !! so that
279 !! \f[ \theta(y,z) =
280 !! \theta_0 - \Delta \theta \left( z + h_{ML} \right) & \forall & z < h_{ML}(y) T.B.D.
281 !! \f]
282 
integer, parameter regridding_layer
Layer mode.
subroutine, public read_axis_data(filename, axis_name, var)
Definition: MOM_io.F90:424
character(len=40) mdl
This module&#39;s name.
integer function coordinatemode(string)
Parse a string parameter specifying the coordinate mode and return the appropriate enumerated integer...
integer, parameter regridding_sigma
Sigma coordinates.
real, parameter frontfractionalwidth
Width of front as fraction of domain.
Ocean grid type. See mom_grid for details.
Definition: MOM_grid.F90:19
Calculates density of sea water from T, S and P.
Definition: MOM_EOS.F90:45
Provides the ocean grid type.
Definition: MOM_grid.F90:2
character(len= *), parameter default_coordinate_mode
Default coordinate mode.
real, parameter hmlmax
Deepest ML as fractional depth of ocean.
This module contains I/O framework code.
Definition: MOM_io.F90:2
Initial conditions for the 2D Rossby front test.
subroutine, public rossby_front_initialize_velocity(u, v, h, G, GV, param_file, just_read_params)
Initialization of u and v in the Rossby front test.
subroutine, public calculate_density_derivs(T, S, pressure, drho_dT, drho_dS, start, npts, EOS)
Calls the appropriate subroutine to calculate density derivatives for 1-D array inputs.
Definition: MOM_EOS.F90:214
logical function, public is_root_pe()
subroutine, public rossby_front_initialize_temperature_salinity(T, S, h, G, param_file, eqn_of_state, just_read_params)
Initialization of temperature and salinity in the Rossby front test.
subroutine, public rossby_front_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialization of thicknesses in 2D Rossby front test.
subroutine, public mom_mesg(message, verb, all_print)
Provides subroutines for quantities specific to the equation of state.
Definition: MOM_EOS.F90:2
Type for describing a variable, typically a tracer.
Definition: MOM_io.F90:51
integer, parameter regridding_zstar
z* coordinates
real, parameter hmlmin
Shallowest ML as fractional depth of ocean.
real function hml(G, lat)
Analytic prescription of mixed layer depth in 2d Rossby front test.
The thermo_var_ptrs structure contains pointers to an assortment of thermodynamic fields that may be ...
Contains constants for interpreting input parameters that control regridding.
real function dtdy(G, dT, lat)
Analytic prescription of mixed layer temperature gradient in 2d Rossby front test.
subroutine, public mom_error(level, message, all_print)
integer, parameter regridding_rho
Target interface densities.
real function ypseudo(G, lat)
Pseudo coordinate across domain used by Hml() and dTdy() returns a coordinate from -PI/2 ...
A control structure for the equation of state.
Definition: MOM_EOS.F90:55