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