Clearly fwrite was called with invalid parameters, but you don't give enough information for anyone to explain why. Compile your program with debugging symbols and print the whole stack trace, e.g. with "backtrace full". Also try valgrind.

class CNSGA2

{

allocate mem for var;

some deallocate statement;

some pointers;

evaluate(); // it is a function

}

This isn't even close to valid code since you can't have statements in the suggested scope.

main()

{

CNSGA2* nsga2a = new CNSGA2(true); // true or false are only for different constructors

CNSGA2* nsga2b = new CNSGA2(false);

if (myRank == 0) // scope1

{

initialize the objects of nsga2a or nsga2b;

}

broadcast some parameters, which are got from scope1.

According to the parameters, define a datatype (myData) so that all workers use that to do recv and send.

if (myRank == 0) // scope2

{

send out myData to workers by the datatype defined above;

}

if (myRank != 0)

{

newCNSGA2 myNsga2;

recv data from master and work on the recved data;

myNsga2.evaluate(recv data);

send back results;

}

}

According to the above, rank 0 never receives the results from before. You should paste valid code.