Scientific Computing

CMake use MUSL slim libc

CMake can use MUSL slim libc natively (e.g. Alpine Linux), in a Docker container, or by cross-compiling. Cross-compiling in CMake generally uses a toolchain file to set critical variables that can’t be detected automatically. For example, using the x86_64 MUSL binaries from musl.cc, extract the tar file say to ~/musl and then create file ~/musl/musl-toolchain.cmake like:

set(CMAKE_SYSTEM_NAME Linux)
# target system
set(CMAKE_SYSTEM_PROCESSOR x86_64)
# target architecture

set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/x86_64-linux-musl-native)

# These cross-compilers come from the toolchain downloaded from musl.cc
set(_bin ${CMAKE_FIND_ROOT_PATH}/bin)

set(CMAKE_C_COMPILER "${_bin}/x86_64-linux-musl-gcc")
set(CMAKE_CXX_COMPILER "${_bin}/x86_64-linux-musl-g++")
set(CMAKE_Fortran_COMPILER "${_bin}/x86_64-linux-musl-gfortran")

set(_lib ${CMAKE_FIND_ROOT_PATH}/lib)

set(CMAKE_SYSTEM_LIBRARY_PATH ${_lib})
set(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_FIND_ROOT_PATH}/include)

set(CMAKE_EXE_LINKER_FLAGS_INIT -Wl,-rpath-link=${_lib},-rpath=${_lib})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

Use this to cross-compile a CMake project with MUSL like:

cmake -Bbuild ---toolchain ~/musl/musl-toolchain.cmake

cmake --build build

ctest --test-.dir build

The LINKER_FLAGS allow executables to be run from the host system.

Windows 11 manual upgrade

When turning on an old Windows PC that hasn’t been used for a while, the Windows OS may be several versions out of date. Windows may be so old that using Windows Update doesn’t automatically give an option to upgrade Windows, or may offer a non-latest Windows release. Instead of discarding the PC, consider manually upgrading Windows to the latest release via the Windows Upgrade Assistant. Typically the Assistant will have a PC Health Check that it will ask to have run first. The Health Check will tell among other things the current maximum capacity of the laptop battery. The PC can still be used during the upgrade, which doesn’t take too long. It’s important to use a currently supported version of Windows to be better protected from cybersecurity concerns and to avoid unsupported or non-working software configurations.

Earth Abides miniseries radio frequency

ℹ️ Note

This entire article involves spoilers for the original 1949 book and 2024 miniseries adaptation of “Earth Abides” by George R. Stewart.

The 2024 MGM miniseries adaptation of George R. Stewart’s novel “Earth Abides” has several distinctions from the original study facilitated by 2020’s technology not available in the 1949 book. This technology enables a more comfortable, modern-like existence while still facing many of the same challenges as the book.

A key plot element involves the 2 meter amateur radio band VHF radio frequency 147.225 MHz. However, most of the radios used and antenna notebook designs are specifically for HF. The antenna ultimately erected is consistent with a VHF antenna. The radio powered on is an HF radio, with a possible old signal generator capable of generating a VHF signal being shown. I suppose the lack of modern radios having direct key entry was a factor in the movie production. In my opinion, showing an actual VHF radio being tuned in say 5 kHz steps would have been more realistic and not at all detracting from the story. While millennials and younger generations are decreasingly familiar with tuning a radio dial, it is still not a foreign concept to them and easy to film and understand for world audiences.

Using 50% spot probability and ideal site locations not locally obstructed by terrain or buildings as indicated on the TV show, it is possible with a typical inexpensive VHF mobile transceiver to communicate with adequate FM SNR as shown on the show. It is especially possible during periods of tropospheric ducting experienced in this region that communications would be possible between two base stations.

Earth Abides radio path profile

Path profile for the Earth Abides radio frequency communication.

Intel oneMKL ScaLAPACK examples

Intel oneAPI / oneMKL includes Scalapack. MKL Scalapack library & include files are found under the MKLROOT environment variable. Scalapack MKL is used in CMake via MKLConfig.cmake (found under $ENV{MKLROOT}/lib/cmake/MKLConfig.cmake) like:

set(ENABLE_BLACS true)
set(ENABLE_SCALAPACK true)

set(MKL_INTERFACE "lp64")
# "lp64" is the 32-bit interface, "ilp64" is the 64-bit interface

set(MKL_SYCL_MPI false)
set(MKL_SYCL_LINK false)
# for Intel oneAPI 2025.2, we don't need SYCL

find_package(MKL CONFIG REQUIRED)

add_executable(mytest main.f90)
target_link_libraries(mytest PRIVATE MKL::MKL_SCALAPACK)

The MKL_SYCL* variables control whether SYCL is enabled for Intel oneAPI 2025.2 and later, which usually we don’t want.

The exact link flags and compile flags (that are automatically handled by MKLConfig.cmake) for a particular system are obtained from Intel Link Line Advisor.

Intel MKL Scalapack example project

Netlib Scalapack examples can also be used with non-MKL Scalapack.

GitHub Actions Windows MSYS2 MS-MPI

While we generally recommend using WSL for MPI on Windows, MS-MPI is available and works with MSYS2 / MinGW GCC Gfortran on Windows. MSYS2 is a popular choice to use GCC, Clang and many other developer tools from the Windows Command Prompt, PowerShell or the MSYS Terminal itself.

