Description
In reading through the BMI documentation and best practices, I came across several places that helpfully note that arrays are always flattened in BMI, even if the model uses dimensional variables (one instance). The best practice documentation says the following about the matter:
BMI functions always use flattened, one-dimensional arrays. This avoids any issues stemming from row/column-major indexing when coupling models written in different languages. It’s the developer’s responsibility to ensure that array information is flattened/redimensionalized in the correct order.
However, I was not able to find documentation that says how arrays are flattened, meaning are they flattened using row-major (C) or column-major (Fortran) ordering? Without knowing how arrays are flattened, it is ambiguous as to how they should be unflattened. In practice, if coupled models use different flattening conventions their output will almost certainly be spurious.
For example how should the following 2x2 array be flattened and then unflattened?
[
[1, 2],
[3, 4],
]
# 1. row-major flattened
[1, 2, 3, 4]
# 2. column-major flattened
[1, 3, 2, 4]
# 1. unflattened in column-major
[
[1, 3],
[2, 4]
]
# 2. unflattened in row-major
[
[1, 3],
[2, 4]
]