Skip to content

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

Open
@Beliavsky

Description

@Beliavsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions