Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 482)
+++ /trunk/src/civ.m	(revision 483)
@@ -60,4 +60,6 @@
 errormsg=[];%default error message
 xmlfile='PARAM.xml';
+test_batch=0;%default: ,no batch mode available
+sparam=[];
 if exist(xmlfile,'file')
     try
@@ -66,14 +68,16 @@
     catch ME
         errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message};
+         msgbox_uvmat('WARNING',errormsg);
     end
 else
-    errormsg=[xmlfile ' not found: path to civx binaries undefined'];
-end
-if ~isempty(errormsg)
-    msgbox_uvmat('WARNING',errormsg);
-end
-
-
-test_batch=0;%default: ,no batch mode available
+    %errormsg=[xmlfile ' not found: path to civx binaries undefined'];
+    [s,w]=system('oarstat');
+    if ~isequal(s,0)
+        [s,w]=system('qstat');
+    end
+    if isequal(s,0)
+        test_batch=1;
+    end           
+end
 if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
     batch_mode=sparam.BatchParam.BatchMode; %sge is currently the only implemented batch mod
@@ -100,11 +104,11 @@
 %     set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated)
 end
-if isfield(sparam.RunParam,'CivBin')
-    if ~exist(sparam.RunParam.CivBin,'file')
-        sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin);
-    end
-else
-    sparam.RunParam.CivBin='';
-end
+% if isfield(sparam.RunParam,'CivBin')
+%     if ~exist(sparam.RunParam.CivBin,'file')
+%         sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin);
+%     end
+% else
+%     sparam.RunParam.CivBin='';
+% end
 
 %% load the list of previously browsed files in the upper bar menu Open/
@@ -888,6 +892,8 @@
     drawnow 
 end
-set(hrefresh,'UserData',option_civ)
-        filepath=fileparts(civ_files{1});
+StatusData.time_ref=now;% store the current time
+StatusData.option_civ=option_civ;
+set(hrefresh,'UserData',StatusData)
+filepath=fileparts(civ_files{1});
 set(hlist,'UserData',fileparts(filepath))
 refresh_GUI(hrefresh,[])
@@ -900,98 +906,83 @@
 BarPosition=[0.05 0.81 0.01 0.05];
 hfig=get(hObject,'parent');
+StatusData=get(hObject,'UserData');
 civ_files=get(hfig,'UserData');
-        [filepath,filename,ext]=fileparts(civ_files{1});
-        [tild,SubDir,extdir]=fileparts(filepath);
-        SubDir=[SubDir extdir];
-option_civ=get(hObject,'UserData');
+[filepath,filename,ext]=fileparts(civ_files{1});
+[tild,SubDir,extdir]=fileparts(filepath);
+SubDir=[SubDir extdir];
+option_civ=StatusData.option_civ;
 nbfiles=numel(civ_files);
+testrecent=0;
 count=0;
-testrecent=0;
-% while count<nbfiles
-    count=0;
-    datnum=zeros(1,nbfiles);
-    for ifile=1:nbfiles
-        detect=exist(civ_files{ifile},'file'); % check the existence of the file
-        option=0;
-        if detect==0
-            option_str='not created';
+datnum=zeros(1,nbfiles);
+filefound=cell(1,nbfiles);
+for ifile=1:nbfiles
+    detect=exist(civ_files{ifile},'file'); % check the existence of the file
+    option=0;
+    if detect==0
+        option_str='not created';
+    else
+        datfile=dir(civ_files{ifile});
+        if isfield(datfile,'datenum')
+            datnum(ifile)=datfile.datenum;%only available in recent matlab versions
+            testrecent=1;
+        end
+        filefound(ifile)={datfile.name};
+        
+        % check the content  netcdf file
+        Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix');
+        option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
+        if ~isempty(Data.CivStage)
+            option=Data.CivStage;%case of Matlab civ
         else
-            datfile=dir(civ_files{ifile});
-            if isfield(datfile,'datenum')
-                datnum(ifile)=datfile.datenum;%only available in recent matlab versions
-                testrecent=1;
-            end
-            filefound(ifile)={datfile.name};
-            lastfield='';
-            % check the content  netcdf file
-            Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix');
-            option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
-            if ~isempty(Data.CivStage)
-                option=Data.CivStage;%case of Matlab civ
+            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
+                option=6;
+            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
+                option=5;
+            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
+                option=4;
+            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
+                option=3;
+            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
+                option=2;
             else
-                if ~isempty(Data.patch2) && isequal(Data.patch2,1)
-                    option=6;
-                elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
-                    option=5;
-                elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
-                    option=4;
-                elseif ~isempty(Data.patch) && isequal(Data.patch,1);
-                    option=3;
-                elseif ~isempty(Data.fix) && isequal(Data.fix,1);
-                    option=2;
-                else
-                    option=1;
-                end
-            end
-            option_str=option_list{option};
-        end
-        if option >= option_civ
-            count=count+1;
-        end
-        [filepath,filename,ext]=fileparts(civ_files{ifile});
-        Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
-    end
+                option=1;
+            end
+        end
+        option_str=option_list{option};
+        if datnum(ifile)<StatusData.time_ref
+            option_str=[option_str '  --OLD--'];
+        end
+    end
+    if option >= option_civ
+        count=count+1;
+    end
+    [filepath,filename,ext]=fileparts(civ_files{ifile});
+    Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
+end
+datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
+if isempty(datnum)
+    if testrecent
+        message='no civ result created yet';
+    else
+        message='';
+    end
+else
     datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
