function peigui_varmenu()

% This function scan trough the NC file and find which variables
% shutable to be used with this sofware (hopsgui) exist
%

global peigui_obj

    [ndims, nvars, natts, recdim, status] = ncmex('INQUIRE', peigui_obj{1}.ncid);
    varcount = 0;
    for varid = 0:(nvars-1)
        
        [varname, datatype, ndims, dims, natts, status] = ncmex('VARINQ',peigui_obj{1}.ncid, varid);

        switch ndims
            case 1
                ;
            case 2
		    
            case 3
              if  strcmp('pbar',strrep(varname,' ',''))
		   varcount = varcount + 1;
                menu_variables{varcount} = 'pbar';
		   end
              if  strcmp('qbar',strrep(varname,' ',''))
		   varcount = varcount + 1;
                menu_variables{varcount} = 'qbar';
		   end
		   
            case 4
		   if  ~strcmp('tgrid3',strrep(varname,' ','')) & ~strcmp('vgrid3',strrep(varname,' ','')) ...
		   & ~strcmp('wtgrid3',strrep(varname,' ','')) & ~strcmp('wvgrid3',strrep(varname,' ','')) & ...
		   ~strcmp('tbgrid3',strrep(varname,' ','')) & ~strcmp('vbgrid3',strrep(varname,' ',''))
                varcount = varcount + 1;
                menu_variables{varcount} = varname;
		   end
		   if  strcmp('vtot',strrep(varname,' ',''))
		   varcount = varcount + 1;
                menu_variables{varcount} = 'ut';
		   varcount = varcount + 1;
                menu_variables{varcount} = 'vt';
		   varcount = varcount + 1;
                menu_variables{varcount} = '|Ut|';
		   end
		   
		   if  strcmp('vclin',strrep(varname,' ',''))
		   varcount = varcount + 1;
                menu_variables{varcount} = 'uc';
		   varcount = varcount + 1;
                menu_variables{varcount} = 'vc';
		   varcount = varcount + 1;
                menu_variables{varcount} = '|Uc|';
		    
		   end

		   if  strcmp('vgeo',strrep(varname,' ',''))
		   varcount = varcount + 1;
                menu_variables{varcount} = 'ug';
		   varcount = varcount + 1;
                menu_variables{varcount} = 'vg';
		   varcount = varcount + 1;
                menu_variables{varcount} = '|Ug|';
		    end

		   
		end 
        end





%
% now add to the variable list
%
 bandera = 0. ;
for i = 1:varcount
	if strcmp('temp',strrep(menu_variables{i},' ','')) 
	   bandera = 1;
	   peigui_obj{1}.variable='temp';
	end
        c = uimenu('Parent',peigui_obj{1}.hmenuvar, ...
        'Callback','peigui_menu_command new_variable', ...
        'Label', menu_variables{i}, ...
        'Tag', sprintf ( 'hslice variable %s submenu', menu_variables{i}) );
end

for i =1:varcount
	if strcmp('salt',strrep(menu_variables{i},' ','')) & bandera == 1
        c = uimenu('Parent',peigui_obj{1}.hmenuvar, ...
        'Callback','peigui_menu_command new_variable', ...
        'Label', 'potden', ...
        'Tag', sprintf ( 'hslice variable %s submenu', 'potden' ));

	end


end

