You can do this
#pragma omp parallel for
for (int i = 0; i<10; i++) {
double k = 0.1*i;
}
If you really want to avoid the multiplication in the loop and be closer to your original code you can do this
#pragma omp parallel
{
int nthreads = omp_get_num_threads();
int ithread = omp_get_thread_num();
int starti = ithread*10/nthreads;
int finishi = (ithread+1)*10/nthreads;
double start = 0.1*starti;
double finish = 0.1*finishi;
double k;
int i;
for (k = start, i = starti; k < finish; k += 0.1, i++) {
}
}
When I first wrote this answer I did not realize one subtle point.
The conversion from
for (k = 0; k < 1; k += 0.1)
to
for (int i = 0; i<10; i++) double k = 0.1*i;
is not one-to-one. I mean the results are not necessarily identical. That's because for floating point math multiplication times an integer is not necessarily repeated addition. It may be fine in many cases it's important to be aware that they are not the same thing.
It's possible to go the other way from multiplication to repeated addition if you use Kahan summation but going from repeated addition to multiplication is not guaranteed to give the same result.
You can read more about it at floating-point-multiplication-vs-repeated-addition.