Changeset 1096 for trunk/src/struct2nc.m


Ignore:
Timestamp:
Apr 2, 2021, 3:57:01 PM (3 years ago)
Author:
sommeria
Message:

bugs fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/struct2nc.m

    r1093 r1096  
    4242    return
    4343end
     44FilePath=fileparts(flname);
     45if ~strcmp(FilePath,'') && ~exist(FilePath,'dir')
     46    errormsg=['directory ' FilePath ' needs to be created'];
     47    return
     48end
    4449if ~exist('Data','var')
    4550     errormsg='no data  input for the netcdf file';
     
    4752end
    4853
    49 
    5054%% check the validity of the input field structure
    5155if ~ (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     return
    56 end
     56    [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
    5761end
    5862ListVarName=Data.ListVarName;
    5963
    6064%% 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
     65cmode = netcdf.getConstant('NETCDF4');
     66cmode = bitor(cmode, netcdf.getConstant('CLASSIC_MODEL'));
     67cmode = bitor(cmode, netcdf.getConstant('CLOBBER'));
     68nc = netcdf.create(flname, cmode);
    7469
    7570%% write global constants
Note: See TracChangeset for help on using the changeset viewer.