source: trunk/src/project_startup.m @ 2

Last change on this file since 2 was 2, checked in by pinsard, 12 years ago

import of project infrastructure (to be cont.)

File size: 4.0 KB
Line 
1% PROJECT_STARTUP initialisation of matlab/octave environment for PROJECT project
2
3%+
4%
5% .. _project_startup.m:
6%
7% =================
8% project_startup.m
9% =================
10%
11% DESCRIPTION
12% ===========
13%
14% initialisation of matlab/octave environment for PROJECT project
15%
16% Define :
17%  - path for matlab/octave commands used in PROJECT project
18%  - IO directories in global variables
19%
20% This file can be either run classicaly when current directory
21% is ${PROJECT}::
22%
23%  project_startup
24%
25%
26% If linked or copy to ./startup.m, it will be automaticaly
27% run by matlab at start.
28%
29% If linked or copy to ${HOME}/.octaverc, it will be automaticaly
30% run by octave at start.
31%
32% SEE ALSO
33% ========
34%
35% :ref:`project_profile.sh`
36%
37% TODO
38% ====
39%
40% Minimal version octave : 3.0 still true ?!
41%
42% intwarning error
43%
44% intwarning octave
45%
46% EVOLUTIONS
47% ==========
48%
49% $Id: project_startup.m 325 2011-08-04 15:30:01Z pinsard $
50%
51% $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/project/svn/trunk/src/project_startup.m $
52%
53% - fplod 20120424
54%
55%   * creation
56%
57%-
58%
59%clear all
60%
61matlab_minimal_version_required = '7.4';
62octave_minimal_version_required = '3.0.2';
63%
64%disp('iii : adding path to PROJECT matlab tools')
65%
66% test if PROJECT environment set
67global PROJECT;
68PROJECT=getenv('PROJECT');
69%if ( isempty(PROJECT) )
70% error('eee : PROJECT environment not set');
71%else
72% disp(['iii : PROJECT =' PROJECT])
73%end
74%
75% add path
76addpath(PROJECT);
77%
78% IO directories
79% test if PROJECT_ID environment set
80
81global PROJECT_ID;
82PROJECT_ID=getenv('PROJECT_ID');
83%if ( isempty(PROJECT_ID) )
84% error('eee : PROJECT_ID environment not set');
85%end
86%
87% test if PROJECT_OD environment set
88global PROJECT_OD;
89PROJECT_OD=getenv('PROJECT_OD');
90%if ( isempty(PROJECT_OD) )
91% error('eee : PROJECT_OD environment not set');
92%end
93%
94global application;
95global application_version;
96%
97% detect if either octave or matlab running
98if exist('matlabpath','builtin')
99 application='matlab';
100 tmp=ver(application);
101 application_version=tmp.Version;
102 clear tmp;
103 if verLessThan('matlab', matlab_minimal_version_required)
104  disp(['matlab_minimal_version_required = ', matlab_minimal_version_required]);
105  disp(['application_version =', application_version]);
106  warning('www : you have trouble running an older matlab version');
107 end
108end
109if exist('OCTAVE_VERSION','builtin')
110 application='octave';
111 application_version=version; %% WARNING : do not add () because of matlab 6
112end
113%
114global netcdf_open_available
115netcdf_open=which('netcdf.open');
116if (isempty(netcdf_open))
117  netcdf_open_available=0;
118else
119  netcdf_open_available=1;
120end
121clear netcdf_open
122%
123% set up terminal
124switch application
125  case {'matlab'}
126  case {'octave'}
127       if ismac()
128          setenv('GNUTERM','X11');
129       end
130  otherwise
131      error(['unknown application version running ', application , ' ' ,application_version]);
132end
133
134% severe warning and errors
135switch application
136  case {'matlab'}
137     switch application_version
138        case {'7.4'}
139           intwarning('on')
140        case {'7.10','7.11'}
141             disp([ 'non intwarning when matlab is running']);
142        otherwise
143           error(['unknown application version running ', application , ' ' ,application_version]);
144     end
145
146     s = warning('on', 'MATLAB:intConvertNaN');
147     % turn on MATLAB:divideByZero
148     s = warning('on', 'MATLAB:divideByZero');
149     % show warnings
150     %++debug warning('query','all');
151     %++debug intwarning('query')
152  case {'octave'}
153     switch application_version
154        case {'3.0.2'}
155             disp([ 'non intwarning when octave is running']);
156        case {'3.2.3','3.2.4'}
157             intwarning('on')
158        case {'3.4.0'}
159             disp([ 'no more intwarning when octave is running']);
160        otherwise
161           error(['unknown application version running ', application , ' ' ,application_version]);
162     end
163     s = warning('on', 'Octave:divideByZero');
164     % show warnings
165     %++ debug warning('query','all')
166     %++ 33 s=warning('query','all')
167     %++ 33 s.identifier
168     %++ 33 s.state
169  otherwise
170     error('unknown application running');
171end
172more on
Note: See TracBrowser for help on using the repository browser.