-    if isempty(datnum) 
-        if testrecent
-            message='no civ result created yet';
-        else
-            message='';
-        end
-    else
-        datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
-        [first,ind]=min(datnum);
-        [last,indlast]=max(datnum);
-%         if test_new
-%             message='existing file status, no processing launched yet';
-%         else
-        message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
-            ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
-%         end
-    end
-    %hfig=findobj(allchild(0),'name','civ_status');
-%     if isempty(hfig)% the status list has been deleted
-%         return
-%     else
-        hlist=findobj(hfig,'tag','list');
-        hmsgbox=findobj(hfig,'tag','msgbox');
-        hwaitbar=findobj(hfig,'tag','waitbar');
-        set(hlist,'String',Tabchar)
-        set(hmsgbox,'String', message)
-        if count>0 %&& ~test_new
-            BarPosition(3)=0.9*count/nbfiles;
-            set(hwaitbar,'Position',BarPosition)
-        end
-%     end
-%     [root,filename,ext]=fileparts(civ_files{1});
-% [rootroot,SubDir,extdir]=fileparts(root);
-% 
-%     set(hlist,'UserData',rootroot)
-%     if count<10||(nbfiles-count)<10
-%     pause(.5)% wait 0.5 seconds for next check
-%     else
-%         pause(10)% wait 10 seconds for next check
-%     end
-% end
+    [first,ind]=min(datnum);
+    [last,indlast]=max(datnum);
+    message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
+        ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
+end
+hlist=findobj(hfig,'tag','list');
+hmsgbox=findobj(hfig,'tag','msgbox');
+hwaitbar=findobj(hfig,'tag','waitbar');
+set(hlist,'String',Tabchar)
+set(hmsgbox,'String', message)
+if count>0 %&& ~test_new
+    BarPosition(3)=0.9*count/nbfiles;
+    set(hwaitbar,'Position',BarPosition)
+end
+
 
 %------------------------------------------------------------------------   
@@ -1072,12 +1063,16 @@
 path_civ=fileparts(which('civ')); %path to the source directory of uvmat
 xmlfile='PARAM.xml';
+s=[];
 if exist(xmlfile,'file')% search parameter xml file in the whole matlab path
     t=xmltree(xmlfile);
     s=convert(t);
-else
-    errormsg=['no file ' xmlfile];
-    return
-end
-% test_interp=0; %eviter les variables test_ (LG)
+end% default configuration
+if ~isfield(s,'RunParam')
+    s.RunParam.Civ1Bin='bin/civ1';
+    s.RunParam.Civ2Bin='bin/civ2';
+    s.RunParam.FixBin='bin/fix_flag';
+    s.RunParam.PatchBin='bin/patch_up';
+    s.RunParam.CivmBin='bin/civ_matlab';
+end
 if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
     if isfield(s,'BatchParam')
@@ -1091,16 +1086,23 @@
         end
     else
-        errormsg='no batch civ binaries defined in PARAM.xml';
-        return
+        %standard configuration
+        Param.xml.Civ1Bin='bin/civ1';
+        Param.xml.Civ2Bin='bin/civ2';
+        Param.xml.FixBin='bin/fix_flag';
+        Param.xml.PatchBin='bin/patch_up';
+        s.RunParam.CivmBin='bin/civ_matlab';
+        Param.xml.BatchMode='oar';% TODO : allow choice for sge
     end
 else % run
     if isfield(s,'RunParam')
         Param.xml=s.RunParam;
-    else
-        errormsg='no run civ binaries defined in PARAM.xml';
-        return
-    end
-end
-
+    else %standard default configuration
+        s.RunParam.Civ1Bin='bin/civ1';
+        s.RunParam.Civ2Bin='bin/civ2';
+        s.RunParam.FixBin='bin/fix_flag';
+        s.RunParam.PatchBin='bin/patch_up';
+        s.RunParam.CivmBin='bin/civ_matlab';
+    end
+end
 
 %% check if the binaries exist : to move in civ_opening
Index: /trunk/src/find_file_series.m
===================================================================
--- /trunk/src/find_file_series.m	(revision 482)
+++ /trunk/src/find_file_series.m	(revision 483)
@@ -54,16 +54,6 @@
     return % don't go further if the dir path does not exist
 end
-% NbFrame=1;
-% switch FileType
-%     case 'multimage'
-%     NbFrame=FileInfo.NumberOfFrames;
-%     case {'video','mmreader'}
-%     NomType='*';
-%     NbFrame=FileInfo.NumberOfFrames;
-% end 
-
-% RootFile_i='';
 NomTypePref='';
