Skip to content

Commit 400c982

Browse files
committed
+Add grid_unit_to_L to the ocean_grid_type
Add the new element grid_unit_to_L to the ocean_grid_type and the dyn_horgrid_type, which can be used to convert the units of the geoLat and geoLon variables to rescaled horizontal distance units ([L ~> m]) when they are Cartesian coordinates. When Cartesian coordinates are not in use, G%grid_unit_to_L is set to 0. This new element of the grid type is used to test for inconsistent grids or to eliminate rescaling variables in set_rotation_beta_plane(), initialize_velocity_circular(), DOME_initialize_topography(), DOME_initialize_sponges(), DOME_set_OBC_data(), ISOMIP_initialize_topography(), idealized_hurricane_wind_forcing(), Kelvin_set_OBC_data(), Rossby_front_initialize_velocity(), soliton_initialize_thickness(), and soliton_initialize_velocity(). These are the instances where this new variable could be used and bitwise identical answers are recovered. There are a few other places where they should be used, but where answers would change, and these will be deferred to a subsequent commit. All answers are bitwise identical, but there are new elements in two transparent and widely used types.
1 parent d8da512 commit 400c982

13 files changed

+110
-57
lines changed

src/core/MOM_grid.F90

+4
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ module MOM_grid
190190

191191
! These parameters are run-time parameters that are used during some
192192
! initialization routines (but not all)
193+
real :: grid_unit_to_L !< A factor that converts a the geoLat and geoLon variables and related
194+
!! variables like len_lat and len_lon into rescaled horizontal distance
195+
!! units on a Cartesian grid, in [L km ~> 1000] or [L m-1 ~> 1] or
196+
!! is 0 for a non-Cartesian grid.
193197
real :: south_lat !< The latitude (or y-coordinate) of the first v-line [degrees_N] or [km] or [m]
194198
real :: west_lon !< The longitude (or x-coordinate) of the first u-line [degrees_E] or [km] or [m]
195199
real :: len_lat !< The latitudinal (or y-coord) extent of physical domain [degrees_N] or [km] or [m]

src/core/MOM_transcribe_grid.F90

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ subroutine copy_dyngrid_to_MOM_grid(dG, oG, US)
135135
! Copy various scalar variables and strings.
136136
oG%x_axis_units = dG%x_axis_units ; oG%y_axis_units = dG%y_axis_units
137137
oG%x_ax_unit_short = dG%x_ax_unit_short ; oG%y_ax_unit_short = dG%y_ax_unit_short
138+
oG%grid_unit_to_L = dG%grid_unit_to_L
138139
oG%areaT_global = dG%areaT_global ; oG%IareaT_global = dG%IareaT_global
139140
oG%south_lat = dG%south_lat ; oG%west_lon = dG%west_lon
140141
oG%len_lat = dG%len_lat ; oG%len_lon = dG%len_lon
@@ -296,6 +297,7 @@ subroutine copy_MOM_grid_to_dyngrid(oG, dG, US)
296297
! Copy various scalar variables and strings.
297298
dG%x_axis_units = oG%x_axis_units ; dG%y_axis_units = oG%y_axis_units
298299
dG%x_ax_unit_short = oG%x_ax_unit_short ; dG%y_ax_unit_short = oG%y_ax_unit_short
300+
dG%grid_unit_to_L = oG%grid_unit_to_L
299301
dG%areaT_global = oG%areaT_global ; dG%IareaT_global = oG%IareaT_global
300302
dG%south_lat = oG%south_lat ; dG%west_lon = oG%west_lon
301303
dG%len_lat = oG%len_lat ; dG%len_lon = oG%len_lon

src/framework/MOM_dyn_horgrid.F90

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ module MOM_dyn_horgrid
181181

