Skip to content

Commit

Permalink
+Add density rescaling factors in unit_scale_type
Browse files Browse the repository at this point in the history
  Added factors for power-of-2 rescaling of density to the unit_scale_type,
along with the new run-time parameter R_RESCALE_POWER.  All answers are
bitwise identical, but there is a new runtime parameter, some new elements in
a transparent public type, and a new optional variable in the MOM restart
files.  This adds a new entry to the MOM_parameter_doc.debugging files.
  • Loading branch information
Hallberg-NOAA committed Sep 11, 2019
1 parent 1016be3 commit 3704a66
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,7 @@ subroutine MOM_timing_init(CS)
id_clock_diabatic = cpu_clock_id('(Ocean diabatic driver)', grain=CLOCK_MODULE_DRIVER)

id_clock_continuity = cpu_clock_id('(Ocean continuity equation *)', grain=CLOCK_MODULE)
id_clock_BBL_visc = cpu_clock_id('(Ocean set BBL viscosity)', grain=CLOCK_MODULE)
id_clock_BBL_visc = cpu_clock_id('(Ocean set BBL viscosity)', grain=CLOCK_MODULE)
id_clock_pass = cpu_clock_id('(Ocean message passing *)', grain=CLOCK_MODULE)
id_clock_MOM_init = cpu_clock_id('(Ocean MOM_initialize_state)', grain=CLOCK_MODULE)
id_clock_pass_init = cpu_clock_id('(Ocean init message passing *)', grain=CLOCK_ROUTINE)
Expand Down Expand Up @@ -2644,6 +2644,8 @@ subroutine set_restart_fields(GV, US, param_file, CS, restart_CSp)
"Length unit conversion factor", "L meter-1")
call register_restart_field(US%s_to_T_restart, "s_to_T", .false., restart_CSp, &
"Time unit conversion factor", "T second-1")
call register_restart_field(US%kg_m3_to_R_restart, "kg_m3_to_R", .false., restart_CSp, &
"Density unit conversion factor", "R m3 kg-1")

end subroutine set_restart_fields

Expand Down
23 changes: 19 additions & 4 deletions src/framework/MOM_unit_scaling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ module MOM_unit_scaling
real :: Z_to_m !< A constant that translates distances in the units of depth to meters.
real :: m_to_L !< A constant that translates lengths in meters to the units of horizontal lengths.
real :: L_to_m !< A constant that translates lengths in the units of horizontal lengths to meters.
real :: s_to_T !< A constant that time intervals in seconds to the units of time.
real :: T_to_s !< A constant that the units of time to seconds.
real :: s_to_T !< A constant that translates time intervals in seconds to the units of time.
real :: T_to_s !< A constant that translates the units of time to seconds.
real :: R_to_kg_m3 !< A constant that translates the units of density to kilograms per meter cubed.
real :: kg_m3_to_R !< A constant that translates kilograms per meter cubed to the units of density.

! These are useful combinations of the fundamental scale conversion factors above.
real :: Z_to_L !< Convert vertical distances to lateral lengths
Expand All @@ -32,6 +34,7 @@ module MOM_unit_scaling
real :: m_to_Z_restart = 0.0 !< A copy of the m_to_Z that is used in restart files.
real :: m_to_L_restart = 0.0 !< A copy of the m_to_L that is used in restart files.
real :: s_to_T_restart = 0.0 !< A copy of the s_to_T that is used in restart files.
real :: kg_m3_to_R_restart = 0.0 !< A copy of the kg_m3_to_R that is used in restart files.
end type unit_scale_type

contains
Expand All @@ -44,8 +47,8 @@ subroutine unit_scaling_init( param_file, US )
! This routine initializes a unit_scale_type structure (US).

! Local variables
integer :: Z_power, L_power, T_power
real :: Z_rescale_factor, L_rescale_factor, T_rescale_factor
integer :: Z_power, L_power, T_power, R_power
real :: Z_rescale_factor, L_rescale_factor, T_rescale_factor, R_rescale_factor
! This include declares and sets the variable "version".
# include "version_variable.h"
character(len=16) :: mdl = "MOM_unit_scaling"
Expand All @@ -69,12 +72,18 @@ subroutine unit_scaling_init( param_file, US )
"An integer power of 2 that is used to rescale the model's "//&
"intenal units of time. Valid values range from -300 to 300.", &
units="nondim", default=0, debuggingParam=.true.)
call get_param(param_file, mdl, "R_RESCALE_POWER", R_power, &
"An integer power of 2 that is used to rescale the model's "//&
"intenal units of density. Valid values range from -300 to 300.", &
units="nondim", default=0, debuggingParam=.true.)
if (abs(Z_power) > 300) call MOM_error(FATAL, "unit_scaling_init: "//&
"Z_RESCALE_POWER is outside of the valid range of -300 to 300.")
if (abs(L_power) > 300) call MOM_error(FATAL, "unit_scaling_init: "//&
"L_RESCALE_POWER is outside of the valid range of -300 to 300.")
if (abs(T_power) > 300) call MOM_error(FATAL, "unit_scaling_init: "//&
"T_RESCALE_POWER is outside of the valid range of -300 to 300.")
if (abs(R_power) > 300) call MOM_error(FATAL, "unit_scaling_init: "//&
"R_RESCALE_POWER is outside of the valid range of -300 to 300.")

Z_rescale_factor = 1.0
if (Z_power /= 0) Z_rescale_factor = 2.0**Z_power
Expand All @@ -91,6 +100,11 @@ subroutine unit_scaling_init( param_file, US )
US%T_to_s = 1.0 * T_rescale_factor
US%s_to_T = 1.0 / T_rescale_factor

R_rescale_factor = 1.0
if (R_power /= 0) R_rescale_factor = 2.0**R_power
US%R_to_kg_m3 = 1.0 * R_rescale_factor
US%kg_m3_to_R = 1.0 / R_rescale_factor

! These are useful combinations of the fundamental scale conversion factors set above.
US%Z_to_L = US%Z_to_m * US%m_to_L
US%L_to_Z = US%L_to_m * US%m_to_Z
Expand All @@ -111,6 +125,7 @@ subroutine fix_restart_unit_scaling(US)
US%m_to_Z_restart = US%m_to_Z
US%m_to_L_restart = US%m_to_L
US%s_to_T_restart = US%s_to_T
US%kg_m3_to_R_restart = US%kg_m3_to_R

end subroutine fix_restart_unit_scaling

Expand Down

0 comments on commit 3704a66

Please sign in to comment.