Changeset 7889dc4
- Timestamp:
- 05/03/19 10:13:44 (6 years ago)
- Branches:
- pympi
- Children:
- 7ecb2a8
- Parents:
- 45bb293
- git-author:
- Thomas Uram <turam@…> (05/03/19 10:13:44)
- git-committer:
- Thomas Uram <turam@…> (05/03/19 10:13:44)
- Location:
- python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/genericio.py
r45bb293 r7889dc4 49 49 #the argument types 50 50 libpygio.get_elem_num.restype=ct.c_int64 51 libpygio.get_elem_num.argtypes=[ct.c_ char_p]51 libpygio.get_elem_num.argtypes=[ct.c_int,ct.c_char_p] 52 52 53 53 libpygio.get_variable_type.restype=ct.c_int … … 75 75 libpygio.inspect_gio.argtypes=[ct.c_char_p] 76 76 77 def gio_read_( file_name,var_name):77 def gio_read_(comm,file_name,var_name): 78 78 if sys.version_info[0] == 3: 79 79 file_name = bytes(file_name,'ascii') 80 80 var_name = bytes(var_name,'ascii') 81 var_size = libpygio.get_elem_num( file_name)82 var_type = libpygio.get_variable_type( file_name,var_name)83 field_count = libpygio.get_variable_field_count( file_name,var_name)81 var_size = libpygio.get_elem_num(comm,file_name) 82 var_type = libpygio.get_variable_type(comm,file_name,var_name) 83 field_count = libpygio.get_variable_field_count(comm,file_name,var_name) 84 84 if(var_type==10): 85 85 print("Variable not found") … … 90 90 #float 91 91 result = np.ndarray((var_size),dtype=np.float32) 92 libpygio.read_gio_float( file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_float)),field_count)92 libpygio.read_gio_float(comm,file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_float)),field_count) 93 93 return result 94 94 elif(var_type==1): 95 95 #double 96 96 result = np.ndarray((var_size),dtype=np.float64) 97 libpygio.read_gio_double( file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_double)),field_count)97 libpygio.read_gio_double(comm,file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_double)),field_count) 98 98 return result 99 99 elif(var_type==2): 100 100 #int32 101 101 result = np.ndarray((var_size),dtype=np.int32) 102 libpygio.read_gio_int32( file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_int32)),field_count)102 libpygio.read_gio_int32(comm,file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_int32)),field_count) 103 103 return result 104 104 elif(var_type==3): 105 105 #int64 106 106 result = np.ndarray((var_size),dtype=np.int64) 107 libpygio.read_gio_int64( file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_int64)),field_count)107 libpygio.read_gio_int64(comm,file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_int64)),field_count) 108 108 return result 109 109 elif(var_type==4): 110 110 #uint16 111 111 result = np.ndarray((var_size,field_count),dtype=np.uint16) 112 libpygio.read_gio_uint16( file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_uint16)),field_count)112 libpygio.read_gio_uint16(comm,file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_uint16)),field_count) 113 113 return result 114 114 115 def gio_read( file_name,var_names):115 def gio_read(comm,file_name,var_names): 116 116 ret = [] 117 117 if not isinstance(var_names,list): 118 118 var_names = [ var_names ] 119 119 for var_name in var_names: 120 ret.append( gio_read_( file_name,var_name) )120 ret.append( gio_read_(comm,file_name,var_name) ) 121 121 return np.array( ret ) 122 122 123 def gio_has_variable( file_name,var_name):123 def gio_has_variable(comm,file_name,var_name): 124 124 if sys.version_info[0] == 3: 125 125 file_name=bytes(file_name,'ascii') 126 126 var_name=bytes(var_name,'ascii') 127 var_size = libpygio.get_elem_num( file_name)128 var_type = libpygio.get_variable_type( file_name,var_name)127 var_size = libpygio.get_elem_num(comm,file_name) 128 var_type = libpygio.get_variable_type(comm,file_name,var_name) 129 129 return var_type!=10 130 130 131 def gio_inspect( file_name):131 def gio_inspect(comm,file_name): 132 132 if sys.version_info[0] == 3: 133 133 file_name=bytes(file_name,'ascii') -
python/lib/gio.h
rd409b8c r7889dc4 74 74 reader.close(); 75 75 } 76 extern "C" int64_t get_elem_num(c har* file_name);76 extern "C" int64_t get_elem_num(const MPI_Comm &c, char* file_name); 77 77 78 78 extern "C" void read_gio_float (const MPI_Comm &C, char* file_name, char* var_name, float* data, int field_count); … … 90 90 var_not_found=10 91 91 }; 92 extern "C" var_type get_variable_type(c har* file_name,char* var_name);93 extern "C" int get_variable_field_count(c har* file_name,char* var_name);92 extern "C" var_type get_variable_type(const MPI_Comm &C, char* file_name,char* var_name); 93 extern "C" int get_variable_field_count(const MPI_Comm &C, char* file_name,char* var_name); 94 94 extern "C" void inspect_gio(const MPI_Comm &C, char* file_name);
Note: See TracChangeset
for help on using the changeset viewer.