Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Coarray programming: running n external program in n different image on the same processor (Fortran)



The situation is that I have an Coarray fortran program. I run it and it's distributed on N processors, and each of these processes should call an external program.

This external program is anexe program, however I want to run it in serial, on the processor that is calling it, as if it were part of the fortran program. The fortran program waits until the external program has completed, and then continues.

The problem is that coarray program only call the exe program once in one image if the command "CALL system". If I deleted the command 'call system(......)', it works well.

Can anyone tell me how I can call the program and ensure it runs only on this processor?



Extra information that might be helpful:

It simply run well if I don't use the command "call system". The result show that num_images: 1. The Coarray program is

program HelloWorld1

implicit none


integer :: me,i

me = num_images()

do i=1,num_images()

if(this_image() == i) then

CALL system('cd ..')

print *,'num_images:',num_images()

end if

end do

sync all


end program HelloWorld1


But if delete this sentence "CALL system('cd ..')" ,the program works well, num_images=4. Why about this problem? How to do it tocall an external program indifferent processes?

0 Kudos
1 Reply
Sorry that nobody answered this in a while, but it isn't really appropriate for this forum. It would be better posted in the Intel Fortran for Linux and Mac OS forum. (or Windows - I can't tell which you're using). I will ask to have it moved there.

What does your real application want to do here? The loop you have is rather odd as it would always call SYSTEM in each image - the loop accomplishes nothing. Also, I suspect that the assignment to "me" wants to call this_image rather than num_images, though the code you have here never uses the variable. And, because the SYSTEM command runs in a separate process, the "cd" command would have no effect on the running program.

Typically a coarray program would not try to invoke external programs from the images. Theoretically, it should work, but may not do what you want. I note that the documentation says that SYSTEM waits on Windows, presumably it doesn't on Linux.
0 Kudos