Continuous Integration for Windows MPI applications on GitHub Actions is accomplished as in fortran-mpi-examples Windows CI workflows. Set inter-step environment variables using GitHub Actions environment files.

Keybase.io PGP key export

Public PGP IDs can help verify author identity of Git commits, social media, website, etc. A popular free service to share PGP IDs is Keybase.io. Below we demonstrate exporting Keybase.io PGP keys with the keybase.io client.

Setup GPG on the laptop:

  • Linux: apt install gnupg
  • macOS: brew install gnupg keybase
  • Windows: winget install GnuPG.Gpg4win Keybase.Keybase

Export Keybase.io public & private key and import into GPG:

keybase pgp export | gpg --import

keybase pgp export --secret | gpg --pinentry-mode=loopback --allow-secret-key --import

Verify PGP key:

gpg --list-secret-keys --keyid-format LONG

The first lines will be like:

sec   rsa4096/<public_hex>

The hexadecimal part after the / is a public reference to keybase.io keypair. It’s shown on the keybase.io public profile, next to the key icon.

Next one can sign Git commits with GPG using the exported keybase.io PGP key.

GNU Octave without readline

GNU Octave and other interactive terminal program use GNU Readline for command line editing. If the Readline library is incompatible with GNU Octave, it may become unusable by not being able to type in GUI or non-GUI modes. A workaround for non-GUI mode only is to disable interactive console input like:

octave --no-line-editing

For example Readline 8.3 has a known bug with a patch already released.

SSH-agent for Windows, macOS, Linux

SSH-agent remembers SSH Public Key authentication, which can be time-limited by the user. This avoids the user having to type the password for each SSH connection, especially relevant to using Git over SSH. Windows has SSH built-in from Microsoft including SSH-agent. WSL also can use SSH-agent within each of the WSL images. SSH-agent works well with Git over SSH.

To use SSH-agent, add SSH keys like:

ssh-add ~/.ssh/mykey

This will persist the key in the SSH-agent until the SSH-agent is stopped, the user logs out,or the key is removed.

Remove all SSH-agent keys from RAM (if desired):

ssh-add -D

List all SSH-agent keys loaded:

ssh-add -L

Time limit for SSH-agent keys

Except for Windows, a time limit can be set for how long the key is remembered:

ssh-add -t 30m ~/.ssh/mykey
-t 30m
remember authentication for a period of time (here, 30 minutes)

Currently, the OpenSSH implemenation of SSH-agent on Windows does NOT support the -t option. If the -t option is used on Windows, it will fail like:

Could not add identity <key>: agent refused operation


Each operating system has a distinct method of enabling SSH-agent.

Windows SSH-agent

SSH-agent can be enabled from PowerShell. Note that the OpenSSH Client and OpenSSH server must both be installed.

Check if Windows SSH-Agent is running:

Get-Service ssh-agent

Start SSH Agent:

Set-Service -StartupType Automatic -Name ssh-agent

Start-Service ssh-agent

if status of Windows SSH-Agent in Powershell is “Running” then SSH-agent should be working.

Get-Service ssh-agent

If you still have trouble, try setting the permissions for the $HOME/.ssh directory more conservatively with this Powershell script.

Linux SSH-agent

For Linux, including Windows Subsystem for Linux:

Add to ~/.profile:

if [ -z "$(pgrep ssh-agent)" ]; then
   rm -rf ${TMPDIR}/ssh-*
   eval $(ssh-agent -s) > /dev/null
else
   export SSH_AGENT_PID=$(pgrep ssh-agent)
   export SSH_AUTH_SOCK=$(find ${TMPDIR}/ssh-* -name agent.*)
fi

macOS SSH-agent

On macOS, SSH-agent is enabled by default.


SSH agents can have vulnerabilities, as noted for Windows and Linux.


Related: Disable Gnome Keyring SSH Agent

reference

GNU Data Language (GDL) GUI

GNU Data Language (GDL) can use GDLDE Workbench GUI for graphical development.

Download and install GDL.

  • Windows: installer includes GDLDE Workbench: gdlsetup-Windows-x86_64-standard.exe. Simply install and look in Windows Start menu for “GDL Workbench”
  • macOS: use weekly Release gdl-macOS-arm64-standard.dmg
  • Ubuntu Linux: apt install gnudatalanguage

Download and extract GDLDE.

GNU Octave for continuous integration

Matlab CI is often a better choice than Octave below.


Cross-platform developers run into numerous compatibility issues. Rather than wait for frustrated users to report such a bug, use continuous integration.

Here are CI templates using GNU Octave tests of .m code. Octave oruntests() is incompatible with the advanced functionality of Matlab runtests(),

GitHub Actions: “.github/workflows/ci.yml”:

name: ci

on:
  push:
    paths:
    - "**.m"
    - ".github/workflows/ci.yml"

jobs:

  linux:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout

    - run: |
        sudo apt update
        sudo apt install --no-install-recommends octave

    - run: octave --eval "test_myfuncs"
      working-directory: tests

  windows:
    runs-on: windows-2025
    steps:
    - uses: actions/checkout
    - run: winget install --id=GNU.Octave --disable-interactivity --accept-source-agreements --accept-package-agreements

    - run: octave --eval "test_myfuncs"
      working-directory: tests