function []=write_generic_meta(dirOut,myDim,prec);

%Write a generic metafile 
%Input
%       dirOut  directory where .meta file willbe written
%       myDim   vector of dimensions (e.g. [90 90 50])
%       prec    precission of the data either as 'real*n' or 'float*xx' or n or xx, where n=4/8 and xx=32/64

nDim = max(size(myDim));
if(nDim==3 & myDim(3)==1); myDim=myDim(1:2); end;
if(nDim==1); myDim=[1 1 myDim]; end;
nDim = max(size(myDim));

nRec = 1;
if(isa(prec,'char'));
   if(strcmp(prec,'real*4')|strcmp(prec,'float32'));
      myPrec = 32; fPrec = '4';
   elseif(strcmp(prec,'real*8')|strcmp(prec,'float64'));
      myPrec = 64; fPrec = '8';
   else;
      disp('Data precission not recognized (real*4 or real*8 or float32 or float64 or 4 or 8 or 32 or 64) -> No meta file was written');
      return;
   end;
elseif(isa(prec,'double'));
   if(prec==4|prec==32);
      myPrec = 32; fPrec = '4';
   elseif(prec==8|prec==64);
      myPrec = 64; fPrec = '8';
   else;
      disp('Data precission not recognized (real*4 or real*8 or float32 or float64 or 4 or 8 or 32 or 64) -> No meta file was written');
      return;
   end;
end;

myFile = [dirOut  'generic_' num2str(nDim) 'd_real' fPrec '.meta'];

fid=fopen(myFile,'wt');
%%
fprintf(fid,' nDims = [   %i ];\n',min(nDim,3));
fprintf(fid,' dimList = [\n');
fprintf(fid,' %5i, %5i, %5i,\n',myDim(1),1,myDim(1));
fprintf(fid,' %5i, %5i, %5i,\n',myDim(2),1,myDim(2));
if nDim>2; fprintf(fid,' %5i, %5i, %5i,\n',myDim(3),1,myDim(3)); end;
fprintf(fid,' ];\n');
fprintf(fid,' dataprec = [ ''float%2i'' ];\n',myPrec);
fprintf(fid,' nrecords = [ %5i ];\n',nRec);
%%
fclose(fid);

