[Dune] Weird behaviour of MPIHelper

Aleksejs Fomins aleksejs.fomins at lspr.ch
Tue May 19 17:01:32 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Martin,

Thank you :)
I was assuming for no reason that mpihelper_.getCollectiveCommunication() was giving me a reference to a class stored in subconscious of the MPIHelper, but, obviously, it creates a new class every time.

Sorry for the trouble,
Aleksejs

P.S. Sorry for spam, I forgot to reply to all


On 19/05/15 15:45, Martin Nolte wrote:
> Hi Aleksejs
>
> you're returning a reference to a temporary, so weird behaviour is normal. To my knowledge, however, the compiler should emit a warning in this case. Did you disable / ignore them by accident?
>
> Best,
>
> Martin
>
> On 05/19/2015 03:28 PM, Aleksejs Fomins wrote:
> Dear Dune,
>
> I am having trouble with very basic c++ pointer problem in my curvilinear grid. The file grid.hh contains 2 functions:
>
>      const CollectiveCommunication &comm () const  { return mpihelper_.getCollectiveCommunication(); }
>
>      MPIHelper & mpihelper()  const { return mpihelper_; }
>
> One of them returns the MPIHelper reference, the other the CollectiveCommunication reference.
>
>
> I write a test program:
>
> Grid * grid = factory.createGrid();
>
> std::cout << "rank v1 = " << grid->comm().rank() << std::endl;
> std::cout << "rank v2 = " << grid->mpihelper().getCollectiveCommunication().rank() << std::endl;
>
> the result for a serial run is
> -1183734688
> 0
>
> And the first result puzzles me a lot, as I expect it to be equal to the 2nd one. Otherwise, the grid is functioning well, so it is definitely initialized
>
> Any ideas?
>
> Greetings,
> Aleksejs
>>
>> _______________________________________________
>> Dune mailing list
>> Dune at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune
>>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBAgAGBQJVW1BMAAoJEDkNM7UOEwMZBNQP/jiqHmtvNCqXvWR/SLCeQINp
KrEAM1q+8thwGyzuo8YvLZzLY9yUk1BTMSXz6kWt945Jdfyie3B0tLtvtCfc/lGs
dxvKfMGxkV10jx1ZL/Utx1jLT00Cvn+Q9P1wgZzrls2rJ1iL5RS0BjGwI4kUNo9B
OC8yADM8lzwWAwvcWdFBo0lkXwupBvrN7g+IeVknX0BfPsylOJ6tjdiIA2M80F6J
UDk5/Gf/8uyp/9boWIR2DkTj1so/6VWi//p/g2yj+d9npKhCFhquAqrCoZvM2XfP
q3coEc6dJaxaQKBWh66OuBZWXIjCppVyzYGY5zSONzcsWn2iJqJDDRZuIbdV8lVD
xPZDQUyAJ0TWUS8Cd7TSgMUyiPX+JHxxgXpTj7ghHZEh6Oh1ItbcuygVMsEqleZ2
BwOKROjSHVZAjTnWSw/X/SIaS/iOS+sHFjyyFTywBdg6XuaLfiJJ3/+L8usqvCOA
O7QgSn0gzHWM1E09mZk/g+IKormQ5Wu5LAgg4oVmyllqxVYvrnWjUCWKE36nmJAZ
1ZMeQmsjYXXp/L8G2Uo/O8OGLB+RK921mda2fSr0CPL4WHjnGSSp5BCylCxsAKt0
r/PBAA6BMkl4n7xyFv/sq5Vnsqm7Elatriw6h5cToW90fCGRncHletgr/boGXXUd
KR15aAh80QzwWRufs8o8
=1mtw
-----END PGP SIGNATURE-----




More information about the Dune mailing list