Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set h_align when opening an existing file to write #125

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/drivers/ncmpio/ncmpio_enddef.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ NC_begins(NC *ncp)
}

/* ncp->begin_var is the aligned starting file offset of the first
variable, also the extent of file header */
* variable (also data section), which is the extent of file header
* (header section). File extent may contain free space for header to grow.
*/

/* Now calculate the starting file offsets for all variables.
loop thru vars, first pass is for the 'non-record' vars */
Expand Down Expand Up @@ -363,7 +365,9 @@ NC_begins(NC *ncp)

ncp->recsize = 0;

/* TODO: alignment for record variables (maybe using a new hint) */
/* The alignment is only applicable to the section of record variables,
* rather than individual record variables.
*/

/* loop thru vars, second pass is for the 'record' vars,
* re-calculate the starting offset for each record variable */
Expand Down Expand Up @@ -982,7 +986,11 @@ ncmpio__enddef(void *ncdp,
else if (r_align > 0) /* r_align is passed from ncmpi__enddef */
ncp->h_align = r_align;
}
if (ncp->h_align == 0) /* still not set */
if (ncp->h_align == 0 && ncp->old == NULL)
/* h_align is still not set. Set h_align only when creating a new
* file. When opening an existing file file, setting h_align here
* may unexpectedly grow the file extent.
*/
ncp->h_align = FILE_ALIGNMENT_DEFAULT;
}
/* else respect user hint */
Expand Down
Loading