/[MITgcm]/MITgcm_contrib/enderton/Diagnostics/DiagLoadMonitor.m
ViewVC logotype

Annotation of /MITgcm_contrib/enderton/Diagnostics/DiagLoadMonitor.m

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


Revision 1.3 - (hide annotations) (download)
Mon Sep 5 18:50:15 2005 UTC (19 years, 10 months ago) by enderton
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +8 -8 lines
A few minor changes and comments added.

1 enderton 1.1 function [data,time] = ...
2     DiagLoadMonitor(fln,mnchandle,dad,itr,tst,SecPerYear,DiagDebug);
3    
4     % Read in files names.
5     %files = dir([dad,'/',mnchandle]);
6     filesin=ls([dad,'/',mnchandle]);
7     index=1;
8     while ~isempty(filesin)
9     [token,filesin] = strtok(filesin);
10     if ~isempty(filesin)
11     files(index).name=token; index=index+1;
12     end
13     end
14    
15    
16     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17     % Read in data %
18     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19    
20     % Initialize result arrays.
21     if isempty(itr),
22     time=[];
23     data=[];
24     else
25     time=NaN.*zeros(size(itr));
26     data=NaN.*zeros(size(itr));
27     end
28    
29     for ifile = 1:length(files)
30    
31     % Open monitor file.
32     if DiagDebug, disp(['Entering file: ',files(ifile).name]); end
33     nc=netcdf(files(ifile).name,'read');
34    
35     % Read time and data information.
36 enderton 1.3 nciter=nc{'T'}; if isempty(nciter), nciter=nc{'iter'}.*tst; end
37 enderton 1.1 ncdata=nc{fln};
38     if isempty(nciter), error('Monitor time axis not found!'); end
39     if isempty(ncdata), error(['Monitor field not found: ',fln]); end
40    
41     % Load desired indecies.
42     if isempty(itr)
43     if isempty(time),
44     time=nciter(:);
45     data=ncdata(:);
46     else
47     index=find(~ismember(nciter(:),time));
48 enderton 1.3 if ~isempty(index)
49     nciter=nciter(index); time=[time;NaN;nciter];
50     ncdata=ncdata(index); data=[data;NaN;ncdata];
51 enderton 1.2 end
52 enderton 1.1 end
53     else
54     [test,loc]=ismember(itr,nciter(:));
55     index=find(test);
56     if ~isempty(index)
57     time(index)=nciter(loc(index));
58     data(index)=ncdata(loc(index));
59     end
60     end
61    
62     close(nc);
63     end
64    
65     % Check for missing indecies.
66 enderton 1.3 % if ~isempty(find(isnan(time))) || ~isempty(find(isnan(data)))
67     % error('Missing monitor data for specified indecies!');
68     % end
69 enderton 1.1
70 enderton 1.3 time=time./SecPerYear;

  ViewVC Help
Powered by ViewVC 1.1.22