| 266 | } |
| 267 | |
| 268 | int |
| 269 | DataFileStream::write(Vector &data) |
| 270 | { |
| 271 | if (fileOpen == 0) |
| 272 | this->open(); |
| 273 | |
| 274 | // |
| 275 | // if not parallel, just write the data |
| 276 | // |
| 277 | |
| 278 | if (sendSelfCount == 0) { |
| 279 | (*this) << data; |
| 280 | if (closeOnWrite == true) |
| 281 | this->close(); |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | // |
| 286 | // otherwise parallel, send the data if not p0 |
| 287 | // |
| 288 | |
| 289 | if (sendSelfCount < 0) { |
| 290 | if (data.Size() != 0) { |
| 291 | if ( theChannels[0]->sendVector(0, 0, data) < 0) { |
| 292 | return -1; |
| 293 | } |
| 294 | return 0; |
| 295 | } else |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | // |
| 300 | // if p0 recv the data & write it out sorted |
| 301 | // |
| 302 | |
| 303 | // recv data |
| 304 | for (int i=0; i<=sendSelfCount; i++) { |
| 305 | |
| 306 | int numColumns = (*sizeColumns)(i); |
| 307 | double *dataI = theData[i]; |
| 308 | if (i == 0) { |
| 309 | for (int j=0; j<numColumns; j++) { |
| 310 | dataI[j] = data(j); |
| 311 | } |
| 312 | } else { |
| 313 | if (numColumns != 0) { |
| 314 | Vector *theV = theRemoteData[i]; |
| 315 | if (theChannels[i-1]->recvVector(0, 0, *theV) < 0) { |
| 316 | opserr << "DataFileStream::write - failed to recv data\n"; |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | Matrix &printMapping = *mapping; |
| 323 | |
| 324 | // write data |
| 325 | if (doCSV == 0) { |
no test coverage detected