Skip to content

Commit

Permalink
Merge pull request mom-ocean#1019 from Hallberg-NOAA/density_rescale
Browse files Browse the repository at this point in the history
MOM6: +Expand dimensional consistency testing
  • Loading branch information
marshallward authored Nov 13, 2019
2 parents 0c390a3 + ef462a8 commit 840881d
Show file tree
Hide file tree
Showing 92 changed files with 3,401 additions and 2,923 deletions.
181 changes: 100 additions & 81 deletions config_src/coupled_driver/MOM_surface_forcing_gfdl.F90

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions config_src/coupled_driver/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, time_start_upda
if (OS%use_ice_shelf) &
call shelf_calc_flux(OS%sfc_state, OS%fluxes, OS%Time, dt_coupling, OS%Ice_shelf_CSp)
if (OS%icebergs_alter_ocean) &
call iceberg_fluxes(OS%grid, OS%fluxes, OS%use_ice_shelf, &
call iceberg_fluxes(OS%grid, OS%US, OS%fluxes, OS%use_ice_shelf, &
OS%sfc_state, dt_coupling, OS%marine_ice_CSp)

#ifdef _USE_GENERIC_TRACER
Expand All @@ -541,7 +541,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, time_start_upda
if (OS%use_ice_shelf) &
call shelf_calc_flux(OS%sfc_state, OS%flux_tmp, OS%Time, dt_coupling, OS%Ice_shelf_CSp)
if (OS%icebergs_alter_ocean) &
call iceberg_fluxes(OS%grid, OS%flux_tmp, OS%use_ice_shelf, &
call iceberg_fluxes(OS%grid, OS%US, OS%flux_tmp, OS%use_ice_shelf, &
OS%sfc_state, dt_coupling, OS%marine_ice_CSp)

call fluxes_accumulate(OS%flux_tmp, OS%fluxes, dt_coupling, OS%grid, weight)
Expand All @@ -554,7 +554,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, time_start_upda

! The net mass forcing is not currently used in the MOM6 dynamics solvers, so this is may be unnecessary.
if (do_dyn .and. associated(OS%forces%net_mass_src) .and. .not.OS%forces%net_mass_src_set) &
call get_net_mass_forcing(OS%fluxes, OS%grid, OS%forces%net_mass_src)
call get_net_mass_forcing(OS%fluxes, OS%grid, OS%US, OS%forces%net_mass_src)

if (OS%use_waves .and. do_thermo) then
! For now, the waves are only updated on the thermodynamics steps, because that is where
Expand Down Expand Up @@ -654,7 +654,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, time_start_upda
if (OS%fluxes%fluxes_used .and. do_thermo) then
call enable_averaging(OS%fluxes%dt_buoy_accum, OS%Time, OS%diag)
call forcing_diagnostics(OS%fluxes, OS%sfc_state, OS%fluxes%dt_buoy_accum, &
OS%grid, OS%diag, OS%forcing_CSp%handles)
OS%grid, OS%US, OS%diag, OS%forcing_CSp%handles)
call disable_averaging(OS%diag)
endif

Expand Down
104 changes: 55 additions & 49 deletions config_src/ice_solo_driver/MOM_surface_forcing.F90

Large diffs are not rendered by default.

45 changes: 22 additions & 23 deletions config_src/ice_solo_driver/user_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,19 @@ module user_surface_forcing
logical :: use_temperature ! If true, temperature and salinity are used as
! state variables.
logical :: restorebuoy ! If true, use restoring surface buoyancy forcing.
real :: Rho0 ! The density used in the Boussinesq
! approximation [kg m-3].
real :: Rho0 ! The density used in the Boussinesq approximation [R ~> kg m-3].
real :: G_Earth ! The gravitational acceleration [L2 Z-1 T-2 ~> m s-2].
real :: Flux_const ! The restoring rate at the surface [m s-1].
real :: Flux_const ! The restoring rate at the surface [Z T-1 ~> m s-1].
real :: gust_const ! A constant unresolved background gustiness
! that contributes to ustar [Pa].
! that contributes to ustar [R Z L T-1 ~> Pa].

type(diag_ctrl), pointer :: diag ! A structure that is used to regulate the
! timing of diagnostic output.
end type user_surface_forcing_CS

contains

!> This subroutine sets the surface wind stresses, forces%taux and forces%tauy, in [Pa].
!> This subroutine sets the surface wind stresses, forces%taux and forces%tauy, in [R Z L T-2 ~> Pa].
!! These are the stresses in the direction of the model grid (i.e. the same
!! direction as the u- and v- velocities).
subroutine USER_wind_forcing(sfc_state, forces, day, G, US, CS)
Expand All @@ -104,7 +103,7 @@ subroutine USER_wind_forcing(sfc_state, forces, day, G, US, CS)
type(user_surface_forcing_CS), pointer :: CS !< A pointer to the control structure returned
!! by a previous call to user_surface_forcing_init

! This subroutine sets the surface wind stresses, forces%taux and forces%tauy [Pa].
! This subroutine sets the surface wind stresses, forces%taux and forces%tauy [R Z L T-2 ~> Pa].
! In addition, this subroutine can be used to set the surface friction velocity,
! forces%ustar [Z T-1 ~> m s-1], which is needed with a bulk mixed layer.

Expand All @@ -130,7 +129,8 @@ subroutine USER_wind_forcing(sfc_state, forces, day, G, US, CS)
! The i-loop extends to is-1 so that taux can be used later in the
! calculation of ustar - otherwise the lower bound would be Isq.
do j=js,je ; do I=is-1,Ieq
forces%taux(I,j) = G%mask2dCu(I,j) * 0.0 ! Change this to the desired expression.
! Change this to the desired expression.
forces%taux(I,j) = G%mask2dCu(I,j) * 0.0*US%kg_m3_to_R*US%m_s_to_L_T**2*US%L_to_Z
enddo ; enddo
do J=js-1,Jeq ; do i=is,ie
forces%tauy(i,J) = G%mask2dCv(i,J) * 0.0 ! Change this to the desired expression.
Expand All @@ -139,9 +139,9 @@ subroutine USER_wind_forcing(sfc_state, forces, day, G, US, CS)
! Set the surface friction velocity [Z s-1 ~> m s-1]. ustar is always positive.
if (associated(forces%ustar)) then ; do j=js,je ; do i=is,ie
! This expression can be changed if desired, but need not be.
forces%ustar(i,j) = US%m_to_Z*US%T_to_s * G%mask2dT(i,j) * sqrt(CS%gust_const/CS%Rho0 + &
sqrt(0.5*(forces%taux(I-1,j)**2 + forces%taux(I,j)**2) + &
0.5*(forces%tauy(i,J-1)**2 + forces%tauy(i,J)**2))/CS%Rho0)
forces%ustar(i,j) = G%mask2dT(i,j) * sqrt(US%L_to_Z * (CS%gust_const/CS%Rho0 + &
sqrt(0.5*(forces%taux(I-1,j)**2 + forces%taux(I,j)**2) + &
0.5*(forces%tauy(i,J-1)**2 + forces%tauy(i,J)**2))/CS%Rho0))
enddo ; enddo ; endif

end subroutine USER_wind_forcing
Expand Down Expand Up @@ -173,15 +173,15 @@ subroutine USER_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
! (fprec, lrunoff and frunoff) left as arrays full of zeros.
! Evap is usually negative and precip is usually positive. All heat fluxes
! are in W m-2 and positive for heat going into the ocean. All fresh water
! fluxes are in kg m-2 s-1 and positive for water moving into the ocean.
! fluxes are in [R Z T-1 ~> kg m-2 s-1] and positive for water moving into the ocean.

real :: Temp_restore ! The temperature that is being restored toward [C].
real :: Salin_restore ! The salinity that is being restored toward [ppt]
real :: density_restore ! The potential density that is being restored
! toward [kg m-3].
real :: rhoXcp ! The mean density times the heat capacity [J m-3 degC-1].
real :: buoy_rest_const ! A constant relating density anomalies to the
! restoring buoyancy flux [L2 m3 T-3 kg-1 ~> m5 s-3 kg-1].
! restoring buoyancy flux [L2 T-3 R-1 ~> m5 s-3 kg-1].

integer :: i, j, is, ie, js, je
integer :: isd, ied, jsd, jed
Expand Down Expand Up @@ -249,18 +249,17 @@ subroutine USER_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
call MOM_error(FATAL, "User_buoyancy_surface_forcing: " // &
"Temperature and salinity restoring used without modification." )

rhoXcp = CS%Rho0 * fluxes%C_p
rhoXcp = US%R_to_kg_m3*CS%Rho0 * fluxes%C_p
do j=js,je ; do i=is,ie
! Set Temp_restore and Salin_restore to the temperature (in degC) and
! salinity (in ppt or PSU) that are being restored toward.
Temp_restore = 0.0
Salin_restore = 0.0

fluxes%heat_added(i,j) = (G%mask2dT(i,j) * (rhoXcp * CS%Flux_const)) * &
fluxes%heat_added(i,j) = (G%mask2dT(i,j) * (rhoXcp * US%Z_to_m*US%s_to_T*CS%Flux_const)) * &
(Temp_restore - sfc_state%SST(i,j))
fluxes%vprec(i,j) = - (G%mask2dT(i,j) * (CS%Rho0*CS%Flux_const)) * &
((Salin_restore - sfc_state%SSS(i,j)) / &
(0.5 * (Salin_restore + sfc_state%SSS(i,j))))
((Salin_restore - sfc_state%SSS(i,j)) / (0.5 * (Salin_restore + sfc_state%SSS(i,j))))
enddo ; enddo
else
! When modifying the code, comment out this error message. It is here
Expand All @@ -269,14 +268,14 @@ subroutine USER_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
"Buoyancy restoring used without modification." )

