High resolution/Large DEMs in CAESAR-Lisflood

200 views
Skip to first unread message

Declan

unread,
Jun 2, 2016, 2:56:39 PM6/2/16
to caesar-lisflood
I thought I would share this for anyone who wants to use large DEMs with CAESAR-Lisflood. (Warning: you have to edit the C# project files in the source code folder with Visual Studio and re-build).

There is an arbitrary limit on the maximum array size in C# programs of 2GB: http://stackoverflow.com/questions/2338778/what-is-the-maximum-length-of-an-array-in-net-on-64-bit-windows
So if you are using DEMs with millions of grid cells, this will likely cause the error message: "Array size exceeded supported dimensions", when you try to load your data in CL.

You can get around this by opening up the latest source code C# project file and adding an "Application Config File" to the project. Paste in the following config information to this new file between the <configuration> tags it creates for you:

 <runtime>
    <gcAllowVeryLargeObjects enabled="true"/>
 </runtime>

Make sure you have it set to .NET version 4.5 or higher in the project properties. (Already done if using CL v1.9b.) Then rebuild the project. You get the CAESAR .exe file, as well as some additional config files. These have to be present with your new .exe when you run the modified version.

You should now be able to load large or high resolution DEMs into CAESAR-LF without the array exceeds max dimensions error. Obviously, it depends on having enough memory on your computer as well. You also need to be running a 64-bit version of Windows.

More info on the application config files:

https://msdn.microsoft.com/en-us/library/ms184658.aspx
https://msdn.microsoft.com/en-us/library/hh285054%28v=vs.110%29.aspx

Been testing this with a DEM with around 18 million grid cells, and although running slowly, it appears stable.

Hope this is of use to some,
Cheers,

Tom Coulthard

unread,
Jun 5, 2016, 8:59:32 AM6/5/16
to caesar-...@googlegroups.com

Hi Declan – that’s brilliant – I’ve never managed to get up to the limit on any of our machines! But its obviously something that can happen!

You mentioned it generates (and needs?) extra files to run with the .exe? I take it this means its not straight forward to add to the general release? – or is this something that’s really required or not?

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.
For more options, visit https://groups.google.com/d/optout.

Declan Valters

unread,
Jun 5, 2016, 11:12:57 AM6/5/16
to caesar-...@googlegroups.com
Hi Tom,

Actually the large array support is just a run-time setting - I just noticed in the v1.9b source files there is already a "CAESAR-lisflood 1.9b.exe.config" file anyway - you would just paste in the three lines mentioned above into this .config file and don't need to re-compile/re-build anything. To enable the large array support you need to have the "xxxx.config" file present with the .exe file though - if it is missing it will run, but just use the .NET defaults, which in this case is not to allow large objects (arrays) > 2Gb. It seems like this is the only file you need though.

You could either include this .config file with future releases, or there is potentially a way to embed the setting into the .exe file, but again I haven't tested it: http://stackoverflow.com/questions/1846975/how-do-you-embed-app-config-in-c-sharp-projects


Declan

Reply all
Reply to author
Forward
0 new messages