proc posout() {local pci, pcti, rank, gid, srcid localobj tgt, f, cell // Write out the 3d position coordinates of each cell
pc.barrier() // Wait for all ranks to get to this point
sprint(cmd,"./results/%s/position.dat", RunName)
f = new File(cmd)
if (pc.id == 0) { // Write header to file 1 time only
f.wopen()
f.printf("cell\tx\ty\tz\thost\n")
f.close()
}
for rank = 0, pc.nhost-1 { // For each processor, allow processor to append to file the positions of its cells
if (rank == pc.id) { // Ensure that each processor runs once
f.aopen() // Open for appending to file
for pcitr(&pci, &pcti, &gid, cellType[0].cellStartGid, cellType[numCellTypes-1].cellEndGid) { // Use the pciter over all non ppStim cells
if (pc.gid_exists(gid)) { // If cell exists on this machine
cell = pc.gid2cell(gid) // Refer to cell
if (cell.is_art()==0) {
f.printf("%d\t%d\t%d\t%d\t%d\n", gid, cell.x, cell.y, cell.z, pc.id)
} else {
f.printf("%d\t%d\t%d\t%d\t%d\n", gid, cell.xpos, cell.ypos, cell.zpos, pc.id)
}
}
}
f.close()
}
pc.barrier()
}
}