182182
! These parameters are run-time parameters that are used during some
183183
! initialization routines (but not all)
184+
real :: grid_unit_to_L !< A factor that converts a the geoLat and geoLon variables and related
185+
!! variables like len_lat and len_lon into rescaled horizontal distance
186+
!! units on a Cartesian grid, in [L km ~> 1000] or [L m-1 ~> 1] or
187+
!! is 0 for a non-Cartesian grid.
184188
real :: south_lat !< The latitude (or y-coordinate) of the first v-line [degrees_N] or [km] or [m]
185189
real :: west_lon !< The longitude (or x-coordinate) of the first u-line [degrees_E] or [km] or [m]
186190
real :: len_lat !< The latitudinal (or y-coord) extent of physical domain [degrees_N] or [km] or [m]
@@ -400,6 +404,7 @@ subroutine rotate_dyn_horgrid(G_in, G, US, turns)
400404
G%len_lon = G_in%len_lon
401405

402406
! Rotation-invariant fields
407+
G%grid_unit_to_L = G_in%grid_unit_to_L
403408
G%areaT_global = G_in%areaT_global
404409
G%IareaT_global = G_in%IareaT_global
405410
G%Rad_Earth = G_in%Rad_Earth

src/ice_shelf/MOM_ice_shelf_diag_mediator.F90

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ subroutine set_IS_axes_info(G, param_file, diag_cs, axes_set_name)
132132

133133
G%x_axis_units = "degrees_E" ; G%y_axis_units = "degrees_N"
134134
G%x_ax_unit_short = "degrees_E" ; G%y_ax_unit_short = "degrees_N"
135+
G%grid_unit_to_L = 0.0
135136

136137
if (index(lowercase(trim(grid_config)),"cartesian") > 0) then
137138
! This is a cartesian grid, and may have different axis units.
@@ -145,9 +146,11 @@ subroutine set_IS_axes_info(G, param_file, diag_cs, axes_set_name)
145146
if (units_temp(1:1) == 'k') then
146147
G%x_axis_units = "kilometers" ; G%y_axis_units = "kilometers"
147148
G%x_ax_unit_short = "km" ; G%y_ax_unit_short = "km"
149+
G%grid_unit_to_L = 1000.0*diag_cs%US%m_to_L
148150
elseif (units_temp(1:1) == 'm') then
149151
G%x_axis_units = "meters" ; G%y_axis_units = "meters"
150152
G%x_ax_unit_short = "m" ; G%y_ax_unit_short = "m"
153+
G%grid_unit_to_L = diag_cs%US%m_to_L
151154
endif
152155
call log_param(param_file, mdl, "explicit AXIS_UNITS", G%x_axis_units)
153156
else

src/initialization/MOM_grid_initialize.F90

+8-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ subroutine set_grid_metrics(G, param_file, US)
8484
! These are defaults that may be changed in the next select block.
8585
G%x_axis_units = "degrees_east" ; G%y_axis_units = "degrees_north"
8686
G%x_ax_unit_short = "degrees_E" ; G%y_ax_unit_short = "degrees_N"
87-
87+
G%grid_unit_to_L = 0.0
8888
G%Rad_Earth_L = -1.0*US%m_to_L ; G%len_lat = 0.0 ; G%len_lon = 0.0
8989
select case (trim(config))
9090
case ("mosaic"); call set_grid_metrics_from_mosaic(G, param_file, US)
@@ -251,6 +251,11 @@ subroutine set_grid_metrics_from_mosaic(G, param_file, US)
251251
G%geoLatCv(i,J) = tmpZ(i2-1,j2)
252252
enddo ; enddo
253253

254+
! This routine could be modified to support the use of a mosaic using Cartesian grid coordinates,
255+
! in which case the values of G%x_axis_units, G%y_axis_units and G%grid_unit_to_L would need to be
256+
! reset appropriately here, but this option has not yet been implemented, and the grid coordinates
257+
! are assumed to be degrees of longitude and latitude.
258+
254259
! Read DX,DY from the supergrid
255260
tmpU(:,:) = 0. ; tmpV(:,:) = 0.
256261
call MOM_read_data(filename, 'dx', tmpV, SGdom, position=NORTH_FACE, scale=US%m_to_L)
@@ -440,9 +445,11 @@ subroutine set_grid_metrics_cartesian(G, param_file, US)
440445
enddo
441446

