title: The correct usage of nested #pragma omp for directives
body: <p>The following code runs like a charm before OpenMP parallelization was applied. In fact, the following code was in a state of endless loop! I'm sure that's result from my incorrect use to the OpenMP directives. Would you please show me the correct way? Thank you very much.</p>
  
  <pre><code>          #pragma omp parallel for
            for (int nY = nYTop; nY &lt;= nYBottom; nY++)
            {   
                for (int nX = nXLeft; nX &lt;= nXRight; nX++)
                {   
                    // Use look-up table for performance
                    dLon = theApp.m_LonLatLUT.LonGrid()[nY][nX] + m_FavoriteSVISSRParams.m_dNadirLon;
                    dLat = theApp.m_LonLatLUT.LatGrid()[nY][nX];
  
                    // If you don't want to use longitude/latitude look-up table, uncomment the following line
                    //NOMGeoLocate.XYToGEO(dLon, dLat, nX, nY);
  
                    if (dLon &gt; 180 || dLat &gt; 180)
                    {  
                       continue;
                    }
  
                    if (Navigation.GeoToXY(dX, dY, dLon, dLat, 0) &gt; 0) 
                    {  
                       continue;
                    }
  
                    // Skip void data scanline
                    dY = dY - nScanlineOffset;
  
                    // Compute coefficients as well as its four neighboring points' values
                    nX1 = int(dX);
                    nX2 = nX1 + 1;
                    nY1 = int(dY);
                    nY2 = nY1 + 1;
  
                    dCx = dX - nX1;
                    dCy = dY - nY1;
  
                    dP1 = pIRChannelData-&gt;operator [](nY1)[nX1];
                    dP2 = pIRChannelData-&gt;operator [](nY1)[nX2];
                    dP3 = pIRChannelData-&gt;operator [](nY2)[nX1];
                    dP4 = pIRChannelData-&gt;operator [](nY2)[nX2];
  
                    // Bilinear interpolation
                    usNomDataBlock[nY][nX] = (unsigned short)BilinearInterpolation(dCx, dCy, dP1, dP2, dP3, dP4);
                } 
            }
  </code></pre>