aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Requirements
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-04-04 15:29:14 -0400
committerErik Schnetter <schnetter@gmail.com>2013-04-04 15:29:14 -0400
commit21a97f9756161e7aa2407c810fd77e46fec2fc1e (patch)
tree5a6d7e90c1af1e4a7505b3a68cf597dba7266170 /Carpet/Requirements
parent3a31ba2df380c593282b2442ad2f5513eaa1f843 (diff)
Requirements: Use location_t to output warnings and errors
Add function_data to location_t. Update location_t's output routine. Pass iteration number to Requirements::Recompose. Update callers in Carpet.
Diffstat (limited to 'Carpet/Requirements')
-rw-r--r--Carpet/Requirements/src/Requirements.cc6
-rw-r--r--Carpet/Requirements/src/Requirements.hh2
-rw-r--r--Carpet/Requirements/src/all_state.cc68
-rw-r--r--Carpet/Requirements/src/all_state.hh2
-rw-r--r--Carpet/Requirements/src/gridpoint.cc99
-rw-r--r--Carpet/Requirements/src/gridpoint.hh25
-rw-r--r--Carpet/Requirements/src/location.cc13
-rw-r--r--Carpet/Requirements/src/location.hh26
8 files changed, 114 insertions, 127 deletions
diff --git a/Carpet/Requirements/src/Requirements.cc b/Carpet/Requirements/src/Requirements.cc
index d4a9dfd3c..1401b7bc4 100644
--- a/Carpet/Requirements/src/Requirements.cc
+++ b/Carpet/Requirements/src/Requirements.cc
@@ -2,7 +2,6 @@
#include <cctk.h>
#include <cctk_Parameters.h>
-#include <cctk_Functions.h>
#include <cctk_Schedule.h>
#include <util_String.h>
@@ -88,7 +87,8 @@ namespace Requirements {
}
}
- void Recompose(int const reflevel, valid::valid_t const where)
+ void Recompose(int const iteration, int const reflevel,
+ valid::valid_t const where)
{
DECLARE_CCTK_PARAMETERS;
if (check_requirements) {
@@ -101,7 +101,7 @@ namespace Requirements {
where == valid::everywhere ? "everywhere" :
NULL);
}
- all_state.recompose(reflevel, where);
+ all_state.recompose(iteration, reflevel, where);
}
if (inconsistencies_are_fatal and gridpoint_t::there_was_an_error) {
CCTK_WARN(CCTK_WARN_ABORT,
diff --git a/Carpet/Requirements/src/Requirements.hh b/Carpet/Requirements/src/Requirements.hh
index 8c682f6dd..adc50460e 100644
--- a/Carpet/Requirements/src/Requirements.hh
+++ b/Carpet/Requirements/src/Requirements.hh
@@ -32,7 +32,7 @@ namespace Requirements {
void Regrid(int reflevels);
// Recompose, ensures valid data on one level, indicating whether
// boundaries are valid (e.g. if recomposing was a no-op)
- void Recompose(int reflevel, valid::valid_t where);
+ void Recompose(int iteration, int reflevel, valid::valid_t where);
// Free data structures after regridding
void RegridFree();
// Cycle time levels
diff --git a/Carpet/Requirements/src/all_state.cc b/Carpet/Requirements/src/all_state.cc
index 892fd4725..3619ce637 100644
--- a/Carpet/Requirements/src/all_state.cc
+++ b/Carpet/Requirements/src/all_state.cc
@@ -18,7 +18,6 @@ namespace Requirements {
void *const callback_arg)
{
std::vector<bool>& ivs = *static_cast<std::vector<bool>*>(callback_arg);
-
ivs.AT(id) = true;
}
@@ -196,12 +195,13 @@ namespace Requirements {
}
// Update internal data structures when Carpet recomposes
- void all_state_t::recompose(int const reflevel, valid::valid_t const where)
+ void all_state_t::recompose(int const iteration, int const reflevel,
+ valid::valid_t const where)
{
DECLARE_CCTK_PARAMETERS;
int const ng = CCTK_NumGroups();
- location_t loc;
- loc.info = "recompose";
+ location_t loc("recompose");
+ loc.it = iteration;
loc.rl = reflevel;
for (int gi=0; gi<ng; ++gi) {
int const group_type = CCTK_GroupTypeI(gi);
@@ -351,6 +351,8 @@ namespace Requirements {
int const timelevel_offset)
const
{
+ location_t loc("routine", function_data);
+ loc.it = iteration;
// Loop over all clauses
clauses_t const& clauses = all_clauses.get_clauses(function_data);
for (vector<clause_t>::const_iterator iclause = clauses.reads.begin();
@@ -363,9 +365,9 @@ namespace Requirements {
++ivar)
{
int const vi = *ivar;
+ loc.vi = vi;
- if (ignored_variables.AT(vi))
- continue;
+ if (ignored_variables.AT(vi)) continue;
// Loop over all (refinement levels, maps, time levels)
reflevels_t const& rls = vars.AT(vi);
@@ -377,6 +379,7 @@ namespace Requirements {
min_rl = reflevel; max_rl = min_rl+1;
}
for (int rl=min_rl; rl<max_rl; ++rl) {
+ loc.rl = rl;
maps_t const& ms = rls.AT(rl);
int const maps = int(ms.size());
@@ -387,17 +390,19 @@ namespace Requirements {
min_m = map; max_m = min_m+1;
}
for (int m=min_m; m<max_m; ++m) {
+ loc.m = m;
timelevels_t const& tls = ms.AT(m);
int const ntls = int(tls.size());
assert(ntls >= clause.min_num_timelevels());
assert(timelevel != -1);
for (int tl=0; tl<ntls; ++tl) {
+ loc.tl = tl;
if (tl >= timelevel_offset and
clause.active_on_timelevel(tl - timelevel_offset))
{
gridpoint_t const& gp = tls.AT(tl);
- gp.check_state(clause, function_data, vi, iteration, rl, m, tl);
+ gp.check_state(clause, loc);
}
}
@@ -417,14 +422,7 @@ namespace Requirements {
int const timelevel,
int const timelevel_offset)
{
- location_t loc;
- std::string info = "after_routine ";
- info += function_data->thorn;
- info += "::";
- info += function_data->routine;
- info += " in ";
- info += function_data->where;
- loc.info = info.c_str();
+ location_t loc("routine", function_data);
loc.it = iteration;
// Loop over all clauses
clauses_t const& clauses = all_clauses.get_clauses(function_data);
@@ -468,10 +466,10 @@ namespace Requirements {
assert(ntls >= clause.min_num_timelevels());
assert(timelevel != -1);
for (int tl=0; tl<ntls; ++tl) {
+ loc.tl = tl;
if (tl >= timelevel_offset and
clause.active_on_timelevel(tl - timelevel_offset))
{
- loc.tl = tl;
gridpoint_t& gp = tls.AT(tl);
// TODO: If this variable is both read and written
// (i.e. if this is a projection), then only the
@@ -493,8 +491,7 @@ namespace Requirements {
int const iteration,
int const reflevel, int const timelevel)
{
- location_t loc;
- loc.info = "sync";
+ location_t loc("synchronisation", function_data);
loc.it = iteration;
loc.rl = reflevel;
loc.tl = timelevel;
@@ -538,28 +535,28 @@ namespace Requirements {
// Synchronising requires a valid interior
if (not gp.interior()) {
- gp.report_error
- (function_data, vi, iteration, rl, m, tl,
- "synchronising", "interior");
+ gp.report_error(loc, "interior");
}
// Synchronising (i.e. prolongating) requires valid data
// on all time levels of the same map of the next
// coarser refinement level
if (rl > 0) {
+ location_t cloc(loc);
+ cloc.info = "prolongation";
int const crl = rl-1;
+ cloc.rl = crl;
maps_t const& cms = rls.AT(crl);
timelevels_t const& ctls = cms.AT(m);
// TODO: use prolongation_order_time instead?
int const ctimelevels = int(ctls.size());
for (int ctl=0; ctl<ctimelevels; ++ctl) {
+ cloc.tl = ctl;
gridpoint_t const& cgp = ctls.AT(ctl);
if (not (cgp.interior() and cgp.boundary() and
cgp.ghostzones() and cgp.boundary_ghostzones()))
{
- cgp.report_error
- (function_data, vi, iteration, crl, m, ctl,
- "prolongating", "everywhere");
+ cgp.report_error(cloc, "everywhere");
}
}
}
@@ -568,15 +565,11 @@ namespace Requirements {
// ghost zones if boundary zones are set
if (gp.boundary() ) {
if (gp.ghostzones() and gp.boundary_ghostzones()) {
- gp.report_warning
- (function_data, vi, iteration, rl, m, tl,
- "synchronising", "ghostzones+boundary_ghostzones");
+ gp.report_warning(loc, "ghostzones+boundary_ghostzones");
}
} else {
if (gp.ghostzones()) {
- gp.report_warning
- (function_data, vi, iteration, rl, m, tl,
- "synchronising", "ghostzones");
+ gp.report_warning(loc, "ghostzones");
}
}
gp.set_ghostzones(true, loc);
@@ -592,8 +585,7 @@ namespace Requirements {
void all_state_t::restrict1(vector<int> const& groups,
int const iteration, int const reflevel)
{
- location_t loc;
- loc.info = "restrict";
+ location_t loc("restriction");
loc.it = iteration;
loc.rl = reflevel;
// Loop over all variables
@@ -622,9 +614,8 @@ namespace Requirements {
int const v0 = CCTK_FirstVarIndexI(gi);
int const nv = CCTK_NumVarsInGroupI(gi);
for (int vi=v0; vi<v0+nv; ++vi) {
- if (ignored_variables.AT(vi))
- continue;
loc.vi = vi;
+ if (ignored_variables.AT(vi)) continue;
reflevels_t& rls = vars.AT(vi);
int const reflevels = int(rls.size());
@@ -641,8 +632,7 @@ namespace Requirements {
// cannot be sure that all of the interior is valid
// afterwards)
if (not gp.interior()) {
- gp.report_error
- (NULL, vi, iteration, rl, m, tl, "restricting", "interior");
+ gp.report_error(loc, "interior");
}
// Restricting requires valid data on the current time
@@ -653,13 +643,13 @@ namespace Requirements {
maps_t const& fms = rls.AT(frl);
timelevels_t const& ftls = fms.AT(m);
int const ftl = 0;
+ location_t floc(loc);
+ floc.rl=frl; floc.tl = ftl;
gridpoint_t const& fgp = ftls.AT(ftl);
if (not (fgp.interior() and fgp.boundary() and
fgp.ghostzones() and fgp.boundary_ghostzones()))
{
- fgp.report_error
- (NULL, vi, iteration, frl, m, ftl,
- "restricting", "everywhere");
+ fgp.report_error(floc, "everywhere");
}
}
diff --git a/Carpet/Requirements/src/all_state.hh b/Carpet/Requirements/src/all_state.hh
index 06bf6b12f..e6fa4e571 100644
--- a/Carpet/Requirements/src/all_state.hh
+++ b/Carpet/Requirements/src/all_state.hh
@@ -35,7 +35,7 @@ namespace Requirements {
vector<int> const& timelevels,
int reflevel);
void regrid(int reflevels);
- void recompose(int reflevel, valid::valid_t where);
+ void recompose(int iteration, int reflevel, valid::valid_t where);
void regrid_free();
void cycle(int reflevel);
void before_routine(cFunctionData const* function_data,
diff --git a/Carpet/Requirements/src/gridpoint.cc b/Carpet/Requirements/src/gridpoint.cc
index eb5b06fab..122970c8e 100644
--- a/Carpet/Requirements/src/gridpoint.cc
+++ b/Carpet/Requirements/src/gridpoint.cc
@@ -14,129 +14,113 @@ namespace Requirements {
bool gridpoint_t::there_was_a_warning = false;
// Accessors
- void gridpoint_t::set_interior(bool b, const location_t &l)
+ void gridpoint_t::set_interior(bool b, const location_t& loc)
{
const gridpoint_t oldgp = *this;
i_interior = b;
- output_location(oldgp, l);
+ output_location(oldgp, loc);
}
- void gridpoint_t::set_boundary(bool b, const location_t &l)
+ void gridpoint_t::set_boundary(bool b, const location_t& loc)
{
const gridpoint_t oldgp = *this;
i_boundary = b;
- output_location(oldgp, l);
+ output_location(oldgp, loc);
}
- void gridpoint_t::set_ghostzones(bool b, const location_t &l)
+ void gridpoint_t::set_ghostzones(bool b, const location_t& loc)
{
const gridpoint_t oldgp = *this;
i_ghostzones = b;
- output_location(oldgp, l);
+ output_location(oldgp, loc);
}
- void gridpoint_t::set_boundary_ghostzones(bool b, const location_t &l)
+ void gridpoint_t::set_boundary_ghostzones(bool b, const location_t& loc)
{
const gridpoint_t oldgp = *this;
i_boundary_ghostzones = b;
- output_location(oldgp, l);
+ output_location(oldgp, loc);
}
// Check that all the parts of the grid variables read by a function
// are valid. This will be called before the function is executed.
- void gridpoint_t::check_state(clause_t const& clause,
- cFunctionData const* const function_data,
- int const vi,
- int const it,
- int const rl, int const m, int const tl)
+ void gridpoint_t::check_state(clause_t const& clause, const location_t& loc)
const
{
if (not i_interior) {
if (clause.everywhere or clause.interior) {
- report_error(function_data, vi, it, rl, m, tl,
- "calling function", "interior");
+ report_error(loc, "interior");
}
}
if (not i_boundary) {
if (clause.everywhere or clause.boundary) {
- report_error(function_data, vi, it, rl, m, tl,
- "calling function", "boundary");
+ report_error(loc, "boundary");
}
}
if (not i_ghostzones) {
if (clause.everywhere) {
- report_error(function_data, vi, it, rl, m, tl,
- "calling function", "ghostzones");
+ report_error(loc, "ghostzones");
}
}
if (not i_boundary_ghostzones) {
if (clause.everywhere or clause.boundary_ghostzones) {
- report_error(function_data, vi, it, rl, m, tl,
- "calling", "boundary-ghostzones");
+ report_error(loc, "boundary-ghostzones");
}
}
}
- void gridpoint_t::report_error(cFunctionData const* const function_data,
- int const vi,
- int const it,
- int const rl, int const m, int const tl,
- char const* const what,
+ void gridpoint_t::report_error(const location_t& loc,
char const* const where) const
{
- char* const fullname = CCTK_FullName(vi);
+ char* const fullname = CCTK_FullName(loc.vi);
ostringstream state;
- state << "current state: " << *this << std::endl;
- if (function_data) {
+ state << "Current state: " << *this << std::endl;
+ if (loc.fd) {
// The error is related to a scheduled function
CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
"Schedule READS clause not satisfied: "
"Function %s::%s in %s: "
"Variable %s iteration=%d reflevel=%d map=%d timelevel=%d: "
- "%s not valid for %s. %s",
- function_data->thorn, function_data->routine,
- function_data->where,
- fullname, it, rl, m, tl,
- where, what, state.str().c_str());
+ "%s not valid before %s. %s",
+ loc.fd->thorn, loc.fd->routine,
+ loc.fd->where,
+ fullname, loc.it, loc.rl, loc.m, loc.tl,
+ where, loc.info.c_str(), state.str().c_str());
} else {
// The error is not related to a scheduled function
CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
"Schedule READS clause not satisfied: "
"Variable %s iteration=%d reflevel=%d map=%d timelevel=%d: "
- "%s not valid for %s. %s",
- fullname, it, rl, m, tl,
- where, what, state.str().c_str());
+ "%s not valid before %s. %s",
+ fullname, loc.it, loc.rl, loc.m, loc.tl,
+ where, loc.info.c_str(), state.str().c_str());
}
free(fullname);
there_was_an_error = true;
}
- void gridpoint_t::report_warning(cFunctionData const* const function_data,
- int const vi,
- int const it,
- int const rl, int const m, int const tl,
- char const* const what,
+ void gridpoint_t::report_warning(const location_t& loc,
char const* const where) const
{
- char* const fullname = CCTK_FullName(vi);
+ char* const fullname = CCTK_FullName(loc.vi);
ostringstream state;
- state << "current state: " << *this << std::endl;
- if (function_data) {
+ state << "Current state: " << *this << std::endl;
+ if (loc.fd) {
// The error is related to a scheduled function
CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
"Schedule WRITES clause is superfluous: "
"Function %s::%s in %s: "
"Variable %s iteration=%d reflevel=%d map=%d timelevel=%d: "
- "%s already valid for %s. %s",
- function_data->thorn, function_data->routine,
- function_data->where,
- fullname, it, rl, m, tl,
- where, what, state.str().c_str());
+ "%s already valid before %s. %s",
+ loc.fd->thorn, loc.fd->routine,
+ loc.fd->where,
+ fullname, loc.it, loc.rl, loc.m, loc.tl,
+ where, loc.info.c_str(), state.str().c_str());
} else {
// The error is not related to a scheduled function
CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
"Schedule WRITES clause already satisfied: "
"Variable %s iteration=%d reflevel=%d map=%d timelevel=%d: "
- "%s already valid for %s. %s",
- fullname, it, rl, m, tl,
- where, what, state.str().c_str());
+ "%s already valid before %s. %s",
+ fullname, loc.it, loc.rl, loc.m, loc.tl,
+ where, loc.info.c_str(), state.str().c_str());
}
free(fullname);
there_was_a_warning = true;
@@ -144,7 +128,7 @@ namespace Requirements {
// Update this object to reflect the fact that some parts of some
// variables are now valid after a function has been called
- void gridpoint_t::update_state(clause_t const& clause, const location_t &loc)
+ void gridpoint_t::update_state(clause_t const& clause, const location_t& loc)
{
const gridpoint_t oldgp = *this;
if (clause.everywhere or clause.interior) {
@@ -174,7 +158,7 @@ namespace Requirements {
// Some readable and parsable debug output
void gridpoint_t::output_location(const gridpoint_t& oldgp,
- const location_t& l) const
+ const location_t& loc) const
{
DECLARE_CCTK_PARAMETERS;
if (not output_changes) return;
@@ -182,7 +166,7 @@ namespace Requirements {
const gridpoint_t difference = *this ^ oldgp;
if (difference.empty()) return;
- cout << "LOC: " << l << " ("
+ cout << loc << " ("
<< (difference.interior() ? "IN" : "in" ) << ":"
<< interior() << ","
<< (difference.boundary() ? "BO" : "bo" ) << ":"
@@ -190,8 +174,7 @@ namespace Requirements {
<< (difference.ghostzones() ? "GH" : "gh" ) << ":"
<< ghostzones() << ","
<< (difference.boundary_ghostzones() ? "BG" : "bg" ) << ":"
- << boundary_ghostzones() << ") "
- << l.info << "\n";
+ << boundary_ghostzones() << ")\n";
}
}
diff --git a/Carpet/Requirements/src/gridpoint.hh b/Carpet/Requirements/src/gridpoint.hh
index ead8a7338..0db3257b3 100644
--- a/Carpet/Requirements/src/gridpoint.hh
+++ b/Carpet/Requirements/src/gridpoint.hh
@@ -47,21 +47,16 @@ namespace Requirements {
bool boundary() const { return i_boundary; }
bool ghostzones() const { return i_ghostzones; }
bool boundary_ghostzones() const { return i_boundary_ghostzones; }
- void set_interior(bool b, const location_t &l);
- void set_boundary(bool b, const location_t &l);
- void set_ghostzones(bool b, const location_t &l);
- void set_boundary_ghostzones(bool b, const location_t &l);
+ void set_interior(bool b, const location_t& loc);
+ void set_boundary(bool b, const location_t& loc);
+ void set_ghostzones(bool b, const location_t& loc);
+ void set_boundary_ghostzones(bool b, const location_t& loc);
- void check_state(clause_t const& clause,
- cFunctionData const* function_data,
- int vi, int it, int rl, int m, int tl) const;
- void report_error(cFunctionData const* function_data,
- int vi, int it, int rl, int m, int tl,
- char const* what, char const* where) const;
- void report_warning(cFunctionData const* function_data,
- int vi, int it, int rl, int m, int tl,
- char const* what, char const* where) const;
- void update_state(clause_t const& clause, const location_t &loc);
+ void check_state(clause_t const& clause, const location_t& loc) const;
+ void update_state(clause_t const& clause, const location_t& loc);
+
+ void report_error(const location_t& loc, char const* where) const;
+ void report_warning(const location_t& loc, char const* where) const;
// Operators
bool empty() const
@@ -79,7 +74,7 @@ namespace Requirements {
// Input/Output helpers
void input (istream& is);
void output (ostream& os) const;
- void output_location(const gridpoint_t& oldgp, const location_t& l) const;
+ void output_location(const gridpoint_t& oldgp, const location_t& loc) const;
static bool there_was_an_error;
static bool there_was_a_warning;
diff --git a/Carpet/Requirements/src/location.cc b/Carpet/Requirements/src/location.cc
index b672b6e7f..d049d8cfd 100644
--- a/Carpet/Requirements/src/location.cc
+++ b/Carpet/Requirements/src/location.cc
@@ -1,17 +1,26 @@
+#include <cstdlib>
#include <iostream>
+#include <cctk.h>
+
#include <location.hh>
namespace Requirements {
void location_t::output(ostream& os) const
{
- os << "vi:" << vi << ", "
+ os << "LOC: " << info << " ";
+ if (fd) {
+ os << "func " << fd->thorn << "::" << fd->routine << " "
+ << "in " << fd->where << " ";
+ }
+ char* const fullname = CCTK_FullName(vi);
+ os << "it " << it << ", var " << fullname << " "
<< "["
- << "it:" << it << ","
<< "rl:" << rl << ","
<< "m:" << m << ","
<< "tl:" << tl
<< "]";
+ free(fullname);
}
}
diff --git a/Carpet/Requirements/src/location.hh b/Carpet/Requirements/src/location.hh
index 4abb31780..18063846d 100644
--- a/Carpet/Requirements/src/location.hh
+++ b/Carpet/Requirements/src/location.hh
@@ -1,7 +1,10 @@
#ifndef LOCATION_HH
#define LOCATION_HH
+#include <cctk_Schedule.h>
+
#include <iostream>
+#include <string>
namespace Requirements {
@@ -9,20 +12,27 @@ namespace Requirements {
// Struct defining a location of a grid point
struct location_t {
- int it, vi, tl, rl, m;
- char const* info;
+ string info;
+ cFunctionData const* fd;
+ int it;
+ int vi;
+ int rl, m, tl;
location_t():
- it(-1), vi(-1), tl(-1), rl(-1), m(-1), info("")
+ info(""), fd(0), it(-1), vi(-1), rl(-1), m(-1), tl(-1)
+ {}
+ location_t(string info_):
+ info(info_), fd(0), it(-1), vi(-1), rl(-1), m(-1), tl(-1)
{}
- location_t(int it_, int vi_, int tl_, int rl_, int m_, char const* info_):
- it(it_), vi(vi_), tl(tl_), rl(rl_), m(m_), info(info_)
+ location_t(string info_, cFunctionData const* fd_):
+ info(info_), fd(fd_), it(-1), vi(-1), rl(-1), m(-1), tl(-1)
{}
// Output helper
void output (ostream& os) const;
};
-
- inline ostream& operator<< (ostream& os, const location_t& a) {
- a.output(os);
+
+ inline ostream& operator<<(ostream& os, const location_t& loc)
+ {
+ loc.output(os);
return os;
}
}