Load(): Bug when loading some files that have scale factor and offset, plus requesting interpolation and subsetting
As reported by @ncortesi
data <- Load('psl', 'ecmwf/system4_m1', NULL, '19820101', leadtimemax = 1, output = 'lonlat', storefreq = 'daily', grid = 'r480x241', lonmax = 100)
gives the error
Error in Rsx_nc4_put_vara_int: NetCDF: Numeric conversion not representable
Error in ncvar_put(fnc, ncdf_var, tmp) :
C function Rsx_nc4_put_vara_int returned error
This happens because Load() needs, in this particular situation, to create temporary files. But R cannot save data back with scale factor and offset. The crash only occurs when the original files contain data values great enough to overflow, after applying the offset and scale factor, the representation range of the original data type (short, int, float, ...).
The involved file in this case is /esnas/exp/ecmwf/system4_m1/daily_mean/psl_f6h/psl_19820101.nc