Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct wave and spherical harmonics unit descriptions #273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
endif

if (present(waves_CSp)) then
call waves_register_restarts(waves_CSp, HI, GV, param_file, restart_CSp)
call waves_register_restarts(waves_CSp, HI, GV, US, param_file, restart_CSp)
endif

if (use_temperature) then
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5324,11 +5324,11 @@ subroutine update_segment_tracer_reservoirs(G, GV, uhr, vhr, h, OBC, dt, Reg)
integer :: i, j, k, m, n, ntr, nz
integer :: ishift, idir, jshift, jdir
real :: b_in, b_out ! The 0 and 1 switch for tracer reservoirs
! 1 if the length scale of reservoir is zero [nodim]
! 1 if the length scale of reservoir is zero [nondim]
real :: a_in, a_out ! The 0 and 1(-1) switch for reservoir source weights
! e.g. a_in is -1 only if b_in ==1 and uhr or vhr is inward
! e.g. a_out is 1 only if b_out==1 and uhr or vhr is outward
! It's clear that a_in and a_out cannot be both non-zero [nodim]
! It's clear that a_in and a_out cannot be both non-zero [nondim]
nz = GV%ke
ntr = Reg%ntr

Expand Down
50 changes: 25 additions & 25 deletions src/parameterizations/lateral/MOM_spherical_harmonics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module MOM_spherical_harmonics
!> Control structure for spherical harmonic transforms
type, public :: sht_CS ; private
logical :: initialized = .False. !< True if this control structure has been initialized.
integer :: ndegree !< Maximum degree of the spherical harmonics [nodim].
integer :: ndegree !< Maximum degree of the spherical harmonics [nondim].
integer :: lmax !< Number of associated Legendre polynomials of nonnegative m
!! [lmax=(ndegree+1)*(ndegree+2)/2] [nodim].
!! [lmax=(ndegree+1)*(ndegree+2)/2] [nondim].
real, allocatable :: cos_clatT(:,:) !< Precomputed cosine of colatitude at the t-cells [nondim].
real, allocatable :: Pmm(:,:,:) !< Precomputed associated Legendre polynomials (m=n) at the t-cells [nondim].
real, allocatable :: cos_lonT(:,:,:), & !< Precomputed cosine factors at the t-cells [nondim].
Expand All @@ -46,18 +46,18 @@ subroutine spherical_harmonics_forward(G, CS, var, Snm_Re, Snm_Im, Nd)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(sht_CS), intent(inout) :: CS !< Control structure for SHT
real, dimension(SZI_(G),SZJ_(G)), &
intent(in) :: var !< Input 2-D variable []
real, intent(out) :: Snm_Re(:) !< SHT coefficients for the real modes (cosine)
real, intent(out) :: Snm_Im(:) !< SHT coefficients for the imaginary modes (sine)
intent(in) :: var !< Input 2-D variable [A]
real, intent(out) :: Snm_Re(:) !< SHT coefficients for the real modes (cosine) [A]
real, intent(out) :: Snm_Im(:) !< SHT coefficients for the imaginary modes (sine) [A]
integer, optional, intent(in) :: Nd !< Maximum degree of the spherical harmonics
!! overriding ndegree in the CS [nondim]
! local variables
integer :: Nmax ! Local copy of the maximum degree of the spherical harmonics [nodim]
integer :: Ltot ! Local copy of the number of spherical harmonics [nodim]
integer :: Nmax ! Local copy of the maximum degree of the spherical harmonics [nondim]
integer :: Ltot ! Local copy of the number of spherical harmonics [nondim]
real, dimension(SZI_(G),SZJ_(G)) :: &
pmn, & ! Current associated Legendre polynomials of degree n and order m [nodim]
pmnm1, & ! Associated Legendre polynomials of degree n-1 and order m [nodim]
pmnm2 ! Associated Legendre polynomials of degree n-2 and order m [nodim]
pmn, & ! Current associated Legendre polynomials of degree n and order m [nondim]
pmnm1, & ! Associated Legendre polynomials of degree n-1 and order m [nondim]
pmnm2 ! Associated Legendre polynomials of degree n-2 and order m [nondim]
integer :: i, j, k
integer :: is, ie, js, je, isd, ied, jsd, jed
integer :: m, n, l
Expand Down Expand Up @@ -143,19 +143,19 @@ end subroutine spherical_harmonics_forward
subroutine spherical_harmonics_inverse(G, CS, Snm_Re, Snm_Im, var, Nd)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(sht_CS), intent(in) :: CS !< Control structure for SHT
real, intent(in) :: Snm_Re(:) !< SHT coefficients for the real modes (cosine)
real, intent(in) :: Snm_Im(:) !< SHT coefficients for the imaginary modes (sine)
real, intent(in) :: Snm_Re(:) !< SHT coefficients for the real modes (cosine) [A]
real, intent(in) :: Snm_Im(:) !< SHT coefficients for the imaginary modes (sine) [A]
real, dimension(SZI_(G),SZJ_(G)), &
intent(out) :: var !< Output 2-D variable []
intent(out) :: var !< Output 2-D variable [A]
integer, optional, intent(in) :: Nd !< Maximum degree of the spherical harmonics
!! overriding ndegree in the CS [nondim]
! local variables
integer :: Nmax ! Local copy of the maximum degree of the spherical harmonics [nodim]
real :: mFac ! A constant multiplier. mFac = 1 (if m==0) or 2 (if m>0) [nodim]
integer :: Nmax ! Local copy of the maximum degree of the spherical harmonics [nondim]
real :: mFac ! A constant multiplier. mFac = 1 (if m==0) or 2 (if m>0) [nondim]
real, dimension(SZI_(G),SZJ_(G)) :: &
pmn, & ! Current associated Legendre polynomials of degree n and order m [nodim]
pmnm1, & ! Associated Legendre polynomials of degree n-1 and order m [nodim]
pmnm2 ! Associated Legendre polynomials of degree n-2 and order m [nodim]
pmn, & ! Current associated Legendre polynomials of degree n and order m [nondim]
pmnm1, & ! Associated Legendre polynomials of degree n-1 and order m [nondim]
pmnm2 ! Associated Legendre polynomials of degree n-2 and order m [nondim]
integer :: i, j, k
integer :: is, ie, js, je, isd, ied, jsd, jed
integer :: m, n, l
Expand Down Expand Up @@ -210,7 +210,7 @@ subroutine spherical_harmonics_init(G, param_file, CS)
type(sht_CS), intent(inout) :: CS !< Control structure for spherical harmonic transforms

