Changeset 140 for trunk/src/struct2nc.m


Ignore:
Timestamp:
Nov 29, 2010, 9:55:54 AM (14 years ago)
Author:
sommeria
Message:

bug repair in netcdf file reading, dealing with unavailable variables, + cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/struct2nc.m

    r128 r140  
    5151        return
    5252    end
    53     [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
     53    [Data,errormsg]=check_field_structure(Data)%check the validity of the input field structure
     54    if ~isempty(errormsg)
     55        errormsg=['invalid input structure:' errormsg];
     56        return
     57    end
    5458    ListVarName=Data.ListVarName;
    5559    nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname   
     
    110114            eval(['VarVal=Data.' ListVarName{ivar} ';'])%varval=values of the current variable
    111115            VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
    112             siz=size(VarVal);
    113116            VarDimName=Data.VarDimName{ivar};
    114117            if ischar(VarDimName)
    115118                VarDimName={VarDimName};
    116119            end
     120            siz=size(VarVal);
    117121            testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values.
    118122            testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));%matlab vector
Note: See TracChangeset for help on using the changeset viewer.