Skip to content

Commit 8fc107f

Browse files
committed
Add pnetcdf.libver() and pnetcdf.inq_clibvers()
1 parent dd3c0bf commit 8fc107f

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

docs/source/api/file_api.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ relations among data fields stored in a netCDF file.
1515
detach_buff, set_fill, inq_buff_usage, inq_buff_size, inq_num_rec_vars,
1616
inq_num_fix_vars, inq_striping, inq_recsize, inq_version, inq_info,
1717
inq_header_size, inq_put_size, inq_header_extent, inq_nreqs
18-
:exclude-members: dimensions, variables, file_format, libver, indep_mode,
19-
path
18+
:exclude-members: dimensions, variables, file_format, indep_mode, path
2019

2120
Read-only Python Attributes of File Class
2221
The following class members are read-only and should not be modified by the
@@ -44,9 +43,3 @@ Read-only Python Attributes of File Class
4443

4544
**Type:** `str`
4645

47-
.. attribute:: libver
48-
49-
The PnetCDF-Python version string.
50-
51-
**Type:** `str`
52-

docs/source/api/function_api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
Utility Functions
33
================
44

5+
.. autofunction:: pnetcdf::libver
56
.. autofunction:: pnetcdf::strerror
67
.. autofunction:: pnetcdf::strerrno
78
.. autofunction:: pnetcdf::chartostring
89
.. autofunction:: pnetcdf::stringtochar
910
.. autofunction:: pnetcdf::set_default_format
1011
.. autofunction:: pnetcdf::inq_default_format
1112
.. autofunction:: pnetcdf::inq_file_format
13+
.. autofunction:: pnetcdf::inq_clibvers

include/PnetCDF.pxi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cdef extern from "pnetcdf.h":
2121
ctypedef int MPI_Datatype
2222
const_char_ptr ncmpi_strerror(int err);
2323
const_char_ptr ncmpi_strerrno(int err);
24+
const_char_ptr ncmpi_inq_libvers();
2425

2526

2627
cdef const int NC_BYTE_C "NC_BYTE"

src/pnetcdf/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@
1212
from ._Dimension import *
1313
from ._Variable import *
1414
from ._utils import *
15+
16+
def libver():
17+
"""
18+
libver()
19+
20+
:return: PnetCDF-Python version string.
21+
:rtype: str
22+
"""
23+
return __version__
24+

src/pnetcdf/_utils.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ cpdef inq_default_format()
2626
cpdef inq_file_format(str file_name)
2727
cpdef inq_malloc_max_size()
2828
cpdef inq_malloc_size()
29+
cpdef inq_clibvers()

src/pnetcdf/_utils.pyx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,20 @@ cdef _get_format(int ncid):
791791

792792

793793
# external C functions.
794+
cpdef inq_clibvers():
795+
"""
796+
inq_clibvers()
797+
798+
This function returns a string describing the version of the PnetCDF-C
799+
library used to build this PnetCDF-Python module, and when the PnetCDF-C
800+
library was built.
801+
802+
:return: a string about PnetCDF-C library
803+
:rtype: str
804+
"""
805+
ver_str = (<char *>ncmpi_inq_libvers()).decode('ascii')
806+
return ver_str
807+
794808
cpdef strerror(err_code):
795809
"""
796810
strerror(err_code)
@@ -807,7 +821,6 @@ cpdef strerror(err_code):
807821
"""
808822
cdef int ierr
809823
ierr = err_code
810-
811824
err_str = (<char *>ncmpi_strerror(ierr)).decode('ascii')
812825
return err_str
813826

@@ -873,7 +886,7 @@ cpdef inq_default_format():
873886
874887
:Operational mode: This function is an independent subroutine.
875888
"""
876-
cdef int curformat
889+
cdef int ierr, curformat
877890
with nogil:
878891
ierr = ncmpi_inq_default_format(&curformat)
879892
_check_err(ierr)

0 commit comments

Comments
 (0)