Skip to content

Commit

Permalink
+Add US args and rescale dt arg to generic tracers
Browse files Browse the repository at this point in the history
  Added unit_scaling_type arguments to various routines that had previously used
a unit scaling type, but did so via the G%US pointer, to make the type
dependencies more explicit and to avoid unnecessary pointer use.  It had been
the intention to make these arguments explicit from the time they were
introduced via a pointer in the ocean_grid_type as a temporary convenience.
The construct G%US%... was replaced with US%... wherever it was possible.

  Also rescaled some local variables or corrected comments in oil_tracer.F90,
nw2_tracers.F90, and boundary_impulse_tracer.F90, and rescaled the units of
the dt argument to MOM_generic_tracer_column_physics from [s] to [T ~> s].

  All answers are bitwise identical, although there are multiple changes to
public interfaces.
  • Loading branch information
Hallberg-NOAA authored and marshallward committed Dec 19, 2021
1 parent 12f29f6 commit a902e75
Show file tree
Hide file tree
Showing 23 changed files with 163 additions and 138 deletions.
8 changes: 4 additions & 4 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ subroutine step_MOM_tracer_dyn(CS, G, GV, US, h, Time_local)
if (associated(CS%tv%T)) call hchksum(CS%tv%T, "Pre-advection T", G%HI, haloshift=1)
if (associated(CS%tv%S)) call hchksum(CS%tv%S, "Pre-advection S", G%HI, haloshift=1)
if (associated(CS%tv%frazil)) call hchksum(CS%tv%frazil, "Pre-advection frazil", G%HI, haloshift=0, &
scale=G%US%Q_to_J_kg*G%US%RZ_to_kg_m2)
scale=US%Q_to_J_kg*US%RZ_to_kg_m2)
if (associated(CS%tv%salt_deficit)) call hchksum(CS%tv%salt_deficit, &
"Pre-advection salt deficit", G%HI, haloshift=0, scale=US%RZ_to_kg_m2)
! call MOM_thermo_chksum("Pre-advection ", CS%tv, G, US)
Expand Down Expand Up @@ -1445,7 +1445,7 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
if (associated(tv%T)) call hchksum(tv%T, "Post-diabatic T", G%HI, haloshift=1)
if (associated(tv%S)) call hchksum(tv%S, "Post-diabatic S", G%HI, haloshift=1)
if (associated(tv%frazil)) call hchksum(tv%frazil, "Post-diabatic frazil", G%HI, haloshift=0, &
scale=G%US%Q_to_J_kg*G%US%RZ_to_kg_m2)
scale=US%Q_to_J_kg*US%RZ_to_kg_m2)
if (associated(tv%salt_deficit)) call hchksum(tv%salt_deficit, &
"Post-diabatic salt deficit", G%HI, haloshift=0, scale=US%RZ_to_kg_m2)
! call MOM_thermo_chksum("Post-diabatic ", tv, G, US)
Expand Down Expand Up @@ -3514,7 +3514,7 @@ subroutine extract_surface_state(CS, sfc_state_in)
'Extreme surface sfc_state detected: i=',ig,'j=',jg, &
'lon=',G%geoLonT(i,j), 'lat=',G%geoLatT(i,j), &
'x=',G%gridLonT(ig), 'y=',G%gridLatT(jg), &
'D=',CS%US%Z_to_m*(G%bathyT(i,j)+G%Z_ref), 'SSH=',CS%US%Z_to_m*sfc_state%sea_lev(i,j), &
'D=',US%Z_to_m*(G%bathyT(i,j)+G%Z_ref), 'SSH=',US%Z_to_m*sfc_state%sea_lev(i,j), &
'SST=',sfc_state%SST(i,j), 'SSS=',sfc_state%SSS(i,j), &
'U-=',US%L_T_to_m_s*sfc_state%u(I-1,j), 'U+=',US%L_T_to_m_s*sfc_state%u(I,j), &
'V-=',US%L_T_to_m_s*sfc_state%v(i,J-1), 'V+=',US%L_T_to_m_s*sfc_state%v(i,J)
Expand All @@ -3523,7 +3523,7 @@ subroutine extract_surface_state(CS, sfc_state_in)
'Extreme surface sfc_state detected: i=',ig,'j=',jg, &
'lon=',G%geoLonT(i,j), 'lat=',G%geoLatT(i,j), &
'x=',G%gridLonT(i), 'y=',G%gridLatT(j), &
'D=',CS%US%Z_to_m*(G%bathyT(i,j)+G%Z_ref), 'SSH=',CS%US%Z_to_m*sfc_state%sea_lev(i,j), &
'D=',US%Z_to_m*(G%bathyT(i,j)+G%Z_ref), 'SSH=',US%Z_to_m*sfc_state%sea_lev(i,j), &
'U-=',US%L_T_to_m_s*sfc_state%u(I-1,j), 'U+=',US%L_T_to_m_s*sfc_state%u(I,j), &
'V-=',US%L_T_to_m_s*sfc_state%v(i,J-1), 'V+=',US%L_T_to_m_s*sfc_state%v(i,J)
endif
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_boundary_update.F90
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ subroutine update_OBC_data(OBC, G, GV, US, tv, h, CS, Time)
! if (CS%use_files) &
! call update_OBC_segment_data(G, GV, OBC, tv, h, Time)
if (CS%use_tidal_bay) &
call tidal_bay_set_OBC_data(OBC, CS%tidal_bay_OBC, G, GV, h, Time)
call tidal_bay_set_OBC_data(OBC, CS%tidal_bay_OBC, G, GV, US, h, Time)
if (CS%use_Kelvin) &
call Kelvin_set_OBC_data(OBC, CS%Kelvin_OBC_CSp, G, GV, US, h, Time)
if (CS%use_shelfwave) &
call shelfwave_set_OBC_data(OBC, CS%shelfwave_OBC_CSp, G, GV, US, h, Time)
if (CS%use_dyed_channel) &
call dyed_channel_update_flow(OBC, CS%dyed_channel_OBC_CSp, G, GV, Time)
call dyed_channel_update_flow(OBC, CS%dyed_channel_OBC_CSp, G, GV, US, Time)
if (OBC%needs_IO_for_data .or. OBC%add_tide_constituents) &
call update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)

Expand Down
10 changes: 6 additions & 4 deletions src/core/MOM_variables.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module MOM_variables
use MOM_EOS, only : EOS_type
use MOM_error_handler, only : MOM_error, FATAL
use MOM_grid, only : ocean_grid_type
use MOM_unit_scaling, only : unit_scale_type
use MOM_verticalGrid, only : verticalGrid_type

implicit none ; private
Expand Down Expand Up @@ -562,10 +563,11 @@ subroutine dealloc_BT_cont_type(BT_cont)
end subroutine dealloc_BT_cont_type

!> Diagnostic checksums on various elements of a thermo_var_ptrs type for debugging.
subroutine MOM_thermovar_chksum(mesg, tv, G)
subroutine MOM_thermovar_chksum(mesg, tv, G, US)
character(len=*), intent(in) :: mesg !< A message that appears in the checksum 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

! 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
Expand All @@ -575,11 +577,11 @@ subroutine MOM_thermovar_chksum(mesg, tv, G)
if (associated(tv%S)) &
call hchksum(tv%S, mesg//" tv%S", G%HI)
if (associated(tv%frazil)) &
call hchksum(tv%frazil, mesg//" tv%frazil", G%HI, scale=G%US%Q_to_J_kg*G%US%RZ_to_kg_m2)
call hchksum(tv%frazil, mesg//" tv%frazil", G%HI, scale=US%Q_to_J_kg*US%RZ_to_kg_m2)
if (associated(tv%salt_deficit)) &
call hchksum(tv%salt_deficit, mesg//" tv%salt_deficit", G%HI, scale=G%US%RZ_to_kg_m2)
call hchksum(tv%salt_deficit, mesg//" tv%salt_deficit", G%HI, scale=US%RZ_to_kg_m2)
if (associated(tv%TempxPmE)) &
call hchksum(tv%TempxPmE, mesg//" tv%TempxPmE", G%HI, scale=G%US%RZ_to_kg_m2)
call hchksum(tv%TempxPmE, mesg//" tv%TempxPmE", G%HI, scale=US%RZ_to_kg_m2)
end subroutine MOM_thermovar_chksum

end module MOM_variables
11 changes: 6 additions & 5 deletions src/diagnostics/MOM_sum_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci

nTr_stocks = 0
Tr_minmax_avail(:) = .false.
call call_tracer_stocks(h, Tr_stocks, G, GV, tracer_CSp, stock_names=Tr_names, &
call call_tracer_stocks(h, Tr_stocks, G, GV, US, tracer_CSp, stock_names=Tr_names, &
stock_units=Tr_units, num_stocks=nTr_stocks,&
got_min_max=Tr_minmax_avail, global_min=Tr_min, global_max=Tr_max, &
xgmin=Tr_min_x, ygmin=Tr_min_y, zgmin=Tr_min_z,&
Expand Down Expand Up @@ -1248,7 +1248,7 @@ subroutine write_depth_list(G, US, DL, filename)
character(len=16) :: depth_chksum, area_chksum

! All ranks are required to compute the global checksum
call get_depth_list_checksums(G, depth_chksum, area_chksum)
call get_depth_list_checksums(G, US, depth_chksum, area_chksum)

if (.not.is_root_pe()) return

Expand Down Expand Up @@ -1313,7 +1313,7 @@ subroutine read_depth_list(G, US, DL, filename, require_chksum, file_matches)
call MOM_error(WARNING, trim(var_msg) // " some diagnostics may not be reproducible.")
endif
else
call get_depth_list_checksums(G, depth_grid_chksum, area_grid_chksum)
call get_depth_list_checksums(G, US, depth_grid_chksum, area_grid_chksum)

if ((trim(depth_grid_chksum) /= trim(depth_file_chksum)) .or. &
(trim(area_grid_chksum) /= trim(area_file_chksum)) ) then
Expand Down Expand Up @@ -1360,8 +1360,9 @@ end subroutine read_depth_list
!!
!! Checksums are saved as hexadecimal strings, in order to avoid potential
!! datatype issues with netCDF attributes.
subroutine get_depth_list_checksums(G, depth_chksum, area_chksum)
subroutine get_depth_list_checksums(G, US, depth_chksum, area_chksum)
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
character(len=16), intent(out) :: depth_chksum !< Depth checksum hexstring
character(len=16), intent(out) :: area_chksum !< Area checksum hexstring

Expand All @@ -1378,7 +1379,7 @@ subroutine get_depth_list_checksums(G, depth_chksum, area_chksum)

! Area checksum
do j=G%jsc,G%jec ; do i=G%isc,G%iec
field(i,j) = G%mask2dT(i,j) * G%US%L_to_m**2*G%areaT(i,j)
field(i,j) = G%mask2dT(i,j) * US%L_to_m**2*G%areaT(i,j)
enddo ; enddo
write(area_chksum, '(Z16)') field_chksum(field(:,:))

Expand Down
2 changes: 1 addition & 1 deletion src/initialization/MOM_state_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
elseif (trim(config) == "shelfwave") then
OBC%update_OBC = .true.
elseif (lowercase(trim(config)) == "supercritical") then
call supercritical_set_OBC_data(OBC, G, GV, PF)
call supercritical_set_OBC_data(OBC, G, GV, US, PF)
elseif (trim(config) == "tidal_bay") then
OBC%update_OBC = .true.
elseif (trim(config) == "USER") then
Expand Down
Loading

0 comments on commit a902e75

Please sign in to comment.