/[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.3 - (hide annotations) (download)
Wed Jun 22 14:35:42 2011 UTC (14 years ago) by gforget
Branch: MAIN
Changes since 1.2: +11 -5 lines
- clean up and document grid_load_native.m and rdmds2workspace.m.
- move grid_load_90x50.m grid_load_96x23.m grid_load_occa.m to gcmfaces_legacy.

1 gforget 1.3 function []=rdmds2workspace(varargin);
2     %object: read with rmds2gcmfaces then pass variables to workspace
3     %input: varargin are the options to pass to rdmds (type help rdmds)
4     %output: no output needs to be specified
5     %
6 gforget 1.1
7 gforget 1.3 data=rdmds2gcmfaces(varargin{:});
8 gforget 1.1
9 gforget 1.3 tmp1=dir([varargin{1} '*.meta']); tmp1=tmp1(1).name;
10     tmp2=strfind(varargin{1},'/');
11     if ~isempty(tmp2); tmp2=tmp2(end); else; tmp2=0; end;
12     tmp1=[varargin{1}(1:tmp2) tmp1]; fid=fopen(tmp1);
13 gforget 1.1 while 1;
14     tline = fgetl(fid);
15     if ~ischar(tline), break, end
16     if isempty(whos('tmp3')); tmp3=tline; else; tmp3=[tmp3 ' ' tline]; end;
17     end
18     fclose(fid);
19    
20     tmp1=who;%list current workspace variables
21     eval(tmp3);%add meta variables to workspace
22     tmp3=who;%also list meta variables
23     for ii=1:length(tmp3);%store in structure (meta)
24     if sum(strcmp(tmp1,tmp3(ii)))==0;
25     eval(['meta.' tmp3{ii} '=' tmp3{ii} ';']);
26     end;
27     end;
28    
29     %export the various fields to caller workspace:
30     assignin('caller','meta',meta);
31    
32     %export the various fields to caller workspace:
33     for ii=1:meta.nFlds;
34     if meta.nDims==3;
35     assignin('caller',deblank(meta.fldList{ii}),squeeze(data(:,:,:,ii,:)));
36     else;
37     assignin('caller',deblank(meta.fldList{ii}),squeeze(data(:,:,ii,:)));
38     end;
39 gforget 1.3 fprintf([deblank(meta.fldList{ii}) ' loaded into workspace \n']);
40 gforget 1.1 end;
41    

  ViewVC Help
Powered by ViewVC 1.1.22