function test_varmget ( ncfile ) % % ok, first create this baby. [ncid, status] = mexnc ( 'create', ncfile, 'write' ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''create'' failed on %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end [ydimid, status] = mexnc ( 'def_dim', ncid, 'y', 6 ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''def_dim'' failed on dim y, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end [xdimid, status] = mexnc ( 'def_dim', ncid, 'x', 4 ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''def_dim'' failed on dim x, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end [varid, status] = mexnc ( 'def_var', ncid, 'rh', 'NC_FLOAT', 2, [ydimid xdimid] ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''def_var'' failed on var rh, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end status = mexnc ( 'enddef', ncid ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''enddef'' failed on file %s, error message '' %s ''\n', mfilename, ncerr_msg ); error ( msg ); end data = [1:24]'; data2 = reshape ( data, 6, 4 ); status = mexnc ( 'put_var_double', ncid, varid, data2' ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''put_var_double'' failed on var rh, file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end status = mexnc ( 'sync', ncid ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''sync'' failed on file %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end status = mexnc ( 'close', ncid ); if ( status ~= 0 ) ncerr_msg = mexnc ( 'strerror', status ); msg = sprintf ( '%s: ''close'' failed on %s, error message '' %s ''\n', mfilename, ncfile, ncerr_msg ); error ( msg ); end return