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

RunQQ Function

oscarpiedrahita
Beginner
1,953 Views
Hello People

RunQQ is a Run-Time Function for execution of another program
Its syntax is:
result = RUNQQ (filename, commandline)

Is there any way to use commandline as input/output? Or, in other words, how can I send information back to the calling program?
Do I have to use a COM Server/Client?

Thanks in advance

OPiedrahita
0 Kudos
11 Replies
rahzan
New Contributor I
1,953 Views
You can send information back on the command line arguments If the callee is designed to accept it. Otherwise it will ignore it.

A Com client is no different, if the other program does not want to talk to your client then it's not gonna happen.

So it all depends on the interface to the callee.
It would be the User interface for the case of RUNQQ
and Programming interface (API) in the case of the com-client.

You can for example run a typical DOS command like delete and use the argument to tell it which file:
CALL RUNQQ('DEL','SOMEFILE.TXT /V')

Lest to confuse you more, the third choice is CREATEPROCESS which is a generalized form of RUNQQ.

TimH
0 Kudos
james1
Beginner
1,953 Views
No, the commandline argument is readonly. There are any number of IPC mechanisms available depending upon what sort of data you would like to provide back to the original program.

James
0 Kudos
oscarpiedrahita
Beginner
1,953 Views
Thanks

Sorry I did not answer sooner

Commandline argument is read only, therefore it is necessary to use another method to send back information.

I can make a text string with my information using some rule to separate the variables, for example separating them with brackets, therefore let us think about transferring back a string
. How can I do it?
OPiedra
0 Kudos
oscarpiedrahita
Beginner
1,953 Views
Thank you TimH

I like RunQQ because it is simple to debug, but it is read only.
I have not begun to work with com-client yet.
Where could I find information about CreateProcess?
OPiedra
0 Kudos
Steven_L_Intel1
Employee
1,953 Views
You could start with my CVF Newsletter Article on CreateProcess.

You'd probably need to use a pipe to get data back from the subprocess - my article doesn't cover that.

Steve
0 Kudos
james1
Beginner
1,953 Views
Mailslots provide an easy solution. Here is a simple example (no error handling):
mbx.def

use kernel32
character(*), parameter :: IPCname = ".mailslotmymbx"
integer, parameter :: IPCsize = 128
character(IPCsize) IPCdata
integer(HANDLE) hMail
integer(DWORD) size

parent.f90

program parent
use dflib
include 'mbx.def'
hMail = CreateMailslot(IPCname,IPCsize,0,NULL)
call RUNQQ('child',' ')
if (ReadFile(hMail,LOC(IPCdata),IPCsize,LOC(size),NULL) /= 0) type *, IPCdata(:size)
end

child.f90

program child
include 'mbx.def'
hMail = CreateFile(IPCname,GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL,NULL)
call time(IPCdata)
call WriteFile(hMail,LOC(IPCdata),LEN_TRIM(IPCdata),LOC(size),NULL)
end

Save the three files and build the two programs as console apps, then run the parent program which will return a time string from the child.

James
0 Kudos
Steven_L_Intel1
Employee
1,953 Views
A tip. Don't add the .def file to the project's "Source Files", otherwise the linker will try to read it because .DEF is a kind of file the linker uses. If you just save the file in the same folder as the other sources, Developer Studio will find it. Or, rename the .def file to be .inc or .fi or something like that (and change the INCLUDE)

Steve
0 Kudos
oscarpiedrahita
Beginner
1,953 Views
Thank you James
Ohh! Is this the pipe?
As I understand it, the section defined as mbx.def is something like a module defining global variables for both programs, Parent and Child.
Parent Program creates a file with the parameters of this module and the Child program writes on it the information that it is wanted to be transferred. Then, the Parent program reads the file.
Then, it would be better to send the information about the common file directly in the parameter of the RunQQ and to make your own protocol, isn?t it?
As I understand it, the pipe then would be a shared file where you write the information you want to be transfered between the programs.
It seems good to me, although f90SQL considers it obsolete.Is there any other way?
OPiedra
0 Kudos
james1
Beginner
1,953 Views
This isn't a pipe but a mailslot. Take a look at http://msdn.microsoft.com/library/en-us/ipc/mailslot_7gj7.asp for more details.

The .DEF file in just included by both the parent and child program, just insert its contents into those two files and eliminate it if you like. As Steve points out, that file extension also has other meanings if used in Developer studio. However it is just code that in included for compilation.

There is no file involved, despite the name of the routine, rather a mailslot is an in memory structure that allows the one way communication from the slave to the parent that you were looking for.

James
0 Kudos
oscarpiedrahita
Beginner
1,953 Views
Hello James
This is exactly the information I needed.
I appreciate very much your kindness.
Best Regards
OPiedra
0 Kudos
Xj_Kong
Novice
1,953 Views

Is it secured to use mailslot? I mean if my data contains huge info, does it transfer safely?

Kong

 

0 Kudos
Reply