Changeset 1171 for trunk/src/series.m
- Timestamp:
- Jan 23, 2025, 11:37:09 AM (10 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r1170 r1171 138 138 if ~exist(xmlfile,'file') 139 139 [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile); 140 if success==0 141 disp(message) 142 return 143 end 140 144 end 141 145 if exist(xmlfile,'file') 142 SeriesData=xml2struct(xmlfile); 146 SeriesData=xml2struct(xmlfile);% read the xml file containing parameters for series computations 143 147 if ~(isfield(SeriesData,'ClusterParam')&& isfield(SeriesData.ClusterParam,'LaunchCmdFcn')) 144 [success,message]=copyfile(xmlfile,fullfile(path_series,'series _old.xml'));% update the file series.xml inot correctly documented148 [success,message]=copyfile(xmlfile,fullfile(path_series,'series.xml~'));% backup the file series.xml, not correctly documented 145 149 delete(xmlfile); 146 [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile); 147 end 148 SeriesData=xml2struct(xmlfile); 150 [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile);% use the defualt series.xml 151 end 152 SeriesData=xml2struct(xmlfile);% read again the xml file containing parameters for series computations 149 153 end 150 154 … … 160 164 ActionPathList(:)={path_series_fct}; % set the default path to series fcts to all list members 161 165 RunModeList={'local';'background'}; % default choice of extensions (Matlab fct .m or compiled version .sh) 162 if isfield(SeriesData.ClusterParam.ExistenceTest,'Text') 163 oarcommand=SeriesData.ClusterParam.ExistenceTest.Text; 166 if isfield(SeriesData.ClusterParam, 'ExistenceTest') 167 oarcommand=SeriesData.ClusterParam.ExistenceTest; 168 [s,w]=system(oarcommand); % look for cluster system presence 169 if isequal(s,0)% cluster detected 170 RunModeList=[RunModeList;{'cluster'}]; 171 set(handles.MonitorCluster,'Visible','on'); % make visible button for access to Monika 172 set(handles.num_CPUTime,'Visible','on'); % make visible button for CPU time estimate for one ref index 173 set(handles.num_CPUTime,'String','')% default CPU time undefined 174 set(handles.CPUTime_txt,'Visible','on'); % make visible button for CPU time title 175 end 176 set(handles.RunMode,'String',RunModeList)% display the menu of available run modes, local, background or cluster manager 164 177 else 165 oarcommand=SeriesData.ClusterParam.ExistenceTest; 166 end 167 [s,w]=system(oarcommand); % look for cluster system presence 168 if isequal(s,0) 169 RunModeList=[RunModeList;{'cluster'}]; 170 set(handles.MonitorCluster,'Visible','on'); % make visible button for access to Monika 171 set(handles.num_CPUTime,'Visible','on'); % make visible button for CPU time estimate for one ref index 172 set(handles.num_CPUTime,'String','')% default CPU time undefined 173 set(handles.CPUTime_txt,'Visible','on'); % make visible button for CPU time title 174 end 175 set(handles.RunMode,'String',RunModeList)% display the menu of available run modes, local, background or cluster manager 178 disp('no cluster availability test in series.xml') 179 end 180 176 181 177 182 %% list of builtin transform functions in the menu TransformName … … 1438 1443 if strcmp(RunMode,'local') 1439 1444 current_dir=pwd; % current working dir 1440 cd(ActionPath) 1441 h_fun=str2func(ActionName);% create the function handle for the function ActionName 1442 cd(current_dir) 1443 % if ~isequal(ActionPath,path_series) 1444 % 1445 % %eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION 1446 % if ~exist(ActionPath,'dir') 1447 % errormsg=['The prescribed function path ' ActionPath ' does not exist']; 1448 % return 1449 % end 1450 % spath=fileparts(which(ActionName)); 1451 % if ~strcmp(spath,ActionPath) 1452 % addpath(ActionPath)% add the prescribed path if not the current one 1453 % end 1454 % end 1455 % eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION 1456 % if ~isequal(ActionPath,path_series) 1457 % rmpath(ActionPath)% add the prescribed path if not the current one 1458 % end 1459 end 1445 cd(ActionPath) 1446 h_fun=str2func(ActionName);% create the function handle for the function ActionName 1447 cd(current_dir) 1448 end 1460 1449 1461 1450 %% Get parameters from series.xml … … 1533 1522 % NbCore is the number of computer processors used 1534 1523 % NbProcess is the number of independent processes in which the required calculation is split. 1535 % switch RunMode1536 % case {'local','background'}1537 % NbCore=1; % no need to split the calculation1538 % case 'cluster'1539 % %proposed number of cores to reserve in the cluster1540 % NbCoreAdvised=SeriesData.ClusterParam.NbCoreAdvised;1541 % NbCoreMax=min(NbProcess,SeriesData.ClusterParam.NbCoreMax);1542 % if NbCoreMax~=11543 % if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)1544 % warning_string=', preferably use .sh option to save Matlab licences';1545 % else1546 % warning_string=')';1547 % end1548 % answer=msgbox_uvmat('INPUT_TXT',['Number of cores (max ' num2str(NbCoreMax) ', ' warning_string],num2str(NbCoreAdvised));1549 % if isempty(answer)1550 % errormsg='Action launch interrupted by user';1551 % return1552 % end1553 % NbCore=str2double(answer);1554 % if NbCore > NbCoreMax1555 % NbCore=NbCoreMax;1556 % end1557 % else1558 % NbCore=1;1559 % end1560 % end1561 1524 if ~isfield(Param.IndexRange,'NbSlice') 1562 1525 Param.IndexRange.NbSlice=[]; … … 1586 1549 for iexp=1:numel(ListExp) 1587 1550 if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder 1588 %if strcmp(get(BrowseData.DataSeries,'enable'),'off') %case of a multiple input line for series 1589 % NbExp=NbExp+1; 1590 % ExpIndex{NbExp}=iexp; 1591 % for idevice=1:numel(ListDevices) 1592 % lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),... 1593 % regexprep(ListDevices{idevice},'^\+/','')); 1594 % lpathout=fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),... 1595 % regexprep(ListDevices{idevice},'^\+/','')); 1596 % ldir=regexprep(ListDataSeries{idevice},'^\+/',''); 1597 % ListPath{idevice,NbExp}=lpath; 1598 % ListPathOut{idevice,NbExp}=lpathout; 1599 % ListSubdir{idevice,NbExp}=ldir; 1600 % end 1601 %else 1602 for idevice=1:numel(ListDevices) 1603 if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder 1604 for isubdir=1:numel(ListDataSeries) 1605 if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder 1606 lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),... 1607 regexprep(ListDevices{idevice},'^\+/','')); 1608 lpathout= fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),... 1609 regexprep(ListDevices{idevice},'^\+/','')); 1610 ldir= regexprep(ListDataSeries{isubdir},'^\+/',''); 1611 if exist(fullfile(lpath,ldir),'dir') 1612 NbExp=NbExp+1; 1613 ExpIndex(NbExp)=ExpIndices(iexp); 1614 DeviceIndex(NbExp)=DeviceIndices(idevice); 1615 ListPath{NbExp}=lpath; 1616 ListPathOut{NbExp}=lpathout; 1617 ListDeviceOut{NbExp}=regexprep(ListDevices{idevice},'^\+/',''); 1618 ListExpOut{NbExp}=regexprep(ListExp{iexp},'^\+/',''); 1619 ListSubdir{NbExp}=ldir; 1620 end 1551 for idevice=1:numel(ListDevices) 1552 if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder 1553 for isubdir=1:numel(ListDataSeries) 1554 if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder 1555 lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),... 1556 regexprep(ListDevices{idevice},'^\+/','')); 1557 lpathout= fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),... 1558 regexprep(ListDevices{idevice},'^\+/','')); 1559 ldir= regexprep(ListDataSeries{isubdir},'^\+/',''); 1560 if exist(fullfile(lpath,ldir),'dir') 1561 NbExp=NbExp+1; 1562 ExpIndex(NbExp)=ExpIndices(iexp); 1563 DeviceIndex(NbExp)=DeviceIndices(idevice); 1564 ListPath{NbExp}=lpath; 1565 ListPathOut{NbExp}=lpathout; 1566 ListDeviceOut{NbExp}=regexprep(ListDevices{idevice},'^\+/',''); 1567 ListExpOut{NbExp}=regexprep(ListExp{iexp},'^\+/',''); 1568 ListSubdir{NbExp}=ldir; 1621 1569 end 1622 1570 end 1623 1571 end 1624 1572 end 1625 % end 1573 end 1574 % end 1626 1575 end 1627 1576 end … … 1829 1778 Param.Action.CPUTime=CPUTime; 1830 1779 end 1831 JobNumberMax=SeriesData.ClusterParam.JobNumberMax; 1832 JobCPUTimeAdvised=SeriesData.ClusterParam.JobCPUTimeAdvised; 1780 if isfield(SeriesData.ClusterParam,'JobNumberMax') 1781 JobNumberMax=SeriesData.ClusterParam.JobNumberMax; 1782 else 1783 disp('ClusterParam.JobNumberMax not documented in series.xml, set to 500 by default') 1784 JobNumberMax=500; 1785 end 1786 if isfield(SeriesData.ClusterParam,'JobCPUTimeAdvised') 1787 JobCPUTimeAdvised=SeriesData.ClusterParam.JobCPUTimeAdvised; 1788 else 1789 disp('ClusterParam.JobCPUTimeAdvised not documented in series.xml, set to 120 minutes by default') 1790 JobCPUTimeAdvised=120; 1791 end 1833 1792 if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined 1834 1793 BlockLength= ceil(JobCPUTimeAdvised/(CPUTime*nbfield_j)); % iterations are grouped in sets with length BlockLength such that the typical CPU time of a job is JobCPUTimeAdvised. … … 1838 1797 NbProcess=Param.IndexRange.NbSlice; % the parameter NbSlice sets the nbre of run processes 1839 1798 end 1840 1799 1841 1800 % %proposed number of cores to reserve in the cluster 1842 NbCoreAdvised=SeriesData.ClusterParam.NbCoreAdvised; 1843 NbCoreMax=min(NbProcess,SeriesData.ClusterParam.NbCoreMax);% reduces the number of cores if it exceeds the number of processes 1801 if isfield(SeriesData.ClusterParam,'NbCoreAdvised') 1802 NbCoreAdvised=SeriesData.ClusterParam.NbCoreAdvised; 1803 else 1804 disp('ClusterParam.NbCoreAdvised not documented in series.xml, set to 16 by default') 1805 NbCoreAdvised=16; 1806 end 1807 if isfield(SeriesData.ClusterParam,'NbCoreMax') 1808 NbCoreMax=min(NbProcess,SeriesData.ClusterParam.NbCoreMax);% reduces the number of cores if it exceeds the number of processes 1809 else 1810 disp('ClusterParam.NbCoreMax not documented in series.xml, set to 36 by default') 1811 NbCoreMax=min(NbProcess,36); 1812 end 1844 1813 if NbCoreMax~=1 1845 1814 if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled) … … 1848 1817 warning_string=')'; 1849 1818 end 1850 answer=msgbox_uvmat('INPUT_TXT',['Number of cores ( max ' num2str(NbCoreMax) ', 'warning_string],num2str(NbCoreAdvised));1851 if isempty(answer) 1819 answer=msgbox_uvmat('INPUT_TXT',['Number of cores (limited to ' num2str(NbCoreMax) warning_string],num2str(NbCoreAdvised)); 1820 if isempty(answer)||strcmp(answer,'Cancel') 1852 1821 errormsg='Action launch interrupted by user'; 1853 1822 return … … 2106 2075 end 2107 2076 CPUTimeProcess=CPUTime*BlockLength*nbfield_j; % estimated CPU time for one individual process (in minutes) 2077 if isfield(SeriesData.ClusterParam,'LaunchCmdFcn')&& exist(SeriesData.ClusterParam.LaunchCmdFcn,'file') 2108 2078 LaunchCmdFcn=SeriesData.ClusterParam.LaunchCmdFcn;% command obtained from the function 2079 else 2080 disp('no ClusterParam.LaunchCmdFcn defined in series.xml') 2081 return 2082 end 2109 2083 oar_command=feval(LaunchCmdFcn,ListProcess,ActionFullName,DirLog,NbProcess, NbCore,CPUTimeProcess) 2110 2084 [status,result]=system(oar_command)% execute system command and show the result (ID number of the launched job) on the Matlab command window
Note: See TracChangeset
for help on using the changeset viewer.