/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_global.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_global.m

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


Revision 1.1 - (show annotations) (download)
Fri Aug 5 22:00:03 2011 UTC (13 years, 11 months ago) by gforget
Branch: MAIN
- retired function:	gcmfaces_path.m
- added function:	gcmfaces_global.m
- replace gcmfaces_path and 'global mygrid' calls with gcmfaces_global calls
- revised global variables (verbose, lesstest, lessplot -- in gcmfaces_init e.g.)
- added basic_diags_compute_v3_or_v4 to gcmfaces_init (when not lesstest)

1 function []=gcmfaces_global(varargin);
2 %object: take care of path and global variables (mygrid and myenv),
3 % and sends global variables to caller routine workspace
4 %optional inputs: optional paramaters take the following form
5 % {'name',param1,param2,...}. Are currently active:
6 % {'resetGrid',resetGrid} states that mygrid will be cleared
7 % and re-loaded interactively (1), or not (0;default).
8 % {'listVars',varName1,varName2} is a list of variables
9 % to check is in mygrid (empty by default).
10 %notes: - in any call, if this has not yet been done,
11 % this routine also adds gcmfaces subdirectories
12 % to the matlab path, and it defines myenv.
13 % - calls to this routine will eventually replace
14 % both gcmfaces_path and 'global mygrid' calls.
15
16
17 %set optional paramaters to default values
18 resetGrid=0; listVars={};
19 %set more optional paramaters to user defined values
20 for ii=1:nargin;
21 if ~iscell(varargin{ii});
22 warning('inputCheck:gcmfaces_global_1',...
23 ['As of june 2011, gcmfaces_global expects \n'...
24 ' its optional parameters as cell arrays. \n'...
25 ' Argument no. ' num2str(ii+1) ' was ignored \n'...
26 ' Type ''help gcmfaces_global'' for details.']);
27 elseif ~ischar(varargin{ii}{1});
28 warning('inputCheck:gcmfaces_global_2',...
29 ['As of june 2011, gcmfaces_global expects \n'...
30 ' its optional parameters cell arrays \n'...
31 ' to start with character string. \n'...
32 ' Argument no. ' num2str(ii+1) ' was ignored \n'...
33 ' Type ''help gcmfaces_global'' for details.']);
34 else;
35 if strcmp(varargin{ii}{1},'listVars');
36 eval([varargin{ii}{1} '={varargin{ii}{2:end}};']);
37 elseif strcmp(varargin{ii}{1},'resetGrid');
38 eval([varargin{ii}{1} '=varargin{ii}{2};']);
39 else;
40 warning('inputCheck:gcmfaces_global_3',...
41 ['unknown option ''' varargin{ii}{1} ''' was ignored']);
42 end;
43 end;
44 end;
45
46
47 %get/define global variables:
48 global myenv mygrid;
49
50 %take care of path:
51 test0=which('convert2gcmfaces.m');
52 if isempty(test0);
53 test0=which('gcmfaces_global.m'); ii=strfind(test0,'/');
54 mydir=test0(1:ii(end));
55 %
56 eval(['addpath ' mydir ';']);
57 eval(['addpath ' mydir '/gcmfaces_IO/;']);
58 eval(['addpath ' mydir 'gcmfaces_convert/;']);
59 eval(['addpath ' mydir 'gcmfaces_exch/;']);
60 eval(['addpath ' mydir 'gcmfaces_maps/;']);
61 eval(['addpath ' mydir '/gcmfaces_misc/;']);
62 eval(['addpath ' mydir '/gcmfaces_calc/;']);
63 eval(['addpath ' mydir '/gcmfaces_smooth/;']);
64 eval(['addpath ' mydir 'ecco_v4/;']);
65 eval(['addpath ' mydir 'sample_analysis/;']);
66 eval(['addpath ' mydir 'sample_processing/;']);
67 eval(['addpath ' mydir 'gcmfaces_devel/;']);
68 end;
69
70 %environment variables:
71 if isempty(myenv);
72 test0=which('gcmfaces_global.m'); ii=strfind(test0,'/');
73 myenv.gcmfaces_dir=test0(1:ii(end));
74 myenv.verbose=0;
75 myenv.lessplot=0;
76 myenv.lesstest=0;
77 myenv.useNativeMatlabNetcdf = ~isempty(which('netcdf.open'));
78 %... check m_map and netcdf
79 end;
80
81 %load grid variables:
82 if resetGrid==1;
83 mygrid=[];
84 dirGrid=input('grid directory name?\n','s');
85 nFaces=input('number of grid faces?\n');
86 fileFormat=input('file format?\n[''native'',''straight'',''cube'' or ''compact'']\n','s');
87 if strcmp(fileFormat,'native');
88 grid_load_native(dirGrid,nFaces);
89 else;
90 grid_load(dirGrid,nFaces,fileFormat);
91 end;
92 end;
93
94 %check available mygrid variables:
95 for ii=1:length(listVars);
96 if ~isfield(mygrid,listVars{ii});
97 error(['mygrid does not include ' listVars{ii}]);
98 end;
99 end;
100
101 %send to workspace:
102 evalin('caller','global mygrid myenv');
103

  ViewVC Help
Powered by ViewVC 1.1.22