Critical / End Critical

 

  • CRITICAL [(name)]/END CRITIAL [(name)]
    • Argument name optional; identifies the critical section when used
    • Only one thread can enter at a time
    • Illegal to branch into or out of CRITICAL code section
    • If name is specified in CRITICAL, same name must be specified in END CRITICAL
!$OMP PARALLEL DEFAULT(PRIVATE) SHARED(X,Y)
!$OMP CRITICAL (XAXIS)
       CALL DEQUEUE(IX_NEXT,X)
!$OMP END CRITICAL (XAXIS)

       CALL WORK(IX_NEXT,X)

!$OMP CRITICAL (YAXIS)
       CALL DEQUEUE(IY_NEXT,Y)
!$OMP END CRITICAL (YAXIS)

       CALL WORK(IY_NEXT,Y)

!$OMP END PARALLEL