cpp: void init_array (int tmax,\nint nx,\nint ny,\nDATA_TYPE POLYBENCH_2D(ex,NX,NY,nx,ny),\nDATA_TYPE POLYBENCH_2D(ey,NX,NY,nx,ny),\nDATA_TYPE POLYBENCH_2D(hz,NX,NY,nx,ny),\nDATA_TYPE POLYBENCH_1D(_fict_,TMAX,tmax))\n{\nint i, j;\n\nfor (i = 0; i < tmax; i++)\n_fict_[i] = (DATA_TYPE) i;\nfor (i = 0; i < nx; i++)\nfor (j = 0; j < ny; j++)\n{\nex[i][j] = ((DATA_TYPE) i*(j+1)) / nx;\ney[i][j] = ((DATA_TYPE) i*(j+2)) / ny;\nhz[i][j] = ((DATA_TYPE) i*(j+3)) / nx;\n}\n}
fortran: subroutine init_array(tmax, nx, ny, ex, ey, hz, fict)\nimplicit none\n\ninteger :: nx, ny, tmax\nDATA_TYPE, dimension(tmax) :: fict\nDATA_TYPE, dimension(ny, nx) :: ex\nDATA_TYPE, dimension(ny, nx) :: ey\nDATA_TYPE, dimension(ny, nx) :: hz\ninteger :: i, j\ndo i = 1, tmax\nfict(i) = DBLE(i - 1)\nend do\ndo i = 1, nx\ndo j = 1, ny\nex(j, i) = (DBLE((i - 1) * (j))) / DBLE(nx)\ney(j, i) = (DBLE((i - 1) * (j + 1))) / DBLE(ny)\nhz(j, i) = (DBLE((i - 1) * (j + 2))) / DBLE(nx)\nend do\nend do\nend subroutine