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 | % |
---|
61 | matlab_minimal_version_required = '7.4'; |
---|
62 | octave_minimal_version_required = '3.0.2'; |
---|
63 | % |
---|
64 | %disp('iii : adding path to PROJECT matlab tools') |
---|
65 | % |
---|
66 | % test if PROJECT environment set |
---|
67 | global PROJECT; |
---|
68 | PROJECT=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 |
---|
76 | addpath(PROJECT); |
---|
77 | % |
---|
78 | % IO directories |
---|
79 | % test if PROJECT_ID environment set |
---|
80 | |
---|
81 | global PROJECT_ID; |
---|
82 | PROJECT_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 |
---|
88 | global PROJECT_OD; |
---|
89 | PROJECT_OD=getenv('PROJECT_OD'); |
---|
90 | %if ( isempty(PROJECT_OD) ) |
---|
91 | % error('eee : PROJECT_OD environment not set'); |
---|
92 | %end |
---|
93 | % |
---|
94 | global application; |
---|
95 | global application_version; |
---|
96 | % |
---|
97 | % detect if either octave or matlab running |
---|
98 | if 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 |
---|
108 | end |
---|
109 | if exist('OCTAVE_VERSION','builtin') |
---|
110 | application='octave'; |
---|
111 | application_version=version; %% WARNING : do not add () because of matlab 6 |
---|
112 | end |
---|
113 | % |
---|
114 | global netcdf_open_available |
---|
115 | netcdf_open=which('netcdf.open'); |
---|
116 | if (isempty(netcdf_open)) |
---|
117 | netcdf_open_available=0; |
---|
118 | else |
---|
119 | netcdf_open_available=1; |
---|
120 | end |
---|
121 | clear netcdf_open |
---|
122 | % |
---|
123 | % set up terminal |
---|
124 | switch 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]); |
---|
132 | end |
---|
133 | |
---|
134 | % severe warning and errors |
---|
135 | switch 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'); |
---|
171 | end |
---|
172 | more on |
---|