Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting .exe in more then one console at same time

Status
Not open for further replies.

hi5er

Programmer
Mar 15, 2012
3
DE
Hi there,

at work i use the radiative transfer model MODTRAN which is an .exe and i start it from my Fortran programs using something like:

Resrun = Systemqq(modtran.exe < inputfile)

Is there any way to start several runs parallel?
perhaps by using OpenMP?

I can do this manually by opening more then one console and typing
modtran.exe < inputfile in each console (of course with different working directories so I do not overwrite any output).

Thanks for any help!
 
To my knowledge you can do this with the Compac compiler only if you create a Windows application and use

irslt = CreateProcess (...)

which does start a new process but does not wait with further execution of your prog till the process has finished.

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Thank you Norbert,

I have found a functioning Subroutine on the Internet which calls CreateProcess and it works when just passing on a program name like
'*.exe'.

However it does not do anything when the string containing the programname also includes an Inputfile (like '*.exe < inputfile')

Is there anything special I have to be aware of in this context?
 
No, that is not what I meant.

The function CreateProcess, that I was referring to, is part of the Windows Win32API. If you are working in a windows environment it apparently works even if your program is a console application - not a windows application. Here is the code I tested
Code:
	program testrun
	
	use dfwin

	implicit none

	character*100 cName
	integer irslt
	logical lrslt
	type (T_PROCESS_INFORMATION) tPI			! data to start external thread	(jpg to bitmap conversion)
	type (T_STARTUPINFO) tSI					! data to start external thread	(jpg to bitmap conversion)

	cName = 'test3d.exe'

	write (*,*) 'Hello'

	tSi.dwFlags = STARTF_USESHOWWINDOW
	tSi.wShowWindow = SW_SHOWMINIMIZED
	lrslt = CreateProcess (cName, NULL, NULL, NULL, .false., CREATE_NEW_CONSOLE, NULL, NULL, tSi, tPi)
	irslt = GetLastError()
	continue
	call sleep (10000)

	stop
	end

test3d.exe is a console application which this proggy started parallel to its own console. You should look up the documentation on win32API for details of this function. This documentation should be included in your compiler package (at least it was in mine). You are using the Compaq compiler - or one of its younger derivatives from Hewlett Pacjard or whoever sells it right now, don't you ?

Norbert



The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Try:
Code:
START "modtran.exe < inputfile"

It works in XP and opens a new cmd window by default (see options "START /?" under the dos prompt)

So in gfortran that would be

Code:
CALL SYSTEM('START "./DIRONE/modtran.exe < inputfile1"')
CALL SYSTEM('START "./DIRTWO/modtran.exe < inputfile2"')
CALL SYSTEM('START "./DIRTHR/modtran.exe < inputfile3"')

Should launch modtran three times.
 
@Norbert
sry I wasn´t clear in my previous message.
The Subroutine I mentioned which I found on the Internet does use the Win32 API Function CreateProcess.

I think it certainly will do what I want it to once I have figured out all the parameters.

I have solved the problem with it just starting the .exe but not using the Inputfile by creating a batchfile and then starting this with CreateProcess.

(I use Intel Visual Fortran XE 2011 with VS2008)


@GerritGroot
I`ll give this a try to.
The started program should give back a message once it has completed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top