jpblasques
Marine/Ocean
- Nov 24, 2006
- 20
Hi everyone!
I am trying to call a program from Fortran using the CALL SYSTEM subroutine. The problem has a little twist to it which is I am trying to run two commands in parallel. I am working on a UNIX machine.
What I have now is:
progam main
.
.
.
CALL SYSTEM('run_prog1 & run_prog2')
.
.
.
end main
What happens is that prog1 and prog 2 are executed (almost) simultaneously (the procedure is rather straight forward as I am simply using "&" to execute the two programs as I would otherwise do in the command prompt). The problem is that the computation of prog1 is different from prog2. So if prog1 is faster than prog2 fortran will finish executing prog1 and proceed reading the next commands from the main program while prog2 keeps running. Well, this is not really what i wanted! I would like Fortran to "wait" for both prog1 and prog2 to be finished (that means they have written their output files) before continuing with the main program.
I am very grateful for any help or any suggestions that you might have.
Regards
José
I am trying to call a program from Fortran using the CALL SYSTEM subroutine. The problem has a little twist to it which is I am trying to run two commands in parallel. I am working on a UNIX machine.
What I have now is:
progam main
.
.
.
CALL SYSTEM('run_prog1 & run_prog2')
.
.
.
end main
What happens is that prog1 and prog 2 are executed (almost) simultaneously (the procedure is rather straight forward as I am simply using "&" to execute the two programs as I would otherwise do in the command prompt). The problem is that the computation of prog1 is different from prog2. So if prog1 is faster than prog2 fortran will finish executing prog1 and proceed reading the next commands from the main program while prog2 keeps running. Well, this is not really what i wanted! I would like Fortran to "wait" for both prog1 and prog2 to be finished (that means they have written their output files) before continuing with the main program.
I am very grateful for any help or any suggestions that you might have.
Regards
José