Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jeff-cohere opened this issue Jun 24, 2022 · 0 comments
Assignees
Labels

Comments

@jeff-cohere
Copy link
Collaborator

jeff-cohere commented Jun 24, 2022

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
@jeff-cohere jeff-cohere self-assigned this Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant