-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtst_libver.py
66 lines (51 loc) · 1.85 KB
/
tst_libver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# Copyright (C) 2024, Northwestern University and Argonne National Laboratory
# See COPYRIGHT notice in top-level directory.
#
"""
This program test the followings:
pnetcdf class member: __version__ a string of PnetCDF-Python version
pnetcdf method: libver() a function call to get the version
pnetcdf method: inq_clibvers() a string of PnetCDF-C library version
"""
import sys, argparse
from mpi4py import MPI
import pnetcdf
def parse_help():
help_flag = "-h" in sys.argv or "--help" in sys.argv
if help_flag and rank == 0:
help_text = (
"Usage: {} [-h | -q]\n"
" [-h] Print help\n"
" [-q] Quiet mode (reports when fail)\n"
).format(sys.argv[0])
print(help_text)
return help_flag
if __name__ == "__main__":
rank = MPI.COMM_WORLD.Get_rank()
if parse_help():
MPI.Finalize()
sys.exit(1)
# Get command-line arguments
args = None
parser = argparse.ArgumentParser()
parser.add_argument("-q", help="Quiet mode (reports when fail)", action="store_true")
args = parser.parse_args()
verbose = False if args.q else True
if verbose and rank == 0:
print("test pnetcdf.libver() and pnetcdf.inq_clibvers()")
# Run tests
try:
mlibver = pnetcdf.__version__
if verbose and rank == 0:
print("Test python class member, pnetcdf.__version__ = ", mlibver)
plibver = pnetcdf.libver()
if verbose and rank == 0:
print("test pnetcdf.libver(), PnetCDF Python version : ", plibver)
clibvers = pnetcdf.inq_clibvers()
if verbose and rank == 0:
print("test pnetcdf_python_clibvers(), PnetCDF C library version: ", clibvers)
except BaseException as err:
print("Error: type:", type(err), str(err))
raise
MPI.Finalize()