Skip to content

Commit

Permalink
+Add optional unscale arguments to checksums
Browse files Browse the repository at this point in the history
  Added an optional unscale argument to 16 checksum and 9 spatial_mean or
spatial_integral routines.  These are synonymous with the existing optional
scale arguments to these routines, and if both are provided, the new unscale
arguments take precedence.

  All this is done to come up with a more systematic nomenclature for the
various scaling and unscaling arguments, so that the factors passed to them will
follow a more regular pattern.  With this change, the `scale=` argument to a
get_param or read_data call will take the opposite setting to the `unscale=`
argument used in a checksum call.  For example, for a velocity, these arguments
would be `scale=US%m_s_to_L_T` and `unscale=US%L_T_to_m_s`, but the reverse
values of `scale=US%L_T_to_m_s` and `unscale=US%m_s_to_L_T` would only work for
inverse velocities and will therefore be very uncommon and warrant extra
scrutiny. With this change, `unscale=` and `conversion=` arguments used when
registering diagnostics will often take similar  arguments, although the latter
can also have extra factors that are unrelated to dimensional rescaling.

  As a test of these capabilities, these new `unscale` arguments are being used
in 23 calls from the MOM_chksum_packages routines and in 76 calls to chksums or
global integrals from MOM_forcing_chksum(), MOM_mech_forcing_chksum() and
forcing_diagnostics().  The results are equivalent to what was generated before
in cases with debugging enabled so the revised code would be exercised.

  All answers are bitwise identical, but there are new optional arguments to 25
publicly visible routines.
  • Loading branch information
