system command in Fortran

Posted on 2003-02-25
Medium Priority
Last Modified: 2013-11-08
This is a question on Fortran. There was no list for Fortran, so I am asking it here.

I would like to know the equivalent command of system("")
in fortran.

C: system("run.exe")

What is the command in Fortran?
Thanks a lot!!
Question by:dpark1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

gj62 earned 400 total points
ID: 8017360
You should have posted in the Programming Languages main section, rather than just picking a different language.  

Anyhow, for Sun Fortran (the only Fortran I kinda know - sorry), the command is as follows (tell me what Fortran you are using if this does not work):

INTEGER*4 system
status = system( string )

string  character*n  Input  String containing command to do
Return value  INTEGER*4  Output  Exit status of the shell executed. See wait(2) for an explanation of this value.

character*8 string / 'ls s*' /
INTEGER*4 status, system
status = system( string )
if ( status .ne. 0 ) stop 'system: error'

The function system passes string to your shell as input, as if the string had been typed as a command. Note: string cannot be longer than 1024 characters.

If system can find the environment variable SHELL, then system uses the value of SHELL as the command interpreter (shell); otherwise, it uses sh(1).

The current process waits until the command terminates.

Historically, cc and f77 developed with different assumptions:

If cc calls system, the shell is always the Bourne shell.

If f77 calls system, then which shell is called depends on the environment variable SHELL.
The system function flushes all open files:

For output files, the buffer is flushed to the actual file.
For input files, the position of the pointer is unpredictable.
See also: execve(2), wait(2), and system(3).
The system() function is not MT-safe. Do not call it from multithreaded or parallelized programs.

LVL 12

Expert Comment

ID: 8023262
Which fortran you are using. Without that its' impossible to answer your question.
LVL 20

Expert Comment

ID: 10018250
Nothing has happened on this question in over 10 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by gj62.


EE Cleanup Volunteer

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question