Skip to content

Commit d5599cf

Browse files
committed
make varn APIs separated from var APIs
1. the optional arguments of varn APIs are different from var 2. the dimensionality of starts, and counts are also different
1 parent 2977773 commit d5599cf

File tree

7 files changed

+587
-356
lines changed

7 files changed

+587
-356
lines changed

examples/put_varn_int.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def pnetcdf_io(file_name, file_format):
153153
w_buf = np.full(w_len, rank, dtype=np.int32)
154154

155155
# set the buffer pointers to different offsets to the I/O buffe
156-
v.put_var_all(w_buf, start = starts, count = counts, num = num_reqs)
156+
v.put_varn_all(w_buf, num = num_reqs, starts = starts, counts = counts)
157157

158158
# close the file
159159
f.close()

src/pnetcdf/_Variable.pyx

Lines changed: 572 additions & 341 deletions
Large diffs are not rendered by default.

test/tst_var_bput_varn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def run_test(format):
166166
v = f.variables[f'data{i}']
167167
assert(f.inq_buff_size() - f.inq_buff_usage() > 0)
168168
# post the request to write an array of values
169-
req_id = v.bput_var(data, start = starts, count = counts, num = num_subarrays)
169+
req_id = v.bput_varn(data, num_subarrays, starts, counts)
170170
# track the request ID for each write request
171171
req_ids.append(req_id)
172172

@@ -182,7 +182,7 @@ def run_test(format):
182182
# post requests to write the 2nd half of variables w/o tracking req ids
183183
for i in range(num_reqs):
184184
v = f.variables[f'data{num_reqs + i}']
185-
v.bput_var(data, start = starts, count = counts, num = num_subarrays)
185+
v.bput_varn(data, num_subarrays, starts, counts)
186186

187187
# commit the posted requests all at once using wait_all (collective i/o)
188188
f.wait_all(num = pnetcdf.NC_PUT_REQ_ALL)

test/tst_var_get_varn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ def runTest(self):
120120
"""testing variable get varn for CDF-5/CDF-2/CDF-1 file"""
121121
dataref = np.full((buf_len,), rank, np.float32)
122122
f = pnetcdf.File(self.file_path, 'r')
123-
# test collective i/o get_var
123+
# test collective i/o get_varn
124124
v1 = f.variables['var1']
125125
buff = np.empty((buf_len,), v1.dtype)
126-
v1.get_var_all(buff, start = starts, count = counts, num = num_reqs)
126+
v1.get_varn_all(buff, num_reqs, starts, counts)
127127
assert_array_equal(buff, dataref)
128-
# test independent i/o get_var
128+
# test independent i/o get_varn
129129
f.begin_indep()
130130
buff = np.empty((buf_len,), v1.dtype)
131-
v1.get_var(buff, start = starts, count = counts, num = num_reqs)
131+
v1.get_varn(buff, num_reqs, starts, counts)
132132
assert_array_equal(buff, dataref)
133133
f.close()
134134

test/tst_var_iget_varn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def setUp(self):
135135
v = f.variables[f'data{i}']
136136
buff = np.empty(shape = buf_len, dtype = v.datatype)
137137
# post the request to read multiple slices (subarrays) of the variable
138-
req_id = v.iget_var(buff, start = starts, count = counts, num = num_subarray_reqs)
138+
req_id = v.iget_varn(buff, num_subarray_reqs, starts, counts)
139139
# track the reqeust ID for each read reqeust
140140
req_ids.append(req_id)
141141
# store the reference of variable values
@@ -154,7 +154,7 @@ def setUp(self):
154154
v = f.variables[f'data{i}']
155155
buff = np.empty(buf_len, dtype = v.datatype)
156156
# post the request to read a list of subarrays from the variable
157-
v.iget_var(buff, start = starts, count = counts, num = num_subarray_reqs)
157+
v.iget_varn(buff, num_subarray_reqs, starts, counts)
158158
# store the reference of variable values
159159
v_datas.append(buff)
160160

test/tst_var_iput_varn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def setUp(self):
136136
for i in range(num_reqs):
137137
v = f.variables[f'data{i}']
138138
# post the request to write an array of values
139-
req_id = v.iput_var(data, start = starts, count = counts, num = num_subarrays)
139+
req_id = v.iput_varn(data, num_subarrays, starts, counts)
140140
# track the reqeust ID for each write reqeust
141141
req_ids.append(req_id)
142142

@@ -153,7 +153,7 @@ def setUp(self):
153153
for i in range(num_reqs):
154154
v = f.variables[f'data{num_reqs + i}']
155155
# post the request to write an array of values
156-
v.iput_var(data, start = starts, count = counts, num = num_subarrays)
156+
v.iput_varn(data, num_subarrays, starts, counts)
157157

158158
# all processes commit all pending requests to the file at once using wait_all (collective i/o)
159159
f.wait_all(num = pnetcdf.NC_PUT_REQ_ALL)

test/tst_var_put_varn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ def setUp(self):
114114
buf_len += w_req_len
115115
data = np.empty(buf_len, dtype=np.float32)
116116
data.fill(rank)
117-
# collective put_var
118-
var1.put_var_all(data, start = starts, count = counts, num = num_reqs)
117+
# collective put_varn
118+
var1.put_varn_all(data, num_reqs, starts, counts)
119119

120-
# independent put_var
120+
# independent put_varn
121121
f.begin_indep()
122-
var2.put_var(data, start = starts, count = counts, num = num_reqs)
122+
var2.put_varn(data, num_reqs, starts, counts)
123123
f.close()
124124
comm.Barrier()
125125
assert validate_nc_file(os.environ.get('PNETCDF_DIR'), self.file_path) == 0 if os.environ.get('PNETCDF_DIR') is not None else True

0 commit comments

Comments
 (0)