Ignore:
Timestamp:
Aug 23, 2013, 2:56:17 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired, in particula timing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_cells.m

    r648 r674  
    107107
    108108%% find scattered (unstructured) coordinates
    109 ivar_coord_x=find(strcmp('coord_x',Role));
    110 % VarDimCell=cell(numel(ivar_coord_x));
     109ivar_coord_x=find(strcmp('coord_x',Role));%find variables with Role='coord_x'
    111110check_select=false(1,nbvar);
    112111check_coord=false(1,nbvar);
    113112CellInfo=cell(1,numel(ivar_coord_x));
    114113NbDim=zeros(1,numel(ivar_coord_x));
     114% loop on unstructured coordinate x -> different field cells
    115115for icell=1:numel(ivar_coord_x)
    116     DimCell=Data.VarDimName{ivar_coord_x(icell)};
    117     if ischar(DimCell),DimCell={DimCell};end
     116    DimCell=Data.VarDimName{ivar_coord_x(icell)};% cell of dimension names for ivar_coord_x(icell)
     117    if ischar(DimCell),DimCell={DimCell};end % transform char to cell for a single dimension
     118    % look for variables sharing dimension(s) with ivar_coord_x(icell)
    118119    check_cell=zeros(numel(DimCell),nbvar);
    119120    for idim=1:numel(DimCell)
     
    123124    end
    124125    check_cell=sum(check_cell,1)==numel(DimCell);%logical array=1 for variables belonging to the current cell
    125     VarIndex=find(check_cell);
     126    VarIndex=find(check_cell);% list of detected variable indices
    126127    if ~(numel(VarIndex)==1 && numel(DimCell)==1)% exclude case of isolated coord_x variable (treated later)
    127128        if ~(numel(VarIndex)==1 && numel(DimCell)>1)% a variable is associated to coordinate
     
    132133            else
    133134                for idim=1:numel(DimCell)
    134                  check_index= strcmp(DimCell{idim},Data.ListDimName);
    135                  CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);
     135                    check_index= strcmp(DimCell{idim},Data.ListDimName);
     136                    CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);
    136137                end
    137138                CellInfo{icell}.CoordSize=prod(CellInfo{icell}.CoordSize);
     
    291292NbDim=[NbDim NewNbDim];
    292293CellInfo=[CellInfo NewCellInfo];
    293 %
    294 % %% suppress empty cells
    295 % check_empty=cellfun(@isempty,CellInfo);
    296 % CellInfo(check_empty)=[];
    297 % NbDim(check_empty)=[];
    298294
    299295%% suppress empty cells or cells with a single coordinate variable
     
    308304
    309305%% document roles of non-coordinate variables
    310 % ListRole={'vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...
    311 %    'ancillary','image','color','discrete','scalar'};% except coord,coord_x,_y,_z,Coord_tps already taken, into account
    312306for icell=1:numel(CellInfo)
    313307    VarIndex=CellInfo{icell}.VarIndex;
Note: See TracChangeset for help on using the changeset viewer.