From 3f7bcaa567186b2272a4db195e1754ced675b36a Mon Sep 17 00:00:00 2001 From: He Wang Date: Fri, 20 Dec 2024 21:51:22 -0500 Subject: [PATCH 1/3] Fix indexing error in extract_surface_state Correct a bug that G%gridLonT/G%gridLatT were not using global indexing in outputing extreme surface information. --- src/core/MOM.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 7ee90d746a..289ac66baf 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -4041,7 +4041,7 @@ subroutine extract_surface_state(CS, sfc_state_in) write(msg(1:240),'(2(a,i4,1x),4(a,f8.3,1x),6(a,es11.4))') & '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), & + 'x=',G%gridLonT(ig), 'y=',G%gridLatT(jg), & '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) From 25a45c908151d814c690c4f44c41ee43a723277f Mon Sep 17 00:00:00 2001 From: He Wang Date: Fri, 20 Dec 2024 21:54:04 -0500 Subject: [PATCH 2/3] Minor change of SSH check in extract_surface_state Previously extreme surface message is triggered when `sea_lev` is smaller than or **equal** to ocean topography: sfc_state%sea_lev(i,j) <= -G%bathyT(i,j) - G%Z_ref The equality is innocuous for a non-zero minimum thickness (Angstrom/=0), but it can be problematic for true zero thickness. Besides, there is the fourth criterion in this check: sfc_state%sea_lev(i,j) + G%bathyT(i,j) + G%Z_ref < CS%bad_val_col_thick This is supposed to allow a user-specified tolerance (default=0.0), which should be a more stringent check when the tolerance is larger than zero. The equality from the first check contradicts this logic. --- src/core/MOM.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 289ac66baf..8716fe6cd8 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -4014,7 +4014,7 @@ subroutine extract_surface_state(CS, sfc_state_in) numberOfErrors=0 ! count number of errors do j=js,je ; do i=is,ie if (G%mask2dT(i,j)>0.) then - localError = sfc_state%sea_lev(i,j) <= -G%bathyT(i,j) - G%Z_ref & + localError = sfc_state%sea_lev(i,j) < -G%bathyT(i,j) - G%Z_ref & .or. sfc_state%sea_lev(i,j) >= CS%bad_val_ssh_max & .or. sfc_state%sea_lev(i,j) <= -CS%bad_val_ssh_max & .or. sfc_state%sea_lev(i,j) + G%bathyT(i,j) + G%Z_ref < CS%bad_val_col_thick From 26305700be944649ef63349f695df3914adc5e79 Mon Sep 17 00:00:00 2001 From: He Wang Date: Fri, 20 Dec 2024 22:22:41 -0500 Subject: [PATCH 3/3] Recover diagnostic "SSH_inst" Fix a bug that sea surface height averaged over every dynamic time step (SSH_inst) is not outputted correctly. --- src/core/MOM.F90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 8716fe6cd8..e5d1f46086 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -986,7 +986,11 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS do j=js,je ; do i=is,ie CS%ssh_rint(i,j) = CS%ssh_rint(i,j) + dt*ssh(i,j) enddo ; enddo - if (CS%IDs%id_ssh_inst > 0) call post_data(CS%IDs%id_ssh_inst, ssh, CS%diag) + if (CS%IDs%id_ssh_inst > 0) then + call enable_averages(dt, Time_local, CS%diag) + call post_data(CS%IDs%id_ssh_inst, ssh, CS%diag) + call disable_averaging(CS%diag) + endif call cpu_clock_end(id_clock_dynamics) endif