Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Compiling MUMPS with GFortran on Windows? #7

Closed
chrisdembia opened this issue Aug 19, 2017 · 20 comments
Closed

Compiling MUMPS with GFortran on Windows? #7

chrisdembia opened this issue Aug 19, 2017 · 20 comments

Comments

@chrisdembia
Copy link

I apologize for creating an issue on GitHub for this, but I simply have a question. I see that you have done a very nice job with a build script for Ipopt on WIndows that builds MUMPS as well using Intel's Fortran compiler.

I was wondering if you had tried compiling MUMPS with GFortran and Ipopt with MSVC? I would like to do this so that I can compile and use Ipopt with free compilers. This would be nice so that I could use AppVeyor to build Ipopt and MUMPS in an automated way. Would this be possible?

I appreciate that your project makes Ipopt binaries for Windows available (here). I would like to do the same for my project.

Thank you.

@chrisdembia
Copy link
Author

I now see that your team has discussed this in various places, including here: microsoft/vcpkg#233

@traversaro
Copy link

Hi @chrisdembia , thanks for getting in contact!

As you may have found out in microsoft/vcpkg#233 (comment) the IPOPT binaries that you find in http://www.icub.org/download/3rd-party/ are actually compiled with the Intel Fortran compiler, that has native compatibility with MSVC. They are relatively self-contained, so if it is feasible for you to just include them in your installer I think you can just do that. We have script used to build it on a local machine, as soon as I am back in IIT I can send it to you.

I briefly tried to compile fortran libraries with GFortran for adding support for them in vcpkg but I abandoned that attempt because gfortran does not support linking against the latest MSVC CRT library, something that vcpkg enforces. However, for a library linking a different CRT library from the rest of the linked libraries and binaries is ok as long as no file handles (or similar objects managed by the CRT) are passed along the library interface, and I hope this is the case with MUMPS. You can find a report of my attempt in microsoft/vcpkg#23 (comment) , and actually I think that with this commit microsoft/vcpkg@e604d4e the vcpkg fork with fortran support proposed in microsoft/vcpkg#1098 is able to compile MUMPS with gfortran.

@albertziegenhagel
Copy link

@traversaro First of all thank's for trying the fortran support and I am glad that it works for you!

About the gfortran support. Theoretically microsoft/vcpkg@e604d4e enables MinGW support for vcpkg, but building MUMPS with it is blocked by multiple issues. First of all CMake does not yet support GNUtoMS for the Ninja generator. I've submitted a merge request for that at https://gitlab.kitware.com/cmake/cmake/merge_requests/1165. But this would not be a blocker since one could switch to MinGW Makefiles if GNU is selected.
The other issue is that gfortran and MSMPI are not compatible. There is a workaround described at dev-cafe/autocmake#85 but I was not yet able to implement it for vcpkg. I don't know when I will find time to dig deeper into that.

@traversaro
Copy link

Thanks for the relevant comment @albertziegenhagel and also for your precious work on Fortan support in vcpkg.

@chrisdembia
Copy link
Author

We have script used to build it on a local machine, as soon as I am back in IIT I can send it to you.

I would appreciate if you could send that to me; thank you (my email address is on my GitHub profile page).

I look forward to being able to get IPOPT via vcpkg.

@chrisdembia
Copy link
Author

Thank you both for the quick responses and the awesome contributions to the larger community.

@albertziegenhagel
Copy link

Some status update: The required changes to CMake have been merged to the latest master and I have pushed a few changes to my branch that made me successfully build MUMPS with gfortran on windows. I have not yet tested whether this version works correctly.

@chrisdembia
Copy link
Author

@albertziegenhagel thanks for the update. I do not need MSMPI. Does that mean that once there is a MUMPS port for vcpkg, I'll be able to install MUMPS via vcpkg so long as I am using the latest master of CMake?

@albertziegenhagel
Copy link

@chrisdembia Yes, that is true, even with MSMPI. The MUMPS port I wrote is not capable of being build without MPI support yet, though this shouldn't be very difficult to add.

But please note that I don't know when/if the fortran support will be merged into vcpkg and that using gfortran may come with a few issues due to the CRT mismatch. I would still suggest to use Intel Fortran if available or PGI Fortran if a free alternative is required.

@chrisdembia
Copy link
Author

@albertziegenhagel do you have any scripts or instructions to build MUMPS with PGI Fortran?

@albertziegenhagel
Copy link

albertziegenhagel commented Oct 1, 2018

@chrisdembia If you want to use vcpkg you can use my branch at https://github.com/albertziegenhagel/vcpkg/tree/fortran-ports to build MUMPS. The instructions should be as simple the follwing:

  • clone my fork of the repository and switch to the branch fortran-ports.
  • follow the vcpkg documentation to bootstrap vcpkg.
  • add the line set(VCPKG_FORTRAN_COMPILER PGI) to the file <vcpkg_root>\triplets\x64-windows.cmake.
  • call vcpkg install mumps:x64-windows.

NOTE 1: This is all experimental, so you will might encounter some issues. If there a problems, let me know and I will try to help.

NOTE 2: vcpkg will try to find the PGI Fortran compiler automatically, and I am not sure whether this will work under all circumstances. PGI in general is not my main compiler, so I do not test this often. If you just do need MUMPS and do not care about the Fortran compiler used to compile it, I would suggest to set VCPKG_FORTRAN_COMPILER to Flang. This will automatically download a windows fork of flang to compile the code with it.

NOTE 3 I update my fork with changes from upstream vcpkg only very occasionally, so you may not get all the newest versions of the other ports.

NOTE 4 To build MUMPS on windows, I am using a very simple, handwritten CMake build system. The CMakeLists file can be found here: https://github.com/albertziegenhagel/vcpkg/blob/fortran-ports/ports/mumps/CMakeLists.txt

@chrisdembia
Copy link
Author

Thanks @albertziegenhagel . I will try these instructions.

However, I'd like to build MUMPS without vcpkg, so I may try to go straight from your MUMPS CMake build system, but in this case I do not know how to tell CMake to use PGI. Any suggestions?

@albertziegenhagel
Copy link

If the compiler is in your PATH (which should be the case if you are within the PGI command prompt, or have loaded the environment via the pgi_env.bat file), I think CMake should detect it automatically. Else you can always pass the compiler to cmake via CMAKE_Fortran_COMPILER.

@chrisdembia
Copy link
Author

@albertziegenhagel your branch worked! I was able to build MUMPS very easily. I will now try integrating these MUMPS binaries with Ipopt. Please let me know if you have suggestions for this process.

cc @traversaro

@traversaro
Copy link

Great @chrisdembia, and thanks a lot @albertziegenhagel for his hard work !

Depending on the version of MUMPS and/or IPOPT (in particular with IPOPT < 3.12.11 with MUMPS >= 5.1.0), you may be affected by this: robotology/idyntree#456 .

@chrisdembia
Copy link
Author

Thanks @traversaro

@chrisdembia
Copy link
Author

@traversaro you mentioned you had build scripts for Ipopt on Windows. Do you still have those and if so would you be willing to share them?

Thank you.

@traversaro
Copy link

Sorry @chrisdembia, I probably missed your reply, I need to ask to the person that is handling this.

@chrisdembia
Copy link
Author

Thanks. I now have the ability to build IPOPT using clang-cl with a toolchain from conda. https://github.com/chrisdembia/coin/tree/ipopt_external_mumps

@traversaro
Copy link

Given that @chrisdembia solved his original problem, I think we can close this issue. Thanks for the useful inputs @chrisdembia @albertziegenhagel !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@chrisdembia @traversaro @albertziegenhagel and others