cdfdiff(1)

๐Ÿ’– cdfdiff(1) โ€” PnetCDF utilities โœจ

okay bestie, pull up a chair because we're gonna talk about cdfdiff, one of the PnetCDF utilities, and honestly? it's giving humble little workhorse and I'm obsessed. ๐Ÿซถ


โœจ NAME โœจ

cdfdiff โ€” compares two classic netCDF files in parallel ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

cdfdiff [-b] [-q] [-h] [-v var1,...,varn] [-t diff,ratio] file1 file2

like. that's the whole vibe. two files, some optional flags, let's go ๐ŸŽ€


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So cdfdiff is the sequential version of ncmpidiff โ€” no cap โ€” and what it does is take the contents of your two classic netCDF files and compare them, then reports the first difference it finds to standard output. and when we say "classic" we mean the classic file formats, which are CDF-1, CDF-2, and CDF-5. those three. that's the canon. โญ

now for variables and attributes, here's the tea: when you're not using the -t option, it reports the array indices of the first element it found that's different. but when you do use -t, it switches up and reports the element with the largest difference that fails to meet the tolerance requirements. so like, it's not just "first one wins" anymore, it's "worst one wins." energy shift. ๐Ÿ’€

and if you don't pass either -v or -h โ€” like, it's literally just the two file names and nothing else โ€” then the entire files get compared. the whole thing. no shortcuts. ๐Ÿ‘‘


๐Ÿงš cdfdiff vs. diff โ€” the lore ๐Ÿงš

okay so when you're comparing two files entirely, here's the one (1) thing that makes cdfdiff different from the Unix command diff:

cdfdiff skips the gaps between variables. ๐Ÿ•ณ๏ธโœจ

and WHY are there gaps, you ask? because of the alignment feature that gets used when you create a new file. that alignment lets you allocate a bigger space for the file header and align the starting file offsets of fixed-size variables โ€” you can peep the API ncmpi__enddef and the PnetCDF hints for the deets, iykyk.

and oftentimes?? the contents of those gaps are just non-zero arbitrary bytes. random little crumbs. so here's the consequence, and it's important bestie: two netCDF files โ€” whether they're the same size or different sizes โ€” can be reported identical by cdfdiff but NOT by diff. ๐Ÿ˜ญ same files, two totally different verdicts. that's just how it is.


๐Ÿ’… OPTIONS ๐Ÿ’…

  • -b โ€” verbose mode, babe. prints results โ€” whether they're the same or different โ€” for all the components in the comparison (file, header, or variables). everything gets a report card. ๐Ÿ“‹
  • -q โ€” quiet mode. prints, like, nothing to the command-line output. and heads up: this also disables verbose mode, so no sneaking around it. when you're in quiet mode you gotta check the exit status yourself โ€” scroll down to EXIT STATUS for that. ๐Ÿคซ
  • -h โ€” compare the file header only. just the header. nothing else invited. ๐ŸŽ€
  • -v var1,...,varn โ€” compare only the given list of variables, names separated by a comma with no space. so var1,var2,var3, not var1, var2, var3. mind the gap. ๐Ÿ“
  • -t diff,ratio โ€” compare variables element-wisely with tolerance, diff and ratio separated by a comma with no space. let's break it down:
    • diff is the absolute value of the element-wise difference of two variables that have the same name but are stored in the two input files.
    • ratio is the relative element-wise difference ratio, defined as |x - y|/max(|x|, |y|), where x is an array element from a variable in the first file and y is the corresponding array element of that same variable in the second file. and |x| means the absolute value of x. math is math. ๐Ÿงฎ
    • and note โ€” when this option is used, the output reports only the first array element that fails to meet both tolerance requirements. both of them. not one. both. ๐Ÿ’–

๐ŸŒˆ EXIT STATUS ๐ŸŒˆ

  • an exit status of 0 means no differences were found ๐Ÿซถ
  • an exit status of 1 means some differences were found ๐Ÿ˜ญ
heads up: on a VMS-based system, those exit status values are reversed. stay woke. ๐Ÿ‘€

โญ SEE ALSO โญ

go read those too, bestie, it's a whole ecosystem ๐Ÿ’œ


๐Ÿ“… DATE ๐Ÿ“…

July 1, 2026


and that's the whole page, you ate it, no crumbs. ๐Ÿ’…โœจ this was PnetCDF 1.15.0, printed 2026-11-02, and yeah โ€” cdfdiff(1), the icon herself. go compare something. periodt. ๐Ÿ‘‘๐Ÿฆ‹๐ŸŽ€

๐Ÿ“ฆ where this page comes from