! The -1 is because density has the opposite sign to buoyancy.
buoy_rest_const = -1.0 * (CS%G_Earth * US%m_to_Z*US%T_to_s*CS%Flux_const) / CS%Rho0
buoy_rest_const = -1.0 * (CS%G_Earth * CS%Flux_const) / CS%Rho0
do j=js,je ; do i=is,ie
! Set density_restore to an expression for the surface potential
! density [kg m-3] that is being restored toward.
density_restore = 1030.0

fluxes%buoy(i,j) = G%mask2dT(i,j) * buoy_rest_const * &
(density_restore - sfc_state%sfc_density(i,j))
US%kg_m3_to_R*(density_restore - sfc_state%sfc_density(i,j))
enddo ; enddo
endif
endif ! end RESTOREBUOY
Expand Down Expand Up @@ -319,10 +318,10 @@ subroutine USER_surface_forcing_init(Time, G, US, param_file, diag, CS)
"calculate accelerations and the mass for conservation "//&
"properties, or with BOUSSINSEQ false to convert some "//&
"parameters from vertical units of m to kg m-2.", &
units="kg m-3", default=1035.0)
units="kg m-3", default=1035.0, scale=US%R_to_kg_m3)
call get_param(param_file, mdl, "GUST_CONST", CS%gust_const, &
"The background gustiness in the winds.", units="Pa", &
default=0.02)
"The background gustiness in the winds.", &
units="Pa", default=0.02, scale=US%kg_m3_to_R*US%m_s_to_L_T**2*US%L_to_Z)

