Skip to content

Commit 749721f

Browse files
committed
fix FArrayBox I/O for gpu. resize is not safe.
1 parent b25ac20 commit 749721f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Src/Base/AMReX_FArrayBox.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ FABio::read_header (std::istream& is,
500500
//
501501
// Set the FArrayBox to the appropriate size.
502502
//
503-
f.resize(bx,nvar);
503+
if (f.box() != bx || f.nComp() != nvar) {
504+
f.resize(bx,nvar);
505+
}
504506
is.ignore(BL_IGNORE_MAX, '\n');
505507
switch (typ_in)
506508
{
@@ -527,7 +529,9 @@ FABio::read_header (std::istream& is,
527529
//
528530
// Set the FArrayBox to the appropriate size.
529531
//
530-
f.resize(bx,nvar);
532+
if (f.box() != bx || f.nComp() != nvar) {
533+
f.resize(bx,nvar);
534+
}
531535
is.ignore(BL_IGNORE_MAX, '\n');
532536
fio = new FABio_binary(rd);
533537
}
@@ -575,7 +579,9 @@ FABio::read_header (std::istream& is,
575579
//
576580
// Set the FArrayBox to the appropriate size.
577581
//
578-
f.resize(bx,nvar);
582+
if (f.box() != bx || f.nComp() != nvar) {
583+
f.resize(bx,nvar);
584+
}
579585
is.ignore(BL_IGNORE_MAX, '\n');
580586
switch (typ_in)
581587
{
@@ -604,7 +610,9 @@ FABio::read_header (std::istream& is,
604610
//
605611
// Set the FArrayBox to the appropriate size.
606612
//
607-
f.resize(bx,nvar);
613+
if (f.box() != bx || f.nComp() != nvar) {
614+
f.resize(bx,nvar);
615+
}
608616
is.ignore(BL_IGNORE_MAX, '\n');
609617
fio = new FABio_binary(rd);
610618
}

0 commit comments

Comments
 (0)