-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move all print statements to execute() #435
base: issue-432
Are you sure you want to change the base?
Conversation
@@ -185,20 +185,40 @@ specfem::IO::read_mesh(const std::string filename, | |||
|
|||
stream.close(); | |||
|
|||
// Print material properties | |||
const auto &l_elastic_isotropic = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a separate print mesh function, the osstream operator could be overloaded like so:
class A {
int val;
public:
A(int v) : val(v) {}
friend ostream& operator<<(ostream& os, const A& obj) {
os << obj.val;
return os;
}
};
then you can just
std::cout << mesh << std::endl;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we define std::cout << mesh, it should call mesh.print(), which is already defined and prints different stuff.
void print(std::ostream &out) const { | ||
out << " Quadrature in X-dimension \n"; | ||
gll.print(out); | ||
|
||
out << " Quadrature in Z-dimension \n"; | ||
gll.print(out); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::cout << gll has already been defined, but at this stage not declared. I could use some help on the import order.
@@ -41,8 +41,15 @@ void execute( | |||
// -------------------------------------------------------------- | |||
// Read mesh and materials | |||
// -------------------------------------------------------------- | |||
const auto quadrature = setup.instantiate_quadrature(); | |||
const auto quadratures = setup.instantiate_quadrature(); | |||
if (mpi->main_proc()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the options are two, either you check here whether it's the main_proc() and then use the ostream << overload, or you parse mpi check locally if you are on main_proc and return if you aren't.
What do you think? Am i forgetting something?
Option 3:
the struct should all have the osstream overload. mpi->cout should really check whether you are on main proc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this otherwise
Issue Number
Closes #434