Serializing histogram objects

Hi Rene,

Thank you for quick answer. Those examples was almost what I needed.
I am using the Object Oriented implementation of MPI (OOMPI), which seens to be the best approach when building a full object oriented application. With MPI/OOMPI I can send only basic types or vectors (int, double, char, and so on). It is possible to serialize an object by TMessage::Buffer() method, inherited from TBuffer class. This is my program to a slave node (it is working):

  TH1D *h1sl  = new TH1D ("h1sl","h1sl", 100, -3, 3);
  
  h1sl->FillRandom ("gaus", 100000);
  msg = new TMessage (kMESS_OBJECT);
  msg->Reset();
  msg->WriteObject (h1sl);
  
  int j = (int)msg->Length();
  OOMPI_COMM_WORLD[0].Send(OOMPI_Message(j));
  
  char *k = msg->Buffer();
  
  OOMPI_Message array_msg (k, j);
  OOMPI_COMM_WORLD[0].Send(array_msg);

My problem now is how to fill a TMessage/TBuffer with a received message and get the object. I have tried this program on master node without success:

  for(Int_t i = 1; i < size; i++)
    {
  int lg;
  OOMPI_COMM_WORLD[i].Recv(lg); //buffer length

  char *kg = new char [lg];	//buffer 
  OOMPI_COMM_WORLD[i].Recv(kg,lg);

  msg = new TMessage ();
  msg->SetBuffer (kg, lg);	//filling message buffer

  TH1D *h1s = (TH1D *) msg->ReadObject(msg->GetClass());

  h1s->Draw();
  }

Where ‘i’ run over my all nodes.

I can compile this program, but when I run I get this error message:
*** Break *** segmentation violation
Generating stack trace…
0x4139cca8 in from /lib/i686/libc.so.6
0x41389c57 in __libc_start_main + 0xc7 from /lib/i686/libc.so.6
0x08066d41 in strcpy + 0x3d from testprogram

Could you help me?

Luís A. Perles

Medical Physics PhD. student
USP - Brazil