How can I do multi-tasking and inter-process communication in Fortran?
The main standards to read up on are OpenMP (shared memory multi-threading) and MPI (message passing). Both work well with Fortran (as well as other languages) and you will find a lot of information online.
OpenMP defines a simple way of programming concurrent (parallel) processing in Fortran/C/C++. The process must reside in a same computer (node).
OpenMP 3.0 recent introduces $OMP TASK directive which in principle should allow multitasking the way multithreading is usually done (that is, each thread does its own task). For OpenMP, see this tutorial:
https://computing.llnl.gov/tutorials/openMP/
or specs in http://www.openmp.org/
I won't address interprocess communication (IPC) since I am not familiar with this. I believe you can do POSIX function calls if that what you want. If your compiler supports some Fortran 2003 constructs (e.g. gfortran >= 4.4) then you can use the nice C-Fortran interoperability provided by ISO_C_BINDING standard module. Then with proper care you can call posix functions that can provide IPC functionalities. That's my 2c.
Fortran2008 also has coarrays, which allows distributed-memory computing from within the language itself, and do concurrent, which allows for functionality similar to an OpenMP parallel do loop. Right now, only the newest intel compiler fully supports these, and g95 has partial support; however, they are actively being worked on by the other compiler vendors, including gfortran.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With