← back to index

src/ALE/regrid_consts.F90

portedportable, not yet portedexecuted, not portableexecutable, not hit by this run

1! This file is part of MOM6, the Modular Ocean Model version 6.
2! See the LICENSE file for licensing information.
3! SPDX-License-Identifier: Apache-2.0
4
5!> Contains constants for interpreting input parameters that control regridding.
6module regrid_consts
7
8use MOM_error_handler, only : MOM_error, FATAL
9use MOM_string_functions, only : uppercase
10
11implicit none ; public
12
13! List of regridding types. These should be consecutive and starting at 1.
14! This allows them to be used as array indices.
15integer, parameter :: REGRIDDING_LAYER = 1 !< Layer mode identifier
16integer, parameter :: REGRIDDING_ZSTAR = 2 !< z* coordinates identifier
17integer, parameter :: REGRIDDING_RHO = 3 !< Density coordinates identifier
18integer, parameter :: REGRIDDING_SIGMA = 4 !< Sigma coordinates identifier
19integer, parameter :: REGRIDDING_ARBITRARY = 5 !< Arbitrary coordinates identifier
20integer, parameter :: REGRIDDING_HYCOM1 = 6 !< Simple HyCOM coordinates without BBL
21integer, parameter :: REGRIDDING_SIGMA_SHELF_ZSTAR = 8 !< Identifiered for z* coordinates at the bottom,
22 !! sigma-near the top
23integer, parameter :: REGRIDDING_ADAPTIVE = 9 !< Adaptive coordinate mode identifier
24integer, parameter :: REGRIDDING_HYBGEN = 10 !< Hybgen coordinates identifier
25
26character(len=*), parameter :: REGRIDDING_LAYER_STRING = "LAYER" !< Layer string
27character(len=*), parameter :: REGRIDDING_ZSTAR_STRING_OLD = "Z*" !< z* string (legacy name)
28character(len=*), parameter :: REGRIDDING_ZSTAR_STRING = "ZSTAR" !< z* string
29character(len=*), parameter :: REGRIDDING_RHO_STRING = "RHO" !< Rho string
30character(len=*), parameter :: REGRIDDING_SIGMA_STRING = "SIGMA" !< Sigma string
31character(len=*), parameter :: REGRIDDING_ARBITRARY_STRING = "ARB" !< Arbitrary coordinates
32character(len=*), parameter :: REGRIDDING_HYCOM1_STRING = "HYCOM1" !< Hycom string
33character(len=*), parameter :: REGRIDDING_HYBGEN_STRING = "HYBGEN" !< Hybgen string
34character(len=*), parameter :: REGRIDDING_SIGMA_SHELF_ZSTAR_STRING = "SIGMA_SHELF_ZSTAR" !< Hybrid z*/sigma
35character(len=*), parameter :: REGRIDDING_ADAPTIVE_STRING = "ADAPTIVE" !< Adaptive coordinate string
36character(len=*), parameter :: DEFAULT_COORDINATE_MODE = REGRIDDING_LAYER_STRING !< Default coordinate mode
37
38!> Returns a string with the coordinate units associated with the coordinate mode.
39interface coordinateUnits
40 module procedure coordinateUnitsI
41 module procedure coordinateUnitsS
42end interface
43
44!> Returns true if the coordinate is dependent on the state density, returns false otherwise.
45interface state_dependent
46 module procedure state_dependent_char
47 module procedure state_dependent_int
48end interface
49
50contains
51
52!> Parse a string parameter specifying the coordinate mode and
53!! return the appropriate enumerated integer
54618function coordinateMode(string)
55 integer :: coordinateMode !< Enumerated integer indicating coordinate mode
56 character(len=*), intent(in) :: string !< String to indicate coordinate mode
57618 select case ( uppercase(trim(string)) )
580 case (trim(REGRIDDING_LAYER_STRING)); coordinateMode = REGRIDDING_LAYER
59421 case (trim(REGRIDDING_ZSTAR_STRING)); coordinateMode = REGRIDDING_ZSTAR
600 case (trim(REGRIDDING_ZSTAR_STRING_OLD)); coordinateMode = REGRIDDING_ZSTAR
612 case (trim(REGRIDDING_RHO_STRING)); coordinateMode = REGRIDDING_RHO
62195 case (trim(REGRIDDING_SIGMA_STRING)); coordinateMode = REGRIDDING_SIGMA
630 case (trim(REGRIDDING_HYCOM1_STRING)); coordinateMode = REGRIDDING_HYCOM1
640 case (trim(REGRIDDING_HYBGEN_STRING)); coordinateMode = REGRIDDING_HYBGEN
650 case (trim(REGRIDDING_ARBITRARY_STRING)); coordinateMode = REGRIDDING_ARBITRARY
660 case (trim(REGRIDDING_SIGMA_SHELF_ZSTAR_STRING)); coordinateMode = REGRIDDING_SIGMA_SHELF_ZSTAR
670 case (trim(REGRIDDING_ADAPTIVE_STRING)); coordinateMode = REGRIDDING_ADAPTIVE
68 case default ; call MOM_error(FATAL, "coordinateMode: "//&
691236 "Unrecognized choice of coordinate ("//trim(string)//").")
70 end select
711236end function coordinateMode
72
73!> Returns a string with the coordinate units associated with the
74!! enumerated integer,
753function coordinateUnitsI(coordMode)
76 character(len=16) :: coordinateUnitsI !< Units of coordinate
77 integer, intent(in) :: coordMode !< Coordinate mode
783 select case ( coordMode )
790 case (REGRIDDING_LAYER); coordinateUnitsI = "kg m^-3"
803 case (REGRIDDING_ZSTAR); coordinateUnitsI = "m"
810 case (REGRIDDING_SIGMA_SHELF_ZSTAR); coordinateUnitsI = "m"
820 case (REGRIDDING_RHO); coordinateUnitsI = "kg m^-3"
830 case (REGRIDDING_SIGMA); coordinateUnitsI = "Non-dimensional"
840 case (REGRIDDING_HYCOM1); coordinateUnitsI = "m"
850 case (REGRIDDING_HYBGEN); coordinateUnitsI = "m"
860 case (REGRIDDING_ADAPTIVE); coordinateUnitsI = "m"
87 case default ; call MOM_error(FATAL, "coordinateUnts: "//&
883 "Unrecognized coordinate mode.")
89 end select
903end function coordinateUnitsI
91
92!> Returns a string with the coordinate units associated with the
93!! string defining the coordinate mode.
943function coordinateUnitsS(string)
95 character(len=16) :: coordinateUnitsS !< Units of coordinate
96 character(len=*), intent(in) :: string !< Coordinate mode
97 integer :: coordMode
986 coordMode = coordinateMode(string)
993 coordinateUnitsS = coordinateUnitsI(coordMode)
1003end function coordinateUnitsS
101
102!> Returns true if the coordinate is dependent on the state density, returns false otherwise.
1032logical function state_dependent_char(string)
104 character(len=*), intent(in) :: string !< String to indicate coordinate mode
105
1062 state_dependent_char = state_dependent_int( coordinateMode(string) )
107
1084end function state_dependent_char
109
110!> Returns true if the coordinate is dependent on the state density, returns false otherwise.
1114logical function state_dependent_int(mode)
112 integer, intent(in) :: mode !< Coordinate mode
1134 select case ( mode )
1140 case (REGRIDDING_LAYER); state_dependent_int = .true.
1154 case (REGRIDDING_ZSTAR); state_dependent_int = .false.
1160 case (REGRIDDING_SIGMA_SHELF_ZSTAR); state_dependent_int = .false.
1170 case (REGRIDDING_RHO); state_dependent_int = .true.
1180 case (REGRIDDING_SIGMA); state_dependent_int = .false.
1190 case (REGRIDDING_HYCOM1); state_dependent_int = .true.
1200 case (REGRIDDING_HYBGEN); state_dependent_int = .true.
1210 case (REGRIDDING_ADAPTIVE); state_dependent_int = .true.
122 case default ; call MOM_error(FATAL, "state_dependent: "//&
1234 "Unrecognized choice of coordinate.")
124 end select
1254end function state_dependent_int
126
127end module regrid_consts