/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_IO/write2meta.m
ViewVC logotype

Diff of /MITgcm_contrib/gael/matlab_class/gcmfaces_IO/write2meta.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by gforget, Mon Sep 12 21:55:59 2011 UTC revision 1.2 by gforget, Wed Mar 16 15:02:19 2016 UTC
# Line 3  function []=write2meta(myFile,myDim,vara Line 3  function []=write2meta(myFile,myDim,vara
3  %  %
4  %inputs:        myFile is the file name (must finish with '.data')  %inputs:        myFile is the file name (must finish with '.data')
5  %               myDim is the size of a field (2D or 3D integer vector)  %               myDim is the size of a field (2D or 3D integer vector)
6  %(optional)     myPrec is the file myPrecision (32, by default, or 64)  %(optional 1)   myPrec is the file myPrecision (32, by default, or 64)
7    %(optional 2)   fldList is the list of field names (cell array)
8    
9  %precision:  %precision:
10  if nargin>2; myPrec=varargin{1}; else; myPrec=32; end;  if nargin>2; myPrec=varargin{1}; else; myPrec=32; end;
11    if nargin>3; fldList=varargin{2}; else; fldList=[]; end;
12  %number of dimensions  %number of dimensions
13  nDim=length(myDim);  nDim=length(myDim);
14  %number of records:  %number of records:
# Line 32  if nDim>2; fprintf(fid,' %5i, %5i, %5i,\ Line 34  if nDim>2; fprintf(fid,' %5i, %5i, %5i,\
34  fprintf(fid,' ];\n');  fprintf(fid,' ];\n');
35  fprintf(fid,' dataprec = [ ''float%2i'' ];\n',myPrec);  fprintf(fid,' dataprec = [ ''float%2i'' ];\n',myPrec);
36  fprintf(fid,' nrecords = [ %5i ];\n',nRec);  fprintf(fid,' nrecords = [ %5i ];\n',nRec);
37    if ~isempty(fldList);
38      nFlds=length(fldList);
39      fprintf(fid,' nFlds = [   %i ];\n',nFlds);
40      fprintf(fid,' fldList = {\n');
41      txt=' '; for ii=1:length(fldList); txt=[txt '''' fldList{ii} '''' ' ']; end;
42      fprintf(fid,[txt '\n']);
43      fprintf(fid,' };\n');
44    end;
45  %%  %%
46  fclose(fid);  fclose(fid);
47    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.22