! local variables
real, parameter :: PI = 4.0*atan(1.0) ! 3.1415926... calculated as 4*atan(1) [nodim]
real, parameter :: PI = 4.0*atan(1.0) ! 3.1415926... calculated as 4*atan(1) [nondim]
real, parameter :: RADIAN = PI / 180.0 ! Degree to Radian constant [rad/degree]
real, dimension(SZI_(G),SZJ_(G)) :: sin_clatT ! sine of colatitude at the t-cells [nondim].
real :: Pmm_coef ! = sqrt{ 1.0/(4.0*PI) * prod[(2k+1)/2k)] } [nondim].
Expand Down Expand Up @@ -305,18 +305,18 @@ end subroutine spherical_harmonics_end

!> Calculates the number of real elements (cosine) of spherical harmonics given maximum degree Nd.
function calc_lmax(Nd) result(lmax)
integer :: lmax !< Number of real spherical harmonic modes [nodim]
integer, intent(in) :: Nd !< Maximum degree [nodim]
integer :: lmax !< Number of real spherical harmonic modes [nondim]
integer, intent(in) :: Nd !< Maximum degree [nondim]

lmax = (Nd+2) * (Nd+1) / 2
end function calc_lmax

!> Calculates the one-dimensional index number at (n=0, m=m), given order m and maximum degree Nd.
!! It is sequenced with degree (n) changing first and order (m) changing second.
function order2index(m, Nd) result(l)
integer :: l !< One-dimensional index number [nodim]
integer, intent(in) :: m !< Current order number [nodim]
integer, intent(in) :: Nd !< Maximum degree [nodim]
integer :: l !< One-dimensional index number [nondim]
integer, intent(in) :: m !< Current order number [nondim]
integer, intent(in) :: Nd !< Maximum degree [nondim]

l = ((Nd+1) + (Nd+1-(m-1)))*m/2 + 1
end function order2index
Expand Down Expand Up @@ -379,4 +379,4 @@ end function order2index
!! Schaeffer, N., 2013. Efficient spherical harmonic transforms aimed at pseudospectral numerical simulations.
!! Geochemistry, Geophysics, Geosystems, 14(3), pp.751-758.
!! https://doi.org/10.1002/ggge.20071
end module MOM_spherical_harmonics
end module MOM_spherical_harmonics
2 changes: 1 addition & 1 deletion src/parameterizations/vertical/MOM_set_diffusivity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ subroutine set_diffusivity_init(Time, G, GV, US, param_file, diag, CS, int_tide_
! This include declares and sets the variable "version".
# include "version_variable.h"
character(len=40) :: mdl = "MOM_set_diffusivity" ! This module's name.
real :: vonKar ! The von Karman constant as used for mixed layer viscosity [nomdim]
real :: vonKar ! The von Karman constant as used for mixed layer viscosity [nondim]
real :: omega_frac_dflt ! The default value for the fraction of the absolute rotation rate
! that is used in place of the absolute value of the local Coriolis
! parameter in the denominator of some expressions [nondim]
Expand Down
2 changes: 1 addition & 1 deletion src/parameterizations/vertical/MOM_vert_friction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module MOM_vert_friction
real :: Hbbl !< The static bottom boundary layer thickness [H ~> m or kg m-2].
real :: Kv_extra_bbl !< An extra vertical viscosity in the bottom boundary layer of thickness
!! Hbbl when there is not a bottom drag law in use [Z2 T-1 ~> m2 s-1].
real :: vonKar !< The von Karman constant as used for mixed layer viscosity [nomdim]
real :: vonKar !< The von Karman constant as used for mixed layer viscosity [nondim]

real :: maxvel !< Velocity components greater than maxvel are truncated [L T-1 ~> m s-1].
real :: vel_underflow !< Velocity components smaller than vel_underflow
Expand Down
56 changes: 28 additions & 28 deletions src/user/MOM_wave_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module MOM_wave_interface
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : thermo_var_ptrs, surface
use MOM_verticalgrid, only : verticalGrid_type
use MOM_restart, only : register_restart_field, MOM_restart_CS
use MOM_restart, only : register_restart_pair, MOM_restart_CS

implicit none ; private

Expand Down Expand Up @@ -73,27 +73,27 @@ module MOM_wave_interface
!! Horizontal -> V points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
ddt_Us_x !< 3d time tendency of zonal Stokes drift profile [m s-1]
ddt_Us_x !< 3d time tendency of zonal Stokes drift profile [L T-2 ~> m s-2]
!! Horizontal -> U points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
ddt_Us_y !< 3d time tendency of meridional Stokes drift profile [m s-1]
ddt_Us_y !< 3d time tendency of meridional Stokes drift profile [L T-2 ~> m s-2]
!! Horizontal -> V points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
Us_x_from_ddt !< Check of 3d zonal Stokes drift profile [m s-1]
Us_x_from_ddt !< Check of 3d zonal Stokes drift profile [L T-1 ~> m s-1]
!! Horizontal -> U points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
Us_y_from_ddt !< Check of 3d meridional Stokes drift profile [m s-1]
Us_y_from_ddt !< Check of 3d meridional Stokes drift profile [L T-1 ~> m s-1]
!! Horizontal -> V points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
Us_x_prev !< 3d zonal Stokes drift profile, previous dynamics call [m s-1]
Us_x_prev !< 3d zonal Stokes drift profile, previous dynamics call [L T-1 ~> m s-1]
!! Horizontal -> U points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
Us_y_prev !< 3d meridional Stokes drift profile, previous dynamics call [m s-1]
Us_y_prev !< 3d meridional Stokes drift profile, previous dynamics call [L T-1 ~> m s-1]
!! Horizontal -> V points
!! Vertical -> Mid-points
real, allocatable, dimension(:,:,:), public :: &
Expand Down Expand Up @@ -450,8 +450,8 @@ subroutine MOM_wave_interface_init(time, G, GV, US, param_file, CS, diag, restar
call get_param(param_file, mdl, "MIN_LANGMUIR", CS%La_min, &
"A minimum value for all Langmuir numbers that is not physical, "//&
"but is likely only encountered when the wind is very small and "//&
"therefore its effects should be mostly benign.", units="nondim", &
default=0.05)
"therefore its effects should be mostly benign.", &
units="nondim", default=0.05)

! Allocate and initialize
! a. Stokes driftProfiles
Expand Down Expand Up @@ -487,9 +487,9 @@ subroutine MOM_wave_interface_init(time, G, GV, US, param_file, CS, diag, restar
CS%diag%axesCuL,Time,'3d Stokes drift (x)', 'm s-1', conversion=US%L_T_to_m_s)
if (CS%Stokes_DDT) then
CS%id_ddt_3dstokes_y = register_diag_field('ocean_model','dvdt_Stokes', &
CS%diag%axesCvL,Time,'d/dt Stokes drift (meridional)','m s-2')
CS%diag%axesCvL,Time,'d/dt Stokes drift (meridional)', 'm s-2', conversion=US%L_T2_to_m_s2)
CS%id_ddt_3dstokes_x = register_diag_field('ocean_model','dudt_Stokes', &
CS%diag%axesCuL,Time,'d/dt Stokes drift (zonal)','m s-2')
CS%diag%axesCuL,Time,'d/dt Stokes drift (zonal)', 'm s-2', conversion=US%L_T2_to_m_s2)
CS%id_3dstokes_y_from_ddt = register_diag_field('ocean_model','3d_stokes_y_from_ddt', &
CS%diag%axesCvL,Time,'3d Stokes drift from ddt (y)', 'm s-1', conversion=US%L_T_to_m_s)
CS%id_3dstokes_x_from_ddt = register_diag_field('ocean_model','3d_stokes_x_from_ddt', &
Expand Down Expand Up @@ -614,7 +614,7 @@ subroutine Update_Stokes_Drift(G, GV, US, CS, h, ustar, dt, dynamics_step)
intent(in) :: h !< Thickness [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G)), &
intent(in) :: ustar !< Wind friction velocity [Z T-1 ~> m s-1].
real, intent(in) :: dt !< Time-step for computing Stokes-tendency
real, intent(in) :: dt !< Time-step for computing Stokes-tendency [T ~> s]
logical, intent(in) :: dynamics_step !< True if this call is on a dynamics step

