diff --git a/postprocessing/mppnccombine/mppnccombine.c b/postprocessing/mppnccombine/mppnccombine.c index 7c8cea12..d797fbfc 100644 --- a/postprocessing/mppnccombine/mppnccombine.c +++ b/postprocessing/mppnccombine/mppnccombine.c @@ -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); + *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) { diff --git a/t/Test02-mppnccombine.sh b/t/Test02-mppnccombine.sh index 6785e76a..06257d87 100755 --- a/t/Test02-mppnccombine.sh +++ b/t/Test02-mppnccombine.sh @@ -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 +}