From 5ff40fbdbda313873f4363730c748d9ab1bf8657 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Wed, 19 Jun 2019 16:43:09 -0400 Subject: [PATCH 1/3] * High precision energy stats output Since we currently rely on ocean.stats and seaice.stats to detect regressions, there are cases (mostly very short runs) which are not detected by the current 12-decimal precision. This patch extends the precision of the *.stats files to 16 decimal places (scaled), which matches machine precision. --- src/diagnostics/MOM_sum_output.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diagnostics/MOM_sum_output.F90 b/src/diagnostics/MOM_sum_output.F90 index 9399f73a58..842f9ff3c2 100644 --- a/src/diagnostics/MOM_sum_output.F90 +++ b/src/diagnostics/MOM_sum_output.F90 @@ -818,7 +818,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, OBC, dt_ endif if (CS%use_temperature) then - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES18.12, & + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &es11.4,", M ",ES11.5,", S",f8.4,", T",f8.4,& &", Me ",ES9.2,", Se ",ES9.2,", Te ",ES9.2)') & @@ -826,7 +826,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, OBC, dt_ -H_0APE(1), mass_tot, salin, temp, mass_anom/mass_tot, salin_anom, & temp_anom else - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES18.12, & + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &ES11.4,", Mass ",ES11.5,", Me ",ES9.2)') & trim(n_str), trim(day_str), CS%ntrunc, En_mass, max_CFL(1), & From f0fec84f1cde95ebd0dcefad8fc7fe2f593ffcc5 Mon Sep 17 00:00:00 2001 From: "brandon.reichl" Date: Tue, 23 Jul 2019 10:05:44 -0400 Subject: [PATCH 2/3] Adding scale_factor and add_offset for MOM_horizontal_regridding.F90 netCDF inputs in horiz_interp_and_extrap_tracer_record --- src/framework/MOM_horizontal_regridding.F90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/framework/MOM_horizontal_regridding.F90 b/src/framework/MOM_horizontal_regridding.F90 index 21d581978a..2113d5156e 100644 --- a/src/framework/MOM_horizontal_regridding.F90 +++ b/src/framework/MOM_horizontal_regridding.F90 @@ -303,6 +303,7 @@ subroutine horiz_interp_and_extrap_tracer_record(filename, varnam, conversion, real, dimension(:), allocatable :: lat_inp, last_row real :: max_lat, min_lat, pole, max_depth, npole real :: roundoff ! The magnitude of roundoff, usually ~2e-16. + real :: add_offset, scale_factor logical :: add_np character(len=8) :: laynum type(horiz_interp_type) :: Interp @@ -376,6 +377,13 @@ subroutine horiz_interp_and_extrap_tracer_record(filename, varnam, conversion, if (rcode /= 0) call MOM_error(FATAL,"error finding missing value for "//& trim(varnam)//" in file "// trim(filename)//" in hinterp_extrap") + rcode = NF90_GET_ATT(ncid, varid, "add_offset", add_offset) + if (rcode /= 0) add_offset = 0.0 + + rcode = NF90_GET_ATT(ncid, varid, "scale_factor", scale_factor) + if (rcode /= 0) scale_factor = 1.0 + + if (allocated(lon_in)) deallocate(lon_in) if (allocated(lat_in)) deallocate(lat_in) if (allocated(z_in)) deallocate(z_in) @@ -499,7 +507,7 @@ subroutine horiz_interp_and_extrap_tracer_record(filename, varnam, conversion, do i=1,id if (abs(tr_inp(i,j)-missing_value) > abs(roundoff*missing_value)) then mask_in(i,j) = 1.0 - tr_inp(i,j) = tr_inp(i,j) * conversion + tr_inp(i,j) = (tr_inp(i,j)*scale_factor+add_offset) * conversion else tr_inp(i,j) = missing_value endif From d8a5970a81db33d668ab55da426656ab0b4ebe84 Mon Sep 17 00:00:00 2001 From: Raphael Dussin Date: Tue, 23 Jul 2019 13:19:14 -0400 Subject: [PATCH 3/3] unit change, fix #934 --- 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 3cfcaa1880..901b15fd4a 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -2009,7 +2009,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, & endif call register_tracer(CS%tv%T, CS%tracer_Reg, param_file, dG%HI, GV, & tr_desc=vd_T, registry_diags=.true., flux_nameroot='T', & - flux_units='W m-2', flux_longname='Heat', & + flux_units='W', flux_longname='Heat', & flux_scale=conv2watt, convergence_units='W m-2', & convergence_scale=conv2watt, CMOR_tendprefix="opottemp", diag_form=2) call register_tracer(CS%tv%S, CS%tracer_Reg, param_file, dG%HI, GV, &