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

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_IO/rdmds2workspace.m

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


Revision 1.1 - (hide annotations) (download)
Wed Dec 22 01:04:08 2010 UTC (14 years, 6 months ago) by gforget
Branch: MAIN
- rdmds2workspace.m	load all fields from rdmds file, assuming
			that names are incldued in the meta file
- read2memory.m write2file.m	basic binary read/write shortcuts

1 gforget 1.1 function []=rdmds2workspace(fileName,varargin);
2    
3     data=rdmds(fileName,varargin{:});
4    
5     tmp1=dir([fileName '*.meta']); tmp1=tmp1(1).name;
6     tmp2=strfind(fileName,'/'); tmp2=tmp2(end);
7     tmp1=[fileName(1:tmp2) tmp1]; fid=fopen(tmp1);
8     while 1;
9     tline = fgetl(fid);
10     if ~ischar(tline), break, end
11     if isempty(whos('tmp3')); tmp3=tline; else; tmp3=[tmp3 ' ' tline]; end;
12     end
13     fclose(fid);
14    
15     tmp1=who;%list current workspace variables
16     eval(tmp3);%add meta variables to workspace
17     tmp3=who;%also list meta variables
18     for ii=1:length(tmp3);%store in structure (meta)
19     if sum(strcmp(tmp1,tmp3(ii)))==0;
20     eval(['meta.' tmp3{ii} '=' tmp3{ii} ';']);
21     end;
22     end;
23    
24     %export the various fields to caller workspace:
25     assignin('caller','meta',meta);
26    
27     %export the various fields to caller workspace:
28     for ii=1:meta.nFlds;
29     if meta.nDims==3;
30     assignin('caller',deblank(meta.fldList{ii}),squeeze(data(:,:,:,ii,:)));
31     else;
32     assignin('caller',deblank(meta.fldList{ii}),squeeze(data(:,:,ii,:)));
33     end;
34     end;
35    

  ViewVC Help
Powered by ViewVC 1.1.22