File1: #include <stdio.h>\n#include <assert.h>\n\nint sum0=0, sum1=0;\n#pragma omp threadprivate(sum0)\n\nint main()\n{\n  int len=1000;\n  int i, sum=0;\n#pragma omp parallel copyin(sum0)\n  {\n#pragma omp for\n    for (i=0;i<len;i++)\n    {\n      sum0=sum0+i;\n    }   \n#pragma omp critical\n    {\n      sum= sum+sum0;\n    } \n  }  \n  /*  reference calculation */\n  for (i=0;i<len;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
File2: program DRB091_threadprivate2_orig_no\n    use omp_lib\n    use DRB091\n    implicit none\n\n    integer :: len, i, sum\n    len = 1000\n    sum = 0\n\n    !$omp parallel copyin(sum0)\n        !$omp do\n        do i = 1, len\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, len\n        sum1 = sum1+i\n    end do\n\n    print*,'sum =',sum,'sum1 =',sum1\n\nend program