When using a virtual machine, and especially if the virtual machine is in emulation mode, which is generally many times slower than virtualization mode, it can greatly help interaction speed to use a console boot rather than graphical desktop.
In operating systems like Ubuntu, this can be done by editing /etc/default/grub and setting:
Windows Subsystem for Linux
WSL
has Ubuntu LTS releases among other Linux distros on the
Microsoft Store.
The Microsoft Store is the recommended method to install WSL.
If the Microsoft Store isn’t available on the computer,
manual WSL install
is also available.
The WSL
changelog
shows the continually expanding WSL feature set.
WSL can use GUI and sound with programs like
Spyder
via
WSLg.
List WSL distros already installed on the computer from PowerShell / Command Prompt:
wsl --list --verbose
Install, list, and switch between Linux distros on Windows default for bash from Command Prompt:
Limit the amount of RAM WSL2 can use for all installed WSL instances by editing Windows file
$HOME/.wslconfig
to include:
[wsl2]swap=0memory=4GB
Set memory= to less than the total computer physical RAM to help avoid using Windows swap.
A per-WSL instance default that is confusing and slows down WSL program-finding is stuffing Windows PATH into WSL PATH.
We normally disable Windows PATH injection into WSL, because it also breaks library finding in build systems like CMake.
Additionally, we enable filesystem metadata, as weird permission errors can occur, even causing CMake to fail to configure simple projects.
Add to each distro’s /etc/wsl.conf file:
[interop]enabled=falseappendWindowsPath=false
Run Ubuntu apps from Windows Command Prompt or PowerShell:
wsl ls -l
Run Windows program from Ubuntu terminal:
/mnt/c/Windows/System32/notepad.exe
Note that capitalization matters and .exe must be at the end.
CMake uses the
bundled cURL library
by default.
When debugging connectivity issues with CMake, a developer may wish to build CMake with a specific cURL version.
To do so, from the cmake/ project source directory, use options like:
macOS can update system software from Terminal, even macOS itself.
However, to complete the upgrade requires using the graphical desktop, perhaps over VNC.
Valgrind
is a dynamic analysis tool that can detect memory leaks and other problems in programs including C, C++, and Fortran.
Valgrind is available on Linux and BSD for x86 and ARM CPU architectures.
For macOS on Intel x86 CPUs, Valgrind is available in
Homebrew.
For macOS on Apple Silicon ARM64 CPU, Valgrind can be used from an aarch64
Linux virtual machine
in native mode for best performance.
Variable length strings are implemented in Fortran 2003 standard like:
character(:), allocatable:: str
Passing such variables to procedures is declared the same as fixed length strings.
In fact, we always declare actual arguments with “*” to avoid needing every string an exact length.
Before Fortran 202X standard, intrinsic Fortran functions need traditional fixed length character variables.
For example:
integer:: i, L
character(:), allocatable:: buf
call get_command_argument(1, length=L, status=i)
if (i /=0) error stop"first command argument not available"allocate(character(L) :: buf)
call get_command_argument(1, buf)
Fortran function can return allocatable characters.
If you run into bugs with this on old compilers, try manually allocating the character variable.
Fortran standard compliant compilers auto-allocate character functions like numeric arrays.
It is proper to manually allocate character variable actual arguments when bind(C) interfaces are used.
function greet(b)
logical, intent(in) :: b
character(:), allocatable:: greet
!! Manual allocation of character variable. This could be necessary on old or buggy compilers.
if(b) thenallocate(character(5) :: greet)
greet ='hello'elseallocate(character(3) :: greet)
greet ='bye'endifendfunction greet
GitHub Actions workflows can use different compilers per job by writing the compiler name or path to
environment files
in each job.
This is useful for programs and libraries that need distinct compiler versions.
An example of this is Matlab, where each Matlab release has a range of
compatible compilers.
Battery time remaining estimates for computing devices can vary widely in accuracy.
The estimates are based on assumptions about future behavior based on prior usage trends, from a mix of current and prior charge usage.
Windows updates can disable battery time remaining, and devices may come from the factory with battery time estimates disabled.
Hovering over the battery icon on the Windows taskbar can show the estimated battery time remaining along with the percent battery charge.
The estimated battery time remaining is the same shown under System / Power & Battery.
The usual precautions on modifying the Windows Registry apply–do a Windows System Recovery milestone first.
These keys are under:
HKLM\SYSTEM\CurrentControlSet\Control\Power
Reboot after making these changes.
It may take a minute or two after first reboot for the estaimted battery life to show up.
If these registry keys exist, set their value to 0.
If they don’t exist, that’s fine too.
GDB debugger is not yet readily available for macOS with Apple Silicon CPU.
It has long been possible to use a virtual machine with Linux for ARM64 to run GDB within the VM.
The CLion package provides GDB, but with caveats such as using a particular compiler and libstdc++.
What happens for us is when trying to use GDB, it doesn’t work:
gdb ./myexe
r
Don’t know how to run. Try “help target”.
In general, currently to use GDB on an Apple Silicon Mac, it seems a Linux VM is the best option–hopefully this changes.