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

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

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

revision 1.3 by gforget, Mon Jul 28 20:54:09 2014 UTC revision 1.8 by gforget, Wed Jan 13 16:59:19 2016 UTC
# Line 1  Line 1 
1  function []=gcmfaces_global(varargin);  function []=gcmfaces_global(varargin);
2  %object:    take care of path and global variables (mygrid and myenv),  %object:    take care of path and global variables (mygrid and myenv),
3  %           and sends global variables to caller routine workspace  %           and sends global variables to caller routine workspace
4  %optional inputs: optional paramaters take the following form  %optional inputs: optional paramaters take the following form
5  %           {'name',param1,param2,...}. Are currently active:  %           {'name',param1,param2,...}. Are currently active:
6  %               {'resetGrid',resetGrid} states that mygrid will be cleared  %               {'resetGrid',resetGrid} states that mygrid will be cleared
7  %                   and re-loaded interactively (1), or not (0;default).  %                   and re-loaded interactively (1), or not (0;default).
8  %               {'listVars',varName1,varName2} is a list of variables  %               {'listVars',varName1,varName2} is a list of variables
9  %                   to check is in mygrid (empty by default).  %                   to check is in mygrid (empty by default).
10  %notes:     - in any call, if this has not yet been done,  %notes:     - in any call, if this has not yet been done,
11  %           this routine also adds gcmfaces subdirectories  %           this routine also adds gcmfaces subdirectories
12  %           to the matlab path, and it defines myenv.  %           to the matlab path, and it defines myenv.
13  %           - calls to this routine will eventually replace  %           - calls to this routine will eventually replace
14  %           both gcmfaces_path and 'global mygrid' calls.  %           both gcmfaces_path and 'global mygrid' calls.
15    
16  %set optional paramaters to default values  %set optional paramaters to default values
17  resetGrid=0; listVars={};  resetGrid=0; listVars={};
18  %set more optional paramaters to user defined values  %set more optional paramaters to user defined values
19  for ii=1:nargin;  for ii=1:nargin;
20      if ~iscell(varargin{ii});      if ~iscell(varargin{ii});
# Line 32  for ii=1:nargin; Line 32  for ii=1:nargin;
32              '         Type ''help gcmfaces_global'' for details.']);              '         Type ''help gcmfaces_global'' for details.']);
33      else;      else;
34          if strcmp(varargin{ii}{1},'listVars');          if strcmp(varargin{ii}{1},'listVars');
35              eval([varargin{ii}{1} '={varargin{ii}{2:end}};']);                          eval([varargin{ii}{1} '={varargin{ii}{2:end}};']);
36          elseif strcmp(varargin{ii}{1},'resetGrid');          elseif strcmp(varargin{ii}{1},'resetGrid');
37              eval([varargin{ii}{1} '=varargin{ii}{2};']);              eval([varargin{ii}{1} '=varargin{ii}{2};']);
38          else;          else;
# Line 75  if isempty(myenv); Line 75  if isempty(myenv);
75      myenv.lessplot=0;      myenv.lessplot=0;
76      myenv.lesstest=0;      myenv.lesstest=0;
77      myenv.useNativeMatlabNetcdf = ~isempty(which('netcdf.open'));      myenv.useNativeMatlabNetcdf = ~isempty(which('netcdf.open'));
78        myenv.issueWarnings=1;
79      %... check m_map and netcdf      %... check m_map and netcdf
80  end;  end;
81    
# Line 93  end; Line 94  end;
94    
95  %check available mygrid variables:  %check available mygrid variables:
96  for ii=1:length(listVars);  for ii=1:length(listVars);
97      if ~isfield(mygrid,listVars{ii});      if ~isfield(mygrid,listVars{ii});
98          error(['mygrid does not include ' listVars{ii}]);          error(['mygrid does not include ' listVars{ii}]);
99      end;      end;
100  end;  end;
101    
102    %issue warning if mygrid is empty:
103    test0=~isfield(mygrid,'XC');
104    [ST,I]=dbstack; ST={ST(:).name}';
105    test1=1;
106    list1={'grid_load','startup','plot_one_field','plot_std_field',...
107        'example_remap','example_griddata','example_interp','example_faces2latlon2faces',...
108        'example_bin_average','example_transports','example_budget',...
109        'profiles_process_init','gcmfaces_init'};
110    for jj=1:length(list1);
111        test1=test1&isempty(find(strcmp(ST,list1{jj})));
112    end;
113    if test0&test1&myenv.issueWarnings;
114        warning('mygrid has not yet been loaded to memory');
115    end;
116    
117  %send to workspace:  %send to workspace:
118  evalin('caller','global mygrid myenv');  evalin('caller','global mygrid myenv');
119    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22