# TEAMS

OpenMP* Fortran Compiler Directive: Creates a league of thread teams to execute a structured block in the primary thread of each team. This feature is only available for ifx.

## Syntax

!$OMP TEAMS [clause[[,] clause]... ]

loosely-structured-block

!$OMP END TEAMS

-or-

!$OMP TEAMS [clause[[,] clause]... ]

strictly-structured-block

!$OMP END TEAMS

clause | Is one of the following: ALLOCATE ([allocator :] list) DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE) FIRSTPRIVATE (list) NUM_TEAMS (scalar-integer-expression) Specifies the number of teams to be used in a parallel region. The scalar-integer-expression must evaluate to a positive scalar integer value. Only a single NUM_TEAMS clause can appear in the directive. PRIVATE (list) REDUCTION (reduction-identifier : list) SHARED (list) THREAD_LIMIT (scalar-integer-expression) Specifies the maximum number of threads participating in the contention group that each team initiates. The scalar-integer-expression must evaluate to a positive scalar integer value. At most one THREAD_LIMIT clause can appear in the directive.
loosely-structured-block | Is a structured block (section) of statements or constructs. You cannot branch into or out of the block.
strictly-structured-block | Is a Fortran BLOCK construct. You cannot branch into or out of the BLOCK construct.

The binding thread set for a TEAMS construct is the encountering thread.

If a TEAMS construct appears within a TARGET construct, the enclosing TARGET construct must contain no other statements or directives outside of the TEAMS construct. The following are the only OpenMP* constructs that can be nested in the team's region:

- DISTRIBUTE

- PARALLEL

- PARALLEL SECTIONS

- PARALLEL WORKSHARE

- PARALLEL DO

- PARALLEL DO SIMD

The thread that encounters this directive constructs a league of thread teams that execute the block in the primary thread of each team. After the teams are created, the number of teams remains constant for the duration of the team's parallel region.

The region following the TEAMS construct is executed by the primary thread of each team. Other threads do not begin execution until the primary thread encounters a parallel region. After the teams complete execution of the TEAMS construct region, the encountering thread resumes execution of the enclosing target region.

If NUM_TEAMS is not specified, the default number of teams is one. If THREAD_LIMIT is not specified, the default number of threads is the-number-of-available-hardware-threads / NUM_TEAMS.

A program must not depend on any side effects or any ordering of the evaluation of clauses in the TEAMS directive.

Each team has a unique team number. You can use the OpenMP* run-time library routine OMP_GET_TEAM_NUM to get the team number of the calling thread.

Each thread within the team has a unique thread identifier returned by the OpenMP run-time library routine OMP_GET_THREAD_NUM. As in any thread team, the thread identifier starts at zero for the primary thread up to THREAD_LIMIT - 1 for the remaining threads.

Immediately after this directive, only the primary threads in each team are executing, the other team members will only start to execute at the next (nested) parallel region. Therefore, there are only NUM_TEAMS threads executing, and each of them has OMP_GET_THREAD_NUM() == 0.

Parent topic: T to Z

## See Also

OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets