Warning, /doc/phys_pkgs/exch2.rst is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit bf89a37a on 2019-03-17 03:29:27 UTC
8679f9097b Jeff*0001 .. _sub_phys_pkg_exch2:
0002
0003 exch2: Extended Cubed Sphere Topology
0004 -------------------------------------
0005
bf89a37abc Phob*0006 (in directory: :filelink:`pkg/exch2/`)
0007
8679f9097b Jeff*0008 Introduction
0009 ++++++++++++
0010
bf89a37abc Phob*0011 The ``exch2`` package extends the original cubed sphere topology
8679f9097b Jeff*0012 configuration to allow more flexible domain decomposition and
0013 parallelization. Cube faces (also called subdomains) may be divided
0014 into any number of tiles that divide evenly into the grid point
0015 dimensions of the subdomain. Furthermore, the tiles can run on
0016 separate processors individually or in groups, which provides for
0017 manual compile-time load balancing across a relatively arbitrary
0018 number of processors.
0019
bf89a37abc Phob*0020 The exchange parameters are declared in :filelink:`W2_EXCH_TOPOLOGY.h <pkg/exch2/W2_EXCH2_TOPOLOGY.h>`
0021 and assigned in :filelink:`w2_e2setup.F <pkg/exch2/w2_e2setup.F>`. The
8679f9097b Jeff*0022 validity of the cube topology depends on the ``SIZE.h`` file as
0023 detailed below. The default files provided in the release configure a
0024 cubed sphere topology of six tiles, one per subdomain, each with
0025 32 :math:`\times` 32 grid points, with all tiles running on a single processor. Both
0026 files are generated by Matlab scripts in
bf89a37abc Phob*0027 :filelink:`utils/exch2/matlab-topology-generator`; see :numref:`ssub_exch2_topogen`
8679f9097b Jeff*0028 for details on creating alternate topologies. Pregenerated examples
0029 of these files with alternate topologies are provided under
bf89a37abc Phob*0030 :filelink:`utils/exch2/code-mods` along with the appropriate ``SIZE.h``
8679f9097b Jeff*0031 file for single-processor execution.
0032
0033 Invoking exch2
0034 ++++++++++++++
0035
0036 To use exch2 with the cubed sphere, the following conditions must be
0037 met:
0038
bf89a37abc Phob*0039 - The exch2 package is included when ``genmake2`` is run. The easiest way to do this is to add the line ``exch2`` to the ``packages.conf`` file -- see Section :ref:`building_code` for general details.
8679f9097b Jeff*0040
bf89a37abc Phob*0041 - An example of :code:`W2_EXCH2_TOPOLOGY.h` and ``w2_e2setup.F`` must reside in a directory containing files symbolically linked by the ``genmake2`` script. The safest place to put these is the directory indicated in the :code:`-mods=DIR` command line modifier (typically ``../code``), or the build directory. The default versions of these files reside in :filelink:`pkg/exch2` and are linked automatically if no other versions exist elsewhere in the build path, but they should be left untouched to avoid breaking configurations other than the one you intend to modify.
8679f9097b Jeff*0042
0043 - Files containing grid parameters, named ``tile00$n$.mitgrid`` where n=(1:6) (one per subdomain), must be in the working directory when the MITgcm executable is run. These files are provided in the example experiments for cubed sphere configurations with 32 :math:`\times` 32 cube sides -- please contact MITgcm support if you want to generate files for other configurations.
0044
bf89a37abc Phob*0045 - As always when compiling MITgcm, the file ``SIZE.h`` must be placed where ``genmake2`` will find it. In particular for exch2, the domain decomposition specified in ``SIZE.h`` must correspond with the particular configuration's topology specified in ``W2_EXCH2_TOPOLOGY.h`` and ``w2_e2setup.F``. Domain decomposition issues particular to exch2 are addressed in Section :ref:`ssub_exch2_topogen` and :ref:`ssub_exch2mpi` a more general background on the subject relevant to MITgcm is presented in Section :ref:`using_wrapper`.
8679f9097b Jeff*0046
0047 At the time of this writing the following examples use exch2 and may
0048 be used for guidance:
0049
bf89a37abc Phob*0050 - :filelink:`verification/adjust_nlfs.cs-32x32x1`
0051 - :filelink:`verification/adjustment.cs-32x32x1`
0052 - :filelink:`verification/aim.5l_cs`
0053 - :filelink:`verification/global_ocean.cs32x15`
0054 - :filelink:`verification/hs94.cs-32x32x5`
8679f9097b Jeff*0055
0056
0057
0058 .. _ssub_exch2_topogen:
0059
0060 Generating Topology Files for exch2
0061 +++++++++++++++++++++++++++++++++++
0062
0063 Alternate cubed sphere topologies may be created using the Matlab
bf89a37abc Phob*0064 scripts in :filelink:`utils/exch2/matlab-topology-generator`. Running the
0065 m-file :filelink:`driver.m <utils/exch2/matlab-topology-generator/driver.m>`
8679f9097b Jeff*0066 from the Matlab prompt (there are no parameters to pass) generates
bf89a37abc Phob*0067 exch2 topology files ``W2_EXCH2_TOPOLOGY.h`` and
0068 ``w2_e2setup.F`` in the working directory and displays a figure of
0069 the topology via Matlab -- :numref:`fig_6tile`, :numref:`fig_18tile`,
0070 and :numref:`fig_48tile` are examples of the generated diagrams. The other
8679f9097b Jeff*0071 m-files in the directory are
bf89a37abc Phob*0072 subroutines called from :filelink:`driver.m <utils/exch2/matlab-topology-generator/driver.m>` and should not be run ''bare'' except
8679f9097b Jeff*0073 for development purposes.
0074
0075 The parameters that determine the dimensions and topology of the
0076 generated configuration are :code:`nr`, :code:`nb`, :code:`ng`,
0077 :code:`tnx` and :code:`tny`, and all are assigned early in the script.
0078
0079 The first three determine the height and width of the subdomains and
0080 hence the size of the overall domain. Each one determines the number
0081 of grid points, and therefore the resolution, along the subdomain
0082 sides in a ''great circle'' around each the three spatial axes of the cube. At the time
0083 of this writing MITgcm requires these three parameters to be equal,
0084 but they provide for future releases to accomodate different
0085 resolutions around the axes to allow subdomains with differing resolutions.
0086
0087 The parameters :code:`tnx` and :code:`tny` determine the width and height of
0088 the tiles into which the subdomains are decomposed, and must evenly
0089 divide the integer assigned to :code:`nr`, :code:`nb` and :code:`ng`.
0090 The result is a rectangular tiling of the subdomain. :numref:`fig_48tile` shows one possible topology for a twenty-four-tile
0091 cube, and :numref:`fig_6tile` shows one for six tiles.
0092
0093 .. figure:: figs/adjust_cs.*
0094 :width: 70%
0095 :align: center
0096 :alt: cube sphere topology
0097 :name: fig_48tile
0098
0099 Plot of a cubed sphere topology with a 32 :math:`\times` 192 domain divided into six 32 :math:`\times` 32 subdomains, each of which is divided into eight tiles of width :code:`tnx=16` and height :code:`tny=8` for a total of forty-eight tiles. The colored borders of the subdomains represent the parameters :code:`nr` (red), :code:`ng` (green), and :code:`nb` (blue). This tiling is used in the example verification/adjustment.cs-32x32x1/ with the option (blanklist.txt) to remove the land-only 4 tiles (11,12,13,14) which are filled in red on the plot.
0100
0101
0102 .. figure:: figs/polarcap.*
0103 :width: 70%
0104 :align: center
0105 :alt: polar cap topology
0106 :name: fig_18tile
0107
0108 Plot of a non-square cubed sphere topology with 6 subdomains of different size (nr=90,ng=360,nb=90), divided into one to four tiles each (:code:`tnx=90, tny=90`), resulting in a total of 18 tiles.
0109
0110
0111 .. figure:: figs/s6t_32x32.*
0112 :width: 70%
0113 :align: center
0114 :alt: default cubed sphere topology
0115 :name: fig_6tile
0116
0117 Plot of a cubed sphere topology with a 32 :math:`\times` 192 domain divided into six 32 :math:`\times` 32 subdomains with one tile each (:code:`tnx=32, tny=32`). This is the default configuration.
0118
0119
0120 Tiles can be selected from the topology to be omitted from being
0121 allocated memory and processors. This tuning is useful in ocean
0122 modeling for omitting tiles that fall entirely on land. The tiles
0123 omitted are specified in the file blanklist.txt by their tile number in the topology, separated by a newline.
0124
0125
0126
0127 .. _ssub_exch2mpi:
0128
0129 exch2, SIZE.h, and Multiprocessing
0130 ++++++++++++++++++++++++++++++++++
0131
0132
0133 Once the topology configuration files are created, each Fortran
0134 ``PARAMETER`` in ``SIZE.h`` must be configured to match.
bf89a37abc Phob*0135 :numref:`using_wrapper` povides a general description of domain
0136 decomposition within MITgcm and its relation to ``SIZE.h``. The
8679f9097b Jeff*0137 current section specifies constraints that the exch2 package imposes
0138 and describes how to enable parallel execution with MPI.
0139
bf89a37abc Phob*0140 As in the general case, the parameters :varlink:`sNx` and
0141 :varlink:`sNy` define the size of the individual tiles, and so
0142 must be assigned the same respective values as ``tnx`` and
0143 ``tny`` in :filelink:`driver.m <utils/exch2/matlab-topology-generator/driver.m>`.
8679f9097b Jeff*0144
bf89a37abc Phob*0145 The halo width parameters :varlink:`OLx` and :varlink:`OLy`
8679f9097b Jeff*0146 have no special bearing on exch2 and may be assigned as in the general
bf89a37abc Phob*0147 case. The same holds for :varlink:`Nr`, the number of vertical
8679f9097b Jeff*0148 levels in the model.
0149
bf89a37abc Phob*0150 The parameters :varlink:`nSx`, :varlink:`nSy`,
0151 :varlink:`nPx`, and :varlink:`nPy` relate to the number of
8679f9097b Jeff*0152 tiles and how they are distributed on processors. When using exch2,
bf89a37abc Phob*0153 the tiles are stored in the ``x`` dimension, and so
0154 :varlink:`nSy` =1 in all cases. Since the tiles as
8679f9097b Jeff*0155 configured by exch2 cannot be split up accross processors without
bf89a37abc Phob*0156 regenerating the topology, :varlink:`nPy` = 1 as well.
8679f9097b Jeff*0157
0158 The number of tiles MITgcm allocates and how they are distributed
bf89a37abc Phob*0159 between processors depends on :varlink:`nPx` and
0160 :varlink:`nSx`. :varlink:`nSx` is the number of tiles per
0161 processor and :varlink:`nPx` is the number of processors. The
8679f9097b Jeff*0162 total number of tiles in the topology minus those listed in
bf89a37abc Phob*0163 ``blanklist.txt`` must equal :code:`nSx*nPx`. Note that in order to
8679f9097b Jeff*0164 obtain maximum usage from a given number of processors in some cases,
0165 this restriction might entail sharing a processor with a tile that
0166 would otherwise be excluded because it is topographically outside of
bf89a37abc Phob*0167 the domain and therefore in ``blanklist.txt``. For example,
8679f9097b Jeff*0168 suppose you have five processors and a domain decomposition of
0169 thirty-six tiles that allows you to exclude seven tiles. To evenly
0170 distribute the remaining twenty-nine tiles among five processors, you
0171 would have to run one ''dummy'' tile to make an even six tiles per
bf89a37abc Phob*0172 processor. Such dummy tiles are *not* listed in
0173 ``blanklist.txt``.
8679f9097b Jeff*0174
bf89a37abc Phob*0175 The following is an example of ``SIZE.h`` for the six-tile
0176 configuration illustrated in :numref:`fig_6tile`
8679f9097b Jeff*0177 running on one processor:
0178
0179 ::
0180
0181 PARAMETER (
0182 & sNx = 32,
0183 & sNy = 32,
0184 & OLx = 2,
0185 & OLy = 2,
0186 & nSx = 6,
0187 & nSy = 1,
0188 & nPx = 1,
0189 & nPy = 1,
0190 & Nx = sNx*nSx*nPx,
0191 & Ny = sNy*nSy*nPy,
0192 & Nr = 5)
0193
0194 The following is an example for the forty-eight-tile topology in
bf89a37abc Phob*0195 :numref:`fig_48tile` running on six processors:
8679f9097b Jeff*0196
0197 ::
0198
0199 PARAMETER (
0200 & sNx = 16,
0201 & sNy = 8,
0202 & OLx = 2,
0203 & OLy = 2,
0204 & nSx = 8,
0205 & nSy = 1,
0206 & nPx = 6,
0207 & nPy = 1,
0208 & Nx = sNx*nSx*nPx,
0209 & Ny = sNy*nSy*nPy,
0210 & Nr = 5)
0211
0212
0213
0214 .. _ssub_exch2_key_variables:
0215
0216 Key Variables
0217 +++++++++++++
0218
0219 The descriptions of the variables are divided up into scalars,
0220 one-dimensional arrays indexed to the tile number, and two and
0221 three-dimensional arrays indexed to tile number and neighboring tile.
0222 This division reflects the functionality of these variables: The
0223 scalars are common to every part of the topology, the tile-indexed
0224 arrays to individual tiles, and the arrays indexed by tile and
0225 neighbor to relationships between tiles and their neighbors.
0226
0227 Scalars:
bf89a37abc Phob*0228 ~~~~~~~~
8679f9097b Jeff*0229
0230 The number of tiles in a particular topology is set with the parameter
bf89a37abc Phob*0231 :varlink:`exch2_nTiles`, and the maximum number of neighbors of any tiles by
0232 :varlink:`W2_maxNeighbours`. These parameters are used for defining the
8679f9097b Jeff*0233 size of the various one and two dimensional arrays that store tile
0234 parameters indexed to the tile number and are assigned in the files
bf89a37abc Phob*0235 generated by :filelink:`driver.m <utils/exch2/matlab-topology-generator/driver.m>`.
0236
0237 The scalar parameters :code:`exch2_domain_nxt` and :code:`exch2_domain_nyt` express the number
0238 of tiles in the ``x`` and ``y`` global indices. For example, the default
0239 setup of six tiles (:numref:`fig_6tile`) has
0240 :code:`exch2_domain_nxt=6` and :code:`exch2_domain_nyt=1`. A
0241 topology of forty-eight tiles, eight per subdomain (as in
0242 :numref:`fig_48tile`), will have :code:`exch2_domain_nxt=12` and
0243 :code:`exch2_domain_nyt=4`. Note that these parameters express the
8679f9097b Jeff*0244 tile layout in order to allow global data files that are tile-layout-neutral.
0245 They have no bearing on the internal storage of the arrays. The tiles
bf89a37abc Phob*0246 are stored internally in a range from ``bi`` = ``(1:exch2_nTiles)`` in the
0247 ``x`` axis, and the ``y`` axis variable ``bj`` is assumed to
0248 equal 1 throughout the package.
8679f9097b Jeff*0249
0250 Arrays indexed to tile number:
bf89a37abc Phob*0251 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8679f9097b Jeff*0252
bf89a37abc Phob*0253 The following arrays are of length :code:`exch2_nTiles` and are indexed to
8679f9097b Jeff*0254 the tile number, which is indicated in the diagrams with the notation
bf89a37abc Phob*0255 ``tn``. The indices are omitted in the descriptions.
0256
0257 The arrays :varlink:`exch2_tnx` and
0258 :varlink:`exch2_tny` express the ``x`` and ``y`` dimensions of
0259 each tile. At present for each tile :code:`exch2_tnx`=``sNx`` and
0260 :code:`exch2_tny` = :code:`sNy`, as assigned in ``SIZE.h`` and described in
0261 :numref:`ssub_exch2mpi`. Future releases of MITgcm may allow varying tile
8679f9097b Jeff*0262 sizes.
0263
bf89a37abc Phob*0264 The arrays :varlink:`exch2_tbasex` and :varlink:`exch2_tbasey` determine the tiles'
8679f9097b Jeff*0265 Cartesian origin within a subdomain
0266 and locate the edges of different tiles relative to each other. As
bf89a37abc Phob*0267 an example, in the default six-tile topology (:numref:`fig_6tile`)
0268 each index in these arrays is set to 0 since a tile occupies
8679f9097b Jeff*0269 its entire subdomain. The twenty-four-tile case discussed above will
bf89a37abc Phob*0270 have values of 0 or 16, depending on the quadrant of the
8679f9097b Jeff*0271 tile within the subdomain. The elements of the arrays
bf89a37abc Phob*0272 :varlink:`exch2_txglobalo` and
0273 :varlink:`exch2_txglobalo` are similar to
0274 :varlink:`exch2_tbasex` and
0275 :varlink:`exch2_tbasey`, but locate the tile edges within the
8679f9097b Jeff*0276 global address space, similar to that used by global output and input
0277 files.
0278
bf89a37abc Phob*0279 The array :varlink:`exch2_myFace` contains the number of
0280 the subdomain of each tile, in a range ``(1:6)`` in the case of the
0281 standard cube topology and indicated by **fn** in
0282 :numref:`fig_6tile` and
0283 :numref:`fig_48tile`. :varlink:`exch2_nNeighbours`
8679f9097b Jeff*0284 contains a count of the neighboring tiles each tile has, and sets
0285 the bounds for looping over neighboring tiles.
bf89a37abc Phob*0286 :varlink:`exch2_tProc` holds the process rank of each
8679f9097b Jeff*0287 tile, and is used in interprocess communication.
0288
0289
bf89a37abc Phob*0290 The arrays :varlink:`exch2_isWedge`,
0291 :varlink:`exch2_isEedge`,
0292 :varlink:`exch2_isSedge`, and
0293 :varlink:`exch2_isNedge` are set to 1 if the
0294 indexed tile lies on the edge of its subdomain, 0 if
8679f9097b Jeff*0295 not. The values are used within the topology generator to determine
0296 the orientation of neighboring tiles, and to indicate whether a tile
0297 lies on the corner of a subdomain. The latter case requires special
0298 exchange and numerical handling for the singularities at the eight
0299 corners of the cube.
0300
0301
0302 Arrays Indexed to Tile Number and Neighbor:
bf89a37abc Phob*0303 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8679f9097b Jeff*0304
bf89a37abc Phob*0305 The following arrays have vectors of length :varlink:`W2_maxNeighbours` and
0306 :varlink:`exch2_nTiles` and describe the orientations between the the tiles.
8679f9097b Jeff*0307
bf89a37abc Phob*0308 The array :code:`exch2_neighbourId(a,T)` holds the tile number
0309 :code:`Tn` for each of the tile number :code:`T`'s neighboring tiles
0310 :code:`a`. The neighbor tiles are indexed
0311 :code:`1:exch2_nNeighbours(T)` in the order right to left on the
8679f9097b Jeff*0312 north then south edges, and then top to bottom on the east then west
0313 edges.
0314
bf89a37abc Phob*0315 The :code:`exch2_opposingSend_record(a,T)` array holds the
0316 index :code:`b` of the element in :code:`exch2_neighbourId(b,Tn)`
0317 that holds the tile number :code:`T`, given
0318 :code:`Tn=exch2_neighborId(a,T)`. In other words,
8679f9097b Jeff*0319
0320 ::
0321
0322 exch2_neighbourId( exch2_opposingSend_record(a,T),
0323 exch2_neighbourId(a,T) ) = T
0324
0325 This provides a back-reference from the neighbor tiles.
0326
bf89a37abc Phob*0327 The arrays :varlink:`exch2_pi` and
0328 :varlink:`exch2_pj` specify the transformations of indices
8679f9097b Jeff*0329 in exchanges between the neighboring tiles. These transformations are
0330 necessary in exchanges between subdomains because a horizontal dimension
0331 in one subdomain
0332 may map to other horizonal dimension in an adjacent subdomain, and
0333 may also have its indexing reversed. This swapping arises from the
0334 ''folding'' of two-dimensional arrays into a three-dimensional
0335 cube.
0336
bf89a37abc Phob*0337 The dimensions of :code:`exch2_pi(t,N,T)` and :code:`exch2_pj(t,N,T)`
0338 are the neighbor ID :code:`N` and the tile number :code:`T` as explained
0339 above, plus a vector of length 2 containing transformation
0340 factors :code:`t`. The first element of the transformation vector
8679f9097b Jeff*0341 holds the factor to multiply the index in the same dimension, and the
0342 second element holds the the same for the orthogonal dimension. To
bf89a37abc Phob*0343 clarify, :code:`exch2_pi(1,N,T)` holds the mapping of the ``x`` axis
0344 index of tile :code:`T` to the ``x`` axis of tile :code:`T`'s neighbor
0345 :code:`N`, and :code:`exch2_pi(2,N,T)` holds the mapping of :code:`T`'s
0346 ``x`` index to the neighbor :code:`N`'s ``y`` index.
8679f9097b Jeff*0347
bf89a37abc Phob*0348 One of the two elements of :code:`exch2_pi` or :code:`exch2_pj` for a
0349 given tile :code:`T` and neighbor :code:`N` will be 0, reflecting
8679f9097b Jeff*0350 the fact that the two axes are orthogonal. The other element will be
bf89a37abc Phob*0351 1 or -1, depending on whether the axes are indexed in
8679f9097b Jeff*0352 the same or opposite directions. For example, the transform vector of
0353 the arrays for all tile neighbors on the same subdomain will be
bf89a37abc Phob*0354 ``(1,0)``, since all tiles on the same subdomain are oriented
8679f9097b Jeff*0355 identically. An axis that corresponds to the orthogonal dimension
0356 with the same index direction in a particular tile-neighbor
bf89a37abc Phob*0357 orientation will have ``(0,1)``. Those with the opposite index
0358 direction will have ``(0,-1)`` in order to reverse the ordering.
8679f9097b Jeff*0359
bf89a37abc Phob*0360 The arrays :varlink:`exch2_oi`,
0361 :varlink:`exch2_oj`, :varlink:`exch2_oi_f`, and
0362 :varlink:`exch2_oj_f` are indexed to tile number and
8679f9097b Jeff*0363 neighbor and specify the relative offset within the subdomain of the
bf89a37abc Phob*0364 array index of a variable going from a neighboring tile :code:`N` to a
0365 local tile :code:`T`. Consider :code:`T=1` in the six-tile topology
0366 (:numref:`fig_6tile`), where
8679f9097b Jeff*0367
0368 ::
0369
0370 exch2_oi(1,1)=33
0371 exch2_oi(2,1)=0
0372 exch2_oi(3,1)=32
0373 exch2_oi(4,1)=-32
0374
0375
bf89a37abc Phob*0376 The simplest case is :code:`exch2_oi(2,1)`, the southern neighbor,
0377 which is :code:`Tn=6`. The axes of :code:`T` and :code:`Tn` have the
0378 same orientation and their ``x`` axes have the same origin, and so an
0379 exchange between the two requires no changes to the ``x`` index. For
0380 the western neighbor (:code:`Tn=5`), :code:`code_oi(3,1)=32` since the
0381 :code:`x=0` vector on :code:`T` corresponds to the :code:`y=32` vector on
0382 :code:`Tn`. The eastern edge of :code:`T` shows the reverse case
0383 (:code:`exch2_oi(4,1)=-32)`), where :code:`x=32` on :code:`T` exchanges
0384 with :code:`x=0` on :code:`Tn=2`.
0385
0386 The most interesting case, where :code:`exch2_oi(1,1)=33` and
0387 :code:`Tn=3`, involves a reversal of indices. As in every case, the
0388 offset :code:`exch2_oi` is added to the original ``x`` index of :code:`T`
0389 multiplied by the transformation factor :code:`exch2_pi(t,N,T)`. Here
0390 :code:`exch2_pi(1,1,1)=0` since the ``x`` axis of :code:`T` is orthogonal
0391 to the ``x`` axis of :code:`Tn`. :code:`exch2_pi(2,1,1)=-1` since the
0392 ``x`` axis of :code:`T` corresponds to the ``y`` axis of :code:`Tn`, but the
8679f9097b Jeff*0393 index is reversed. The result is that the index of the northern edge
bf89a37abc Phob*0394 of :code:`T`, which runs :code:`(1:32)`, is transformed to
0395 :code:`(-1:-32)`. :code:`exch2_oi(1,1)` is then added to this range to
0396 get back :code:`(32:1)` -- the index of the ``y`` axis of :code:`Tn`
0397 relative to :code:`T`. This transformation may seem overly convoluted
8679f9097b Jeff*0398 for the six-tile case, but it is necessary to provide a general
0399 solution for various topologies.
0400
0401
0402
bf89a37abc Phob*0403 Finally, :varlink:`exch2_itlo_c`,
0404 :varlink:`exch2_ithi_c`,
0405 :varlink:`exch2_jtlo_c` and
0406 :varlink:`exch2_jthi_c` hold the location and index
0407 bounds of the edge segment of the neighbor tile :code:`N`'s subdomain
0408 that gets exchanged with the local tile :code:`T`. To take the example
0409 of tile :code:`T=2` in the forty-eight-tile topology
0410 (:numref:`fig_48tile`):
8679f9097b Jeff*0411
0412 ::
0413
0414 exch2_itlo_c(4,2)=17
0415 exch2_ithi_c(4,2)=17
0416 exch2_jtlo_c(4,2)=0
0417 exch2_jthi_c(4,2)=33
0418
0419
bf89a37abc Phob*0420 Here :code:`N=4`, indicating the western neighbor, which is
0421 :code:`Tn=1`. :code:`Tn` resides on the same subdomain as :code:`T`, so
0422 the tiles have the same orientation and the same ``x`` and ``y`` axes.
0423 The ``x`` axis is orthogonal to the western edge and the tile is 16
0424 points wide, so :code:`exch2_itlo_c` and :code:`exch2_ithi_c`
0425 indicate the column beyond :code:`Tn`'s eastern edge, in that tile's
8679f9097b Jeff*0426 halo region. Since the border of the tiles extends through the entire
bf89a37abc Phob*0427 height of the subdomain, the ``y`` axis bounds :code:`exch2_jtlo_c` to
0428 :code:`exch2_jthi_c` cover the height of :code:`(1:32)`, plus 1 in
8679f9097b Jeff*0429 either direction to cover part of the halo.
0430
bf89a37abc Phob*0431 For the north edge of the same tile :code:`T=2` where :code:`N=1` and
0432 the neighbor tile is :code:`Tn=5`:
8679f9097b Jeff*0433
0434 ::
0435
0436 exch2_itlo_c(1,2)=0
0437 exch2_ithi_c(1,2)=0
0438 exch2_jtlo_c(1,2)=0
0439 exch2_jthi_c(1,2)=17
0440
0441
0442
bf89a37abc Phob*0443 :code:`T`'s northern edge is parallel to the ``x`` axis, but since
0444 :code:`Tn`'s ``y`` axis corresponds to :code:`T`'s ``x`` axis, :code:`T`'s
0445 northern edge exchanges with :code:`Tn`'s western edge. The western
0446 edge of the tiles corresponds to the lower bound of the ``x`` axis, so
0447 :code:`exch2_itlo_c` and :code:`exch2_ithi_c` are 0, in the
0448 western halo region of :code:`Tn`. The range of
0449 :code:`exch2_jtlo_c` and :code:`exch2_jthi_c` correspond to the
0450 width of :code:`T`'s northern edge, expanded by one into the halo.
8679f9097b Jeff*0451
0452
0453 Key Routines
0454 ++++++++++++
0455
0456 Most of the subroutines particular to exch2 handle the exchanges
0457 themselves and are of the same format as those described in
bf89a37abc Phob*0458 :ref:`cubed_sphere_comm`. Like the original routines, they are written as
0459 templates which the local Makefile converts from :code:`RX` into
0460 :code:`RL` and :code:`RS` forms.
0461
0462 The interfaces with the core model subroutines are
0463 :code:`EXCH_UV_XY_RX`, :code:`EXCH_UV_XYZ_RX` and
0464 :code:`EXCH_XY_RX`. They override the standard exchange routines
0465 when :code:`genmake2` is run with :code:`exch2` option. They in turn
0466 call the local exch2 subroutines :code:`EXCH2_UV_XY_RX` and
0467 :code:`EXCH2_UV_XYZ_RX` for two and three-dimensional vector
0468 quantities, and :code:`EXCH2_XY_RX` and :code:`EXCH2_XYZ_RX` for two
8679f9097b Jeff*0469 and three-dimensional scalar quantities. These subroutines set the
bf89a37abc Phob*0470 dimensions of the area to be exchanged, call :code:`EXCH2_RX1_CUBE`
0471 for scalars and :code:`EXCH2_RX2_CUBE` for vectors, and then handle
8679f9097b Jeff*0472 the singularities at the cube corners.
0473
bf89a37abc Phob*0474 The separate scalar and vector forms of :code:`EXCH2_RX1_CUBE` and
0475 :code:`EXCH2_RX2_CUBE` reflect that the vector-handling subroutine
8679f9097b Jeff*0476 needs to pass both the $u$ and $v$ components of the physical vectors.
0477 This swapping arises from the topological folding discussed above, where the
bf89a37abc Phob*0478 ``x`` and ``y`` axes get swapped in some cases, and is not an
8679f9097b Jeff*0479 issue with the scalar case. These subroutines call
bf89a37abc Phob*0480 :code:`EXCH2_SEND_RX1` and :code:`EXCH2_SEND_RX2`, which do most of
8679f9097b Jeff*0481 the work using the variables discussed above.
bf89a37abc Phob*0482
8679f9097b Jeff*0483 .. _ssub_exch2_experiments:
0484
0485 Experiments and tutorials that use exch2
0486 ++++++++++++++++++++++++++++++++++++++++
0487
bf89a37abc Phob*0488 - Held Suarez tutorial, in :filelink:`verification/tutorial_held_suarez_cs` verification directory.