title: call function in openmp parallelized loop
body: <p>I am new to OpenMP and I have a loop that I want to parallelize with OpenMP. Inside the parallel loop a subroutine is called. Here my code:</p>
  
  <pre><code>#pragma omp parallel for shared(dir,utilitiespath,frequency,solvent,Method,dispersion)  private(beginning,file_cp2k,file_geo,file_energy)
  for(i=1;i&lt;=n_conformers;i=i+1)
  {
      time(&amp;beginning);
      file_cp2k="conformer"+ QString::number(i) +".inp";
      file_geo= "conformer" +  QString::number(i) + "_geoMM.sdf";
      file_energy=dir+ "conformer" + QString::number(i)  + "_enerSE";
      cout&lt;&lt;"loop "&lt;&lt;i&lt;&lt;" time "&lt;&lt;beginning&lt;&lt; endl;
      int n_atom=Makecp2kOptInput(file_geo, file_cp2k, dir,utilitiespath, frequency, solvent, Method,dispersion);
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p><strong>* Error in `./ChemAliveMolOpt': double free or corruption
    (fasttop): 0x00000000018d7c00 *</strong> Aborted (core dumped)</p>
  </blockquote>
  
  <p>If I remove the call to the subroutine there is no problem.</p>
  
  <p>How should I proceed to parallelize the loop properly?</p>
  
  <p>Thanks</p>