From 20824cdaab6f7bf8b6f6d52c6b0a2d0790299c5c Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Sat, 22 Jul 2023 18:48:59 +1000 Subject: [PATCH] Added unit attribute in the netcdf output file. --- actions/actiontsc.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/actions/actiontsc.h b/actions/actiontsc.h index 37d1ffa..0aa5c15 100644 --- a/actions/actiontsc.h +++ b/actions/actiontsc.h @@ -144,6 +144,13 @@ template MString ActionTSC::DoAction(const CLArgs& args, D& ds) if(ret != NC_NOERR) return "Can't write long_name attribute of " + vname + " variable in the netcdf file"; } + text = data.Unit(); + if(text.Exist()) + { + ret = nc_put_att_text(ncid, vid, "units", text.Len() + 1, text.Buf()); + if(ret != NC_NOERR) return "Can't write units attribute of " + vname + " variable in the netcdf file"; + } + ret = nc_put_att_float(ncid, vid, "_FillValue", NC_FLOAT, 1, &fill); if(ret != NC_NOERR) return "Can't write _FillValue attribute of " + vname + " variable in the netcdf file";