442447
if (units_temp(1:1) == 'k') then ! Axes are measured in km.
448+
G%grid_unit_to_L = 1000.0*US%m_to_L
443449
dx_everywhere = 1000.0*US%m_to_L * G%len_lon / (REAL(niglobal))
444450
dy_everywhere = 1000.0*US%m_to_L * G%len_lat / (REAL(njglobal))
445451
elseif (units_temp(1:1) == 'm') then ! Axes are measured in m.
452+
G%grid_unit_to_L = US%m_to_L
446453
dx_everywhere = US%m_to_L*G%len_lon / (REAL(niglobal))
447454
dy_everywhere = US%m_to_L*G%len_lat / (REAL(njglobal))
448455
else ! Axes are measured in degrees of latitude and longitude.

src/initialization/MOM_shared_initialization.F90

+3-6
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ subroutine set_rotation_beta_plane(f, G, param_file, US)
485485
real :: f_0 ! The reference value of the Coriolis parameter [T-1 ~> s-1]
486486
real :: beta ! The meridional gradient of the Coriolis parameter [T-1 L-1 ~> s-1 m-1]
487487
real :: beta_lat_ref ! The reference latitude for the beta plane [degrees_N] or [km] or [m]
488-
real :: Rad_Earth_L ! The radius of the planet in rescaled units [L ~> m]
489488
real :: y_scl ! A scaling factor from the units of latitude [L lat-1 ~> m lat-1]
490489
real :: PI ! The ratio of the circumference of a circle to its diameter [nondim]
491490
character(len=40) :: mdl = "set_rotation_beta_plane" ! This subroutine's name.
@@ -503,18 +502,16 @@ subroutine set_rotation_beta_plane(f, G, param_file, US)
503502
call get_param(param_file, mdl, "AXIS_UNITS", axis_units, default="degrees")
504503

