Index: branches/numpy_misc/tools/write_large_files/rwi4_big_file.py
===================================================================
--- branches/numpy_misc/tools/write_large_files/rwi4_big_file.py	(revision 6819)
+++ branches/numpy_misc/tools/write_large_files/rwi4_big_file.py	(revision 6820)
@@ -8,8 +8,10 @@
 # that is checked when the file is read.
 #
-# So, element E of slice S ov variable V has the float value:
-#     V*1000 + S . E*1.0e-1
+# So, for variable V (numbering from 0), slice S (starting from 0), element
+# E will range from 0 to 10**6-1, and the element value will be:
+#     S*100 + V + E*1.0E-6
 # which will look like:
-#     VVVSSSS.0EEEEEE
+#     SSSSVV.EEEEEE
+# This implies that the maximum number of variables written is 100 (0 to 99).
 ################################################################################
 
@@ -28,5 +30,5 @@
 
 # array slice definitions
-XDIM = 1024*1024
+XDIM = 1000*1000
 SLICE_SIZE = XDIM*8	# 8 bytes / float
 MBYTE = 1024*1024
@@ -47,5 +49,5 @@
 
 # mask for variable names
-VarnameMask = 'var_%04d'
+VarnameMask = 'var_%02d'
 
 
@@ -74,5 +76,4 @@
     for var_num in xrange(num_variables):
         varname = VarnameMask % var_num
-        var = fid.variables[varname]
 
         # num variable bytes written counter
@@ -85,7 +86,6 @@
 
             # create expected slice array
-            slice_array = slice_array_mask*slice_number + var_num*1000
-            for x in xrange(XDIM):
-                slice_array[x] += x*1.0e-7
+            slice_array = slice_array_mask*slice_number*100 + var_num
+            slice_array += ElementIndexArray
 
             if Verbose:
@@ -96,7 +96,7 @@
                         float(file_bytes_read)/MBYTE))
 
-#            var_array = fid.variables[varname][slice_number,:]
-            var_array = var[slice_number,:]
-            if num.any(var_array != slice_array):
+            var_array = fid.variables[varname][slice_number,:]
+            if not num.allclose(var_array, slice_array):
+##            if num.any(var_array != slice_array):
                 print 'Read variable %s, slice %d: got unexpected value' % \
                       (varname, slice_number)
@@ -161,7 +161,6 @@
 
             # create unique slice array
-            slice_array = slice_array_mask*slice_number + var_num*1000
-            for x in xrange(XDIM):
-                slice_array[x] += x*1.0e-7
+            slice_array = slice_array_mask*slice_number*100 + var_num
+            slice_array += ElementIndexArray
 
             fid.variables[varname][slice_number,:] = slice_array
@@ -169,5 +168,6 @@
             if CloseAfterSlice:
                 fid.close()
-                fid = nc.NetCDFFile(filename, 'a4')
+#                fid = nc.NetCDFFile(filename, 'a4')
+                fid = nc.NetCDFFile(filename, 'a')
 
             file_bytes_written += SLICE_SIZE
@@ -204,4 +204,5 @@
     print "  and <numvars> is the number of variables of the above size"
     print "                    to write.  If not supplied, 1 is assumed."
+    print "                    There can be at most 100 variables."
     print "  and <opts>    is zero or more of:"
     print "                    -c s    close & open the output file after"
@@ -217,4 +218,5 @@
 def main(argv=None):
     global TimeFileWrite, TimeFileRead, CloseAfterSlice, Verbose
+    global ElementIndexArray
 
     if argv is None:
@@ -259,5 +261,5 @@
 
     var_size = args[0][:-1]
-    modifier =args[0][-1]
+    modifier = args[0][-1]
 
     if modifier in '0123456789':
@@ -280,4 +282,13 @@
             usage()
 
+    if num_vars > 100:
+        usage()
+
+    # initialize the global element index array which contains
+    # 0.EEEEEE in each element.
+    ElementIndexArray = num.ndarray((XDIM,), 'd')
+    for x in xrange(XDIM):
+        ElementIndexArray[x] = x*1.0e-6
+    
     # write the required file
     filename = write_file(var_size, num_vars)
@@ -288,5 +299,5 @@
         return 10
 
-    print 'Read/write of NectCDF file was correct'
+#    print 'Read/write of NectCDF file was correct'
     return 0
 
Index: branches/numpy_misc/tools/write_large_files/rwi_big_file.py
===================================================================
--- branches/numpy_misc/tools/write_large_files/rwi_big_file.py	(revision 6819)
+++ branches/numpy_misc/tools/write_large_files/rwi_big_file.py	(revision 6820)
@@ -8,8 +8,10 @@
 # that is checked when the file is read.
 #
-# So, element E of slice S ov variable V has the float value:
-#     V*1000 + S . E*1.0e-1
+# So, for variable V (numbering from 0), slice S (starting from 0), element
+# E will range from 0 to 10**6-1, and the element value will be:
+#     S*100 + V + E*1.0E-6
 # which will look like:
-#     VVVSSSS.0EEEEEE
+#     SSSSVV.EEEEEE
+# This implies that the maximum number of variables written is 100 (0 to 99).
 ################################################################################
 
@@ -28,5 +30,5 @@
 
 # array slice definitions
-XDIM = 1024*1024
+XDIM = 1000*1000
 SLICE_SIZE = XDIM*8	# 8 bytes / float
 MBYTE = 1024*1024
@@ -47,5 +49,5 @@
 
 # mask for variable names
-VarnameMask = 'var_%04d'
+VarnameMask = 'var_%02d'
 
 
@@ -87,30 +89,24 @@
 
             # create expected slice array
-            slice_array = slice_array_mask*slice_number + var_num*1000
-            for x in xrange(XDIM):
-                slice_array[x] += x*1.0e-7
+            slice_array = slice_array_mask*slice_number*100 + var_num
+            slice_array += ElementIndexArray
 
             if Verbose:
                 print ('File %s, variable %s, reading slice %d: '
                        'var=%.1fMiB, file=%.1fMiB' %
-                       (filename, varname, slice_number, float(var_bytes_read)/MBYTE,
+                       (filename, varname, slice_number,
+                        float(var_bytes_read)/MBYTE,
                         float(file_bytes_read)/MBYTE))
 
             var_array = fid.variables[varname][slice_number,:]
-            if num.any(var_array != slice_array):
-                result = False
-                if Verbose:
-                    print 'Read variable %s, slice %d: got unexpected value' % \
-                          (varname, slice_number)
-                    for x in xrange(XDIM):
-                        if var_array[x] != slice_array[x]:
-                            print 'Got %f, expected %f' % (var_array[x], slice_array[x])
-                    sys.exit(0)
+            if not num.allclose(var_array, slice_array):
+##            if num.any(var_array != slice_array):
                 print 'Read variable %s, slice %d: got unexpected value' % \
                       (varname, slice_number)
                 for x in xrange(XDIM):
                     if var_array[x] != slice_array[x]:
-                        print 'Got %f, expected %f' % (var_array[x], slice_array[x])
-                        sys.exit(0)
+                        print 'Index %d, got %f, expected %f' % \
+                              (x, var_array[x], slice_array[x])
+                        return False
 
             slice_number += 1
@@ -127,5 +123,5 @@
                (stop_file_read - start_file_read))
 
-    return result
+    return True
 
 
@@ -168,7 +164,6 @@
 
             # create unique slice array
-            slice_array = slice_array_mask*slice_number + var_num*1000
-            for x in xrange(XDIM):
-                slice_array[x] += x*1.0e-7
+            slice_array = slice_array_mask*slice_number*100 + var_num
+            slice_array += ElementIndexArray
 
             fid.variables[varname][slice_number,:] = slice_array
@@ -188,4 +183,6 @@
 
         slice_number += 1
+
+    fid.close()
 
     if TimeFileWrite:
@@ -209,4 +206,5 @@
     print "  and <numvars> is the number of variables of the above size"
     print "                    to write.  If not supplied, 1 is assumed."
+    print "                    There can be at most 100 variables."
     print "  and <opts>    is zero or more of:"
     print "                    -c s    close & open the output file after"
@@ -222,4 +220,5 @@
 def main(argv=None):
     global TimeFileWrite, TimeFileRead, CloseAfterSlice, Verbose
+    global ElementIndexArray
 
     if argv is None:
@@ -264,5 +263,5 @@
 
     var_size = args[0][:-1]
-    modifier =args[0][-1]
+    modifier = args[0][-1]
 
     if modifier in '0123456789':
@@ -285,4 +284,13 @@
             usage()
 
+    if num_vars > 100:
+        usage()
+
+    # initialize the global element index array which contains
+    # 0.EEEEEE in each element.
+    ElementIndexArray = num.ndarray((XDIM,), 'd')
+    for x in xrange(XDIM):
+        ElementIndexArray[x] = x*1.0e-6
+    
     # write the required file
     filename = write_file(var_size, num_vars)
@@ -293,5 +301,5 @@
         return 10
 
-    print 'Read/write of NectCDF file was correct'
+#    print 'Read/write of NectCDF file was correct'
     return 0
 
Index: branches/numpy_misc/tools/write_large_files/rwil_big_file.py
===================================================================
--- branches/numpy_misc/tools/write_large_files/rwil_big_file.py	(revision 6819)
+++ branches/numpy_misc/tools/write_large_files/rwil_big_file.py	(revision 6820)
@@ -8,8 +8,10 @@
 # that is checked when the file is read.
 #
-# So, element E of slice S ov variable V has the float value:
-#     V*1000 + S . E*1.0e-1
+# So, for variable V (numbering from 0), slice S (starting from 0), element
+# E will range from 0 to 10**6-1, and the element value will be:
+#     S*100 + V + E*1.0E-6
 # which will look like:
-#     VVVSSSS.0EEEEEE
+#     SSSSVV.EEEEEE
+# This implies that the maximum number of variables written is 100 (0 to 99).
 ################################################################################
 
@@ -28,5 +30,5 @@
 
 # array slice definitions
-XDIM = 1024*1024
+XDIM = 1000*1000
 SLICE_SIZE = XDIM*8	# 8 bytes / float
 MBYTE = 1024*1024
@@ -47,5 +49,5 @@
 
 # mask for variable names
-VarnameMask = 'var_%04d'
+VarnameMask = 'var_%02d'
 
 
@@ -84,7 +86,6 @@
 
             # create expected slice array
-            slice_array = slice_array_mask*slice_number + var_num*1000
-            for x in xrange(XDIM):
-                slice_array[x] += x*1.0e-7
+            slice_array = slice_array_mask*slice_number*100 + var_num
+            slice_array += ElementIndexArray
 
             if Verbose:
@@ -96,6 +97,6 @@
 
             var_array = fid.variables[varname][slice_number,:]
-
-            if num.any(var_array != slice_array):
+            if not num.allclose(var_array, slice_array):
+##            if num.any(var_array != slice_array):
                 print 'Read variable %s, slice %d: got unexpected value' % \
                       (varname, slice_number)
@@ -160,7 +161,6 @@
 
             # create unique slice array
-            slice_array = slice_array_mask*slice_number + var_num*1000
-            for x in xrange(XDIM):
-                slice_array[x] += x*1.0e-7
+            slice_array = slice_array_mask*slice_number*100 + var_num
+            slice_array += ElementIndexArray
 
             fid.variables[varname][slice_number,:] = slice_array
@@ -168,6 +168,6 @@
             if CloseAfterSlice:
                 fid.close()
-                fid = nc.NetCDFFile(filename, 'al')
-#                fid = nc.NetCDFFile(filename, 'a')
+#                fid = nc.NetCDFFile(filename, 'al')
+                fid = nc.NetCDFFile(filename, 'a')
 
             file_bytes_written += SLICE_SIZE
@@ -204,4 +204,5 @@
     print "  and <numvars> is the number of variables of the above size"
     print "                    to write.  If not supplied, 1 is assumed."
+    print "                    There can be at most 100 variables."
     print "  and <opts>    is zero or more of:"
     print "                    -c s    close & open the output file after"
@@ -217,4 +218,5 @@
 def main(argv=None):
     global TimeFileWrite, TimeFileRead, CloseAfterSlice, Verbose
+    global ElementIndexArray
 
     if argv is None:
@@ -259,5 +261,5 @@
 
     var_size = args[0][:-1]
-    modifier =args[0][-1]
+    modifier = args[0][-1]
 
     if modifier in '0123456789':
@@ -280,4 +282,13 @@
             usage()
 
+    if num_vars > 100:
+        usage()
+
+    # initialize the global element index array which contains
+    # 0.EEEEEE in each element.
+    ElementIndexArray = num.ndarray((XDIM,), 'd')
+    for x in xrange(XDIM):
+        ElementIndexArray[x] = x*1.0e-6
+    
     # write the required file
     filename = write_file(var_size, num_vars)
@@ -288,5 +299,5 @@
         return 10
 
-    print 'Read/write of NectCDF file was correct'
+#    print 'Read/write of NectCDF file was correct'
     return 0
 
