Index: /issm/trunk/src/m/contrib/musselman/read_netCDF_commit.py
===================================================================
--- /issm/trunk/src/m/contrib/musselman/read_netCDF_commit.py	(revision 27837)
+++ /issm/trunk/src/m/contrib/musselman/read_netCDF_commit.py	(revision 27838)
@@ -22,4 +22,6 @@
 
 def read_netCDF(filename):
+    print('NetCDF42C v1.1.12')
+
     # check if path exists
     if path.exists(filename):
@@ -93,4 +95,7 @@
     # as simple as navigating to the location_of_variable_in_model and setting it equal to the location_of_variable_in_file
 
+    # NetCDF4 has a property called "_FillValue" that sometimes saves empty lists, so we have to catch those
+    FillValue = -9223372036854775806
+    
     # but there are a couple of cases we need to compensate for, like an arrary of a single integer should just be an integer and not an array
     if len(eval(location_of_variable_in_file))>1:
@@ -99,7 +104,13 @@
     if 'char' in eval(location_of_variable_in_file + '.dimensions[0]'):
         setattr(eval('model_copy.' + location_of_variable_in_model), variable_name, eval(location_of_variable_in_file + '[:][...].tobytes().decode()'))
-    # catch everything else (lists, arrays, etc.)
+    # catch everything else (lists, 1-D arrays, etc.)
     else:
-        setattr(eval('model_copy.' + location_of_variable_in_model), variable_name, eval(location_of_variable_in_file + '[:][0]')) # note the [0] on the end
+        # check for FillValue. use try/except because try block will only work on datatypes than like int64, float, single element lists/arrays ect and not nd-arrays/n-lists etc
+        print(eval(location_of_variable_in_file + '[:][0]'))
+        try:
+            if FillValue == eval(location_of_variable_in_file + '[:][0]'):
+                setattr(eval('model_copy.' + location_of_variable_in_model), variable_name, [])
+        except:
+            setattr(eval('model_copy.' + location_of_variable_in_model), variable_name, eval(location_of_variable_in_file + '[:][0]')) # note the [0] on the end
         
     print('Successfully saved ' + location_of_variable_in_model + '.' + variable_name + ' to model.')
Index: /issm/trunk/src/m/contrib/musselman/write_netCDF_commit.py
===================================================================
--- /issm/trunk/src/m/contrib/musselman/write_netCDF_commit.py	(revision 27837)
+++ /issm/trunk/src/m/contrib/musselman/write_netCDF_commit.py	(revision 27838)
@@ -1,3 +1,4 @@
 # imports
+import netCDF4
 from netCDF4 import Dataset
 import numpy as np
@@ -6,4 +7,5 @@
 from os import path, remove
 from model import *
+from results import *
 
 
@@ -20,4 +22,5 @@
 
 def write_netCDF(model_var, model_name: str, filename: str):
