Skip to content

Commit 664fcca

Browse files
author
Wood, Tony
committed
Remove manual flushing and calls to std::endl.
1 parent f99113c commit 664fcca

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

src/orbit/Bunch.cc

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,6 @@ int Bunch::getCapacity(){
893893

894894
void Bunch::print(std::ostream& Out)
895895
{
896-
int N_flush = 10000;
897-
898896
//single CPU case
899897
if(rank_MPI == 0){
900898

@@ -905,7 +903,7 @@ void Bunch::print(std::ostream& Out)
905903
ParticleAttributes* attrCntr = *pos;
906904
Out << attrCntr->name()<<" ";
907905
}
908-
Out << std::endl;
906+
Out << '\n';
909907

910908
for (pos = attrCntrVect.begin(); pos != attrCntrVect.end(); ++pos) {
911909
ParticleAttributes* attrCntr = *pos;
@@ -918,7 +916,7 @@ void Bunch::print(std::ostream& Out)
918916
double val = params_pos->second;
919917
Out << name <<" " << val << " ";
920918
}
921-
Out << std::endl;
919+
Out << '\n';
922920
}
923921
}
924922

@@ -927,13 +925,13 @@ void Bunch::print(std::ostream& Out)
927925
bunchAttr->getIntAttributeNames(bunch_attr_names);
928926
for(int i = 0, n = bunch_attr_names.size(); i < n; i++){
929927
Out << "% BUNCH_ATTRIBUTE_INT "<<bunch_attr_names[i]<<" ";
930-
Out << bunchAttr->intVal(bunch_attr_names[i]) <<" "<< std::endl;
928+
Out << bunchAttr->intVal(bunch_attr_names[i]) <<" "<< '\n';
931929
}
932930
bunch_attr_names.clear();
933931
bunchAttr->getDoubleAttributeNames(bunch_attr_names);
934932
for(int i = 0, n = bunch_attr_names.size(); i < n; i++){
935933
Out << "% BUNCH_ATTRIBUTE_DOUBLE "<<bunch_attr_names[i]<<" ";
936-
Out << bunchAttr->doubleVal(bunch_attr_names[i]) <<" "<< std::endl;
934+
Out << bunchAttr->doubleVal(bunch_attr_names[i]) <<" "<< '\n';
937935
}
938936

939937
//print synchronous particle parameters to the stream
@@ -946,7 +944,7 @@ void Bunch::print(std::ostream& Out)
946944
Out << attrCntr->attrDescription()<<" ";
947945
}
948946

949-
Out << std::endl;
947+
Out << '\n';
950948

951949
Out <<std::setprecision(8); //<< std::setiosflags(ios::scientific);
952950

@@ -967,12 +965,9 @@ void Bunch::print(std::ostream& Out)
967965
Out << getParticleAttributeVal(i,j) <<" ";
968966
}
969967

970-
Out <<std::endl;
968+
Out <<'\n';
971969
}
972-
973-
if (i % N_flush == 0){Out.flush();}
974970
}
975-
Out.flush();
976971
if(size_MPI == 1) return;
977972
}
978973

@@ -1046,16 +1041,13 @@ void Bunch::print(std::ostream& Out)
10461041
Out<< dump_arr[(nDimAndAttr)*j + 7 + k] << " ";
10471042
}
10481043

1049-
Out << std::endl;
1044+
Out << '\n';
10501045
}
1051-
1052-
if (j % N_flush == 0){ Out.flush();}
10531046
}
10541047
}
10551048
}
10561049
}
10571050

1058-
if(rank_MPI == 0){Out.flush();}
10591051
BufferStore::getBufferStore()->setUnusedIntArr(buff_index0);
10601052
BufferStore::getBufferStore()->setUnusedIntArr(buff_index1);
10611053
BufferStore::getBufferStore()->setUnusedDoubleArr(buff_index2);

src/orbit/SyncPart.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -488,51 +488,49 @@ void SyncPart::print(std::ostream& Out)
488488
Out << getY() <<" ";
489489
Out << getZ() <<" ";
490490
Out <<" x, y, z positions in [m]";
491-
Out << std::endl;
491+
Out << '\n';
492492

493493
//print momentum
494494
Out << "% SYNC_PART_MOMENTUM ";
495495
Out << getPX() <<" ";
496496
Out << getPY() <<" ";
497497
Out << getPZ() <<" ";
498498
Out <<" px, py, pz momentum component in GeV/c";
499-
Out << std::endl;
499+
Out << '\n';
500500

501501
//print x-axis ort
502502
Out << "% SYNC_PART_X_AXIS ";
503503
Out << getNormalXX() <<" ";
504504
Out << getNormalXY() <<" ";
505505
Out << getNormalXZ() <<" ";
506506
Out <<" nxx, nxy, pxz - x-axis ort coordinates";
507-
Out << std::endl;
507+
Out << '\n';
508508

509509
//print energy
510510
Out << "% info only: energy of the synchronous particle [GeV] = ";
511511
Out << getEnergy() <<" ";
512-
Out << std::endl;
512+
Out << '\n';
513513

514514
//print momentum
515515
Out << "% info only: momentum of the synchronous particle [GeV/c] = ";
516516
Out << getMomentum() <<" ";
517-
Out << std::endl;
517+
Out << '\n';
518518

519519
//print beta
520520
Out << "% info only: beta=v/c of the synchronous particle = ";
521521
Out << getBeta() <<" ";
522-
Out << std::endl;
522+
Out << '\n';
523523

524524
//print gamma
525525
Out << "% info only: gamma=1/sqrt(1-(v/c)**2) of the synchronous particle = ";
526526
Out << getGamma() <<" ";
527-
Out << std::endl;
527+
Out << '\n';
528528

529529
//print time
530530
Out << "% SYNC_PART_TIME ";
531531
Out << getTime() <<" ";
532532
Out <<" time in [sec]";
533-
Out << std::endl;
533+
Out << '\n';
534534
}
535-
536-
if(rank_MPI == 0){Out.flush();}
537535
// ===== MPI end =====
538536
}

0 commit comments

Comments
 (0)