Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Another Fortran90 question

  1. Nov 10, 2008 #1
    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é
     
  2. jcsd
  3. Nov 10, 2008 #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.
     
  4. Nov 11, 2008 #3
    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:

    [​IMG]

    Thanks in advance

    Best regards

    André
     
  5. Nov 11, 2008 #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.
     
  6. Nov 12, 2008 #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
     
  7. Nov 12, 2008 #6
    Glad to be of help.
    Let us know if you solved your problem.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Another Fortran90 question
  1. Fortran90 help (Replies: 4)

  2. Fortran90 help (Replies: 5)

Loading...