omp_destroy_lock(svar)

Purpose

This subroutine disassociates a given lock variable from all locks. You must use omp_init_lock to reinitialize a lock variable that was destroyed with a call to omp_destroy_lock before using it again as a lock variable.

If you call omp_destroy_lock with an uninitialized lock variable, the result of the call is undefined.

Class

Subroutine.

Argument Type and Attributes

svar
Type integer with kind omp_lock_kind.

Result Type and Attributes

Result Value

Examples

In the following example, one at a time, the threads gain ownership of the lock associated with the lock variable LCK, print the thread ID, and then release ownership of the lock.

      USE omp_lib
      INTEGER(kind=omp_lock_kind) LCK
      INTEGER ID
      CALL omp_init_lock(LCK)
!$OMP PARALLEL SHARED(LCK), PRIVATE(ID)
      ID = omp_get_thread_num()
      CALL omp_set_lock(LCK)
      PRINT *,'MY THREAD ID IS', ID
      CALL omp_unset_lock(LCK)
!$OMP END PARALLEL
      CALL omp_destroy_lock(LCK)
      END
IBM Copyright 2003