- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
currently I write in a file, close it and directly afterwards I use somewhat like
System('myprogram.exe')
Nothing special so far. The problem now is: myprogram (a second Fortran program) tries to open the file I just created in the main Fortran program. But it seems that the file writing is not finished when myprogram tries to open it. Error message is "cannot open file".
Is there an easy way to wait until the file writing is complete and the file can be accessed by other programs then? I do not want to impelement some stupid dummy loop to win time. Is there a smarter solution possible?
currently I write in a file, close it and directly afterwards I use somewhat like
System('myprogram.exe')
Nothing special so far. The problem now is: myprogram (a second Fortran program) tries to open the file I just created in the main Fortran program. But it seems that the file writing is not finished when myprogram tries to open it. Error message is "cannot open file".
Is there an easy way to wait until the file writing is complete and the file can be accessed by other programs then? I do not want to impelement some stupid dummy loop to win time. Is there a smarter solution possible?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What's wrong with a 'stupid' dummy loop if it does the job?
Logical logopen
logopen=.true.
...
DO WHILE(logopen )
INQUIRE(FILE='filename', err= 9999, OPENED=logopen)
enddo
call systemqq('myprogram.exe filename')
9999 ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please put a call to sleepqq in there, to wait for, say, half a second between tries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve and Anthony,
of course there is nothing wrong with your loop - I just didn't consider this idea. I am still not familiar with the newer Fortran/Library so my idea was much simpler like
DO 200 Z=1, 1000
DO 100 I=1,1000
K =K + 1
100 continue
P = P + 1
200 continue
Your suggestion is much better of course and less "stupid" :)
I turned it into
Code:
logopen=.true. delay = 250 DO WHILE(logopen) INQUIRE(FILE=wkfile, err=999, OPENED=logopen) CALL SLEEPQQ(delay) enddo
and it works fine. Thanks again.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page