How to run an executable from within a c program?

How can I run an executable from within a FORTRAN code?

  • Is there a command I can use in FORTRAN programming that will run another executable? I am using Compaq Visual Fortran with windows, and I also compile the code on a linux box. I would like the commands for both. The other executable will be located in the same folder as the written program.

  • Answer:

    Just as the other answerer said: you have to rely on what is known as a system call, the specifics details may depend on your compiler. Basically, this is your program launching another program just as if you entered the command in a shell tool. What you need to check for, however, is that usually the calling program will be suspended until the called one is completed; if you want to run concurrently, you need to use a run detach modifier, like the "&" of Unix/Linux. The other thing to watch for is that, unless you establish inter-process communication yourself, the two programs do not talk with one another; so you have the second program put its answer in some intermediate file, with a signal for the first program, if you need to transfer information across.

Soulagen... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

It's somewhat bad practice, but if you know what you are doing it would be something like: program name: myProg call system('./myProg') !< Call another executable It's just a call to the system subroutine. It should work on windows, but not guaranteeing it since I don't have a windows Fortran compiler other than under MinGW / Cygwin

Jared

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.