File1: #include <stdio.h>\n#include <stdlib.h>\n\nint main(){\n\n  int a[4];\n  int psum[2];\n  int sum;\n\n  #pragma omp parallel num_threads(2)\n  {\n    #pragma omp for schedule(dynamic, 1)\n    for (int i=0; i < 4; ++i){\n      a[i] = i;\n      int s;\n      s = (- 3 - 3) / - 3;\n    }\n\n    #pragma omp single\n    {\n      #pragma omp task\n      {\n       #pragma omp task\n       {\n         psum[1] = a[2] + a[3];\n       }\n        psum[0] = a[0] + a[1];\n      }\n\n      #pragma omp taskwait\n      sum = psum[1] + psum[0];\n    }\n  }\n\n  printf("sum = %d\n", sum);\n  return 0;\n }\n
File2: program DRB117_taskwait_waitonlychild_orig_yes\n    use omp_lib\n    implicit none\n\n    integer, dimension(:), allocatable :: a, psum\n    integer :: sum, i\n\n    allocate(a(4))\n    allocate(psum(4))\n\n    !$omp parallel num_threads(2)\n        !$omp do schedule(dynamic, 1)\n        do i = 1, 4\n            a(i) = i\n        end do\n        !$omp end do\n\n        !$omp single\n            !$omp task\n                !$omp task\n                  psum(2) = a(3)+a(4)\n                !$omp end task\n               psum(1) = a(1)+a(2)\n            !$omp end task\n            !$omp taskwait\n            sum = psum(2)+psum(1)\n        !$omp end single\n    !$omp end parallel\n\n    print*,'sum =',sum\n\n    deallocate(a,psum)\nend program