Skip to content

Commit

Permalink
+Rescaled the units of tv%salt_deficit
Browse files Browse the repository at this point in the history
  +Rescaled the units of tv%salt_deficit to units of [ppt R Z] for greater
dimensional consistency testing and for code simplification.  This also required
adding a unit_scale_type argument to MOM_thermo_chksum.  All answers are
bitwise identical, but there is a new subroutine argument.
  • Loading branch information
Hallberg-NOAA committed Oct 8, 2019
1 parent d518449 commit 629416b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,8 @@ subroutine step_MOM_tracer_dyn(CS, G, GV, US, h, Time_local)
if (associated(CS%tv%frazil)) call hchksum(CS%tv%frazil, &
"Pre-advection frazil", G%HI, haloshift=0)
if (associated(CS%tv%salt_deficit)) call hchksum(CS%tv%salt_deficit, &
"Pre-advection salt deficit", G%HI, haloshift=0)
! call MOM_thermo_chksum("Pre-advection ", CS%tv, G)
"Pre-advection salt deficit", G%HI, haloshift=0, scale=US%R_to_kg_m3*US%Z_to_m)
! call MOM_thermo_chksum("Pre-advection ", CS%tv, G, US)
call cpu_clock_end(id_clock_other)
endif

Expand Down Expand Up @@ -1186,7 +1186,7 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
call uvchksum("Pre-diabatic [uv]h", CS%uhtr, CS%vhtr, G%HI, &
haloshift=0, scale=GV%H_to_m*US%L_to_m**2)
! call MOM_state_chksum("Pre-diabatic ", u, v, h, CS%uhtr, CS%vhtr, G, GV, vel_scale=1.0)
call MOM_thermo_chksum("Pre-diabatic ", tv, G,haloshift=0)
call MOM_thermo_chksum("Pre-diabatic ", tv, G, US, haloshift=0)
call check_redundant("Pre-diabatic ", u, v, G)
call MOM_forcing_chksum("Pre-diabatic", fluxes, G, US, haloshift=0)
endif
Expand Down Expand Up @@ -1268,8 +1268,8 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
if (associated(tv%frazil)) call hchksum(tv%frazil, &
"Post-diabatic frazil", G%HI, haloshift=0)
if (associated(tv%salt_deficit)) call hchksum(tv%salt_deficit, &
"Post-diabatic salt deficit", G%HI, haloshift=0)
! call MOM_thermo_chksum("Post-diabatic ", tv, G)
"Post-diabatic salt deficit", G%HI, haloshift=0, scale=US%R_to_kg_m3*US%Z_to_m)
! call MOM_thermo_chksum("Post-diabatic ", tv, G, US)
call check_redundant("Post-diabatic ", u, v, G)
endif
call disable_averaging(CS%diag)
Expand Down Expand Up @@ -2910,7 +2910,7 @@ subroutine extract_surface_state(CS, sfc_state)

if (G%mask2dT(i,j)>0.) then
! instantaneous melt_potential [J m-2]
sfc_state%melt_potential(i,j) = CS%tv%C_p * CS%US%R_to_kg_m3*GV%Rho0 * delT(i)
sfc_state%melt_potential(i,j) = CS%tv%C_p * US%R_to_kg_m3*GV%Rho0 * delT(i)
endif
enddo
enddo ! end of j loop
Expand All @@ -2920,7 +2920,7 @@ subroutine extract_surface_state(CS, sfc_state)
!$OMP parallel do default(shared)
do j=js,je ; do i=is,ie
! Convert from gSalt to kgSalt
sfc_state%salt_deficit(i,j) = 1000.0 * CS%tv%salt_deficit(i,j)
sfc_state%salt_deficit(i,j) = 1000.0 * US%R_to_kg_m3*US%Z_to_m*CS%tv%salt_deficit(i,j)
enddo ; enddo
endif
if (allocated(sfc_state%TempxPmE) .and. associated(CS%tv%TempxPmE)) then
Expand Down
6 changes: 4 additions & 2 deletions src/core/MOM_checksum_packages.F90
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ end subroutine MOM_state_chksum_3arg
! =============================================================================

!> Write out chksums for the model's thermodynamic state variables.
subroutine MOM_thermo_chksum(mesg, tv, G, haloshift)
subroutine MOM_thermo_chksum(mesg, tv, G, US, haloshift)
character(len=*), intent(in) :: mesg !< A message that appears on the chksum lines.
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various
!! thermodynamic variables.
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
integer, optional, intent(in) :: haloshift !< The width of halos to check (default 0).

integer :: is, ie, js, je, nz, hs
Expand All @@ -131,7 +132,8 @@ subroutine MOM_thermo_chksum(mesg, tv, G, haloshift)
if (associated(tv%T)) call hchksum(tv%T, mesg//" T",G%HI,haloshift=hs)
if (associated(tv%S)) call hchksum(tv%S, mesg//" S",G%HI,haloshift=hs)
if (associated(tv%frazil)) call hchksum(tv%frazil, mesg//" frazil",G%HI,haloshift=hs)
if (associated(tv%salt_deficit)) call hchksum(tv%salt_deficit, mesg//" salt deficit",G%HI,haloshift=hs)
if (associated(tv%salt_deficit)) &
call hchksum(tv%salt_deficit, mesg//" salt deficit",G%HI,haloshift=hs, scale=US%R_to_kg_m3*US%Z_to_m)

end subroutine MOM_thermo_chksum

Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_variables.F90
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module MOM_variables
real, dimension(:,:), pointer :: salt_deficit => NULL()
!< The salt needed to maintain the ocean column
!! at a minimum salinity of MIN_SALINITY since the last time
!! that calculate_surface_state was called, [gSalt m-2].
!! that calculate_surface_state was called, [ppt R Z ~> gSalt m-2].
real, dimension(:,:), pointer :: TempxPmE => NULL()
!< The net inflow of water into the ocean times the
!! temperature at which this inflow occurs since the
Expand Down Expand Up @@ -465,7 +465,7 @@ subroutine MOM_thermovar_chksum(mesg, tv, G)
if (associated(tv%frazil)) &
call hchksum(tv%frazil, mesg//" tv%frazil", G%HI)
if (associated(tv%salt_deficit)) &
call hchksum(tv%salt_deficit, mesg//" tv%salt_deficit", G%HI)
call hchksum(tv%salt_deficit, mesg//" tv%salt_deficit", G%HI, scale=G%US%R_to_kg_m3*G%US%Z_to_m)
if (associated(tv%TempxPmE)) &
call hchksum(tv%TempxPmE, mesg//" tv%TempxPmE", G%HI, scale=G%US%R_to_kg_m3*G%US%Z_to_m)
end subroutine MOM_thermovar_chksum
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics/MOM_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ subroutine register_surface_diags(Time, G, IDs, diag, tv)
endif

IDs%id_salt_deficit = register_diag_field('ocean_model', 'salt_deficit', diag%axesT1, Time, &
'Salt sink in ocean due to ice flux', 'psu m-2 s-1')
'Salt sink in ocean due to ice flux', 'psu m-2 s-1', conversion=G%US%R_to_kg_m3*G%US%Z_to_m)
IDs%id_Heat_PmE = register_diag_field('ocean_model', 'Heat_PmE', diag%axesT1, Time, &
'Heat flux into ocean from mass flux into ocean', 'W m-2', conversion=G%US%R_to_kg_m3*G%US%Z_to_m)
IDs%id_intern_heat = register_diag_field('ocean_model', 'internal_heat', diag%axesT1, Time,&
Expand Down
6 changes: 3 additions & 3 deletions src/parameterizations/vertical/MOM_diabatic_aux.F90
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ subroutine adjust_salt(h, tv, G, GV, CS, halo)
integer, optional, intent(in) :: halo !< Halo width over which to work

! local variables
real :: salt_add_col(SZI_(G),SZJ_(G)) !< The accumulated salt requirement [gSalt m-2]
real :: salt_add_col(SZI_(G),SZJ_(G)) !< The accumulated salt requirement [ppt R Z ~> gSalt m-2]
real :: S_min !< The minimum salinity [ppt].
real :: mc !< A layer's mass [kg m-2].
real :: mc !< A layer's mass [R Z ~> kg m-2].
integer :: i, j, k, is, ie, js, je, nz

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke
Expand All @@ -355,7 +355,7 @@ subroutine adjust_salt(h, tv, G, GV, CS, halo)
do k=nz,1,-1 ; do i=is,ie
if ( (G%mask2dT(i,j) > 0.0) .and. &
((tv%S(i,j,k) < S_min) .or. (salt_add_col(i,j) > 0.0)) ) then
mc = GV%H_to_kg_m2 * h(i,j,k)
mc = GV%H_to_RZ * h(i,j,k)
if (h(i,j,k) <= 10.0*GV%Angstrom_H) then
! Very thin layers should not be adjusted by the salt flux
if (tv%S(i,j,k) < S_min) then
Expand Down

0 comments on commit 629416b

Please sign in to comment.