function test_create ( ncfile )
% Tests run are open with
%    nc_clobber_mode
%    nc_noclobber_mode
%    nc_share_mode
%    nc_64bit_offset_mode
%

%
% clobber mode
[ncid, status] = mexnc ( 'create', ncfile, nc_clobber_mode );
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
status = mexnc ( 'close', ncid );
if ( status < 0 )
	error ( 'CLOSE failed with nc_clobber_mode' );
end
fprintf ( 1, 'CREATE succeeded with nc_clobber_mode\n' );

%
% clobber | share
mode = bitor ( nc_clobber_mode, nc_share_mode );
[ncid, status] = mexnc ( 'create', ncfile, mode );
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
status = mexnc ( 'close', ncid );
if ( status < 0 )
	error ( 'CLOSE failed with nc_clobber_mode | nc_share_mode' );
end
fprintf ( 1, 'CREATE succeeded with nc_clobber_mode | nc_share_mode\n' );

%
% clobber | share | 64bit_offset
mode = bitor ( nc_clobber_mode, nc_share_mode );
mode = bitor ( mode, nc_64bit_offset_mode );
[ncid, status] = mexnc ( 'create', ncfile, mode );
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
status = mexnc ( 'close', ncid );
if ( status < 0 )
	error ( 'CLOSE failed with nc_clobber_mode | nc_share_mode | nc_64bit_offset_mode' );
end
fprintf ( 1, 'CREATE succeeded with nc_clobber_mode | nc_share_mode | nc_64bit_offset_mode\n' );


%
% share mode.  Should also clobber it.
[ncid, status] = mexnc ( 'create', ncfile, nc_share_mode );
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
status = mexnc ( 'close', ncid );
if ( status < 0 )
	error ( 'CLOSE failed with nc_share_mode' );
end
fprintf ( 1, 'CREATE succeeded with nc_share_mode\n' );


%
% share | 64bit_offset
mode = bitor ( nc_share_mode, nc_64bit_offset_mode );
[ncid, status] = mexnc ( 'create', ncfile, mode );
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
status = mexnc ( 'close', ncid );
if ( status < 0 )
	error ( 'CLOSE failed with nc_share_mode | nc_64bit_offset_mode' );
end
fprintf ( 1, 'CREATE succeeded with nc_share_mode | nc_64bit_offset_mode\n' );



%
% 64bit_offset mode.  Should also clobber it.
[ncid, status] = mexnc ( 'create', ncfile, nc_64bit_offset_mode );
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
status = mexnc ( 'close', ncid );
if ( status < 0 )
	error ( 'CLOSE failed with nc_64bit_offset_mode' );
end
fprintf ( 1, 'CREATE succeeded with nc_64bit_offset_mode\n' );


%
% noclobber mode.  Should not succeed.
[ncid, status] = mexnc ( 'create', ncfile, nc_noclobber_mode );
if ( status == 0 )
	msg = sprintf ( '%s:  ''create'' succeeded on nc_noclobber_mode, should have failed\n', mfilename );
	error ( msg );
end
fprintf ( 1, 'CREATE succeeded with nc_noclobber_mode\n' );







return
