Fortran maximum name lengths

Ancient Fortran code readability is impacted by the restrictions on variable length that could lead to inscrutable variable and procedure names. The Fortran 2003 standard raised many of these limits to lengths that might only be a factor for auto-generated code with internally used very long names. If going beyond the usual name lengths, it’s a good idea to test across the compilers of interest (including compiler versions) to ensure that the required compiler vendors and versions can support the proposed name lengths.

CMake Fortran name length checks

CMake is a natural for this type of checking. We provide code examples verifying that compilers can support 63 character syntax elements (names for modules, submodules, variables), which is the maximum set by Fortran 2003 standard.

Install Intel oneAPI C++ and Fortran compiler

Intel oneAPI is a cross-platform toolset that covers several languages including C, C++, Fortran and Python. Intel oneAPI including the Fortran compiler is free-to-use and no login is required to download oneAPI. The no-cost oneAPI access is distinct from Intel Parallel Studio that requires a paid license, except for instructional use or to develop open source projects.

Install

Refer to the oneAPI install guide to download the oneAPI Fortran compiler for Linux, MacOS or Windows.

  1. (Windows only) Install latest Visual Studio
  2. install GDB from oneAPI Base Toolkit
  3. Install the remaining packages below with oneAPI HPC toolkit

The oneAPI package options we installed included:

  • GDB
  • Intel MPI library
  • Intel C++ compiler
  • Intel Fortran compiler
  • Intel Math Kernel Library

Usage

As with Intel Parallel Studio, there are slightly distinct usage patterns to access the Intel oneAPI compilers on Windows NOTE: it is NOT recommended by Intel to use ifx.exe or icx.exe directly. You should be using ifort icl icc icpc with Intel oneAPI as with Intel Parallel Studio.

Windows

On Windows a Start menu shortcut for a oneAPI command prompt is installed. CMake et al should just find the Intel compiler when in the oneAPI command prompt. Otherwise run setvars.bat as per oneAPI documentation.

Linux / MacOS

each time you wish to use Intel oneAPI, do

. /opt/intel/inteloneapi/setvars.sh

Get user home directory in Matlab on Windows

GNU Octave understands that ~ tilde is the user’s home directory on any operating system, even Windows. Matlab does not consistently understand ~ as the user home directory.

Fix

We created expanduser.m that works on Linux, Mac and Windows. It returns the absolute path of the user home directory, for example:

  • Linux: /home/username
  • MacOS: /Users/username
  • Windows: C:\Users\Username

Chrome and Edge browsers force dark mode

The Google Chrome and Microsoft Edge web browsers can be forced into “dark mode”. This works on mobile and desktop. In the browser address bar, type:

chrome://flags/#enable-force-dark

There are several settings–try “Enabled with selective inversion of non-image elements”. Not all webpages will work correctly, but most do.

Windows WPA3 diagnosis

Windows 1903 enabled WPA3 at the operating system level. Numerous devices require Windows 2004 to enable WPA3 for the specific computer WiFi hardware. The computer may also need device-specific firmware / software updates to get WPA3 working.

Check WiFi 6 capability

WiFi 6 includes 802.11ax. Check if the WiFi hardware is capable of 802.11ax:

netsh wlan show drivers

look for “802.11ax” under:

Radio types supported : 802.11b 802.11a 802.11g 802.11n 802.11ac 802.11ax

also look under:

Authentication and cipher supported in infrastructure mode: WPA3-Personal

Check WPA3 connection

Determine if the network is WPA3 from a Windows device that works on the network by:

netsh wlan show networks

Look for the SSID of the desired network. It should include a field:

Authentication          : WPA3-Personal

Some devices connect to WPA3 by selecting WPA2 if WPA3 menu choice isn’t present.

WPA3 capable devices

Here are a few devices that we have used on WPA3 (or WPA3 transitional) successfully.

  • Microsoft Surface Go
  • Microsoft Surface Pro 7
  • Microsoft Surface Pro 5
  • Google Pixel 4
  • NVIDIA Shield Tablet K1
  • newer iPads
  • newer iPhones
  • newer Chromebooks

Print PDF from Matlab

Saving PDF of plots from Matlab is an effective way to use Matlab plots in LaTeX or for general sharing of high quality plots. Matlab exportgraphics, solved many of the previously long-standing issues with getting production-ready plots from Matlab. We also recommend tiledlayout for creating subplots. The Mathworks is continuing to upgrade Matlab’s plotting capabilities, so keep an eye on the release notes for new releases, it may finally fix issues you’ve had in the past.

Example

fg = figure;
ax = axes('parent', fg);
plot(ax, 1:10)

exportgraphics(fg, 'line.pdf', 'Resolution', 300)

Notes

Matlab R2020a Update 5 fixed bugs with exportgraphics.

Obsolete

The “print” and “saveas” functions are generally not recommended for saving plots from Matlab as they suffer from matching the saved file to what is seen on the screen. Use “exportgraphics” instead.

  • print() allows controlling image DPI via the -rDPI option, while saveas() is fixed at 150 DPI
  • saveas() is an “easier” version of print(), since saveas() is actually making calls to print() for both Matlab and Octave.

Generate vectors of datetime in Matlab / Octave

Generating a range of datetime data is a common data analysis and simulation task. Here we show examples of generating datetime vectors for:

datetime

Matlab “datetime” is strongly encouraged over legacy datenum(). datetime has a native ability to generate range of datetime like:

function times = datetime_range(tstart, tend, ts)
arguments
  tstart (1,1) datetime
  tend (1,1) datetime
  ts (1,1) duration
end

dt = tstart:ts:tend

end

GNU Octave datetime

GNU Octave can use many datetime features via the Octave-Tablicious package.

then load by:

pkg load tablicious

datenum

Generate a range of datenum times like:

function times = datetime_range(tstart, tend, ts)
% ts: seconds

times = tstart:ts/86400:tend;

end