Transfer data between 2 individual program fortran

  • Context: Fortran 
  • Thread starter Thread starter luonganh89
  • Start date Start date
  • Tags Tags
    Data Fortran Program
Click For Summary

Discussion Overview

The discussion revolves around the challenges of transferring data between two individual Fortran programs. Participants explore various methods and experiences related to data sharing, including the use of common blocks, subroutines, and file-based communication.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about transferring data between two separate Fortran programs, having previously used common blocks for data transfer between subroutines.
  • Another participant asserts that sharing memory between two distinct Fortran programs is not feasible and suggests writing data to disk for later retrieval as a viable alternative.
  • A participant indicates they attempted to convert one of the programs into a subroutine to facilitate data transfer but encountered errors when allocating variables.
  • There is a call for more specific details regarding the errors encountered to provide effective assistance.
  • One participant discusses the limitations of using Windows-specific methods for memory sharing and proposes using files and handshake mechanisms for synchronization between programs.
  • A suggestion is made to implement networking capabilities, such as TCP/IP, to facilitate data transfer between programs.

Areas of Agreement / Disagreement

Participants express differing views on the feasibility of data transfer methods, with some advocating for file-based communication while others explore the potential of subroutines or networking. The discussion remains unresolved regarding the best approach to achieve data transfer between the two programs.

Contextual Notes

Participants have not provided specific details about the errors encountered, nor have they clarified the assumptions or definitions related to their proposed solutions. The discussion lacks consensus on the most effective method for data transfer.

luonganh89
Messages
12
Reaction score
0
hi all
i try to transfer data between 2 individual program fortran . I've ever tranferred data between 2 subroutine by using common block, but 2 program make so confused. Have you ever done like me can share some experience ?

thank you
 
Technology news on Phys.org
If you are talking about 2 different fortran progarms, each with its own 'main'...it is not possible to share memory between them (that's what common blocks are...memory).

If you have the ability to run one fortran program at one time and the other at other time...you cannot expect them to share memory.

If anything, you can write the data to disk in certain order from one program and read it from the other in the same order when it runs...you can choose text or binary format.
 
Dear gsal

Of course, I know that and I try to change one of two programe to a sub-program and try to transfer data. But when i allocate some variable in it , it occcurs erros ...
 
luonganh89 said:
Dear gsal

Of course, I know that and I try to change one of two programe to a sub-program and try to transfer data. But when i allocate some variable in it , it occcurs erros ...
If you want help here, you're going to have to be more specific. "it occcurs erros" doesn't give us any ideas what kinds of problems you are encountering.
 
Yeah, please be clear...

In your original post (and title of this thread) you said you wanted to transfer data between two programs...now you say that you turned on of them into a subroutine...that's not transfering data between two programs!

If you can, "stop the hand waving" and ask very specific questions and, if possible, post the fortran code itself.
 
I assume there is no way for separate fortran programs to access each others memory via the DuplicateHandle() method available with various versions of Windows with C programs (although generally the one program has to invoke the other program in order to pass some parameters on the command line used to define and share handles required for DuplicateHandle() ).

An option would be to use a file to share data, along with one or more "handshake" files used to synchonize communication. The issue here is how to "wait" for input from the "other" program. If your version of Fortran includes a sleep function, you can reduce the cpu overhead and/or prevent locking up the process. For each handshake file, you only need one integer as a state flag for each data path (from one program to the other or vice versa):

0 = no pending data, set by sending program (and also the initial value)
1 = pending data, set by sending program (which then "waits" for value == 2 or 3)
2 = data read by receiving program, set by receiving program
3 = optional state, set by receiving program to indicate it's ready to for more data.
 
Can you implement networking capability through FORTRAN like TCP/IP?

If you can, then do this.
 

Similar threads

  • · Replies 37 ·
2
Replies
37
Views
5K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
Replies
86
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 43 ·
2
Replies
43
Views
8K