Another Fortran90 question

  • Fortran
  • Thread starter andredoc
  • Start date
  • Tags
    Fortran90
In summary, the program creates a text file that is used to estimate the variance of data. The problem is that the file is not completely generated, and this may cause the program to abort.
  • #1
andredoc
5
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
  • #2
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.
 
  • #3
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:
  • #4
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.
 
  • #5
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
 
  • #6
Glad to be of help.
Let us know if you solved your problem.
 

What is Fortran90?

Fortran90 is a programming language commonly used for scientific and engineering applications. It was released in 1991 and is an updated version of the original Fortran language.

What are the main features of Fortran90?

Some of the main features of Fortran90 include: improved array handling, dynamic memory allocation, modules for organizing code, built-in support for complex numbers, and the ability to create recursive subroutines.

Is Fortran90 still widely used?

Yes, Fortran90 is still widely used in scientific and engineering fields, particularly for high-performance computing applications. It is also actively maintained and updated by the Fortran Standards Committee.

What are the advantages of using Fortran90?

Some advantages of using Fortran90 include its strong support for numerical and scientific calculations, its efficient use of computer resources, and its portability across different operating systems.

Can I use Fortran90 for other types of programming?

While Fortran90 is primarily used for scientific and engineering applications, it can also be used for other types of programming. Its capabilities include file handling, string manipulation, and other general programming tasks.

Similar threads

  • Programming and Computer Science
Replies
22
Views
921
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
2
Replies
65
Views
2K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
12
Views
9K
Replies
6
Views
1K
Replies
19
Views
1K
  • Programming and Computer Science
Replies
11
Views
2K
Back
Top