webpage
webpage copied to clipboard
Mention allocation-on-assignment in allocatable array section
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.