Allocates and initializes the ocean model unit scaling type.
57 type(param_file_type),
optional,
intent(in) :: param_file
58 type(unit_scale_type),
optional,
pointer :: US
63 integer :: Z_power, L_power, T_power, R_power, Q_power
64 real :: Z_rescale_factor, L_rescale_factor, T_rescale_factor, R_rescale_factor, Q_rescale_factor
66 # include "version_variable.h"
67 character(len=16) :: mdl =
"MOM_unit_scaling"
69 if (.not.
present(us))
return
71 if (
associated(us))
call mom_error(fatal, &
72 'unit_scaling_init: called with an associated US pointer.')
75 if (
present(param_file))
then
77 call log_version(param_file, mdl, version, &
78 "Parameters for doing unit scaling of variables.", debugging=.true.)
79 call get_param(param_file, mdl,
"Z_RESCALE_POWER", z_power, &
80 "An integer power of 2 that is used to rescale the model's "//&
81 "internal units of depths and heights. Valid values range from -300 to 300.", &
82 units=
"nondim", default=0, debuggingparam=.true.)
83 call get_param(param_file, mdl,
"L_RESCALE_POWER", l_power, &
84 "An integer power of 2 that is used to rescale the model's "//&
85 "internal units of lateral distances. Valid values range from -300 to 300.", &
86 units=
"nondim", default=0, debuggingparam=.true.)
87 call get_param(param_file, mdl,
"T_RESCALE_POWER", t_power, &
88 "An integer power of 2 that is used to rescale the model's "//&
89 "internal units of time. Valid values range from -300 to 300.", &
90 units=
"nondim", default=0, debuggingparam=.true.)
91 call get_param(param_file, mdl,
"R_RESCALE_POWER", r_power, &
92 "An integer power of 2 that is used to rescale the model's "//&
93 "internal units of density. Valid values range from -300 to 300.", &
94 units=
"nondim", default=0, debuggingparam=.true.)
95 call get_param(param_file, mdl,
"Q_RESCALE_POWER", q_power, &
96 "An integer power of 2 that is used to rescale the model's "//&
97 "internal units of heat content. Valid values range from -300 to 300.", &
98 units=
"nondim", default=0, debuggingparam=.true.)
100 z_power = 0 ; l_power = 0 ; t_power = 0 ; r_power = 0 ; q_power = 0
103 if (abs(z_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
104 "Z_RESCALE_POWER is outside of the valid range of -300 to 300.")
105 if (abs(l_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
106 "L_RESCALE_POWER is outside of the valid range of -300 to 300.")
107 if (abs(t_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
108 "T_RESCALE_POWER is outside of the valid range of -300 to 300.")
109 if (abs(r_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
110 "R_RESCALE_POWER is outside of the valid range of -300 to 300.")
111 if (abs(q_power) > 300)
call mom_error(fatal,
"unit_scaling_init: "//&
112 "Q_RESCALE_POWER is outside of the valid range of -300 to 300.")
114 z_rescale_factor = 1.0
115 if (z_power /= 0) z_rescale_factor = 2.0**z_power
116 us%Z_to_m = 1.0 * z_rescale_factor
117 us%m_to_Z = 1.0 / z_rescale_factor
119 l_rescale_factor = 1.0
120 if (l_power /= 0) l_rescale_factor = 2.0**l_power
121 us%L_to_m = 1.0 * l_rescale_factor
122 us%m_to_L = 1.0 / l_rescale_factor
124 t_rescale_factor = 1.0
125 if (t_power /= 0) t_rescale_factor = 2.0**t_power
126 us%T_to_s = 1.0 * t_rescale_factor
127 us%s_to_T = 1.0 / t_rescale_factor
129 r_rescale_factor = 1.0
130 if (r_power /= 0) r_rescale_factor = 2.0**r_power
131 us%R_to_kg_m3 = 1.0 * r_rescale_factor
132 us%kg_m3_to_R = 1.0 / r_rescale_factor
134 q_rescale_factor = 1.0
135 if (q_power /= 0) q_rescale_factor = 2.0**q_power
136 us%Q_to_J_kg = 1.0 * q_rescale_factor
137 us%J_kg_to_Q = 1.0 / q_rescale_factor
140 us%Z_to_L = us%Z_to_m * us%m_to_L
141 us%L_to_Z = us%L_to_m * us%m_to_Z
143 us%L_T_to_m_s = us%L_to_m * us%s_to_T
144 us%m_s_to_L_T = us%m_to_L * us%T_to_s
146 us%L_T2_to_m_s2 = us%L_to_m * us%s_to_T**2
149 us%Z2_T_to_m2_s = us%Z_to_m**2 * us%s_to_T
150 us%m2_s_to_Z2_T = us%m_to_Z**2 * us%T_to_s
152 us%RZ_to_kg_m2 = us%R_to_kg_m3 * us%Z_to_m
155 us%kg_m2s_to_RZ_T = us%kg_m3_to_R * us%m_to_Z * us%T_to_s
156 us%RZ_T_to_kg_m2s = us%R_to_kg_m3 * us%Z_to_m * us%s_to_T
158 us%RZ3_T3_to_W_m2 = us%R_to_kg_m3 * us%Z_to_m**3 * us%s_to_T**3
159 us%W_m2_to_RZ3_T3 = us%kg_m3_to_R * us%m_to_Z**3 * us%T_to_s**3
161 us%W_m2_to_QRZ_T = us%J_kg_to_Q * us%kg_m3_to_R * us%m_to_Z * us%T_to_s
162 us%QRZ_T_to_W_m2 = us%Q_to_J_kg * us%R_to_kg_m3 * us%Z_to_m * us%s_to_T
164 us%RL2_T2_to_Pa = us%R_to_kg_m3 * us%L_T_to_m_s**2