<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">I still feel the standard obscures the case. Passing a buffer (value) and the length of the buffer (valuelen) is easier for programmers.<div>The Fortran interface "CHARACTER(LEN=valuelen), INTENT(OUT) ::  value" is clearer in this regard.</div>







</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div>
<br><div class="gmail_quote">On Tue, Feb 3, 2015 at 5:33 PM, Thakur, Rajeev <span dir="ltr"><<a href="mailto:thakur@mcs.anl.gov" target="_blank">thakur@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I guess it may have been defined that way because in Fortran strings are not null-terminated. The definition in the standard allows the same value to be returned/passed in valuelen in both C and Fortran.<br>
<br>
Rajeev<br>
<br>
On Feb 3, 2015, at 5:28 PM, Junchao Zhang <<a href="mailto:jczhang@mcs.anl.gov">jczhang@mcs.anl.gov</a>><br>
<div class="HOEnZb"><div class="h5"> wrote:<br>
<br>
> OK, I guess MPI standard wants to have this kind of code.<br>
><br>
> int valuelen;<br>
> MPI_Info_get_valuelen(..., &valuelen,...);<br>
> int buflen = valuelen + 1;<br>
> char* value = (char *)malloc(buflen);<br>
> MPI_Info_get(..., valuelen, value, ...);<br>
><br>
> Though, from a user's point of view, I fell better if it was MPI_Info_get(..., buflen, value, ...), that is, using buflen to specify the length of buffer I pass to MPI.<br>
><br>
><br>
> --Junchao Zhang<br>
><br>
> On Tue, Feb 3, 2015 at 4:26 PM, William Gropp <<a href="mailto:wgropp@illinois.edu">wgropp@illinois.edu</a>> wrote:<br>
> Thanks.  Yes, I believe this is a bug.  The implementation of MPI_Info_get in MPICH passes valuelen to the internal copy routine, yet it is clear that the definition in the standard for MPI_Info_get, it should pass valuelen+1 (it should also check for the error return code from the internal routine and return a value MPI error code if the buffer is too small.<br>
><br>
> Bill<br>
><br>
> On Feb 1, 2015, at 12:13 AM, Hajime Fujita <<a href="mailto:hfujita@uchicago.edu">hfujita@uchicago.edu</a>> wrote:<br>
><br>
>> Hello,<br>
>><br>
>> I came across some question about a behavior of MPI_Info_get in MPICH.<br>
>><br>
>> If I knew the size of the value, what should I pass to MPI_Info_get as `valuelen`?<br>
>> Suppose I have 3-byte value in the info object, and I allocate 4-byte buffer including a space for null-termination. Then I think I should specify 3 as valuelen to retrieve the whole value, as the MPI-3 specifications says<br>
>> "In C, valuelen should be one less than the amount of allocated space to allow for the null terminator.”<br>
>><br>
>> However, when I run the attached program in MPICH 3.1.1, I get:<br>
>> $ ./test<br>
>> key found: vaule=va  # The last character ‘l’ is missing<br>
>><br>
>> If I specify `sizeof(buff)` as valuelen, it shows “val” correctly.<br>
>><br>
>> So apparently MPICH thinks valuelen includes null terminator.<br>
>> Am I missing anything, or any misunderstanding here?<br>
>><br>
>><br>
>> Thank you in advance,<br>
>> Hajime<br>
>><br>
>> --<br>
>> Hajime Fujita<br>
>> Postdoctoral Scholar, Large-Scale Systems Group<br>
>> Department of Computer Science, The University of Chicago<br>
>> <a href="http://www.cs.uchicago.edu/people/hfujita" target="_blank">http://www.cs.uchicago.edu/people/hfujita</a><br>
>> _______________________________________________<br>
>> discuss mailing list     <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
>> To manage subscription options or unsubscribe:<br>
>> <a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
>> <test.c><br>
><br>
><br>
> _______________________________________________<br>
> discuss mailing list     <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
><br>
> _______________________________________________<br>
> discuss mailing list     <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
<br>
_______________________________________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
</div></div></blockquote></div><br></div>