DSSAT Archives

DSSAT - Crop Models and Applications

DSSAT@LISTSERV.UGA.EDU

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Wilkens, Paul W. <[log in to unmask]>" <[log in to unmask]>
Reply To:
DSSAT - Crop Models and Applications <[log in to unmask]>
Date:
Mon, 4 Jun 2001 11:09:52 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (94 lines)
Andre,

If you are trying to wait until CERES is done before spawning a new copy of
GECER980, a method might be to use a Win API call to WaitForSingleObject.
An example (in Delphi, not VB, sorry) might work something like this.  The
VB method would be similar.

function AndreRunCERESAndWaitTillItIsDone (const FileName: string): DWORD;
var
  StartupInfo : TStartupInfo;
  ProcessInfo : TProcessInformation;
begin
  Result := STILL_ACTIVE;
  GetStartupInfo (StartupInfo);
  if CreateProcess
(nil,PCHar(FileName),nil,nil,IsConsole,NORMAL_PRIORITY_CLASS,nil,nil,Startup
Info, ProcessInfo) then
    try
      WaitForSingleObject (ProcessInfo.hProcess, INFINITE) = WAIT_OBJECT_0
    then
      GetExitCodeProcess (ProcessInfo.hProcess, Result);
  finally
    CloseHandle (ProcessInfo.hThread);
    CloseHandle (ProcessInfo.hProcess);
  end;
end;

CreatProcess creates a new process and its primary thread. The new process
executes the specified executable file.

The WaitForSingleObject function checks the current state of the specified
object. If the object's state is nonsignaled, the calling thread enters an
efficient wait state. The thread consumes very little processor time while
waiting for the object state to become signaled or the time-out interval to
elapse.

Consult the Windows SDK with VB for details on each function call.  There
are (I'm sure) many other ways to do this.

Cheers,

PW

Paul Wilkens
International Fertilizer Development Center
P.O. Box 2040
Muscle Shoals, Alabama  35662

(256) 381-6600 (Tel)
(256) 381-7408 (Fax)

[log in to unmask]
http://www.ifdc.org/




-----Original Message-----
From: Andre du Toit [mailto:[log in to unmask]]
Sent: Monday, June 04, 2001 1:06 AM
To: [log in to unmask]
Subject: VB and CERES-Maize


We need to run about 13000 CERES-Maize runs for a project. A
VB  interface was written to generate an IBSNAT35.INP file from
the Access file and then running then a pif file (using the shell
command)  with  the following command line "GECER980.EXE
IBSNAT35.INP I S 1". The problem  is that VB program sending out
the next INP file or reading the Summary.out before CERES-Maize
have completed the run. We were able to slow down the VB
program by including a loop counter.  At this stage it  take up to 7
hours to complete all the runs (1.9 seconds per run).

Any suggestions how we could tell the VB program that CERES-
Maize is still busy.

Regards
Andre




**************************************
* ANDRE DU TOIT                      *
* AGRICULTURAL RESEARCH COUNCIL      *
* SUMMER GRAIN CENTRE                *
* PRIVATE BAG X1251                  *
* POTCHEFSTROOM 2520                 *
* TEL: (018) 2996249                *
* FAX: (018) 2947146                *
* INTERNET: [log in to unmask]      *
**************************************

ATOM RSS1 RSS2