Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

call system help

roddur
Beginner
935 Views
in a old program, i have to run the executable together .let they are A,B and C
EXECUTABLE A and B
cd
../a.out (see, the executable is one step up in directory tree)

and for C
cd
./c.out

now, instead of running all the executable seperatly, i tried something like:
call system ('cd && ../a.out &')
in C main file.
expecting the job will run on background and transfer the control outside the call statement....but this is NOT what i am getting.
can anybody help me?


0 Kudos
4 Replies
TimP
Honored Contributor III
935 Views
Are you supplying a "system" subroutine of your own? If so, did you supply an INTERFACE or put it in a MODULE? A real example would be needed to see if there is a bug here.
If you mean to use the one provided by ifort, it looks like you omitted "USE ifport," as you should have got compiler complaints about CALLing a function. Yes, it's incompatible with gfortran and g77. Remind me never to use this stuff without the following style:

#ifdef _INTEL_COMPILER
USE ifport
#endif
...
#ifdef _INTEL_COMPILER
icode = system("yourscript")
#elif defined(__GNUC__)
call system('yourscript')
#else
error "system call in unknown compiler environment"
#endif

Choosing cpp style, as that is mandated by OpenMP, thus supported by more compilers than other pre-processing styles.
Note that systemqq is equivalent, but has a logical rather than integer return type.

Simple command lines are OK if they will work in a new copy of the same shell you used to start the program. You could also start a script which specifies which shell it runs. Backgrounding the script won't necessarily work the same in Windows, in case that interests you.
0 Kudos
Steven_L_Intel1
Employee
935 Views
According to the gfortran documentation, its implementation of SYSTEM is as either a subroutine or a function (but only one at a time can be used in a program unit.) As best as I can tell, Intel Fortran behaves the same way, but if you USE IFPORT, then you must use it as a function. For portability, as best as one can be portable with a non-standard routine, it's probably best to use it as a function.

In any event, I don't think that the form of the call is the issue here. To the best of my knowledge, SYSTEM will execute one command only, not a series of commands. Perhaps if you wrote a shell script you could invoke it with a call to SYSTEM.
0 Kudos
TimP
Honored Contributor III
935 Views
That's interesting; I have used the function call form with apparent success with gfortran, then I read another copy of gfortran documentation which said only the subroutine was supported.
Anyway, it seemsmore reliableto write a script which specifies the shell, even when issuing a pair of commands.
0 Kudos
Steven_L_Intel1
Employee
935 Views
The OP also asked this in comp.lang.fortran, where a script was also recommended.
0 Kudos
Reply