I don’t agree that the standard obscures the case (at least in this instance).  The language is clear.  You are objecting to the choice that was made in the standard, and I might agree with you that it is unfortunate.  But that doesn’t change the fact that (a) the standard is clear and (b) any change would not be backward compatible.

Bill

On Feb 3, 2015, at 10:41 PM, Junchao Zhang <jczhang@mcs.anl.gov> wrote:

I still feel the standard obscures the case. Passing a buffer (value) and the length of the buffer (valuelen) is easier for programmers.
The Fortran interface "CHARACTER(LEN=valuelen), INTENT(OUT) ::  value" is clearer in this regard.

--Junchao Zhang

On Tue, Feb 3, 2015 at 5:33 PM, Thakur, Rajeev <thakur@mcs.anl.gov> wrote:
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.

Rajeev

On Feb 3, 2015, at 5:28 PM, Junchao Zhang <jczhang@mcs.anl.gov>
 wrote:

> OK, I guess MPI standard wants to have this kind of code.
>
> int valuelen;
> MPI_Info_get_valuelen(..., &valuelen,...);
> int buflen = valuelen + 1;
> char* value = (char *)malloc(buflen);
> MPI_Info_get(..., valuelen, value, ...);
>
> 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.
>
>
> --Junchao Zhang
>
> On Tue, Feb 3, 2015 at 4:26 PM, William Gropp <wgropp@illinois.edu> wrote:
> 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.
>
> Bill
>
> On Feb 1, 2015, at 12:13 AM, Hajime Fujita <hfujita@uchicago.edu> wrote:
>
>> Hello,
>>
>> I came across some question about a behavior of MPI_Info_get in MPICH.
>>
>> If I knew the size of the value, what should I pass to MPI_Info_get as `valuelen`?
>> 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
>> "In C, valuelen should be one less than the amount of allocated space to allow for the null terminator.”
>>
>> However, when I run the attached program in MPICH 3.1.1, I get:
>> $ ./test
>> key found: vaule=va  # The last character ‘l’ is missing
>>
>> If I specify `sizeof(buff)` as valuelen, it shows “val” correctly.
>>
>> So apparently MPICH thinks valuelen includes null terminator.
>> Am I missing anything, or any misunderstanding here?
>>
>>
>> Thank you in advance,
>> Hajime
>>
>> --
>> Hajime Fujita
>> Postdoctoral Scholar, Large-Scale Systems Group
>> Department of Computer Science, The University of Chicago
>> http://www.cs.uchicago.edu/people/hfujita
>> _______________________________________________
>> discuss mailing list     discuss@mpich.org
>> To manage subscription options or unsubscribe:
>> https://lists.mpich.org/mailman/listinfo/discuss
>> <test.c>
>
>
> _______________________________________________
> discuss mailing list     discuss@mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
>
> _______________________________________________
> discuss mailing list     discuss@mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss

_______________________________________________
discuss mailing list     discuss@mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss

_______________________________________________
discuss mailing list     discuss@mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss