Commit 6685b950 authored by William F Godoy's avatar William F Godoy
Browse files

Modified bpls to avoid seg faults

Added test for block info in local variables
parent c75ff59b
Loading
Loading
Loading
Loading
+41 −8
Original line number Diff line number Diff line
@@ -670,7 +670,7 @@ int printVariableInfo(core::Engine *fp, core::IO *io,
        fprintf(outf, "  ");
        if (nsteps > 1)
            fprintf(outf, "%zu*", nsteps);
        if (variable->m_Shape.size() > 0)
        if (variable->m_ShapeID == ShapeID::GlobalArray)
        {
            fprintf(outf, "{%zu", variable->m_Shape[0]);
            for (size_t j = 1; j < variable->m_Shape.size(); j++)
@@ -679,6 +679,15 @@ int printVariableInfo(core::Engine *fp, core::IO *io,
            }
            fprintf(outf, "}");
        }
        else if (variable->m_ShapeID == ShapeID::LocalArray)
        {
            fprintf(outf, "{%zu", variable->m_Count[0]);
            for (size_t j = 1; j < variable->m_Count.size(); j++)
            {
                fprintf(outf, ", %zu", variable->m_Count[j]);
            }
            fprintf(outf, "}");
        }
        else
        {
            fprintf(outf, "scalar");
@@ -1522,8 +1531,15 @@ int readVar(core::Engine *fp, core::IO *io, core::Variable<T> *variable)
        }

        // read a slice finally
        Dims startv = helper::Uint64ArrayToSizetVector(tdims - tidx, s + tidx);
        Dims countv = helper::Uint64ArrayToSizetVector(tdims - tidx, c + tidx);
        const Dims startv =
            variable->m_ShapeID == ShapeID::GlobalArray
                ? helper::Uint64ArrayToSizetVector(tdims - tidx, s + tidx)
                : Dims();
        const Dims countv =
            variable->m_ShapeID == ShapeID::GlobalArray
                ? helper::Uint64ArrayToSizetVector(tdims - tidx, c + tidx)
                : Dims();

        if (verbose > 2)
        {
            printf("set selection: ");
@@ -1533,9 +1549,12 @@ int readVar(core::Engine *fp, core::IO *io, core::Variable<T> *variable)
        }

        if (!variable->m_SingleValue)
        {
            if (variable->m_ShapeID == ShapeID::GlobalArray)
            {
                variable->SetSelection({startv, countv});
            }
        }

        if (nsteps > 1)
        {
@@ -2510,16 +2529,30 @@ void print_decomp(core::Engine *fp, core::IO *io, core::Variable<T> *variable)
            fprintf(outf, "        step %*zu: ", ndigits_nsteps, step);
            fprintf(outf, "\n");
            ndigits_nblocks = ndigits(blocks.size() - 1);
            for (size_t j = 0; j < blocks.size(); j++)

            const size_t blocksSize = blocks.size();

            for (size_t j = 0; j < blocksSize; j++)
            {
                fprintf(outf, "          block %*zu: [", ndigits_nblocks, j);

                const Dims blockCount =
                    variable->m_ShapeID == ShapeID::LocalValue
                        ? Dims(ndim, 1)
                        : blocks[j].Count;

                const Dims blockStart =
                    variable->m_ShapeID == ShapeID::GlobalArray
                        ? blocks[j].Start
                        : Dims(blockCount.size(), 0);

                for (size_t k = 0; k < ndim; k++)
                {
                    if (blocks[j].Count[k])
                    if (blockCount[k])
                    {
                        fprintf(outf, "%*" PRIu64 ":%*" PRIu64, ndigits_dims[k],
                                blocks[j].Start[k], ndigits_dims[k],
                                blocks[j].Start[k] + blocks[j].Count[k] - 1);
                                blockStart[k], ndigits_dims[k],
                                blockStart[k] + blockCount[k] - 1);
                    }
                    else
                    {
+1334 −133

File changed.

Preview size limit exceeded, changes collapsed.