title: Parallelizing many nested for loops in openMP c++
body: <p>Hi i am new to c++ and i made a code which runs but it is slow because of many nested for loops i want to speed it up by openmp anyone who can guide me. i tried to use '<strong>#pragma omp parallel</strong>' before <strong>ip</strong> loop and inside this loop i used '<strong>#pragma omp parallel for</strong>'  before <strong>it</strong> loop but it does not works </p>
  
  <pre><code>    #pragma omp parallel
      for(int ip=0; ip !=nparticle; ip++){
          inf14&gt;&gt;r&gt;&gt;xp&gt;&gt;yp&gt;&gt;zp;
          zp/=sqrt(gamma2);
          counter++;
          double para[7]={0,0,Vz,x0-xp,y0-yp,z0-zp,0};
          if(ip&gt;=0 &amp;&amp; ip&lt;=43){
               #pragma omp parallel for
               for(int it=0;it&lt;NT;it++){  
               para[6]=PosT[it];
                  for(int ix=0;ix&lt;NumX;ix++){
                      para[3]=PosX[ix]-xp;
                      for(int iy=0;iy&lt;NumY;iy++){
                          para[4]=PosY[iy]-yp;
                          for(int iz=0;iz&lt;NumZ;iz++){
                              para[5]=PosZ[iz]-zp;
                              int position=it*NumX*NumY*NumZ+ix*NumY*NumZ+iy*NumZ+iz;
                              rotation(para,&amp;Field[3*position]);
                              MagX[position] +=chg*Field[3*position];
                              MagY[position] +=chg*Field[3*position+1];
                              MagZ[position] +=chg*Field[3*position+2];
                          }   
                      }
                  }
              }   
          }
      }enter code here
  </code></pre>
  
  <p>and my rotation function also has infinite integration for loop as given below </p>
  
  <pre><code>for(int i=1;;i++){
      gsl_integration_qag(&amp;F, 10*i, 10*i+10, 1.0e-8, 1.0e-8, 100, 2, w, &amp;temp, &amp;error);
      result+=temp;
      if(abs(temp/result)&lt;ACCURACY){
          break;
      }
  }
  </code></pre>
  
  <p>i am using gsl libraries as well. so how to speed up this process or how to make openmp?</p>