Skip to content

Commit f486837

Browse files
committed
(*)Consolidate conversion of 4 salt tendency diags
Collected the conversion factors for the 4 salt tendency diagnostics diabatic_salt_tendency, diabatic_salt_tendency_2d, boundary_forcing_salt_tendency and boundary_forcing_heat_tendency_2d out of the calculation of the diagnostics before they are posted and into the conversion argument in their register_diag_field calls. This change simplifies the code where the diagnostics are calculated, but although all expressions are mathematically equivalent, there is a change in the order of arithmetic with which these 4 diagnostics are calculated, so answers will change at roundoff, although this is unlikely to be detected if the diagnostics are being written as 32 bit floats. All model solutions are bitwise identical.
1 parent 809d56e commit f486837

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/parameterizations/vertical/MOM_diabatic_driver.F90

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,7 +2724,6 @@ subroutine diagnose_diabatic_diff_tendency(tv, h, temp_old, saln_old, dt, G, GV,
27242724
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: work_3d ! A 3-d work array for diagnostics [various]
27252725
real, dimension(SZI_(G),SZJ_(G)) :: work_2d ! A 2-d work array for diagnostics [various]
27262726
real :: Idt ! The inverse of the timestep [T-1 ~> s-1]
2727-
real :: ppt2mks ! Conversion factor from S to kg/kg [S-1 ~> ppt-1].
27282727
integer :: i, j, k, is, ie, js, je, nz
27292728
logical :: do_saln_tend ! Calculate salinity-based tendency diagnostics
27302729

@@ -2774,9 +2773,8 @@ subroutine diagnose_diabatic_diff_tendency(tv, h, temp_old, saln_old, dt, G, GV,
27742773

27752774
! salt tendency
27762775
if (CS%id_diabatic_diff_salt_tend > 0 .or. CS%id_diabatic_diff_salt_tend_2d > 0) then
2777-
ppt2mks = US%S_to_ppt*0.001
27782776
do k=1,nz ; do j=js,je ; do i=is,ie
2779-
work_3d(i,j,k) = h(i,j,k)*GV%H_to_RZ * ppt2mks * work_3d(i,j,k)
2777+
work_3d(i,j,k) = h(i,j,k) * work_3d(i,j,k)
27802778
enddo ; enddo ; enddo
27812779
if (CS%id_diabatic_diff_salt_tend > 0) then
27822780
call post_data(CS%id_diabatic_diff_salt_tend, work_3d, CS%diag, alt_h=h)
@@ -2819,7 +2817,6 @@ subroutine diagnose_boundary_forcing_tendency(tv, h, temp_old, saln_old, h_old,
28192817
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: work_3d ! A 3-d work array for diagnostics [various]
28202818
real, dimension(SZI_(G),SZJ_(G)) :: work_2d ! A 2-d work array for diagnostics [various]
28212819
real :: Idt ! The inverse of the timestep [T-1 ~> s-1]
2822-
real :: ppt2mks ! Conversion factor from S to kg/kg [S-1 ~> ppt-1].
28232820
integer :: i, j, k, is, ie, js, je, nz
28242821

28252822
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
@@ -2870,9 +2867,8 @@ subroutine diagnose_boundary_forcing_tendency(tv, h, temp_old, saln_old, h_old,
28702867

28712868
! salt tendency
28722869
if (CS%id_boundary_forcing_salt_tend > 0 .or. CS%id_boundary_forcing_salt_tend_2d > 0) then
2873-
ppt2mks = US%S_to_ppt*0.001
28742870
do k=1,nz ; do j=js,je ; do i=is,ie
2875-
work_3d(i,j,k) = GV%H_to_RZ * ppt2mks * Idt * (h(i,j,k) * tv%S(i,j,k) - h_old(i,j,k) * saln_old(i,j,k))
2871+
work_3d(i,j,k) = Idt * (h(i,j,k) * tv%S(i,j,k) - h_old(i,j,k) * saln_old(i,j,k))
28762872
enddo ; enddo ; enddo
28772873
if (CS%id_boundary_forcing_salt_tend > 0) then
28782874
call post_data(CS%id_boundary_forcing_salt_tend, work_3d, CS%diag, alt_h=h_old)
@@ -3372,7 +3368,8 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di
33723368
CS%id_diabatic_diff_salt_tend = register_diag_field('ocean_model', &
33733369
'diabatic_salt_tendency', diag%axesTL, Time, &
33743370
'Diabatic diffusion of salt tendency', &
3375-
'kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s, cmor_field_name='osaltdiff', &
3371+
'kg m-2 s-1', conversion=US%S_to_ppt*0.001*GV%H_to_RZ*US%RZ_T_to_kg_m2s, &
3372+
cmor_field_name='osaltdiff', &
33763373
cmor_standard_name='tendency_of_sea_water_salinity_expressed_as_salt_content_'// &
33773374
'due_to_parameterized_dianeutral_mixing', &
33783375
cmor_long_name='Tendency of sea water salinity expressed as salt content '// &
@@ -3399,7 +3396,8 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di
33993396
CS%id_diabatic_diff_salt_tend_2d = register_diag_field('ocean_model', &
34003397
'diabatic_salt_tendency_2d', diag%axesT1, Time, &
34013398
'Depth integrated diabatic diffusion salt tendency', &
3402-
'kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s, cmor_field_name='osaltdiff_2d', &
3399+
'kg m-2 s-1', conversion=US%S_to_ppt*0.001*GV%H_to_RZ*US%RZ_T_to_kg_m2s, &
3400+
cmor_field_name='osaltdiff_2d', &
34033401
cmor_standard_name='tendency_of_sea_water_salinity_expressed_as_salt_content_'// &
34043402
'due_to_parameterized_dianeutral_mixing_depth_integrated', &
34053403
cmor_long_name='Tendency of sea water salinity expressed as salt content '// &
@@ -3446,7 +3444,8 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di
34463444

34473445
CS%id_boundary_forcing_salt_tend = register_diag_field('ocean_model',&
34483446
'boundary_forcing_salt_tendency', diag%axesTL, Time, &
3449-
'Boundary forcing salt tendency', 'kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s, &
3447+
'Boundary forcing salt tendency', &
3448+
'kg m-2 s-1', conversion=US%S_to_ppt*0.001*GV%H_to_RZ*US%RZ_T_to_kg_m2s, &
34503449
v_extensive = .true.)
34513450
if (CS%id_boundary_forcing_salt_tend > 0) then
34523451
CS%boundary_forcing_tendency_diag = .true.
@@ -3465,7 +3464,7 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di
34653464
CS%id_boundary_forcing_salt_tend_2d = register_diag_field('ocean_model',&
34663465
'boundary_forcing_salt_tendency_2d', diag%axesT1, Time, &
34673466
'Depth integrated boundary forcing of ocean salt', &
3468-
'kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s)
3467+
'kg m-2 s-1', conversion=US%S_to_ppt*0.001*GV%H_to_RZ*US%RZ_T_to_kg_m2s)
34693468
if (CS%id_boundary_forcing_salt_tend_2d > 0) then
34703469
CS%boundary_forcing_tendency_diag = .true.
34713470
endif

0 commit comments

Comments
 (0)