Ignore:
Timestamp:
Aug 18, 2012, 11:17:48 PM (12 years ago)
Author:
sommeria
Message:

various bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_interp.m

    r517 r521  
    2323InputVarList={};
    2424if ischar(Operation),Operation={Operation};end
     25check_skipped=zeros(size(Operation));
     26Operator=cell(size(Operation));
    2527for ilist=1:numel(Operation)
    2628    r=regexp(Operation{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names');
    2729    if isempty(r) % the operation is the variable
    28         if isempty(find(strcmp(Operation{ilist},InputVarList)));
    29             InputVarList=[InputVarList Operation{ilist}];
     30        if ~isfield(Data,Operation{ilist})
     31            check_skipped(ilist)=1;
     32        else
     33            if isempty(find(strcmp(Operation{ilist},InputVarList)));
     34                InputVarList=[InputVarList Operation{ilist}];% the variable is added to the list if it is not already in the list
     35            end
     36            Operator{ilist}='';
    3037        end
    31         Operator{ilist}='';
    3238    else
    33         UName{ilist}=r.UName;
    34         VName{ilist}=r.VName;
    35         if isempty(find(strcmp(r.UName,InputVarList)));
    36             InputVarList=[InputVarList UName{ilist}];
     39        if ~isfield(Data,r.UName)||~isfield(Data,r.VName)
     40            check_skipped(ilist)=1;
     41        else
     42            UName{ilist}=r.UName;
     43            VName{ilist}=r.VName;
     44            if isempty(find(strcmp(r.UName,InputVarList)));
     45                InputVarList=[InputVarList UName{ilist}]; %the variable is added to the list if it is not already in the list
     46            end
     47            if isempty(find(strcmp(r.VName,InputVarList)));
     48                InputVarList=[InputVarList VName{ilist}]; %the variable is added to the list if it is not already in the list
     49            end
     50            Operator{ilist}=r.Operator;
    3751        end
    38         if isempty(find(strcmp(r.VName,InputVarList)));
    39             InputVarList=[InputVarList VName{ilist}];
    40         end
    41         Operator{ilist}=r.Operator;
    4252    end
    4353end
     
    4959end
    5060for ilist=1:numel(Operation)
     61    if ~check_skipped(ilist)
    5162    nbvar=numel(ListVarName);
    5263    switch Operator{ilist}
     
    6374            VarAttribute{nbvar+1}.Role='vector_x';
    6475            VarAttribute{nbvar+2}.Role='vector_y';
    65             %         case 'U'
    66             %             VarVal{nbvar+1}=F_u(XI,YI);
    67             %             ListVarName{nbvar+1}='U';
    68             %             VarAttribute{nbvar+1}.Role='scalar';
    69             %         case 'V'
    70             %             VarVal{nbvar+1}=F_v(XI,YI);
    71             %             ListVarName{nbvar+1}='V';
    72             %             VarAttribute{nbvar+1}.Role='scalar';
    7376        case 'norm'
    7477            if exist('XI','var')
     
    9396            end
    9497    end
     98    end
    9599end
    96100% put an error flag to indicate NaN data
Note: See TracChangeset for help on using the changeset viewer.