# Reuse the size of assumed-shape array vs. allocate

**URL:** <https://fortran-lang.discourse.group/t/reuse-the-size-of-assumed-shape-array-vs-allocate/8073>\
**Category:** Help\
**Created:** [May 22, 2024, 6:05pm UTC](https://fortran-lang.discourse.group/t/reuse-the-size-of-assumed-shape-array-vs-allocate/8073 "2024-05-22T18:05:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [May 22, 2024, 6:51pm UTC](https://fortran-lang.discourse.group/t/reuse-the-size-of-assumed-shape-array-vs-allocate/8073/2 "2024-05-22T18:51:14Z")

</div>

One difference between automatic and `allocatable` arrays is that the `allocate` statement lets you set and check a `stat` specifier to see if the allocation succeeded. There is no such error handling with automatic arrays. There was a thread

> [@Difference between automatic arrays on the heap and allocatable arrays](https://fortran-lang.discourse.group/t/difference-between-automatic-arrays-on-the-heap-and-allocatable-arrays/4949):
>
> Is there any practically significant difference between automatic arrays saved on the heap and allocatable arrays? As an example, consider the following code (edit: I added functions with array results inspired by the comment of @RonShepard). module s\_mod implicit none private public :: sf\_auto, sf\_alloc, af\_auto, af\_alloc contains function sf\_auto(n) result(s) integer, intent(in) :: n real :: s real :: x\_auto(n) x\_auto = 1.0 s = sum(x\_auto) end function sf\_auto function sf\_alloc(n) result(…

---

_[View the full topic](https://fortran-lang.discourse.group/t/reuse-the-size-of-assumed-shape-array-vs-allocate/8073)._
