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

Added fix for blocking factor of 0 in mppnccombine #275

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
43 changes: 21 additions & 22 deletions postprocessing/mppnccombine/mppnccombine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,29 +1004,28 @@ int process_vars(struct fileinfo *ncinfile, struct fileinfo *ncoutfile,
recdimsize=ncinfile->dimsize[ncinfile->recdim];

/* Check the number of records */
if (*nrecs==1)
{
*nrecs=recdimsize;

if ((*bf) >= 1)
{
if ((*bf) > (*nrecs)) {
fprintf(stderr, "blocking factor (k) > total records (%d). Setting blocking factor to %d.\n",
*nrecs, *nrecs);
*bf = *nrecs;
}
if (((*nrecs) % (*bf)) != 0) *nblocks = (int)((*nrecs)/(*bf)) + 1;
else *nblocks = (int)((*nrecs)/(*bf));
}
else
{
/* bf was set to zero, so we do full buffering */
*bf = min(MAX_BF,*nrecs); // we use the maximum blocking factor in our capacity
/* normally we'll have one block, unless we hit MAX_BF */
*nblocks = (int)((*nrecs)/(*bf));
}
if (verbose) fprintf(stderr, "blocking factor=%d, num. blocks=%d, num. records=%d\n",*bf,*nblocks, *nrecs);
if (*nrecs==1) {
*nrecs=recdimsize;

/* adjust bf */
if ((*bf) >= 1) {
if ((*bf) > (*nrecs)) {
fprintf(stderr, "blocking factor (k) > total records (%d). Setting blocking factor to %d.\n",
*nrecs, *nrecs);
0cole marked this conversation as resolved.
Show resolved Hide resolved
*bf = *nrecs;
}
}
else {
/* bf was set to zero, so we do full buffering */
*bf = min(MAX_BF,*nrecs); // we use the maximum blocking factor in our capacity
/* normally we'll have one block, unless we hit MAX_BF */
}
/* find nblocks */
if (((*nrecs) % (*bf)) != 0) *nblocks = (int)((*nrecs)/(*bf)) + 1;
else *nblocks = (int)((*nrecs)/(*bf));

if (verbose) fprintf(stderr, "blocking factor=%d, num. blocks=%d, num. records=%d\n",*bf,*nblocks, *nrecs);
}
else
if (recdimsize != *nrecs)
{
Expand Down
13 changes: 13 additions & 0 deletions t/Test02-mppnccombine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ load test_utils
run_and_check [ -e mppnccombine_output.nc ]
ncdump -h mppnccombine_output.nc
}

@test "mppnccombine combines with blocking factor 0" {

generate_all_from_ncl_num mppnccombine Test02-input

#Combine the files into 1
mppnccombine \
-k 0 \
mppnccombine_output.nc \
mppnccombine.nc.????
run_and_check [ -e mppnccombine_output.nc ]
ncdump -h mppnccombine_output.nc
}
Loading