cpp: #include <stdio.h>\n#if (_OPENMP<201511)\n#error "OpenMP 4.5 compilers (e.g. GCC 6.x or later ) are needed to compile this test."\n#endif\n\n#include <stdio.h>\n#define MYLEN 100\nint a[MYLEN];\n\nvoid gen_task(int& i)\n{\n#pragma omp task\n{\na[i]= i+1;\n}\n}\n\nint main()\n{\nint i=0;\n#pragma omp parallel\n{\n#pragma omp single\n{\nfor (i=0; i<MYLEN; i++)\n{\ngen_task(i);\n}\n}\n}\n\n/* correctness checking */\nfor (i=0; i<MYLEN; i++)\n{\n//assert (a[i]==i+1);\nif (a[i]!= i+1)\n{\nprintf("warning: a[%d] = %d, not expected %d\n", i, a[i], i+1);\n}\n}\nreturn 0;\n}
fortran: program DRB100_task_reference_orig_no\n    use omp_lib\n    use DRB100\n    implicit none\n\n    integer :: i\n    allocate (a(100))\n\n    !$omp parallel\n        !$omp single\n        do i = 1, 100\n            call gen_task(i)\n        end do\n        !$omp end single\n    !$omp end parallel\n\n    do i = 1, 100\n        if (a(i) /= i+1) then\n            print*,'warning: a(',i,') =',a(i),' not expected',i+1\n        end if\n!        print*,a(i),i+1\n    end do\nend program