Fortran How Can Fortran 90 Ensure External Executable Completion Before Proceeding?

  • Thread starter Thread starter andredoc
  • Start date Start date
  • Tags Tags
    Fortran90
AI Thread Summary
In Fortran 90, ensuring that an external executable completes before proceeding can be challenging, especially when using the call system function. The user experienced issues with reading a generated text file that sometimes contained incomplete data, resulting in erroneous values. It was suggested that good programming practice involves closing files after writing, or flushing buffers to ensure data is fully written before reading. The user discovered that the problem may stem from errors in the executable code, leading to incomplete file generation even after attempts to delay processing. This highlights the importance of debugging the executable to ensure proper file handling and completion.
andredoc
Messages
5
Reaction score
0
Hello! I’m programming in Fortran 90 using Force, version 3.0.0. beta2 compiler. The program calls an executable external file with the instruction call system (‘name of file’). This executable file calculates the estimation variance of a set of data and automatically generates an output txt file. Then, the program opens the txt file to read the values generated. But, when the program reads the txt file, sometimes the file is still incomplete and some values assume the value of -999 because when the file is open these values aren’t completely generated.

Is there any instruction that allows the code to proceed only when the executable file is finished? I searched the tutorials and found an instruction called runqq with the sintax:
RUNQQ (filename, commandline)

I’ve tryed to run this command on the compiler but the program doesn’t recognize this instruction. Is it because of the compiler I’m using? Can anyone help me?

Thanks in advance

André
 
Technology news on Phys.org
It seems that the file was still open when you tried to access the file.
Good programmig practice would require that the file be closed when there is no more informtion to be written. In case the writer expects to write more later, it would either close and reopen lalter in append mode, or flush the buffer so the file can be read to the end by someone else.
If the version of Fortran you use does not allow flushing of the buffer, you can always close file and reopen it, hoping that no one else took possession of it in the mean time.
 
mathmate said:
It seems that the file was still open when you tried to access the file.
Good programmig practice would require that the file be closed when there is no more informtion to be written. In case the writer expects to write more later, it would either close and reopen lalter in append mode, or flush the buffer so the file can be read to the end by someone else.
If the version of Fortran you use does not allow flushing of the buffer, you can always close file and reopen it, hoping that no one else took possession of it in the mean time.

Mathmate,

the executable external file and the txt file generated by this executable file, are inserted in a do cicle. In each cycle a new txt file is opened, the values are read and the file is closed and deleted.

The problem is that when the txt file (generated automatically by the executable file) is read, it's not completely generated.

The image below ilustrates the problem:

http://1.bp.blogspot.com/_hEyr1VZJRlU/SRl7-aEIqzI/AAAAAAAAADY/O8C_YWziMOo/s1600-h/ilustracao.jpg

Thanks in advance

Best regards

André
 
Last edited by a moderator:
Did you find out why it was not completely generated? The problem seems to lie there.
If there is an error and the program is aborted, then the file will be incomplete and left open.
 
Mathmate, I thought it was because the txt was not fully created when it was read, but now I've found that it wasn't because of that. I use the instruction sleep and found that, even if I delayed the program for a few seconds, the txt file was still incomplete for some iterations. Now I known where to focus, there must be an error on the code somewhere and, as you say, the program is aborted and the file is incomplete and left open.

Thanks mathmate
 
Glad to be of help.
Let us know if you solved your problem.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
11
Views
3K
Replies
2
Views
18K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
2
Views
30K
Replies
9
Views
9K
Replies
6
Views
5K
Back
Top