# Fortran 2023: An array or allocatable object may have a coarray component

**URL:** <https://fortran-lang.discourse.group/t/fortran-2023-an-array-or-allocatable-object-may-have-a-coarray-component/8877>\
**Category:** Uncategorized\
**Created:** [November 24, 2024, 9:51pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-an-array-or-allocatable-object-may-have-a-coarray-component/8877 "2024-11-24T21:51:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Federchen](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Federchen](https://fortran-lang.discourse.group/u/Federchen)\
**Post date:** [November 24, 2024, 9:51pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-an-array-or-allocatable-object-may-have-a-coarray-component/8877/1 "2024-11-24T21:51:02Z")

</div>

We are currently discussing the following new Fortran 2023 feature:

See this quote from _Modern Fortran explained, Fortran 2023 edition, chapter 23.6.1, p.455-456_:

“…_, Fortran 2018 requires that a variable_ _ **or component** _ _that is of a type with a coarray ultimate component be a non-pointer non-allocatable non-coarray scalar. Fortran 2023 permits such a variable_ _ **or component** _ _to be an array and/or allocatable, …_ _This can happen at any depth of component selection,…_ _”_

I did interpret that this would allow a coding style as shown with the simple test case below:

```auto
program main
end program main

module test
implicit none
private

type, public :: a
  private
  integer, public, allocatable, dimension(:), codimension[:] :: coarray
end type a

type, public :: b
  private
  type(a), public, allocatable, dimension(:) :: channels_1 ! compile time error 
  ! with ifx 2025.0.0:
  ! error #8474: A data component whose type has a coarray potential subobject 
  ! component must be a nonpointer nonallocatable scalar.
end type b

type(a), public, allocatable, dimension(:) :: channels_2 ! compiles and runs 
  ! perfectly with ifx 2025.0.0

end module test

```

But the compiler engineers do validly point to the Fortran 2023 standards text:

“ **C753 A data component whose type has a coarray potential subobject component shall be a nonpointer non-allocatable scalar and shall not be a coarray.** ”

Any idea what is wrong here? Did I mistake _Modern Fortran explained_? Or is there an error in the Fortran 2023 standard text, or is _Modern Fortran explained_ wrong?

Regards

---

<div class="post-metadata">

**Author:** ![AniruddhaDas](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@AniruddhaDas](https://fortran-lang.discourse.group/u/AniruddhaDas)\
**Post date:** [November 25, 2024, 3:38am UTC](https://fortran-lang.discourse.group/t/fortran-2023-an-array-or-allocatable-object-may-have-a-coarray-component/8877/2 "2024-11-25T03:38:20Z")

</div>

This has been addressed in the paper [25-100](https://j3-fortran.org/doc/year/25/25-100.txt) with the number F23/009 titled coarray sub-object of component.

---

<div class="post-metadata">

**Author:** ![Federchen](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Federchen](https://fortran-lang.discourse.group/u/Federchen)\
**Post date:** [November 25, 2024, 10:07am UTC](https://fortran-lang.discourse.group/t/fortran-2023-an-array-or-allocatable-object-may-have-a-coarray-component/8877/3 "2024-11-25T10:07:54Z")

</div>

> [@AniruddhaDas](#):
>
> This has been addressed in the paper [25-100](https://j3-fortran.org/doc/year/25/25-100.txt) with the number F23/009 titled coarray sub-object of component.

Thanks very much for pointing to this. This already solves the issue:

> [@](#):
>
> NUMBER: F23/009  
> TITLE: Coarray subobject of component  
> KEYWORDS: coarray, allocatable, array, component  
> DEFECT TYPE: Erratum  
> STATUS: Passed by J3 meeting
> 
> QUESTION:
> 
> The Introduction of Fortran 2023 says  
> “A data object with a coarray component can be an array or  
> allocatable.”
> 
> This appears to be true for named variables, but there is a constraint  
> that makes it impossible for an array component or an allocatable  
> component:  
> “C753 A data component whose type has a coarray potential subobject  
> component shall be a nonpointer nonallocatable scalar and  
> shall not be a coarray.”
> 
> That means that given the type
> 
> ```
> Type real_coarray
> Real,Allocatable :: c[:]
> End Type
> 
> ```
> 
> the statements
> 
> ```
> Type(real_coarray) x(100)
> Type(real_coarray),Allocatable :: y
> 
> ```
> 
> are acceptable as type declaration statements, but unacceptable as  
> component definition statements.
> 
> Is this irregularity deliberate?
> 
> ANSWER:
> 
> No, this constraint was accidentally overlooked when extending types  
> with coarray components to be subobjects of arrays and allocatables.
> 
> An edit is provided to correct this mistake.
> 
> EDIT to N2218 (Fortran 2023 FDIS):
> 
> [79:constraint C753] In subclause  
> Delete this constraint, which begins  
> “C753 A data component whose type has a coarray”
> 
> [80:After NOTE 1] Insert new NOTE  
> “NOTE 1.5  
> A data component whose type has a coarray potential subobject  
> component cannot be a coarray or a pointer, see constraint C825.”  
> {C825 says “An entity whose type has a coarray potential subobject…”  
> and components are certainly entities. We specifically wrote “entity”  
> instead of “named variable” to cover the component case.  
> I prefer to say it once and refer to it.}
> 
> SUBMITTED BY: John Reid & Reinhold Bader
> 
> HISTORY: 23-210 m231 Submitted  
> 23-210r1 m231 Revised  
> 23-210r2 m231 Passed as amended by J3 meeting 231.

Interestingly, I was already aware of C825 using the word “entity” and thought hopefully this could be for exactly that case.

Regards
