cpp: #include <stdio.h> \n#include <assert.h> \n#include <unistd.h>\nint main()\n{\n  int i=0, j, k;\n#pragma omp parallel\n#pragma omp single\n  {\n#pragma omp task depend (out:i)\n    {\n      sleep(3);\n      i = 1;    \n    }\n#pragma omp task depend (in:i)\n    j =i; \n#pragma omp task depend (in:i)\n    k =i; \n  }\n  printf ("j=%d k=%d\n", j, k);\n  assert (j==1 && k==1);\n  return 0;\n} \n
fortran: program DRB079_taskdep3_orig_no\n    use omp_lib\n    implicit none\n\n    integer :: i, j, k\n    i = 0\n\n    !$omp parallel\n        !$omp single\n            !$omp task depend (out:i)\n                call sleep(3)\n                i = 1\n            !$omp end task\n            !$omp task depend (in:i)\n                j = i\n            !$omp end task\n            !$omp task depend (in:i)\n                k = i\n            !$omp end task\n        !$omp end single\n    !$omp end parallel\n\n    print 100, j, k\n    100 format ('j =',i3,2x,'k =',i3)\n\n    if (j /= 1 .and. k /= 1) then\n        print*, 'Race Condition'\n    end if\n\nend program