fregrid fails with "Error in setting deflation level" when using Netcdf-4
Closed this issue · 0 comments
Describe the bug
When using NetCDF-4 format input files without specifying the compression output level with --deflation=
, fregrid sometimes fails with "Error in setting deflation level: NetCDF: Variable not found".
The problem is a bug within mpp_io.c that sets the compression level: https://github.com/NOAA-GFDL/FRE-NCtools/blob/master/tools/libfrencutils/mpp_io.c#L1024-L1072
The problem is that the variable ID is not consistent between the input and output file. Instead of assuming the variable ids in the input and output files are mapped to the same variables, the loop should be over the output variable IDs, and look up the input variable ID using the name.
To Reproduce
Using fregrid on any Netcdf-4 input file without specifying the compression level may reproduce the problem.
Using fregrid on a Netcdf input file with unregriddable variables (i.e. interp_method=NONE
) while specifying all variables will definitely bring out the error.
Expected behavior
If compression settings are specified on the command line, then they should be used on the output file.
Otherwise, the compression settings of the input file should be used.
System Environment
Describe the system environment, include:
- OS: [e.g. RHEL 7.2]
- Compiler(s): Type and version [e.g. Intel 19.1]
- netCDF Version: For both C and Fortran
- Configure options: Any additional flags, or macros passed to configure
Additional context
Add any other context about the problem. If applicable, include where any files
that help describe, or reproduce the problem exist.