In my testing I found that setting fill value to NaN and *writing* data caused GRIB API to hang. I don't know why this might be and didn't investigate further, I don't know if the issue is reproducible. I agree with you that it would be nice and simple to do it this way, and I would like to do so, but unfortunately I found this not to be the case in practice.