! Local Variables
Expand All @@ -629,7 +629,7 @@ subroutine Update_Stokes_Drift(G, GV, US, CS, h, ustar, dt, dynamics_step)
real :: PI ! 3.1415926535...
real :: La ! The local Langmuir number [nondim]
integer :: ii, jj, kk, b, iim1, jjm1
real :: idt ! 1 divided by the time step
real :: idt ! 1 divided by the time step [T-1 ~> s-1]

if (CS%WaveMethod==EFACTOR) return

Expand Down Expand Up @@ -1564,13 +1564,13 @@ subroutine Stokes_PGF(G, GV, h, u, v, PFu_Stokes, PFv_Stokes, CS )
real, dimension(SZI_(G),SZJ_(G),SZK_(G)),&
intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2]
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
intent(in) :: u !< Lagrangian Velocity i-component [m s-1]
intent(in) :: u !< Lagrangian Velocity i-component [L T-1 ~> m s-1]
real, dimension(SZI_(G),SZJB_(G),SZK_(G)), &
intent(in) :: v !< Lagrangian Velocity j-component [m s-1]
intent(in) :: v !< Lagrangian Velocity j-component [L T-1 ~> m s-1]
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
intent(out) :: PFu_Stokes !< PGF Stokes-shear i-component [L T-2]
intent(out) :: PFu_Stokes !< PGF Stokes-shear i-component [L T-2 ~> m s-2]
real, dimension(SZI_(G),SZJB_(G),SZK_(G)), &
intent(out) :: PFv_Stokes !< PGF Stokes-shear j-component [m s-1]
intent(out) :: PFv_Stokes !< PGF Stokes-shear j-component [L T-2 ~> m s-2]
type(Wave_parameters_CS), &
pointer :: CS !< Surface wave related control structure.

