| 325 | } |
| 326 | |
| 327 | int |
| 328 | NEESData::insertData(const char *tableName, char *columns[], |
| 329 | int commitTag, const Vector &data) |
| 330 | { |
| 331 | // search the tables for valid table |
| 332 | NEES_table *t = tables; |
| 333 | for (int i=0; i<numTables; i++) { |
| 334 | if (strcmp(t->name, tableName) == 0) |
| 335 | i = numTables; |
| 336 | else |
| 337 | t = t->next; |
| 338 | } |
| 339 | |
| 340 | if ( t == 0) { |
| 341 | opserr << "NEESData::insertData - table: " << tableName << " has not been created\n"; |
| 342 | return -1; |
| 343 | } |
| 344 | |
| 345 | if (t->numColumns != data.Size()) { |
| 346 | opserr << "NEESData::insertData - incorrect number of columns for table: " << tableName << "\n"; |
| 347 | return -2; |
| 348 | } |
| 349 | |
| 350 | char *fileName = t->name; |
| 351 | if (t->hasOutExtension == false) |
| 352 | strcat(fileName,".out"); |
| 353 | |
| 354 | ofstream table; |
| 355 | table.open(fileName, ios::app); |
| 356 | |
| 357 | table << setiosflags(ios::scientific); |
| 358 | table << std::setprecision(16); |
| 359 | |
| 360 | if (table.is_open()) { |
| 361 | // write the data |
| 362 | for (int i=0; i<data.Size(); i++) { |
| 363 | table << data(i) << "\t"; |
| 364 | } |
| 365 | |
| 366 | table << "\n"; |
| 367 | table.close(); |
| 368 | |
| 369 | } else { |
| 370 | opserr << "NEESData::insertData - failed to open file: " << fileName << endln; |
| 371 | return -1; |
| 372 | } |
| 373 | |
| 374 | strcpy(fileName, tableName); |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | |
| 379 | int |