MOM6
coord_sigma.F90
Go to the documentation of this file.
1 !> Regrid columns for the sigma coordinate
2 module coord_sigma
3 
4 ! This file is part of MOM6. See LICENSE.md for the license.
5 
6 use mom_error_handler, only : mom_error, fatal
7 
8 implicit none ; private
9 
10 !> Control structure containing required parameters for the sigma coordinate
11 type, public :: sigma_cs ; private
12 
13  !> Number of levels
14  integer :: nk
15 
16  !> Minimum thickness allowed for layers
17  real :: min_thickness
18 
19  !> Target coordinate resolution, nondimensional
20  real, allocatable, dimension(:) :: coordinateresolution
21 end type sigma_cs
22 
24 
25 contains
26 
27 !> Initialise a sigma_CS with pointers to parameters
28 subroutine init_coord_sigma(CS, nk, coordinateResolution)
29  type(sigma_cs), pointer :: cs !< Unassociated pointer to hold the control structure
30  integer, intent(in) :: nk !< Number of layers in the grid
31  real, dimension(:), intent(in) :: coordinateresolution !< Nominal coordinate resolution [nondim]
32 
33  if (associated(cs)) call mom_error(fatal, "init_coord_sigma: CS already associated!")
34  allocate(cs)
35  allocate(cs%coordinateResolution(nk))
36 
37  cs%nk = nk
38  cs%coordinateResolution = coordinateresolution
39 end subroutine init_coord_sigma
40 
41 !> This subroutine deallocates memory in the control structure for the coord_sigma module
42 subroutine end_coord_sigma(CS)
43  type(sigma_cs), pointer :: cs !< Coordinate control structure
44 
45  ! nothing to do
46  if (.not. associated(cs)) return
47  deallocate(cs%coordinateResolution)
48  deallocate(cs)
49 end subroutine end_coord_sigma
50 
51 !> This subroutine can be used to set the parameters for the coord_sigma module
52 subroutine set_sigma_params(CS, min_thickness)
53  type(sigma_cs), pointer :: cs !< Coordinate control structure
54  real, optional, intent(in) :: min_thickness !< Minimum allowed thickness [H ~> m or kg m-2]
55 
56  if (.not. associated(cs)) call mom_error(fatal, "set_sigma_params: CS not associated")
57 
58  if (present(min_thickness)) cs%min_thickness = min_thickness
59 end subroutine set_sigma_params
60 
61 
62 !> Build a sigma coordinate column
63 subroutine build_sigma_column(CS, depth, totalThickness, zInterface)
64  type(sigma_cs), intent(in) :: cs !< Coordinate control structure
65  real, intent(in) :: depth !< Depth of ocean bottom (positive [H ~> m or kg m-2])
66  real, intent(in) :: totalthickness !< Column thickness (positive [H ~> m or kg m-2])
67  real, dimension(CS%nk+1), intent(inout) :: zinterface !< Absolute positions of interfaces [H ~> m or kg m-2]
68 
69  ! Local variables
70  integer :: k
71 
72  zinterface(cs%nk+1) = -depth
73  do k = cs%nk,1,-1
74  zinterface(k) = zinterface(k+1) + (totalthickness * cs%coordinateResolution(k))
75  ! Adjust interface position to accommodate inflating layers
76  ! without disturbing the interface above
77  if (zinterface(k) < (zinterface(k+1) + cs%min_thickness)) then
78  zinterface(k) = zinterface(k+1) + cs%min_thickness
79  endif
80  enddo
81 end subroutine build_sigma_column
82 
83 end module coord_sigma
coord_sigma::init_coord_sigma
subroutine, public init_coord_sigma(CS, nk, coordinateResolution)
Initialise a sigma_CS with pointers to parameters.
Definition: coord_sigma.F90:29
coord_sigma::build_sigma_column
subroutine, public build_sigma_column(CS, depth, totalThickness, zInterface)
Build a sigma coordinate column.
Definition: coord_sigma.F90:64
coord_sigma::sigma_cs
Control structure containing required parameters for the sigma coordinate.
Definition: coord_sigma.F90:11
mom_error_handler::mom_error
subroutine, public mom_error(level, message, all_print)
This provides a convenient interface for writing an mpp_error message with run-time filter based on a...
Definition: MOM_error_handler.F90:72
coord_sigma::set_sigma_params
subroutine, public set_sigma_params(CS, min_thickness)
This subroutine can be used to set the parameters for the coord_sigma module.
Definition: coord_sigma.F90:53
coord_sigma::end_coord_sigma
subroutine, public end_coord_sigma(CS)
This subroutine deallocates memory in the control structure for the coord_sigma module.
Definition: coord_sigma.F90:43
coord_sigma
Regrid columns for the sigma coordinate.
Definition: coord_sigma.F90:2
mom_error_handler
Routines for error handling and I/O management.
Definition: MOM_error_handler.F90:2