portedportable, not yet portedexecuted, not portableexecutable, not hit by this run
| 1 | ! This file is part of MOM6, the Modular Ocean Model version 6. | |
| 2 | ! See the LICENSE file for licensing information. | |
| 3 | ! SPDX-License-Identifier: Apache-2.0 | |
| 4 | ||
| 5 | !> Module with routines for copying information from a shared dynamic horizontal | |
| 6 | !! grid to an ocean-specific horizontal grid and the reverse. | |
| 7 | module MOM_transcribe_grid | |
| 8 | ||
| 9 | use MOM_array_transform, only : rotate_array, rotate_array_pair | |
| 10 | use MOM_domains, only : pass_var, pass_vector | |
| 11 | use MOM_domains, only : To_All, SCALAR_PAIR, CGRID_NE, AGRID, BGRID_NE, CORNER | |
| 12 | use MOM_dyn_horgrid, only : dyn_horgrid_type, set_derived_dyn_horgrid | |
| 13 | use MOM_dyn_horgrid, only : rotate_dyngrid=>rotate_dyn_horgrid | |
| 14 | use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING | |
| 15 | use MOM_grid, only : ocean_grid_type, set_derived_metrics | |
| 16 | use MOM_unit_scaling, only : unit_scale_type | |
| 17 | ||
| 18 | implicit none ; private | |
| 19 | ||
| 20 | public copy_dyngrid_to_MOM_grid, copy_MOM_grid_to_dyngrid, rotate_dyngrid | |
| 21 | ||
| 22 | contains | |
| 23 | ||
| 24 | !> Copies information from a dynamic (shared) horizontal grid type into an | |
| 25 | !! ocean_grid_type. There may also be a change in the reference | |
| 26 | !! height for topography between the two grids. | |
| 27 | 1 | subroutine copy_dyngrid_to_MOM_grid(dG, oG, US) |
| 28 | type(dyn_horgrid_type), intent(in) :: dG !< Common horizontal grid type | |
| 29 | type(ocean_grid_type), intent(inout) :: oG !< Ocean grid type | |
| 30 | type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type | |
| 31 | ||
| 32 | integer :: isd, ied, jsd, jed ! Common data domains. | |
| 33 | integer :: IsdB, IedB, JsdB, JedB ! Common data domains. | |
| 34 | integer :: ido, jdo, Ido2, Jdo2 ! Indexing offsets between the grids. | |
| 35 | integer :: Igst, Jgst ! Global starting indices. | |
| 36 | integer :: i, j | |
| 37 | ||
| 38 | ! MOM_grid_init and create_dyn_horgrid are called outside of this routine. | |
| 39 | ! This routine copies over the fields that were set by MOM_initialized_fixed. | |
| 40 | ||
| 41 | ! Determine the indexing offsets between the grids. | |
| 42 | 1 | ido = dG%idg_offset - oG%idg_offset |
| 43 | 1 | jdo = dG%jdg_offset - oG%jdg_offset |
| 44 | ||
| 45 | 1 | isd = max(oG%isd, dG%isd+ido) ; jsd = max(oG%jsd, dG%jsd+jdo) |
| 46 | 1 | ied = min(oG%ied, dG%ied+ido) ; jed = min(oG%jed, dG%jed+jdo) |
| 47 | 1 | IsdB = max(oG%IsdB, dG%IsdB+ido) ; JsdB = max(oG%JsdB, dG%JsdB+jdo) |
| 48 | 1 | IedB = min(oG%IedB, dG%IedB+ido) ; JedB = min(oG%JedB, dG%JedB+jdo) |
| 49 | ||
| 50 | ! Check that the grids conform. | |
| 51 | 1 | if ((isd > oG%isc) .or. (ied < oG%ied) .or. (jsd > oG%jsc) .or. (jed > oG%jed)) & |
| 52 | 0 | call MOM_error(FATAL, "copy_dyngrid_to_MOM_grid called with incompatible grids.") |
| 53 | ||
| 54 | 8833 | do i=isd,ied ; do j=jsd,jed |
| 55 | 8704 | oG%geoLonT(i,j) = dG%geoLonT(i+ido,j+jdo) |
| 56 | 8704 | oG%geoLatT(i,j) = dG%geoLatT(i+ido,j+jdo) |
| 57 | 8704 | oG%dxT(i,j) = dG%dxT(i+ido,j+jdo) |
| 58 | 8704 | oG%dyT(i,j) = dG%dyT(i+ido,j+jdo) |
| 59 | 8704 | oG%areaT(i,j) = dG%areaT(i+ido,j+jdo) |
| 60 | 8704 | oG%bathyT(i,j) = dG%bathyT(i+ido,j+jdo) - oG%Z_ref |
| 61 | 8704 | oG%meanSL(i,j) = dG%meanSL(i+ido,j+jdo) + oG%Z_ref |
| 62 | ||
| 63 | 8704 | oG%dF_dx(i,j) = dG%dF_dx(i+ido,j+jdo) |
| 64 | 8704 | oG%dF_dy(i,j) = dG%dF_dy(i+ido,j+jdo) |
| 65 | 8704 | oG%sin_rot(i,j) = dG%sin_rot(i+ido,j+jdo) |
| 66 | 8704 | oG%cos_rot(i,j) = dG%cos_rot(i+ido,j+jdo) |
| 67 | 8832 | oG%mask2dT(i,j) = dG%mask2dT(i+ido,j+jdo) |
| 68 | enddo ; enddo | |
| 69 | ||
| 70 | 8902 | do I=IsdB,IedB ; do j=jsd,jed |
| 71 | 8772 | oG%geoLonCu(I,j) = dG%geoLonCu(I+ido,j+jdo) |
| 72 | 8772 | oG%geoLatCu(I,j) = dG%geoLatCu(I+ido,j+jdo) |
| 73 | 8772 | oG%dxCu(I,j) = dG%dxCu(I+ido,j+jdo) |
| 74 | 8772 | oG%dyCu(I,j) = dG%dyCu(I+ido,j+jdo) |
| 75 | 8772 | oG%dy_Cu(I,j) = dG%dy_Cu(I+ido,j+jdo) |
| 76 | ||
| 77 | 8772 | oG%porous_DminU(I,j) = dG%porous_DminU(I+ido,j+jdo) - oG%Z_ref |
| 78 | 8772 | oG%porous_DmaxU(I,j) = dG%porous_DmaxU(I+ido,j+jdo) - oG%Z_ref |
| 79 | 8772 | oG%porous_DavgU(I,j) = dG%porous_DavgU(I+ido,j+jdo) - oG%Z_ref |
| 80 | ||
| 81 | 8772 | oG%mask2dCu(I,j) = dG%mask2dCu(I+ido,j+jdo) |
| 82 | 8772 | oG%OBCmaskCu(I,j) = dG%OBCmaskCu(I+ido,j+jdo) |
| 83 | 8772 | oG%areaCu(I,j) = dG%areaCu(I+ido,j+jdo) |
| 84 | 8901 | oG%IareaCu(I,j) = dG%IareaCu(I+ido,j+jdo) |
| 85 | enddo ; enddo | |
| 86 | ||
| 87 | 8961 | do i=isd,ied ; do J=JsdB,JedB |
| 88 | 8832 | oG%geoLonCv(i,J) = dG%geoLonCv(i+ido,J+jdo) |
| 89 | 8832 | oG%geoLatCv(i,J) = dG%geoLatCv(i+ido,J+jdo) |
| 90 | 8832 | oG%dxCv(i,J) = dG%dxCv(i+ido,J+jdo) |
| 91 | 8832 | oG%dyCv(i,J) = dG%dyCv(i+ido,J+jdo) |
| 92 | 8832 | oG%dx_Cv(i,J) = dG%dx_Cv(i+ido,J+jdo) |
| 93 | ||
| 94 | 8832 | oG%porous_DminV(i,J) = dG%porous_DminV(i+ido,J+jdo) - oG%Z_ref |
| 95 | 8832 | oG%porous_DmaxV(i,J) = dG%porous_DmaxV(i+ido,J+jdo) - oG%Z_ref |
| 96 | 8832 | oG%porous_DavgV(i,J) = dG%porous_DavgV(i+ido,J+jdo) - oG%Z_ref |
| 97 | ||
| 98 | 8832 | oG%mask2dCv(i,J) = dG%mask2dCv(i+ido,J+jdo) |
| 99 | 8832 | oG%OBCmaskCv(i,J) = dG%OBCmaskCv(i+ido,J+jdo) |
| 100 | 8832 | oG%areaCv(i,J) = dG%areaCv(i+ido,J+jdo) |
| 101 | 8960 | oG%IareaCv(i,J) = dG%IareaCv(i+ido,J+jdo) |
| 102 | enddo ; enddo | |
| 103 | ||
| 104 | 9031 | do I=IsdB,IedB ; do J=JsdB,JedB |
| 105 | 8901 | oG%geoLonBu(I,J) = dG%geoLonBu(I+ido,J+jdo) |
| 106 | 8901 | oG%geoLatBu(I,J) = dG%geoLatBu(I+ido,J+jdo) |
| 107 | 8901 | oG%dxBu(I,J) = dG%dxBu(I+ido,J+jdo) |
| 108 | 8901 | oG%dyBu(I,J) = dG%dyBu(I+ido,J+jdo) |
| 109 | 8901 | oG%areaBu(I,J) = dG%areaBu(I+ido,J+jdo) |
| 110 | 8901 | oG%CoriolisBu(I,J) = dG%CoriolisBu(I+ido,J+jdo) |
| 111 | 8901 | oG%Coriolis2Bu(I,J) = dG%Coriolis2Bu(I+ido,J+jdo) |
| 112 | 9030 | oG%mask2dBu(I,J) = dG%mask2dBu(I+ido,J+jdo) |
| 113 | enddo ; enddo | |
| 114 | ||
| 115 | 1 | oG%bathymetry_at_vel = dG%bathymetry_at_vel |
| 116 | 1 | if (oG%bathymetry_at_vel) then |
| 117 | 0 | do I=IsdB,IedB ; do j=jsd,jed |
| 118 | 0 | oG%Dblock_u(I,j) = dG%Dblock_u(I+ido,j+jdo) - oG%Z_ref |
| 119 | 0 | oG%Dopen_u(I,j) = dG%Dopen_u(I+ido,j+jdo) - oG%Z_ref |
| 120 | enddo ; enddo | |
| 121 | 0 | do i=isd,ied ; do J=JsdB,JedB |
| 122 | 0 | oG%Dblock_v(i,J) = dG%Dblock_v(i+ido,J+jdo) - oG%Z_ref |
| 123 | 0 | oG%Dopen_v(i,J) = dG%Dopen_v(i+ido,J+jdo) - oG%Z_ref |
| 124 | enddo ; enddo | |
| 125 | endif | |
| 126 | ||
| 127 | 121 | oG%gridLonT(oG%isg:oG%ieg) = dG%gridLonT(dG%isg:dG%ieg) |
| 128 | 61 | oG%gridLatT(oG%jsg:oG%jeg) = dG%gridLatT(dG%jsg:dG%jeg) |
| 129 | ! The more complicated logic here avoids segmentation faults if one grid uses | |
| 130 | ! global symmetric memory while the other does not. Because a northeast grid | |
| 131 | ! convention is being used, the upper bounds for each array correspond. | |
| 132 | ! Note that the dynamic grid always uses symmetric memory. | |
| 133 | 1 | Ido2 = dG%IegB-oG%IegB ; Igst = max(oG%IsgB, (dG%isg-1)-Ido2) |
| 134 | 1 | Jdo2 = dG%JegB-oG%JegB ; Jgst = max(oG%JsgB, (dG%jsg-1)-Jdo2) |
| 135 | 122 | do I=Igst,oG%IegB ; oG%gridLonB(I) = dG%gridLonB(I+Ido2) ; enddo |
| 136 | 62 | do J=Jgst,oG%JegB ; oG%gridLatB(J) = dG%gridLatB(J+Jdo2) ; enddo |
| 137 | ||
| 138 | ! Copy various scalar variables and strings. | |
| 139 | 1 | oG%x_axis_units = dG%x_axis_units ; oG%y_axis_units = dG%y_axis_units |
| 140 | 1 | oG%x_ax_unit_short = dG%x_ax_unit_short ; oG%y_ax_unit_short = dG%y_ax_unit_short |
| 141 | 1 | oG%grid_unit_to_L = dG%grid_unit_to_L |
| 142 | 1 | oG%areaT_global = dG%areaT_global ; oG%IareaT_global = dG%IareaT_global |
| 143 | 1 | oG%south_lat = dG%south_lat ; oG%west_lon = dG%west_lon |
| 144 | 1 | oG%len_lat = dG%len_lat ; oG%len_lon = dG%len_lon |
| 145 | 1 | oG%Rad_Earth_L = dG%Rad_Earth_L |
| 146 | 1 | oG%max_depth = dG%max_depth |
| 147 | ||
| 148 | ! Update the halos in case the dynamic grid has smaller halos than the ocean grid. | |
| 149 | 1 | call pass_var(oG%areaT, oG%Domain) |
| 150 | 1 | call pass_var(oG%bathyT, oG%Domain) |
| 151 | 1 | call pass_var(oG%meanSL, oG%Domain) |
| 152 | 1 | call pass_var(oG%geoLonT, oG%Domain) |
| 153 | 1 | call pass_var(oG%geoLatT, oG%Domain) |
| 154 | 1 | call pass_vector(oG%dxT, oG%dyT, oG%Domain, To_All+Scalar_Pair, AGRID) |
| 155 | 1 | call pass_vector(oG%dF_dx, oG%dF_dy, oG%Domain, To_All, AGRID) |
| 156 | 1 | call pass_vector(oG%cos_rot, oG%sin_rot, oG%Domain, To_All, AGRID) |
| 157 | 1 | call pass_var(oG%mask2dT, oG%Domain) |
| 158 | ||
| 159 | 1 | call pass_vector(oG%areaCu, oG%areaCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 160 | 1 | call pass_vector(oG%dyCu, oG%dxCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 161 | 1 | call pass_vector(oG%dxCu, oG%dyCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 162 | 1 | call pass_vector(oG%dy_Cu, oG%dx_Cv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 163 | 1 | call pass_vector(oG%mask2dCu, oG%mask2dCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 164 | 1 | call pass_vector(oG%OBCmaskCu, oG%OBCmaskCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 165 | 1 | call pass_vector(oG%IareaCu, oG%IareaCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 166 | 1 | call pass_vector(oG%IareaCu, oG%IareaCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 167 | 1 | call pass_vector(oG%geoLatCu, oG%geoLatCv, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 168 | ||
| 169 | 1 | call pass_var(oG%areaBu, oG%Domain, position=CORNER) |
| 170 | 1 | call pass_var(oG%geoLonBu, oG%Domain, position=CORNER, inner_halo=oG%isc-isd) |
| 171 | 1 | call pass_var(oG%geoLatBu, oG%Domain, position=CORNER) |
| 172 | 1 | call pass_vector(oG%dxBu, oG%dyBu, oG%Domain, To_All+Scalar_Pair, BGRID_NE) |
| 173 | 1 | call pass_var(oG%CoriolisBu, oG%Domain, position=CORNER) |
| 174 | 1 | call pass_var(oG%Coriolis2Bu, oG%Domain, position=CORNER) |
| 175 | 1 | call pass_var(oG%mask2dBu, oG%Domain, position=CORNER) |
| 176 | ||
| 177 | 1 | if (oG%bathymetry_at_vel) then |
| 178 | 0 | call pass_vector(oG%Dblock_u, oG%Dblock_v, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 179 | 0 | call pass_vector(oG%Dopen_u, oG%Dopen_v, oG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 180 | endif | |
| 181 | ||
| 182 | 1 | call set_derived_metrics(oG, US) |
| 183 | ||
| 184 | 1 | end subroutine copy_dyngrid_to_MOM_grid |
| 185 | ||
| 186 | ||
| 187 | !> Copies information from an ocean_grid_type into a dynamic (shared) | |
| 188 | !! horizontal grid type. There may also be a change in the reference | |
| 189 | !! height for topography between the two grids. | |
| 190 | 0 | subroutine copy_MOM_grid_to_dyngrid(oG, dG, US) |
| 191 | type(ocean_grid_type), intent(in) :: oG !< Ocean grid type | |
| 192 | type(dyn_horgrid_type), intent(inout) :: dG !< Common horizontal grid type | |
| 193 | type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type | |
| 194 | ||
| 195 | integer :: isd, ied, jsd, jed ! Common data domains. | |
| 196 | integer :: IsdB, IedB, JsdB, JedB ! Common data domains. | |
| 197 | integer :: ido, jdo, Ido2, Jdo2 ! Indexing offsets between the grids. | |
| 198 | integer :: Igst, Jgst ! Global starting indices. | |
| 199 | integer :: i, j | |
| 200 | ||
| 201 | ! MOM_grid_init and create_dyn_horgrid are called outside of this routine. | |
| 202 | ! This routine copies over the fields that were set by MOM_initialized_fixed. | |
| 203 | ||
| 204 | ! Determine the indexing offsets between the grids. | |
| 205 | 0 | ido = oG%idG_offset - dG%idG_offset |
| 206 | 0 | jdo = oG%jdG_offset - dG%jdG_offset |
| 207 | ||
| 208 | 0 | isd = max(dG%isd, oG%isd+ido) ; jsd = max(dG%jsd, oG%jsd+jdo) |
| 209 | 0 | ied = min(dG%ied, oG%ied+ido) ; jed = min(dG%jed, oG%jed+jdo) |
| 210 | 0 | IsdB = max(dG%IsdB, oG%IsdB+ido) ; JsdB = max(dG%JsdB, oG%JsdB+jdo) |
| 211 | 0 | IedB = min(dG%IedB, oG%IedB+ido) ; JedB = min(dG%JedB, oG%JedB+jdo) |
| 212 | ||
| 213 | ! Check that the grids conform. | |
| 214 | 0 | if ((isd > dG%isc) .or. (ied < dG%ied) .or. (jsd > dG%jsc) .or. (jed > dG%jed)) & |
| 215 | 0 | call MOM_error(FATAL, "copy_dyngrid_to_MOM_grid called with incompatible grids.") |
| 216 | ||
| 217 | 0 | do i=isd,ied ; do j=jsd,jed |
| 218 | 0 | dG%geoLonT(i,j) = oG%geoLonT(i+ido,j+jdo) |
| 219 | 0 | dG%geoLatT(i,j) = oG%geoLatT(i+ido,j+jdo) |
| 220 | 0 | dG%dxT(i,j) = oG%dxT(i+ido,j+jdo) |
| 221 | 0 | dG%dyT(i,j) = oG%dyT(i+ido,j+jdo) |
| 222 | 0 | dG%areaT(i,j) = oG%areaT(i+ido,j+jdo) |
| 223 | 0 | dG%bathyT(i,j) = oG%bathyT(i+ido,j+jdo) + oG%Z_ref |
| 224 | 0 | dG%meanSL(i,j) = oG%meanSL(i+ido,j+jdo) - oG%Z_ref |
| 225 | ||
| 226 | 0 | dG%dF_dx(i,j) = oG%dF_dx(i+ido,j+jdo) |
| 227 | 0 | dG%dF_dy(i,j) = oG%dF_dy(i+ido,j+jdo) |
| 228 | 0 | dG%sin_rot(i,j) = oG%sin_rot(i+ido,j+jdo) |
| 229 | 0 | dG%cos_rot(i,j) = oG%cos_rot(i+ido,j+jdo) |
| 230 | 0 | dG%mask2dT(i,j) = oG%mask2dT(i+ido,j+jdo) |
| 231 | enddo ; enddo | |
| 232 | ||
| 233 | 0 | do I=IsdB,IedB ; do j=jsd,jed |
| 234 | 0 | dG%geoLonCu(I,j) = oG%geoLonCu(I+ido,j+jdo) |
| 235 | 0 | dG%geoLatCu(I,j) = oG%geoLatCu(I+ido,j+jdo) |
| 236 | 0 | dG%dxCu(I,j) = oG%dxCu(I+ido,j+jdo) |
| 237 | 0 | dG%dyCu(I,j) = oG%dyCu(I+ido,j+jdo) |
| 238 | 0 | dG%dy_Cu(I,j) = oG%dy_Cu(I+ido,j+jdo) |
| 239 | ||
| 240 | 0 | dG%porous_DminU(I,j) = oG%porous_DminU(I+ido,j+jdo) + oG%Z_ref |
| 241 | 0 | dG%porous_DmaxU(I,j) = oG%porous_DmaxU(I+ido,j+jdo) + oG%Z_ref |
| 242 | 0 | dG%porous_DavgU(I,j) = oG%porous_DavgU(I+ido,j+jdo) + oG%Z_ref |
| 243 | ||
| 244 | 0 | dG%mask2dCu(I,j) = oG%mask2dCu(I+ido,j+jdo) |
| 245 | 0 | dG%OBCmaskCu(I,j) = oG%OBCmaskCu(I+ido,j+jdo) |
| 246 | 0 | dG%areaCu(I,j) = oG%areaCu(I+ido,j+jdo) |
| 247 | 0 | dG%IareaCu(I,j) = oG%IareaCu(I+ido,j+jdo) |
| 248 | enddo ; enddo | |
| 249 | ||
| 250 | 0 | do i=isd,ied ; do J=JsdB,JedB |
| 251 | 0 | dG%geoLonCv(i,J) = oG%geoLonCv(i+ido,J+jdo) |
| 252 | 0 | dG%geoLatCv(i,J) = oG%geoLatCv(i+ido,J+jdo) |
| 253 | 0 | dG%dxCv(i,J) = oG%dxCv(i+ido,J+jdo) |
| 254 | 0 | dG%dyCv(i,J) = oG%dyCv(i+ido,J+jdo) |
| 255 | 0 | dG%dx_Cv(i,J) = oG%dx_Cv(i+ido,J+jdo) |
| 256 | ||
| 257 | 0 | dG%porous_DminV(i,J) = oG%porous_DminU(i+ido,J+jdo) + oG%Z_ref |
| 258 | 0 | dG%porous_DmaxV(i,J) = oG%porous_DmaxU(i+ido,J+jdo) + oG%Z_ref |
| 259 | 0 | dG%porous_DavgV(i,J) = oG%porous_DavgU(i+ido,J+jdo) + oG%Z_ref |
| 260 | ||
| 261 | 0 | dG%mask2dCv(i,J) = oG%mask2dCv(i+ido,J+jdo) |
| 262 | 0 | dG%OBCmaskCv(i,J) = oG%OBCmaskCv(i+ido,J+jdo) |
| 263 | 0 | dG%areaCv(i,J) = oG%areaCv(i+ido,J+jdo) |
| 264 | 0 | dG%IareaCv(i,J) = oG%IareaCv(i+ido,J+jdo) |
| 265 | enddo ; enddo | |
| 266 | ||
| 267 | 0 | do I=IsdB,IedB ; do J=JsdB,JedB |
| 268 | 0 | dG%geoLonBu(I,J) = oG%geoLonBu(I+ido,J+jdo) |
| 269 | 0 | dG%geoLatBu(I,J) = oG%geoLatBu(I+ido,J+jdo) |
| 270 | 0 | dG%dxBu(I,J) = oG%dxBu(I+ido,J+jdo) |
| 271 | 0 | dG%dyBu(I,J) = oG%dyBu(I+ido,J+jdo) |
| 272 | 0 | dG%areaBu(I,J) = oG%areaBu(I+ido,J+jdo) |
| 273 | 0 | dG%CoriolisBu(I,J) = oG%CoriolisBu(I+ido,J+jdo) |
| 274 | 0 | dG%Coriolis2Bu(I,J) = oG%Coriolis2Bu(I+ido,J+jdo) |
| 275 | 0 | dG%mask2dBu(I,J) = oG%mask2dBu(I+ido,J+jdo) |
| 276 | enddo ; enddo | |
| 277 | ||
| 278 | 0 | dG%bathymetry_at_vel = oG%bathymetry_at_vel |
| 279 | 0 | if (dG%bathymetry_at_vel) then |
| 280 | 0 | do I=IsdB,IedB ; do j=jsd,jed |
| 281 | 0 | dG%Dblock_u(I,j) = oG%Dblock_u(I+ido,j+jdo) + oG%Z_ref |
| 282 | 0 | dG%Dopen_u(I,j) = oG%Dopen_u(I+ido,j+jdo) + oG%Z_ref |
| 283 | enddo ; enddo | |
| 284 | 0 | do i=isd,ied ; do J=JsdB,JedB |
| 285 | 0 | dG%Dblock_v(i,J) = oG%Dblock_v(i+ido,J+jdo) + oG%Z_ref |
| 286 | 0 | dG%Dopen_v(i,J) = oG%Dopen_v(i+ido,J+jdo) + oG%Z_ref |
| 287 | enddo ; enddo | |
| 288 | endif | |
| 289 | ||
| 290 | 0 | dG%gridLonT(dG%isg:dG%ieg) = oG%gridLonT(oG%isg:oG%ieg) |
| 291 | 0 | dG%gridLatT(dG%jsg:dG%jeg) = oG%gridLatT(oG%jsg:oG%jeg) |
| 292 | ||
| 293 | ! The more complicated logic here avoids segmentation faults if one grid uses | |
| 294 | ! global symmetric memory while the other does not. Because a northeast grid | |
| 295 | ! convention is being used, the upper bounds for each array correspond. | |
| 296 | ! Note that the dynamic grid always uses symmetric memory. | |
| 297 | 0 | Ido2 = oG%IegB-dG%IegB ; Igst = max(dG%isg-1, oG%IsgB-Ido2) |
| 298 | 0 | Jdo2 = oG%JegB-dG%JegB ; Jgst = max(dG%jsg-1, oG%JsgB-Jdo2) |
| 299 | 0 | do I=Igst,dG%IegB ; dG%gridLonB(I) = oG%gridLonB(I+Ido2) ; enddo |
| 300 | 0 | do J=Jgst,dG%JegB ; dG%gridLatB(J) = oG%gridLatB(J+Jdo2) ; enddo |
| 301 | ||
| 302 | ! Copy various scalar variables and strings. | |
| 303 | 0 | dG%x_axis_units = oG%x_axis_units ; dG%y_axis_units = oG%y_axis_units |
| 304 | 0 | dG%x_ax_unit_short = oG%x_ax_unit_short ; dG%y_ax_unit_short = oG%y_ax_unit_short |
| 305 | 0 | dG%grid_unit_to_L = oG%grid_unit_to_L |
| 306 | 0 | dG%areaT_global = oG%areaT_global ; dG%IareaT_global = oG%IareaT_global |
| 307 | 0 | dG%south_lat = oG%south_lat ; dG%west_lon = oG%west_lon |
| 308 | 0 | dG%len_lat = oG%len_lat ; dG%len_lon = oG%len_lon |
| 309 | 0 | dG%Rad_Earth_L = oG%Rad_Earth_L |
| 310 | 0 | dG%max_depth = oG%max_depth |
| 311 | ||
| 312 | ! Update the halos in case the dynamic grid has smaller halos than the ocean grid. | |
| 313 | 0 | call pass_var(dG%areaT, dG%Domain) |
| 314 | 0 | call pass_var(dG%bathyT, dG%Domain) |
| 315 | 0 | call pass_var(dG%meanSL, dG%Domain) |
| 316 | 0 | call pass_var(dG%geoLonT, dG%Domain) |
| 317 | 0 | call pass_var(dG%geoLatT, dG%Domain) |
| 318 | 0 | call pass_vector(dG%dxT, dG%dyT, dG%Domain, To_All+Scalar_Pair, AGRID) |
| 319 | 0 | call pass_vector(dG%dF_dx, dG%dF_dy, dG%Domain, To_All, AGRID) |
| 320 | 0 | call pass_vector(dG%cos_rot, dG%sin_rot, dG%Domain, To_All, AGRID) |
| 321 | 0 | call pass_var(dG%mask2dT, dG%Domain) |
| 322 | ||
| 323 | 0 | call pass_vector(dG%areaCu, dG%areaCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 324 | 0 | call pass_vector(dG%dyCu, dG%dxCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 325 | 0 | call pass_vector(dG%dxCu, dG%dyCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 326 | 0 | call pass_vector(dG%dy_Cu, dG%dx_Cv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 327 | 0 | call pass_vector(dG%mask2dCu, dG%mask2dCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 328 | 0 | call pass_vector(dG%OBCmaskCu, dG%OBCmaskCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 329 | 0 | call pass_vector(dG%IareaCu, dG%IareaCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 330 | 0 | call pass_vector(dG%IareaCu, dG%IareaCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 331 | 0 | call pass_vector(dG%geoLatCu, dG%geoLatCv, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 332 | ||
| 333 | 0 | call pass_var(dG%areaBu, dG%Domain, position=CORNER) |
| 334 | 0 | call pass_var(dG%geoLonBu, dG%Domain, position=CORNER, inner_halo=dG%isc-isd) |
| 335 | 0 | call pass_var(dG%geoLatBu, dG%Domain, position=CORNER) |
| 336 | 0 | call pass_vector(dG%dxBu, dG%dyBu, dG%Domain, To_All+Scalar_Pair, BGRID_NE) |
| 337 | 0 | call pass_var(dG%CoriolisBu, dG%Domain, position=CORNER) |
| 338 | 0 | call pass_var(dG%Coriolis2Bu, dG%Domain, position=CORNER) |
| 339 | 0 | call pass_var(dG%mask2dBu, dG%Domain, position=CORNER) |
| 340 | ||
| 341 | 0 | if (dG%bathymetry_at_vel) then |
| 342 | 0 | call pass_vector(dG%Dblock_u, dG%Dblock_v, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 343 | 0 | call pass_vector(dG%Dopen_u, dG%Dopen_v, dG%Domain, To_All+Scalar_Pair, CGRID_NE) |
| 344 | endif | |
| 345 | ||
| 346 | 0 | call set_derived_dyn_horgrid(dG, US) |
| 347 | ||
| 348 | 0 | end subroutine copy_MOM_grid_to_dyngrid |
| 349 | ||
| 350 | end module MOM_transcribe_grid |