Hallberg-NOAA committed Jun 5, 2024
1 parent b389a89 commit bce6f86
Show file tree
Hide file tree
Showing 4 changed files with 398 additions and 232 deletions.
46 changes: 23 additions & 23 deletions src/core/MOM_checksum_packages.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ subroutine MOM_state_chksum_5arg(mesg, u, v, h, uh, vh, G, GV, US, haloshift, sy
scale_vel = US%L_T_to_m_s ; if (present(vel_scale)) scale_vel = vel_scale

call uvchksum(mesg//" [uv]", u, v, G%HI, haloshift=hs, symmetric=sym, &
omit_corners=omit_corners, scale=scale_vel)
call hchksum(h, mesg//" h", G%HI, haloshift=hs, omit_corners=omit_corners, scale=GV%H_to_MKS)
omit_corners=omit_corners, unscale=scale_vel)
call hchksum(h, mesg//" h", G%HI, haloshift=hs, omit_corners=omit_corners, unscale=GV%H_to_MKS)
call uvchksum(mesg//" [uv]h", uh, vh, G%HI, haloshift=hs, symmetric=sym, &
omit_corners=omit_corners, scale=GV%H_to_MKS*US%L_to_m**2*US%s_to_T)
omit_corners=omit_corners, unscale=GV%H_to_MKS*US%L_to_m**2*US%s_to_T)
end subroutine MOM_state_chksum_5arg

! =============================================================================
Expand Down Expand Up @@ -110,8 +110,8 @@ subroutine MOM_state_chksum_3arg(mesg, u, v, h, G, GV, US, haloshift, symmetric,
hs = 1 ; if (present(haloshift)) hs = haloshift
sym = .false. ; if (present(symmetric)) sym = symmetric
call uvchksum(mesg//" u", u, v, G%HI, haloshift=hs, symmetric=sym, &
omit_corners=omit_corners, scale=US%L_T_to_m_s)
call hchksum(h, mesg//" h",G%HI, haloshift=hs, omit_corners=omit_corners, scale=GV%H_to_MKS)
omit_corners=omit_corners, unscale=US%L_T_to_m_s)
call hchksum(h, mesg//" h",G%HI, haloshift=hs, omit_corners=omit_corners, unscale=GV%H_to_MKS)
end subroutine MOM_state_chksum_3arg

! =============================================================================
Expand All @@ -130,22 +130,22 @@ subroutine MOM_thermo_chksum(mesg, tv, G, US, haloshift, omit_corners)
hs=1 ; if (present(haloshift)) hs=haloshift

if (associated(tv%T)) &
call hchksum(tv%T, mesg//" T", G%HI, haloshift=hs, omit_corners=omit_corners, scale=US%C_to_degC)
call hchksum(tv%T, mesg//" T", G%HI, haloshift=hs, omit_corners=omit_corners, unscale=US%C_to_degC)
if (associated(tv%S)) &
call hchksum(tv%S, mesg//" S", G%HI, haloshift=hs, omit_corners=omit_corners, scale=US%S_to_ppt)
call hchksum(tv%S, mesg//" S", G%HI, haloshift=hs, omit_corners=omit_corners, unscale=US%S_to_ppt)
if (associated(tv%frazil)) &
call hchksum(tv%frazil, mesg//" frazil", G%HI, haloshift=hs, omit_corners=omit_corners, &
scale=US%Q_to_J_kg*US%R_to_kg_m3*US%Z_to_m)
unscale=US%Q_to_J_kg*US%R_to_kg_m3*US%Z_to_m)
if (associated(tv%salt_deficit)) &
call hchksum(tv%salt_deficit, mesg//" salt deficit", G%HI, haloshift=hs, omit_corners=omit_corners, &
scale=US%S_to_ppt*US%RZ_to_kg_m2)
unscale=US%S_to_ppt*US%RZ_to_kg_m2)
if (associated(tv%varT)) &
call hchksum(tv%varT, mesg//" varT", G%HI, haloshift=hs, omit_corners=omit_corners, scale=US%C_to_degC**2)
call hchksum(tv%varT, mesg//" varT", G%HI, haloshift=hs, omit_corners=omit_corners, unscale=US%C_to_degC**2)
if (associated(tv%varS)) &
call hchksum(tv%varS, mesg//" varS", G%HI, haloshift=hs, omit_corners=omit_corners, scale=US%S_to_ppt**2)
call hchksum(tv%varS, mesg//" varS", G%HI, haloshift=hs, omit_corners=omit_corners, unscale=US%S_to_ppt**2)
if (associated(tv%covarTS)) &
call hchksum(tv%covarTS, mesg//" covarTS", G%HI, haloshift=hs, omit_corners=omit_corners, &
scale=US%S_to_ppt*US%C_to_degC)
unscale=US%S_to_ppt*US%C_to_degC)

end subroutine MOM_thermo_chksum

Expand All @@ -170,18 +170,18 @@ subroutine MOM_surface_chksum(mesg, sfc_state, G, US, haloshift, symmetric)
hs = 1 ; if (present(haloshift)) hs = haloshift

if (allocated(sfc_state%SST)) call hchksum(sfc_state%SST, mesg//" SST", G%HI, haloshift=hs, &
scale=US%C_to_degC)
unscale=US%C_to_degC)
if (allocated(sfc_state%SSS)) call hchksum(sfc_state%SSS, mesg//" SSS", G%HI, haloshift=hs, &
scale=US%S_to_ppt)
unscale=US%S_to_ppt)
if (allocated(sfc_state%sea_lev)) call hchksum(sfc_state%sea_lev, mesg//" sea_lev", G%HI, &
haloshift=hs, scale=US%Z_to_m)
haloshift=hs, unscale=US%Z_to_m)
if (allocated(sfc_state%Hml)) call hchksum(sfc_state%Hml, mesg//" Hml", G%HI, haloshift=hs, &
scale=US%Z_to_m)
unscale=US%Z_to_m)
if (allocated(sfc_state%u) .and. allocated(sfc_state%v)) &
call uvchksum(mesg//" SSU", sfc_state%u, sfc_state%v, G%HI, haloshift=hs, symmetric=sym, &
scale=US%L_T_to_m_s)
unscale=US%L_T_to_m_s)
if (allocated(sfc_state%frazil)) call hchksum(sfc_state%frazil, mesg//" frazil", G%HI, &
haloshift=hs, scale=US%Q_to_J_kg*US%RZ_to_kg_m2)
haloshift=hs, unscale=US%Q_to_J_kg*US%RZ_to_kg_m2)

end subroutine MOM_surface_chksum

Expand Down Expand Up @@ -232,14 +232,14 @@ subroutine MOM_accel_chksum(mesg, CAu, CAv, PFu, PFv, diffu, diffv, G, GV, US, p
! Note that for the chksum calls to be useful for reproducing across PE
! counts, there must be no redundant points, so all variables use is..ie
! and js...je as their extent.
call uvchksum(mesg//" CA[uv]", CAu, CAv, G%HI, haloshift=0, symmetric=sym, scale=US%L_T2_to_m_s2)
call uvchksum(mesg//" PF[uv]", PFu, PFv, G%HI, haloshift=0, symmetric=sym, scale=US%L_T2_to_m_s2)
call uvchksum(mesg//" diffu", diffu, diffv, G%HI,haloshift=0, symmetric=sym, scale=US%L_T2_to_m_s2)
call uvchksum(mesg//" CA[uv]", CAu, CAv, G%HI, haloshift=0, symmetric=sym, unscale=US%L_T2_to_m_s2)
call uvchksum(mesg//" PF[uv]", PFu, PFv, G%HI, haloshift=0, symmetric=sym, unscale=US%L_T2_to_m_s2)
call uvchksum(mesg//" diffu", diffu, diffv, G%HI,haloshift=0, symmetric=sym, unscale=US%L_T2_to_m_s2)
if (present(pbce)) &
call hchksum(pbce, mesg//" pbce",G%HI,haloshift=0, scale=GV%m_to_H*US%L_T_to_m_s**2)
call hchksum(pbce, mesg//" pbce",G%HI,haloshift=0, unscale=GV%m_to_H*US%L_T_to_m_s**2)
if (present(u_accel_bt) .and. present(v_accel_bt)) &
call uvchksum(mesg//" [uv]_accel_bt", u_accel_bt, v_accel_bt, G%HI,haloshift=0, symmetric=sym, &
scale=US%L_T2_to_m_s2)
unscale=US%L_T2_to_m_s2)
end subroutine MOM_accel_chksum

! =============================================================================
Expand Down
Loading

0 comments on commit bce6f86

Please sign in to comment.