Execute_command_line

Szabó László szabola@met.hu
Tue Oct 8 12:05:00 GMT 2013


You are right, system waits for executed program. It was an other error in my program, and so I belived that system subroutine causes the error. I solved my problem.

thank you 
szabola
----- Eredeti üzenet -----
From: Tobias Burnus <burnus@net-b.de>
Címzett: Szabó László <szabola@met.hu>
Másolat: fortran@gcc.gnu.org
Elküldött: Mon, 07 Oct 2013 19:06:40 -0000
Tárgy: Re: Execute_command_line

Szabó László wrote:
> I tried SYSTEM subroutine earlier, but this method doesn't wait for the executed program has been finished. I would like to copy some big size files in a fortran program, and after copy I would like to open these files. Since SYSTEM doesn't wait for the end of copying when I try to open files, I get "No such file" errors....

I think EXECUTE_COMMAND_LINE won't help in this case. For SYSTEM, 
gfortran calls the system's "system" function, cf. 
http://man7.org/linux/man-pages/man3/system.3.html and 
http://pubs.opengroup.org/onlinepubs/009695399/functions/system.html

SYSTEM is by itself waiting until the executed program is finished. 
Hence, I highly suspect that the program you execute forks and the 
parent returns before the forked child (which does the actual copying) 
is finished. In that case, you cannot do much from the Fortran side.

EXECUTE_COMMAND_LINE would only help for the reverse problem, 
WAIT=.false. In that case, gfortran forks a child process, which calls - 
again - the system's "system" function - which permits to continue 
without waiting for "system" to return.

I wonder whether it works on the command line - because you should have 
the same problem there. If it works there, using a short sleep as 
suggested by Steve might help. (Still, using "sleep" sounds a bit racy 
and fragile.)

Tobias





More information about the Fortran mailing list