Index: GNUmakefile
===================================================================
--- GNUmakefile	(revision 1d6ab66c1c9f22608cfb6785bba9cd2ea2d07fd1)
+++ GNUmakefile	(revision d409b8cca24c589136321db366285d0ba0d55735)
@@ -79,5 +79,5 @@
 
 MPIDIR = mpi
-MPI_CFLAGS := -g -O3 $(OPENMPFLAG) $(G99FLAG)
+MPI_CFLAGS := -g -O3 $(OPENMPFLAG) $(G99FLAG) -fPIC
 MPI_CPPFLAGS := $(BASE_CPPFLAGS)
 
@@ -233,4 +233,7 @@
 MPI_BLOSC_O := $(addprefix $(MPIDIR)/,$(BLOSC_O))
 
+$(MPIDIR)/libpygio.so: $(MPIDIR)/GenericIO.o $(MPIDIR)/python/lib/gio.o $(MPI_BLOSC_O)
+	$(MPICXX) $(MPI_CFLAGS) $(MPI_SHARED) -fPIC -shared -o $@ $^
+
 $(MPIDIR)/GenericIOPrint: $(MPIDIR)/GenericIOPrint.o $(MPIDIR)/GenericIO.o $(MPI_BLOSC_O)
 	$(MPICXX) $(MPI_CFLAGS) -o $@ $^ 
@@ -251,5 +254,5 @@
 fe-progs: frontend-progs
 
-mpi-progs: $(MPIDIR)/GenericIOPrint $(MPIDIR)/GenericIOVerify $(MPIDIR)/GenericIOBenchmarkRead $(MPIDIR)/GenericIOBenchmarkWrite $(MPIDIR)/GenericIORewrite
+mpi-progs: $(MPIDIR)/GenericIOPrint $(MPIDIR)/GenericIOVerify $(MPIDIR)/GenericIOBenchmarkRead $(MPIDIR)/GenericIOBenchmarkWrite $(MPIDIR)/GenericIORewrite $(MPIDIR)/libpygio.so
 
 frontend-sqlite: $(FEDIR)/GenericIOSQLite.so $(FEDIR)/sqlite3
Index: python/lib/gio.cxx
===================================================================
--- python/lib/gio.cxx	(revision dd5694520387f29badcdcadad3464175fd982107)
+++ python/lib/gio.cxx	(revision d409b8cca24c589136321db366285d0ba0d55735)
@@ -43,22 +43,22 @@
 #include <iostream>
 
