[petsc-dev] Are there both a function AND a #define to retrieve PETSc version?

Eric Chamberland Eric.Chamberland at giref.ulaval.ca
Mon Aug 29 08:35:30 CDT 2016



On 28/08/16 06:24 PM, Jed Brown wrote:
> Eric Chamberland <Eric.Chamberland at giref.ulaval.ca> writes:
>
>> Le 2016-08-27 à 15:22, Jed Brown a écrit :
>>> Barry Smith <bsmith at mcs.anl.gov> writes:
>>>>     Well in Eric's case he knows he needs a bug fix in sub minor 3 and wants to generate an error if linked against an earlier one that does not have the bug fix. There needs to be a way for users to indicate if they need above something in the sub minor, doesn't there?
>>> Oh, then we can have PetscVersionGet(&major,&minor,&subminor,&release).
>>> Or PetscVersionGetMajor(&major), ...
>>>
>>> Preference?
>> Good question!  I am not aware of other libs than MPI, and in MPI the
>> returned value is a string containing eventually a lot a things...
>
> There is both MPI_Get_version(int *version, int *subversion) and
> MPI_Get_library_version(char *version, int *resultlen).
>
Yes, but I think MPI_Get_version refers to MPI version's of the standard...

> Meanwhile, there is already PetscGetVersion(char *version, size_t len).
> If you like parsing strings, it seems like that would serve you purpose.

Okay!  That was in fact my very first question... so there is already 
something!!!

> But if you want to handle it programmatically without needing to parse a
> string, then perhaps we should add a PetscGetVersionNumber (more
> consistent name than my first suggestion).  What is your peference?
>

Personally, I prefer to use something that is already there...  even if 
it implies to to some strings manipulation for now, I will have this 
check functional for older versions of Petsc we still deal with...

But I think it is a good idea to replace PetscInitialize with the 
verification right into Petsc...

>> For me now, what you proposed is enough... but if the most interesting
>> would be to have a function with an API that will not change too much in
>> the future, maybe a string is a better choice. If changing the function
>> API is not an argument, then I prefer a single call than n calls to
>> retreive the complete version.
>
> The problem with a string is that the format of the string can be
> changed without changing the API, thus breaking existing code in a
> possibly subtly way at run time.  Note that the MPI standard does not
> specify the format of MPI_Get_library_version.
>

Yes, but I do know which versions we support... :)

Thanks!

Eric



More information about the petsc-dev mailing list