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. | |
| 6 | module regrid_consts | |
| 7 | ||
| 8 | use MOM_error_handler, only : MOM_error, FATAL | |
| 9 | use MOM_string_functions, only : uppercase | |
| 10 | ||
| 11 | implicit 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. | |
| 15 | integer, parameter :: REGRIDDING_LAYER = 1 !< Layer mode identifier | |
| 16 | integer, parameter :: REGRIDDING_ZSTAR = 2 !< z* coordinates identifier | |
| 17 | integer, parameter :: REGRIDDING_RHO = 3 !< Density coordinates identifier | |
| 18 | integer, parameter :: REGRIDDING_SIGMA = 4 !< Sigma coordinates identifier | |
| 19 | integer, parameter :: REGRIDDING_ARBITRARY = 5 !< Arbitrary coordinates identifier | |
| 20 | integer, parameter :: REGRIDDING_HYCOM1 = 6 !< Simple HyCOM coordinates without BBL | |
| 21 | integer, parameter :: REGRIDDING_SIGMA_SHELF_ZSTAR = 8 !< Identifiered for z* coordinates at the bottom, | |
| 22 | !! sigma-near the top | |
| 23 | integer, parameter :: REGRIDDING_ADAPTIVE = 9 !< Adaptive coordinate mode identifier | |
| 24 | integer, parameter :: REGRIDDING_HYBGEN = 10 !< Hybgen coordinates identifier | |
| 25 | ||
| 26 | character(len=*), parameter :: REGRIDDING_LAYER_STRING = "LAYER" !< Layer string | |
| 27 | character(len=*), parameter :: REGRIDDING_ZSTAR_STRING_OLD = "Z*" !< z* string (legacy name) | |
| 28 | character(len=*), parameter :: REGRIDDING_ZSTAR_STRING = "ZSTAR" !< z* string | |
| 29 | character(len=*), parameter :: REGRIDDING_RHO_STRING = "RHO" !< Rho string | |
| 30 | character(len=*), parameter :: REGRIDDING_SIGMA_STRING = "SIGMA" !< Sigma string | |
| 31 | character(len=*), parameter :: REGRIDDING_ARBITRARY_STRING = "ARB" !< Arbitrary coordinates | |
| 32 | character(len=*), parameter :: REGRIDDING_HYCOM1_STRING = "HYCOM1" !< Hycom string | |
| 33 | character(len=*), parameter :: REGRIDDING_HYBGEN_STRING = "HYBGEN" !< Hybgen string | |
| 34 | character(len=*), parameter :: REGRIDDING_SIGMA_SHELF_ZSTAR_STRING = "SIGMA_SHELF_ZSTAR" !< Hybrid z*/sigma | |
| 35 | character(len=*), parameter :: REGRIDDING_ADAPTIVE_STRING = "ADAPTIVE" !< Adaptive coordinate string | |
| 36 | character(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. | |
| 39 | interface coordinateUnits | |
| 40 | module procedure coordinateUnitsI | |
| 41 | module procedure coordinateUnitsS | |
| 42 | end interface | |
| 43 | ||
| 44 | !> Returns true if the coordinate is dependent on the state density, returns false otherwise. | |
| 45 | interface state_dependent | |
| 46 | module procedure state_dependent_char | |
| 47 | module procedure state_dependent_int | |
| 48 | end interface | |
| 49 | ||
| 50 | contains | |
| 51 | ||
| 52 | !> Parse a string parameter specifying the coordinate mode and | |
| 53 | !! return the appropriate enumerated integer | |
| 54 | 618 | function coordinateMode(string) |
| 55 | integer :: coordinateMode !< Enumerated integer indicating coordinate mode | |
| 56 | character(len=*), intent(in) :: string !< String to indicate coordinate mode | |
| 57 | 618 | select case ( uppercase(trim(string)) ) |
| 58 | 0 | case (trim(REGRIDDING_LAYER_STRING)); coordinateMode = REGRIDDING_LAYER |
| 59 | 421 | case (trim(REGRIDDING_ZSTAR_STRING)); coordinateMode = REGRIDDING_ZSTAR |
| 60 | 0 | case (trim(REGRIDDING_ZSTAR_STRING_OLD)); coordinateMode = REGRIDDING_ZSTAR |
| 61 | 2 | case (trim(REGRIDDING_RHO_STRING)); coordinateMode = REGRIDDING_RHO |
| 62 | 195 | case (trim(REGRIDDING_SIGMA_STRING)); coordinateMode = REGRIDDING_SIGMA |
| 63 | 0 | case (trim(REGRIDDING_HYCOM1_STRING)); coordinateMode = REGRIDDING_HYCOM1 |
| 64 | 0 | case (trim(REGRIDDING_HYBGEN_STRING)); coordinateMode = REGRIDDING_HYBGEN |
| 65 | 0 | case (trim(REGRIDDING_ARBITRARY_STRING)); coordinateMode = REGRIDDING_ARBITRARY |
| 66 | 0 | case (trim(REGRIDDING_SIGMA_SHELF_ZSTAR_STRING)); coordinateMode = REGRIDDING_SIGMA_SHELF_ZSTAR |
| 67 | 0 | case (trim(REGRIDDING_ADAPTIVE_STRING)); coordinateMode = REGRIDDING_ADAPTIVE |
| 68 | case default ; call MOM_error(FATAL, "coordinateMode: "//& | |
| 69 | 1236 | "Unrecognized choice of coordinate ("//trim(string)//").") |
| 70 | end select | |
| 71 | 1236 | end function coordinateMode |
| 72 | ||
| 73 | !> Returns a string with the coordinate units associated with the | |
| 74 | !! enumerated integer, | |
| 75 | 3 | function coordinateUnitsI(coordMode) |
| 76 | character(len=16) :: coordinateUnitsI !< Units of coordinate | |
| 77 | integer, intent(in) :: coordMode !< Coordinate mode | |
| 78 | 3 | select case ( coordMode ) |
| 79 | 0 | case (REGRIDDING_LAYER); coordinateUnitsI = "kg m^-3" |
| 80 | 3 | case (REGRIDDING_ZSTAR); coordinateUnitsI = "m" |
| 81 | 0 | case (REGRIDDING_SIGMA_SHELF_ZSTAR); coordinateUnitsI = "m" |
| 82 | 0 | case (REGRIDDING_RHO); coordinateUnitsI = "kg m^-3" |
| 83 | 0 | case (REGRIDDING_SIGMA); coordinateUnitsI = "Non-dimensional" |
| 84 | 0 | case (REGRIDDING_HYCOM1); coordinateUnitsI = "m" |
| 85 | 0 | case (REGRIDDING_HYBGEN); coordinateUnitsI = "m" |
| 86 | 0 | case (REGRIDDING_ADAPTIVE); coordinateUnitsI = "m" |
| 87 | case default ; call MOM_error(FATAL, "coordinateUnts: "//& | |
| 88 | 3 | "Unrecognized coordinate mode.") |
| 89 | end select | |
| 90 | 3 | end function coordinateUnitsI |
| 91 | ||
| 92 | !> Returns a string with the coordinate units associated with the | |
| 93 | !! string defining the coordinate mode. | |
| 94 | 3 | function coordinateUnitsS(string) |
| 95 | character(len=16) :: coordinateUnitsS !< Units of coordinate | |
| 96 | character(len=*), intent(in) :: string !< Coordinate mode | |
| 97 | integer :: coordMode | |
| 98 | 6 | coordMode = coordinateMode(string) |
| 99 | 3 | coordinateUnitsS = coordinateUnitsI(coordMode) |
| 100 | 3 | end function coordinateUnitsS |
| 101 | ||
| 102 | !> Returns true if the coordinate is dependent on the state density, returns false otherwise. | |
| 103 | 2 | logical function state_dependent_char(string) |
| 104 | character(len=*), intent(in) :: string !< String to indicate coordinate mode | |
| 105 | ||
| 106 | 2 | state_dependent_char = state_dependent_int( coordinateMode(string) ) |
| 107 | ||
| 108 | 4 | end function state_dependent_char |
| 109 | ||
| 110 | !> Returns true if the coordinate is dependent on the state density, returns false otherwise. | |
| 111 | 4 | logical function state_dependent_int(mode) |
| 112 | integer, intent(in) :: mode !< Coordinate mode | |
| 113 | 4 | select case ( mode ) |
| 114 | 0 | case (REGRIDDING_LAYER); state_dependent_int = .true. |
| 115 | 4 | case (REGRIDDING_ZSTAR); state_dependent_int = .false. |
| 116 | 0 | case (REGRIDDING_SIGMA_SHELF_ZSTAR); state_dependent_int = .false. |
| 117 | 0 | case (REGRIDDING_RHO); state_dependent_int = .true. |
| 118 | 0 | case (REGRIDDING_SIGMA); state_dependent_int = .false. |
| 119 | 0 | case (REGRIDDING_HYCOM1); state_dependent_int = .true. |
| 120 | 0 | case (REGRIDDING_HYBGEN); state_dependent_int = .true. |
| 121 | 0 | case (REGRIDDING_ADAPTIVE); state_dependent_int = .true. |
| 122 | case default ; call MOM_error(FATAL, "state_dependent: "//& | |
| 123 | 4 | "Unrecognized choice of coordinate.") |
| 124 | end select | |
| 125 | 4 | end function state_dependent_int |
| 126 | ||
| 127 | end module regrid_consts |