| 230 | } |
| 231 | |
| 232 | int |
| 233 | BinaryFileStream::write(Vector &data) |
| 234 | { |
| 235 | if (fileOpen == 0) |
| 236 | this->open(); |
| 237 | |
| 238 | // |
| 239 | // if not parallel, just write the data |
| 240 | // |
| 241 | |
| 242 | if (sendSelfCount == 0) { |
| 243 | (*this) << data; |
| 244 | return 0; |
| 245 | } |
| 246 | |
| 247 | // |
| 248 | // otherwise parallel, send the data if not p0 |
| 249 | // |
| 250 | |
| 251 | if (sendSelfCount < 0) { |
| 252 | if (data.Size() != 0) { |
| 253 | return theChannels[0]->sendVector(0, 0, data); |
| 254 | } else |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | // |
| 259 | // if p0 recv the data & write it out sorted |
| 260 | // |
| 261 | |
| 262 | // recv data |
| 263 | for (int i=0; i<=sendSelfCount; i++) { |
| 264 | int numColumns = (*sizeColumns)(i); |
| 265 | double *dataI = theData[i]; |
| 266 | if (i == 0) { |
| 267 | for (int j=0; j<numColumns; j++) { |
| 268 | dataI[j] = data(j); |
| 269 | } |
| 270 | } else { |
| 271 | if (numColumns != 0) { |
| 272 | theChannels[i-1]->recvVector(0, 0, *(theRemoteData[i])); |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | Matrix &printMapping = *mapping; |
| 278 | |
| 279 | // write data |
| 280 | for (int i=0; i<maxCount+1; i++) { |
| 281 | int fileID = (int)printMapping(0,i); |
| 282 | int startLoc = (int)printMapping(1,i); |
| 283 | int numData = (int)printMapping(2,i); |
| 284 | double *data = theData[fileID]; |
| 285 | // for (int j=0; j<numData; j++) |
| 286 | theFile.write((char *)(&data[startLoc]), 8*numData); |
| 287 | } |
| 288 | theFile << "\n"; |
| 289 |
no test coverage detected