Dear all,

I would like to use OpenMP with a code that uses the Openbabel library, and
I am facing problems. I have copied an example of a simple code below. I
have tried with Openbabel 2.3.2 and 2.4.1. I am compiling with:

g++ -O3 -Wall -std=c++11 -Wno-uninitialized
-I/home/nicolas/Programs/Openbabel_2.3.2/include/openbabel-2.0 -lm -fopenmp
-c File.cpp -o File.o
g++ File.o -o File.exe -rdynamic
/home/nicolas/Programs/Openbabel_2.3.2/lib/libopenbabel.so
-Wl,-rpath,/home/nicolas/Programs/Openbabel_2.3.2/lib -fopenmp

When using the following, it works and produces 20 files (Ligand_0_x.xyz
with x from 0 to 19):
export OMP_NUM_THREADS=1
./File.exe

When I set export OMP_NUM_THREADS=4, it fails with:
==============================
*** Open Babel Warning  in Translate
  Cannot perform atom type translation: table cannot find requested types.
Erreur de segmentation (core dumped)


Can someone please help me fixing it. I am now wondering if it is possible
to mix OpenMP and Openbabel.

Thank you

Nicolas



***********************************************
#include <openbabel/mol.h>
#include <openbabel/obconversion.h>
#include <openbabel/forcefield.h>
#include <openbabel/atom.h>
#include <omp.h>

using namespace std;

int main(int nbarg, char * argv[])
{
   #pragma omp parallel for
   for (int x=0 ; x < 20 ; x++) {
      //Convert thread index and x in string
      ostringstream threadFlow;
      threadFlow << omp_get_thread_num();
      string thread = threadFlow.str();
      ostringstream xFlow;
      xFlow << x;
      string counter = xFlow.str();

      //Read the input file
      OpenBabel::OBMol obMol;
      OpenBabel::OBConversion obConversion;
      OpenBabel::OBFormat *format =
obConversion.FormatFromExt("Molecule.pdb");
      obConversion.SetInFormat(format);
      obConversion.ReadFile(&obMol, "Molecule.pdb");

      //Convert the object in xyz
      string outputFileName = "Ligand_" + thread + "_" + counter + ".xyz";
      obConversion.SetOutFormat("xyz");
      obMol.SetTitle(outputFileName);
      obConversion.WriteFile(&obMol, outputFileName);
      }
    return 0;
}
------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to