How Can Fortran 90 Ensure External Executable Completion Before Proceeding?

  • Context: Fortran 
  • Thread starter Thread starter andredoc
  • Start date Start date
  • Tags Tags
    Fortran90
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 5K views
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é
 
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.