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

Contents 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.5 - (show annotations) (download)
Mon Jul 28 20:54:11 2014 UTC (10 years, 11 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.4: +1 -1 lines
- fix windows PC compatibility (contributed by D.Spiegel).

1 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
7 data=rdmds2gcmfaces(varargin{:});
8
9 tmp1=dir([varargin{1} '*.meta']); tmp1=tmp1(1).name;
10 tmp2=strfind(varargin{1},filesep);
11 if ~isempty(tmp2); tmp2=tmp2(end); else; tmp2=0; end;
12 tmp1=[varargin{1}(1:tmp2) tmp1]; fid=fopen(tmp1);
13 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 % fprintf([deblank(meta.fldList{ii}) ' loaded into workspace \n']);
40 end;
41

  ViewVC Help
Powered by ViewVC 1.1.22