Ignore:
Timestamp:
Oct 4, 2017, 3:55:18 PM (7 years ago)
Author:
g7moreau
Message:
  • Remove property svn:executable
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/hdf5save_recursion.m

    • Property svn:executable deleted
    r947 r1013  
    1515function hdf5save_recursion(filename,prefix,new,varcell)
    1616
    17 if ~strcmp(class(filename),'char') ;
    18     error('first argument should be a string giving the path to the hdf5 file to save') ;
    19 end
     17    if ~strcmp(class(filename),'char');
     18        error('first argument should be a string giving the path to the hdf5 file to save');
     19    end
    2020
    21 if ~strcmp(class(prefix),'char') ;
    22     error('second argument should be a string giving the name of the groupe to save the data in') ;
    23 end
     21    if ~strcmp(class(prefix),'char');
     22        error('second argument should be a string giving the name of the groupe to save the data in');
     23    end
    2424
    25 if new~=1 && new~=0 ;
    26     error('third argument should be 0 or 1: 0 to append data, and 1 to create a new file')
    27 end
     25    if new~=1 && new~=0;
     26        error('third argument should be 0 or 1: 0 to append data, and 1 to create a new file');
     27    end
    2828
    29 nvars=size(varcell,2)/2;
     29    nvars=size(varcell,2)/2;
    3030
    31 if nvars~=floor(nvars) ;
    32     error('expecting a name for each variable') ;
    33 end
     31    if nvars~=floor(nvars);
     32        error('expecting a name for each variable');
     33    end
    3434
    35 for i=[1:nvars]
    36     str=varcell{2*i};
    37     var=evalin('base',str);
    38     name=varcell{2*i-1};
    39     type=class(var);
    40     location=strcat('/',prefix,name);
    41     %disp(['variable name in workspace : ',str]);
    42     %disp(['variable name to put : ',name]);
    43     switch type
    44     case 'struct'
    45         names=fieldnames(var);
    46         for j=1:size(names,1) ;
    47             if (j~=1 || i~=1)
    48                 new=0 ;
    49             end
    50             varname=strcat(name,'.',names{j});
    51             hdf5save_recursion(filename,strcat(name,'/'),new,{names{j},varname});
    52         end
    53     otherwise
    54         location=strcat('/',prefix,name);
    55         if new==1 && i==1 ;
    56             hdf5write(filename,location,var);
    57         else
    58             %disp(['location : ',location]);
    59             hdf5write(filename,location,var,'WriteMode', 'append');
    60         end
     35    for i=[1:nvars]
     36        str=varcell{2*i};
     37        var=evalin('base',str);
     38        name=varcell{2*i-1};
     39        type=class(var);
     40        location=strcat('/',prefix,name);
     41        %disp(['variable name in workspace : ',str]);
     42        %disp(['variable name to put : ',name]);
     43        switch type
     44            case 'struct'
     45                names=fieldnames(var);
     46                for j=1:size(names,1);
     47                    if (j~=1 || i~=1)
     48                        new=0;
     49                    end
     50                    varname=strcat(name,'.',names{j});
     51                    hdf5save_recursion(filename,strcat(name,'/'),new,{names{j},varname});
     52                end
     53            otherwise
     54                location=strcat('/',prefix,name);
     55                if new==1 && i==1;
     56                    hdf5write(filename,location,var);
     57                else
     58                    %disp(['location : ',location]);
     59                    hdf5write(filename,location,var,'WriteMode', 'append');
     60                end
     61        end
    6162    end
    6263end
    63 
Note: See TracChangeset for help on using the changeset viewer.