| 1 |
gforget |
1.1 |
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 |
| 4 |
|
|
%notes: - in any call, if this has not yet been done, |
| 5 |
|
|
% this routine also adds MITprof subdirectories |
| 6 |
|
|
% to the matlab path, and it defines mitprofenv. |
| 7 |
|
|
% - this routine replaces MITprof_path |
| 8 |
|
|
|
| 9 |
|
|
%get/define global variables: |
| 10 |
gforget |
1.2 |
gcmfaces_global; |
| 11 |
gforget |
1.1 |
|
| 12 |
|
|
%take care of path: |
| 13 |
|
|
test0=which('MITprof_load.m'); |
| 14 |
|
|
if isempty(test0); |
| 15 |
|
|
test0=which('MITprof_global.m'); ii=strfind(test0,filesep); |
| 16 |
|
|
mydir=test0(1:ii(end)); |
| 17 |
|
|
% |
| 18 |
|
|
addpath(fullfile(mydir)); |
| 19 |
|
|
addpath(fullfile(mydir,'profiles_process_main_v2')); |
| 20 |
|
|
addpath(fullfile(mydir,'profiles_IO_v2')); |
| 21 |
|
|
addpath(fullfile(mydir,'profiles_IO_external')); |
| 22 |
|
|
addpath(fullfile(mydir,'profiles_misc')); |
| 23 |
|
|
addpath(fullfile(mydir,'profiles_stats')); |
| 24 |
|
|
addpath(fullfile(mydir,'ecco_v4')); |
| 25 |
|
|
addpath(fullfile(mydir,'profiles_devel')); |
| 26 |
|
|
end; |
| 27 |
|
|
|
| 28 |
|
|
%environment variables: |
| 29 |
gforget |
1.2 |
if ~isfield(myenv,'MITprof_dir'); |
| 30 |
gforget |
1.1 |
test0=which('MITprof_global.m'); ii=strfind(test0,filesep); |
| 31 |
gforget |
1.2 |
myenv.MITprof_dir=test0(1:ii(end)); |
| 32 |
gforget |
1.5 |
% |
| 33 |
|
|
gridDir=''; |
| 34 |
|
|
tmpDir=fullfile(myenv.gcmfaces_dir,'..','GRID',filesep); |
| 35 |
|
|
if isdir(tmpDir); gridDir=tmpDir; end; |
| 36 |
|
|
tmpDir=fullfile(myenv.gcmfaces_dir,'..','nctiles_grid',filesep); |
| 37 |
|
|
if isdir(tmpDir); gridDir=tmpDir; end; |
| 38 |
|
|
if isdir('GRID/'); gridDir='GRID/'; end; |
| 39 |
|
|
if isdir('nctiles_grid/'); gridDir='nctiles_grid/'; end; |
| 40 |
|
|
|
| 41 |
|
|
if isempty(gridDir); error('could not find grid'); end; |
| 42 |
|
|
addpath(gridDir); |
| 43 |
|
|
fil=which('GRID.0001.nc'); |
| 44 |
|
|
if isempty(fil); fil=which('XC.meta'); end; |
| 45 |
|
|
if isempty(fil); error('could not find grid'); end; |
| 46 |
|
|
myenv.MITprof_griddir=[fileparts(fil) filesep]; |
| 47 |
|
|
% |
| 48 |
|
|
climDir=''; |
| 49 |
|
|
tmpDir=fullfile(myenv.gcmfaces_dir,'sample_input','OCCAetcONv4GRID',filesep); |
| 50 |
|
|
if isdir(tmpDir); climDir=tmpDir; end; |
| 51 |
|
|
tmpDir=fullfile(myenv.MITprof_dir,'..','MITprof_climatologies',filesep); |
| 52 |
|
|
if isdir(tmpDir); climDir=tmpDir; end; |
| 53 |
|
|
tmpDir=fullfile('sample_input','OCCAetcONv4GRID',filesep); |
| 54 |
|
|
if isdir(tmpDir); climDir=tmpDir; end; |
| 55 |
|
|
tmpDir=fullfile('MITprof_climatologies',filesep); |
| 56 |
|
|
if isdir(tmpDir); climDir=tmpDir; end; |
| 57 |
|
|
|
| 58 |
|
|
addpath(climDir); |
| 59 |
|
|
fil=which('sigma_T_mad_feb2013.bin'); |
| 60 |
|
|
if isempty(fil); |
| 61 |
|
|
fprintf('\n please indicate the climatologies directory (e.g., ''MITprof_climatologies/'') \n\n'); |
| 62 |
|
|
fprintf(' It can be obtained as follows: \n'); |
| 63 |
|
|
fprintf(' wget --recursive ftp://mit.ecco-group.org/gforget/OCCAetcONv4GRID .\n\n'); |
| 64 |
|
|
fprintf(' mv mit.ecco-group.org/gforget/OCCAetcONv4GRID MITprof_climatologies \n\n'); |
| 65 |
gforget |
1.6 |
climDir=input(''); |
| 66 |
gforget |
1.5 |
end; |
| 67 |
|
|
|
| 68 |
|
|
addpath(climDir); |
| 69 |
|
|
fil=which('sigma_T_mad_feb2013.bin'); |
| 70 |
|
|
if isempty(fil); error('could not find sigma_T_mad_feb2013.bin'); end; |
| 71 |
|
|
myenv.MITprof_climdir=[fileparts(fil) filesep]; |
| 72 |
|
|
|
| 73 |
gforget |
1.1 |
end; |
| 74 |
|
|
|
| 75 |
|
|
%send to workspace: |
| 76 |
|
|
evalin('caller','global mygrid mitprofenv'); |
| 77 |
|
|
|