<p><b>dwj07@fsu.edu</b> 2012-04-06 13:02:08 -0600 (Fri, 06 Apr 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Fixing the clearing of the input buffer on invalid input.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/tools/mpas_draw/netcdf_utils.cpp
===================================================================
--- branches/tools/mpas_draw/netcdf_utils.cpp        2012-04-06 18:31:50 UTC (rev 1754)
+++ branches/tools/mpas_draw/netcdf_utils.cpp        2012-04-06 19:02:08 UTC (rev 1755)
@@ -808,7 +808,8 @@
         int i;
         int j;
         int valid = 0;
-        int choice = 0;
+        int choice = -1;
+        bool failed;
 
         vector&lt;string&gt; excluded_vars;
 
@@ -879,11 +880,21 @@
                         cout &lt;&lt; ncid.get_var(var_ids.at(i))-&gt;get_dim(num_dims-1)-&gt;name() &lt;&lt; endl;
                 }
                 cout &lt;&lt; endl &lt;&lt; endl;
-
                 cout &lt;&lt; &quot;Enter the number of the field you would like to print&quot; &lt;&lt; endl;
                 cout &lt;&lt; &quot;Choose from list above, or enter 0 for default:&quot; &lt;&lt; endl;
-                cin &gt;&gt; choice;
 
+                do{
+                        cin &gt;&gt; choice;
+                        if(cin.fail()){
+                                failed = true;
+                                cin.clear();
+                                cin.ignore(1024,'</font>
<font color="gray">');
+                                cout &lt;&lt; &quot;Invalid input or the input buffer needed to be cleared. Please try again.&quot; &lt;&lt; endl;
+                        } else {
+                                failed = false;
+                        }
+                }while(failed);
+
                 for(i = 0; i &lt; var_ids.size(); i++){
                         if(var_ids.at(i) == choice){
                                 valid = 1;
@@ -946,6 +957,7 @@
         int j;
         int choice = 0;
         int valid = 0;
+        bool failed;
 
         vector&lt;string&gt; excluded_vars;
 
@@ -1020,7 +1032,17 @@
 
                 cout &lt;&lt; &quot;Enter the number of the field you would like to print&quot; &lt;&lt; endl;
                 cout &lt;&lt; &quot;Choose from list above, or enter 0 for default:&quot; &lt;&lt; endl;
-                cin &gt;&gt; choice;
+                do{
+                        cin &gt;&gt; choice;
+                        if(cin.fail()){
+                                failed = true;
+                                cin.clear();
+                                cin.ignore(1024,'</font>
<font color="gray">');
+                                cout &lt;&lt; &quot;Invalid input or the input buffer needed to be cleared. Please try again.&quot; &lt;&lt; endl;
+                        } else {
+                                failed = false;
+                        }
+                }while(failed);
 
                 for(i = 0; i &lt; var_ids.size(); i++){
                         if(var_ids.at(i) == choice){
@@ -1085,6 +1107,7 @@
         int j;
         int choice = 0;
         int valid = 0;
+        bool failed;
 
         vector&lt;string&gt; excluded_vars;
 
@@ -1156,7 +1179,17 @@
                 cout &lt;&lt; endl &lt;&lt; endl;
                 cout &lt;&lt; &quot;Enter the number of the field you would like to print&quot; &lt;&lt; endl;
                 cout &lt;&lt; &quot;Choose from list above, or enter 0 for default:&quot; &lt;&lt; endl;
-                cin &gt;&gt; choice;
+                do{
+                        cin &gt;&gt; choice;
+                        if(cin.fail()){
+                                failed = true;
+                                cin.clear();
+                                cin.ignore(1024,'</font>
<font color="blue">');
+                                cout &lt;&lt; &quot;Invalid input or the input buffer needed to be cleared. Please try again.&quot; &lt;&lt; endl;
+                        } else {
+                                failed = false;
+                        }
+                }while(failed);
 
                 for(i = 0; i &lt; var_ids.size(); i++){
                         if(var_ids.at(i) == choice){

</font>
</pre>