Git stash cleanup

Git stash is often used to hold temporary work that wasn’t yet ready for a commit, perhaps during a rebase. The stash history is per repo. Over time, one may accumulate numerous stash entries that are no longer relevant and may desire to cleanup this clutter.

View Git stash entries by:

git stash list

View the contents of a particular stash entry by:

git stash show -p "stash@{0}"

where the number in braces corresponds to the git stash list index.

To remove a stash entry, sliding up all the entries older than it:

git stash drop "stash@{N}"

where “N” is the entry index to remove.

If one wishes to recover a dropped Git stash entry, it may be possible:

TeXLive from the command line

TeXLive is a well maintained and often updated LaTeX distribution that works for any OS. Download TeXLive net Installer and run. Click Advanced and use the “basic” scheme, which is well under one GB to start.

When building a document and it seems to be missing a package, note the error messages. Find and install needed packages via tlmgr using commands like:

  • find package by filename: tlmgr search --global --file fullpage.sty
  • find fonts/packages by name: tlmgr info ieee
  • install package: tlmgr install lmodern

Use a LaTeX IDE (GUI editor) like TeXstudio.

When a new major version of TeXLive is released, simply repeat the procedure above and point any programs like TeXstudio to the new TeXLive install directory.

Upgrade Matlab from Terminal

Upgrading the Matlab version or installing Addon Toolboxes can be initiated from the system Terminal / Command Prompt. Actually doing the upgrade or addon install does require a graphical connection to the computer (Remote Desktop, VNC, or similar).

The little bell icon on the upper right corner of the Matlab IDE typically shows when a Matlab update is available. To force checking for install, even if the bell is not showing an update, under the Matlab directory look for “update_installer”

  • Windows: bin/win64/update_installer.exe
  • Linux: bin/glnxa64/update_installer
  • MacOS: bin/maci64/update_installer

If the graphical connection has a problem, an error results like:

terminating with uncaught exception of type (anonymous namespace)::DisplayError: No display available.

The Addon interface does need to be launched from the Matlab IDE and likewise requires a graphical connection.

If having trouble with the graphical windows launched, try this for diagnosis:


That should return a webwindow object without error (a window does not actually open). If on Linux with a graphical connection and errors result, try renaming like:

cd <matlabroot>/bin/glnxa64/


Related: Matlab install Linux

Fortran MPI on Windows

Get MPI on Windows with C and Fortran by any one of: MS-MPI, Intel oneAPI or Windows Subsystem for Linux libopenmpi-dev. We often use MPI via MSYS2 with GCC / Gfortran compilers on Windows. Note: the mpi_f08 interface is not yet available via MS-MPI.

To install MS-MPI: download and install Microsoft MS-MPI. Make mpiexec.exe available by adding to user PATH: C:\Program Files\Microsoft MPI\Bin – this is needed even when using MSYS2. Install MSYS2 MS-MPI library from the MSYS2 Terminal:

pacman -S mingw-w64-x86_64-msmpi

OpenMPI is not currently available for native Windows. MPICH is not directly buildable on Windows, even with MSYS2.

Upon installing or updating Intel oneAPI compilers and libraries on Windows, you may experience CMake failing to find MPI for MinGW. This happens because Intel compilers put Intel MPI on the system PATH. Fix this by removing Intel MPI from the system PATH and use the Intel Compiler shell instead, which provides all the needed directories.

Major changes in GCC Gfortran by version

GCC Gfortran and Intel oneAPI are the most advanced, widely available modern Fortran compilers. Useful Fortran 2018 enhancements include: select rank assumed array rank, error stop within pure procedures, random_init to initialize random number seed, and implicit none (type, external) to require external procedures to be explicitly declared. GCC 9 is the oldest version currently maintained. Intel oneAPI has full Fortran 2018 support.

To get recent GCC is usually straightforward. Red Hat should use GCC Toolset. MacOS Homebrew quickly adds the latest GCC version. If Ubuntu gfortran repo defaults aren’t adequate, get recent Gfortran via PPA.

Here are some of the major changes in Gfortran by version:

  • Gfortran 11 completed OpenMP 4.5 support
  • Gfortran 10 added select rank
  • Gfortran 9 added random_init() to initialize the random generator seed…randomly
  • Gfortran 8 added automatic nested loop exchange with do concurrent, actual argument array with too few elements for dummy argument now errors, initial support for parameterized derived types (simply define kind at initialization) and coarray support for teams. Standard flag -std=f2018 added and deprecated -std=f2008ts.
  • Gfortran 7 added derived type IO select type. Complete Fortran 2003 support, Fortran 2018 non-constant stop and error stop codes, and -fdec- options to help compile very old non-standard code.

Gfortran 6 added Fortran 2008 submodule support, useful for large projects to save compilation time and allow powerful use scenarios. Fortran 2003 deferred-length character are useful for avoiding bothersome trim() everywhere.

GCC 5 added full support for OpenMP 4.0, Fortran 2003 ieee_ intrinsics, Fortran 2008 error stop in pure procedures with constant error code. GCC 4.9 added Fortran 2003 deferred-length character variables in derived types. GCC 4.8 supported Fortran 2008 polymorphism, including select type, class(*), type(*), and assumed rank dimension(..). GCC 4.6 was the first version of Gfortran reaching beyond Fortran 95, with Fortran 2003 deferred-length character variable and Fortran 2008 impure elemental support. GCC 4.5 added Fortran 2008 iso_fortran_env. GCC 4.4 added initial support for polymorphism and OpenMP 3.

CMake allows switching parameters based on compiler version. This is very useful for modern Fortran programs.

Example CMakeLists.txt for Fortran compiler version dependent options.


  # option applying to any language for this compiler

  # language-specific, note LEADING space
  string(APPEND CMAKE_Fortran_FLAGS " -fimplicit-none")

    string(APPEND CMAKE_Fortran_FLAGS " -std=f2018")


add_executable(myprog main.f90)

Reference: Gfortran changelog

Check CMake TLS functioning

CMake itself is built with SSL by default. Sometimes a user may mistakenly build CMake itself without SSL support. This is generally not workable as the vast majority of Internet sites require SSL / TLS to function. Confusing errors result for CMake network operations like file(DOWNLOAD) in this case.

In our projects using CMake, we use this simple check_tls:

Homebrew revert to GCC 10

Any new version of a program may add new bugs even as it adds new features and fixes other bugs. GCC is no exception–the GCC 11.1 release introduced Fortran syntax bugs. As Homebrew is often among the first easy sources of new GCC releases, we upgraded quickly before realizing the new bug was intolerable for us. For Intel CPU Macs, simply do:

brew install gcc@10

For Apple Silicon ARM64 Macs, there is a unique problem–GCC 10 is no longer available as binary downloads from Homebrew. This is because backports and hacks were necessary to get GCC 10 working on ARM64, and the Homebrew team wanted to encourage moving to mainstream supported GCC 11. The Homebrew maintainers provided hints for a workaround to install GCC 10 on ARM64.

CentOS 8 Stream SSH and VNC

CentOS and Red Hat add a few complexities on top of the “plain” Debian-based Linux distros one may be more likely to run on a laptop or Raspberry Pi. SELinux in particular is another layer to consider.

For SSH connection problems, suggest setting /etc/ssh/sshd_config to have

LogLevel DEBUG


systemctl restart sshd.service


journalctl -f

and try to login. This will print a good amount of information streaming and helps reveal .ssh/authorized_keys permissions issues and more.

In general, if one is puzzled if SELinux is causing an issue, as a last resort one may temporarily and carefully edit /etc/selinux/config to have


and reboot. Be sure to put that back to enforcing and reboot when done.

Check that firewalld is allowing the desired SSH port through.

tcpdump port 22 -n -Q inout

should show packets from the client–if not the SSH server firewall may be blocking them.

For VNC in general we avoid the fancy graphical desktop. To use the 2D simple “classic” desktop on VNC, edit ~/.vnc/xstartup to have:


before the “xinitrc” line.

To check VNC server status:

systemctl status vncserver@:1

If VNC isn’t working for a user, check that their username is specied with a display number in file: /etc/tigervnc/vncserver.users

CMake temporary directory

A temporary directory for build system use should be created under the build directory. Some CIs and systems do not define the environment variables “TMPDIR” or “TEMP” for temporary directory. Virus scanners can false detect activity in the system temporary directory as malicious.

Create a temporary directory in CMake using random string like:

if(NOT DEFINED tmpdir)
  string(RANDOM LENGTH 24 _s)
  set(tmpdir ${CMAKE_CURRENT_BINARY_DIR}/${_s} CACHE PATH "temporary directory")