On Mar 12, 2008, at 3:25 AM, Manoj Vaghela wrote:
> I want to copy derived datatype "newtype1" to "newtype2".
> This is for avoiding copying of each and every element of
> "newtype1" to "newtype2"
> I tried the following conventions:
>
> MPI_Type_size(newtype1, &newtype1_size);
> memcpy(&newtype2, &newtype1, newtype1_size);
>
> As "newtype1_size" should be equal to "newtype2_size", either
> of them can be used.
>
> When I printed individual values of newtype2, it showed
> garbage/zero values.
> Can anyone please throw some light on this? Or any other idea
> of copying one derived datatype to another can be explained.
Well, the short answer is that you can't do that :). newtype1 is a
handle to the actual datatype, not the actual datatype itself.
MPI_Type_size gives you the space that the data represented by
newtype1 takes, not the size of the backing information for newtype1.
Hope that makes sense. If not, you probably want to have another read
through the MPI datatype section.
Brian
--
Brian Barrett
LAM/MPI Developer
Make today a LAM/MPI day!
|