-if strcmp(NomType,'')||strcmp(NomType,'*')
+if isempty(NomType)
     if exist(fullfileinput,'file')
         [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing), get the filename without its extension
@@ -71,8 +61,4 @@
         RootFile='';
     end
-%     i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening
-%     i2_input=[];
-%     j1_input=[];
-%     j2_input=[];
 else
     %% possibly include the first index in the root name, if there exists a corresponding xml file
@@ -224,8 +210,6 @@
         ref_ij=ref_i_list*max_j+ref_j_list; % ordered by index i, then by j for a given i.
     end
-    %[tild,ifile_min]=min(ref_ij(ref_ij>0));
     ind_select=find(ref_ij>0);
     if isempty(ind_select)
-        %         RootPath='';
         RootFile='';
         NomType='';
@@ -252,7 +236,26 @@
         i1_series=(1:FileInfo.NumberOfFrames)';
         i1_input=1;
-    else
-       j1_series=(1:FileInfo.NumberOfFrames)'; 
-       j1_input=1;
+        NomType='*';
+    else
+        j1_series=(1:FileInfo.NumberOfFrames)';
+        %  include the first index in the root name
+        r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
+        if ~isempty(r)
+            fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
+            if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
+                rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
+            else% if a separator '_' is  detected
+                rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
+            end
+            if ~isempty(rr)
+                RootFile=[RootFile rr.i1];% new root file
+                NomTypePref=r.tiretnum;
+                NomType=regexprep(NomType,['^'  NomTypePref],'');
+                i1_input=j1_input;
+                i2_input=j2_input;
+                j1_input=1;
+                j2_input=[];
+            end
+        end
     end
 end
Index: /trunk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 482)
+++ /trunk/src/mouse_up.m	(revision 483)
@@ -244,13 +244,20 @@
     xlim=get(currentaxes,'XLim');
     ylim=get(currentaxes,'YLim');
- % if left mouse button has been pressed, zoom in by a factor of 2
+    % if left mouse button has been pressed, zoom in by a factor of 2
     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
-        xlim(1)=0.5*xy(1,1)+0.5*xlim(1);
-        xlim(2)=0.5*xy(1,1)+0.5*xlim(2);%double the field whith the middle at the selected points
-        set(currentaxes,'XLim',xlim)
-        ylim(2)=0.5*xy(1,2)+0.5*ylim(2);
-        ylim(1)=0.5*xy(1,2)+0.5*ylim(1);
-        set(currentaxes,'YLim',ylim)
- % if right mouse button has been pressed, zoom out by a factor of 2
+        PlotBoxAspectRatio=get(currentaxes,'PlotBoxAspectRatio');
+        yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1);
+        if yoverx <2
+            xlim(1)=0.5*xy(1,1)+0.5*xlim(1);
+            xlim(2)=0.5*xy(1,1)+0.5*xlim(2);%double the field whith the middle at the selected points
+            set(currentaxes,'XLim',xlim)
+        end
+        if yoverx >0.5
+            ylim(2)=0.5*xy(1,2)+0.5*ylim(2);
+            ylim(1)=0.5*xy(1,2)+0.5*ylim(1);
+            set(currentaxes,'YLim',ylim)
+        end
+        
+        % if right mouse button has been pressed, zoom out by a factor of 2
     else
         xlim(1)=2*xlim(1)-xy(1,1);% reverse of the zoom on action
@@ -267,5 +274,5 @@
                 ylim=AxeData.RangeY;
             end
-         % desactivate the zoom if the full field is visible within the axes
+            % desactivate the zoom if the full field is visible within the axes
             if isequal(xlim,AxeData.RangeX) && isequal(ylim,AxeData.RangeY)
                 set(hhuvmat.CheckZoom,'Value',0)
@@ -323,7 +330,7 @@
 %% finalising ruler
 if test_ruler
-    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat  
-    xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates 
-    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates 
+    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
+    xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates
+    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates
     RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning
     RulerCoord=RulerCoord(1)+i*RulerCoord(2);
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 482)
+++ /trunk/src/uvmat.m	(revision 483)
@@ -3084,14 +3084,7 @@
 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
-% NomTypeNew=NomType;%default
 if isequal(field,'image')
-%     if isequal(NomType,'_1-2_1')||isequal(NomType,'_1_1-2')
-%         NomTypeNew='_1_1';
-%     elseif isequal(NomType,'#_ab')
-%         NomTypeNew='#a';
-%     elseif isequal(NomType,'_1-2')
-%         NomTypeNew='_1';
-%     end
-    imagename=fullfile_uvmat(RootPath,SubDir,RootFile,'.png',NomType,i1,[],j1,[]);
+    SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
+    imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     if ~exist(imagename,'file')
         [FileName,PathName] = uigetfile( ...
@@ -3197,5 +3190,6 @@
     case 'image'
         % guess the image name corresponding to the current netcdf name (no unique correspondance)
-        imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
+        SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
+        imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
         if ~exist(imagename,'file') % browse for images if it is not found
             [FileName,PathName] = uigetfile( ...
