Changeset 1157 for trunk/src/struct2nc.m
- Timestamp:
- Jul 11, 2024, 4:13:03 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/struct2nc.m
r1127 r1157 38 38 function [errormsg,nc]=struct2nc(flname,Data,action,ListDimName,DimValue,VarDimIndex) 39 39 nc=[]; 40 errormsg=''; 40 41 if ~ischar(flname) 41 42 errormsg='invalid input for the netcf file name'; … … 81 82 end 82 83 if ~testvar 83 eval(['cte=Data.' keys{iattr} ';'])84 cte=Data.(keys{iattr}); 84 85 if (ischar(cte) ||isnumeric(cte)) && ~isempty(cte)%&& ~isequal(cte,'') 85 86 %write constant only if it is numeric or char string, and not empty … … 106 107 %% create the variables 107 108 varid=nan(1,length(Data.ListVarName)); 109 VarClass=cell(1,length(ListVarName)); 108 110 for ivar=1:length(ListVarName) 109 111 if isfield(Data,ListVarName{ivar}) … … 141 143 netcdf.endDef(nc); %put in data mode 142 144 143 %% fill the variables with input data 145 %% fill the variables with input data except in mode 'keep_open' (variables will be filled later) 144 146 if ~(exist('action','var') && strcmp(action,'keep_open')) 145 147 for ivar=1:length(ListVarName) … … 169 171 end 170 172 end 173 if ~ (exist('action','var') && strcmp(action,'keep_open')) 171 174 netcdf.close(nc) 172 175 [success,errormsg] = fileattrib(flname ,'+w');% allow writing access for the group of users 176 end 173 177 %'check_field_structure': check the validity of the field struture representation consistant with the netcdf format 174 178 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.