 			pg = pg->next;
 		}
 
-		res[pos] = count;
+		page_count_device[pos2] = count;
 	}
 }
 MC_GLOBAL void spParticleDumpKernel(int const * offset, spParticlePage **buckets, void** page_data_ptr_device,
-		MeshEntityId * page_id_device, int * res)
-{
-	int count = 0;
-
+		MeshEntityId * page_id_device)
+{
 	int pos = offset[spParallelBlockNum()];
 
 	spParticlePage * pg = buckets[spParallelBlockNum()];

 */
void spParticleWrite(spParticle const *sp, spIOStream *os, const char name[], int flag)
{

	char curr_path[2048];
	char new_path[2048];

		for (int j = 0; j < num_of_pages; ++j)
		{
			spParallelMemcpy((void*) ((byte_type*) (d) + j * page_size_in_byte),
					(void*) ((byte_type*) (page_data_ptr_host[j]) + offset_in_byte), page_size_in_byte);
		}

		spIOStreamWriteSimple(os, sp->attrs[i].name, sp->attrs[i].type_tag, d, 2, f_dims, NULL, f_dims, (int) flag);

		spParallelHostFree(&d);
	}
