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. ๐-vvar1,...,varn โ compare only the given list of variables, names separated by a comma with no space. sovar1,var2,var3, notvar1, var2, var3. mind the gap. ๐-tdiff,ratio โ compare variables element-wisely with tolerance,diffandratioseparated by a comma with no space. let's break it down:diffis the absolute value of the element-wise difference of two variables that have the same name but are stored in the two input files.ratiois the relative element-wise difference ratio, defined as|x - y|/max(|x|, |y|), wherexis an array element from a variable in the first file andyis the corresponding array element of that same variable in the second file. and|x|means the absolute value ofx. 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
0means no differences were found ๐ซถ - an exit status of
1means 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
- ubuntu stonking: pnetcdf-bin 1.15.0-3build1 ยท Northwestern
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms