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:
#pragma omp parallel for shared(dir,utilitiespath,frequency,solvent,Method,dispersion) private(beginning,file_cp2k,file_geo,file_energy)
for(i=1;i<=n_conformers;i=i+1)
{
time(&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<<"loop "<<i<<" time "<<beginning<< endl;
int n_atom=Makecp2kOptInput(file_geo, file_cp2k, dir,utilitiespath, frequency, solvent, Method,dispersion);
}
I get the following error:
* Error in `./ChemAliveMolOpt': double free or corruption (fasttop): 0x00000000018d7c00 * Aborted (core dumped)
If I remove the call to the subroutine there is no problem.
How should I proceed to parallelize the loop properly?
Thanks
timewon't work as you're expecting it to, probably.iprivate andn_conformersshared. However, without us knowing what the functionMakecp2kOptInputdoes and how it interacts with these variables, we can't help you further.