/[MITgcm]/MITgcm/utils/matlab/rdmds.m
ViewVC logotype

Diff of /MITgcm/utils/matlab/rdmds.m

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

revision 1.21 by jmc, Sat Feb 17 23:49:43 2007 UTC revision 1.22 by jmc, Tue Mar 20 22:23:19 2007 UTC
# Line 157  end Line 157  end
157  for j=1:size(allfiles,1);  for j=1:size(allfiles,1);
158    
159  % Read meta- and data-file  % Read meta- and data-file
160  [A,N,M] = localrdmds([Dir allfiles(j).name],ieee,recnum);  [A,N,M,mG] = localrdmds([Dir allfiles(j).name],ieee,recnum);
161    
162  %- Merge local Meta file content (M) to MM string:  %- Merge local Meta file content (M) to MM string:
163  if j > 0, %- to comment out this block: "if j < 0" (since j is always > 0)  if j > 0, %- to comment out this block: "if j < 0" (since j is always > 0)
# Line 191  bdims=N(1,:); Line 191  bdims=N(1,:);
191  r0=N(2,:);  r0=N(2,:);
192  rN=N(3,:);  rN=N(3,:);
193  ndims=prod(size(bdims));  ndims=prod(size(bdims));
194  if     (ndims == 1)  if j==1 & iter==1, AA=zeros([bdims size(iters,2)]); end
195   AA(r0(1):rN(1),iter)=A;  if mG(1)==0 & mG(2)==1,
196  elseif (ndims == 2)    if     (ndims == 1)
197   AA(r0(1):rN(1),r0(2):rN(2),iter)=A;     AA(r0(1):rN(1),iter)=A;
198  elseif (ndims == 3)    elseif (ndims == 2)
199   AA(r0(1):rN(1),r0(2):rN(2),r0(3):rN(3),iter)=A;     AA(r0(1):rN(1),r0(2):rN(2),iter)=A;
200  elseif (ndims == 4)    elseif (ndims == 3)
201   AA(r0(1):rN(1),r0(2):rN(2),r0(3):rN(3),r0(4):rN(4),iter)=A;     AA(r0(1):rN(1),r0(2):rN(2),r0(3):rN(3),iter)=A;
202  elseif (ndims == 5)    elseif (ndims == 4)
203   AA(r0(1):rN(1),r0(2):rN(2),r0(3):rN(3),r0(4):rN(4),r0(5):rN(5),iter)=A;     AA(r0(1):rN(1),r0(2):rN(2),r0(3):rN(3),r0(4):rN(4),iter)=A;
204      elseif (ndims == 5)
205       AA(r0(1):rN(1),r0(2):rN(2),r0(3):rN(3),r0(4):rN(4),r0(5):rN(5),iter)=A;
206      else
207       error('Dimension of data set is larger than currently coded. Sorry!')
208      end
209    elseif     (ndims == 1)
210       AA(r0(1):rN(1),iter)=A;
211  else  else
212   error('Dimension of data set is larger than currently coded. Sorry!')  %- to debug: do simple stransfert (with a loop on 2nd index);
213    %  will need to change this later, to improve efficiency:
214     for i=0:rN(2)-r0(2),
215      if (ndims == 2)
216       AA(r0(1)+i*mG(1):rN(1)+i*mG(1),r0(2)+i*mG(2),iter)=A(:,1+i);
217      elseif (ndims == 3)
218       AA(r0(1)+i*mG(1):rN(1)+i*mG(1),r0(2)+i*mG(2), ...
219                                        r0(3):rN(3),iter)=A(:,1+i,:);
220      elseif (ndims == 4)
221       AA(r0(1)+i*mG(1):rN(1)+i*mG(1),r0(2)+i*mG(2), ...
222                            r0(3):rN(3),r0(4):rN(4),iter)=A(:,1+i,:,:);
223      elseif (ndims == 5)
224       AA(r0(1)+i*mG(1):rN(1)+i*mG(1),r0(2)+i*mG(2), ...
225                r0(3):rN(3),r0(4):rN(4),r0(5):rN(5),iter)=A(:,1+i,:,:,:);
226      else
227       error('Dimension of data set is larger than currently coded. Sorry!')
228      end
229     end
230  end  end
231    
232  end % files  end % files
# Line 210  end % iterations Line 234  end % iterations
234    
235  %-------------------------------------------------------------------------------  %-------------------------------------------------------------------------------
236    
237  function [A,N,M] = localrdmds(fname,ieee,recnum)  function [A,N,M,map2glob] = localrdmds(fname,ieee,recnum)
238    
239  mname=strrep(fname,' ','');  mname=strrep(fname,' ','');
240  dname=strrep(mname,'.meta','.data');  dname=strrep(mname,'.meta','.data');
241    
242    %- set default mapping from tile to global file:
243    map2glob=[0 1];
244    
245  % Read and interpret Meta file  % Read and interpret Meta file
246  fid = fopen(mname,'r');  fid = fopen(mname,'r');
247  if (fid == -1)  if (fid == -1)
# Line 239  while keepgoing > 0, Line 266  while keepgoing > 0,
266    line=[line,' //']; ind=findstr(line,'//'); line=line(1:ind(1)-1);    line=[line,' //']; ind=findstr(line,'//'); line=line(1:ind(1)-1);
267  % Add to total string (without starting & ending blanks)  % Add to total string (without starting & ending blanks)
268    while line(1:1) == ' ', line=line(2:end); end    while line(1:1) == ' ', line=line(2:end); end
269    allstr=[allstr,deblank(line),' '];    if strncmp(line,'map2glob',8), eval(line);
270  % allstr=[allstr line];    else allstr=[allstr,deblank(line),' '];
271      end
272   end   end
273  end  end
274    

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.22