Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29236 Discussions

Shared memory in Linux with Fortran 10.0

avanhorn
Beginner
462 Views
I have need for multiple programs to share the same data. How can I share memory among different programs using Fortran 10.0 under Linux?
0 Kudos
1 Reply
Ron_Green
Moderator
462 Views
Intel Fortran doesn't directly support shm/shared memory.

You may wish to consider a mixed-language model where C manages the shm memory segments. Are you thinking of using BSD style mmap or Sys V IPC?

I, personally, have never done this. I have seen folks use a shared disk file in Fortran to share data, assuming the updates are not frequent, this could be a relatively easy mechanism. This works well for a program chain, that is, a series of programs that run one after another, each taking the output of the prior program as input. Are your programs serialized?

Another thought, again having not tried this, is to use C to dispatch a POSIX thread, or threads. Convert the separate programs into Fortran subroutines compiled into the main Fortran program. Have the master program call a C function to spawn a thread. This child thread then calls the Fortran subroutine. This child subroutine could then share all the static data structures as the main program.

There are many ways to code these things. The design really depends on your intended workflow, need for real time sharing vs infrequent global data, etc.

ron
0 Kudos
Reply