cpp: #include <omp.h>\n#include <stdio.h>\n\n#define N 100\n\nint var = 0;\n\nint main(){\n\n  #pragma omp target map(tofrom:var) device(0)\n  #pragma omp teams distribute parallel for\n  for(int i=0; i<N; i++){\n    #pragma omp critical(addlock)\n    var++;\n\n    #pragma omp critical(sublock)\n    var -= 2;\n  }\n\n  printf("%d\n",var);\n\n  return 0;\n}\n
fortran: program DRB148_critical1_orig_gpu_yes\n    use omp_lib\n    implicit none\n\n    integer :: var, i\n    var = 0\n\n    !$omp target map(tofrom:var) device(0)\n    !$omp teams distribute parallel do\n    do i = 1, 100\n        !$omp critical(addlock)\n        var = var+1\n        !$omp end critical(addlock)\n    end do\n    !$omp end teams distribute parallel do\n    !$omp end target\n\n    print*,var\nend program