Index: /issm/trunk-jpl/src/m/io/loadvars.py
===================================================================
--- /issm/trunk-jpl/src/m/io/loadvars.py	(revision 26127)
+++ /issm/trunk-jpl/src/m/io/loadvars.py	(revision 26128)
@@ -166,122 +166,127 @@
             if len(curclass.groups) > 0:  #that is presumably only for old style NC where each result step had its own group
                 if onlylast:
-                    listclass = curclass.groups[keylist[len(curclass.groups) - 1]]
+                    groupclass = [curclass.groups[keylist[len(curclass.groups) - 1]]]
                 else:
-                    listclass = curclass.groups[keylist[0]]
+                    groupclass = [curclass.groups[key] for key in keylist]
             else:
-                listclass = curclass
+                groupclass = [curclass]
             #==== We deal with Variables {{{
-            for var in listclass.variables:
-                if debug:
-                    print("    ==> treating var {}".format(var))
-                if var not in ['errlog', 'outlog']:
-                    varval = listclass.variables[str(var)]
-                    vardim = varval.ndim
-                    #There is a special treatment for results to account for its specific structure
-                    #that is the new export version where time is a named dimension
-                    NewFormat = 'Time' in NCFile.dimensions
-                    if type(Tree) == list:  # and NewFormat:
-                        if onlylast:
-                            if NewFormat:
-                                if vardim == 1:
-                                    Tree[0].__dict__[str(var)] = varval[-1].data
-                                elif vardim == 2:
-                                    Tree[0].__dict__[str(var)] = varval[-1, :].data
-                                elif vardim == 3:
-                                    Tree[0].__dict__[str(var)] = varval[-1, :, :].data
+            for groupindex, listclass in enumerate(groupclass):
+                for var in listclass.variables:
+                    if debug:
+                        print("    ==> treating var {}".format(var))
+                    if var not in ['errlog', 'outlog']:
+                        varval = listclass.variables[str(var)]
+                        vardim = varval.ndim
+                        #There is a special treatment for results to account for its specific structure
+                        #that is the new export version where time is a named dimension
+                        NewFormat = 'Time' in NCFile.dimensions
+                        if type(Tree) == list:  # and NewFormat:
+                            if onlylast:
+                                if NewFormat:
+                                    if vardim == 1:
+                                        Tree[0].__dict__[str(var)] = varval[-1].data
+                                    elif vardim == 2:
+                                        Tree[0].__dict__[str(var)] = varval[-1, :].data
+                                    elif vardim == 3:
+                                        Tree[0].__dict__[str(var)] = varval[-1, :, :].data
+                                    else:
+                                        print('table dimension greater than 3 not implemented yet')
+                                else:  #old format had step sorted in difeerent group so last group is last time
+                                    Tree[0].__dict__[str(var)] = varval[:].data
+                            else:
+                                if NewFormat:
+                                    incomplete = 'Time' not in varval.dimensions and NewFormat
+                                    if incomplete:
+                                        chosendim = varval.dimensions[0]
+                                        timelist = np.arange(0, len(NCFile.dimensions[chosendim]))
+                                        print('WARNING, {} is not present on every times, we chose {}({}) as the dimension to write it with'.format(var, chosendim, len(NCFile.dimensions[chosendim])))
+                                    else:
+                                        timelist = np.arange(0, len(NCFile.dimensions['Time']))
+                                    for t in timelist:
+                                        if debug:
+                                            print("filing step {} for {}".format(t, var))
+                                        if vardim == 0:
+                                            Tree[t].__dict__[str(var)] = varval[:].data
+                                        elif vardim == 1:
+                                            Tree[t].__dict__[str(var)] = varval[t].data
+                                        elif vardim == 2:
+                                            Tree[t].__dict__[str(var)] = varval[t, :].data
+                                        elif vardim == 3:
+                                            Tree[t].__dict__[str(var)] = varval[t, :, :].data
+                                        else:
+                                            print('table dimension greater than 3 not implemented yet')
                                 else:
