openMP/MPI parallelization of external standalone program

Hello forum,

is possible to parallelize via OpenMP/MPI the following fragment of fortran code:

do i = 1,n
   call ext_run(input(i), output(i))
end do

where subroutine ext_run(input,output) execute external single thread program via SYSTEM(commandline) function. For example:

subroutine ext_run(input, output)

...
response = SYSTEM ('extprog.exe < input_i.dat > output_i.dat')
...

return
end

where input_i and output_i are auxiliary data files which were created using input(i) or output(i) parameters.

I will be happy for some simple examples. Thanks …

Michal

Hi Michal,

Here’s a simple OpenMP program that runs the date command.

% cat omp_sys.f90 
program testsys
  
  use omp_lib
  integer i
  
!$omp parallel do private(i)
do i=1,10
  call ext_run(i)
end do

end program testsys

subroutine ext_run(i)
integer i, rc
character*80 :: cmd 
write(cmd,'(AI3.3)'), "date > output_",i
rc = system(cmd) 
print *, rc
end subroutine ext_run
 
% pgf90 omp_sys.f90 ; a.out
            0
            0
            0
            0
            0
            0
            0
            0
            0
            0
  • Mat