Array sections and structure components

Understanding how array sections and structure components interact requires a familiarity with the syntax for Derived type components.

What we defined at the beginning of this section as an array section is really only a subset of the possible array sections. An array name or array name with a section_subscript_list can be a subobject of a structure component:

struct_sect_subobj:
Read syntax diagramSkip visual syntax diagram
>>-object_name--+------------------------------+---------------->
                '-(--section_subscript_list--)-'   

   .----------------------------------------------------.   
   V                                                    |   
>----+-%-+--comp_name--+------------------------------+-+------->
     '-.-'             '-(--section_subscript_list--)-'     

>--+-----------------+-----------------------------------------><
   '-substring_range-'   

object_name
is the name of an object of derived type
section_subscript_list, substring_range
are the same as defined under Array sections
comp_name
is the name of a derived-type component
% or .
Separator character.
Note: The . (period) separator is an IBM extension.
Note:
  1. The type of the last component determines the type of the array.
  2. Only one part of the structure component may have nonzero rank. Either the rightmost comp_name must have a section_subscript_list with nonzero rank, or another part must have nonzero rank.
  3. Any parts to the right of the part with nonzero rank must not have the ALLOCATABLE or POINTER attributes.
TYPE BUILDING_T
  LOGICAL RESIDENTIAL
END TYPE BUILDING_T
TYPE STREET_T
  TYPE (BUILDING_T) ADDRESS(500)
END TYPE STREET_T
TYPE CITY_T
  TYPE (STREET_T) STREET(100,100)
END TYPE CITY_T
TYPE (CITY_T) PARIS
TYPE (STREET_T) S
TYPE (BUILDING_T) RESTAURANT
! LHS is not an array section, no subscript triplets or vector subscripts.
PARIS%STREET(10,20) = S
! None of the parts are array sections, but the entire construct
!   is a section because STREET has a nonzero rank and is not
!   the rightmost part.
PARIS%STREET%ADDRESS(100) = BUILDING_T(.TRUE.)

! STREET(50:100,10) is an array section, making the LHS an array section
!   with rank=1, shape=(/51/).
! ADDRESS(123) must not be an array section because only one can appear
!   in a reference to a structure component.
PARIS%STREET(50:100,10)%ADDRESS(123)%RESIDENTIAL = .TRUE.
END