Transfer data between 2 individual program fortran

In summary: If you can't, then you will need to find another way to do what you want.In summary, you cannot "transfer data between two programs" by using the DuplicateHandle() method. You need to find another way.
  • #1
luonganh89
12
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
  • #2
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.
 
  • #3
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 ...
 
  • #4
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.
 
  • #5
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.
 
  • #6
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.
 
  • #7
Can you implement networking capability through FORTRAN like TCP/IP?

If you can, then do this.
 

Related to Transfer data between 2 individual program fortran

1. How can I transfer data between two individual programs in Fortran?

In Fortran, data can be transferred between two individual programs using the COMMON statement or the SAVE statement. The COMMON statement allows for the sharing of variables between programs, while the SAVE statement allows for variables to retain their values between separate program executions.

2. Can I transfer arrays or structures between programs in Fortran?

Yes, it is possible to transfer arrays or structures between programs in Fortran using the COMMON statement. However, it is important to ensure that the array or structure is declared in the same way in both programs for successful transfer.

3. Is there a limit to the amount of data that can be transferred between programs in Fortran?

The amount of data that can be transferred between programs in Fortran is limited by the available memory on the system. It is important to carefully manage and optimize data transfer to avoid memory constraints.

4. Can I transfer data between programs written in different versions of Fortran?

Yes, it is possible to transfer data between programs written in different versions of Fortran. However, care must be taken to ensure that the data types and declarations are compatible between the two versions.

5. Are there any alternative methods for transferring data between programs in Fortran?

Yes, apart from the COMMON and SAVE statements, data can also be transferred between programs in Fortran using files. The data can be written to a file in one program and then read in the other program for transfer.

Similar threads

  • Programming and Computer Science
2
Replies
37
Views
3K
  • Programming and Computer Science
Replies
4
Views
669
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
16
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
9
Views
3K
  • Programming and Computer Science
Replies
9
Views
1K
Back
Top