?
Solved

system command in Fortran

Posted on 2003-02-25
4
Medium Priority
?
1,930 Views
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.

e.g.
C: system("run.exe")

What is the command in Fortran?
Thanks a lot!!
0
Comment
Question by:dpark1
3 Comments
 
LVL 6

Accepted Solution

by:
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 )

where:
 
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.
 
Example:

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

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.


0
 
LVL 12

Expert Comment

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

Expert Comment

by:jmcg
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

601 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