项目作者: interkosmos

项目描述 :
Fortran 2008 interface bindings to selected POSIX and SysV procedures
高级语言: Fortran
项目地址: git://github.com/interkosmos/fortran-unix.git
创建时间: 2020-12-14T18:23:20Z
项目社区:https://github.com/interkosmos/fortran-unix

开源协议:ISC License

下载


fortran-unix

Build

A work-in-progress collection of Fortran 2008 ISO C binding interfaces to
selected POSIX and SysV types, functions, and routines on 64-bit Unix-like
operating systems:

  • standard input/output,
  • file and directory access,
  • clocks and timers,
  • signals,
  • processes,
  • pipes,
  • serial port input/output,
  • terminal control,
  • POSIX threads,
  • POSIX mutexes and semaphores,
  • POSIX regular expressions,
  • BSD sockets,
  • UNIX System V message queues,
  • POSIX message queues.

Similar libraries for modern Fortran:

Currently, only Linux (glibc) and FreeBSD are supported. The library has been
tested on:

  • FreeBSD 14 (GCC 14, LLVM 20),
  • Debian 12 (GCC 12, Intel oneAPI 2024).

Preprocessor macros are used to achieve platform-independent interoperability.
Therefore, your Fortran compiler has to support at least GNU preprocessor
conditionals.

Build Instructions

Run either GNU/BSD make or FPM to build
the static library libfortran-unix.a. Link your Fortran application with
libfortran-unix.a, and optionally with -lpthread to access POSIX threads, or
-lrt to access POSIX message queues.

Make

On FreeBSD, run:

  1. $ make freebsd

To build with LLVM 20 instead:

  1. $ make freebsd CC=clang20 FC=flang20

On Linux (x86-64), run:

  1. $ make linux

On Linux (aarch64), run:

  1. $ make linux_aarch64

To build with Intel oneAPI, run:

  1. $ make CC=icx FC=ifx PPFLAGS=

Optionally, install libfortran-unix.a and the associated module files
system-wide:

  1. $ make install PREFIX=/opt
  2. --- Installing libfortran-unix.a to /opt/lib/ ...
  3. --- Installing module files to /opt/include/libfortran-unix/ ...

Fortran Package Manager

Using FPM, a preprocessor flag has to be passed to GNU Fortran. On FreeBSD:

  1. $ fpm build --profile release --flag "-D__FreeBSD__"

On Linux (x86-64):

  1. $ fpm build --profile release --flag "-D__linux__"

On Linux (aarch64):

  1. $ fpm build --profile release --flag "-D__linux__ -D__aarch64__"

Source Code Documentation

The source code documentation of the library has to be created with
FORD. Install the Python
package with:

  1. $ python3 -m pip install -U ford

In the source repository, either run:

  1. $ make freebsd_doc

Or:

  1. $ make linux_doc

The HTML files will be written to directory doc/. Open index.html in a web
browser.

Examples

Examples are provided in directory examples/:

  • dirent prints the contents of a file system directory.
  • fifo creates a named pipe for IPC.
  • fork forks a process and uses anonymous pipes for IPC.
  • irc implements a basic IRC bot, based on BSD sockets.
  • key reads single key-strokes from standard input.
  • mqueue creates a POSIX message queue.
  • msg shows message passing with UNIX System V message queues.
  • mutex demonstrates threaded access to variable using a mutex.
  • os returns the name of the operating system (Linux, macOS, FreeBSD, …).
  • pid outputs the process id.
  • pipe creates anonymous pipes for bidirectional IPC.
  • pthread runs a Fortran subroutine inside multiple POSIX threads.
  • regex calls POSIX regex functions.
  • semaphore tests POSIX semaphores.
  • serial shows some basic serial port input reading (requires socat(1) and minicom(1)).
  • signal catches SIGINT (CTRL + C).
  • socket creates a TCP/IP connection to a local netcat server (requires nc(1)).
  • stat reads and outputs status of a file.
  • time prints out the results of time functions.
  • uname prints OS information from uname().
  • uptime outputs system uptime.

To compile the example programs, either run:

  1. $ make freebsd_examples

Or:

  1. $ make linux_examples

Licence

ISC