Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libmcnptools/src/mergeMctals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Mctal mergeMctals(const std::string& name, const std::vector<std::string> mctal_
Mctal base(mctal_names.at(0));

std::vector<Mctal> mctals;
mctals.reserve(mctal_names.size() - 1);
for(unsigned int m=1; m<mctal_names.size(); m++) {
if( verbosity > 1 )
std::cerr << "Indexing MCTAL file \'" << mctal_names.at(m) << "\'" << std::endl;
mctals.push_back(Mctal(mctal_names.at(m)));
mctals.emplace_back(mctal_names.at(m));
}

const std::vector<int> tallies = base.GetTallyList();
Expand Down Expand Up @@ -137,10 +138,11 @@ Mctal parallelMergeMctals(const std::string& name, const std::vector<std::string
Mctal base(mctal_names.at(lrank));

std::vector<Mctal> mctals;
mctals.reserve(mctal_names.size() / size + 1);
for(size_t m=lrank+size; m<mctal_names.size(); m+=size) {
if( verbosity > 1 )
std::cerr << "Task " << lrank << " indexing MCTAL file \'" << mctal_names.at(m) << "\'" << std::endl;
mctals.push_back(Mctal(mctal_names.at(m)));
mctals.emplace_back(mctal_names.at(m));
}

// build the total number of histories and random numbers used
Expand Down
1 change: 1 addition & 0 deletions libmcnptools/tests/mctal/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ list(APPEND TEST_SRCS
MctalKcodeCycles.cpp
MctalKcodeNdat.cpp
MctalKcodeValue.cpp
MctalMergeManyInputs.cpp
MctalNps.cpp
MctalRandoms.cpp
MctalTallyCBins.cpp
Expand Down
21 changes: 21 additions & 0 deletions libmcnptools/tests/mctal/tests/MctalMergeManyInputs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "gtest/gtest.h"
#include "mcnptools/Mctal.hpp"
#include "mcnptools/mergeMctals.hpp"

#include <cstdio>
#include <string>
#include <vector>

TEST(MctalMerge, ManyInputFiles) {
const std::string output = "test_mctal_merged_many";
std::vector<std::string> mctals(130, "test_mctal");
std::remove(output.c_str());

EXPECT_NO_THROW({
mcnptools::Mctal merged = mcnptools::mergeMctals(output, mctals);
merged.GetTally(1);
merged.GetTally(4);
});

std::remove(output.c_str());
}