how to call an executable file and give the variables

I would like to call an executable file and give it variables in my fortran code. for example:

function obj(ii)
use omp_lib
use  ifport
implicit none
integer,intent(in)::ii
integer::     thron
real::obj
thron=omp_get_thread_num()
obj=RUNQQ('C:\pgi\matlab_omp_cuda\test.exe','')
return
end function  obj

In this code, “thron” is the thread no. which is a variable in another executable file.

Hi Chia,

Could you do something like this?

function obj(ii) 
use omp_lib 
use  ifport 
implicit none 
integer,intent(in)::ii 
integer::     thron 
real::obj 
character(len=80) :: cmdline
thron=omp_get_thread_num() 
write (cmdline, '(i1)') thron
obj=RUNQQ('C:\pgi\matlab_omp_cuda\test.exe', trim(cmdline)) 
return 
end function  obj

This modification would basically convert thron to a string, store it in the cmdline variable, then pass the cmdline variable as a parameter to the test.exe application.

However, this assumes that the test.exe application has been coded in such a way as to expect this parameter upon being called, and handle it correctly.

Hope this helps,

+chris