505504
PI = 4.0*atan(1.0)
505+
y_scl = G%grid_unit_to_L
506+
if (G%grid_unit_to_L <= 0.0) y_scl = PI * G%Rad_Earth_L / 180.
507+
506508
select case (axis_units(1:1))
507509
case ("d")
508-
call get_param(param_file, mdl, "RAD_EARTH", Rad_Earth_L, &
509-
"The radius of the Earth.", units="m", default=6.378e6, scale=US%m_to_L)
510510
beta_lat_ref_units = "degrees"
511-
y_scl = PI * Rad_Earth_L / 180.
512511
case ("k")
513512
beta_lat_ref_units = "kilometers"
514-
y_scl = 1.0e3 * US%m_to_L
515513
case ("m")
516514
beta_lat_ref_units = "meters"
517-
y_scl = 1.0 * US%m_to_L
518515
case default ; call MOM_error(FATAL, &
519516
" set_rotation_beta_plane: unknown AXIS_UNITS = "//trim(axis_units))
520517
end select

src/initialization/MOM_state_initialization.F90

+5-2
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,10 @@ subroutine initialize_velocity_circular(u, v, G, GV, US, param_file, just_read)
16361636

16371637
if (just_read) return ! All run-time parameters have been read, so return.
16381638

1639-
dpi=acos(0.0)*2.0 ! pi
1639+
if (G%grid_unit_to_L <= 0.) call MOM_error(FATAL, "MOM_state_initialization.F90: "//&
1640+
"initialize_velocity_circular() is only set to work with Cartesian axis units.")
1641+
1642+
dpi = acos(0.0)*2.0 ! pi
16401643

16411644
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
16421645
psi1 = my_psi(I,j)
@@ -1663,7 +1666,7 @@ real function my_psi(ig,jg)
16631666
r = sqrt( (x**2) + (y**2) ) ! Circular stream function is a function of radius only
16641667
r = min(1.0, r) ! Flatten stream function in corners of box
16651668
my_psi = 0.5*(1.0 - cos(dpi*r))
1666-
my_psi = my_psi * (circular_max_u * G%US%m_to_L*G%len_lon*1e3 / dpi) ! len_lon is in km
1669+
my_psi = my_psi * (circular_max_u * G%len_lon * G%grid_unit_to_L / dpi) ! len_lon is in km
16671670
end function my_psi
16681671

16691672
end subroutine initialize_velocity_circular

src/user/DOME_initialization.F90

+43-17
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,28 @@ subroutine DOME_initialize_topography(D, G, param_file, max_depth, US)
4949
real :: min_depth ! The minimum ocean depth [Z ~> m]
5050
real :: shelf_depth ! The ocean depth on the shelf in the DOME configuration [Z ~> m]
5151
real :: slope ! The bottom slope in the DOME configuration [Z L-1 ~> nondim]
52-
real :: shelf_edge_lat ! The latitude of the edge of the topographic shelf [km]
53-
real :: inflow_lon ! The edge longitude of the DOME inflow [km]
54-
real :: inflow_width ! The longitudinal width of the DOME inflow channel [km]
55-
real :: km_to_L ! The conversion factor from the units of latitude to L [L km-1 ~> 1e3]
52+
real :: shelf_edge_lat ! The latitude of the edge of the topographic shelf in the same units as geolat, often [km]
53+
real :: inflow_lon ! The edge longitude of the DOME inflow in the same units as geolon, often [km]
54+
real :: inflow_width ! The longitudinal width of the DOME inflow channel in the same units as geolat, often [km]
55+
real :: km_to_grid_unit ! The conversion factor from km to the units of latitude often 1 [nondim],
56+
! but this could be 1000 [m km-1]
5657
! This include declares and sets the variable "version".
5758
# include "version_variable.h"
5859
character(len=40) :: mdl = "DOME_initialize_topography" ! This subroutine's name.
5960
integer :: i, j, is, ie, js, je, isd, ied, jsd, jed
6061
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec
6162
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
6263

63-
km_to_L = 1.0e3*US%m_to_L
64+
if (G%grid_unit_to_L <= 0.) call MOM_error(FATAL, "DOME_initialization: "//&
65+
"DOME_initialize_topography is only set to work with Cartesian axis units.")
66+
if (abs(G%grid_unit_to_L*US%L_to_m - 1000.0) < 1.0e-3) then ! The grid latitudes are in km.
67+
km_to_grid_unit = 1.0
68+
elseif (abs(G%grid_unit_to_L*US%L_to_m - 1.0) < 1.0e-6) then ! The grid latitudes are in m.
69+
km_to_grid_unit = 1000.0
70+
else
71+
call MOM_error(FATAL, "DOME_initialization: "//&
72+
"DOME_initialize_topography is not recognizing the value of G%grid_unit_to_L.")
73+
endif
6474

6575
call MOM_mesg(" DOME_initialization.F90, DOME_initialize_topography: setting topography", 5)
6676

@@ -75,15 +85,16 @@ subroutine DOME_initialize_topography(D, G, param_file, max_depth, US)
7585
default=600.0, units="m", scale=US%m_to_Z)
7686
call get_param(param_file, mdl, "DOME_SHELF_EDGE_LAT", shelf_edge_lat, &
7787
"The latitude of the shelf edge in the DOME configuration.", &
78-
default=600.0, units="km")
88+
default=600.0, units="km", scale=km_to_grid_unit)
7989
call get_param(param_file, mdl, "DOME_INFLOW_LON", inflow_lon, &
80-
"The edge longitude of the DOME inflow.", units="km", default=1000.0)
90+
"The edge longitude of the DOME inflow.", units="km", default=1000.0, scale=km_to_grid_unit)
8191
call get_param(param_file, mdl, "DOME_INFLOW_WIDTH", inflow_width, &
82-
"The longitudinal width of the DOME inflow channel.", units="km", default=100.0)
92+
"The longitudinal width of the DOME inflow channel.", &
93+
units="km", default=100.0, scale=km_to_grid_unit)
8394

8495
do j=js,je ; do i=is,ie
8596
if (G%geoLatT(i,j) < shelf_edge_lat) then
86-
D(i,j) = min(shelf_depth - slope * (G%geoLatT(i,j)-shelf_edge_lat)*km_to_L, max_depth)
97+
D(i,j) = min(shelf_depth - slope * (G%geoLatT(i,j)-shelf_edge_lat)*G%grid_unit_to_L, max_depth)
8798
else
8899
if ((G%geoLonT(i,j) > inflow_lon) .AND. (G%geoLonT(i,j) < inflow_lon+inflow_width)) then
89100
D(i,j) = shelf_depth
@@ -177,7 +188,6 @@ subroutine DOME_initialize_sponges(G, GV, US, tv, depth_tot, PF, CSp)
177188
real :: min_depth ! The minimum depth at which to apply damping [Z ~> m]
178189
real :: damp_W, damp_E ! Damping rates in the western and eastern sponges [T-1 ~> s-1]
179190
real :: peak_damping ! The maximum sponge damping rates as the edges [T-1 ~> s-1]
180-
real :: km_to_L ! The conversion factor from the units of longitude to L [L km-1 ~> 1e3]
181191
real :: edge_dist ! The distance to an edge [L ~> m]
182192
real :: sponge_width ! The width of the sponges [L ~> m]
183193
character(len=40) :: mdl = "DOME_initialize_sponges" ! This subroutine's name.
@@ -186,7 +196,8 @@ subroutine DOME_initialize_sponges(G, GV, US, tv, depth_tot, PF, CSp)
186196
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
187197
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
188198

189-
km_to_L = 1.0e3*US%m_to_L
199+
if (G%grid_unit_to_L <= 0.) call MOM_error(FATAL, "DOME_initialization: "//&
200+
"DOME_initialize_sponges is only set to work with Cartesian axis units.")
190201

191202
! Set up sponges for the DOME configuration
192203
call get_param(PF, mdl, "MINIMUM_DEPTH", min_depth, &
@@ -196,15 +207,15 @@ subroutine DOME_initialize_sponges(G, GV, US, tv, depth_tot, PF, CSp)
196207
default=10.0, units="day-1", scale=1.0/(86400.0*US%s_to_T))
197208
call get_param(PF, mdl, "DOME_SPONGE_WIDTH", sponge_width, &
198209
"The width of the the DOME sponges.", &
199-
default=200.0, units="km", scale=km_to_L)
210+
default=200.0, units="km", scale=1.0e3*US%m_to_L)
200211

201212
! Here the inverse damping time [T-1 ~> s-1], is set. Set Idamp to 0 wherever
202213
! there is no sponge, and the subroutines that are called will automatically
203214
! set up the sponges only where Idamp is positive and mask2dT is 1.
204215

205216
Idamp(:,:) = 0.0
206217
do j=js,je ; do i=is,ie ; if (depth_tot(i,j) > min_depth) then
207-
edge_dist = (G%geoLonT(i,j) - G%west_lon) * km_to_L
218+
edge_dist = (G%geoLonT(i,j) - G%west_lon) * G%grid_unit_to_L
208219
if (edge_dist < 0.5*sponge_width) then
209220
damp_W = peak_damping
210221
elseif (edge_dist < sponge_width) then
@@ -213,7 +224,7 @@ subroutine DOME_initialize_sponges(G, GV, US, tv, depth_tot, PF, CSp)
213224
damp_W = 0.0
214225
endif
215226