-                                    print('table dimension greater than 3 not implemented yet')
-                            else:  #old format had step sorted in difeerent group so last group is last time
-                                Tree[0].__dict__[str(var)] = varval[:].data
+                                    if debug:
+                                        print("filing step {} for {}".format(groupindex, var))
+                                    Tree[groupindex].__dict__[str(var)] = varval[:].data
                         else:
-                            incomplete = 'Time' not in varval.dimensions and NewFormat
-                            if incomplete:
-                                chosendim = varval.dimensions[0]
-                                timelist = np.arange(0, len(NCFile.dimensions[chosendim]))
-                                print('WARNING, {} is not present on every times, we chose {}({}) as the dimension to write it with'.format(var, chosendim, len(NCFile.dimensions[chosendim])))
-                            elif not NewFormat:
-                                timelist = len(curclass.groups)
+                            if vardim == 0:  #that is a scalar
+                                if str(varval[0]) == '':  #no value
+                                    Tree.__dict__[str(var)] = []
+                                elif varval[0] == 'True':  #treatin bool
+                                    Tree.__dict__[str(var)] = True
+                                elif varval[0] == 'False':  #treatin bool
+                                    Tree.__dict__[str(var)] = False
+                                else:
+                                    Tree.__dict__[str(var)] = varval[0].item()
+
+                            elif vardim == 1:  #that is a vector
+                                if varval.dtype == str:
+                                    if varval.shape[0] == 1:
+                                        Tree.__dict__[str(var)] = [str(varval[0]), ]
+                                    elif 'True' in varval[:] or 'False' in varval[:]:
+                                        Tree.__dict__[str(var)] = np.asarray([V == 'True' for V in varval[:]], dtype=bool)
+                                    else:
+                                        Tree.__dict__[str(var)] = [str(vallue) for vallue in varval[:]]
+                                else:
+                                    try:
+                                        #some thing specifically require a list
+                                        mdtype = type(Tree.__dict__[str(var)])
+                                    except KeyError:
+                                        mdtype = float
+                                    if mdtype == list:
+                                        Tree.__dict__[str(var)] = [mdval for mdval in varval[:]]
+                                    else:
+                                        Tree.__dict__[str(var)] = varval[:].data
+
+                            elif vardim == 2:
+                                #dealling with dict
+                                if varval.dtype == str:  #that is for dictionaries
+                                    if any(varval[:, 0] == 'toolkit'):  #toolkit definition have to be first
+                                        Tree.__dict__[str(var)] = OrderedDict([('toolkit', str(varval[np.where(varval[:, 0] == 'toolkit')[0][0], 1]))])
+                                        strings1 = [str(arg[0]) for arg in varval if arg[0] != 'toolkits']
+                                        strings2 = [str(arg[1]) for arg in varval if arg[0] != 'toolkits']
+                                        Tree.__dict__[str(var)].update(list(zip(strings1, strings2)))
+                                    else:
+                                        strings1 = [str(arg[0]) for arg in varval]
+                                        strings2 = [str(arg[1]) for arg in varval]
+                                        Tree.__dict__[str(var)] = OrderedDict(list(zip(strings1, strings2)))
+                            elif vardim == 3:
+                                Tree.__dict__[str(var)] = varval[:, :, :].data
                             else:
-                                timelist = np.arange(0, len(NCFile.dimensions['Time']))
-                            for t in timelist:
-                                print("filing step {} for {}".format(t, var))
-                                if vardim == 0:
-                                    Tree[t].__dict__[str(var)] = varval[:].data
-                                if vardim == 1:
-                                    Tree[t].__dict__[str(var)] = varval[t].data
-                                elif vardim == 2:
-                                    Tree[t].__dict__[str(var)] = varval[t, :].data
-                                elif vardim == 3:
-                                    Tree[t].__dict__[str(var)] = varval[t, :, :].data
-                                else:
-                                    print('table dimension greater than 3 not implemented yet')
-                    else:
-                        if vardim == 0:  #that is a scalar
-                            if str(varval[0]) == '':  #no value
-                                Tree.__dict__[str(var)] = []
-                            elif varval[0] == 'True':  #treatin bool
-                                Tree.__dict__[str(var)] = True
-                            elif varval[0] == 'False':  #treatin bool
-                                Tree.__dict__[str(var)] = False
+                                print('table dimension greater than 3 not implemented yet')
+                # }}}
+                #==== And with atribute {{{
+                for attr in listclass.ncattrs():
+                    if debug:
+                        print("      ==> treating attribute {}".format(attr))
+                    if attr != 'classtype':  #classtype is for treatment, don't get it back
+                        attribute = str(attr).swapcase()  #there is a reason for swapcase, no sure what it isanymore
+                        if attr == 'VARNAME':
+                            attribute = 'name'
+                        if type(Tree) == list:
+                            if debug:
+                                print("        printing with index 0")
+                            if listtype == 'dict':
+                                Tree[0][attribute] = str(listclass.getncattr(attr))
                             else:
