CoarrayRef

A reference to a coarray on another image.

Declaration

Syntax

CoarrayRef(expr var, coarray_index* coindices, ttype type, expr? value)

Arguments

Argument

Description

var

the coarray being referenced.

coindices

one coarray_index per codimension, selecting the image.

type

the type of the expression.

value

the compile time value of the expression, when the frontend could fold it; nil otherwise.

Return values

The value of the expression.

Description

a[2] reads a on image two. The coindices select the image, and are written in square brackets to keep them distinct from the subscripts that select an element within one image’s copy.

A reference with no coindices is not a CoarrayRef: it is an ordinary Var or ArrayItem reading this image’s copy.

Examples

(CoarrayRef
  :var (Var
    :v (SymbolRef 1 "a")
  )
  :coindices [
    (coarray_index
      :index (IntegerConstant
        :n 1
        :type (Integer
          :kind 4
        )
        :intboz_type :Decimal
      )
      :star :CodimensionExpr
    )
  ]
  :type (Integer
    :kind 4
  )
  :value nil
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "a" (Variable
              :parent_symtab 1
              :name "a"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims [
                (codimension
                  :start (IntegerConstant
                    :n 1
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                  :end nil
                  :end_star :CodimensionExpr
                )
              ]
            )
            "i" (Variable
              :parent_symtab 1
              :name "i"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (Assignment
            :target (Var
              :v (SymbolRef 1 "i")
            )
            :value (CoarrayRef
              :var (Var
                :v (SymbolRef 1 "a")
              )
              :coindices [
                (coarray_index
                  :index (IntegerConstant
                    :n 1
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                  :star :CodimensionExpr
                )
              ]
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
        ]
      )
    }
  )
  :items []
)

See Also

coarray_index, codimension, SyncAll, Variable