Changeset 598 for trunk/src/series.m


Ignore:
Timestamp:
Apr 2, 2013, 9:13:42 AM (11 years ago)
Author:
sommeria
Message:

various bugs repaired . civ_series further developed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r596 r598  
    7070set(hObject,'Units','pixels')
    7171set(handles.PairString,'ColumnName',{'pairs'})
    72 set(handles.PairString,'ColumnEditable',logical(0))
     72set(handles.PairString,'ColumnEditable',false)
    7373set(handles.PairString,'ColumnFormat',{'char'})
    7474set(handles.PairString,'Data',{''})
     
    8484[path_series,name,ext]=fileparts(which('series'));% path to the GUI series
    8585path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
    86 path_bin=fullfile(path_series,'bin');%path of the binary functions (compiled)
     86%path_bin=fullfile(path_series,'bin');%path of the binary functions (compiled)
    8787ActionPathList=regexprep(ActionList,'^.+$',path_series_fct);% set path=path_series to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string)
    88 ActionPathList=[ActionPathList regexprep(ActionList,'^.+$',path_bin)];% set path to compiled functions
     88ActionPathList=[ActionPathList ActionPathList];% set path to .sh commands for compiled functions
    8989ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh)
    9090RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh)
     
    13661366    if exist(xmlfile,'file')
    13671367        s=xml2struct(xmlfile);
    1368         if strcmp(RunMode,'cluster') && isfield(s,'BatchParam')
     1368        if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam')
    13691369            if isfield(s.BatchParam,'RunTime')
    13701370                RunTime=s.BatchParam.RunTime;
     
    13821382        end
    13831383    end
    1384     if isempty(RunTime) && strcmp(RunMode,'cluster')
     1384    if isempty(RunTime) && strcmp(RunMode,'cluster_oar')
    13851385        msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster')
    13861386        return
    13871387    end
    1388     Series.RunTime=RunTime;
     1388%     Series.RunTime=RunTime;
    13891389end
    13901390
     
    14421442        if isempty(Series.IndexRange.NbSlice)
    14431443            Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength;
    1444             Series.IndexRange.last_i=first_i+(iprocess)*BlockLength-1;
     1444            if Series.IndexRange.first_i>last_i
     1445                break
     1446            end
     1447            Series.IndexRange.last_i=min(first_i+(iprocess)*BlockLength-1,last_i);
    14451448        else
    14461449            Series.IndexRange.first_i= first_i+iprocess-1;
     
    14591462                    case {'PCWIN','PCWIN64'} %Windows system
    14601463                        filexml=regexprep(filexml,'\\','\\\\');% add '\' so that '\' are left as characters
    1461                         system([fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml]);% TODO: adapt to DOS system
     1464                        system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]);% TODO: adapt to DOS system
    14621465                    case {'GLNX86','GLNXA64','MACI64'}%Linux  system
    1463                         system([fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml]);
     1466                        system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]);
    14641467                end
    14651468        end
     
    14921495        if isempty(Series.IndexRange.NbSlice)% process by blocks of i index
    14931496            Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength;
    1494             Series.IndexRange.last_i=first_i+(iprocess)*BlockLength-1;
     1497            if Series.IndexRange.first_i>last_i
     1498                NbProcess=iprocess-1;
     1499                break% leave the loop, we are at the end of the calculation
     1500            end
     1501            Series.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength-1);
    14951502        else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1
    14961503            Series.IndexRange.first_i= first_i+iprocess-1;
     
    15061513       
    15071514        %create the executable file
    1508         filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.bat',OutputNomType,...
    1509             Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1515%         filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.bat',OutputNomType,...
     1516%             Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1517         filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.sh',OutputNomType,...
     1518           Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
    15101519        batch_file_list{iprocess}=filebat;
    15111520        [fid,message]=fopen(filebat,'w');% create the executable file
     
    15511560                            'hostname && date \n '...
    15521561                            'umask 002 \n'...
    1553                             fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml];%allow writting access to created files for user group
     1562                            fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml];%allow writting access to created files for user group
    15541563                        fprintf(fid,cmd);%fill the executable file with the  char string cmd
    15551564                        fclose(fid);% close the executable file
     
    15901599        fid=fopen(filename_joblist,'w');
    15911600        for p=1:length(batch_file_list)
    1592             fprintf(fid,[batch_file_list{p} '\n']);% list of exe files (TODO: create them)
     1601            fprintf(fid,[batch_file_list{p} '\n']);% list of exe files
    15931602        end
    15941603        fclose(fid);
     
    17051714end
    17061715Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
    1707 Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
    1708 Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
     1716% Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
     1717% Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
    17091718empty_line=false(size(Series.InputTable,1),1);
    17101719for iline=1:size(Series.InputTable,1)
     
    17261735    end
    17271736end
     1737set(handles.ActionName,'BackgroundColor',[1 1 0])
     1738drawnow
    17281739
    17291740%% get Action name and path
     
    17521763    end
    17531764    [ActionPath,ActionName,ActionExt]=fileparts(FileName);
    1754     % insert the choice in the menu
     1765   
     1766    % insert the choice in the menu ActionName
    17551767    ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action
    17561768    if isempty(ActionIndex)%the input string does not exist in the menu
     
    17591771        set(handles.ActionName,'String',ActionList)
    17601772    end
    1761     %set(handles.ActionName,'Value',ActionIndex)
    1762     %list_path{ActionIndex}=PathName;
     1773   
     1774    % record the file extension and extend the path list if it is a new extension
     1775    ActionExtList=get(handles.ActionExt,'String');
     1776    ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1);
     1777    if isempty(ActionExtIndex)
     1778        set(handles.ActionExt,'String',[ActionExtList;{ActionExt}])
     1779        ActionExtIndex=numel(ActionExtList)+1;
     1780        ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath
     1781        ActionPathList=[ActionPathList ActionPathNew];
     1782    end
     1783    set(handles.ActionName,'UserData',ActionPathList);
     1784
    17631785    % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5)
    17641786    if length(ActionList)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu
    17651787        nbremove=length(ActionList)-nb_builtin_ACTION-5;
    17661788        ActionList(nb_builtin_ACTION+1:end-5)=[];
    1767         ActionPathList(nb_builtin_ACTION+1:end-4)=[];
     1789        ActionPathList(nb_builtin_ACTION+1:end-4,:)=[];
    17681790        ActionIndex=ActionIndex-nbremove;
    17691791    end
     1792   
     1793    % record action menu, choice and path
    17701794    set(handles.ActionName,'Value',ActionIndex)
    17711795    set(handles.ActionName,'String',ActionList)
    1772     ActionPathList{ActionIndex}=PathName;
    1773     set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off')
    1774    
    1775     % record the file extension and update the paths in userdata
    1776     ActionExtList=get(handles.ActionExt,'String');
    1777     ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1);
    1778     if isempty(ActionExtIndex)
    1779         set(handles.ActionExt,'String',[ActionExtList;{ActionExt}])
    1780         set(handles.ActionExt,'Value',numel(ActionExtList)+1)
    1781         ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath
    1782         ActionPathNew{ActionIndex}=ActionPath;
    1783         ActionPathList=[ActionPathList ActionPathNew];
    1784     end
    1785     set(handles.ActionName,'UserData',ActionPathList);
    1786    
    1787     %record the current menu in personal file profil_perso
     1796    set(handles.ActionExt,'Value',ActionExtIndex)
     1797    ActionPathList{ActionIndex,ActionExtIndex}=PathName;
     1798       
     1799    %record the user defined menu additions in personal file profil_perso
    17881800    dir_perso=prefdir;
    17891801    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    1790     if nb_builtin_ACTION+1<=length(ActionList)-1
     1802    if nb_builtin_ACTION+1<=numel(ActionList)-1
    17911803        ActionListUser=ActionList(nb_builtin_ACTION+1:numel(ActionList)-1);
    17921804        ActionPathListUser=ActionPathList(nb_builtin_ACTION+1:numel(ActionList)-1,:);
     
    18111823
    18121824%% default setting for the visibility of the GUI elements
    1813 set(handles.FieldTransform,'Visible','off')
    1814 set(handles.CheckObject,'Visible','off');
    1815 set(handles.ProjObject,'Visible','off');
    1816 set(handles.CheckMask,'Visible','off')
    1817 set(handles.Mask,'Visible','off')
     1825% set(handles.FieldTransform,'Visible','off')
     1826% set(handles.CheckObject,'Visible','off');
     1827% set(handles.ProjObject,'Visible','off');
     1828% set(handles.CheckMask,'Visible','off')
     1829% set(handles.Mask,'Visible','off')
    18181830
    18191831%% create the function handle for Action
     
    18341846end
    18351847
    1836 %% prepare the input param
    1837 [Series,tild,errormsg]=prepare_jobs(handles);
     1848%% Activate the Action fct
     1849[Series,tild,errormsg]=prepare_jobs(handles);% read the parameters from the GUI series
    18381850if ~isempty(errormsg)
    18391851    msgbox_uvmat('ERROR',errormsg)
     
    18421854ParamOut=h_fun(Series);
    18431855
    1844 %% Put the first line of the selected Action fct as tootip help
     1856%% Put the first line of the selected Action fct as tooltip help
    18451857try
    18461858    [fid,errormsg] =fopen([ActionName '.m']);
     
    18491861    set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help
    18501862end
    1851 % if ~isequal(path_series,PathName)
    1852 %     rmpath(PathName)
    1853 % end
    1854 Param_list={};
    18551863
    18561864%% Detect the types of input files
     
    19982006    set(handles.ActionInput,'Visible','on')
    19992007    set(handles.ActionInput_title,'Visible','on')
     2008    set(handles.ActionInputView,'Visible','on')
     2009    set(handles.ActionInputView,'Value',0)
    20002010    set(handles.ActionInput,'String',ActionName)
     2011    ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput
    20012012    SeriesData.ActionInput=ParamOut.ActionInput;
    20022013else
    20032014    set(handles.ActionInput,'Visible','off')
    20042015    set(handles.ActionInput_title,'Visible','off')
     2016    set(handles.ActionInputView,'Visible','off')
    20052017    if isfield(SeriesData,'ActionInput')
    20062018    SeriesData=rmfield(SeriesData,'ActionInput');
     
    20082020end   
    20092021set(handles.series,'UserData',SeriesData)
     2022set(handles.ActionName,'BackgroundColor',[1 1 1])
     2023
     2024%------------------------------------------------------------------------
     2025% --- Executes on button press in ActionInputView.
     2026function ActionInputView_Callback(hObject, eventdata, handles)
     2027%------------------------------------------------------------------------
     2028if get(handles.ActionInputView,'Value')
     2029ActionName_Callback(hObject, eventdata, handles)
     2030end
    20102031
    20112032%------------------------------------------------------------------------
     
    24272448    if strcmp(FileType,'txt')
    24282449        edit(FullSelectName)
     2450    elseif strcmp(FileType,'xml')
     2451        editxml(FullSelectName)
    24292452    else
    24302453        uvmat(FullSelectName)
     
    26062629NbSlice=str2num(get(handles.num_NbSlice,'String'));
    26072630set(handles.num_NbProcess,'String',num2str(NbSlice))
     2631
     2632
Note: See TracChangeset for help on using the changeset viewer.