Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

operating system commands

14 views
Skip to first unread message

Daniel H

unread,
Mar 7, 2012, 6:12:49 AM3/7/12
to
Hi

is there a portable way to issue a command to the OS from a Fortran
program? The Intel Fortran Compiler provides the command system(string)
as an extension, but I don't find anything similar in the book by
Metcalf/Reid/Cohen (F95/03 explained).

Thanks in advance!

Daniel

arjenmarkus

unread,
Mar 7, 2012, 6:51:16 AM3/7/12
to
Yes, there is - it is the F2008 routine EXECUTE_COMMAND_LINE you are
looking for.

Mind you, having a standard way of running external commands does not
mean that these commands are in any way standardised!

Regards,

Arjen

Daniel H

unread,
Mar 7, 2012, 8:00:07 AM3/7/12
to
>
> Yes, there is - it is the F2008 routine EXECUTE_COMMAND_LINE you are
> looking for.

Ah, true - actually I might have asked that a while ago and forgotten.
Just saw that Gfortran has implemented it, the latest Intel has not.

Thx.

Paul Anton Letnes

unread,
Mar 7, 2012, 8:03:30 AM3/7/12
to
Supposedly, gfortran is the only one who has.

Paul

http://fortranwiki.org/fortran/show/Fortran+2008+status

arjenmarkus

unread,
Mar 7, 2012, 8:29:32 AM3/7/12
to
Well, for future's sake, it should not be too hard to use SYSTEM()
and other compiler-specific functions/routines to emulate the
EXECUTE_COMMAND_LINE routine (concentrating on the common bits
and pieces). That way you can start using the new standard without
having to wait for the compilers to adopt this respect.

Regards,

Arjen

Tim Prince

unread,
Mar 7, 2012, 10:38:49 AM3/7/12
to
On 03/07/2012 06:12 AM, Daniel H wrote:

> is there a portable way to issue a command to the OS from a Fortran
> program? The Intel Fortran Compiler provides the command system(string)
> as an extension, but I don't find anything similar in the book by
> Metcalf/Reid/Cohen (F95/03 explained).
>

f2008 provides a standard intrinsic get_command_line for the first time.
Of the compilers I've tested, only gfortran (from 4.6) supports it.
Every compiler I've tried in recent years works with the system()
function, even though the details in principle vary among compilers
(including the question of whether it's available as a subroutine).
You could write your own get_command_line in terms of what your compiler
library provides.

robert....@oracle.com

unread,
Mar 7, 2012, 11:23:37 PM3/7/12
to
On Mar 7, 5:03 am, Paul Anton Letnes
Oracle Solaris Studio Fortran has had EXECUTE_COMMAND_LINE for the
past
two releases.

Bob Corbett
0 new messages