Fortran - c interprocess communication

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

Discussion Overview

The discussion revolves around the possibility of establishing interprocess communication (IPC) between a Fortran 90 program and a C program, specifically focusing on how changes made in one program can be instantly reflected in the other through modifications to .xyz (mol) files. The scope includes technical exploration of IPC methods and potential compatibility issues between Fortran and C.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants propose using standardized IPC methods such as pipes, which allow for reading and writing data between processes.
  • Others suggest that a network protocol could be utilized for IPC, although this may be considered overkill for the task at hand.
  • A participant mentions the possibility of using a publish/subscribe model for managing events and callbacks, indicating a method to send updates between programs.
  • There is uncertainty regarding the ability of Fortran to access system-level libraries (DLLs or SOs), with one participant expressing doubt about this capability.
  • One participant considers implementing a loop that continuously checks for changes in the .xyz files as a potential solution for communication between the two programs.
  • Suggestions are made to explore specific libraries and documentation, such as the sockets library for networking and named pipes for IPC.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method for IPC between Fortran and C, and multiple competing views on potential solutions remain. There is also uncertainty about the compatibility of the two programming languages in this context.

Contextual Notes

Limitations include potential dependencies on operating system frameworks for IPC, as well as unresolved questions about the specific capabilities of Fortran in accessing system libraries.

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
12K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
16K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 12 ·
Replies
12
Views
2K