+    print('C2NetCDF4 v1.1.12')
     '''
     model_var = class object to be saved
@@ -37,8 +40,44 @@
     # Walk through the model_var class and compare subclass states to empty_model
     walk_through_model(model_var, model_name)
-    
+
+    # in order to handle some subclasses in the results class, we have to utilize this band-aid
+    # there will likely be more band-aids added unless a class name library is created with all class names that might be added to a model
+    try:
+        # if results has meaningful data, save the name of the subclass and class instance
+        NetCDF.groups['results']
+        results_subclasses_bandaid(model_var)
+        # otherwise, ignore
+    except KeyError:
+        pass
+        
     NetCDF.close()
     print('Model successfully saved as NetCDF4')
     
+
+
+def results_subclasses_bandaid(model_var):
+    # since the results class may have nested classes within it, we need to record the name of the 
+    # nested class instance variable as it appears in the model that we're trying to save
+    quality_control = []
+    for class_instance_name in model_var.results.__dict__.keys():
+        # for each class instance in results, see which class its from and record that info in the netcdf to recreate structure later
+        # check to see if there is a solutionstep class instance
+        if isinstance(model_var.results.__dict__[class_instance_name],solutionstep):
+            quality_control.append(1)
+            write_string_to_netcdf(variable_name=str('solutionstep'), adress_of_child=str(class_instance_name), group=NetCDF.groups['results'])
+        # check to see if there is a solution class instance
+        if isinstance(model_var.results.__dict__[class_instance_name],solution):
+            quality_control.append(1)
+            write_string_to_netcdf(variable_name=str('solution'), adress_of_child=str(class_instance_name), group=NetCDF.groups['results'])
+        # check to see if there is a resultsdakota class instance
+        if isinstance(model_var.results.__dict__[class_instance_name],resultsdakota):
+            quality_control.append(1)
+            write_string_to_netcdf(variable_name=str('resultsdakota'), adress_of_child=str(class_instance_name), group=NetCDF.groups['results'])
+    if len(quality_control) != len(model_var.results.__dict__.keys()):
+        print('Error: The class instance within your model.results class is not currently supported by this application')
+        print(type(model_var.results.__dict__[class_instance_name]))
+    else:
+        print('The results class was successfully stored on disk')
+
 
     
@@ -79,9 +118,9 @@
 def walk_through_subclasses(model_var, adress: str, model_name: str):
     # Iterate over each subclass' attributes
-    # Use try/except since it's either a class or it's not, no unknown exceptions
+    # Use try/except since it's either a class w/ attributes or it's not, no unknown exceptions
     try:
         # enter the subclass, see if it has nested classes and/or attributes
-        # then compare attribute states between models and write to netCDF if they differ
-        # repeat starting from new location
+        # then compare attributes between models and write to netCDF if they differ
+        # if subclass found, walk through it and repeat
         for child in eval(adress + '.__dict__.keys()'):
             # make a string variable so we can send thru this func again
@@ -101,7 +140,9 @@
                 create_group(model_var, adress_of_child)
                 walk_through_subclasses(model_var, adress_of_child, model_name)
-    except: pass
-
- 
+    except AttributeError: pass
+    except Exception as e: print(e)
+
+
+        
 def create_group(model_var, adress_of_child):
     # start by splitting the adress_of_child into its components
@@ -139,22 +180,22 @@
         variable = group.createVariable(variable_name, float, ('float',))
         variable[:] = eval(adress_of_child)
-        
+
     # or a string
     elif isinstance(eval(adress_of_child), str):
         write_string_to_netcdf(variable_name, adress_of_child, group)
         
-    # or a list of strings -- this needs work as it can only handle a list of 1 string
-    elif isinstance(eval(adress_of_child)[0],str):
-        for string in eval(adress_of_child):
-            write_string_to_netcdf(variable_name, string, group)
-        
-    # or a list
-    elif isinstance(eval(adress_of_child), list):
-        variable = group.createVariable(variable_name, type(eval(adress_of_child)[0]), ('Unlim',))
-        variable[:] = eval(adress_of_child)
-        
     # or an empty list
     elif isinstance(eval(adress_of_child), list) and len(eval(adress_of_child))==0:
         variable = group.createVariable(variable_name, int, ('int',))
+
+    # or a list of strings -- this needs work as it can only handle a list of 1 string
+    elif isinstance(eval(adress_of_child),list) and isinstance(eval(adress_of_child)[0],str):
+        for string in eval(adress_of_child):
+            write_string_to_netcdf(variable_name, string, group)
+
+    # or a regular list
+    elif isinstance(eval(adress_of_child), list):
+        variable = group.createVariable(variable_name, type(eval(adress_of_child)[0]), ('Unlim',))
+        variable[:] = eval(adress_of_child)
 
     # anything else... (will likely need to add more cases; ie dict)
@@ -169,4 +210,6 @@
     print('Successfully transferred data from ' + adress_of_child + ' to the NetCDF')
     
+
+
 
 def write_string_to_netcdf(variable_name, adress_of_child, group):
@@ -177,5 +220,5 @@
         length_of_the_string = len(the_string_to_save)
         numpy_datatype = 'S' + str(length_of_the_string)
-        str_out = netCDF4.stringtochar(np.array(['the_string_to_save'], dtype=numpy_datatype))
+        str_out = netCDF4.stringtochar(np.array([the_string_to_save], dtype=numpy_datatype))
     #otherwise we need to treat it like a string:
     except: 
@@ -183,15 +226,15 @@
         length_of_the_string = len(the_string_to_save)
         numpy_datatype = 'S' + str(length_of_the_string)
-        str_out = netCDF4.stringtochar(np.array(['the_string_to_save'], dtype=numpy_datatype))        
+        str_out = netCDF4.stringtochar(np.array([the_string_to_save], dtype=numpy_datatype))        
 
     # we'll need to make a new dimension for the string if it doesn't already exist
+    name_of_dimension = 'char' + str(length_of_the_string)
     try: 
-        name_of_dimension = 'char' + str(length_of_the_string)
         group.createDimension(name_of_dimension, length_of_the_string)
     except: pass
     # now we can make a variable in this dimension:
-    string = group.createVariable(variable_name, 'S1', ('nchar'))
+    string = group.createVariable(variable_name, 'S1', (name_of_dimension))
     #finally we can write the variable:
-    string[:] = the_string_to_save    
+    string[:] = str_out
 
 
