 function [t,mx,my,meqn,data] = readq2d(n,mgrid)

 if n<10 & n>=0
   fname = [ '../../../sphere_shllw/2d/no_rotation/output/fgrid',num2str(mgrid),'.00',num2str(n)];
 elseif n<100  & n>=10
   fname = [ '../../../sphere_shllw/2d/no_rotation/output/fgrid',num2str(mgrid),'.0',num2str(n)];
 elseif n<1000  & n>=100
   fname = [ '../../../sphere_shllw/2d/no_rotation/output/fgrid',num2str(mgrid),'.',num2str(n)];
 else
   disp(['ERROR: n is too large, n = ',num2str(n)]);
 end
 fid = fopen(fname);
 [info,count] = fscanf(fid,'%g %d %d %d',4);
 t = info(1);
 mx = info(2);
 my = info(3);
 meqn = info(4);
 data = fscanf(fid,'%g',[meqn,inf]);
 data = data';
 status = fclose(fid);