216-
edge_dist = ((G%len_lon + G%west_lon) - G%geoLonT(i,j)) * km_to_L
227+
edge_dist = ((G%len_lon + G%west_lon) - G%geoLonT(i,j)) * G%grid_unit_to_L
217228
if (edge_dist < 0.5*sponge_width) then
218229
damp_E = peak_damping
219230
elseif (edge_dist < sponge_width) then
@@ -328,10 +339,12 @@ subroutine DOME_set_OBC_data(OBC, tv, G, GV, US, PF, tr_Reg)
328339
! properties [T-1 ~> s-1]
329340
real :: g_prime_tot ! The reduced gravity across all layers [L2 Z-1 T-2 ~> m s-2]
330341
real :: Def_Rad ! The deformation radius, based on fluid of thickness D_edge [L ~> m]
331-
real :: inflow_lon ! The edge longitude of the DOME inflow [km]
342+
real :: inflow_lon ! The edge longitude of the DOME inflow in the same units as geolon, often [km]
332343
real :: I_Def_Rad ! The inverse of the deformation radius in the same units as G%geoLon [km-1]
333344
real :: Ri_trans ! The shear Richardson number in the transition
334345
! region of the specified shear profile [nondim]
346+
real :: km_to_grid_unit ! The conversion factor from km to the units of latitude often 1 [nondim],
347+
! but this could be 1000 [m km-1]
335348
character(len=32) :: name ! The name of a tracer field.
336349
character(len=40) :: mdl = "DOME_set_OBC_data" ! This subroutine's name.
337350
integer :: i, j, k, itt, is, ie, js, je, isd, ied, jsd, jed, m, nz, ntherm, ntr_id
@@ -343,6 +356,17 @@ subroutine DOME_set_OBC_data(OBC, tv, G, GV, US, PF, tr_Reg)
343356
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
344357
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
345358

359+
if (G%grid_unit_to_L <= 0.) call MOM_error(FATAL, "DOME_initialization: "//&
360+
"DOME_initialize_topography is only set to work with Cartesian axis units.")
361+
if (abs(G%grid_unit_to_L*US%L_to_m - 1000.0) < 1.0e-3) then ! The grid latitudes are in km.
362+
km_to_grid_unit = 1.0
363+
elseif (abs(G%grid_unit_to_L*US%L_to_m - 1.0) < 1.0e-6) then ! The grid latitudes are in m.
364+
km_to_grid_unit = 1000.0
365+
else
366+
call MOM_error(FATAL, "DOME_initialization: "//&
367+
"DOME_initialize_topography is not recognizing the value of G%grid_unit_to_L.")
368+
endif
369+
346370
call get_param(PF, mdl, "DOME_INFLOW_THICKNESS", D_edge, &
347371
"The thickness of the dense DOME inflow at the inner edge.", &
348372
default=300.0, units="m", scale=US%m_to_Z)
@@ -362,7 +386,7 @@ subroutine DOME_set_OBC_data(OBC, tv, G, GV, US, PF, tr_Reg)
362386
"The value of the Coriolis parameter that is used to determine the DOME "//&
363387
"inflow properties.", units="s-1", default=f_0*US%s_to_T, scale=US%T_to_s)
364388
call get_param(PF, mdl, "DOME_INFLOW_LON", inflow_lon, &
365-
"The edge longitude of the DOME inflow.", units="km", default=1000.0)
389+
"The edge longitude of the DOME inflow.", units="km", default=1000.0, scale=km_to_grid_unit)
366390
if (associated(tv%S) .or. associated(tv%T)) then
367391
call get_param(PF, mdl, "S_REF", S_ref, &
368392
units="ppt", default=35.0, scale=US%ppt_to_S, do_not_log=.true.)
@@ -383,7 +407,9 @@ subroutine DOME_set_OBC_data(OBC, tv, G, GV, US, PF, tr_Reg)
383407
tr_0 = (-D_edge*sqrt(D_edge*g_prime_tot)*0.5*Def_Rad) * (Rlay_Ref + 0.5*Rlay_range) * GV%RZ_to_H
384408
endif
385409

386-
I_Def_Rad = 1.0 / (1.0e-3*US%L_to_m*Def_Rad)
410+
I_Def_Rad = 1.0 / ((1.0e-3*US%L_to_m*km_to_grid_unit) * Def_Rad)
411+
! This is mathematically equivalent to
412+
! I_Def_Rad = G%grid_unit_to_L / Def_Rad
387413

