ExplicitDeallocate

The deallocate statement written by the user.

Declaration

Sintaxe

ExplicitDeallocate(expr* vars, expr? stat, expr? errmsg)

Argumentos

Argument

Descrição

vars

the allocatables and pointers to deallocate.

stat

a variable receiving the status: zero on success, non-zero if an object is not allocated. With stat the program continues after a failed deallocation.

errmsg

a character variable receiving the error message.

Valores de retorno

Nenhum.

Descrição

Deallocating something that is not allocated is an error at run time. That is the difference from ImplicitDeallocate, which the compiler inserts and which does nothing in that case.

Exemplos

(ExplicitDeallocate
  :vars [
    (Var
      :v (SymbolRef 1 "a")
    )
  ]
  :stat (Var
    :v (SymbolRef 1 "stat")
  )
  :errmsg 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 (Allocatable
                :type (Array
                  :type (Integer
                    :kind 4
                  )
                  :dims [
                    (dimension
                      :start nil
                      :length nil
                    )
                  ]
                  :physical_type :DescriptorArray
                  :memory_space :Global
                )
              )
              :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_asynchronous false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
              :common_block nil
            )
            "p" (Variable
              :parent_symtab 1
              :name "p"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Pointer
                :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_asynchronous false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
              :common_block nil
            )
            "stat" (Variable
              :parent_symtab 1
              :name "stat"
              :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_asynchronous false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
              :common_block nil
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (Allocate
            :args [
              (alloc_arg
                :a (Var
                  :v (SymbolRef 1 "a")
                )
                :dims [
                  (dimension
                    :start (IntegerConstant
                      :n 1
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                    :length (IntegerConstant
                      :n 10
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                ]
                :codims []
                :len_expr nil
                :sym_subclass nil
                :type nil
              )
            ]
            :stat (Var
              :v (SymbolRef 1 "stat")
            )
            :errmsg nil
            :source nil
          )
          (ReAlloc
            :args [
              (alloc_arg
                :a (Var
                  :v (SymbolRef 1 "a")
                )
                :dims [
                  (dimension
                    :start (IntegerConstant
                      :n 1
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                    :length (IntegerConstant
                      :n 20
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                ]
                :codims []
                :len_expr nil
                :sym_subclass nil
                :type nil
              )
            ]
            :shape_differs (IntegerCompare
              :left (ArraySize
                :v (Var
                  :v (SymbolRef 1 "a")
                )
                :dim (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :type (Integer
                  :kind 4
                )
                :value nil
              )
              :op :NotEq
              :right (IntegerConstant
                :n 20
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
          )
          (ExplicitDeallocate
            :vars [
              (Var
                :v (SymbolRef 1 "a")
              )
            ]
            :stat (Var
              :v (SymbolRef 1 "stat")
            )
            :errmsg nil
          )
          (Nullify
            :vars [
              (Var
                :v (SymbolRef 1 "p")
              )
            ]
          )
          (ImplicitDeallocate
            :vars [
              (Var
                :v (SymbolRef 1 "a")
              )
            ]
          )
        ]
        :global_init nil
      )
    }
  )
  :items []
  :global_init nil
)

Veja Também

ImplicitDeallocate, Allocate, Nullify