Python write api does not check for non-contiguous or non-c-layout numpy arrays
Created by: isosc
Issue: Numpy arrays which are not contiguous C-ordered arrays are not properly understood by the write API, leading to missing or out-of-order data in ADIOS2. Currently can work around by making a c-ordered copy (which is expensive for large arrays), but generally it seems like the python bindings should check order and handle appropriately.
Code example:
from mpi4py import MPI
import adios2 as ad
import numpy as np
import sys
dd = np.array([[111,112,113,114],[121,122,123,124],[131,132,133,134]])
global_shape = dd.shape
local_shape = dd.shape
offset = [0,0]
print ("Original order:")
print (dd)
#Write using c order
with ad.open('c.bp','w', MPI.COMM_WORLD) as fh:
fh.write('myvar',np.copy(dd,'C'),global_shape,offset,local_shape)
with ad.open('c.bp','r', MPI.COMM_WORLD) as fh:
aa = fh.read('myvar')
print ("Written with c order:")
print (aa)
#write using fortran order
with ad.open('f.bp','w', MPI.COMM_WORLD) as fh:
fh.write('myvar',np.copy(dd,'F'),global_shape,offset,local_shape)
with ad.open('f.bp','r', MPI.COMM_WORLD) as fh:
aa = fh.read('myvar')
print ("Written with fortran order:")
print (aa)
Result: Original order: [[111 112 113 114] [121 122 123 124] [131 132 133 134]] Written with c order: [[111 112 113 114] [121 122 123 124] [131 132 133 134]] Written with fortran order: [[111 121 131 112] [122 132 113 123] [133 114 124 134]]