Run CL from command line?

271 views
Skip to first unread message

Ivo Pink

unread,
Nov 2, 2022, 11:35:01 AM11/2/22
to caesar-lisflood
Hi Tom,

Is there  a way to run CL from the command line (i.e. with the xml file as argument)? That would come in very handy for ensemble modelling. I'm aware (and a fan) of HAIL-Caesar but would prefer a windows-based solution at the moment. 

I haven't found this question answered elsewhere but apologies for cross posting if there is already an answer. 

Thanks and best wishes,
Ivo

tom.co...@gmail.com

unread,
Nov 3, 2022, 5:54:59 AM11/3/22
to caesar-...@googlegroups.com

Hi Ivo,

Yes –  CL can be run in batch mode – reading in the xml file from a small text batch file. There should be a thread/set of posts on this on the forum (have a search?) but in the source code – there is a chunk of commented out code that can be uncommented (and the corresponding code commented) that makes this happen. Sounds harder than it actually is – and when done it works really well. It runs the model (with the GUI) but all driven from a small text file – so you can set up a file to run 10-100 (etc..) model runs in sequence.

If theres nothing on the forum already for this then get back to me.

Tom

--
You received this message because you are subscribed to the Google Groups "caesar-lisflood" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caesar-lisflo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caesar-lisflood/21272348-d38c-421c-abef-6957ca1be124n%40googlegroups.com.

Ivo Pink

unread,
Nov 11, 2022, 7:27:11 AM11/11/22
to caesar-lisflood
Hi Tom,

Thanks for getting back so quickly! 

I'll have a search and give it a try. I'll get back to you if running into problems. 

Have a good weekend,
Ivo

Ivo Pink

unread,
Nov 18, 2022, 12:36:13 PM11/18/22
to caesar-...@googlegroups.com
Hi, just a follow up.

I've managed to create the command-promt executable. Like Tom wrote, it's basically just uncommenting some code and commenting the corresponding pieces. A couple of lines were outdated - those can just be replaced by the corresponding uncommented bits. Then it can be compiled using Visual Studio. I attach the updated CL script just in case somebody struggles with it and need a reference.

Thanks again Tom! 

You received this message because you are subscribed to a topic in the Google Groups "caesar-lisflood" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caesar-lisflood/-D69sXPGOQU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caesar-lisflo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caesar-lisflood/abc86625-e460-424b-b925-0bf2b1f9ccafn%40googlegroups.com.
Caesar Lisflood 1.9j_batch_update.cs

Tom Coulthard

unread,
Nov 18, 2022, 12:59:59 PM11/18/22
to caesar-...@googlegroups.com
👏👏
I’ve also been sent a version that works without the GUI from a command line - but I’ve not had time to compile it and try yet. 

I’ll keep you all posted. 

On 18 Nov 2022, at 17:36, Ivo Pink <ivop...@gmail.com> wrote:


Caesar Lisflood 1.9j_batch_update.cs

Benjamin Jackson

unread,
Dec 7, 2022, 5:40:15 AM12/7/22
to caesar-lisflood
Hi Ivo,

I appreciate you adding the file for others, very helpful. Maybe I'm being really dumb but I cannot work out how to compile this in Visual Studio. I assume it involves more than just running the code?

Ben

Ivo Pink

unread,
Dec 7, 2022, 7:10:38 AM12/7/22
to caesar-...@googlegroups.com
Hi Ben, 

Maybe there is some issue with the VS configuration. It didn't work for me on one PC and on another it did. I'll be back in Uni next Monday and then I can share the .exe. 

Best,
Ivo

tom.co...@gmail.com

unread,
Dec 7, 2022, 7:39:40 AM12/7/22
to caesar-...@googlegroups.com

Its usually making sure all the files are in the right place!

Benjamin Jackson