-  void read_gio_float(char* file_name, char* var_name, float* data, int field_count){
-    read_gio<float>(file_name,var_name,data,field_count);
+  void read_gio_float(const MPI_Comm &C, char* file_name, char* var_name, float* data, int field_count){
+    read_gio<float>(C, file_name,var_name,data,field_count);
   }
-  void read_gio_double(char* file_name, char* var_name, double* data, int field_count){
-    read_gio<double>(file_name,var_name,data,field_count);
+  void read_gio_double(const MPI_Comm &C, char* file_name, char* var_name, double* data, int field_count){
+    read_gio<double>(C, file_name,var_name,data,field_count);
   }
-  void read_gio_uint16(char* file_name, char* var_name, uint16_t* data, int field_count){
-    read_gio<uint16_t>(file_name,var_name,data,field_count);
+  void read_gio_uint16(const MPI_Comm &C, char* file_name, char* var_name, uint16_t* data, int field_count){
+    read_gio<uint16_t>(C, file_name,var_name,data,field_count);
   }
-  void read_gio_int32(char* file_name, char* var_name, int* data, int field_count){
-    read_gio<int>(file_name,var_name,data,field_count);
+  void read_gio_int32(const MPI_Comm &C, char* file_name, char* var_name, int* data, int field_count){
+    read_gio<int>(C, file_name,var_name,data,field_count);
   }
-  void read_gio_int64(char* file_name, char* var_name, int64_t* data, int field_count){
-    read_gio<int64_t>(file_name,var_name,data,field_count);
+  void read_gio_int64(const MPI_Comm &C, char* file_name, char* var_name, int64_t* data, int field_count){
+    read_gio<int64_t>(C, file_name,var_name,data,field_count);
   }
   
-  int64_t get_elem_num(char* file_name){
-    gio::GenericIO reader(file_name);
+  int64_t get_elem_num(const MPI_Comm &C, char* file_name){
+    gio::GenericIO reader(C, file_name);
     reader.openAndReadHeader(gio::GenericIO::MismatchAllowed);
     int num_ranks = reader.readNRanks();
@@ -70,6 +70,6 @@
   }
 
-  var_type get_variable_type(char* file_name,char* var_name){
-   gio::GenericIO reader(file_name);
+  var_type get_variable_type(const MPI_Comm &C, char* file_name,char* var_name){
+   gio::GenericIO reader(C, file_name);
    std::vector<gio::GenericIO::VariableInfo> VI;
    reader.openAndReadHeader(gio::GenericIO::MismatchAllowed);
@@ -98,6 +98,6 @@
   }
 
-  int get_variable_field_count(char* file_name,char* var_name){
-   gio::GenericIO reader(file_name);
+  int get_variable_field_count(const MPI_Comm &C, char* file_name,char* var_name){
+   gio::GenericIO reader(C, file_name);
    std::vector<gio::GenericIO::VariableInfo> VI;
    reader.openAndReadHeader(gio::GenericIO::MismatchAllowed);
@@ -114,7 +114,12 @@
   }
 
-extern "C" void inspect_gio(char* file_name){
-  int64_t size = get_elem_num(file_name);
-  gio::GenericIO reader(file_name);
+#ifndef GENERICIO_NO_MPI
+extern "C" void inspect_gio(const MPI_Comm &C, char* file_name){
+  gio::GenericIO reader(C, file_name);
+#else
+extern "C" void inspect_gio(const MPI_Comm &C, char* file_name){
+  gio::GenericIO reader(C, file_name);
+#endif
+  int64_t size = get_elem_num(C,file_name);
   std::vector<gio::GenericIO::VariableInfo> VI;
   reader.openAndReadHeader(gio::GenericIO::MismatchAllowed);
Index: python/lib/gio.h
===================================================================
--- python/lib/gio.h	(revision dd5694520387f29badcdcadad3464175fd982107)
+++ python/lib/gio.h	(revision d409b8cca24c589136321db366285d0ba0d55735)
@@ -46,6 +46,11 @@
 
 template <class T>
+#ifndef GENERICIO_NO_MPI
+void read_gio(const MPI_Comm &C, char* file_name, std::string var_name, T*& data, int field_count){
+  gio::GenericIO reader(C, file_name);
+#else
 void read_gio(char* file_name, std::string var_name, T*& data, int field_count){
   gio::GenericIO reader(file_name);
+#endif
   reader.openAndReadHeader(gio::GenericIO::MismatchAllowed);
   int num_ranks = reader.readNRanks();
@@ -71,9 +76,9 @@
 extern "C" int64_t get_elem_num(char* file_name);
 
-extern "C" void read_gio_float (char* file_name, char* var_name, float* data, int field_count);
-extern "C" void read_gio_double(char* file_name, char* var_name, double* data, int field_count);
-extern "C" void read_gio_uint16 (char* file_name, char* var_name, uint16_t* data, int field_count); 
-extern "C" void read_gio_int32 (char* file_name, char* var_name, int* data, int field_count); 
-extern "C" void read_gio_int64 (char* file_name, char* var_name, int64_t* data, int field_count);
+extern "C" void read_gio_float (const MPI_Comm &C, char* file_name, char* var_name, float* data, int field_count);
+extern "C" void read_gio_double(const MPI_Comm &C, char* file_name, char* var_name, double* data, int field_count);
+extern "C" void read_gio_uint16 (const MPI_Comm &C, char* file_name, char* var_name, uint16_t* data, int field_count); 
+extern "C" void read_gio_int32 (const MPI_Comm &C, char* file_name, char* var_name, int* data, int field_count); 
+extern "C" void read_gio_int64 (const MPI_Comm &C, char* file_name, char* var_name, int64_t* data, int field_count);
 enum var_type{
   float_type=0,
@@ -87,3 +92,3 @@
 extern "C" var_type get_variable_type(char* file_name,char* var_name);
 extern "C" int get_variable_field_count(char* file_name,char* var_name);
-extern "C" void inspect_gio(char* file_name);
+extern "C" void inspect_gio(const MPI_Comm &C, char* file_name);
