cpp: #include <stdio.h>\n#include <assert.h>\nint sum0=0, sum1=0;\n//#pragma omp threadprivate(sum0)\n\nint main()\n{\n  int i, sum=0;\n#pragma omp parallel\n  {\n#pragma omp for\n    for (i=1;i<=1000;i++)\n    {\n      sum0=sum0+i;\n    }   \n#pragma omp critical\n    {\n      sum= sum+sum0;\n    } \n  }  \n/*  reference calculation */\n  for (i=1;i<=1000;i++)\n  {\n    sum1=sum1+i;\n  }\n  printf("sum=%d; sum1=%d\n",sum,sum1);\n//  assert(sum==sum1);\n  return 0;\n}\n\n
fortran: program DRB092_threadprivatemissing2_orig_yes\n    use omp_lib\n    use DRB092\n    implicit none\n\n    integer :: i, sum\n    sum = 0\n    sum0 = 0\n    sum1 = 0\n\n    !$omp parallel\n        !$omp do\n        do i = 1, 1001\n            sum0 = sum0+i\n        end do\n        !$omp end do\n        !$omp critical\n        sum = sum+sum0\n        !$omp end critical\n    !$omp end parallel\n\n    do i = 1, 1001\n        sum1=sum1+i\n    end do\n\n    print*,'sum =',sum,'sum1 =',sum1\n\nend program