Skip to content

Bug fix: move data after adding new variables#199

Merged
wkliao merged 7 commits intomasterfrom
grow_data_section
Dec 19, 2025
Merged

Bug fix: move data after adding new variables#199
wkliao merged 7 commits intomasterfrom
grow_data_section

Conversation

@wkliao
Copy link
Copy Markdown
Member

@wkliao wkliao commented Dec 17, 2025

This handles the case when file header extent does not grow after adding new variable. In addition, the case when adding new record variables does not grow the starting offset of record variable section.

This handles the case when file header extent does not grow after adding
new variable. In addition, the case when adding new record variables
does not grow the starting offset of record variable section.
…ection

The setting is based on the followings.

Each time ncmpi__enddef() is called, use env variable and MPI info
object to recalculate ncp->v_align and ncp->r_align, which are later
used to calculate the file starting offsets for fix-sized variable
section and record variable section.

    if (env variable of v_align is set)
        ncp->v_align = env value
    else if (MPI info hint of v_align is set)
        ncp->v_align = hint value
    else if (v_align passed to ncmpi__enddef() > 0)
        ncp->v_align = v_align + 4 - v_align % 4;
    else /* Not set by user, <= 0 */
        ncp->v_align = 0;

if has fix-sized variables
    if ncp->v_align > 0    /* v_align is set by users */
        use it
    else
        ncp->v_align = default 512

    * use ncp->v_align to set ncp->begin_var

    if ncp->r_align > 0    /* r_align is set by users */
        use it
    else
        ncp->r_align = default 4

    * use ncp->r_align to set ncp->begin_rec

else
    discard ncp->v_align
    discard ncp->v_minfree

    if ncp->r_align > 0     /* r_align is set by users */
        use it
    else
        ncp->r_align = default 512

    * use ncp->r_align to set ncp->begin_rec
    * set ncp->begin_var == ncp->begin_rec

Do not reuse ncp->v_align or ncp->r_align in next ncmpi_enddef() !
@wkliao wkliao merged commit fbb6846 into master Dec 19, 2025
4 checks passed
@wkliao wkliao deleted the grow_data_section branch January 1, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant