Skip to content

Commit

Permalink
Clean up screen output about default vector inputs
Browse files Browse the repository at this point in the history
Specifically, eliminate very chatty output from grvy when default
vector input is used.  This is a bit hacky b/c we have to set the grvy
loglevel prior to Read_Var_Vec call and reset it afterward.  But I
don't see a cleaner way to keep grvy from outputing a message from
every mpi rank.  We still give a message from TPS, but only on rank 0.
  • Loading branch information
trevilo committed Dec 3, 2024
1 parent c8542cf commit bdaa23d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/tps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,22 @@ void Tps::getInput(const char *name, T &var, T varDefault) {
void Tps::getVec(const char *name, Vector &vec, size_t numElems, const Vector &vdef) {
if ((size_t)vdef.Size() < numElems) exit(ERROR);
if ((size_t)vec.Size() < numElems) vec.SetSize(numElems);

// To avoid grvy chattiness from Read_Var_Vec, set log level to
// GRVY_NOLOG, just for this call. Reset below to previous value.
const int grvy_log_level = grvy_log_getlevel();
grvy_log_setlevel(GRVY_NOLOG);

if (!iparse_.Read_Var_Vec(name, vec.HostWrite(), numElems)) {
grvy_printf(GRVY_INFO, "Setting input vector %s to default.", name);
grvy_log_setlevel(grvy_log_level);
if (isRank0_) grvy_printf(GRVY_INFO, "Setting input vector %s to default.\n", name);
double *hv = vec.HostWrite();
const double *hd = vdef.HostRead();
for (size_t i = 0; i < numElems; i++) {
hv[i] = hd[i];
}
}
grvy_log_setlevel(grvy_log_level);
}

/** Read an input value for keyword [name] and store in var. If
Expand All @@ -364,7 +372,6 @@ void Tps::getRequiredInput(const char *name, T &var) {
std::cout << "ERROR: Unable to read required input variable -> " << name << std::endl;
exit(ERROR);
}
return;
}

/** \brief Input parsing for vector quantities that must be provided.
Expand Down

0 comments on commit bdaa23d

Please sign in to comment.