function test_attinq ( ncfile )
% TEST_ATTINQ
%



[ncid, status] = mexnc ( 'create', ncfile, nc_clobber_mode );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end


%
% DIMDEF
[xdimid, status] = mexnc ( 'def_dim', ncid, 'x', 20 );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end

[varid, status] = mexnc ( 'def_var', ncid, 'x', nc_double, 1, xdimid );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end

%
% Double test
input_data = 3.14159;
status = mexnc ( 'ATTPUT', ncid, varid, 'test_double', nc_double, 1, input_data );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end
[status] = mexnc ( 'end_def', ncid );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end
status = mexnc ( 'sync', ncid );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end



[datatype, len, status] = mexnc('ATTINQ', ncid, varid, 'test_double');
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end
if ( datatype ~= 6 )
	err_msg = sprintf ( '%s:  returned datatype was not NC_DOUBLE, ATTINQ failed\n', mfilename );
	error ( err_msg );
end
if ( len ~= 1 )
	err_msg = sprintf ( '%s:  returned length was not 1, ATTINQ failed\n', mfilename );
	error ( err_msg );
end


%
% test a bad ncid
[datatype, len, status] = mexnc('ATTINQ', -1, varid, 'test_double');
if ( status >= 0 )
	err_msg = sprintf ( '%s:  ATTINQ succeeded on bad ncid\n', mfilename );
	error ( err_msg );
end


%
% test a bad varid
[datatype, len, status] = mexnc('ATTINQ', ncid, -5, 'test_double');
if ( status >= 0 )
	err_msg = sprintf ( '%s:  ATTINQ succeeded on bad varid\n', mfilename );
	error ( err_msg );
end



status = mexnc ( 'close', ncid );
if ( status < 0 )
	ncerr = mexnc ( 'strerror', status );
	err_msg = sprintf ( '%s:  ''%s''\n', mfilename, ncerr );
	error ( err_msg );
end

fprintf ( 1, 'ATTINQ succeeded.\n' );


return
















