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 | !> A thin wrapper for Boussinesq/non-Boussinesq forms of the pressure force calculation. | |
| 6 | module MOM_PressureForce | |
| 7 | ||
| 8 | use MOM_diag_mediator, only : diag_ctrl, time_type | |
| 9 | use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe | |
| 10 | use MOM_file_parser, only : get_param, log_version, param_file_type | |
| 11 | use MOM_grid, only : ocean_grid_type | |
| 12 | use MOM_PressureForce_FV, only : PressureForce_FV_Bouss, PressureForce_FV_nonBouss | |
| 13 | use MOM_PressureForce_FV, only : PressureForce_FV_init | |
| 14 | use MOM_PressureForce_FV, only : PressureForce_FV_CS | |
| 15 | use MOM_PressureForce_Mont, only : PressureForce_Mont_Bouss, PressureForce_Mont_nonBouss | |
| 16 | use MOM_PressureForce_Mont, only : PressureForce_Mont_init | |
| 17 | use MOM_PressureForce_Mont, only : PressureForce_Mont_CS | |
| 18 | use MOM_self_attr_load, only : SAL_CS | |
| 19 | use MOM_tidal_forcing, only : tidal_forcing_CS | |
| 20 | use MOM_unit_scaling, only : unit_scale_type | |
| 21 | use MOM_variables, only : thermo_var_ptrs, accel_diag_ptrs | |
| 22 | use MOM_verticalGrid, only : verticalGrid_type | |
| 23 | use MOM_ALE, only: ALE_CS | |
| 24 | implicit none ; private | |
| 25 | ||
| 26 | #include <MOM_memory.h> | |
| 27 | ||
| 28 | public PressureForce, PressureForce_init | |
| 29 | ||
| 30 | !> Pressure force control structure | |
| 31 | type, public :: PressureForce_CS ; private | |
| 32 | logical :: Analytic_FV_PGF !< If true, use the analytic finite volume form | |
| 33 | !! (Adcroft et al., Ocean Mod. 2008) of the PGF. | |
| 34 | !> Control structure for the analytically integrated finite volume pressure force | |
| 35 | type(PressureForce_FV_CS) :: PressureForce_FV | |
| 36 | !> Control structure for the Montgomery potential form of pressure force | |
| 37 | type(PressureForce_Mont_CS) :: PressureForce_Mont | |
| 38 | end type PressureForce_CS | |
| 39 | ||
| 40 | contains | |
| 41 | ||
| 42 | !> A thin layer between the model and the Boussinesq and non-Boussinesq pressure force routines. | |
| 43 | 48 | subroutine PressureForce(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, ADp, p_atm, pbce, eta) |
| 44 | type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure | |
| 45 | type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure | |
| 46 | type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type | |
| 47 | real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & | |
| 48 | intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2] | |
| 49 | type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables | |
| 50 | real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), & | |
| 51 | intent(out) :: PFu !< Zonal pressure force acceleration [L T-2 ~> m s-2] | |
| 52 | real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), & | |
| 53 | intent(out) :: PFv !< Meridional pressure force acceleration [L T-2 ~> m s-2] | |
| 54 | type(PressureForce_CS), intent(inout) :: CS !< Pressure force control structure | |
| 55 | type(ALE_CS), pointer :: ALE_CSp !< ALE control structure | |
| 56 | type(accel_diag_ptrs), pointer :: ADp !< Acceleration diagnostic pointers | |
| 57 | real, dimension(:,:), pointer :: p_atm !< The pressure at the ice-ocean or | |
| 58 | !! atmosphere-ocean interface [R L2 T-2 ~> Pa]. | |
| 59 | real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & | |
| 60 | optional, intent(out) :: pbce !< The baroclinic pressure anomaly in each layer | |
| 61 | !! due to eta anomalies [L2 T-2 H-1 ~> m s-2 or m4 s-2 kg-1]. | |
| 62 | real, dimension(SZI_(G),SZJ_(G)), & | |
| 63 | optional, intent(out) :: eta !< The bottom mass used to calculate PFu and PFv, | |
| 64 | !! [H ~> m or kg m-2], with any tidal contributions. | |
| 65 | ||
| 66 | 24 | if (CS%Analytic_FV_PGF) then |
| 67 | 24 | if (GV%Boussinesq) then |
| 68 | call PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS%PressureForce_FV, & | |
| 69 | 24 | ALE_CSp, ADp, p_atm, pbce, eta) |
| 70 | else | |
| 71 | call PressureForce_FV_nonBouss(h, tv, PFu, PFv, G, GV, US, CS%PressureForce_FV, & | |
| 72 | 0 | ALE_CSp, ADp, p_atm, pbce, eta) |
| 73 | endif | |
| 74 | else | |
| 75 | 0 | if (GV%Boussinesq) then |
| 76 | call PressureForce_Mont_Bouss(h, tv, PFu, PFv, G, GV, US, CS%PressureForce_Mont, & | |
| 77 | 0 | p_atm, pbce, eta) |
| 78 | else | |
| 79 | call PressureForce_Mont_nonBouss(h, tv, PFu, PFv, G, GV, US, CS%PressureForce_Mont, & | |
| 80 | 0 | p_atm, pbce, eta) |
| 81 | endif | |
| 82 | endif | |
| 83 | ||
| 84 | 48 | end subroutine Pressureforce |
| 85 | ||
| 86 | !> Initialize the pressure force control structure | |
| 87 | 1 | subroutine PressureForce_init(Time, G, GV, US, param_file, diag, CS, ADp, SAL_CSp, tides_CSp) |
| 88 | type(time_type), target, intent(in) :: Time !< Current model time | |
| 89 | type(ocean_grid_type), intent(in) :: G !< Ocean grid structure | |
| 90 | type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure | |
| 91 | type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type | |
| 92 | type(param_file_type), intent(in) :: param_file !< Parameter file handles | |
| 93 | type(diag_ctrl), target, intent(inout) :: diag !< Diagnostics control structure | |
| 94 | type(PressureForce_CS), intent(inout) :: CS !< Pressure force control structure | |
| 95 | type(accel_diag_ptrs), pointer :: ADp !< Acceleration diagnostic pointers | |
| 96 | type(SAL_CS), intent(in), optional :: SAL_CSp !< SAL control structure | |
| 97 | type(tidal_forcing_CS), intent(in), optional :: tides_CSp !< Tide control structure | |
| 98 | #include "version_variable.h" | |
| 99 | character(len=40) :: mdl = "MOM_PressureForce" ! This module's name. | |
| 100 | ||
| 101 | ! Read all relevant parameters and write them to the model log. | |
| 102 | 1 | call log_version(param_file, mdl, version, "") |
| 103 | call get_param(param_file, mdl, "ANALYTIC_FV_PGF", CS%Analytic_FV_PGF, & | |
| 104 | "If true the pressure gradient forces are calculated "//& | |
| 105 | "with a finite volume form that analytically integrates "//& | |
| 106 | "the equations of state in pressure to avoid any "//& | |
| 107 | "possibility of numerical thermobaric instability, as "//& | |
| 108 | 1 | "described in Adcroft et al., O. Mod. (2008).", default=.true.) |
| 109 | ||
| 110 | 1 | if (CS%Analytic_FV_PGF) then |
| 111 | !$omp target enter data map(alloc: CS%PressureForce_FV) | |
| 112 | call PressureForce_FV_init(Time, G, GV, US, param_file, diag, & | |
| 113 | 1 | CS%PressureForce_FV, ADp, SAL_CSp, tides_CSp) |
| 114 | else | |
| 115 | call PressureForce_Mont_init(Time, G, GV, US, param_file, diag, & | |
| 116 | 0 | CS%PressureForce_Mont, SAL_CSp, tides_CSp) |
| 117 | endif | |
| 118 | !$omp target update to(CS) | |
| 119 | 1 | end subroutine PressureForce_init |
| 120 | ||
| 121 | !> \namespace mom_pressureforce | |
| 122 | !! | |
| 123 | !! This thin module provides a branch to two forms of the horizontal accelerations | |
| 124 | !! due to pressure gradients. The two options currently available are a | |
| 125 | !! Montgomery potential form (used in traditional isopycnal layer models), and the | |
| 126 | !! analytic finite volume form. | |
| 127 | ||
| 128 | 0 | end module MOM_PressureForce |