Expand Down Expand Up @@ -1889,10 +1889,11 @@ subroutine Waves_end(CS)
end subroutine Waves_end

!> Register wave restart fields. To be called before MOM_wave_interface_init
subroutine waves_register_restarts(CS, HI, GV, param_file, restart_CSp)
subroutine waves_register_restarts(CS, HI, GV, US, param_file, restart_CSp)
type(wave_parameters_CS), pointer :: CS !< Wave parameter Control structure
type(hor_index_type), intent(inout) :: HI !< Grid structure
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(param_file_type), intent(in) :: param_file !< Input parameter structure
type(MOM_restart_CS), pointer :: restart_CSp !< Restart structure, data intent(inout)
! Local variables
Expand All @@ -1916,21 +1917,20 @@ subroutine waves_register_restarts(CS, HI, GV, param_file, restart_CSp)

if (.not.(use_waves .or. StatisticalWaves)) return

call get_param(param_file,mdl,"STOKES_DDT",time_tendency_term, do_not_log=.true., default=.false.)
call get_param(param_file, mdl, "STOKES_DDT", time_tendency_term, do_not_log=.true., default=.false.)

if (time_tendency_term) then
! Allocate wave fields needed for restart file
allocate(CS%Us_x_prev(HI%isdB:HI%IedB,HI%jsd:HI%jed,GV%ke))
CS%Us_x_prev(:,:,:) = 0.0
allocate(CS%Us_y_prev(HI%isd:HI%Ied,HI%jsdB:HI%jedB,GV%ke))
CS%Us_y_prev(:,:,:) = 0.0
! Register to restart
allocate(CS%Us_x_prev(HI%isdB:HI%IedB,HI%jsd:HI%jed,GV%ke), source=0.0)
allocate(CS%Us_y_prev(HI%isd:HI%Ied,HI%jsdB:HI%jedB,GV%ke), source=0.0)

! Register to restart files. If these are not found in a restart file, they stay 0.
vd(1) = var_desc("Us_x_prev", "m s-1", "3d zonal Stokes drift profile",&
hor_grid='u',z_grid='L')
hor_grid='u', z_grid='L')
vd(2) = var_desc("Us_y_prev", "m s-1", "3d meridional Stokes drift profile",&
hor_grid='v',z_grid='L')
call register_restart_field(CS%US_x_prev(:,:,:), vd(1), .false., restart_CSp)
call register_restart_field(CS%US_y_prev(:,:,:), vd(2), .false., restart_CSp)
hor_grid='v', z_grid='L')
call register_restart_pair(CS%US_x_prev, CS%US_y_prev, vd(1), vd(2), .false., &
restart_CSp, conversion=US%L_T_to_m_s)
endif

end subroutine waves_register_restarts
Expand Down
2 changes: 1 addition & 1 deletion src/user/Rossby_front_2d_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ real function dTdy( G, dT, lat, US )
real :: PI ! The ratio of the circumference of a circle to its diameter [nondim]
real :: dHML ! The range of the mixed layer depths [Z ~> m]
real :: dHdy ! The mixed layer depth gradient [Z L-1 ~> m m-1]
real :: km_to_L ! Horizontal axis unit conversion factor when AXIS_UNITS = 'k' (1000 m) [L km-1]
real :: km_to_L ! Horizontal axis unit conversion factor when AXIS_UNITS = 'k' (1000 m) [L km-1 ~> 1000]

PI = 4.0 * atan(1.0)
km_to_L = 1.0e3*US%m_to_L
Expand Down
Loading