call get_param(param_file, mdl, "RESTOREBUOY", CS%restorebuoy, &
"If true, the buoyancy fluxes drive the model back "//&
Expand All @@ -332,8 +331,8 @@ subroutine USER_surface_forcing_init(Time, G, US, param_file, diag, CS)
call get_param(param_file, mdl, "FLUXCONST", CS%Flux_const, &
"The constant that relates the restoring surface fluxes "//&
"to the relative surface anomalies (akin to a piston "//&
"velocity). Note the non-MKS units.", units="m day-1", &
fail_if_missing=.true.)
"velocity). Note the non-MKS units.", &
units="m day-1", scale=US%m_to_Z*US%T_to_s, fail_if_missing=.true.)
! Convert CS%Flux_const from m day-1 to m s-1.
CS%Flux_const = CS%Flux_const / 86400.0
endif
Expand Down
8 changes: 4 additions & 4 deletions config_src/mct_driver/mom_ocean_model_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
endif
if (OS%icebergs_alter_ocean) then
if (do_dyn) &
call iceberg_forces(OS%grid, OS%forces, OS%use_ice_shelf, &
call iceberg_forces(OS%grid, OS%US, OS%forces, OS%use_ice_shelf, &
OS%sfc_state, dt_coupling, OS%marine_ice_CSp)
if (do_thermo) &
call iceberg_fluxes(OS%grid, OS%fluxes, OS%use_ice_shelf, &
call iceberg_fluxes(OS%grid, OS%US, OS%fluxes, OS%use_ice_shelf, &
OS%sfc_state, dt_coupling, OS%marine_ice_CSp)
endif

Expand Down Expand Up @@ -582,7 +582,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
endif

call set_derived_forcing_fields(OS%forces, OS%fluxes, OS%grid, OS%US, OS%GV%Rho0)
call set_net_mass_forcing(OS%fluxes, OS%forces, OS%grid)
call set_net_mass_forcing(OS%fluxes, OS%forces, OS%grid, OS%US)

if (OS%use_waves) then
call Update_Surface_Waves(OS%grid, OS%GV, OS%US, OS%time, ocean_coupling_time_step, OS%waves)
Expand Down Expand Up @@ -676,7 +676,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
if (OS%fluxes%fluxes_used) then
call enable_averaging(OS%fluxes%dt_buoy_accum, OS%Time, OS%diag)
call forcing_diagnostics(OS%fluxes, OS%sfc_state, OS%fluxes%dt_buoy_accum, &
OS%grid, OS%diag, OS%forcing_CSp%handles)
OS%grid, OS%US, OS%diag, OS%forcing_CSp%handles)
call disable_averaging(OS%diag)
endif

Expand Down
Loading

0 comments on commit 840881d

Please sign in to comment.