1 |
function []=MITprof_global(varargin); |
function []=MITprof_global(varargin); |
2 |
%object: take care of path and global variables (mygrid and mitprofenv), |
% |
3 |
% and sends global variables to caller routine workspace |
% MITPROF_GLOBAL calls gcmfaces_global, adds MITprof paths, adds |
4 |
%notes: - in any call, if this has not yet been done, |
% defines MITprof_climdir and MITprof_griddir in myenv, and |
5 |
% this routine also adds MITprof subdirectories |
% adds myenv (global variable) to caller routine workspace |
|
% to the matlab path, and it defines mitprofenv. |
|
|
% - this routine replaces MITprof_path |
|
6 |
|
|
7 |
%get/define global variables: |
%get/define global variables: |
8 |
global mitprofenv; |
gcmfaces_global; |
9 |
|
|
10 |
%take care of path: |
%take care of path: |
11 |
test0=which('MITprof_load.m'); |
test0=which('MITprof_load.m'); |
24 |
end; |
end; |
25 |
|
|
26 |
%environment variables: |
%environment variables: |
27 |
if isempty(mitprofenv); |
if ~isfield(myenv,'MITprof_dir'); |
28 |
test0=which('MITprof_global.m'); ii=strfind(test0,filesep); |
test0=which('MITprof_global.m'); ii=strfind(test0,filesep); |
29 |
mitprofenv.MITprof_dir=test0(1:ii(end)); |
myenv.MITprof_dir=test0(1:ii(end)); |
30 |
mitprofenv.verbose=0; |
% |
31 |
mitprofenv.lessplot=0; |
gridDir=''; |
32 |
mitprofenv.lesstest=0; |
tmpDir=fullfile(myenv.gcmfaces_dir,'..','GRID',filesep); |
33 |
mitprofenv.useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); |
if isdir(tmpDir); gridDir=tmpDir; end; |
34 |
%... check for gcmfaces |
tmpDir=fullfile(myenv.gcmfaces_dir,'..','nctiles_grid',filesep); |
35 |
|
if isdir(tmpDir); gridDir=tmpDir; end; |
36 |
|
if isdir('GRID/'); gridDir='GRID/'; end; |
37 |
|
if isdir('nctiles_grid/'); gridDir='nctiles_grid/'; end; |
38 |
|
|
39 |
|
if isempty(gridDir); error('could not find grid'); end; |
40 |
|
addpath(gridDir); |
41 |
|
fil=which('GRID.0001.nc'); |
42 |
|
if isempty(fil); fil=which('XC.meta'); end; |
43 |
|
if isempty(fil); error('could not find grid'); end; |
44 |
|
myenv.MITprof_griddir=[fileparts(fil) filesep]; |
45 |
|
% |
46 |
|
climDir=''; |
47 |
|
tmpDir=fullfile(myenv.gcmfaces_dir,'sample_input','OCCAetcONv4GRID',filesep); |
48 |
|
if isdir(tmpDir); climDir=tmpDir; end; |
49 |
|
tmpDir=fullfile(myenv.MITprof_dir,'..','gcmfaces_climatologies',filesep); |
50 |
|
if isdir(tmpDir); climDir=tmpDir; end; |
51 |
|
tmpDir=fullfile('sample_input','OCCAetcONv4GRID',filesep); |
52 |
|
if isdir(tmpDir); climDir=tmpDir; end; |
53 |
|
tmpDir=fullfile('gcmfaces_climatologies',filesep); |
54 |
|
if isdir(tmpDir); climDir=tmpDir; end; |
55 |
|
|
56 |
|
addpath(climDir); |
57 |
|
fil=which('sigma_T_mad_feb2013.bin'); |
58 |
|
if isempty(fil); |
59 |
|
fprintf('\n please indicate the climatologies directory (e.g., ''gcmfaces_climatologies/'') \n\n'); |
60 |
|
fprintf(' It can be obtained as follows: \n'); |
61 |
|
fprintf(' wget --recursive ftp://mit.ecco-group.org/gforget/OCCAetcONv4GRID .\n\n'); |
62 |
|
fprintf(' mv mit.ecco-group.org/gforget/OCCAetcONv4GRID gcmfaces_climatologies \n\n'); |
63 |
|
climDir=input(''); |
64 |
|
end; |
65 |
|
|
66 |
|
addpath(climDir); |
67 |
|
fil=which('sigma_T_mad_feb2013.bin'); |
68 |
|
if isempty(fil); error('could not find sigma_T_mad_feb2013.bin'); end; |
69 |
|
myenv.MITprof_climdir=[fileparts(fil) filesep]; |
70 |
|
|
71 |
end; |
end; |
72 |
|
|
73 |
%send to workspace: |
%send to workspace: |
74 |
evalin('caller','global mygrid mitprofenv'); |
evalin('caller','global mygrid myenv'); |
75 |
|
|