You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spawning or forking synchronous and asynchronous processes in an Fortran application is currently not easily doable in a cross-platform way. This is usually required for job servers which cannot access a functionality from a dynamically loaded library but have to access this functionality by other means, e.g. invoking a program with some input (standard input, files or arguments) and processing its output (standard output or files). Redesigning the functionality to allow dynamically loading symbols is not always possible or desirable.
A current alternative is the execute_command_line which allows to create a new shell or CMD instance, which in turn can invoke commands. Together with OpenMP, MPI or coarrays this can be done even asynchronous but is tedious and somewhat errorprone. Using a shell or CMD instance has some security and speed implications as well.
Possible API
procedural API similar to POSIX API (basically thin iso_c_binding wrapper)
object oriented API similar to Python's subprocess module
A number of Fortran Posix API's are linked here: #22 (comment) It's a shame the Fortran community didn't unite earlier, and instead allowed compiler vendors to role out several incompatible Posix interfaces.
Edit: the C runtime library for Microsoft Windows has the _spawn, _wspawn Functions which seem to fit the purpose.
awvwgk
added
the
topic: utilities
containers, strings, files, OS/environment integration, unit testing, assertions, logging, ...
label
Feb 3, 2021
Signal handling might deserve an issue on its own, what do you think?
From my experience the signal extension in gfortran and ifort is not really satisfactory, therefore I usually resort to install signal handlers via C. I use it to gracefully catch SIGINT and SIGTERM and shut down the program, depending on your compiler those are most likely completely ignored by default which makes it a pain to kill a Fortran program.
Motivation
Spawning or forking synchronous and asynchronous processes in an Fortran application is currently not easily doable in a cross-platform way. This is usually required for job servers which cannot access a functionality from a dynamically loaded library but have to access this functionality by other means, e.g. invoking a program with some input (standard input, files or arguments) and processing its output (standard output or files). Redesigning the functionality to allow dynamically loading symbols is not always possible or desirable.
A current alternative is the
execute_command_line
which allows to create a new shell or CMD instance, which in turn can invoke commands. Together with OpenMP, MPI or coarrays this can be done even asynchronous but is tedious and somewhat errorprone. Using a shell or CMD instance has some security and speed implications as well.Possible API
iso_c_binding
wrapper)subprocess
moduleAvailable Implementations
Feel free to add entries to this list.
For POSIX API:
For Windows API?
The text was updated successfully, but these errors were encountered: