function [data] = loadHDFvdata(namein);

%Open TRMM HDF file
file_id = hdfh('open',namein,'read',0);   % 536870912

% Open HDF SDS and VDATA Interfaces

status = hdfv('start',file_id);   % 0

% Now read in the Vdata tables and write to separate output files.

vdata_ref = - 1;
vdata_ref = hdfvs('getid',file_id, vdata_ref);

total_vidx = 0;

while(vdata_ref ~= -1)

    vdata_id = hdfvs('attach',file_id, vdata_ref, 'r');

    [n_records, interlace, fields, vdata_size, vdata_name, status] = hdfvs('inquire', vdata_id);
  
    total_vref(total_vidx+1) = vdata_ref;
    
    total_vidx = total_vidx + 1;

    status = hdfvs('detach',vdata_id);
    
    vdata_ref = hdfvs('getid',file_id,vdata_ref);
    
end

nparm = 1;

temparm = [2];

nindex = 0;

for index  = 0:(nparm-1)
    if temparm <=total_vidx
        vdata_index = temparm;
        nindex = length(temparm);
    end
end

% Now loop through vdatas and create array of data

if nindex > 0
    for index = 1:nindex
        vdata_idx = vdata_index(index)-1;
        vdata_id = hdfvs('attach',file_id,total_vref(vdata_idx+1),'r');
    
        [n_records,interlace,fields, vdata_size, vdata_name, status] = hdfvs('inquire',vdata_id);
    
        status = hdfvs('setfields',vdata_id,fields);
        [vdatabuf, status] = hdfvs('read',vdata_id,n_records);
    
        [data] = vdatabuf{1};
        
    end % end of for statement for index of total selected vdata
end % end of if statement for nindex 

status = hdfv('end',file_id);
% status = hdfv('close',file_id);
% status = hdfh('end',file_id);
status = hdfh('close',file_id);
% status = hdfvs('end',file_id);
% status = hdfvs('close',file_id);


