WSL/SLF GitLab Repository

Skip to content
Snippets Groups Projects

Fix read-in of a NetCDF dates list

I'm trying to read dates from a NetCDF file. Presumably this worked for some kind of Null-terminated data in some files? For me and simple date strings it didn't and behaved like this minimal example:

char *data = (char*)calloc(length, sizeof(char));
data[0] = 'a'; data[1] = 'b'; data[2] = 'c';
std::string res(&data[1]);

(Giving "bc", or in the case of MeteoIO the first string would be all dates after each other, the next one all dates again but truncated by length strMaxLen, etc.)

Here is how ncdump displays the strings:

dimensions:
        (...)
        DateStrLen = 19 ;
        (...)

data:

 Times =
  "2022-09-18_06:00:00",
  "2022-09-18_07:00:00",
  (...)
  "2022-09-19_02:00:00",
  "2022-09-19_03:00:00" ;

So, is strMaxLen really just an upper limit, and with this fix do we need to take care of string termination before reaching this length afterwards?

Merge request reports

Pipeline #1895 passed

Pipeline passed for 17b7a1aa on fix/strmaxlen

Approved by

Merged by Mathias BavayMathias Bavay Feb 1, 2023 (Feb 1, 2023 3:15pm UTC)

Merge details

  • Changes merged into master with 966690e1.
  • Deleted the source branch.

Pipeline #1898 passed

Pipeline passed for 966690e1 on master

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading