Changeset 595


Ignore:
Timestamp:
Mar 29, 2013, 9:03:29 PM (12 years ago)
Author:
sommeria
Message:

steps further to use series with cluster. Some bsolete functions removed

Location:
trunk/src
Files:
3 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r591 r595  
    41254125    case {'civ_matlab','civ_matlab.sh'}
    41264126        filename=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml');
     4127        fileattrib(fileparts(filename),'+w +x','o g');% set writting access
    41274128        save(struct2xml(Param),filename);
    41284129end
  • trunk/src/editxml.m

    r508 r595  
    340340    schemafile=[fullfile(path_uvmat,'xml_shemas',head_name) '.xsd'];
    341341    if ~exist(schemafile,'file')
    342         schemafile=fullfile(path_UVMAT,schemafile);%look for relative path definition
     342        schemafile=fullfile(path_uvmat,schemafile);%look for relative path definition
    343343    end
    344344    if exist(schemafile,'file')
    345345        xs=xmltree(schemafile);
    346346    else
    347         msgbox_uvmat('ERROR',['The needed xml schema  ' sparam.SchemaPath ' is not found, check the file PARAM.xml'])
     347        msgbox_uvmat('WARNING','The xml schema is not found, check the file PARAM.xml')
    348348        [FileName, PathName]=uigetfile( ...
    349349            {'*.xsd', '(*.xsd)';
     
    12951295return
    12961296%%%%%%%%%%% A REVOIR
    1297 % Copier la liste des elements selectionnés dans dataview
     1297% Copier la liste des elements selectionnï¿œs dans dataview
    12981298%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    12991299%ANCIEN:
  • trunk/src/get_file_type.m

    r549 r595  
    1717% fileinput: name, including path, of the file to analyse
    1818function [FileType,FileInfo,VideoObject]=get_file_type(fileinput)
    19 FileType='';
     19FileType='txt';%default, text file
    2020FileInfo=[];
    2121VideoObject=[];
     
    2323
    2424switch FileExt
    25     case {'.civ','.log','.cmx','.cmx2','.txt','.bat','.m','.sh'}
    26         FileType='txt';
    2725    case '.fig'
    2826        FileType='figure';
  • trunk/src/nomtype2pair.m

    r107 r595  
    1 %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature
     1%'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature, used by series fct
    22%---------------------------------------------------------------------
    3 % [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj);
     3% NomTypeOut=nomtype2pair(NomTypeIn)
    44%---------------------------------------------------------------------           
    5 
    65% OUTPUT:
    7 %nom_type_nc
    8 
     6% NomTypeOut: file index nomenclature for pairs
    97%---------------------------------------------------------------------
    108% INPUT:
    11 % 'nom_type': string defining the kind of nomenclature used:
    12      %nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
    13      %nom_type='*': the same  file [filebase ext] contains successive fields (ex avi movies)
    14      %nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
    15      %nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
    16      %nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
    17      %nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc')
    18      %nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
    19      %nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc')
    20      %nom_type='#a','#A', with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
    21      %nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
    22      %nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
    23      %nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE
    24      %nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
    25      %nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
    26 % Dti: ~=0 if i index pairs are used
    27 % Dtj: ~=0 if i index pairs are used
     9% NomTypeIn: file index nomenclature for images
     10%
     11% for definitions of file index nomenclature, see fct fullfile_uvmat
    2812
    29 function [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj)
     13function NomTypeOut=nomtype2pair(NomTypeIn)
    3014
    31 %determine nom_type_nc:
    32 nom_type_pair=[];%default
    33 if ischar(nom_type)
    34     switch nom_type
    35         case {'_i_j'}
    36             if Dtj>0 || Dtj<0
    37                 nom_type_pair='_i_j1-j2';
    38                 if Dti>0 || Dti<0
    39                     nom_type_pair='_i1-i2_j1-j2';
    40                 end
    41                 elseif Dti>0 || Dti<0
    42                 nom_type_pair='_i1-i21_j';   
    43             else
    44                  nom_type_pair='_i_j';
    45             end
    46         case {'_i1-i2_j'}
    47             if Dtj>0 || Dtj<0
    48                nom_type_pair='_i1-i2_j1-j2';
    49             else
    50                 nom_type_pair='_i1-i2_j';
    51             end
    52         case {'i_j1-j2'}
    53             if Dti>0 || Dti<0
    54                nom_type_pair='_i1-i2_j1-j2';
    55             else
    56                 nom_type_pair='_i1-i2_j';
    57             end
    58         case {'i1-i2_j1-j2'}
    59              nom_type_pair='_i1-i2_j1-j2';
    60         case '#a'
    61             if Dtj>0 || Dtj<0
    62                 nom_type_pair='#_ab';
    63             end
    64         otherwise
    65             if Dti>0 || Dti<0
    66                nom_type_pair='_i1-i2';
    67             end
     15if ~isempty(regexp(NomTypeIn,'a$'))
     16    NomTypeOut=[NomTypeIn 'b'];
     17elseif ~isempty(regexp(NomTypeIn,'A$'))
     18    NomTypeOut=[NomTypeIn 'B'];
     19else
     20    r=regexp(NomTypeIn,'(?<num1>\d+)_(?<num2>\d+)$','names');
     21    % case of a single input index (no j)
     22    if isempty(r)
     23        NomTypeOut='_1-2';
     24    else  % case of two indices i,j, separated by '_'
     25        NomTypeOut='_1-2_1-2';
    6826    end
    6927end
  • trunk/src/proj_field.m

    r589 r595  
    828828%                 coord_x_proj=XMin:DX:XMax;
    829829%                 coord_y_proj=YMin:DY:YMax;
    830                 DataOut=calc_field(FieldData.FieldList,FieldData,cat(3,xreg,yreg));
     830                DataOut=calc_field_tps(FieldData.FieldList,FieldData,cat(3,xreg,yreg));
    831831                ProjData.ListVarName=[ProjData.ListVarName DataOut.ListVarName];
    832832                ProjData.VarDimName=[ProjData.VarDimName DataOut.VarDimName];
     
    14941494                        eval(['ProjData.' VarName '=reshape(vec_B,npY,npX,nbcolor);']);
    14951495                    end
    1496                     ProjData.FF=reshape(~flagin,npY,npX);%false flag A FAIRE: tenir compte d'un flga antérieur
     1496                    ProjData.FF=reshape(~flagin,npY,npX);%false flag A FAIRE: tenir compte d'un flga antï¿œrieur
    14971497                    ProjData.ListVarName=[ProjData.ListVarName 'FF'];
    14981498                    ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
     
    21082108                    eval(['ProjData.' VarName '=reshape(vec_B,npY,npX,nbcolor);']);
    21092109                end
    2110                 ProjData.FF=reshape(~flagin,npY,npX);%false flag A FAIRE: tenir compte d'un flga antérieur 
     2110                ProjData.FF=reshape(~flagin,npY,npX);%false flag A FAIRE: tenir compte d'un flga antï¿œrieur 
    21112111                ProjData.ListVarName=[ProjData.ListVarName 'FF'];
    21122112                ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
  • trunk/src/read_field.m

    r580 r595  
    8787            Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected)
    8888        end
    89         [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y)' ListVar]);
     89        [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]);
    9090        if isfield(Field,'Txt')
    9191            errormsg=Field.Txt;
  • trunk/src/series.m

    r594 r595  
    899899        end
    900900        FileName=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1_series(1,ref_j+1,ref_i+1),i2,j1,j2);
    901         hget_field=get_field(FileName);
    902         hhget_field=guidata(hget_field);
    903         get_field('RUN_Callback',hhget_field.RUN,[],hhget_field);
     901%         hget_field=get_field(FileName);
     902%         hhget_field=guidata(hget_field);
     903%         get_field('RUN_Callback',hhget_field.RUN,[],hhget_field);
    904904    otherwise
    905905        set(handles.FieldName,'Value',1) % set menu to 'image'
     
    13031303function RUN_Callback(hObject, eventdata, handles)
    13041304%------------------------------------------------------------------------
     1305
    13051306set(handles.RUN,'BusyAction','queue');
    13061307set(0,'CurrentFigure',handles.series)
     
    13081309set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    13091310drawnow
    1310 [Series,filexml,errormsg]=prepare_jobs(handles);
     1311
     1312%% read the input parameters and set the output dir and nomenclature
     1313[Series,OutputDir,errormsg]=prepare_jobs(handles);% get parameters form the GUI series
    13111314if ~isempty(errormsg)
    13121315    msgbox_uvmat('ERROR',errormsg)
    13131316    return
    13141317end
     1318OutputNomType=nomtype2pair(Series.InputTable{1,4});% nomenclature for output files
     1319DirXml=fullfile(OutputDir,'0_XML');
     1320if ~exist(DirXml,'dir')
     1321    [tild,msg1]=mkdir(DirXml);
     1322    if ~strcmp(msg1,'')
     1323        msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation
     1324        return
     1325    end
     1326end
     1327
     1328%% select the Action modes
    13151329RunModeList=get(handles.RunMode,'String');
    13161330RunMode=RunModeList{get(handles.RunMode,'Value')};
    1317 ActionExtList=get(handles.ActionExt,'String');
    1318 ActionExt=ActionExtList{get(handles.ActionExt,'Value')};% '.m' or '.sh' (compiled)
    1319 ActionPath=get(handles.ActionPath,'String');
    1320 ActionList=get(handles.ActionName,'String');
    1321 ActionName=ActionList{get(handles.ActionName,'Value')};
     1331ActionExt='.m';%default
     1332if isfield(Series.Action,'ActionExt')
     1333    ActionExt=Series.Action.ActionExt;% '.m' or '.sh' (compiled)
     1334end
     1335ActionName=Series.Action.ActionName;
     1336ActionPath=Series.Action.ActionPath;
    13221337path_series=fileparts(which('series'));
    13231338
    1324 % create the Action fct handle if RunMode option = 'local'
     1339%% create the Action fct handle if RunMode option = 'local'
    13251340if strcmp(RunMode,'local')
    13261341    if ~isequal(ActionPath,path_series)
     
    13731388    Series.RunTime=RunTime;
    13741389end
    1375    
    1376 %% set nbre of processes
    1377 if ~isfield(Series,'NbSlice')
    1378     Series.NbSlice=[];
    1379 end
    1380 if isempty(Series.NbSlice)
    1381     switch RunMode
    1382         case {'local','background'}
    1383          NbCore=1;% no need to split the calculation
    1384         case 'cluster'
    1385             if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
    1386                 NbCore=1;% one core used only (limitation of Matlab licences)
    1387                 msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
    1388             else
     1390
     1391%% set nbre of cluster cores and processes
     1392switch RunMode
     1393    case {'local','background'}
     1394        NbCore=1;% no need to split the calculation
     1395    case 'cluster_oar'
     1396        if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
     1397            NbCore=1;% one core used only (limitation of Matlab licences)
     1398            msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
     1399            extra_oar='';
     1400        else
    13891401            answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
    13901402            NbCore=str2double(answer{1});
    1391             end
    1392     end
     1403            extra_oar=answer{2};
     1404        end
     1405end
     1406if ~isfield(Series.IndexRange,'NbSlice')
     1407    Series.IndexRange.NbSlice=[];
     1408end
     1409if isempty(Series.IndexRange.NbSlice)
    13931410    NbProcess=NbCore;% choose one process per core
    13941411else
    1395     NbProcess=Series.NbSlice;% the nbre of run processes is equal to the number of slices
     1412    NbProcess=Series.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices
     1413    NbCore=min(NbCore,NbProcess);% at least one process per core
    13961414end
    13971415
     
    14021420first_j=1;
    14031421last_j=1;
    1404 incr_j=1;
    14051422if isfield(Series.IndexRange,'first_i')
    14061423    first_i=Series.IndexRange.first_i;
     
    14131430end
    14141431if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    1415     set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return
     1432        set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return
    14161433else
    14171434    BlockLength=ceil(numel(first_i:incr_i:last_i)/NbProcess);
    14181435end
    14191436
    1420 %% main processing
    1421 for iprocess=1:NbProcess% TOD0
    1422 %     split the input files
    1423 %     adjust Param
    1424 %     create xmlfile and batfile
    1425 end
     1437%% direct processing on the current Matlab session
     1438if strcmp (RunMode,'local')
     1439    Series.RUNHandle=handles.RUN;
     1440    Series.WaitbarHandle=handles.Waitbar;
     1441    for iprocess=1:NbProcess
     1442        if isempty(Series.IndexRange.NbSlice)
     1443            Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength;
     1444            Series.IndexRange.last_i=first_i+(iprocess)*BlockLength-1;
     1445        else
     1446            Series.IndexRange.first_i= first_i+iprocess-1;
     1447            Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice;
     1448        end
     1449        t=struct2xml(Series);
     1450        t=set(t,1,'name','Series');
     1451        filexml=fullfile_uvmat(DirXml,'',Series.InputTable{1,3},'.xml',OutputNomType,...
     1452            Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1453        save(t,filexml);
     1454        switch ActionExt
     1455            case '.m'
     1456                h_fun(Series);
     1457            case '.sh'
     1458                switch computer
     1459                    case {'PCWIN','PCWIN64'} %Windows system
     1460                        filexml=regexprep(filexml,'\\','\\\\');% add '\' so that '\' are left as characters
     1461                        system([fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml]);% TODO: adapt to DOS system
     1462                    case {'GLNX86','GLNXA64','MACI64'}%Linux  system
     1463                        system([fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml]);
     1464                end
     1465        end
     1466    end
     1467elseif strcmp(get(handles.OutputDirExt,'Visible'),'off')
     1468    msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option
     1469    return
     1470else
     1471    %% processing on a different session of the same computer (background) or cluster, create executable files
     1472    batch_file_list=cell(NbProcess,1);% initiate the list of executable files
     1473    DirBat=fullfile(OutputDir,'0_BAT');
     1474    %create subdirectory for executable files
     1475    if ~exist(DirBat,'dir')
     1476        [tild,msg1]=mkdir(DirBat);
     1477        if ~strcmp(msg1,'')
     1478            msgbox_uvmat('ERROR',['cannot create ' DirBat ': ' msg1]);%error message for directory creation
     1479            return
     1480        end
     1481    end
     1482    %create subdirectory for log files
     1483    DirLog=fullfile(OutputDir,'0_LOG');
     1484    if ~exist(DirLog,'dir')
     1485        [tild,msg1]=mkdir(DirLog);
     1486        if ~strcmp(msg1,'')
     1487            msgbox_uvmat('ERROR',['cannot create ' DirLog ': ' msg1]);%error message for directory creation
     1488            return
     1489        end
     1490    end
     1491    for iprocess=1:NbProcess
     1492        if isempty(Series.IndexRange.NbSlice)% process by blocks of i index
     1493            Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength;
     1494            Series.IndexRange.last_i=first_i+(iprocess)*BlockLength-1;
     1495        else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1
     1496            Series.IndexRange.first_i= first_i+iprocess-1;
     1497            Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice;
     1498        end
     1499       
     1500        % create, fill and save the xml parameter file
     1501        t=struct2xml(Series);
     1502        t=set(t,1,'name','Series');
     1503        filexml=fullfile_uvmat(DirXml,'',Series.InputTable{1,3},'.xml',OutputNomType,...
     1504            Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1505        save(t,filexml);% save the parameter file
     1506       
     1507        %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);
     1510        batch_file_list{iprocess}=filebat;
     1511        [fid,message]=fopen(filebat,'w');% create the executable file
     1512        if isequal(fid,-1)
     1513            msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
     1514            return
     1515        end
     1516       
     1517        % set the log file name
     1518        filelog=fullfile_uvmat(DirLog,'',Series.InputTable{1,3},'.log',OutputNomType,...
     1519            Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1520       
     1521        % fill and save the executable file
     1522        switch ActionExt
     1523            case '.m'% Matlab function
     1524                switch computer
     1525                    case {'GLNX86','GLNXA64','MACI64'}
     1526                        cmd=[...
     1527                            '#!/bin/bash \n'...
     1528                            '. /etc/sysprofile \n'...
     1529                            'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
     1530                            'addpath(''' path_series '''); \n'...
     1531                            'addpath(''' Series.Action.ActionPath '''); \n'...
     1532                            '' Series.Action.ActionName  '( ''' filexml '''); \n'...
     1533                            'exit \n'...
     1534                            'END_MATLAB \n'];
     1535                        fprintf(fid,cmd);%fill the executable file with the  char string cmd
     1536                        fclose(fid);% close the executable file
     1537                        system(['chmod +x ' filebat]);% set the file to executable
     1538                    case {'PCWIN','PCWIN64'}
     1539                        text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')...
     1540                            ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
     1541                            'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'...
     1542                            '' Series.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
     1543                        fprintf(fid,text_matlabscript);%fill the executable file with the  char string cmd
     1544                        fclose(fid);% close the executable file
     1545                end
     1546            case '.sh' % compiled Matlab function
     1547                switch computer
     1548                    case {'GLNX86','GLNXA64','MACI64'}
     1549                        cmd=['#!/bin/bash \n '...
     1550                            '#$ -cwd \n '...
     1551                            'hostname && date \n '...
     1552                            'umask 002 \n'...
     1553                            fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml];%allow writting access to created files for user group
     1554                        fprintf(fid,cmd);%fill the executable file with the  char string cmd
     1555                        fclose(fid);% close the executable file
     1556                        system(['chmod +x ' filebat]);% set the file to executable
     1557                       
     1558                    case {'PCWIN','PCWIN64'}    %       TODO: adapt to Windows system
     1559                        %                                 cmd=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')...
     1560                        %                                     ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
     1561                        %                                     'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'...
     1562                        %                                     '' Series.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
     1563                        fprintf(fid,cmd);
     1564                        fclose(fid);
     1565                        %                               dos([filebat ' &']);
     1566                end
     1567        end
     1568    end
     1569end
     1570
     1571%% launch the executable files for background or cluster processing
    14261572switch RunMode
    1427     case 'local'
    1428         Series.RUNHandle=handles.RUN;
    1429         Series.WaitbarHandle=handles.Waitbar;
     1573    case 'background'
    14301574        for iprocess=1:NbProcess
    1431             if isempty(Series.NbSlice)
    1432                 Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength;
    1433                 Series.IndexRange.last_i=first_i+(iprocess)*BlockLength-1;
    1434             else
    1435                 Series.IndexRange.first_i= first_i+iprocess-1;
    1436                 Series.IndexRange.incr_i=incr_i*Series.NbSlice;
    1437             end
    1438             if ~isempty(filexml)
    1439                 t=struct2xml(Series);
    1440                 t=set(t,1,'name','Series');
    1441                 if isequal(Series.IndexRange.last_i,Series.IndexRange.first_i)
    1442                     term_i=num2str(Series.IndexRange.first_i);
    1443                 else
    1444                     term_i=[num2str(Series.IndexRange.first_i) '-' num2str(Series.IndexRange.last_i)];
    1445                 end
    1446                 if isequal(Series.IndexRange.last_j,Series.IndexRange.first_j)
    1447                     term_j=num2str(Series.IndexRange.first_j);
    1448                 else
    1449                     term_j=[num2str(Series.IndexRange.first_j) '-' num2str(Series.IndexRange.last_j)];
    1450                 end
    1451                 save(t,[filexml '_' term_i '_' term_j '.xml']);
    1452             end
    1453             switch ActionExt
    1454                 case '.m'
    1455                     h_fun(Series);
    1456                 case '.sh'
    1457                     switch computer
    1458                         case {'PCWIN','PCWIN64'} %Windows system
    1459                             filename=regexprep(filename,'\\','\\\\');% add '\' so that '\' are left as characters
    1460                             % TODO launch command in DOS
    1461                         case {'GLNX86','GLNXA64','MACI64'}%Linux  system
    1462 %                             cmd=['#!/bin/bash \n '...
    1463 %                                 '#$ -cwd \n '...
    1464 %                                 'hostname && date \n '...
    1465 %                                 'umask 002 \n'...
    1466 %                                 fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml '_' term_i '_' term_j '.xml'];%allow writting access to created files for user group
    1467                              system([fullfile(ActionPath,[ActionName '.sh']) ' ' Series.RunTime ' ' filexml '_' term_i '_' term_j '.xml']);
    1468                     end
    1469             end
    1470         end
    1471     case 'background'
    1472         if isempty(filexml)
    1473             Series=h_fun(Series);% no background in the absence of output file
    1474         else
    1475             % update the xml file after interactive input with the function
    1476 %             Series.Specific='?';
    1477 %             Series=h_fun(Series);
    1478             t=struct2xml(Series);
    1479             t=set(t,1,'name','Series');
    1480             save(t,filexml);
    1481            
    1482             filename_bat=regexprep(filexml,'.xml$','.bat');% create executable file to run program in background
    1483             [fid,message]=fopen(filename_bat,'w');
    1484             if isequal(fid,-1)
    1485                 msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
     1575            system(batch_file_list{iprocess})% directly execute the command file for each process
     1576        end
     1577    case 'cluster_oar' % option 'oar-parexec' used
     1578        %create subdirectory for oar command and log files
     1579        DirOAR=fullfile(OutputDir,'0_OAR');
     1580        if ~exist(DirOAR,'dir')
     1581            [tild,msg1]=mkdir(DirOAR);
     1582            if ~strcmp(msg1,'')
     1583                msgbox_uvmat('ERROR',['cannot create ' DirOAR ': ' msg1]);%error message for directory creation
    14861584                return
    14871585            end
    1488             %ActionPath=get(handles.ActionPath,'String');
    1489             filelog=regexprep(filexml,'.xml$','.log');
    1490        
    1491             switch computer
    1492                 case {'GLNX86','GLNXA64','MACI64'}
    1493                     text_matlabscript=[...
    1494                         '#!/bin/bash \n'...
    1495                         '. /etc/sysprofile \n'...
    1496                         'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
    1497                         'addpath(''' path_series '''); \n'...
    1498                         'addpath(''' Series.Action.ActionPath '''); \n'...
    1499                         '' Series.Action.ActionName  '( ''' filexml '''); \n'...
    1500                         'exit \n'...
    1501                         'END_MATLAB \n'];
    1502                     fprintf(fid,text_matlabscript);
    1503                     fclose(fid);
    1504                     system(['chmod +x ' filename_bat]);% set the file to executable
    1505                     system(['. ' filename_bat ' &']);%execute fct
    1506                    
    1507                 case {'PCWIN','PCWIN64'}
    1508                     text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')...
    1509                         ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
    1510                         'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'...
    1511                         '' Series.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
    1512                     fprintf(fid,text_matlabscript);
    1513                     fclose(fid);
    1514                     dos([filename_bat ' &']);
    1515             end
    1516         end
    1517         update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
    1518      case 'cluster' %NOT YET READY
    1519         switch batch_mode
    1520             case 'sge' %at the moment only psmn ENS Lyon uses it
    1521                 for p=1:length(batch_file_list)
    1522                     cmd=['!qsub -q piv1,piv2,piv3 '...
    1523                         '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')...
    1524                         ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}];
    1525                     display(cmd);eval(cmd);
    1526                 end
    1527             case 'oar'
    1528                 max_walltime=3600*12; % 12h max
    1529                 oar_modes={'oar-parexec','oar-dispatch','mpilauncher'};
    1530                 text={'Batch processing on servcalcul3 LEGI';...
    1531                     'Please choose one of the followint modes';...
    1532                     '* oar-parexec : default and best choice';...
    1533                     '* oar-dispatch : jobs in a container of several cores';...
    1534                     '* mpilauncher : one single parallel mpi job using several cores';...
    1535                     '**********************************'...
    1536                     };
    1537                 [S,v]=listdlg('PromptString',text,'ListString',oar_modes,...
    1538                     'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode');
    1539                 switch oar_modes{S}
    1540                     case 'oar-parexec' %oar-dispatch.pl
    1541 %                         if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
    1542 %                             ncores=1;% one core used only (limitation of Matlab licences)
    1543 %                             msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
    1544 %                         else
    1545 %                         answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
    1546 %                         ncores=str2double(answer{1});
    1547 %                         end
    1548 
    1549                         extra_oar=answer{2};
    1550                         walltime_onejob=600;%seconds
    1551                         filename_joblist=fullfile(RootBat,'job_list.txt');
    1552                         fid=fopen(filename_joblist,'w');
    1553                         for p=1:length(batch_file_list)
    1554                             fprintf(fid,[batch_file_list{p} '\n']);% list of exe files (TODO: create them)
    1555                         end
    1556                         fclose(fid);
    1557                         oar_command=['oarsub -n CIVX '...
    1558                             '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
    1559                             '-l /core=' num2str(ncores) ','...
    1560                             'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '...
    1561                             '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
    1562                             '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
    1563                             extra_oar ' '...
    1564                             '"oar-parexec -s -f ' filename_joblist ' '...
    1565                             '-l ' filename_joblist '.log"\n'];
    1566                         filename_oarcommand=fullfile(RootBat,'oar_command');
    1567                         fid=fopen(filename_oarcommand,'w');
    1568                         fprintf(fid,oar_command);
    1569                         fclose(fid);
    1570                         fprintf(oar_command);% display in command line
    1571                         system(oar_command);
    1572                     case 'oar-dispatch' %oar-dispatch.pl
    1573                         ncores=str2double(...
    1574                             inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})...
    1575                             );
    1576                         walltime_onejob=600;%seconds
    1577                         filename_joblist=fullfile(RootBat,'job_list.txt');
    1578                         fid=fopen(filename_joblist,'w');
    1579                         for p=1:length(batch_file_list)
    1580                             oar_command=['oarsub -n CIVX '...
    1581                                 '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')...
    1582                                 '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '"   ' batch_file_list{p}];
    1583                             fprintf(fid,[oar_command '\n']);
    1584                         end
    1585                         fclose(fid);
    1586                         oar_command=['oarsub -t container -n civx-container '...
    1587                             '-l /core=' num2str(ncores)...
    1588                             ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '...
    1589                             '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
    1590                             '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
    1591                             '"oar-dispatch -f ' filename_joblist '"'];
    1592                         filename_oarcommand=fullfile(RootBat,'oar_command');
    1593                         fid=fopen(filename_oarcommand,'w');
    1594                         fprintf(fid,[oar_command '\n']);
    1595                         fclose(fid);
    1596                         display(oar_command);
    1597                         eval(['! . ' filename_oarcommand])
    1598                     case 'mpilauncher'
    1599                         filename_joblist=fullfile(RootBat,'job_list.txt');
    1600                         fid=fopen(filename_joblist,'w');
    1601                        
    1602                         for p=1:length(batch_file_list)
    1603                             fprintf(fid,[batch_file_list{p} '\n']);
    1604                         end
    1605                         fclose(fid)
    1606                         text_oarscript=[...
    1607                             '#!/bin/bash \n'...
    1608                             '#OAR -n Mylauncher \n'...
    1609                             '#OAR -l node=4/core=5,walltime=0:15:00 \n'...
    1610                             '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'...
    1611                             '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'...
    1612                             '# ========================================================= \n'...
    1613                             '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'...
    1614                             '# application for coriolis PIV post-processing. \n'...
    1615                             '# OAR uses oarshmost wrapper to propagate the user environement. \n'...
    1616                             '# This wrapper assert that the user has the same environment on all the \n'...
    1617                             '# allocated nodes (basic behavior needed by most MPI applications).  \n'...
    1618                             '# \n'...
    1619                             '# REQUIREMENT: \n'...
    1620                             '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'...
    1621                             '# If a different location is used, change the line following the comment "Bidouille" \n'...
    1622                             '# ========================================================= \n'...
    1623                             '#   USER should only modify these 2 lines  \n'...
    1624                             'WORKDIR=' pwd ' \n'...
    1625                             'COMMANDE="mpilauncher  -f ' filename_joblist '" \n'...
    1626                             '# ========================================================= \n'...
    1627                             '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'...
    1628                             'echo "job starting on: "`hostname` \n'...
    1629                             'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'...
    1630                             'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'...
    1631                             '#========== Bidouille ============== \n'...
    1632                             'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...%                     'cd $WORKDIR \n'...
    1633                             'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'...
    1634                             'echo "I run: $CMD"  \n'...
    1635                             '$CMD \n'...
    1636                             'echo "job ending" \n'...
    1637                             ];
    1638                         filename_oarscript=fullfile(RootBat,'oar_command');
    1639                         fid=fopen(filename_oarscript,'w');
    1640                         fprintf(fid,[text_oarscript]);
    1641                         fclose(fid);
    1642                         eval(['!chmod +x  ' filename_oarscript]);
    1643                         eval(['!oarsub -S ' filename_oarscript]);
    1644                 end
    1645         end
    1646 end
    1647 
     1586        end
     1587        max_walltime=3600*12; % 12h max
     1588        walltime_onejob=600;%seconds
     1589        filename_joblist=fullfile(DirOAR,'job_list.txt');%create name of the global executable file
     1590        fid=fopen(filename_joblist,'w');
     1591        for p=1:length(batch_file_list)
     1592            fprintf(fid,[batch_file_list{p} '\n']);% list of exe files (TODO: create them)
     1593        end
     1594        fclose(fid);
     1595        system(['chmod +x ' filename_joblist]);% set the file to executable
     1596        oar_command=['oarsub -n CIVX '...
     1597            '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
     1598            '-l /core=' num2str(NbCore) ','...
     1599            'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),NbCore)/NbCore,max_walltime/86400),13) ' '...
     1600            '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
     1601            '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
     1602            extra_oar ' '...
     1603            '"oar-parexec -s -f ' filename_joblist ' '...
     1604            '-l ' filename_joblist '.log"\n'];
     1605        filename_oarcommand=fullfile(DirOAR,'oar_command');
     1606        fid=fopen(filename_oarcommand,'w');
     1607        fprintf(fid,oar_command);
     1608        fclose(fid);
     1609        fprintf(oar_command);% display in command line
     1610        %system(['chmod +x ' oar_command]);% set the file to executable
     1611        system(oar_command);     
     1612end
     1613
     1614%% reset the GUI series
     1615update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
    16481616set(handles.RUN, 'Enable','On')
    16491617set(handles.RUN,'BackgroundColor',[1 0 0])
     
    16711639% --- Main launch command, called by RUN and BATCH
    16721640
    1673 function [Series,filexml,errormsg]=prepare_jobs(handles)
     1641function [Series,OutputDir,errormsg]=prepare_jobs(handles)
    16741642%INPUT:
    16751643% handles: handles of graphic objects on the GUI series
    1676 % run=0, just to display parameters for MenuExport/GUI config
    1677 % run=1 (default) prepare the computation
    1678 
    1679 %------------------------------------------------------------------------
    1680 filexml='';
     1644
     1645%------------------------------------------------------------------------
     1646OutputDir='';
    16811647errormsg='';
    16821648
    16831649%% Read parameters from series
    16841650Series=read_GUI(handles.series);
    1685 if isfield(Series,'Pairs')
    1686     Series=rmfield(Series,'Pairs'); %info Pairs not needed for output
    1687 end
    1688 
    1689 
    1690 %% projection object
    1691 % if isfield(Series,'CheckObject')
    1692 %     if Series.CheckObject
    1693 %         hset_object=findobj(allchild(0),'tag','set_object');
    1694 %         Series.ProjObject=read_GUI(hset_object);
    1695 %         CheckObject_Callback([], [], handles)
    1696 %     end
    1697 % else
    1698 %     Series.CheckObject=0;
    1699 % end
    17001651
    17011652%% get_field GUI
    1702 if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field')
    1703     if strcmp(Series.InputFields.Field,'get_field...')
    1704         hget_field=findobj(allchild(0),'name','get_field');
    1705         Series.GetField=read_GUI(hget_field);
    1706     end
    1707 end
    1708 
    1709 %% defining the ActionName function handle
    1710 % list_action=get(handles.ActionName,'String');% list menu action
    1711 % index=get(handles.ActionName,'Value');
    1712 % action= list_action{index}; % selected string
    1713 % %Series.hseries=handles.series; % handles to the series GUI
    1714 % path_series=which('series');
    1715 % ActionPathList=get(handles.ActionName,'UserData');
    1716 % ActionPath=ActionPathList{index}; %path stored for the function ACTION
    1717 % if ~isequal(ActionPath,path_series)
    1718 %     eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION
    1719 %     if ~exist(ActionPath,'dir')
    1720 %         errormsg=['The prescribed function path ' ActionPath ' does not exist'];
    1721 %         return
    1722 %     end
    1723 %     if ~isequal(spath,ActionPath)
    1724 %         addpath(ActionPath)% add the prescribed path if not the current one
     1653% if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field')
     1654%     if strcmp(Series.InputFields.Field,'get_field...')
     1655%         hget_field=findobj(allchild(0),'name','get_field');
     1656%         Series.GetField=read_GUI(hget_field);
    17251657%     end
    17261658% end
    1727 % eval(['h_fun=@' action ';'])%create a function handle for ACTION
    1728 % if ~isequal(ActionPath,path_series)
    1729 %         rmpath(ActionPath)% add the prescribed path if not the current one   
    1730 % end
    1731 
    1732 %% create the output data directory and write in it the xml file from the GUI config
     1659
     1660%% create the output data directory
    17331661%determine the root file corresponding to the first sub dir
    17341662if get(handles.RUN,'value') && isfield(Series,'OutputSubDir')
    17351663    SubDirOut=[get(handles.OutputSubDir,'String') Series.OutputDirExt];
    17361664    SubDirOutNew=SubDirOut;
    1737     iview=1;
    17381665    SeriesData=get(handles.series,'UserData');
    17391666    if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort
     
    17621689    Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output
    17631690    set(handles.OutputDirExt,'String',Series.OutputDirExt)
    1764     % create output directory
    1765     OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]);
    1766     if check_create
     1691    OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]);% full name (with path) of output directory
     1692    if check_create    % create output directory if it does not exist
    17671693        [tild,msg1]=mkdir(OutputDir);
    17681694        if ~strcmp(msg1,'')
     
    17711697        end
    17721698    end
    1773     filexml=fullfile(OutputDir,Series.InputTable{1,3});% name of the parameter xml file set in this directory
    1774 end
    1775 %removes redondant information
     1699   % RootOut=fullfile(OutputDir,Series.InputTable{1,3});% name of the parameter xml file set in this directory
     1700end
     1701
     1702%% removes unused information on Series
     1703if isfield(Series,'Pairs')
     1704    Series=rmfield(Series,'Pairs'); %info Pairs not needed for output
     1705end
    17761706Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
    17771707Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
    17781708Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
    1779 %removes empty lines of InputTable
    17801709empty_line=false(size(Series.InputTable,1),1);
    17811710for iline=1:size(Series.InputTable,1)
     
    20872016field_index=get(handles.FieldName,'Value');
    20882017field=field_str{field_index(1)};
    2089 if isequal(field,'get_field...')   
    2090      hget_field=findobj(allchild(0),'name','get_field');
    2091      if ~isempty(hget_field)
    2092          delete(hget_field)%delete opened versions of get_field
    2093      end
    2094      filecell=get_file_series(read_GUI(handles.series));
    2095      if exist(filecell{1,1},'file')
    2096         get_field(filecell{1,1})
    2097      end
    2098 elseif isequal(field,'more...')
    2099     str=calc_field;
    2100     [ind_answer,v] = listdlg('PromptString','Select a file:',...
    2101                 'SelectionMode','single',...
    2102                 'ListString',str);
    2103        % edit the choice in the fields and actionname menu
    2104      scalar=cell2mat(str(ind_answer));
    2105      update_menu(handles.FieldName,scalar)
     2018if isequal(field,'get_field...')
     2019    hget_field=findobj(allchild(0),'name','get_field');
     2020    if ~isempty(hget_field)
     2021        delete(hget_field)%delete opened versions of get_field
     2022    end
     2023    Series=read_GUI(handles.series);
     2024    Series.InputTable=Series.InputTable(1,:);
     2025    filecell=get_file_series(Series);
     2026    if exist(filecell{1,1},'file')
     2027        GetFieldData=get_field(filecell{1,1});
     2028        FieldList={};
     2029        XName=GetFieldData.XVarName;
     2030        if GetFieldData.CheckVector
     2031            UName=GetFieldData.PanelVectors.vector_x;
     2032            VName=GetFieldData.PanelVectors.vector_y;
     2033            XName=GetFieldData.XVarName;
     2034            YName=GetFieldData.YVarName;
     2035            CName=GetFieldData.PanelVectors.vec_color;
     2036            [FieldList,VecColorList]=set_field_list(UName,VName,CName);
     2037        elseif GetFieldData.CheckScalar
     2038            AName=GetFieldData.PanelScalar.scalar;
     2039            XName=GetFieldData.XVarName;
     2040            YName=GetFieldData.YVarName;
     2041            FieldList={AName};
     2042        elseif GetFieldData.CheckPlot1D;
     2043            YName=GetFieldData.CheckPlot1D.ordinate;
     2044        end
     2045        set(handles.Coord_x,'String',{XName})
     2046        set(handles.Coord_y,'String',{YName})
     2047        set(handles.FieldName,'Value',1)
     2048        set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
     2049        %         set(handles.ColorScalar,'Value',1)
     2050        %         set(handles.ColorScalar,'String',VecColorList);
     2051        %         UvData.FileType{1}='netcdf';
     2052        %         set(handles.uvmat,'UserData',UvData)
     2053    end
     2054    % elseif isequal(field,'more...')
     2055    %     str=calc_field;
     2056    %     [ind_answer,v] = listdlg('PromptString','Select a file:',...
     2057    %                 'SelectionMode','single',...
     2058    %                 'ListString',str);
     2059    %        % edit the choice in the fields and actionname menu
     2060    %      scalar=cell2mat(str(ind_answer));
     2061    %      update_menu(handles.FieldName,scalar)
    21062062end
    21072063
     
    21242080        set(hget_field,'name','get_field_1')
    21252081     end
    2126 elseif isequal(field,'more...')
    2127     str=calc_field;
    2128     [ind_answer,v] = listdlg('PromptString','Select a file:',...
    2129                 'SelectionMode','single',...
    2130                 'ListString',str);
    2131        % edit the choice in the fields and actionname menu
    2132      scalar=cell2mat(str(ind_answer));
    2133      update_menu(handles.FieldName_1,scalar)
     2082% elseif isequal(field,'more...')
     2083%     str=calc_field;
     2084%     [ind_answer,v] = listdlg('PromptString','Select a file:',...
     2085%                 'SelectionMode','single',...
     2086%                 'ListString',str);
     2087%        % edit the choice in the fields and actionname menu
     2088%      scalar=cell2mat(str(ind_answer));
     2089%      update_menu(handles.FieldName_1,scalar)
    21342090end   
    21352091
     
    22052161value=get(handles.CheckObject,'Value');
    22062162if value
    2207      set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
     2163%      set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
    22082164     hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle
    22092165     if ishandle(hset_object)
     
    22162172            defaultname={''};
    22172173         end
    2218         [FileName, PathName, filterindex] = uigetfile( ...
     2174        [FileName, PathName] = uigetfile( ...
    22192175       {'*.xml;*.mat', ' (*.xml,*.mat)';
    22202176       '*.xml',  '.xml files '; ...
     
    22422198     set(handles.DeleteObject,'Visible','on');
    22432199     set(handles.ViewObject,'Visible','on');
     2200     set(handles.ProjObject,'Visible','on');
    22442201else
    2245     set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
     2202         set(handles.DeleteObject,'Visible','off');
     2203     set(handles.ViewObject,'Visible','off');
     2204     set(handles.ProjObject,'Visible','off');
     2205%     set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
    22462206end
    22472207%set(handles.series,'UserData',SeriesData)
     
    23992359% --- Executes on button press in status.
    24002360function status_Callback(hObject, eventdata, handles)
    2401 val=get(handles.status,'Value');
    2402 
    2403 %% delete current display fig if selection is off
    2404 if val==0
     2361
     2362if get(handles.status,'Value')
     2363    set(handles.status,'BackgroundColor',[1 1 0])
     2364    drawnow
     2365    StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch
     2366    Param=read_GUI(handles.series);
     2367    RootPath=Param.InputTable{1,1};
     2368    OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
     2369    OutputDir=fullfile(RootPath,OutputSubDir);
     2370    hfig=findobj(allchild(0),'name','series_status');
     2371    if isempty(hfig)
     2372        hfig=figure('DeleteFcn',@stop_status);
     2373        set(hfig,'MenuBar','none')% suppress the menu bar
     2374        set(hfig,'NumberTitle','off')%suppress the fig number in the title
     2375        set(hfig,'name','series_status')
     2376        set(hfig,'tag','series_status')
     2377        uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @view_file,'tag','list','UserData',OutputDir);
     2378        uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,'String',OutputDir);
     2379        uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     2380        uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
     2381        hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
     2382        set(hrefresh,'UserData',StatusData)
     2383        BarPosition=[0.05 0.81 0.01 0.05];
     2384        uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     2385        drawnow
     2386    end
     2387    refresh_GUI(hrefresh,[])
     2388else
     2389    %% delete current display fig if selection is off
    24052390    set(handles.status,'BackgroundColor',[0 1 0])
    24062391    hfig=findobj(allchild(0),'name','series_status');
     
    24102395    return
    24112396end
    2412 set(handles.status,'BackgroundColor',[1 1 0])
    2413 drawnow
    2414 % listtype={'civ1','fix1','patch1','civ2','fix2','patch2'};
    2415 % Param.CheckCiv1=get(handles.CheckCiv1,'Value');
    2416 % Param.CheckFix1=get(handles.CheckFix1,'Value');
    2417 % Param.CheckPatch1=get(handles.CheckPatch1,'Value');
    2418 % Param.CheckCiv2=get(handles.CheckCiv2,'Value');
    2419 % Param.CheckFix2=get(handles.CheckFix2,'Value');
    2420 % Param.CheckPatch2=get(handles.CheckPatch2,'Value');
    2421 % box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2];
    2422 %
    2423 % option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test)
    2424 % filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV
    2425 % test_new=0;
    2426 % if ~isfield(filecell,'nc')
    2427 %     test_new=1;
    2428 %     [ref_i,ref_j,errormsg]=find_ref_indices(handles);
    2429 %     if ~isempty(errormsg)
    2430 %         msgbox_uvmat('ERROR',errormsg)
    2431 %         return
    2432 %     end
    2433 %     filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status
    2434 % end
    2435 % if ~isequal(box_test(4:6),[0 0 0])
    2436 %     civ_files=filecell.nc.civ2;%case of civ2 operations
    2437 % else
    2438 %     civ_files=filecell.nc.civ1;
    2439 % end
    2440 % InputTable=get(handles.InputTable,'Data');
    2441 % OutputDir=fullfile(InputTable{1,1},[get(handles.OutputSubDir,'String') get(handles.OutputDirExt,'String')]);
    2442 StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch
    2443 % StatusData.option_civ=option_civ;
    2444 Param=read_GUI(handles.series);
    2445 RootPath=Param.InputTable{1,1};
    2446 %SubDir=Param.InputTable{1,2};
    2447 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    2448 OutputDir=fullfile(RootPath,OutputSubDir);
    2449 % set(hlist,'UserData',OutputDir)
    2450 hfig=findobj(allchild(0),'name','series_status');
    2451 if isempty(hfig)
    2452     hfig=figure('DeleteFcn',@stop_status);
    2453     set(hfig,'MenuBar','none')% suppress the menu bar
    2454     set(hfig,'NumberTitle','off')%suppress the fig number in the title
    2455     set(hfig,'name','series_status')
    2456     set(hfig,'tag','series_status')
    2457 %    set(hfig,'UserData',civ_files)
    2458     hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list','UserData',OutputDir);
    2459     uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String',OutputDir);
    2460     uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    2461     %uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@close_GUI);
    2462     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
    2463     hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
    2464     set(hrefresh,'UserData',StatusData)
    2465     BarPosition=[0.05 0.81 0.01 0.05];
    2466     uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
    2467     drawnow
    2468 end
    2469 
    2470 refresh_GUI(hrefresh,[])
     2397
     2398
     2399%------------------------------------------------------------------------   
     2400% launched by selecting a file on the list
     2401function view_file(hObject, eventdata)
     2402list=get(hObject,'String');
     2403index=get(hObject,'Value');
     2404rootroot=get(hObject,'UserData');
     2405selectname=list{index};
     2406ind_dot=regexp(selectname,'\.\.\.');
     2407if ~isempty(ind_dot)
     2408    selectname=selectname(1:ind_dot-1);
     2409end
     2410FullSelectName=fullfile(rootroot,selectname);
     2411if exist(FullSelectName,'dir')% a directory has been selected
     2412    ListFiles=dir(FullSelectName);
     2413    ListDisplay=cell(numel(ListFiles),1);
     2414    for ilist=2:numel(ListDisplay)% suppress the first line '.'
     2415        ListDisplay{ilist-1}=ListFiles(ilist).name;
     2416    end
     2417    set(hObject,'Value',1)
     2418    set(hObject,'String',ListDisplay)
     2419    if strcmp(selectname,'..')
     2420        FullSelectName=fileparts(fileparts(FullSelectName));
     2421    end
     2422    set(hObject,'UserData',FullSelectName)
     2423    hfig=get(hObject,'parent');
     2424    htitlebox=findobj(hfig,'tag','titlebox');   
     2425    set(htitlebox,'String',FullSelectName)
     2426elseif exist(FullSelectName,'file')%visualise the vel field if it exists
     2427    FileType=get_file_type(FullSelectName);
     2428    if strcmp(FileType,'txt')
     2429        edit(FullSelectName)
     2430    else
     2431        uvmat(FullSelectName)
     2432    end
     2433    set(gcbo,'Value',1)
     2434end
     2435
     2436
     2437%------------------------------------------------------------------------
     2438
    24712439%------------------------------------------------------------------------   
    24722440% launched by refreshing the status figure
    24732441function refresh_GUI(hObject, eventdata)
    24742442%------------------------------------------------------------------------
    2475 % Tabchar={};
    2476 % BarPosition=[0.05 0.81 0.01 0.05];
    24772443hfig=get(hObject,'parent');
    2478 hmsgbox=findobj(hfig,'tag','msgbox');
     2444htitlebox=findobj(hfig,'tag','titlebox');
    24792445hlist=findobj(hfig,'tag','list');
    2480 % StatusData=get(hObject,'UserData');
    2481 OutputDir=get(hmsgbox,'String');
     2446OutputDir=get(htitlebox,'String');
    24822447ListFiles=dir(OutputDir);
    24832448ListDisplay=cell(numel(ListFiles),1);
    2484 for ilist=1:numel(ListDisplay)
    2485     ListDisplay{ilist}=ListFiles(ilist).name;
     2449for ilist=2:numel(ListDisplay)
     2450    ListDisplay{ilist-1}=ListFiles(ilist).name;
    24862451end
    24872452set(hlist,'String',ListDisplay)
     
    25562521% end
    25572522% hlist=findobj(hfig,'tag','list');
    2558 % hmsgbox=findobj(hfig,'tag','msgbox');
     2523% htitlebox=findobj(hfig,'tag','titlebox');
    25592524% hwaitbar=findobj(hfig,'tag','waitbar');
    25602525% set(hlist,'String',Tabchar)
    2561 % set(hmsgbox,'String', message)
     2526% set(htitlebox,'String', message)
    25622527% if count>0 %&& ~test_new
    25632528%     BarPosition(3)=0.9*count/nbfiles;
     
    25972562    if isfield(m_file,'datenum') && m_file.datenum>sh_file.datenum
    25982563        set(handles.ActionExt,'BackgroundColor',[1 1 0])
     2564        drawnow
    25992565        answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
    26002566        if strcmp(answer,'Yes')
  • trunk/src/series/aver_stat.m

    r594 r595  
    8989% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    9090%%%%%%%%%%%%
    91 NbSlice=1;%default
    92 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
    93     NbSlice=Param.IndexRange.NbSlice;
    94 end
     91% NbSlice=1;%default
     92% if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
     93%     NbSlice=Param.IndexRange.NbSlice;
     94% end
    9595nbview=numel(i1_series);%number of input file series (lines in InputTable)
    9696nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    9797nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    9898nbfield=nbfield_j*nbfield_i; %total number of fields
    99 nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
    100 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
     99%nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
     100%nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
    101101
    102102%determine the file type on each line from the first input file
     
    173173
    174174%% MAIN LOOP ON SLICES
    175 for i_slice=1:NbSlice
    176     index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
     175% for i_slice=1:NbSlice
     176   % index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
    177177    nbfiles=0;
    178178    nbmissing=0;
    179179
    180180    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    181     for index=index_slice
     181    for index=1:nbfield
     182    %for index=index_slice
    182183          if checkrun
    183184                stopstate=get(Param.RUNHandle,'BusyAction');
     
    305306   
    306307    %writting the result file
    307     OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
     308    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),j1_series{1}(1),j1_series{1}(end));
    308309    if CheckImage{1} %case of images
    309310        if isequal(FileInfo{1}.BitDepth,16)||(numel(FileInfo)==2 &&isequal(FileInfo{2}.BitDepth,16))
     
    324325        end
    325326    end  % end averaging  loop
    326 end
     327% end
    327328%%%%%%%%%%%%%%%% end loop on slices %%%%%%%%%%%%%%%%
    328329
  • trunk/src/series/merge_proj.m

    r592 r595  
    6363
    6464%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
     65
     66
    6567%% read input parameters from an xml file if input is a file name (batch mode)
    6668checkrun=1;
     
    157159end
    158160NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
    159 if checkrun==1
    160     ParamOut.Specific=[];%no specific parameter
    161     return %stop here for interactive input (option Param.Specific='?')
    162 end
     161% if checkrun==1
     162%     ParamOut.Specific=[];%no specific parameter
     163%     return %stop here for interactive input (option Param.Specific='?')
     164% end
    163165
    164166%% Set field names and velocity types
     
    174176    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    175177    for index=index_slice
    176  
    177178        if checkrun
    178             update_waitbar(hseries.Waitbar,index/(nbfield))
    179             stopstate=get(hseries.RUN,'BusyAction');
     179            stopstate=get(Param.RUNHandle,'BusyAction');
     180            update_waitbar(Param.WaitbarHandle,index/nbfield)
    180181        else
    181182            stopstate='queue';
    182183        end
    183        
     184        if ~isequal(stopstate,'queue')% enable STOP command
     185            return
     186        end
    184187        %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    185188        Data=cell(1,nbview);%initiate the set Data
  • trunk/src/uvmat.m

    r591 r595  
    7373%               _____________|____________
    7474%              |                          |                   
    75 %        proj_field.m               proj_field.m       project the field on the projection objects (use calc_field.m)           
     75%        proj_field.m               proj_field.m       project the field on the projection objects (use set_field_list.m)           
    7676%              |                          |
    7777%         UvData.PlotAxes          ViewData.PlotAxes (on view_field)
     
    10411041        set(handles_Fields,'Value',1)
    10421042        set(handles_Fields,'String',{'get_field...'})
    1043         hget_field=get_field(FileName);
    1044         hhget_field=guidata(hget_field);
    1045         get_field('RUN_Callback',hhget_field.RUN,[],hhget_field);
     1043        FieldName_Callback([],[], handles)
     1044%         hget_field=get_field(FileName);
     1045%         hhget_field=guidata(hget_field);
     1046%         get_field('RUN_Callback',hhget_field.RUN,[],hhget_field);
    10461047    otherwise
    10471048        set(handles_Fields,'Value',1) % set menu to 'image'
     
    21212122    ParamIn.VelType=VelType;
    21222123    XNameMenu=get(handles.Coord_x,'String');
    2123     ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value'));
     2124    if ~isempty(XNameMenu)
     2125        ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value'));
     2126    end
    21242127    YNameMenu=get(handles.Coord_y,'String');
    2125     ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value'));
     2128    if ~isempty(YNameMenu)
     2129        ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value'));
     2130    end
    21262131end
    21272132check_tps = 0;         
     
    25972602    set(handles.ListObject_1,'Visible','off')
    25982603    [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat));
    2599     write_plot_param(handles,PlotParamOut) %update the auto plot parameters
     2604    errormsg=fill_GUI(PlotParamOut,handles.uvmat);
     2605    %write_plot_param(handles,PlotParamOut) %update the auto plot parameters
    26002606   
    26012607%% 2D or 3D fieldname are generally projected
     
    27042710            else
    27052711                [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
    2706                 write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
     2712                if imap==1
     2713                errormsg=fill_GUI(PlotParamOut,handles.uvmat);
     2714                else
     2715                    errormsg=fill_GUI(PlotParamOut,hview_field);
     2716                end
     2717                %write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
    27072718                if isfield(Field,'CoordMesh')&&~isempty(Field.CoordMesh)
    27082719                    ObjectData.CoordMesh=Field.CoordMesh; % gives an estimated mesh size (useful for mouse action on the plot)
     
    31043115    FieldList={};
    31053116    VecColorList={};
    3106     XName='';
    3107     YName='';
     3117    XName=GetFieldData.XVarName;
    31083118    if GetFieldData.CheckVector
    31093119        UName=GetFieldData.PanelVectors.vector_x;
     
    31133123        CName=GetFieldData.PanelVectors.vec_color;
    31143124        [FieldList,VecColorList]=set_field_list(UName,VName,CName);
    3115 %         FieldList={['vec(' UName ',' VName ')'];...
    3116 %             ['norm(' UName ',' VName ')'];...
    3117 %             ['curl(' UName ',' VName ')'];...
    3118 %             ['div(' UName ',' VName ')'];...
    3119 %             ['strain(' UName ',' VName ')']};
    3120 %         VecColorList={['norm(' UName ',' VName ')'];...
    3121 %             UName;...
    3122 %             VName};...
    3123 %             if ~isempty(CName)
    3124 %             VecColorList=[{CName};VecColorList];
    3125 %             end
    3126     end
    3127     if GetFieldData.CheckScalar
     3125    elseif GetFieldData.CheckScalar
    31283126        AName=GetFieldData.PanelScalar.scalar;
    31293127        XName=GetFieldData.XVarName;
    31303128        YName=GetFieldData.YVarName;
    31313129        FieldList={AName};
    3132     end
    3133     if GetFieldData.CheckPlot1D
    3134         XName=GetFieldData.CheckPlot1D.abscissa;
     3130    elseif GetFieldData.CheckPlot1D;
    31353131        YName=GetFieldData.CheckPlot1D.ordinate;
    31363132    end
     
    41014097PlotParam=read_GUI(handles.uvmat);
    41024098[tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
    4103 write_plot_param(handles,PlotParamOut); %update the auto plot parameters
     4099errormsg=fill_GUI(PlotParamOut,handles.uvmat);
     4100%write_plot_param(handles,PlotParamOut); %update the auto plot parameters
    41044101
    41054102%------------------------------------------------------------------------
     
    41834180    hhview_field=guidata(hview_field);
    41844181    ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    4185     [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interfachhview_fiel
    4186     write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
     4182    [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface
     4183   
     4184    %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
    41874185    haxes=findobj(hview_field,'tag','axes3');
    41884186    pos=get(hview_field,'Position'); 
     
    43784376    hhview_field=guidata(hview_field);
    43794377    [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field);
    4380     write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
     4378    errormsg=fill_GUI(PlotParam,hview_field);
     4379    %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
    43814380    haxes=findobj(hview_field,'tag','axes3');
    43824381    pos=get(hview_field,'Position');
Note: See TracChangeset for help on using the changeset viewer.