The LASTPRIVATE clause provides a superset of the functionality provided by the PRIVATE clause (see Section 15.2.2.5); objects are declared PRIVATE and they are given certain values when the parallel region is exited. It takes the following form:
Variables that appear in a LASTPRIVATE list are subject to PRIVATE clause semantics. In addition, once the parallel region is exited, each variable has the value provided by the sequentially last section or loop iteration.
When the LASTPRIVATE clause appears in a DO directive, the thread that executes the sequentially last iteration updates the version of the object it had before the construct. When the LASTPRIVATE clause appears in a SECTIONS (or PSECTIONS) directive, the thread that executes the lexically last SECTION updates the version of the object it had before the construct.
Subobjects that are not assigned a value by the last iteration of the DO or the lexically last SECTION of the SECTIONS (or PSECTIONS) directive are undefined after the construct.