Fortran - c interprocess communication

  • Context: Fortran 
  • Thread starter Thread starter Radight
  • Start date Start date
  • Tags Tags
    Communication Fortran
Click For Summary
SUMMARY

This discussion centers on establishing interprocess communication (IPC) between a Fortran 90 program and a C program, specifically for real-time updates to .xyz (mol files). The primary methods suggested include using named pipes for IPC and implementing a TCP/IP network model with sockets for communication. The discussion emphasizes the need for both programs to handle data exchange efficiently, with recommendations to explore the Windows API for named pipes and the Winsock library for TCP/IP on Windows systems.

PREREQUISITES
  • Understanding of Fortran 90 programming
  • Familiarity with C programming
  • Knowledge of Interprocess Communication (IPC) techniques
  • Basic understanding of TCP/IP networking and socket programming
NEXT STEPS
  • Research named pipes and their implementation in both Fortran and C
  • Explore the Winsock library for TCP/IP communication on Windows
  • Investigate the standard sockets library for Unix-based systems
  • Review the Windows API documentation for IPC methods
USEFUL FOR

Software developers working with Fortran and C, particularly those involved in scientific computing or applications requiring real-time data synchronization between processes.

Radight
Messages
3
Reaction score
0
there is a program in written in fortran 90 and a program written in c, the first program is able to modify .xyz (mol files) and the C program can read those,
so is it possible to make an interprocess communication between these 2 program to let one update instantly if i change anything in the fortran progra for example or in the c program
if i change anything in the .xyz file using fortran it should instantly appear changed in the c program and vica versa
is that possible somehow? i am not sure about c and fortran interprocessing abilities
thanks for the help in advance

i think my problem is quite similar to this topic but i am not using 2 fortran program so that's why i am not sure about compatibility that c and fortran is compatible in both ways or not
https://www.physicsforums.com/archive/index.php/t-104004.html
 
Technology news on Phys.org
Radight said:
there is a program in written in fortran 90 and a program written in c, the first program is able to modify .xyz (mol files) and the C program can read those,
so is it possible to make an interprocess communication between these 2 program to let one update instantly if i change anything in the fortran progra for example or in the c program
if i change anything in the .xyz file using fortran it should instantly appear changed in the c program and vica versa
is that possible somehow? i am not sure about c and fortran interprocessing abilities
thanks for the help in advance

i think my problem is quite similar to this topic but i am not using 2 fortran program so that's why i am not sure about compatibility that c and fortran is compatible in both ways or not
https://www.physicsforums.com/archive/index.php/t-104004.html

There are different ways you can do this.

In terms of Inter Process Communication (IPC), typically you use pretty standardized objects like pipes. A pipe is basically a read,write,(or both) object and typically what happens is that programs create specially named pipes, and then each process will get the appropriate handle and then send and receive data to it, as if it was like a network connection.

Similarly one trick you could use is to use a network protocol of some sort. This could be overkill, but it does work.

In the context of your problem (making changes to file, need to update other programs), there is bound to be an OS level framework that allows this, but I haven't tried it myself. In terms of IPC, I've used the network idea and used a standard protocol framework that uses publish/subscribe (fancy way for managing events and callbacks) and with that you just make a connection and send a network packet to another port on the local machine.

I haven't used FORTRAN though, so what kind of access can you get to functions in DLL's? Is there a platform library, or some way of getting access to system level libraries (DLL's or SO's)?
 
i am not sure about what you are asking but i don't think so you can access systems dll`s

by the way would you be more specific or can you provide any links about your ideas where i can look for details how to do it and which program i have to rewrite to make this communication possible?

i got the source code of both program so i can change anything i want in c and the fortran one as well but i am not sure how to do it

i was thinking about a loop first (thats runs with the program till quitting) which is checking for changes in the files or something
 
Radight said:
i am not sure about what you are asking but i don't think so you can access systems dll`s

by the way would you be more specific or can you provide any links about your ideas where i can look for details how to do it and which program i have to rewrite to make this communication possible?

i got the source code of both program so i can change anything i want in c and the fortran one as well but i am not sure how to do it

i was thinking about a loop first (thats runs with the program till quitting) which is checking for changes in the files or something

In terms of the networking ideas, its basically implementing a simple network model based on the reliable TCP/IP protocol. For this, just look at the sockets library. Windows has an implementation called Winsock, which you you will want to check out for windows, or on the *nix platform, just use the standard sockets library.

For pipes, just look up named pipes. If you want more details look at the Windows API documentation.

You should also look at things like this:

http://www.codeproject.com/KB/threads/Win32IPC.aspx
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 59 ·
2
Replies
59
Views
11K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
16K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 12 ·
Replies
12
Views
2K