title: openmp segmentation fault - strange behaviour
body: <p>I'm quite new at c++ and openmp in general. I have a part of my program that is causing segmentation faults in strange circumstances (strange to me at least).</p>
  
  <p>It doesn't occur when using the g++ compiler, but does with intel compiler, however there are no faults in serial.</p>
  
  <p>It also doesnt segfault when compiling on a different system (university hpc, intel compiler), but does on my PC.</p>
  
  <p>It also doesn't segfault when three particular cout statements are present, however if any one of them is commented out then the segfault occurs. (This is what I find strange)</p>
  
  <p>I'm new at using the intel debugger (idb) and i don't know how to work it properly yet. But i did manage to get this information from it:</p>
  
  <pre><code>Program received signal SIGSEGV
  VLMsolver::iterateWake (this=&lt;no value&gt;) at /home/name/prog/src/vlmsolver.cpp:996
  996     moveWakePoints();
  </code></pre>
  
  <p>So I'll show the moveWakePoints method below, and point out the critical cout lines:</p>
  
  <pre><code>void VLMsolver::moveWakePoints() {
  
  inFreeWakeStage =true;
  int iw = 0;
  std::vector&lt;double&gt; wV(3);
  std::vector&lt;double&gt; bV(3);
  for (int cl=0;cl&lt;3;++cl) {
      wV[cl]=0;
      bV[cl]=0;
  }
  
  cout&lt;&lt;"thanks for helping"&lt;&lt;endl;
  
  for (int b = 0;b &lt; sNumberOfBlades;++b) {
      cout&lt;&lt;"b: "&lt;&lt;b&lt;&lt;endl;
      #pragma omp parallel for firstprivate(iw,b,bV,wV)
      for (int i = 0;i&lt; iteration;++i) {
          iw = iteration -i - 1;
          for (int j = 0;j&lt;numNodesY;++j) {
              cout&lt;&lt;"b: "&lt;&lt;b&lt;&lt;"a: "&lt;&lt;"a: "&lt;&lt;endl;
              double xp = wakes[b].x[iw*numNodesY+j];
              double yp = wakes[b].y[iw*numNodesY+j];
              double zp = wakes[b].z[iw*numNodesY+j];
              if ( (sFreeWake ==true &amp;&amp; sFreezeAfter == 0) || ( sFreeWake==true &amp;&amp; iw&lt;((sFreezeAfter*2*M_PI)/(sTimeStep*sRotationRate)) &amp;&amp; sRotationRate != 0  ) || ( sFreeWake==true &amp;&amp; sRotationRate == 0 &amp;&amp; iw&lt;((sFreezeAfter*sChord)/(sTimeStep*sFreeStream)))) {
                  if (iteration&gt;1) { 
                      getWakeVelocity(xp, yp, zp, wV);
                  }
                  getBladeVelocity(xp, yp, zp, bV);
              } else {
                  for (int cl=0;cl&lt;3;++cl) {
                      wV[cl]=0;
                      bV[cl]=0;
                  }
              }
              if (sRotationRate != 0) {
                  double theta;
                  theta = M_PI/2;
                  double radius = sqrt(pow(yp,2) + pow(zp,2));
                  wakes[b].yTemp[(iw+1)*numNodesY+j] = cos(theta - sTimeStep*sRotationRate)*radius;
                  wakes[b].zTemp[(iw+1)*numNodesY+j] = sin(theta - sTimeStep*sRotationRate)*radius;
                  wakes[b].xTemp[(iw+1)*numNodesY+j] = xp + sFreeStream*sTimeStep;
              } else { 
                  std::vector&lt;double&gt; fS(3);
                  getFreeStreamVelocity(xp, yp, zp, fS);
                  wakes[b].xTemp[(iw+1)*numNodesY+j] = xp + fS[0] * sTimeStep;
                  wakes[b].yTemp[(iw+1)*numNodesY+j] = yp + fS[1] * sTimeStep;
                  wakes[b].zTemp[(iw+1)*numNodesY+j] = zp + fS[2] * sTimeStep;
              }
              wakes[b].xTemp[(iw+1)*numNodesY+j] = wakes[b].xTemp[(iw+1)*numNodesY+j] + (wV[0]+bV[0])*sTimeStep;
              wakes[b].yTemp[(iw+1)*numNodesY+j] = wakes[b].yTemp[(iw+1)*numNodesY+j] + (wV[1]+bV[1])*sTimeStep;
              wakes[b].zTemp[(iw+1)*numNodesY+j] = wakes[b].zTemp[(iw+1)*numNodesY+j] + (wV[2]+bV[2])*sTimeStep;
  
          }  // along the numnodesy
      }  // along the iterations i
      if (sBladeSymmetry) {
          break;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The three cout lines at the top are what I added, and found the program worked when i did.</p>
  
  <p>On the third cout line for example, if I change it to:</p>
  
  <pre><code>cout&lt;&lt;"b: "&lt;&lt;"a: "&lt;&lt;"a: "&lt;&lt;endl;
  </code></pre>
  
  <p>i get the segfault, or if I change it to: </p>
  
  <pre><code>cout&lt;&lt;"b: "&lt;&lt;b&lt;&lt;endl; 
  </code></pre>
  
  <p>, i also get the segfault.</p>
  
  <p>Thanks for reading, I appreciate any ideas.</p>