Deadlock
This shows a race condition and a deadlock.
If A is locked in the first section and the if statement branches around the unset lock, threads running the other sections deadlock waiting for the lock to be released.
Make sure you release your locks.
CALL OMP_INIT_LOCK (LCKA)
CALL OMP_UNSET_LOCK (LCKA)
CALL OMP_UNSET_LOCK(LCKA)