Skip to content

Commit

Permalink
+Add optional unscale arguments to MOM_write_field
Browse files Browse the repository at this point in the history
  Added an optional unscale argument to 10 routines under the overloaded
MOM_write_field interface, mirroring the recent additions of unscale arguments
to the various chksum routines.  These new unscale arguments are synonymous with
the existing optional scale arguments to these routines, and if both are
provided, the new unscale arguments take precedence.

  A total of 26 MOM_write_field calls in save_restart, write_depth_list,
write_Hybgen_coord_file, write_vertgrid_file and write_ocean_geometry_file were
modified to replace a scale argument with the new unscale argument.

  All answers are bitwise identical, but there are new optional arguments to 10
publicly visible routines.
  • Loading branch information
Hallberg-NOAA authored and marshallward committed Jul 10, 2024
1 parent e9f59c2 commit 2f2b790
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 89 deletions.
6 changes: 3 additions & 3 deletions src/ALE/MOM_hybgen_regrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ subroutine write_Hybgen_coord_file(GV, CS, filepath)
call create_MOM_file(IO_handle, trim(filepath), vars, 3, fields, &
SINGLE_FILE, GV=GV)

call MOM_write_field(IO_handle, fields(1), CS%dp0k, scale=CS%coord_scale)
call MOM_write_field(IO_handle, fields(2), CS%ds0k, scale=CS%coord_scale)
call MOM_write_field(IO_handle, fields(3), CS%target_density, scale=CS%Rho_coord_scale)
call MOM_write_field(IO_handle, fields(1), CS%dp0k, unscale=CS%coord_scale)
call MOM_write_field(IO_handle, fields(2), CS%ds0k, unscale=CS%coord_scale)
call MOM_write_field(IO_handle, fields(3), CS%target_density, unscale=CS%Rho_coord_scale)

call IO_handle%close()
end subroutine write_Hybgen_coord_file
Expand Down
6 changes: 3 additions & 3 deletions src/diagnostics/MOM_sum_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,9 @@ subroutine write_depth_list(G, US, DL, filename)

call create_MOM_file(IO_handle, filename, vars, 3, fields, SINGLE_FILE, &
extra_axes=extra_axes, global_atts=global_atts)
call MOM_write_field(IO_handle, fields(1), DL%depth, scale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(2), DL%area, scale=US%L_to_m**2)
call MOM_write_field(IO_handle, fields(3), DL%vol_below, scale=US%Z_to_m*US%L_to_m**2)
call MOM_write_field(IO_handle, fields(1), DL%depth, unscale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(2), DL%area, unscale=US%L_to_m**2)
call MOM_write_field(IO_handle, fields(3), DL%vol_below, unscale=US%Z_to_m*US%L_to_m**2)

call delete_axis_info(extra_axes)
call delete_attribute_info(global_atts)
Expand Down
181 changes: 130 additions & 51 deletions src/framework/MOM_io.F90

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/framework/MOM_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1513,19 +1513,19 @@ subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, num_
do m=start_var,next_var-1
if (associated(CS%var_ptr3d(m)%p)) then
call MOM_write_field(IO_handle, fields(m-start_var+1), G%Domain, CS%var_ptr3d(m)%p, &
restart_time, scale=CS%restart_field(m)%conv, turns=-turns)
restart_time, unscale=CS%restart_field(m)%conv, turns=-turns)
elseif (associated(CS%var_ptr2d(m)%p)) then
call MOM_write_field(IO_handle, fields(m-start_var+1), G%Domain, CS%var_ptr2d(m)%p, &
restart_time, scale=CS%restart_field(m)%conv, turns=-turns)
restart_time, unscale=CS%restart_field(m)%conv, turns=-turns)
elseif (associated(CS%var_ptr4d(m)%p)) then
call MOM_write_field(IO_handle, fields(m-start_var+1), G%Domain, CS%var_ptr4d(m)%p, &
restart_time, scale=CS%restart_field(m)%conv, turns=-turns)
restart_time, unscale=CS%restart_field(m)%conv, turns=-turns)
elseif (associated(CS%var_ptr1d(m)%p)) then
call MOM_write_field(IO_handle, fields(m-start_var+1), CS%var_ptr1d(m)%p, &
restart_time, scale=CS%restart_field(m)%conv)
restart_time, unscale=CS%restart_field(m)%conv)
elseif (associated(CS%var_ptr0d(m)%p)) then
call MOM_write_field(IO_handle, fields(m-start_var+1), CS%var_ptr0d(m)%p, &
restart_time, scale=CS%restart_field(m)%conv)
restart_time, unscale=CS%restart_field(m)%conv)
endif
enddo

Expand Down
4 changes: 2 additions & 2 deletions src/initialization/MOM_coord_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ subroutine write_vertgrid_file(GV, US, param_file, directory)
call create_MOM_file(IO_handle, trim(filepath), vars, 2, fields, &
SINGLE_FILE, GV=GV)

call MOM_write_field(IO_handle, fields(1), GV%Rlay, scale=US%R_to_kg_m3)
call MOM_write_field(IO_handle, fields(2), GV%g_prime, scale=US%L_T_to_m_s**2*US%m_to_Z)
call MOM_write_field(IO_handle, fields(1), GV%Rlay, unscale=US%R_to_kg_m3)
call MOM_write_field(IO_handle, fields(2), GV%g_prime, unscale=US%L_T_to_m_s**2*US%m_to_Z)

call IO_handle%close()

Expand Down
42 changes: 21 additions & 21 deletions src/initialization/MOM_shared_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1424,30 +1424,30 @@ subroutine write_ocean_geometry_file(G, param_file, directory, US, geom_file)
call MOM_write_field(IO_handle, fields(3), G%Domain, G%geoLatT)
call MOM_write_field(IO_handle, fields(4), G%Domain, G%geoLonT)

call MOM_write_field(IO_handle, fields(5), G%Domain, G%bathyT, scale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(6), G%Domain, G%CoriolisBu, scale=US%s_to_T)

call MOM_write_field(IO_handle, fields(7), G%Domain, G%dxCv, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(8), G%Domain, G%dyCu, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(9), G%Domain, G%dxCu, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(10), G%Domain, G%dyCv, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(11), G%Domain, G%dxT, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(12), G%Domain, G%dyT, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(13), G%Domain, G%dxBu, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(14), G%Domain, G%dyBu, scale=US%L_to_m)

call MOM_write_field(IO_handle, fields(15), G%Domain, G%areaT, scale=US%L_to_m**2)
call MOM_write_field(IO_handle, fields(16), G%Domain, G%areaBu, scale=US%L_to_m**2)

call MOM_write_field(IO_handle, fields(17), G%Domain, G%dx_Cv, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(18), G%Domain, G%dy_Cu, scale=US%L_to_m)
call MOM_write_field(IO_handle, fields(5), G%Domain, G%bathyT, unscale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(6), G%Domain, G%CoriolisBu, unscale=US%s_to_T)

call MOM_write_field(IO_handle, fields(7), G%Domain, G%dxCv, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(8), G%Domain, G%dyCu, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(9), G%Domain, G%dxCu, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(10), G%Domain, G%dyCv, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(11), G%Domain, G%dxT, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(12), G%Domain, G%dyT, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(13), G%Domain, G%dxBu, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(14), G%Domain, G%dyBu, unscale=US%L_to_m)

call MOM_write_field(IO_handle, fields(15), G%Domain, G%areaT, unscale=US%L_to_m**2)
call MOM_write_field(IO_handle, fields(16), G%Domain, G%areaBu, unscale=US%L_to_m**2)

call MOM_write_field(IO_handle, fields(17), G%Domain, G%dx_Cv, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(18), G%Domain, G%dy_Cu, unscale=US%L_to_m)
call MOM_write_field(IO_handle, fields(19), G%Domain, G%mask2dT)

if (G%bathymetry_at_vel) then
call MOM_write_field(IO_handle, fields(20), G%Domain, G%Dblock_u, scale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(21), G%Domain, G%Dopen_u, scale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(22), G%Domain, G%Dblock_v, scale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(23), G%Domain, G%Dopen_v, scale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(20), G%Domain, G%Dblock_u, unscale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(21), G%Domain, G%Dopen_u, unscale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(22), G%Domain, G%Dblock_v, unscale=US%Z_to_m)
call MOM_write_field(IO_handle, fields(23), G%Domain, G%Dopen_v, unscale=US%Z_to_m)
endif

call IO_handle%close()
Expand Down
8 changes: 4 additions & 4 deletions src/parameterizations/vertical/MOM_bkgnd_mixing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,19 @@ subroutine bkgnd_mixing_init(Time, G, GV, US, param_file, diag, CS, physical_OBL

call get_param(param_file, mdl, "BCKGRND_VDC1", CS%bckgrnd_vdc1, &
"Background diffusivity (Ledwell) when HORIZ_VARYING_BACKGROUND=True", &
units="m2 s-1",default = 0.16e-04, scale=GV%m2_s_to_HZ_T)
units="m2 s-1", default=0.16e-04, scale=GV%m2_s_to_HZ_T)

call get_param(param_file, mdl, "BCKGRND_VDC_EQ", CS%bckgrnd_vdc_eq, &
"Equatorial diffusivity (Gregg) when HORIZ_VARYING_BACKGROUND=True", &
units="m2 s-1",default = 0.01e-04, scale=GV%m2_s_to_HZ_T)
units="m2 s-1", default=0.01e-04, scale=GV%m2_s_to_HZ_T)

call get_param(param_file, mdl, "BCKGRND_VDC_PSIM", CS%bckgrnd_vdc_psim, &
"Max. PSI induced diffusivity (MacKinnon) when HORIZ_VARYING_BACKGROUND=True", &
units="m2 s-1",default = 0.13e-4, scale=GV%m2_s_to_HZ_T)
units="m2 s-1", default=0.13e-4, scale=GV%m2_s_to_HZ_T)

call get_param(param_file, mdl, "BCKGRND_VDC_BAN", CS%bckgrnd_vdc_Banda, &
"Banda Sea diffusivity (Gordon) when HORIZ_VARYING_BACKGROUND=True", &
units="m2 s-1",default = 1.0e-4, scale=GV%m2_s_to_HZ_T)
units="m2 s-1", default=1.0e-4, scale=GV%m2_s_to_HZ_T)
endif

call get_param(param_file, mdl, "PRANDTL_BKGND", CS%prandtl_bkgnd, &
Expand Down

0 comments on commit 2f2b790

Please sign in to comment.