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

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

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


Revision 1.12 - (hide annotations) (download)
Mon Apr 2 17:44:59 2018 UTC (7 years, 3 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66o, HEAD
Changes since 1.11: +5 -0 lines
- retire old documentation; gcmfaces.pdf now merely points to readthedocs version.
- add first deprecation warning in gcmfaces_global.m; point to readthedocs.

1 gforget 1.1 function []=gcmfaces_global(varargin);
2 gforget 1.6 %object: take care of path and global variables (mygrid and myenv),
3 gforget 1.1 % 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 gforget 1.6 % {'resetGrid',resetGrid} states that mygrid will be cleared
7 gforget 1.1 % 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 gforget 1.6 %notes: - in any call, if this has not yet been done,
11     % this routine also adds gcmfaces subdirectories
12 gforget 1.1 % to the matlab path, and it defines myenv.
13 gforget 1.6 % - calls to this routine will eventually replace
14 gforget 1.1 % both gcmfaces_path and 'global mygrid' calls.
15    
16 gforget 1.12 warning(sprintf(['This version of gcmfaces, from an old CVS server, is \n' ...
17     ' now considered deprecated. Future devopment will proceed, instead, \n' ...
18     ' via GitHub. For up to date documentation, please refer to \n' ...
19     ' http://gcmfaces.readthedocs.io/en/latest/']));
20    
21 gforget 1.1 %set optional paramaters to default values
22 gforget 1.6 resetGrid=0; listVars={};
23 gforget 1.1 %set more optional paramaters to user defined values
24     for ii=1:nargin;
25     if ~iscell(varargin{ii});
26     warning('inputCheck:gcmfaces_global_1',...
27     ['As of june 2011, gcmfaces_global expects \n'...
28     ' its optional parameters as cell arrays. \n'...
29     ' Argument no. ' num2str(ii+1) ' was ignored \n'...
30     ' Type ''help gcmfaces_global'' for details.']);
31     elseif ~ischar(varargin{ii}{1});
32     warning('inputCheck:gcmfaces_global_2',...
33     ['As of june 2011, gcmfaces_global expects \n'...
34     ' its optional parameters cell arrays \n'...
35     ' to start with character string. \n'...
36     ' Argument no. ' num2str(ii+1) ' was ignored \n'...
37     ' Type ''help gcmfaces_global'' for details.']);
38     else;
39     if strcmp(varargin{ii}{1},'listVars');
40 gforget 1.6 eval([varargin{ii}{1} '={varargin{ii}{2:end}};']);
41 gforget 1.1 elseif strcmp(varargin{ii}{1},'resetGrid');
42     eval([varargin{ii}{1} '=varargin{ii}{2};']);
43     else;
44     warning('inputCheck:gcmfaces_global_3',...
45     ['unknown option ''' varargin{ii}{1} ''' was ignored']);
46     end;
47     end;
48     end;
49    
50    
51     %get/define global variables:
52     global myenv mygrid;
53    
54     %take care of path:
55     test0=which('convert2gcmfaces.m');
56     if isempty(test0);
57 gforget 1.3 test0=which('gcmfaces_global.m'); ii=strfind(test0,filesep);
58 gforget 1.1 mydir=test0(1:ii(end));
59     %
60     eval(['addpath ' mydir ';']);
61     eval(['addpath ' mydir '/gcmfaces_IO/;']);
62     eval(['addpath ' mydir 'gcmfaces_convert/;']);
63     eval(['addpath ' mydir 'gcmfaces_exch/;']);
64     eval(['addpath ' mydir 'gcmfaces_maps/;']);
65     eval(['addpath ' mydir '/gcmfaces_misc/;']);
66     eval(['addpath ' mydir '/gcmfaces_calc/;']);
67     eval(['addpath ' mydir '/gcmfaces_smooth/;']);
68     eval(['addpath ' mydir 'ecco_v4/;']);
69     eval(['addpath ' mydir 'sample_analysis/;']);
70     eval(['addpath ' mydir 'sample_processing/;']);
71 gforget 1.2 eval(['addpath ' mydir 'gcmfaces_diags/;']);
72 gforget 1.1 eval(['addpath ' mydir 'gcmfaces_devel/;']);
73     end;
74    
75     %environment variables:
76     if isempty(myenv);
77 gforget 1.3 test0=which('gcmfaces_global.m'); ii=strfind(test0,filesep);
78 gforget 1.1 myenv.gcmfaces_dir=test0(1:ii(end));
79     myenv.verbose=0;
80     myenv.lessplot=0;
81     myenv.lesstest=0;
82     myenv.useNativeMatlabNetcdf = ~isempty(which('netcdf.open'));
83 gforget 1.5 myenv.issueWarnings=1;
84 gforget 1.1 %... check m_map and netcdf
85     end;
86    
87     %load grid variables:
88     if resetGrid==1;
89     mygrid=[];
90     dirGrid=input('grid directory name?\n','s');
91     nFaces=input('number of grid faces?\n');
92     fileFormat=input('file format?\n[''native'',''straight'',''cube'' or ''compact'']\n','s');
93     if strcmp(fileFormat,'native');
94     grid_load_native(dirGrid,nFaces);
95     else;
96     grid_load(dirGrid,nFaces,fileFormat);
97     end;
98     end;
99    
100     %check available mygrid variables:
101     for ii=1:length(listVars);
102 gforget 1.6 if ~isfield(mygrid,listVars{ii});
103     error(['mygrid does not include ' listVars{ii}]);
104 gforget 1.1 end;
105     end;
106    
107 gforget 1.4 %issue warning if mygrid is empty:
108 gforget 1.6 test0=~isfield(mygrid,'XC');
109     [ST,I]=dbstack; ST={ST(:).name}';
110     test1=1;
111 gforget 1.9 list1={'grid_load','startup','example_display','example_IO',...
112 gforget 1.6 'example_remap','example_griddata','example_interp','example_faces2latlon2faces',...
113 gforget 1.7 'example_bin_average','example_transports','example_budget',...
114 gforget 1.10 'profiles_process_init','gcmfaces_init','diags_pre_process','diags_grid'};
115 gforget 1.11 list1={list1{:},'profiles_prep_main','profiles_prep_select','MITprof_demo'};
116 gforget 1.6 for jj=1:length(list1);
117     test1=test1&isempty(find(strcmp(ST,list1{jj})));
118     end;
119     if test0&test1&myenv.issueWarnings;
120 gforget 1.8 warning('mygrid has not yet been loaded to memory');
121 gforget 1.4 end;
122    
123 gforget 1.1 %send to workspace:
124     evalin('caller','global mygrid myenv');
125    

  ViewVC Help
Powered by ViewVC 1.1.22