OpenMP: pragma cancel for

I am trying to implement following code: