The Fortran array dimension order is column-major, meaning the first dimension changes fastest in memory.
This is consistent with how Fortran and
Matlab store arrays
in memory.
When indexing arrays, particularly in a loop, significant performance differences can arise depending on the dimension order.
Accessing elements in the fastest-changing dimension first is generally more efficient as it’s memory contiguous, reducing cache misses and improving performance.
The HDF5 document on
C versus Fortran interfaces
explains how HDF5 handles arrays in different programming languages.
Most languages, including C, C++, Java, and Python use row-major order, where the last dimension changes fastest in memory, which is also how the HDF5 interface to those languages works.
For Fortran and Matlab, the HDF5 interface expects arrays in column-major order, consistent with Fortran’s memory layout.
This column-major array ordering is also true for the HDF5 APIs of the
h5fortran object-oriented Fortran HDF5 interface
and the
stdlib for Matlab
libraries.
The HDF5 Library stores arrays along the fastest-changing dimension.
This approach is often referred to as being “in C order.”
C, C++, and Java work with arrays in row-major order.
In other words, the row, or the last dimension, is the fastest-changing dimension.
Fortran, on the other hand, handles arrays in column-major order making the column, or the first dimension, the fastest-changing dimension.
C++20 standard (issued December 2020) is long
supported
by all modern C++ compilers.
In particular Microsoft Visual C++ has been steadily adding support for C++20 (and newer standards).
Major and/or popular projects are already adopting C++20 features in their codebases.
C++20 codified several
features
that had been compiler-specific extensions.
Some
examples:
One of the biggest discussions about C++20 is
modules,
which improve compilation times and provide better encapsulation of code compared to traditional header files.
The C++ ecosystem from compiler to build system works for C++20 modules with CMake support, but is still maturing.
Migrating the build configuration of a project to use C++20 standard when available can reveal oversights and fragile assumptions in the codebase, particularly around features that have changed or been newly introduced in C++20.
An example of this is the numerous
bugfixes
surrounding a default build in C++20 for CMake, despite CMake not yet requiring C++20 for its own build.
GitHub Gist only recognizes the “main” branch.
Git commits on any other branch will not be visible in the Gist interface.
Check the current branch with:
git branch --show-current
If commits were accidentally made in a non-main branch, change the name of the branch to “main” to make the commits visible in the Gist interface.
git branch -m main
After renaming the branch, it may be necessary to force push to update the remote Gist. First, ensure the remote content is in sync with the local branch to avoid overwriting any changes.
# --force overwrites the remote branch with local changesgit push origin main [--force]
Check if the old branch was pushed
git ls-remote origin
If the old non-main branch (perhaps “master”) still exists on the remote, consider deleting it to avoid confusion.
git push origin --delete master
Perhaps globally configure the computer to always use “main” as the default branch for new repositories:
Computing platforms may have multiple versions of the HDF5 library installed.
The HDF5 library version currently being used can be determined by the program as in the following examples by language.
The HDF5 library can write backward-compatible HDF5 files by
HDF5 version bounds.
Currently there is no way to introspect the HDF5 library version required to read a specific HDF5 file other than trying to read the HDF5 file.
After pushing a commit or merging a pull request, one may accidentally drop a Git commit from branch history.
If the commit was part of a pull request, GitHub will not reopen a closed pull request whose source branch no longer contains the commit.
Instead, check whether the commit still exists in
git reflog
by searching for its message or hash.
git reflog
If the commit exists in the reflog, recover it using the commit hash:
git checkout -b recovered-branch <commit-hash>
If the commit is not in the reflog, it may still exist as an unreachable object or in another branch or remote.
Note the reflog is local: it only records commits that existed in the local repository.
Major Linux distros including Ubuntu 26.04 and Debian stable have adopted the Parmetis compatibility layer provided by Scotch for parallel graph partitioning and sparse matrix reordering.
Therefore “libparmetis-dev” package has been
dropped
in favor of the free Scotch-provided compatibility layer in “libscotchparmetis-dev”, which provides libparmetis.so and the headers required for ParMETIS compatibility.
The standard
git bisect
command helps quickly identify a specific commit that introduced a bug in a Git repository.
In projects where branches with lots of commits were previously merged, there may be known-bad commits with build failure unrelated to the current bisect search.
It’s possible to
skip
such commits during the bisect process, or
avoid
specific commits altogether.
For projects using Git submodules it’s useful to set option
submodules.recursetrue
git config --global submodule.recurse true
that works for most Git commands and avoids the need during “git bisect” to also have to “git submodule update –init –recursive” at each step of the bisect process.
git bisect start
# if you already know this current commit is good or bad, tell Git about itgit bisect <good|bad> <commit>
# test the current commit by running your test code / program / scriptgit bisect run <test command>
# ... repeat the above two steps until Git finds the first bad commit# finish the bisect process and return to the original branchgit bisect reset
If running into errors about “dirty” submodules and/or lots of deleted files when Git bisecting or just switching Git branches, try disabling Git submodule.recurse for the command:
The Python package
img2pdf
losslessly converts PNG images to PDF.
Install it with:
pip install img2pdf
The command line program “img2pdf” can do many tasks, but even more power comes from making a brief Python script.
Here are simple command line examples.
A common issue with document scanning is that pages may have been inserted in the wrong orientation, making the PDF difficult to read with upside-down text.
This is trivially fixed with the
QPDF command line tool.
qpdf --rotate=180 in.pdf out.pdf
in.pdf
input PDF file needing rotation
out.pdf
output PDF file with rotated pages
--rotate=180
rotate each page 180 degrees
QPDF can do vastly more operations on PDF files as seen in the
QPDF documentation.
Poppler is oriented toward rendering and extracting content from PDF files rather than modifying them like QPDF, which does not render PDF files.
Opening the same PDF file multiple times is particularly useful when reviewing journal article drafts to view figures simultaneously with text describing the figure.
Okular
is a free lightweight PDF viewer for Linux, macOS and Windows that trivially opens the same PDF multiple times by just selecting through the File → Open menu as many times as desired.