source: trunk/src/command_launch_matlab.m @ 1147

Last change on this file since 1147 was 1134, checked in by sommeria, 8 months ago

adapted to reading hdf5 data from fluidimage, extract_rdvision improved

File size: 3.2 KB
Line 
1%'command_launch_matlab': creates the command strings for opening a new Matlab
2%session and running a programme in a Linux system('GLNX86','GLNXA64','MACI64')
3%------------------------------------------------------------------------
4% function cmd=command_launch_matlab(filelog,path_uvmat,ActionPath,ActionName,inputxml,option)
5%
6%OUTPUT
7% cmd=set of system commands (char string) to write in an executable file: [fid,message]=fopen(file_exe,'w');
8                           % fprintf(fid,cmd); % fill the executable file with the  char string cmd
9                           % fclose(fid); % close the executable file
10                           %  system(['chmod +x ' file_exe]); % set the file to executable
11                           % system([file_exe ' &'])%  execute the command file
12                           
13%
14%INPUT:
15% filelog: name (char string)  of the file to collect the output in the Matlab command window
16% path_uvmat: path to the UVMAT Matlab toolbox
17% ActionPath:  path to the Matlab programme to launch
18% ActionName: name of the programme to launch
19% inputxml: full name, including path, of the xml input parameter file for the programme ActionName
20% option: ='bacground' or 'cluster' depending on the launching option
21
22function cmd=command_launch_matlab(filelog,path_uvmat,ActionPath,ActionName,inputxml,option)
23ThreadOption='';
24if strcmp(option,'cluster')
25    ThreadOption='-singleCompThread';
26    inputxml={inputxml};% single input parameter file
27end
28matlab_ver = ver('MATLAB');
29matlab_version = matlab_ver.Version;
30cmd=[...
31    '#!/bin/bash\n'...
32    'source /etc/profile\n'...
33    'module purge\n'...
34    'module load matlab/' matlab_version '\n'...% CHOICE OF THE SAME MATLAB VERSION AS THE CURRENT MATLAB SESSION (not mandatory)
35    'time_start=$(date +%%s)\n'...
36    'matlab -nodisplay -nosplash -nojvm ''' ThreadOption ''' -logfile ''' filelog ''' <<END_MATLAB\n'...%launch the new Matlab session  without display
37    'addpath(''' path_uvmat ''');\n'...
38    'addpath(''' ActionPath ''');\n'];
39for iprocess=1:numel(inputxml)
40    cmd=[cmd '' ActionName  '(''' inputxml{iprocess} ''');\n'];
41end
42cmd=[cmd  'exit\n' 'END_MATLAB\n'];
43    if strcmp(option,'background')
44    cmd=[cmd ...
45    'time_end=$(date +%%s)\n'...
46    'echo "global time = " $(($time_end - $time_start)) >> ''' filelog '''\n'];
47    end
48
49%% case cluster:
50% matlab_ver = ver('MATLAB');
51%                     matlab_version = matlab_ver.Version;
52%                     cmd=[...
53%                         '#!/bin/bash\n'...
54%                         'source /etc/profile\n'...
55%                         'module purge\n'...
56%                         'module load matlab/' matlab_version '\n'...% CHOICE OF CURRENT MATLAB VERSION
57%                         'matlab -nodisplay -nosplash -nojvm -singleCompThread -logfile ''' filelog{iprocess} ''' <<END_MATLAB\n'...% open a new Matlab session without display
58%                         'addpath(''' path_series ''');\n'...
59%                         'addpath(''' ActionPath ''');\n'...
60%                         '' ActionName  '(''' filexml{iprocess} ''');\n'...% launch the Matlab function selected by the GUI 'series'
61%                         'exit\n'...
62%                         'END_MATLAB\n'];
63%                 end
64
65
Note: See TracBrowser for help on using the repository browser.