function O = PetscOpenFile(filename,rw)
%
  %   O = PetscOpenFile(filename,rw) - opens the binary file (generated by PETSc for reading) or for writing
%
%  This provides an object oriented interface to the Matlab routines fopen(), fread() and fclose()
%  allowing PETSc  Matlab utilities like PetscBinaryRead.m to work cleanly with either binary
%  files or sockets
%
if nargin == 1
  rw = 'r';
end
S = struct('fd', fopen(filename,rw,'ieee-be'));
O = class(S,'PetscOpenFile');

