9 implicit none ;
private
34 real :: m_to_z_restart = 0.0
35 real :: m_to_l_restart = 0.0
36 real :: s_to_t_restart = 0.0
37 real :: kg_m3_to_r_restart = 0.0
50 integer :: z_power, l_power, t_power, r_power
51 real :: z_rescale_factor, l_rescale_factor, t_rescale_factor, r_rescale_factor
53 # include "version_variable.h"
54 character(len=16) :: mdl =
"MOM_unit_scaling"
56 if (
associated(us))
call mom_error(fatal, &
57 'unit_scaling_init: called with an associated US pointer.')
62 "Parameters for doing unit scaling of variables.")
63 call get_param(param_file, mdl,
"Z_RESCALE_POWER", z_power, &
64 "An integer power of 2 that is used to rescale the model's "//&
65 "intenal units of depths and heights. Valid values range from -300 to 300.", &
66 units=
"nondim", default=0, debuggingparam=.true.)
67 call get_param(param_file, mdl,
"L_RESCALE_POWER", l_power, &
68 "An integer power of 2 that is used to rescale the model's "//&
69 "intenal units of lateral distances. Valid values range from -300 to 300.", &
70 units=
"nondim", default=0, debuggingparam=.true.)
71 call get_param(param_file, mdl,
"T_RESCALE_POWER", t_power, &
72 "An integer power of 2 that is used to rescale the model's "//&
73 "intenal units of time. Valid values range from -300 to 300.", &
74 units=
"nondim", default=0, debuggingparam=.true.)
75 call get_param(param_file, mdl,
"R_RESCALE_POWER", r_power, &
76 "An integer power of 2 that is used to rescale the model's "//&
77 "intenal units of density. Valid values range from -300 to 300.", &
78 units=
"nondim", default=0, debuggingparam=.true.)
79 if (abs(z_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
80 "Z_RESCALE_POWER is outside of the valid range of -300 to 300.")
81 if (abs(l_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
82 "L_RESCALE_POWER is outside of the valid range of -300 to 300.")
83 if (abs(t_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
84 "T_RESCALE_POWER is outside of the valid range of -300 to 300.")
85 if (abs(r_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
86 "R_RESCALE_POWER is outside of the valid range of -300 to 300.")
88 z_rescale_factor = 1.0
89 if (z_power /= 0) z_rescale_factor = 2.0**z_power
90 us%Z_to_m = 1.0 * z_rescale_factor
91 us%m_to_Z = 1.0 / z_rescale_factor
93 l_rescale_factor = 1.0
94 if (l_power /= 0) l_rescale_factor = 2.0**l_power
95 us%L_to_m = 1.0 * l_rescale_factor
96 us%m_to_L = 1.0 / l_rescale_factor
98 t_rescale_factor = 1.0
99 if (t_power /= 0) t_rescale_factor = 2.0**t_power
100 us%T_to_s = 1.0 * t_rescale_factor
101 us%s_to_T = 1.0 / t_rescale_factor
103 r_rescale_factor = 1.0
104 if (r_power /= 0) r_rescale_factor = 2.0**r_power
105 us%R_to_kg_m3 = 1.0 * r_rescale_factor
106 us%kg_m3_to_R = 1.0 / r_rescale_factor
109 us%Z_to_L = us%Z_to_m * us%m_to_L
110 us%L_to_Z = us%L_to_m * us%m_to_Z
111 us%L_T_to_m_s = us%L_to_m * us%s_to_T
112 us%m_s_to_L_T = us%m_to_L * us%T_to_s
113 us%L_T2_to_m_s2 = us%L_to_m * us%s_to_T**2
115 us%Z2_T_to_m2_s = us%Z_to_m**2 * us%s_to_T
116 us%m2_s_to_Z2_T = us%m_to_Z**2 * us%T_to_s
125 us%m_to_Z_restart = us%m_to_Z
126 us%m_to_L_restart = us%m_to_L
127 us%s_to_T_restart = us%s_to_T
128 us%kg_m3_to_R_restart = us%kg_m3_to_R