Fortran - c interprocess communication

In summary: IPC frameworks... which would give you more control over the whole process. But in the end, its just a matter of doing research and finding a way to do what you want.
  • #1
Radight
3
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
  • #2
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)?
 
  • #3
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
 
  • #4
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
 
  • #5


Yes, it is possible to establish interprocess communication between a program written in Fortran and a program written in C. Both Fortran and C have libraries and tools that allow for interprocess communication, such as using shared memory or pipes. However, the compatibility between the two languages will depend on the specific implementation and usage of these tools. It is important to carefully consider the data types and structures used in both programs to ensure they are compatible for communication. Additionally, proper error handling and synchronization techniques should be implemented to avoid any potential issues. It is recommended to consult with experts in both languages or refer to documentation and resources specific to your situation to ensure successful interprocess communication.
 

Related to Fortran - c interprocess communication

1. What is Fortran - c interprocess communication?

Fortran - c interprocess communication is a method for two separate computer processes, one running Fortran and the other running C, to share information and communicate with each other. This allows for the integration of code written in both languages, expanding the capabilities and functionality of a program.

2. How does Fortran - c interprocess communication work?

Fortran - c interprocess communication works by using a shared memory space between the Fortran and C processes. This shared memory allows for the exchange of data between the two processes, allowing them to communicate and work together.

3. What are the advantages of using Fortran - c interprocess communication?

One of the main advantages of using Fortran - c interprocess communication is the ability to combine the strengths of both languages. Fortran is known for its scientific and numerical computing capabilities, while C is known for its speed and efficiency. By using both languages, developers can create programs that are both powerful and fast.

4. Are there any challenges in using Fortran - c interprocess communication?

Yes, there are some challenges in using Fortran - c interprocess communication. One of the main challenges is ensuring that the shared memory space is managed properly, as any errors or conflicts in the shared memory can cause the program to crash. Additionally, there may be compatibility issues between the two languages that need to be addressed.

5. Can Fortran - c interprocess communication be used with other languages?

Yes, Fortran - c interprocess communication can also be used with other languages, such as C++ or Java. However, the implementation may vary and additional steps may be needed to ensure compatibility between the different languages.

Similar threads

  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
2
Views
7K
  • Programming and Computer Science
Replies
20
Views
5K
  • Programming and Computer Science
Replies
22
Views
4K
Back
Top