cpp: #include<stdio.h>\n#include<assert.h>\n\nvoid f1(int *q)\n{\n#pragma omp critical\n  *q = 1;\n#pragma omp flush\n}\n\nint main()\n{ \n  int i=0, sum=0; \n  \n  #pragma omp parallel reduction(+:sum) num_threads(10) \n  {\n     f1(&i);\n     sum+=i;\n  }\n  assert (sum==10);\n  printf("sum=%d\n", sum);\n  return 0;   \n}\n
fortran: program DRB074_flush_orig_yes\n    use omp_lib\n    use DRB074\n    implicit none\n\n    integer :: i, sum\n    i = 0\n    sum =  0\n\n    !$omp parallel reduction(+:sum) num_threads(10)\n    call f1(i)\n    sum = sum+i\n    !$omp end parallel\n\n    if (sum /= 10) then\n        print*,'sum =',sum\n    end if\nend program