# Difference between assumed-size and assumed-shape arrays?

**URL:** <https://fortran-lang.discourse.group/t/difference-between-assumed-size-and-assumed-shape-arrays/6923>\
**Category:** Help\
**Created:** [December 5, 2023, 1:15am UTC](https://fortran-lang.discourse.group/t/difference-between-assumed-size-and-assumed-shape-arrays/6923 "2023-12-05T01:15:05Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![danielc](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/danielc/32/3774_2.png) [@danielc](https://fortran-lang.discourse.group/u/danielc)\
**Post date:** [December 5, 2023, 1:15am UTC](https://fortran-lang.discourse.group/t/difference-between-assumed-size-and-assumed-shape-arrays/6923/1 "2023-12-05T01:15:05Z")

</div>

Can someone help me understand the difference between assumed-shape and assumed-size arrays?

```fortran
subroutine example(A,B)
    real :: A(:) ! Assumed-shape
    real :: B(*) ! Assumed-size
end subroutine

```

I know that with an assumed-shape array the compiler tells the subroutine what the shape of the array is, so you can do whole-array operations and you can run `size(A)`, `shape(A)`, `sum(A)`, etc; and those don’t work with `B`.

So… why do assumed-size arrays exist? What do they do?

I read that with an assumed-shape array, the “interface of the subroutine must be explicit in the caller”. I’m not sure what that means. I tried to write an example, but I got it wrong. This is what I tried, but it doesn’t compile:

```fortran
module Alpha
  implicit none
contains
  subroutine foo(A,val)
    real :: val, A(:) ! Assumed-shape
    val = 10 + sum(A)
  end subroutine
end module
...
program main
  use Alpha, only: foo
  implicit none
  interface
    subroutine foo(X,val)
      real :: X(:),val
    end subroutine
  end interface
contains
  subroutine bar()
    real :: val, X(10)
    call foo(X, val)
  end subroutine
end program

```

---

_[View the full topic](https://fortran-lang.discourse.group/t/difference-between-assumed-size-and-assumed-shape-arrays/6923)._
