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

Mention allocation-on-assignment in allocatable array section #494

Open
Beliavsky opened this issue Nov 21, 2024 · 0 comments
Open

Mention allocation-on-assignment in allocatable array section #494

Beliavsky opened this issue Nov 21, 2024 · 0 comments

Comments

@Beliavsky
Copy link
Contributor

The information at https://fortran-lang.org/en/learn/best_practices/allocatable_arrays/ is correct, but in the snippet

An already allocated array cannot be allocated again without prior deallocation. Similarly, deallocation can only be invoked for allocated arrays. To reallocate an array use

if (allocated(lam)) deallocate(lam)
allocate(lam(10))

I think allocation-on-assignment should be mentioned, since that will often make code simpler. I may submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant