-
Notifications
You must be signed in to change notification settings - Fork 15
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
Resizable allocatable arrays #326
Comments
Is the idea to add "capacity" into the array descriptor? Because you are not introducing any new types, so it would use the existing array types in Fortran, which means that only arrays that are implemented using a descriptor can be resized. The arrays that do not have a descriptor cannot be resized without a copy. You can then reshape the existing array as long as it fits into the capacity (otherwise you copy & double the capacity), even a multidimensional one. |
Essentially, yes, this is what the compilers would have to do.
This pre-proposal is only for allocatable arrays: I guess they always have a descriptor? |
I see, I think that will work. Yes, allocatable arrays usually have a descriptor in most compilers. |
It's too early for a pull request, but I've prepared a draft proposal to have a basis for the discussion: https://github.com/PierUgit/enhanced-allocatables/blob/main/proposal.txt |
Sorry, I messed a bit the topic by opening this issue while #318 was already opened :( ... Maybe one should be closed, just adding a reference to the other one. : |
Following a discussion on https://fortran-lang.discourse.group/t/enhancements-to-allocatable-arrays/
The basic idea is to have something similar to the C++ vectors, which can be dynamically resized while minimizing the occurences of malloc/copy/free, thanks to a significant overprovisionning of the capacity.
I came up with a description how it could work in Fortran, including a demonstration code (which is non standard, but nicely illustrates the proposed features): https://github.com/PierUgit/enhanced-allocatables
In particular, iteratively appending a element to an array would be much more efficient.
I do not copy/paste the whole description here, it's all in the README of the above repository.
I believe the change would be relatively simple for the compiler writers.
The text was updated successfully, but these errors were encountered: