Changeset 1157 for trunk/src/struct2nc.m


Ignore:
Timestamp:
Jul 11, 2024, 4:13:03 PM (3 months ago)
Author:
sommeria
Message:

filter_time added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/struct2nc.m

    r1127 r1157  
    3838function [errormsg,nc]=struct2nc(flname,Data,action,ListDimName,DimValue,VarDimIndex)
    3939nc=[];
     40errormsg='';
    4041if ~ischar(flname)
    4142    errormsg='invalid input for the netcf file name';
     
    8182            end
    8283            if ~testvar               
    83                 eval(['cte=Data.' keys{iattr} ';'])
     84                cte=Data.(keys{iattr});
    8485                if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)%&& ~isequal(cte,'')
    8586                    %write constant only if it is numeric or char string, and not empty
     
    106107%% create the variables
    107108varid=nan(1,length(Data.ListVarName));
     109VarClass=cell(1,length(ListVarName));
    108110for ivar=1:length(ListVarName)
    109111    if isfield(Data,ListVarName{ivar})
     
    141143netcdf.endDef(nc); %put in data mode
    142144
    143 %% fill the variables with input data
     145%% fill the variables with input data except in mode 'keep_open' (variables will be filled later)
    144146if ~(exist('action','var') && strcmp(action,'keep_open'))
    145147    for ivar=1:length(ListVarName)
     
    169171    end
    170172end
     173if ~ (exist('action','var') && strcmp(action,'keep_open'))
    171174 netcdf.close(nc)
    172175[success,errormsg] = fileattrib(flname ,'+w');% allow writing access for the group of users
     176end
    173177%'check_field_structure': check the validity of the field struture representation consistant with the netcdf format
    174178%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.