ec-jrc / lisflood-code

Lisflood OS - LISFLOOD
https://ec-jrc.github.io/lisflood
European Union Public License 1.2
122 stars 50 forks source link

Compiling the cython module kinematic_wave_parallel_tool #16

Closed agahirpa closed 4 years ago

agahirpa commented 5 years ago

When I try to run the following command: python compile_kinematic_wave_parallel_tools.py build_ext --inplace

I get the following error: running build_extkinematic_wave_parallel_tools.py build_ext --inplace building 'kinematic_wave_parallel_tools' extension error: Unable to find vcvarsall.bat

How can I get by this? Also, can this version of lisflood run on python 3.x?

domeniconappo commented 5 years ago

@agahirpa

Thanks for trying it out. Lisflood is not python3 ready yet. We've just ported Lisvap to python3 while lisflood will probably be ported to python3 before this summer.

@emiliano-gelati Do you know what it's needed to compile kinematic wave tools in a Windows environment? Thanks!

agahirpa commented 5 years ago

@domeniconappo Thank you. my windows pc has python3. probably that is why the compiling fails then?

emiliano-gelati commented 5 years ago

Hi @agahirpa, @domeniconappo,

To compile the Cython module with OpenMP (to run the routing in parallel), we used to use TDM-GCC on 64 bit and MinGW on 32 bit. Check these instructions: https://docs-windows.readthedocs.io/en/latest/devel.html#compilers

However, I am not sure if the above still works.

domeniconappo commented 5 years ago

@agahirpa Lisflood cannot run with Python 3, that's sure. Compilation errors are due to a missing C compiler on your system, which is another thing.

Could you follow instructions suggested by emiliano and let us know? That can help us to write some tips for windows users. Thanks!

agahirpa commented 5 years ago

Thank you both @domeniconappo @emiliano-gelati for the help. I tried to run with @emiliano-gelati 's suggestion, and get the following error.

ImportError: Building module lisflood.hydrological_modules.kinematic_wave_parallel_tools failed: ["distutils.errors.CompileError: command 'C:\\TDM-GCC-64\\bin\\gcc.exe' failed with exit status 1\n"]

emiliano-gelati commented 5 years ago

Hi @agahirpa, @domeniconappo

Is it the full error message? Otherwise, could you copy/paste it here?

If yo have the "mingw32" compiler installed, you may also try: python2 compile_kinematic_wave_parallel_tools.py build_ext --inplace --compiler=mingw32 -D MS_WIN64

ltrotter commented 5 years ago

Hi @emiliano-gelati and @domeniconappo,

after several attempts at getting lisflood to run on windows, I have managed to run the compile_kinematic_wave_parallel_tools.py, albeit on a unix environment using MobaXterm. This seem to have worked fine and created two new files in the hydrological_modules folder:

  1. kinematic_wave_parallel_tools.dll, and
  2. kinematic_wave_parallel_tools.html

however, when I try to actually run the actual model on the sample data python2 src/lisf1.py tests/data/Drina/settings/lisfloodSettings_cold_day_base.xml I get the warning and the error below in the file: error_message.txt It seems to me that despite saying that it will run the wave routing serially, it actually tries to build the parallel module, failing and returning an error.

Note that I have run the lisf1.py script not from MobaXterm, but from my windows python installation, which is why it runs into an error compiling the module. At the moment I can't get MobaXterm to install numpy properly, for whatever reason :/

Any idea why it doesn't recognise the .dll file and it tries to build the parallel module?

domeniconappo commented 5 years ago

Any idea why it doesn't recognise the .dll file and it tries to build the parallel module?

@ltrotter probably it happens because code checks for the pyd file while you got a dll. Also, I think that it tries to build it in any case...I see there is no way to use that module without compiling it.

emiliano-gelati commented 5 years ago

Hi @ltrotter ,

You might try to replace the line BIN = ROOT + (".pyd" if WINDOWS_OS else ".so") with BIN = ROOT + (".dll" if WINDOWS_OS else ".so") at https://github.com/ec-jrc/lisflood-code/blob/master/src/lisflood/hydrological_modules/kinematic_wave_parallel.py#L45 (so the code would look for a ".dll" file instead of a ".pyd")

In any case, be aware that compiling the Cython module under Windows (for both parallel and serial execution) has always been very challenging and not always successful.

salampe commented 5 years ago

@ltrotter, @emiliano-gelati and @domeniconappo ,

Can this issue be closed?