unread,
Dec 7, 2022, 9:06:49 AM12/7/22
to caesar-...@googlegroups.com
Thanks both. I managed to get it working in the end, it was mostly misunderstanding how VS works! For those that are also looking for a solution, I renamed the file Ivo attached to the original filename (Caesar Lisflood 1.9j.cs) then ran CAESAR-lisflood 1.9j.csproj in Visual studio. You then need to click the dropdown on the toolbar to change it from debug to release => click build on the toolbar => click build solution (or rebuild if that doesn't work).

tom.co...@gmail.com

unread,
Dec 7, 2022, 9:26:20 AM12/7/22
to caesar-...@googlegroups.com

You can also right click on cl1.9j.cs in visual studio – select exclude from project – then add your own code file…

Glad it worked!

Benjamin Jackson

unread,
Dec 21, 2022, 12:59:40 PM12/21/22
to caesar-lisflood
Thanks again both.

An issue I've found is that when I run it through the command line version, the program seems to be ignoring my spatial roughness file. In the xml file I have the SpatVarManningsCheckbox set to "true" and the spatvarmanningsfilename is set to a valid filename. If I use the same XML file on the GUI version then it works just fine. Any ideas?

I'm attaching the roughness and xml files in case that is useful.

Cheers,

Ben
rough20rough20.txt
Pre_Beaver_ISCA_Bud23.xml

Tom Coulthard

unread,
Dec 22, 2022, 3:16:09 AM12/22/22
to caesar-...@googlegroups.com
Without looking at the code I’ve a good idea. 

The code you uncommented to read from command line is a copy of the xml reading part of the program that is also in another function. The copy is from an earlier version where it didn’t have the spatial roughness. 

So find that bit of code (it’ll look just like the bits you’ve uncommented) in the rest of the code - then look for parts that are missing (usually at the end) and copy and paste into the command line code that you uncommented. 

It’s actually much easier than that sounds!

From: 'Benjamin Jackson' via caesar-lisflood <caesar-...@googlegroups.com>
Sent: Wednesday, December 21, 2022 5:59:40 PM
To: caesar-lisflood <caesar-...@googlegroups.com>

Benjamin Jackson

unread,
Dec 23, 2022, 8:54:55 AM12/23/22
to caesar-...@googlegroups.com
Thanks Tom I'll have a look and see if I can work it out.

Tom Coulthard

unread,
Dec 24, 2022, 4:54:33 AM12/24/22
to caesar-...@googlegroups.com
👍👍 have a good break. 

From: 'Benjamin Jackson' via caesar-lisflood <caesar-...@googlegroups.com>
Sent: Friday, December 23, 2022 1:54:42 PM
To: caesar-...@googlegroups.com <caesar-...@googlegroups.com>

Benjamin Jackson

unread,
Jan 13, 2023, 12:04:38 PM1/13/23
to caesar-lisflood
Hi Tom,

I added the following lines to the batch part of the script:

                        SpatVarManningsCheckbox.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("SpatVarManningsCheckbox"));
                       
                        textBox19.Text = xreader.ReadElementString("spatvarmanningsfilename");

But it appears to completely ignore these lines and continue without the spatially variable Mannings N file. Any ideas?

Ivo Pink

unread,
Jan 18, 2023, 1:26:10 PM1/18/23
to caesar-lisflood
Hi Ben,

you're right, the results of the GUI and batch versions didn't match because some addons were missing. I must have confused the output files when checking because I've just realised after running my models for a month =D. I copied the lines 13365-13418 to the lines 12482-12535 (everything after " // more add on's  21/5/2012" - the lines you added are part of it). It now gives me the same results then if I run in from the GUI. However, I haven't run it with the mannings n raster. But maybe worth a try. Files are attached (cant post .exe files unfortunately).

Caesar Lisflood 1.9j.cs

Tom Coulthard

unread,
Jan 18, 2023, 3:42:26 PM1/18/23
to caesar-...@googlegroups.com
Sorry for the discrepancies all - yes it’s likely there are changes in the config file set up. 

Whenever I add new features to CL I try and make the changes now at the END of the config file (even if logically they should be in a different section) so it’s backwards compatible (can read old config files without crashing) - but I’ve never bothered really updating the commented out batch file bit as it’s rarely called for. 

From: caesar-...@googlegroups.com <caesar-...@googlegroups.com> on behalf of Ivo Pink <ivop...@gmail.com>
Sent: Wednesday, January 18, 2023 6:26:10 PM

To: caesar-lisflood <caesar-...@googlegroups.com>
Subject: Re: Run CL from command line?
Hi Ben,

you're right, the results of the GUI and batch versions didn't match because some addons were missing. I must have confused the output files when checking because I've just realised after running my models for a month =D. I copied the lines 13365-13418 to the lines 12482-12535 (everything after " // more add on's  21/5/2012" - the lines you added are part of it). It now gives me the same results then if I run in from the GUI. However, I haven't run it with the mannings n raster. But maybe worth a try. Files are attached (cant post .exe files unfortunately).

--
You received this message because you are subscribed to the Google Groups "caesar-lisflood" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caesar-lisflo...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages