1 | function test_varput_1g ( ncfile ) |
---|
2 | % TEST_VARPUT_1G |
---|
3 | % |
---|
4 | % This routine tests VARPUT1, VARPUT, and VARPUTG routines with both scaling |
---|
5 | % and no scaling. MEXCDF should never have been written with scaling built in. |
---|
6 | % |
---|
7 | % Test 1: VARPUT1/VARGET1 |
---|
8 | % Test 2: varput1/varget1 with scaling |
---|
9 | % Test 3: varput/varget |
---|
10 | % Test 4: varput/varget with scaling |
---|
11 | % Test 4.5: varput/varget with scaling, negative integers |
---|
12 | % Test 5: varputg/vargetg |
---|
13 | % Test 6: varputg/vargetg with scaling |
---|
14 | % Test 7: VARPUT1 with a bad ncid |
---|
15 | % Test 8: VARGET1 with a bad ncid |
---|
16 | |
---|
17 | mexnc ( 'setopts', 0 ); |
---|
18 | |
---|
19 | % |
---|
20 | % ok, first create this baby. |
---|
21 | [ncid, status] = mexnc ( 'create', ncfile, nc_clobber_mode ); |
---|
22 | if ( status ~= 0 ) |
---|
23 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
24 | msg = sprintf ( '%s: ''create'' failed on %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); |
---|
25 | error ( msg ); |
---|
26 | end |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | % |
---|
31 | % Create the fixed dimension. |
---|
32 | len_x = 100; |
---|
33 | [xdimid, status] = mexnc ( 'def_dim', ncid, 'x', len_x ); |
---|
34 | if ( status ~= 0 ) |
---|
35 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
36 | msg = sprintf ( '%s: ''def_dim'' failed on dim x, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); |
---|
37 | error ( msg ); |
---|
38 | end |
---|
39 | |
---|
40 | |
---|
41 | [z_double_varid, status] = mexnc ( 'def_var', ncid, 'z_double', nc_double, 1, [xdimid] ); |
---|
42 | if ( status ~= 0 ) |
---|
43 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
44 | msg = sprintf ( '%s: ''def_var'' failed on var x_short, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); |
---|
45 | error ( msg ); |
---|
46 | end |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | [z_short_varid, status] = mexnc ( 'def_var', ncid, 'z_short', nc_short, 1, [xdimid] ); |
---|
51 | if ( status ~= 0 ) |
---|
52 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
53 | msg = sprintf ( '%s: ''def_var'' failed on var z_short, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); |
---|
54 | error ( msg ); |
---|
55 | end |
---|
56 | |
---|
57 | |
---|
58 | eps = 0.01; |
---|
59 | status = mexnc ( 'put_att_double', ncid, z_short_varid, 'scale_factor', nc_double, 1, eps ); |
---|
60 | if ( status ~= 0 ) |
---|
61 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
62 | msg = sprintf ( '%s: ''%s''\n', mfilename, ncerr_msg ); |
---|
63 | error ( msg ); |
---|
64 | end |
---|
65 | |
---|
66 | |
---|
67 | status = mexnc ( 'put_att_double', ncid, z_short_varid, 'add_offset', nc_double, 1, 0.00 ); |
---|
68 | if ( status ~= 0 ) |
---|
69 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
70 | msg = sprintf ( '%s: ''%s''\n', mfilename, ncerr_msg ); |
---|
71 | error ( msg ); |
---|
72 | end |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | [status] = mexnc ( 'enddef', ncid ); |
---|
79 | if ( status ~= 0 ) |
---|
80 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
81 | msg = sprintf ( '%s: ''enddef'' failed, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); |
---|
82 | error ( msg ); |
---|
83 | end |
---|
84 | |
---|
85 | |
---|
86 | % |
---|
87 | % CLOSE |
---|
88 | status = mexnc ( 'close', ncid ); |
---|
89 | if ( status ~= 0 ) |
---|
90 | error ( 'CLOSE failed' ); |
---|
91 | end |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | [ncid, status] = mexnc ( 'open', ncfile, nc_write_mode ); |
---|
96 | if ( status ~= 0 ) |
---|
97 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
98 | msg = sprintf ( '%s: ''%s''\n', mfilename, ncerr_msg ); |
---|
99 | error ( msg ); |
---|
100 | end |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | [z_double_varid, status] = mexnc('INQ_VARID', ncid, 'z_double'); |
---|
105 | if ( status ~= 0 ) |
---|
106 | msg = sprintf ( '%s: INQ_VARID failed\n', mfilename ); |
---|
107 | error ( msg ); |
---|
108 | end |
---|
109 | |
---|
110 | |
---|
111 | % |
---|
112 | % Test 1: varput1/varget1 |
---|
113 | testid = 'Test 1'; |
---|
114 | input_data = 3.14159; |
---|
115 | status = mexnc ( 'VARPUT1', ncid, z_double_varid, [0], input_data ); |
---|
116 | if ( status ~= 0 ) |
---|
117 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
118 | msg = sprintf ( '%s: VARPUT1 failed, (%s)\n', mfilename, ncerr_msg ); |
---|
119 | error ( msg ); |
---|
120 | end |
---|
121 | |
---|
122 | |
---|
123 | [output_data, status] = mexnc ( 'VARGET1', ncid, z_double_varid, [0] ); |
---|
124 | if ( status ~= 0 ) |
---|
125 | msg = sprintf ( '%s: GET_VAR_DOUBLE failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
126 | error ( msg ); |
---|
127 | end |
---|
128 | |
---|
129 | output_data = output_data'; |
---|
130 | |
---|
131 | d = max(abs(output_data-input_data))'; |
---|
132 | if (any(d)) |
---|
133 | msg = sprintf ( '%s: %s: values written by PUT_VAR_DOUBLE do not match what was retrieved by GET_VAR_DOUBLE\n', mfilename, testid ); |
---|
134 | error ( msg ); |
---|
135 | end |
---|
136 | |
---|
137 | fprintf ( 1, 'VARPUT1 succeeded\n' ); |
---|
138 | fprintf ( 1, 'VARGET1 succeeded\n' ); |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | % |
---|
143 | % Test 2: varput1/varget1 with scaling |
---|
144 | testid = 'Test 2'; |
---|
145 | input_data = 3.14159; |
---|
146 | status = mexnc ( 'VARPUT1', ncid, z_short_varid, [0], input_data,1 ); |
---|
147 | if ( status ~= 0 ) |
---|
148 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
149 | msg = sprintf ( '%s: VARPUT1 failed, (%s)\n', mfilename, ncerr_msg ); |
---|
150 | error ( msg ); |
---|
151 | end |
---|
152 | |
---|
153 | |
---|
154 | [output_data, status] = mexnc ( 'VARGET1', ncid, z_short_varid, [0], 1 ); |
---|
155 | if ( status ~= 0 ) |
---|
156 | msg = sprintf ( '%s: GET_VAR_DOUBLE failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
157 | error ( msg ); |
---|
158 | end |
---|
159 | |
---|
160 | output_data = output_data'; |
---|
161 | |
---|
162 | d = max(abs(output_data-input_data))'; |
---|
163 | ind = find ( d > eps ); |
---|
164 | if (any(ind)) |
---|
165 | msg = sprintf ( '%s: %s: values written by VARPUT1 do not match what was retrieved by VARGET1\n', mfilename , testid ); |
---|
166 | error ( msg ); |
---|
167 | end |
---|
168 | |
---|
169 | fprintf ( 1, 'VARPUT1 with scaling (please don''t do this, it''s bad) succeeded\n' ); |
---|
170 | fprintf ( 1, 'VARGET1 with scaling (please don''t do this, it''s bad) succeeded\n' ); |
---|
171 | |
---|
172 | |
---|
173 | % |
---|
174 | % Test 3: varput/varget |
---|
175 | testid = 'Test 3'; |
---|
176 | input_data = rand(100,1); |
---|
177 | status = mexnc ( 'VARPUT', ncid, z_double_varid, [0], [len_x], input_data' ); |
---|
178 | if ( status ~= 0 ) |
---|
179 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
180 | msg = sprintf ( '%s: VARPUT failed, (%s)\n', mfilename, ncerr_msg ); |
---|
181 | error ( msg ); |
---|
182 | end |
---|
183 | |
---|
184 | |
---|
185 | [output_data, status] = mexnc ( 'VARGET', ncid, z_double_varid, [0], [len_x] ); |
---|
186 | if ( status ~= 0 ) |
---|
187 | msg = sprintf ( '%s: VARGET failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
188 | error ( msg ); |
---|
189 | end |
---|
190 | |
---|
191 | output_data = output_data'; |
---|
192 | |
---|
193 | d = max(abs(output_data-input_data))'; |
---|
194 | if (any(d)) |
---|
195 | msg = sprintf ( '%s: %s: values written by VARPUT do not match what was retrieved by VARGET\n', mfilename, testid ); |
---|
196 | error ( msg ); |
---|
197 | end |
---|
198 | |
---|
199 | fprintf ( 1, 'VARPUT succeeded\n' ); |
---|
200 | fprintf ( 1, 'VARGET succeeded\n' ); |
---|
201 | |
---|
202 | |
---|
203 | % |
---|
204 | % Test 4: varput/varget with scaling |
---|
205 | testid = 'Test 4'; |
---|
206 | input_data = rand(100,1); |
---|
207 | status = mexnc ( 'VARPUT', ncid, z_short_varid, [0], [len_x], input_data', 1 ); |
---|
208 | if ( status ~= 0 ) |
---|
209 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
210 | msg = sprintf ( '%s: VARPUT failed, (%s)\n', mfilename, ncerr_msg ); |
---|
211 | error ( msg ); |
---|
212 | end |
---|
213 | |
---|
214 | |
---|
215 | [output_data, status] = mexnc ( 'VARGET', ncid, z_short_varid, [0], [len_x], 1 ); |
---|
216 | if ( status ~= 0 ) |
---|
217 | msg = sprintf ( '%s: VARGET failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
218 | error ( msg ); |
---|
219 | end |
---|
220 | |
---|
221 | output_data = output_data'; |
---|
222 | |
---|
223 | d = max(abs(output_data-input_data))'; |
---|
224 | ind = find ( d > eps/2 ); |
---|
225 | if (any(ind)) |
---|
226 | msg = sprintf ( '%s: %s: values written by VARPUT do not match what was retrieved by VARGET\n', mfilename , testid ); |
---|
227 | error ( msg ); |
---|
228 | end |
---|
229 | |
---|
230 | |
---|
231 | fprintf ( 1, 'VARPUT with scaling (please don''t do this, it''s bad) succeeded\n' ); |
---|
232 | fprintf ( 1, 'VARGET with scaling (please don''t do this, it''s bad) succeeded\n' ); |
---|
233 | |
---|
234 | |
---|
235 | |
---|
236 | |
---|
237 | % |
---|
238 | % Test 4.5: varput/varget with scaling, negative integers being the target. |
---|
239 | testid = 'Test 4.5'; |
---|
240 | input_data = rand(100,1) - 1; |
---|
241 | status = mexnc ( 'VARPUT', ncid, z_short_varid, [0], [len_x], input_data', 1 ); |
---|
242 | if ( status ~= 0 ) |
---|
243 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
244 | msg = sprintf ( '%s: VARPUT failed, (%s)\n', mfilename, ncerr_msg ); |
---|
245 | error ( msg ); |
---|
246 | end |
---|
247 | |
---|
248 | |
---|
249 | [output_data, status] = mexnc ( 'VARGET', ncid, z_short_varid, [0], [len_x], 1 ); |
---|
250 | if ( status ~= 0 ) |
---|
251 | msg = sprintf ( '%s: VARGET failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
252 | error ( msg ); |
---|
253 | end |
---|
254 | |
---|
255 | output_data = output_data'; |
---|
256 | |
---|
257 | d = max(abs(output_data-input_data))'; |
---|
258 | ind = find ( d > eps/2 ); |
---|
259 | if (any(ind)) |
---|
260 | msg = sprintf ( '%s: %s: values written by VARPUT do not match what was retrieved by VARGET\n', mfilename , testid ); |
---|
261 | error ( msg ); |
---|
262 | end |
---|
263 | |
---|
264 | |
---|
265 | fprintf ( 1, 'VARPUT with scaling, negative integers\n' ); |
---|
266 | fprintf ( 1, 'VARGET with scaling, negative integers succeeded\n' ); |
---|
267 | |
---|
268 | |
---|
269 | |
---|
270 | |
---|
271 | % |
---|
272 | % Test 4.6: varput/varget with negative integers |
---|
273 | testid = 'Test 4.6'; |
---|
274 | input_data = round(rand(100,1)*100 - 200); |
---|
275 | status = mexnc ( 'VARPUT', ncid, z_short_varid, [0], [len_x], input_data', 1 ); |
---|
276 | if ( status ~= 0 ) |
---|
277 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
278 | msg = sprintf ( '%s: VARPUT failed, (%s)\n', mfilename, ncerr_msg ); |
---|
279 | error ( msg ); |
---|
280 | end |
---|
281 | |
---|
282 | |
---|
283 | [output_data, status] = mexnc ( 'VARGET', ncid, z_short_varid, [0], [len_x], 1 ); |
---|
284 | if ( status ~= 0 ) |
---|
285 | msg = sprintf ( '%s: VARGET failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
286 | error ( msg ); |
---|
287 | end |
---|
288 | |
---|
289 | output_data = output_data'; |
---|
290 | |
---|
291 | d = max(abs(output_data-input_data))'; |
---|
292 | ind = find ( d > eps/2 ); |
---|
293 | if (any(ind)) |
---|
294 | msg = sprintf ( '%s: %s: values written by VARPUT do not match what was retrieved by VARGET\n', mfilename , testid ); |
---|
295 | error ( msg ); |
---|
296 | end |
---|
297 | |
---|
298 | |
---|
299 | fprintf ( 1, 'VARPUT with negative integers\n' ); |
---|
300 | fprintf ( 1, 'VARGET with negative integers succeeded\n' ); |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | |
---|
305 | % |
---|
306 | % VARPUTG |
---|
307 | % Test 5: varputg/vargetg |
---|
308 | testid = 'Test 5'; |
---|
309 | input_data = rand(100,1); |
---|
310 | input_data = input_data(1:2:end,1:2:end); |
---|
311 | [r,c] = size(input_data); |
---|
312 | status = mexnc ( 'VARPUTG', ncid, z_double_varid, [0 0], [r c], [2 2], [], input_data' ); |
---|
313 | if ( status ~= 0 ) |
---|
314 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
315 | msg = sprintf ( '%s: VARPUTG failed, (%s)\n', mfilename, ncerr_msg ); |
---|
316 | error ( msg ); |
---|
317 | end |
---|
318 | |
---|
319 | |
---|
320 | [output_data, status] = mexnc ( 'VARGETG', ncid, z_double_varid, [0 0], [r c], [2 2], [] ); |
---|
321 | if ( status ~= 0 ) |
---|
322 | msg = sprintf ( '%s: VARGETG failed, msg ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
323 | error ( msg ); |
---|
324 | end |
---|
325 | |
---|
326 | output_data = output_data'; |
---|
327 | |
---|
328 | d = max(abs(output_data-input_data))'; |
---|
329 | if (any(d)) |
---|
330 | msg = sprintf ( '%s: %s: values written by VARPUTG do not match what was retrieved by VARGETG\n', mfilename, testid ); |
---|
331 | error ( msg ); |
---|
332 | end |
---|
333 | |
---|
334 | fprintf ( 1, 'VARPUTG succeeded\n' ); |
---|
335 | fprintf ( 1, 'VARGETG succeeded\n' ); |
---|
336 | |
---|
337 | |
---|
338 | % |
---|
339 | % |
---|
340 | % VARPUTG |
---|
341 | % Test 6: varputg/vargetg with scaling |
---|
342 | testid = 'Test 6'; |
---|
343 | input_data = rand(100,1); |
---|
344 | input_data = input_data(1:2:end); |
---|
345 | [r,c] = size(input_data); |
---|
346 | status = mexnc ( 'VARPUTG', ncid, z_short_varid, [0 0], [r], [2], [], input_data', 1 ); |
---|
347 | if ( status ~= 0 ) |
---|
348 | ncerr_msg = mexnc ( 'strerror', status ); |
---|
349 | msg = sprintf ( '%s: VARPUTG failed, (%s)\n', mfilename, ncerr_msg ); |
---|
350 | error ( msg ); |
---|
351 | end |
---|
352 | |
---|
353 | |
---|
354 | [output_data, status] = mexnc ( 'VARGETG', ncid, z_short_varid, [0], [r], [2], [], 1 ); |
---|
355 | if ( status ~= 0 ) |
---|
356 | msg = sprintf ( '%s: ''%s''\n', mfilename, mexnc ( 'strerror', status ) ); |
---|
357 | error ( msg ); |
---|
358 | end |
---|
359 | |
---|
360 | output_data = output_data'; |
---|
361 | |
---|
362 | d = max(abs(output_data-input_data))'; |
---|
363 | ind = find ( d > eps/2 ); |
---|
364 | if (any(ind)) |
---|
365 | msg = sprintf ( '%s: %s: values written by VARPUTG do not match what was retrieved by VARGETG\n', mfilename, testid ); |
---|
366 | error ( msg ); |
---|
367 | end |
---|
368 | |
---|
369 | |
---|
370 | fprintf ( 1, 'VARPUTG with scaling (please don''t do this, it''s bad) succeeded\n' ); |
---|
371 | fprintf ( 1, 'VARGETG with scaling (please don''t do this, it''s bad) succeeded\n' ); |
---|
372 | |
---|
373 | |
---|
374 | |
---|
375 | |
---|
376 | |
---|
377 | % |
---|
378 | % |
---|
379 | % Test 7: VARPUT1 with a bad ncid |
---|
380 | testid = 'Test 7'; |
---|
381 | input_data = 3.14159; |
---|
382 | status = mexnc ( 'VARPUT1', -100, z_double_varid, [0], input_data ); |
---|
383 | if ( status >= 0 ) |
---|
384 | msg = sprintf ( '%s: %s: VARPUT1 succeeded with a bad ncid\n', mfilename, testid ); |
---|
385 | error ( msg ); |
---|
386 | end |
---|
387 | |
---|
388 | |
---|
389 | % |
---|
390 | % Test 8: VARGET1 with a bad ncid |
---|
391 | testid = 'Test 8'; |
---|
392 | [output_data, status] = mexnc ( 'VARGET1', -100, z_double_varid, [0] ); |
---|
393 | if ( status == 0 ) |
---|
394 | msg = sprintf ( '%s: %s: VARGET1 succeeded with a bad ncid\n', mfilename, testid ); |
---|
395 | error ( msg ); |
---|
396 | end |
---|
397 | |
---|
398 | |
---|
399 | |
---|
400 | % |
---|
401 | % Test 9: VARPUT1 with a bad varid |
---|
402 | testid = 'Test 9'; |
---|
403 | input_data = 3.14159; |
---|
404 | status = mexnc ( 'VARPUT1', ncid, -500, [0], input_data ); |
---|
405 | if ( status == 0 ) |
---|
406 | msg = sprintf ( '%s: %s: VARPUT1 succeeded with a bad varid\n', mfilename, testid ); |
---|
407 | error ( msg ); |
---|
408 | end |
---|
409 | |
---|
410 | |
---|
411 | % |
---|
412 | % VARGET1 with a bad varid |
---|
413 | [output_data, status] = mexnc ( 'VARGET1', ncid, -500, [0] ); |
---|
414 | if ( status >= 0 ) |
---|
415 | msg = sprintf ( '%s: VARGET1 succeeded with a bad varid\n', mfilename ); |
---|
416 | error ( msg ); |
---|
417 | end |
---|
418 | |
---|
419 | |
---|
420 | |
---|
421 | % |
---|
422 | % VARPUT with a bad ncid |
---|
423 | %input_data = [1:1:len_y*len_x] + 3.14159; |
---|
424 | %input_data = reshape ( input_data, len_y, len_x ); |
---|
425 | input_data = rand(100,1); |
---|
426 | status = mexnc ( 'VARPUT', -500, z_short_varid, [0], size(input_data), input_data' ); |
---|
427 | if ( status >= 0 ) |
---|
428 | msg = sprintf ( '%s: VARPUT succeeded with a bad varid\n', mfilename ); |
---|
429 | error ( msg ); |
---|
430 | end |
---|
431 | |
---|
432 | |
---|
433 | % |
---|
434 | % VARGET with a bad ncid |
---|
435 | [output_data, status] = mexnc ( 'VARGET', -500, z_short_varid, [0], size(input_data) ); |
---|
436 | if ( status >= 0 ) |
---|
437 | msg = sprintf ( '%s: VARGET succeeded with a bad varid\n', mfilename ); |
---|
438 | error ( msg ); |
---|
439 | end |
---|
440 | |
---|
441 | |
---|
442 | |
---|
443 | |
---|
444 | % |
---|
445 | % VARPUT with a bad varid |
---|
446 | input_data = rand(100,1); |
---|
447 | status = mexnc ( 'VARPUT', ncid, -500, [0], size(input_data), input_data' ); |
---|
448 | if ( status >= 0 ) |
---|
449 | msg = sprintf ( '%s: VARPUT succeeded with a bad varid\n', mfilename ); |
---|
450 | error ( msg ); |
---|
451 | end |
---|
452 | |
---|
453 | |
---|
454 | % |
---|
455 | % VARGET with a bad varid |
---|
456 | [output_data, status] = mexnc ( 'VARGET', ncid, -500, [0], size(input_data) ); |
---|
457 | if ( status >= 0 ) |
---|
458 | msg = sprintf ( '%s: VARGET succeeded with a bad varid\n', mfilename ); |
---|
459 | error ( msg ); |
---|
460 | end |
---|
461 | |
---|
462 | |
---|
463 | |
---|
464 | |
---|
465 | % |
---|
466 | % VARPUTG with a bad ncid |
---|
467 | %Tinput_data = input_data(1:2:end,1:2:end); |
---|
468 | input_data = rand(100,1); |
---|
469 | [r,c] = size(input_data); |
---|
470 | status = mexnc ( 'VARPUTG', -5, z_short_varid, [0], [r c], [2 2], [], input_data', 1 ); |
---|
471 | if ( status >= 0 ) |
---|
472 | msg = sprintf ( '%s: VARPUTG succeeded with a bad ncid\n', mfilename ); |
---|
473 | error ( msg ); |
---|
474 | end |
---|
475 | |
---|
476 | |
---|
477 | [output_data, status] = mexnc ( 'VARGETG', -5, z_short_varid, [0 0], [r c], [2 2], [], 1 ); |
---|
478 | if ( status >= 0 ) |
---|
479 | msg = sprintf ( '%s: VARGETG succeeded with a bad ncid\n', mfilename ); |
---|
480 | error ( msg ); |
---|
481 | end |
---|
482 | |
---|
483 | |
---|
484 | status = mexnc ( 'VARPUTG', ncid, -5, [0 0], [r c], [2 2], [], input_data', 1 ); |
---|
485 | if ( status >= 0 ) |
---|
486 | msg = sprintf ( '%s: VARPUTG succeeded with a bad varid\n', mfilename ); |
---|
487 | error ( msg ); |
---|
488 | end |
---|
489 | |
---|
490 | |
---|
491 | [output_data, status] = mexnc ( 'VARGETG', ncid, -5, [0 0], [r c], [2 2], [], 1 ); |
---|
492 | if ( status >= 0 ) |
---|
493 | msg = sprintf ( '%s: VARGETG succeeded with a bad varid\n', mfilename ); |
---|
494 | error ( msg ); |
---|
495 | end |
---|
496 | |
---|
497 | |
---|
498 | |
---|
499 | |
---|
500 | % |
---|
501 | % CLOSE |
---|
502 | status = mexnc ( 'close', ncid ); |
---|
503 | if ( status ~= 0 ) |
---|
504 | error ( 'CLOSE failed' ); |
---|
505 | end |
---|
506 | |
---|
507 | |
---|
508 | return |
---|
509 | |
---|
510 | |
---|
511 | |
---|
512 | |
---|
513 | |
---|
514 | |
---|
515 | |
---|