File1: #include <stdio.h>\n/* This is a program based on a test contributed by Yizi Gu@Rice Univ.\n * Classic Fibonacci calculation using task but missing taskwait. \n * Data races pairs: i@61:5:W vs. i@65:14:R\n *                   j@63:5:W vs. j@65:16:R\n * */\nunsigned int input = 10;\nint fib(unsigned int n)\n{\n  if (n<2)\n    return n;\n  else\n  {\n    int i, j;\n#pragma omp task shared(i)\n    i=fib(n-1);\n#pragma omp task shared(j)\n    j=fib(n-2);\n\n    int res= i+j; \n/* We move the original taskwait to a location after i+j to \n * simulate the missing taskwait mistake.\n * Directly removing the taskwait may cause a child task to write to i or j\n * within the stack of a parent task which may already be gone, causing seg fault.\n * This change is suggested by Joachim Protze @RWTH-Aachen. \n * */\n#pragma omp taskwait\n    return res;\n  }\n}\nint main()\n{\n  int result = 0;\n#pragma omp parallel\n  {\n   #pragma omp single\n    {\n      result = fib(input);\n    }\n  }\n  printf ("Fib(%d)=%d (correct answer should be 55)\n", input, result);\n  return 0;\n}\n
File2: module DRB106\n    implicit none\n    integer (kind=4) input\n\ncontains\n    recursive function fib(n) result(r)\n        use omp_lib\n        implicit none\n        integer (kind=4) :: n, i, j, r\n\n        if (n<2) then\n            r = n\n        else\n            !$omp task shared(i)\n            i = fib(n-1)\n            !$omp end task\n            !$omp task shared(j)\n            j = fib(n-2)\n            !$omp end task\n            r = i+j\n        end if\n        !$omp taskwait\n    end function\nend module\n\nprogram DRB106_taskwaitmissing_orig_yes\n    use omp_lib\n    use DRB106\n    implicit none\n\n    integer :: result\n    input = 30\n\n    !$omp parallel\n    !$omp single\n    result = fib(input)\n    !$omp end single\n    !$omp end parallel\n\n    print*,'Fib for ',input,' =',result\n\nend program