-                                Tree.__dict__[str(var)] = varval[0].item()
-
-                        elif vardim == 1:  #that is a vector
-                            if varval.dtype == str:
-                                if varval.shape[0] == 1:
-                                    Tree.__dict__[str(var)] = [str(varval[0]), ]
-                                elif 'True' in varval[:] or 'False' in varval[:]:
-                                    Tree.__dict__[str(var)] = np.asarray([V == 'True' for V in varval[:]], dtype=bool)
-                                else:
-                                    Tree.__dict__[str(var)] = [str(vallue) for vallue in varval[:]]
-                            else:
-                                try:
-                                    #some thing specifically require a list
-                                    mdtype = type(Tree.__dict__[str(var)])
-                                except KeyError:
-                                    mdtype = float
-                                if mdtype == list:
-                                    Tree.__dict__[str(var)] = [mdval for mdval in varval[:]]
-                                else:
-                                    Tree.__dict__[str(var)] = varval[:].data
-
-                        elif vardim == 2:
-                            #dealling with dict
-                            if varval.dtype == str:  #that is for dictionaries
-                                if any(varval[:, 0] == 'toolkit'):  #toolkit definition have to be first
-                                    Tree.__dict__[str(var)] = OrderedDict([('toolkit', str(varval[np.where(varval[:, 0] == 'toolkit')[0][0], 1]))])
-                                    strings1 = [str(arg[0]) for arg in varval if arg[0] != 'toolkits']
-                                    strings2 = [str(arg[1]) for arg in varval if arg[0] != 'toolkits']
-                                    Tree.__dict__[str(var)].update(list(zip(strings1, strings2)))
-                                else:
-                                    strings1 = [str(arg[0]) for arg in varval]
-                                    strings2 = [str(arg[1]) for arg in varval]
-                                    Tree.__dict__[str(var)] = OrderedDict(list(zip(strings1, strings2)))
-                        elif vardim == 3:
-                            Tree.__dict__[str(var)] = varval[:, :, :].data
+                                Tree[0].__dict__[attribute] = str(listclass.getncattr(attr))
                         else:
-                            print('table dimension greater than 3 not implemented yet')
-                # }}}
-            #==== And with atribute {{{
-            for attr in listclass.ncattrs():
-                if debug:
-                    print("      ==> treating attribute {}".format(attr))
-                if attr != 'classtype':  #classtype is for treatment, don't get it back
-                    attribute = str(attr).swapcase()  #there is a reason for swapcase, no sure what it isanymore
-                    if attr == 'VARNAME':
-                        attribute = 'name'
-                    if type(Tree) == list:
-                        if debug:
-                            print("        printing with index 0")
-                        if listtype == 'dict':
-                            Tree[0][attribute] = str(listclass.getncattr(attr))
-                        else:
-                            Tree[0].__dict__[attribute] = str(listclass.getncattr(attr))
-                    else:
-                        Tree.__dict__[attribute] = str(listclass.getncattr(attr))
-                        if listclass.getncattr(attr) == 'True':
-                            Tree.__dict__[attribute] = True
-                        elif listclass.getncattr(attr) == 'False':
-                            Tree.__dict__[attribute] = False
+                            Tree.__dict__[attribute] = str(listclass.getncattr(attr))
+                            if listclass.getncattr(attr) == 'True':
+                                Tree.__dict__[attribute] = True
+                            elif listclass.getncattr(attr) == 'False':
+                                Tree.__dict__[attribute] = False
                 # }}}
             # }}}
