source: issm/oecreview/Archive/21337-21723/ISSM-21647-21648.diff@ 21726

Last change on this file since 21726 was 21726, checked in by Mathieu Morlighem, 8 years ago

CHG added Archive/21337-21723

File size: 2.6 KB
  • ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.m

     
    7272                                else
    7373                                        listsize=length(Var);
    7474                                        subgroupID=netcdf.defGrp(groupID,groupfields{j});
    75                                         netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(md.(groups{i}).(groupfields{j})));
     75                                        netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(Var));
    7676                                        for l=1:listsize
    7777                                                if isprop(Var{l},'name')
    7878                                                        lname=Var{l}.name;
     
    9191                                                end
    9292                                        end
    9393                                end
     94                        elseif isa(Var,'struct') && ~strcmp(groupfields{j},'bamg')
     95                                classtype=class(md.(groups{i}));
     96                                if strcmp(classtype,'struct')
     97                                        classtype=groups{i};
     98                                end
     99                                netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype);
     100                                if length(Var)>1
     101                                        listsize=length(Var);
     102                                        subgroupID=netcdf.defGrp(groupID,groupfields{j});
     103                                        classtype=class(Var);
     104                                        if strcmp(classtype,'struct')
     105                                                classtype=groups{i};
     106                                        end
     107                                        netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype);
     108                                        for l=1:listsize
     109                                                if isfield(Var(l),'step')
     110                                                        lname=[int2str(Var(l).step)];
     111                                                else
     112                                                        lname=[class(Var(l)) int2str(l)];
     113                                                end
     114                                                classtype=class(Var(l));
     115                                                if strcmp(classtype,'struct')
     116                                                        classtype=groups{i};
     117                                                end
     118                                                listgroupID=netcdf.defGrp(subgroupID,lname);
     119                                                netcdf.putAtt(listgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype);
     120                                                subfields=fields(Var(l));
     121                                                for m=1:length(subfields)
     122                                                        if ~strcmp(subfields{m},'outlog')
     123                                                                [DimSize,DimValue]=DefCreateVar(ncid,Var(l).(subfields{m}),listgroupID,subfields{m},DimSize,DimValue);
     124                                                        end
     125                                                end
     126                                        end
     127                                else
     128                                        subgroupID=netcdf.defGrp(groupID,groupfields{j});
     129                                        classtype=class(Var);
     130                                        if strcmp(classtype,'struct')
     131                                                classtype=groups{i};
     132                                        end
     133                                        netcdf.putAtt(subgroupID,netcdf.getConstant('NC_GLOBAL'),'classtype',classtype);
     134                                        subfields=fields(Var);
     135                                        for m=1:length(subfields)
     136                                                if ~strcmp(subfields{m},'outlog')
     137                                                        [DimSize,DimValue]=DefCreateVar(ncid,Var.(subfields{m}),subgroupID,subfields{m},DimSize,DimValue);
     138                                                end
     139                                        end
     140                                end
    94141                        else
    95142                                netcdf.putAtt(groupID,netcdf.getConstant('NC_GLOBAL'),'classtype',class(md.(groups{i})));
    96143                                [DimSize,DimValue]=DefCreateVar(ncid,Var,groupID,groupfields{j},DimSize,DimValue);
Note: See TracBrowser for help on using the repository browser.