# OpenFOAM® v1906: New and updated portability

27/06/2019

## New cross-compiled OpenFOAM version for MS-Windows®

OpenFOAM-v1906 continues our effort to make OpenFOAM accessible on a broader range of platforms. In this version we have incorporated many of the MS-Windows® adaptations pioneered by Symscape, combined with some ideas from BlueCape to support a 64-bit cross-compiled OpenFOAM version for MS-Windows® .

The porting changes led to updating a number of related components, which will help future-proof more parts of OpenFOAM:

• Drop-in compatible support for using C++11 regex instead of POSIX regex with existing code for newer compilers and when cross-compiling.
• removed OSspecific dependency on pthread
• replaced OSspecific clockValue with std::chrono version
• updated endian-related macros for reduced clutter and a more portable generic syntax (relocated from OSspecific to OpenFOAM/primitives)
• use standard compiler macros when distinguishing the operating system type.
• removed bootstrap dependency on flex. The wmake toolchain now only requires a C++ compiler.

• user selectable handling of spaces in file names. While spaces within the OpenFOAM case name itself is still an extremely bad idea (since the case name is often used as a base for other filenames and can lead to invalid dictionary entries), in many cases it is possible to accept spaces in the parent directory name. Spaces in directory names are particularly prevalent on Windows systems. Use with some caution, and report any unexpected issues.
• added OS-specific handling of backslashes and UNC descriptors. Backslashes in the path are converted internally to forward slashes.
• uniform handling of lib/exe file extensions in makefiles and in the dictionary libs entry. On platforms such as Darwin and Windows, the .so extension will automatically by translated to .dylib and .dll, respectively. This allows the same dictionary to be used on Linux and Windows.

As an additional convenience, both the lib prefix and the .so suffix have become optional. This simplifies the dictionary input:

libs    ("sampling");
libs    ("libsampling.so");

## New and updated compiler support

• added wmake rules for the Pgi compiler
• ARM compilation flags for Clang, in cooperation with ARM developers

The principal changes are to use -armpl for linking in the performance libraries and using -mcpu=native for the processor target. The ThirdParty build of boost can now also use armclang instead of gcc.

## Making it easier to apply processor optimisation tweaks

Within the wmake rules, the cpu architecture is now managed with distinct cARCH, c++ARCH internal make variables that allow better separation from compiler settings. This enables architectures such as KNL to become an optimization option instead of a compiler option.

• previously:

WM_COMPILER=GccKNL WM_COMPILE_OPTION=Opt

-> linux64GccKNLDPInt32Opt
• now:

WM_COMPILER=Gcc  WM_COMPILE_OPTION=OptKNL

-> linux64GccDPInt32OptKNL

This makes it easier (and more obvious) for adding different tweaks without needing to generate too many files. For example, create a Broadwell-specific compilation by copying and editing the files cOpt and c++Opt:

cd wmake/rules/linux64Gcc

cp cOpt   cOptBdw
cp c++Opt c++OptBdw

and then set WM_COMPILE_OPTION=OptBdw.

Keywords: wmake -show options for compiler information

When building other libraries directly with autoconfig or cmake, it can be useful or necessary to use the same compiler and compiler settings as used by OpenFOAM itself. These are now obtained from the wmake show options and can be used to set corresponding environment variables. For example,

CC="$(wmake -show-c)" CFLAGS="$(wmake -show-cflags)" ./configure

Here is the correspondence to commonly used environment variables

 Env variable Obtaining from wmake Meaning CC wmake -show-c C compiler CFLAGS wmake -show-cflags C compiler flags CXX wmake -show-cxx C++ compiler CXXFLAGS wmake -show-cxxflags C++ compiler flags wmake -show-cflags-arch Architecture information when linking wmake -show-cxxflags-arch Architecture information when linking

In some situations it can also be useful to have the compiler and flags together (similar to mpicc -show and mpicxx -show):

wmake -show-compile-c
wmake -show-compile-cxx

This system replaces the environment variables (WM_CC, WM_CFLAGS, WM_CXX, WM_CXXFLAGS, and WM_LDFLAGS) used in previous versions that have proved to be inadequate for a number of reasons:

• fragile to maintain
• not guaranteed to be consistent
• does not provided the full compilation flags
• annoying clutter for the environment