ZioLib needs to know how an array is distributed among processes. If distributed array's domain is made of nblks separate rectangular blocks, one way is to describe the distributed array is to specify each rectangular block's local grid size along each array dimension (lsize(1), lsize(2), lsize(3), ...) and its grid offsets (offset(1), offset(2), offset(3), ...) in the global array space:
ret = zio_new_distarray(distarray,nblks,ndims,offset,lsize)
It returns a distributed array descriptor in distarray.
In some case, not all processes have valid data assigned to them. For example, for 2-D surface data in a 3-D decomposition, some processes do not contain valid surface data. In such a case, make sure to set either nblks or lsize(:) to 0 if the current process does not contain valid data.
Another way to create a descriptor is to specify it via a parallel decomposition:
ret = zio_new_decomp(decomp,px,py,pz) ! Parallel decomposition
ret = zio_define_distarray(distarray,decomp,nx,ny,nz)
Here we are dealing with an array of global grid sizes nx, ny, and nz, block-distributed over px, py, and pz processes. Distributed arrays for up to 5-D parallel decompositions can be described in this way. Note, however, that there are some restrictions with this approach. First, it is assumed that process ranks change fastest along the X-axis, then Y-axis, and then Z-axis (for MPI's Cartesian process topology, rank ordering is the opposite). When a grid size is not evenly divisible by the respective process count, it is assumed that the excess grid points (that is, the remainder) are evenly distributed among the lowest-rank processs. For example, if there are 26 grid points distributed among four processs, it is assumed that the local grid points for processes 0, 1, 2, and 3 are 7, 7, 6, and 6, respectively.
If offsets, local sizes, ghost nodes, and index order are set in some routine (presumably provided by a code developer) and a user doesn't want to figure them out himself/herself, then the user can create a distributed array descriptor by simply providing the subroutine name:
ret = zio_import_distarray(distarray,user_func)
where user_func must be provided in the user code. See
Section
for details.
With a distributed array discriptor ZioLib can figure out how to read or write a global array. ZioLib can also read or write non-distributed array replicated on all processes. To read or write such an array, the flag zio_replicated should be used as a descriptor.