Changeset 1096 for trunk/src/struct2nc.m
- Timestamp:
- Apr 2, 2021, 3:57:01 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/struct2nc.m
r1093 r1096 42 42 return 43 43 end 44 FilePath=fileparts(flname); 45 if ~strcmp(FilePath,'') && ~exist(FilePath,'dir') 46 errormsg=['directory ' FilePath ' needs to be created']; 47 return 48 end 44 49 if ~exist('Data','var') 45 50 errormsg='no data input for the netcdf file'; … … 47 52 end 48 53 49 50 54 %% check the validity of the input field structure 51 55 if ~ (exist('action','var') && strcmp(action,'keep_open')) 52 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data);53 if ~isempty(errormsg)54 errormsg=['error in struct2nc:invalid input structure_' errormsg];55 return56 end56 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data); 57 if ~isempty(errormsg) 58 errormsg=['error in struct2nc:invalid input structure_' errormsg]; 59 return 60 end 57 61 end 58 62 ListVarName=Data.ListVarName; 59 63 60 64 %% create the netcdf file with name flname in format NETCDF4 61 % if ischar(flname) 62 FilePath=fileparts(flname); 63 if ~strcmp(FilePath,'') && ~exist(FilePath,'dir') 64 errormsg=['directory ' FilePath ' needs to be created']; 65 return 66 end 67 cmode = netcdf.getConstant('NETCDF4'); 68 cmode = bitor(cmode, netcdf.getConstant('CLASSIC_MODEL')); 69 cmode = bitor(cmode, netcdf.getConstant('CLOBBER')); 70 nc = netcdf.create(flname, cmode); 71 % else 72 % nc=flname; 73 % end 65 cmode = netcdf.getConstant('NETCDF4'); 66 cmode = bitor(cmode, netcdf.getConstant('CLASSIC_MODEL')); 67 cmode = bitor(cmode, netcdf.getConstant('CLOBBER')); 68 nc = netcdf.create(flname, cmode); 74 69 75 70 %% write global constants
Note: See TracChangeset
for help on using the changeset viewer.