cant get the "execute_command_line" routine to work

I want to issue a shell command from within a FORTRAN program to the system in order to start another program. The FORTRAN program should wait until the other program finished, and then read the file that the other program produced. I am working on a Windows-10 machine.

I used to do this with the old OpenWatcom compiler with the function
istatus = FSYSTEM(cmdlin)
where cmdlin is a character variabe that contains the command.

PGfortran seems to have the same functionality with the intrinsic function “SYSTEM()”. However, i could not find a description in the PGI manuals but only in those of the GNU compiler. On the other hand, the program compiles without error, but apparently does not wait for the external process to finish.

FORTRAN 2008 has the function “execute_command_line(command,wait)” that is supposed to do this when wait = .true. However, the linker gives an unresolved external error message. I conclude that the “execute_command_line” intrinsic is not implemented in pgfortran, or requires a special library.

If somebody else asked this question before, I could not find it, since any search for “execute_command_line” is split into searches for the individual words, which appear to often to yield useful search results.

thanks for any help, Bernhard

Hi bdick12925,

As you note there’s the non-standard “SYSTEM” and “SYSTEMQQ” calls which are simply wrappers for the C “system” call. (See: https://www.pgroup.com/resources/docs/19.10/x86/pgi-ref-guide/index.htm#dflib-libm-dfport-use) I just tried and it blocks for me so it’s unclear why it’s not waiting for you.

In PGI 19.10, we just added support for “execute_command_line” but only for Linux. It will link on Windows but give you a runtime error message.

-Mat