Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multitasking in Fortran [closed]

Tags:

fortran

How can I do multi-tasking and inter-process communication in Fortran?

like image 513
Sasha Avatar asked Nov 30 '22 04:11

Sasha


2 Answers

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.

like image 106
robince Avatar answered Dec 09 '22 09:12

robince


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.

like image 24
Jonathan Dursi Avatar answered Dec 09 '22 11:12

Jonathan Dursi