388414
if (OBC%number_of_segments /= 1) then
389415
call MOM_error(WARNING, 'Error in DOME OBC segment setup', .true.)

src/user/ISOMIP_initialization.F90

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ subroutine ISOMIP_initialize_topography(D, G, param_file, max_depth, US)
5959
real :: ly ! domain width (across ice flow) [L ~> m]
6060
real :: bx, by ! The x- and y- contributions to the bathymetric profiles at a point [Z ~> m]
6161
real :: xtil ! x-positon normalized by the characteristic along-flow length scale [nondim]
62-
real :: km_to_L ! The conversion factor from the axis units to L [L km-1 ~> 1e3]
6362
logical :: is_2D ! If true, use a 2D setup
6463
! This include declares and sets the variable "version".
6564
# include "version_variable.h"
@@ -93,16 +92,17 @@ subroutine ISOMIP_initialize_topography(D, G, param_file, max_depth, US)
9392
"Characteristic width of the side walls of the channel in the ISOMIP configuration.", &
9493
units="m", default=4.0e3, scale=US%m_to_L)
9594

96-
km_to_L = 1.0e3*US%m_to_L
95+
if (G%grid_unit_to_L <= 0.) call MOM_error(FATAL, "ISOMIP_initialization.F90: " //&
96+
"ISOMIP_initialize_topography is only set to work with Cartesian axis units.")
9797

9898
! The following variables should be transformed into runtime parameters.
9999
b0 = -150.0*US%m_to_Z ; b2 = -728.8*US%m_to_Z ; b4 = 343.91*US%m_to_Z ; b6 = -50.57*US%m_to_Z
100100

101101
if (is_2D) then
102102
do j=js,je ; do i=is,ie
103103
! For the 2D setup take a slice through the middle of the domain
104-
xtil = G%geoLonT(i,j)*km_to_L / xbar
105-
!xtil = 450.*km_to_L / xbar
104+
xtil = G%geoLonT(i,j)*G%grid_unit_to_L / xbar
105+
! xtil = 450.0e3*US%m_to_L / xbar
106106
bx = b0 + b2*xtil**2 + b4*xtil**4 + b6*xtil**6
107107

108108
by = 2.0 * dc / (1.0 + exp(2.0*wc / fc))
@@ -117,17 +117,17 @@ subroutine ISOMIP_initialize_topography(D, G, param_file, max_depth, US)
117117
! 3D setup
118118
! ===== TEST =====
119119
!if (G%geoLonT(i,j)<500.) then
120-
! xtil = 500.*km_to_L / xbar
120+
! xtil = 500.0e3*US%m_to_L / xbar
121121
!else
122-
! xtil = G%geoLonT(i,j)*km_to_L / xbar
122+
! xtil = G%geoLonT(i,j)*G%grid_unit_to_L / xbar
123123
!endif
124124
! ===== TEST =====
125125

126-
xtil = G%geoLonT(i,j)*km_to_L / xbar
126+
xtil = G%geoLonT(i,j)*G%grid_unit_to_L / xbar
127127

128128
bx = b0 + b2*xtil**2 + b4*xtil**4 + b6*xtil**6
129-
by = (dc / (1.0 + exp(-2.*(G%geoLatT(i,j)*km_to_L - 0.5*ly - wc) / fc))) + &
130-
(dc / (1.0 + exp(2.*(G%geoLatT(i,j)*km_to_L - 0.5*ly + wc) / fc)))
129+
by = (dc / (1.0 + exp(-2.*(G%geoLatT(i,j)*G%grid_unit_to_L - 0.5*ly - wc) / fc))) + &
130+
(dc / (1.0 + exp(2.*(G%geoLatT(i,j)*G%grid_unit_to_L - 0.5*ly + wc) / fc)))
131131

132132
D(i,j) = -max(bx+by, -bmax)
133133
if (D(i,j) > max_depth) D(i,j) = max_depth

0 commit comments

Comments
 (0)