%\pagebreak
\section{\kcode{depobj} Construct}
\label{sec:depobj}
\index{constructs!depobj@\kcode{depobj}}
\index{depobj construct@\kcode{depobj} construct}
\index{depobj construct@\kcode{depobj} construct!depend clause@\kcode{depend} clause}
\index{depend clause@\kcode{depend} clause}
\index{clauses!depend@\kcode{depend}}

The stand-alone \kcode{depobj} construct provides a mechanism 
to create a \plc{depend object} that expresses a dependence to be 
used subsequently in the \kcode{depend} clause of another construct.
Dependence information is created from a dependence type and a storage location
that is specified in the \kcode{depend} clause of an \kcode{depobj} construct,
%just as one would find directly on a \code{task} construct.  
and it is stored in the depend object.
The depend object is represented by a variable of type \kcode{omp_depend_t} 
in C/C++ and by a scalar variable of integer kind \kcode{omp_depend_kind} in Fortran.

\index{depobj construct@\kcode{depobj} construct!update clause@\kcode{update} clause}
\index{update clause@\kcode{update} clause}
\index{clauses!update@\kcode{update}}
\index{depobj construct@\kcode{depobj} construct!destroy clause@\kcode{destroy} clause}
\index{destroy clause@\kcode{destroy} clause}
\index{clauses!destroy@\kcode{destroy}}
In the example below the stand-alone \kcode{depobj} construct uses the 
\kcode{depend}, \kcode{update} and \kcode{destroy} clauses to 
\plc{initialize}, \plc{update} and \plc{uninitialize}
a depend object (\ucode{obj}).

The first \kcode{depobj} construct initializes the \ucode{obj} 
depend object with 
an \kcode{inout} dependence type and with a storage
location defined by variable \ucode{a}.  
This dependence is passed into the \ucode{driver} 
routine via the \ucode{obj} depend object.

In the first \ucode{driver} routine call, \emph{Task 1} uses
the dependence of the object (\kcode{inout}), 
while \emph{Task 2} uses an \kcode{in} dependence specified 
directly in a \kcode{depend} clause.
For these task dependences \emph{Task 1} must execute and 
complete before \emph{Task 2} begins.

Before the second call to \ucode{driver}, \ucode{obj} is updated 
using the \kcode{depobj} construct to represent an \kcode{in} dependence. 
Hence, in the second call to \ucode{driver}, \emph{Task 1}
will have an \kcode{in} dependence; and \emph{Task 1} and 
\emph{Task 2} can execute simultaneously. Note: in an \kcode{update}
clause, only the dependence type can be (is) updated.

The third \kcode{depobj} construct uses the \kcode{destroy} clause.
It frees resources as it puts the depend object in an uninitialized state --
effectively destroying the depend object.
After an object has been uninitialized it can be initialized again
with a new dependence type and a new variable.

\cexample[5.2]{depobj}{1}

\ffreeexample[5.2]{depobj}{1}
