J. Giles (probably(?) not Mr Freeze Frame) wrote:
> Making system calls is (obviously) system dependent and not
> within the scope of a language definition. The C language
> definition requires that a 'hosted environment' for C must
> provide a system() library procedure. But, what that procedure
> does is not defined within the C standard - the character
> string argument is "executed by a command processor in
> an implementation defined manner". There's just not a
> whole lot a language standard can say about this.
>
> Many Fortran implementations (particularly for UNIX systems)
> give access to the same system() function they provide for C
> implementations (through a wrapper, so the differences in the
> character string data type internals can be adjusted). The
> Fortran language standard does not require any particular
> procedure or other interface for this capability though. The
> documenation for the particular compiler you choose should
> have a description of the proper procedure to call.
What one CAN do is write one's own SUBROUTINE EXECUTE_SYSTEM_COMMAND.
When porting code to other platforms, one only has to change this
routine, which calls system() or whatever, rather than every occurence
in one's own code. Of course, different operating systems have
different facilities one can call, the output is different and so on so
this of course makes this kind of stuff inherently non-portable.
I don't have much experience with it, since I tend to write standard
Fortran, but I understand that it is possible to call many system
services on VMS "directly" from Fortran. (In fact, I've even heard of a
DCL "compiler" which replace DCL .COM files ("shell scripts", DCL being
an interpreted command language) with the equivalent Fortran and then
compiled that, supposedly making it faster.) Since unix is written in
C, it tends to be easier to interface with the operating system from C.
My limited experience with VMS in this respect indicates that it doesn't
matter much which language one uses for such purposes (VMS itself is
written in many languages, but that wouldn't be a requirement for
treating on all on equal basis in this respect).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|