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

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

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


Revision 1.5 - (hide annotations) (download)
Tue Jun 21 21:18:48 2011 UTC (14 years ago) by gforget
Branch: MAIN
Changes since 1.4: +26 -10 lines
- convert2gcmfaces	remove the complicated logic (incl. fileFormat part)
			remove the nFaces argument
			get fileFormat and nFaces from mygrid.
- grid_load		remove the isempty(mygrid) test and load grid each time instead
			remove the rest of the complicated logic at the beginning
			set the list of arguments to dirGrid,nFaces,fileFormat
			add dirGrid,nFaces,fileFormat to mygrid for later use
- rdmds2gcmfaces	remove the complicated logic (incl. fileFormat part)
			remove nFaces argument accordingly
			now all arguments (varargin) are simply passed to rdmds

1 gforget 1.5 function []=grid_load(dirGrid,nFaces,fileFormat);
2     %object: load grid information, convert it to gcmfaces format
3     % and encapsulate it in the global mygrid structure.
4     %inputs: dirGrid is the directory where the grid files (gcm output) can be found.
5     % nFaces is the number of faces in this gcm set-up of current interest.
6     % fileFormat is the file format ('straight','cube','compact')
7    
8     input_list_check('grid_load',nargin);
9 gforget 1.1
10     global mygrid;
11 gforget 1.5 mygrid.dirGrid=dirGrid;
12     mygrid.nFaces=nFaces;
13     mygrid.fileFormat=fileFormat;
14 gforget 1.1
15 gforget 1.5 if ~(nFaces==1&strcmp(fileFormat,'straight'))&...
16     ~(nFaces==6&strcmp(fileFormat,'cube'))&...
17     ~(nFaces==6&strcmp(fileFormat,'compact'))&...
18     ~(nFaces==5&strcmp(fileFormat,'compact'));
19     % if gcmfaces_verbose;
20     % fprintf('\nconvert2gcmfaces.m init: there are several supported file conventions. \n');
21     % fprintf(' By default gcmfaces assumes MITgcm type binary formats as follows: \n')
22     % fprintf(' (1 face) straight global format; (4 or 5 faces) compact global format\n');
23     % fprintf(' (6 faces) cube format with one face after the other. \n');
24     % fprintf(' If this is inadequate, you can change the format below.\n\n');
25     % end;
26     error('non-tested topology/fileFormat');
27 gforget 1.1 end;
28    
29 gforget 1.5 %check for
30 gforget 1.3
31 gforget 1.1 list0={'XC','XG','YC','YG','RAC','RAZ','DXC','DXG','DYC','DYG',...
32 gforget 1.4 'hFacC','hFacS','hFacW','Depth'};
33 gforget 1.1 for iFld=1:length(list0);
34 gforget 1.5 eval(['mygrid.' list0{iFld} '=rdmds2gcmfaces([dirGrid ''' list0{iFld} '*'']);']);
35 gforget 1.1 end;
36    
37 gforget 1.4 list0={'AngleCS','AngleSN'};
38     test0=~isempty(dir([dirGrid 'AngleCS*']));
39     if test0;
40     for iFld=1:length(list0);
41 gforget 1.5 eval(['mygrid.' list0{iFld} '=rdmds2gcmfaces([dirGrid ''' list0{iFld} '*'']);']);
42 gforget 1.4 end;
43     else;
44     warning('\n AngleCS/AngleSN not found; set to 1/0 assuming lat/lon grid.\n');
45     mygrid.AngleCS=mygrid.XC; mygrid.AngleCS(:)=1;
46     mygrid.AngleSN=mygrid.XC; mygrid.AngleSN(:)=0;
47     end;
48    
49 gforget 1.1 list0={'RC','RF','DRC','DRF'};
50     for iFld=1:length(list0);
51 gforget 1.2 eval(['mygrid.' list0{iFld} '=squeeze(rdmds([dirGrid ''' list0{iFld} '*'']));']);
52 gforget 1.1 end;
53    
54     mygrid.hFacCsurf=mygrid.hFacC;
55     for ff=1:mygrid.hFacC.nFaces; mygrid.hFacCsurf{ff}=mygrid.hFacC{ff}(:,:,1); end;
56    
57 gforget 1.2 mskC=mygrid.hFacC; mskC(mskC==0)=NaN; mskC(mskC>0)=1; mygrid.mskC=mskC;
58     mskW=mygrid.hFacW; mskW(mskW==0)=NaN; mskW(mskW>0)=1; mygrid.mskW=mskW;
59     mskS=mygrid.hFacS; mskS(mskS==0)=NaN; mskS(mskS>0)=1; mygrid.mskS=mskS;
60    
61 gforget 1.1

  ViewVC Help
Powered by ViewVC 1.1.22