- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A coroutine is a function that can suspend execution to be resumed later. Coroutines are stackless: they suspend execution by returning to the caller and the data that is required to resume execution is stored separately from the stack. This allows for sequential code that executes asynchronously (e.g. to handle non-blocking I/O without explicit callbacks), and also supports algorithms on lazy-computed infinite sequences and other uses.
----------------------------------------------------
Any chance we will see coroutines in Fortran
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can (somewhat) accomplish this with DO WHILE(.not.done) and select case with a state variable where the Done flag and state variable are SAVE.
In a design similar to OpenMP, you would have a master procedure containing the DO WHILE loop and cooperative select case proceture(s) that progress step-by-step.
An alternative method, would be to construct a ring buffer of procedure pointers where the "master" procedure is a simple loop that calls the next procedure pointer in the ring buffer.
The first method would permit you to split a single procedure into multiple parts, whereas the second method requires each fragment to be its own procedure. (collectively the fragments of a "collective"-procedure would use the same module for save states/common variables of the "collective"-procedure.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The topic has been raised among the Fortran committee - it did not get a warm reception. Fortran already supports asynchronous I/O.
Fortran has two parallel models, coarrays and DO CONCURRENT. There are existing mechanisms in the language to handle most of what coroutines do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
https://ecochiccayman.files.wordpress.com/2015/02/o-polar-bear-family-facebook.jpg
You mean something like this look

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page