batch file to run SWAT from outside of TxtInOut directory

525 views
Skip to first unread message

JJ

unread,
Jul 9, 2011, 2:15:32 PM7/9/11
to SWAT-user
Hello,

I hope someone can help me overcome this obstacle, which I hope is the
last one before I can finally run DREAM with parallel processing
(instead of using only one processor) for uncertainty analsyis of
SWAT, which I would happily share once I get it running right.

Here's the obstacle: I have written a batch file to run swat2009
(revision 477). It works fine when I place it along with swat2009.exe
inside the TxtInOut directory (actually renamed LW3s1_performance),
but when I place the batch file one level higher, and with
swat2009.exe still inside the TxtInOut directory, and click on it at
this higher level, swat2009.exe only runs a fraction of a second
before the screen disappears. The execution is obviously unsuccessful
though the quickness of the flash leaves me no time to read any
message.

Here's what the batch file looks like, with the full path so that it
shouldn't matter whether I place it inside of or one level higher than
the TxtInOut directory.

start c:/Users/John/Documents/LW3s1_performance/swat2009.exe

where LW3s1_performance is the TxtInOut directory. If I create
another batch file to run a similar executable file, SWAT_Edit.exe
(which is from SWAT-CUP2), so that it reads

start c:/Users/John/Documents/LW3s1_performance/SWAT_Edit.exe

the program SWAT_Edit.exe runs fine, regardless of whether I place
this batch file within the TxtInOut directory and click on it there,
or one level higher and click on it at this higher level.

Using slight variations for swat2009.exe such as

start w/ c:/Users/John/Documents/LW3s1_performance/swat2009.exe
or
start w/ c:/Users/John/Documents/LW3s1_performance/swat2009.exe
or
start w/ LW3s1_performance/swat2009.exe

makes no difference.

I wish I could just run the batch from within the TxtInOut directory,
but I don't think this is an option for what I want to achieve. The
batch file must be outside the TxtInOut directory.

Although I don't see how to record any error message, executing
swat2009.exe from R does allow me to see some kind of message, which
might be similar to what would be displayed from the batch file, if
only it wouldn't flash by so quickly:

("c:/Users/John/Documents/LW3s1_performance/swat2009.exe")
SWAT2009
Rev. 477
Soil & Water Assessment Tool
PC Version
Program reading from file.cio . . . executing


forrtl: severe (24): end-of-file during read, unit 23, file C:\Users
\John\Documents\file.cio

Image PC Routine Line
Source
swat2009.exe 0071A0C9 Unknown Unknown Unknown
Warning message:
running command 'c:/Users/John/Documents/LW3s1_performance/
swat2009.exe' had status 24

And, again, if I reset the directory in R to be within
LW3s1_performance, swat2009.exe works fine. But SWAT_Edit.exe and
other executables work fine in R regardless of the directory setting.

I have also tried swat2009 revision 436 and found the same obstacle.

Any ideas? Your help would be much appreciated.

John Joseph

Felix W.

unread,
Jul 11, 2011, 5:13:19 AM7/11/11
to SWAT-user
Hello JJ,

to see your failure message -did you try to start the swat2009.exe (or
your batch file) out of a Dos window (cmd)?! The window should stay
opened doing so..
I once also tryed to run multiple calibration procedures at the same
time.. I stopped working on that as the Swat-Editor does not really
want to be opened multiple times on one single operating system.. Now,
when I want to save time I start multiple operating systems in a
VirtualBox..
By the way -Karim Abbaspour announced Swat-Cup 4 at the Swat
conference in Toledo, which will support parallel processing. So maybe
you could just wait until it is published or ask him for a beta-
version..

cheers,
Felix

JJ

unread,
Jul 11, 2011, 10:58:33 AM7/11/11
to SWAT-user
Thanks, Felix.

I got some detailed help from Chris George regarding the batch file,
and, based on
his input I was able to get the attached file to work. The script
also ensures that the screen
won't simply disappear without giving a chance to read any error
messages:


@echo off

cd C:/Users/John/Documents/LW3s1_performance

C:/Users/John/Documents/LW3s1_performance/swat2009JJ.exe

if %errorlevel% == 0 exit 0

echo.
set /p x="SWAT run failed. Hit Enter to exit"
exit 1

I'm glad SWAT-CUP4 will have more parallelizing. In the past, I've
enjoyed using SWAT-CUP. But, now, I want to do this in R for a few
reasons, and it has to be an MCMC algorithm like DREAM or DREAM-ZS or
something very similar.

I'll let the group know when I get the whole thing to work.

Thanks.

John Joseph
> > John Joseph- Hide quoted text -
>
> - Show quoted text -

Janne Helin

unread,
Mar 26, 2015, 11:53:37 AM3/26/15
to swat...@googlegroups.com
Some  years later.... did that connection with R, ever work?

-Janne

Willem Vervoort

unread,
Mar 26, 2015, 6:06:26 PM3/26/15
to Janne Helin, SWAT-user

--
You received this message because you are subscribed to the Google Groups "SWAT-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swatuser+u...@googlegroups.com.
To post to this group, send email to swat...@googlegroups.com.
Visit this group at http://groups.google.com/group/swatuser.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages