Skip to content

Commit

Permalink
Merge pull request #218 from rhaas80/rhaas/bugfixes
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
eschnett authored Sep 6, 2023
2 parents 8cc4715 + fcf2770 commit c15f44c
Show file tree
Hide file tree
Showing 28 changed files with 142 additions and 55 deletions.
1 change: 1 addition & 0 deletions CarpetX/src/driver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ struct GHExt {
int nghostzones[dim];

ArrayGroupData() {
array_size = -1;
dimension = -1;
activetimelevels = -1;
for (int d = 0; d < dim; d++) {
Expand Down
2 changes: 2 additions & 0 deletions TestArrayGroup/interface.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

IMPLEMENTS: TestArrayGroup

USES INCLUDE HEADER: loop.hxx

CCTK_REAL test_array[4] TYPE=array DIM=2 SIZE=5,6 DISTRIB=constant
{
test1 test2 test3
Expand Down
9 changes: 4 additions & 5 deletions TestArrayGroup/schedule.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ SCHEDULE TestArrayGroup_Initialize AT Initial
WRITES: test_scalar(everywhere)
WRITES: test_array(everywhere)
WRITES: test_gf(everywhere)
} "Initialize data in the test arrays"
} "Initialize data in grid functions, scalars, and distrib=const arrays"

SCHEDULE TestArrayGroup_Compare AT PostInitial
{
LANG: C
READS: test_scalar(everywhere)
READS: test_array(everywhere)
} "Test data in the test arrays"
READS: test_gf(everywhere)
} "Test data in grid functions, scalars, and distrib=const arrays"

SCHEDULE TestArrayGroup_DynamicData AT PostInitial
{
LANG: C
READS: test_scalar(everywhere)
READS: test_array(everywhere)
READS: test_gf(everywhere)
} "Test DynamicData for grid functions, scalars, and distrib=const arrays"
64 changes: 54 additions & 10 deletions TestArrayGroup/src/TestArray.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ extern "C" void TestArrayGroup_Compare(cGH *cctkGH) {
DECLARE_CCTK_PARAMETERS;
DECLARE_CCTK_ARGUMENTS_TestArrayGroup_Compare;

// test array group
const int imax = 5;
const int jmax = 6;
const int nmax = 4;

int error_count[3] = {0, 0, 0};
int array_error_count[3] = {0, 0, 0};

for (int n = 0; n < nmax; n++) {
std::ostringstream vname1;
Expand All @@ -80,30 +81,73 @@ extern "C" void TestArrayGroup_Compare(cGH *cctkGH) {
for (int i = 0; i < imax; i++) {
const int index = i + j * imax;
if (var1[index] != 1 + i * j * n)
error_count[0] += 1;
array_error_count[0] += 1;
if (var2[index] != 1 + 7 * i * j * n)
error_count[1] += 1;
array_error_count[1] += 1;
if (var3[index] != 1 + 13 * i * j * n)
error_count[2] += 1;
array_error_count[2] += 1;
}
}
}

if (error_count[0] > 0) {
if (array_error_count[0] > 0) {
const int size = nmax * jmax * imax;
CCTK_VERROR("TestArrayGroup: grid array test1 failed in %d of %d elements",
error_count[0], size);
array_error_count[0], size);
}

if (error_count[1] > 0) {
if (array_error_count[1] > 0) {
const int size = nmax * jmax * imax;
CCTK_VERROR("TestArrayGroup: grid array test2 failed in %d of %d elements",
error_count[1], size);
array_error_count[1], size);
}

if (error_count[2] > 0) {
if (array_error_count[2] > 0) {
const int size = nmax * jmax * imax;
CCTK_VERROR("TestArrayGroup: grid array test3 failed in %d of %d elements",
error_count[2], size);
array_error_count[2], size);
}

// test grid function
int gf_gi = CCTK_GroupIndex("TestArrayGroup::test_gf");
cGroup gf_group;
int ierr = CCTK_GroupData(gf_gi, &gf_group);
assert(!ierr);
std::array<int, 3> lsh;
ierr = CCTK_GrouplshGI(cctkGH, gf_group.dim, lsh.data(), gf_gi);
assert(!ierr);

const int i0 = cctk_lbnd[0];
const int j0 = cctk_lbnd[1];
const int k0 = cctk_lbnd[2];

int gf_error_count = 0;

for (int k = 0; k < lsh[2]; k++) {
for (int j = 0; j < lsh[1]; j++) {
for (int i = 0; i < lsh[0]; i++) {
const int index = CCTK_GFINDEX3D(cctkGH, i, j, k);
if(test_gf[index] != (i0 + i) * (j0 + j) * (k0 + k))
gf_error_count += 1;
}
}
}

if (gf_error_count > 0) {
const int size = lsh[2] * lsh[1] * lsh[0];
CCTK_VERROR("TestArrayGroup: grid function test failed in %d of %d elements",
gf_error_count, size);
}

// test grid scalar
int scalar_error_count = 0;

if(*test_scalar != 1)
scalar_error_count += 1;

if (scalar_error_count > 0) {
const int size = 1;
CCTK_VERROR("TestArrayGroup: grid scalar test_scalar failed in %d of %d elements",
scalar_error_count, size);
}
}
50 changes: 46 additions & 4 deletions TestArrayGroup/src/TestDynamicData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
#include <cctk_Arguments.h>
#include <cctk_Parameters.h>

#include "loop.hxx"

using Loop::dim;

extern "C" void TestArrayGroup_DynamicData(CCTK_ARGUMENTS) {
DECLARE_CCTK_PARAMETERS;
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_ARGUMENTS_TestArrayGroup_DynamicData;

struct errorcount_t {
int lsh, ash, gsh, lbnd, ubnd, bbox, nghostzones;
Expand All @@ -21,7 +25,7 @@ extern "C" void TestArrayGroup_DynamicData(CCTK_ARGUMENTS) {
if (ierr)
CCTK_ERROR("error in GroupData for grid functions");

if (gf_data.dim != gf_group.dim || gf_data.dim <= 0)
if (gf_data.dim != gf_group.dim || gf_data.dim != 3)
CCTK_ERROR("incorrect dimension in grid function dynamic data");
if (gf_data.activetimelevels != CCTK_ActiveTimeLevelsGI(cctkGH, gf_gi))
CCTK_ERROR("incorrect activetimelevels in grid function dynamic data");
Expand Down Expand Up @@ -73,7 +77,7 @@ extern "C" void TestArrayGroup_DynamicData(CCTK_ARGUMENTS) {
if (ierr)
CCTK_ERROR("error in GroupData for scalars");

if (scalar_data.dim != scalar_group.dim || scalar_data.dim < 0)
if (scalar_data.dim != scalar_group.dim || scalar_data.dim != 0)
CCTK_ERROR("incorrect dimension in grid scalar dynamic data");
if (scalar_data.activetimelevels !=
CCTK_ActiveTimeLevelsGI(cctkGH, scalar_gi))
Expand All @@ -99,6 +103,25 @@ extern "C" void TestArrayGroup_DynamicData(CCTK_ARGUMENTS) {
if (scalar_data.nghostzones[i] != -1)
error.nghostzones += 1;
}
// data is padded to Loop:dim with "neutral"
for (int i = scalar_data.dim; i < dim; i++) {
if (scalar_data.lsh[i] != 1)
error.lsh += 1;
if (scalar_data.ash[i] != 1)
error.ash += 1;
if (scalar_data.gsh[i] != 1)
error.gsh += 1;
if (scalar_data.lbnd[i] != 0)
error.lbnd += 1;
if (scalar_data.ubnd[i] != 0)
error.lbnd += 1;
if (scalar_data.bbox[2 * i] != 1)
error.bbox += 1;
if (scalar_data.bbox[2 * i + 1] != 1)
error.bbox += 1;
if (scalar_data.nghostzones[i] != 0)
error.nghostzones += 1;
}
if (error.lsh)
CCTK_ERROR("incorrect lsh data in scalar dynamic data");
if (error.ash)
Expand Down Expand Up @@ -128,7 +151,7 @@ extern "C" void TestArrayGroup_DynamicData(CCTK_ARGUMENTS) {

const int sz[2] = {5, 6};

if (array_data.dim != array_group.dim || array_data.dim <= 0)
if (array_data.dim != array_group.dim || array_data.dim != 2)
CCTK_ERROR("incorrect dimension in array dynamic data");
if (array_data.activetimelevels != 1)
CCTK_ERROR("incorrect activetimelevels in array dynamic data");
Expand All @@ -153,6 +176,25 @@ extern "C" void TestArrayGroup_DynamicData(CCTK_ARGUMENTS) {
if (array_data.nghostzones[i] != 0)
error.nghostzones += 1;
}
// data is padded to Loop:dim with "neutral"
for (int i = array_data.dim; i < dim; i++) {
if (array_data.lsh[i] != 1)
error.lsh += 1;
if (array_data.ash[i] != 1)
error.ash += 1;
if (array_data.gsh[i] != 1)
error.gsh += 1;
if (array_data.lbnd[i] != 0)
error.lbnd += 1;
if (array_data.ubnd[i] != 0)
error.lbnd += 1;
if (array_data.bbox[2 * i] != 1)
error.bbox += 1;
if (array_data.bbox[2 * i + 1] != 1)
error.bbox += 1;
if (array_data.nghostzones[i] != 0)
error.nghostzones += 1;
}
if (error.lsh)
CCTK_ERROR("incorrect lsh data in array dynamic data");
if (error.ash)
Expand Down
1 change: 0 additions & 1 deletion TestInterpolate/test/interpolate.par
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ActiveThorns = "
CarpetX
CoordinatesX
IOUtil
SystemTopology
TestInterpolate
"

Expand Down
4 changes: 2 additions & 2 deletions TestOutput/src/TestOutput.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" void TestOutput_SetVarsGlobal(CCTK_ARGUMENTS) {
for (int k = 0; k < 5; ++k)
for (int j = 0; j < 6; ++j)
for (int i = 0; i < 7; ++i)
a3[(k * 5 + j) * 7 + i] = 10000 * k + 100 * j + i;
a3[(k * 6 + j) * 7 + i] = 10000 * k + 100 * j + i;
}

extern "C" void TestOutput_UpdateVarsLocal(CCTK_ARGUMENTS) {
Expand Down Expand Up @@ -58,7 +58,7 @@ extern "C" void TestOutput_UpdateVarsGlobal(CCTK_ARGUMENTS) {
for (int k = 0; k < 5; ++k)
for (int j = 0; j < 6; ++j)
for (int i = 0; i < 7; ++i)
a3[(k * 5 + j) * 7 + i] += 1;
a3[(k * 6 + j) * 7 + i] += 1;
}

} // namespace TestOutput
2 changes: 1 addition & 1 deletion TestOutput/test/checkpoint-openpmd.par
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CarpetX::out_tsv_vars = "
"

CarpetX::checkpoint_method = "openpmd"
IO::checkpoint_dir = "../checkpoints"
IO::checkpoint_dir = $parfile + "/checkpoints"
IO::checkpoint_ID = yes
IO::checkpoint_every = 1
IO::checkpoint_on_terminate = yes
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
0 0.0000000000000000e+00 0 2 0 2.0000000000000000e+02
0 0.0000000000000000e+00 0 3 0 3.0000000000000000e+02
0 0.0000000000000000e+00 0 4 0 4.0000000000000000e+02
0 0.0000000000000000e+00 0 5 0 1.0000000000000000e+04
0 0.0000000000000000e+00 0 5 0 5.0000000000000000e+02
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1:iteration 2:time 3:i 4:j 5:k 6:a3
0 0.0000000000000000e+00 0 0 0 0.0000000000000000e+00
0 0.0000000000000000e+00 0 0 1 1.0100000000000000e+04
0 0.0000000000000000e+00 0 0 2 2.0200000000000000e+04
0 0.0000000000000000e+00 0 0 3 3.0300000000000000e+04
0 0.0000000000000000e+00 0 0 4 4.0400000000000000e+04
0 0.0000000000000000e+00 0 0 1 1.0000000000000000e+04
0 0.0000000000000000e+00 0 0 2 2.0000000000000000e+04
0 0.0000000000000000e+00 0 0 3 3.0000000000000000e+04
0 0.0000000000000000e+00 0 0 4 4.0000000000000000e+04
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
1 5.0000000000000000e-01 0 2 0 2.0100000000000000e+02
1 5.0000000000000000e-01 0 3 0 3.0100000000000000e+02
1 5.0000000000000000e-01 0 4 0 4.0100000000000000e+02
1 5.0000000000000000e-01 0 5 0 1.0002000000000000e+04
1 5.0000000000000000e-01 0 5 0 5.0100000000000000e+02
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1:iteration 2:time 3:i 4:j 5:k 6:a3
1 5.0000000000000000e-01 0 0 0 1.0000000000000000e+00
1 5.0000000000000000e-01 0 0 1 1.0101000000000000e+04
1 5.0000000000000000e-01 0 0 2 2.0201000000000000e+04
1 5.0000000000000000e-01 0 0 3 3.0301000000000000e+04
1 5.0000000000000000e-01 0 0 4 4.0401000000000000e+04
1 5.0000000000000000e-01 0 0 1 1.0001000000000000e+04
1 5.0000000000000000e-01 0 0 2 2.0001000000000000e+04
1 5.0000000000000000e-01 0 0 3 3.0001000000000000e+04
1 5.0000000000000000e-01 0 0 4 4.0001000000000000e+04
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
{ "rank":0, "start":"Wed_Aug_23_11:49:58_2023", "bytes":0, "AWD":{"mus":1156, "nCalls":1}, "close_ts":{"mus":1763, "nCalls":1}, "meta_lvl1":{"mus":13, "nCalls":1}, "meta_lvl2":{"mus":437, "nCalls":1}, "endstep":{"mus":3369, "nCalls":1}, "transport_0":{"type":"File_POSIX", "close":{"mus":54, "nCalls":1}, "write":{"mus":113, "nCalls":1}, "open":{"mus":106, "nCalls":1}}, "transport_1":{"type":"File_POSIX", "close":{"mus":42, "nCalls":1}, "write":{"mus":54, "nCalls":5}, "open":{"mus":125, "nCalls":1}} }
{ "rank":0, "start":"Tue_Sep_05_15:48:52_2023", "bytes":0, "AWD":{"mus":160, "nCalls":1}, "close_ts":{"mus":169, "nCalls":1}, "meta_lvl1":{"mus":16, "nCalls":1}, "meta_lvl2":{"mus":56, "nCalls":1}, "endstep":{"mus":404, "nCalls":1}, "transport_0":{"type":"File_POSIX", "close":{"mus":69, "nCalls":1}, "write":{"mus":139, "nCalls":1}, "open":{"mus":72, "nCalls":1}}, "transport_1":{"type":"File_POSIX", "close":{"mus":14, "nCalls":1}, "write":{"mus":16, "nCalls":5}, "open":{"mus":38, "nCalls":1}} }
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
{ "rank":0, "start":"Wed_Aug_23_11:49:59_2023", "bytes":0, "AWD":{"mus":1514, "nCalls":1}, "close_ts":{"mus":133, "nCalls":1}, "meta_lvl1":{"mus":12, "nCalls":1}, "meta_lvl2":{"mus":225, "nCalls":1}, "endstep":{"mus":1887, "nCalls":1}, "transport_0":{"type":"File_POSIX", "close":{"mus":154, "nCalls":1}, "write":{"mus":178, "nCalls":1}, "open":{"mus":202, "nCalls":1}}, "transport_1":{"type":"File_POSIX", "close":{"mus":64, "nCalls":1}, "write":{"mus":58, "nCalls":5}, "open":{"mus":185, "nCalls":1}} }
{ "rank":0, "start":"Tue_Sep_05_15:48:52_2023", "bytes":0, "AWD":{"mus":89, "nCalls":1}, "close_ts":{"mus":79, "nCalls":1}, "meta_lvl1":{"mus":9, "nCalls":1}, "meta_lvl2":{"mus":50, "nCalls":1}, "endstep":{"mus":229, "nCalls":1}, "transport_0":{"type":"File_POSIX", "close":{"mus":35, "nCalls":1}, "write":{"mus":75, "nCalls":1}, "open":{"mus":58, "nCalls":1}}, "transport_1":{"type":"File_POSIX", "close":{"mus":7, "nCalls":1}, "write":{"mus":7, "nCalls":5}, "open":{"mus":30, "nCalls":1}} }
]
2 changes: 1 addition & 1 deletion TestOutput/test/output-arrays/testoutput-a3.it000000.y.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
0 0.0000000000000000e+00 0 2 0 2.0000000000000000e+02
0 0.0000000000000000e+00 0 3 0 3.0000000000000000e+02
0 0.0000000000000000e+00 0 4 0 4.0000000000000000e+02
0 0.0000000000000000e+00 0 5 0 1.0000000000000000e+04
0 0.0000000000000000e+00 0 5 0 5.0000000000000000e+02
8 changes: 4 additions & 4 deletions TestOutput/test/output-arrays/testoutput-a3.it000000.z.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1:iteration 2:time 3:i 4:j 5:k 6:a3
0 0.0000000000000000e+00 0 0 0 0.0000000000000000e+00
0 0.0000000000000000e+00 0 0 1 1.0100000000000000e+04
0 0.0000000000000000e+00 0 0 2 2.0200000000000000e+04
0 0.0000000000000000e+00 0 0 3 3.0300000000000000e+04
0 0.0000000000000000e+00 0 0 4 4.0400000000000000e+04
0 0.0000000000000000e+00 0 0 1 1.0000000000000000e+04
0 0.0000000000000000e+00 0 0 2 2.0000000000000000e+04
0 0.0000000000000000e+00 0 0 3 3.0000000000000000e+04
0 0.0000000000000000e+00 0 0 4 4.0000000000000000e+04
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
0 0.0000000000000000e+00 0 2 0 2.0000000000000000e+02
0 0.0000000000000000e+00 0 3 0 3.0000000000000000e+02
0 0.0000000000000000e+00 0 4 0 4.0000000000000000e+02
0 0.0000000000000000e+00 0 5 0 1.0000000000000000e+04
0 0.0000000000000000e+00 0 5 0 5.0000000000000000e+02
8 changes: 4 additions & 4 deletions TestOutput/test/output-openpmd/testoutput-a3.it000000.z.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1:iteration 2:time 3:i 4:j 5:k 6:a3
0 0.0000000000000000e+00 0 0 0 0.0000000000000000e+00
0 0.0000000000000000e+00 0 0 1 1.0100000000000000e+04
0 0.0000000000000000e+00 0 0 2 2.0200000000000000e+04
0 0.0000000000000000e+00 0 0 3 3.0300000000000000e+04
0 0.0000000000000000e+00 0 0 4 4.0400000000000000e+04
0 0.0000000000000000e+00 0 0 1 1.0000000000000000e+04
0 0.0000000000000000e+00 0 0 2 2.0000000000000000e+04
0 0.0000000000000000e+00 0 0 3 3.0000000000000000e+04
0 0.0000000000000000e+00 0 0 4 4.0000000000000000e+04
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
1 5.0000000000000000e-01 0 2 0 2.0100000000000000e+02
1 5.0000000000000000e-01 0 3 0 3.0100000000000000e+02
1 5.0000000000000000e-01 0 4 0 4.0100000000000000e+02
1 5.0000000000000000e-01 0 5 0 1.0002000000000000e+04
1 5.0000000000000000e-01 0 5 0 5.0100000000000000e+02
8 changes: 4 additions & 4 deletions TestOutput/test/recover-openpmd/testoutput-a3.it000001.z.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1:iteration 2:time 3:i 4:j 5:k 6:a3
1 5.0000000000000000e-01 0 0 0 1.0000000000000000e+00
1 5.0000000000000000e-01 0 0 1 1.0101000000000000e+04
1 5.0000000000000000e-01 0 0 2 2.0201000000000000e+04
1 5.0000000000000000e-01 0 0 3 3.0301000000000000e+04
1 5.0000000000000000e-01 0 0 4 4.0401000000000000e+04
1 5.0000000000000000e-01 0 0 1 1.0001000000000000e+04
1 5.0000000000000000e-01 0 0 2 2.0001000000000000e+04
1 5.0000000000000000e-01 0 0 3 3.0001000000000000e+04
1 5.0000000000000000e-01 0 0 4 4.0001000000000000e+04
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
2 1.0000000000000000e+00 0 2 0 2.0200000000000000e+02
2 1.0000000000000000e+00 0 3 0 3.0200000000000000e+02
2 1.0000000000000000e+00 0 4 0 4.0200000000000000e+02
2 1.0000000000000000e+00 0 5 0 1.0004000000000000e+04
2 1.0000000000000000e+00 0 5 0 5.0200000000000000e+02
8 changes: 4 additions & 4 deletions TestOutput/test/recover-openpmd/testoutput-a3.it000002.z.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1:iteration 2:time 3:i 4:j 5:k 6:a3
2 1.0000000000000000e+00 0 0 0 2.0000000000000000e+00
2 1.0000000000000000e+00 0 0 1 1.0102000000000000e+04
2 1.0000000000000000e+00 0 0 2 2.0202000000000000e+04
2 1.0000000000000000e+00 0 0 3 3.0302000000000000e+04
2 1.0000000000000000e+00 0 0 4 4.0402000000000000e+04
2 1.0000000000000000e+00 0 0 1 1.0002000000000000e+04
2 1.0000000000000000e+00 0 0 2 2.0002000000000000e+04
2 1.0000000000000000e+00 0 0 3 3.0002000000000000e+04
2 1.0000000000000000e+00 0 0 4 4.0002000000000000e+04

0 comments on commit c15f44c

Please sign in to comment.