Skip to content

Commit

Permalink
+Eliminated Zd_to_m from grid types
Browse files Browse the repository at this point in the history
  Eliminated Zd_to_m from dyn_horgrid_type and ocean_grid_type.  Instead, any
dimensional rescaling uses elements of unit_scale_types.  All answers are
bitwise identical.
  • Loading branch information
Hallberg-NOAA committed Nov 15, 2018
1 parent 3d4c891 commit fac1464
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
8 changes: 3 additions & 5 deletions src/core/MOM_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ module MOM_grid

real ALLOCABLE_, dimension(NIMEM_,NJMEM_) :: &
bathyT !< Ocean bottom depth at tracer points, in depth units.
real :: Zd_to_m = 1.0 !< The conversion factor between the units of bathyT and m.

logical :: bathymetry_at_vel !< If true, there are separate values for the
!! basin depths at velocity points. Otherwise the effects of
Expand Down Expand Up @@ -165,7 +164,7 @@ module MOM_grid
real :: len_lat = 0. !< The latitudinal (or y-coord) extent of physical domain
real :: len_lon = 0. !< The longitudinal (or x-coord) extent of physical domain
real :: Rad_Earth = 6.378e6 !< The radius of the planet in meters.
real :: max_depth !< The maximum depth of the ocean in depth units (scaled by Zd_to_m).
real :: max_depth !< The maximum depth of the ocean in depth units (Z).
end type ocean_grid_type

contains
Expand Down Expand Up @@ -359,13 +358,13 @@ subroutine rescale_grid_bathymetry(G, m_in_new_units)
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB

if (m_in_new_units == G%Zd_to_m) return
if (m_in_new_units == 1.0) return
if (m_in_new_units < 0.0) &
call MOM_error(FATAL, "rescale_grid_bathymetry: Negative depth units are not permitted.")
if (m_in_new_units == 0.0) &
call MOM_error(FATAL, "rescale_grid_bathymetry: Zero depth units are not permitted.")

rescale = G%Zd_to_m / m_in_new_units
rescale = 1.0 / m_in_new_units
do j=jsd,jed ; do i=isd,ied
G%bathyT(i,j) = rescale*G%bathyT(i,j)
enddo ; enddo
Expand All @@ -376,7 +375,6 @@ subroutine rescale_grid_bathymetry(G, m_in_new_units)
G%Dblock_v(i,J) = rescale*G%Dblock_v(i,J) ; G%Dopen_v(i,J) = rescale*G%Dopen_v(i,J)
enddo ; enddo ; endif
G%max_depth = rescale*G%max_depth
G%Zd_to_m = m_in_new_units

end subroutine rescale_grid_bathymetry

Expand Down
2 changes: 0 additions & 2 deletions src/core/MOM_transcribe_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ subroutine copy_dyngrid_to_MOM_grid(dG, oG)
if ((isd > oG%isc) .or. (ied < oG%ied) .or. (jsd > oG%jsc) .or. (jed > oG%jed)) &
call MOM_error(FATAL, "copy_dyngrid_to_MOM_grid called with incompatible grids.")

oG%Zd_to_m = dG%Zd_to_m
do i=isd,ied ; do j=jsd,jed
oG%geoLonT(i,j) = dG%geoLonT(i+ido,j+jdo)
oG%geoLatT(i,j) = dG%geoLatT(i+ido,j+jdo)
Expand Down Expand Up @@ -188,7 +187,6 @@ subroutine copy_MOM_grid_to_dyngrid(oG, dG)
if ((isd > dG%isc) .or. (ied < dG%ied) .or. (jsd > dG%jsc) .or. (jed > dG%jed)) &
call MOM_error(FATAL, "copy_dyngrid_to_MOM_grid called with incompatible grids.")

dG%Zd_to_m = oG%Zd_to_m
do i=isd,ied ; do j=jsd,jed
dG%geoLonT(i,j) = oG%geoLonT(i+ido,j+jdo)
dG%geoLatT(i,j) = oG%geoLatT(i+ido,j+jdo)
Expand Down
16 changes: 7 additions & 9 deletions src/framework/MOM_dyn_horgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,16 @@ module MOM_dyn_horgrid

real, allocatable, dimension(:,:) :: &
bathyT !< Ocean bottom depth at tracer points, in depth units.
real :: Zd_to_m = 1.0 !< The conversion factor between the units of bathyT and m.

logical :: bathymetry_at_vel !< If true, there are separate values for the
!! basin depths at velocity points. Otherwise the effects of
!! of topography are entirely determined from thickness points.
real, allocatable, dimension(:,:) :: &
Dblock_u, & !< Topographic depths at u-points at which the flow is blocked, in depth units.
Dopen_u !< Topographic depths at u-points at which the flow is open at width dy_Cu, in depth units.
Dblock_u, & !< Topographic depths at u-points at which the flow is blocked, in Z.
Dopen_u !< Topographic depths at u-points at which the flow is open at width dy_Cu, in Z.
real, allocatable, dimension(:,:) :: &
Dblock_v, & !< Topographic depths at v-points at which the flow is blocked, in depth units.
Dopen_v !< Topographic depths at v-points at which the flow is open at width dx_Cv, in depth units.
Dblock_v, & !< Topographic depths at v-points at which the flow is blocked, in Z.
Dopen_v !< Topographic depths at v-points at which the flow is open at width dx_Cv, in Z.
real, allocatable, dimension(:,:) :: &
CoriolisBu !< The Coriolis parameter at corner points, in s-1.
real, allocatable, dimension(:,:) :: &
Expand All @@ -160,7 +159,7 @@ module MOM_dyn_horgrid
real :: len_lat = 0. !< The latitudinal (or y-coord) extent of physical domain
real :: len_lon = 0. !< The longitudinal (or x-coord) extent of physical domain
real :: Rad_Earth = 6.378e6 !< The radius of the planet in meters.
real :: max_depth !< The maximum depth of the ocean in depth units (scaled by Zd_to_m).
real :: max_depth !< The maximum depth of the ocean in Z.
end type dyn_horgrid_type

contains
Expand Down Expand Up @@ -287,13 +286,13 @@ subroutine rescale_dyn_horgrid_bathymetry(G, m_in_new_units)
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB

if (m_in_new_units == G%Zd_to_m) return
if (m_in_new_units == 1.0) return
if (m_in_new_units < 0.0) &
call MOM_error(FATAL, "rescale_grid_bathymetry: Negative depth units are not permitted.")
if (m_in_new_units == 0.0) &
call MOM_error(FATAL, "rescale_grid_bathymetry: Zero depth units are not permitted.")

rescale = G%Zd_to_m / m_in_new_units
rescale = 1.0 / m_in_new_units
do j=jsd,jed ; do i=isd,ied
G%bathyT(i,j) = rescale*G%bathyT(i,j)
enddo ; enddo
Expand All @@ -304,7 +303,6 @@ subroutine rescale_dyn_horgrid_bathymetry(G, m_in_new_units)
G%Dblock_v(i,J) = rescale*G%Dblock_v(i,J) ; G%Dopen_v(i,J) = rescale*G%Dopen_v(i,J)
enddo ; enddo ; endif
G%max_depth = rescale*G%max_depth
G%Zd_to_m = m_in_new_units

end subroutine rescale_dyn_horgrid_bathymetry

Expand Down

0 comments on commit fac1464

Please sign in to comment.