Skip to content

Replace "jagged array" allocations with proper C99 multidimensional arrays #234

@jeff-cohere

Description

@jeff-cohere

In several places, we create arrays of arrays ("jagged arrays") to represent Fortran-90-style multidimensional arrays. For instance, the TDyAllocate_IntegerArray_* and TDyAllocate_RealArray_* functions in private/tdymemoryimpl.h create these jagged arrays.

This is not actually what we want. In Fortran 90, a multidimensional array is stored as a contiguous block of memory. The C language actually provides this capability as well (though it seems not to be widely known or understood, especially by the C++ crowd). PR #233 introduces a set of macros for declaring variables that represent multidimensional arrays whose storage is backed by contiguous blocks of memory.

With these macros, we should replace the calls to the "jagged array" functions above with block allocations, and declare multidimensional arrays wherever they need to be accessed as such. This will simplify our memory allocation interface and provide better performance in logic that manipulates multidimensional array data.

Files in which these jagged arrays appear:

./fv/mpfao/tdympfao.c
./fv/mpfao/tdympfao_steady.c
./fv/mpfao/tdympfao_utils.c
./fv/mpfao/tdyregion.c
./fv/fvtpf/tdyfvtpf.c
./fv/share/tdyugrid.c
./fv/share/tdymeshplex.c
./fv/share/tdymesh.c
./fv/share/tdymeshcustom.c
./tdyutils.c

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions