An ordinary array has the indexes 0 to (rank-1) and a coarray has the
indexes (rank) to (rank+corank-1).
Assume
integer :: A(5,3)
codimension :: A[1,*]
When the first line is parsed, one creates an array spec for rank = 2
(attr.dimension = 1) and the corank remains 0. If one now parses the
second line, one needs to add a corank (attr.codimension = 1) by simply
appending the coarray bounds as index 2 (= rank) to 3 (= rank + corank -1).
However, if one has:
integer :: A[1,*]
dimension :: A(5,3)
one first creates an array spec for the coarray (at that point it is
scalar) with indexes 0 and 1 (= rank+corank -1). Then one parses the
second line and has to merge in the two normal ranks. To keep the order,
one needs first to shift the coranks from (0 to 1) to (2 to 3) before
one can insert the dimension at (0 to 1).