Fortran compilers typically use 4 bytes for
logical
while C compilers usually use
1 byte for bool.
This becomes of vital importantance when using iso_c_binding to interface between Fortran and C/C++.
Specifically, the Fortran type declaration must use logical(kind=C_BOOL) to ensure the correct size and values are used for interoperability.
If this is not done, there will likely be randomly occuring bugs that pop up across compiler versions, operating systems, etc. due to the non-standard C values used for .true. and .false. in Fortran.
use,intrinsic::iso_c_bindinglogical(C_BOOL)::L1
Intel oneAPI flag
-fpscomp logicals
ensures integer values 0,1 corresponding to .false., .true. are used.
Otherwise by default unexpected values may cause programs to fail at runtime with impossible boolean values like 255.
The Intel oneAPI compiler
-standard-semantics
flag to use C_BOOL
values
correctly between C, C++ and Fortran has a BIG DOWNSIDE in that it breaks linking with system libraries–including Intel MPI!
All projects and libraries linking to a Fortran library that used oneAPI -standard-semantics must also use -standard-semantics.
GCC 5
enabled the
__has_include
macro that checks if a source file exists.
__has_include() was made language standard syntax in C++17 and C23.
__has_include("file.h") checks if “file.h” exists as a file on the compiler includes paths, but not if “file.h” can be included with the specified compiler language standard.
Watch out for buggy __has_include() in GCC < 10.
We found that __has_include("linux/magic.h") with quotes "" instead of the usual carets __has_include(<linux/magic.h>) was needed specifically for
header linux/magic.h.
Other systems libraries with carets worked as expected even with GCC < 10.
#if __has_include("linux/magic.h") // quotes needed for GCC < 10
# include <linux/magic.h>
#endif
CMake FetchContent is useful to incorporate subprojects at configure time.
FetchContent subproject cache variables can override the top-level project cache, which can be confusing.
Projects may wish to use a default install prefix when
cmake –install-prefix
is not specified.
Environment variable
CMAKE_INSTALL_PREFIX
can set a default install prefix across projects.
Some projects force a default install prefix if not specified by the
top level project:
However, it is more a canonical approach to check the install prefix
write permissions.
message(STATUS"CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX})if(CMAKE_VERSIONVERSION_GREATER_EQUAL3.29)if(NOTIS_WRITABLE ${CMAKE_INSTALL_PREFIX})message(FATAL_ERROR"CMAKE_INSTALL_PREFIX is not writable: ${CMAKE_INSTALL_PREFIX}")endif()else()file(TOUCH ${CMAKE_INSTALL_PREFIX}/.cmake_writable"")endif()
C23 specification added C++-like attribute specifiers to C.
As in C++, C
attribute specifiers
add metadata to declarations and definitions.
The metadata can be used by the compiler and by the developer to help understand the code intent.
Compilers including GCC ≥ 11 have __has_c_attribute()
to check if an attribute is supported by the compiler–even if the command line specified standard is older.
On non-Windows systems, the compiler would have issued a warning about y being an unused argument.
The [[maybe_unused]] attribute suppresses that warning.
The [[fallthrough]] attribute is used to indicate that a fall-through in a switch statement is intentional.
This attribute can be used to suppress warnings about missing break statements in a switch block.
TemporaryDirectory(ignore_cleanup_errors=True) fixes the Windows corner case on exiting a tempfile context manager such as cloning a Git repo into the TemporaryDirectory.
importtempfilewith tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmpdir:
# create subdirectories, make files, git clone, etc.# the context manager attempts to recursively delete "tmpdir" on exit
If there is a PermissionError, the temporary directory remains until the operating system cleans up the temporary directory.
Pacman
can download packages in parallel to speed up the process.
The number of parallel download threads can be controlled in the “/etc/pacman.conf” file.
This can be useful on slower internet connections to install packages without disrupting other network activities.
To set the number of parallel download threads, edit “/etc/pacman.conf” file.
Find the “ParallelDownloads” option in the file.
If it is not present, add it under [options] section.
Set the number of download threads.
The ordering of options doesn’t matter.
For example, to use 3 parallel download threads:
Olivier Giroux
chairs the ISO C++ subgroup for Concurrency and Parallelism.
Olivier continues to present very useful interactive talks on C++ concurrency and parallelism.
This talk is about the C++ Forward Progress Guarantee in light of concurrency and parallelism.
C++ Proposal
P2809R3
is to allow trivial infinite loops as defined behavior in C++.
The definition Olivier uses for concurrency at 16:50 in the video above is:
Concurrent tasks eventually observe each other’s effects.
The Android
GnssLogger app
logs data in the user-selected formats, including
RINEX.
GnssLogger can run for hours or days, assuming the device has enough storage.
Do test runs to be sure unnecessary other data files aren’t also stored as they can be much larger than the RINEX data.
When clicking “save and send” to end a logging session, the app asks where to save in the cloud.
Simply canceling the upload retains the data in the “Downloads” folder on the device.
This can be useful when the device has a low-bandwidth or expensive data connection, and the data can be uploaded later or copied to a computer via USB.
In addition to
generic
and
polymorphic
procedures, Fortran also allows aliasing procedure names.
This is useful to provide a shorter or more convenient name for a procedure.
It’s easiest to understand from the example below.
programmaininterfaceeasyprocedure::long_and_descriptive_procedure_nameendinterfacecalleasy()containssubroutinelong_and_descriptive_procedure_nameprint'(a)',"Hello from long name"endsubroutinelong_and_descriptive_procedure_nameendprogram