# Parameterized derived-type contained procedure failure

**URL:** <https://fortran-lang.discourse.group/t/parameterized-derived-type-contained-procedure-failure/6219>\
**Category:** Help\
**Created:** [July 25, 2023, 2:30pm UTC](https://fortran-lang.discourse.group/t/parameterized-derived-type-contained-procedure-failure/6219 "2023-07-25T14:30:59Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [July 26, 2023, 4:29pm UTC](https://fortran-lang.discourse.group/t/parameterized-derived-type-contained-procedure-failure/6219/7 "2023-07-26T16:29:51Z")

</div>

> [@nedanator](#):
>
> You mention that “jagged arrays” are not permitted by Fortran language standard. Does this include all types of “jagged arrays”, or just arrays of PDTs? i.e, is this permitted:

@nedanator ,

Please note what the semantics of the Fortran standard require with arrays is **type parameter** conformity among the elements of the array. Now note there are **two** type parameters: the so-called `kind-type` parameter and the `length-type` parameter. Each element of an array shall have the same kind-type and/or length-type parameters, as applicable to the type in question. So my point above re: “jagged arrays” refers to this aspect of the standard vis-a-vis your PDT that has a length-type parameter.

To understand this more broadly, a good example is the `CHARACTER` intrinsic type. See this [**thread**](https://fortran-lang.discourse.group/t/culture-setting-inoculation-against-squiggles/5857/10). So one can write in Fortran:

```fortran
..
   integer, parameter :: CK = selected_char_kind('ISO_10646')
  ..
   character(kind=CK, len=*), parameter :: string = CK_'𨉟呐㗂越'
..

```

So here, note the named constant `string` has a kind-parameter of `CK` corresponding to `ISO 10646` character set and it has a length-parameter that corresponds to the length required by the processor (compiler) to hold the supplied string literal which is technically in Vietnamese but as represented by the `UTF-8` encoding.

Thus if you are creating an array of strings using the `CHARACTER` intrinsic type, each element of the array shall have the same kind and length.

But now, note the `ALLOCATABLE` aspect is **not** a type parameter, rather it involves different semantics pertaining to an attribute of the type component of a derived type or an object (`variable`) in a program. Thus the use of the so-called **wrapper** derived type with type components of the `ALLOCATABLE` attribute is a workaround to have jagged arrays. So with workaround, each element of the array is of the same type i.e., the wrapper derived type. And since this wrapper type has no type parameters, the standard semantics with type parameter conformity is not an issue. That is not the case when you use a parameterized derived type design since such a type has type parameters.

---

_[View the full topic](https://fortran-lang.discourse.group/t/parameterized-derived-type-contained-procedure-failure/6219)._
