Skip to content

Commit

Permalink
Updated logic for netCDF output file format selection in mppnccombine.c
Browse files Browse the repository at this point in the history
If the netCDF format for the output file is not chosen with the -64 or -n4 options then automatically use the netCDF format of the first input file; except if the first input file is netCDF classic then use netCDF 64-bit offset instead for the output file.
  • Loading branch information
HansVahlenkamp authored Dec 10, 2024
1 parent c0cdf8e commit 4e8e202
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions postprocessing/mppnccombine/mppnccombine.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
V2.2.8: [email protected]
If the netCDF format for the output file is not chosen with the -64
or -n4 options then automatically use the netCDF format of the first
input file; netCDF3 64-bit offset or netCDF4 classic model.
input file; except if the first input file is netCDF classic then use
netCDF 64-bit offset instead for the output file.
V2.2.7: [email protected]
Synchronize output file before closing and check for errors.
V2.2.6: Seth Underwood <[email protected]>
Expand Down Expand Up @@ -701,11 +702,12 @@ void usage()
printf(" -e # Ending number #### of a specified range of input filename extensions.\n");
printf(" Files within the range do not have to be consecutively numbered.\n");
printf(" -h # Add a specified number of bytes of padding at the end of the header.\n");
printf(" -64 Create netCDF output files with the netCDF3 64-bit offset format.\n");
printf(" -n4 Create netCDF output files with the netCDF4 classic model format.\n");
printf(" -64 Create netCDF output file with the 64-bit offset format.\n");
printf(" -n4 Create netCDF output file with the netCDF4 classic model format.\n");
printf(" If the netCDF format for the output file is not chosen with the -64\n");
printf(" or -n4 options then automatically use the netCDF format of the first\n");
printf(" input file; netCDF3 64-bit offset or netCDF4 classic model.\n");
printf(" input file; except if the first input file is netCDF classic then use\n");
printf(" netCDF 64-bit offset instead for the output file.\n");
printf(" -d # When in NETCDF4 mode, use deflation of level #.\n");
printf(" -s When in NETCDF4 mode, use shuffle.\n");
printf(" -m Initialize output variables with a \"missing_value\" from the variables\n");
Expand Down Expand Up @@ -913,13 +915,20 @@ int process_file(char *ncname, unsigned char appendnc,
ncoutformat=(NC_CLOBBER | NC_64BIT_OFFSET);
if (verbose) printf(" ncoutformat reset to NC_64BIT_OFFSET \n");
}
else
else if (ncinformat==NC_FORMAT_NETCDF4)
{
if (ncinformat==NC_FORMAT_NETCDF4 || ncinformat==NC_FORMAT_NETCDF4_CLASSIC)
{
ncoutformat=(NC_CLOBBER | NC_NETCDF4 | NC_CLASSIC_MODEL);
if (verbose) printf(" ncoutformat reset to NC_NETCDF4 with NC_CLASSIC_MODEL\n");
}
ncoutformat=(NC_CLOBBER | NC_NETCDF4);
if (verbose) printf(" ncoutformat reset to NC_NETCDF4\n");
}
else if (ncinformat==NC_FORMAT_NETCDF4_CLASSIC)
{
ncoutformat=(NC_CLOBBER | NC_NETCDF4 | NC_CLASSIC_MODEL);
if (verbose) printf(" ncoutformat reset to NC_NETCDF4 with NC_CLASSIC_MODEL\n");
}
else if (ncinformat==NC_FORMAT_64BIT_DATA)
{
ncoutformat=(NC_CLOBBER | NC_64BIT_DATA);
if (verbose) printf(" ncoutformat reset to NC_64BIT_DATA\n");
}
ncclose(ncoutfile->ncfid);
if (nc__create(outncname,ncoutformat,0,&blksz,&ncoutfile->ncfid)==(-1))
Expand Down

0 comments on commit 4e8e202

Please sign in to comment.