cpp: #include <stdio.h>\n/*\nuse of omp target + map + array sections derived from pointers\n*/\nvoid foo (double* a, double* b, int N)\n{\n  int i; \n#pragma omp target map(to:a[0:N]) map(from:b[0:N])\n#pragma omp parallel for\n  for (i=0;i< N ;i++)\n    b[i]=a[i]*(double)i;\n}\n\nint main(int argc, char* argv[])\n{\n  int i;\n  int len = 1000;\n  double a[len], b[len];\n  for (i=0; i<len; i++)\n  {\n    a[i]= ((double)i)/2.0;\n    b[i]=0.0;\n  }\n\n  foo(a, b, len);\n\n  printf("b[50]=%f\n",b[50]);\n  return 0;\n}\n
fortran: program DRB099_targetparallelfor2_orig_no\n    use omp_lib\n    use DRB099\n    implicit none\n\n    integer :: i, len\n  integer, parameter :: dp = kind(1.0d0)\n    real(dp), dimension(:), allocatable :: a,b\n    real :: x\n\n    len = 1000\n\n    allocate(a(len))\n    allocate(b(len))\n\n    do i = 1, len\n        a(i) = (real(i,dp))/2.0\n        b(i) = 0.0\n    end do\n\n    x=foo(a,b,len)\n    print*,'b(50) =',b(50)\n  \n    deallocate(a,b)\nend program