CH-Earth / summa

Structure for Unifying Multiple Modeling Alternatives:
http://www.ral.ucar.edu/projects/summa
GNU General Public License v3.0
80 stars 106 forks source link

Add CMake Functionality to Summa #569

Closed KyleKlenk closed 5 months ago

KyleKlenk commented 5 months ago

I have added the ability use CMake to compile SUMMA.

I have used two CMakeLists.txt files to achieve this as it helps with Summa-Actors, and follows what the sundials work is using.

The top level file in build/ has the configuration and compilation steps. The lower level CMakeLists.txt file inside build/source, just has the files that are required for compilation. This allows Summa-Actors to just import this lower level CMakeLists.txt file instead of having to keep track of the files manually.

The way I have set this up is that inside build/ is a cmake directory. In this directory are a couple helper files for helping CMake find NetCDF and OpenBLAS. LAPACK is the first library that is tried, and if it cannot be found openBLAS is used as a fallback. I can change this if one is preferred over the other. In addition to the Find files, is a script that can be used to compile Summa in one step compile_script.sh. This will configure and build Summa in parallel, all build files will be stored in cmake_build which is created by cmake. This cmake_build directory has also been added to the .gitignore file so no build files are commited.

Lastly, I updated the documentation files, Installation.md specifically to include instructions for using camke

wknoben commented 5 months ago

Looks good to me, thanks!

Just to be 100% clear for current users, this does not replace the traditional makefiles, nor does it interfere with how they work. This just adds the capability to build using cmake instead, which should be much easier for most users. @KyleKlenk Can you confirm this?

KyleKlenk commented 5 months ago

This does not replace the Makefile. I left the original Makefile untouched and users can use it as they normally would.

wknoben commented 5 months ago

That's what I thought, thanks for confirming. Looks good to me.

wknoben commented 5 months ago

@andywood @martynpclark It's not very conventional but I think merging this straight into master makes sense. It might make life easier for current/new users and doesn't affect science results. Let me know if you disagree.

andywood commented 5 months ago

Hi Wouter -- seems reasonable especially if you expect a pressing demand for this feature. It can be propagated into develop as well. Btw, there was a comment earlier about cmake being 'easier' than a regular Makefile, which I wondered about. I use both and don't find one notably easier than another. CMake adds a layer of abstraction. For the vanilla summa-on-local-linux use case, neither are difficult and they both work. Cheers, Andy

On Mon, Jun 24, 2024 at 4:24 PM Wouter Knoben @.***> wrote:

@andywood https://github.com/andywood @martynpclark https://github.com/martynpclark It's not very conventional but I think merging this straight into master makes sense. It might make life easier for current/new users and doesn't affect science results. Let me know if you disagree.

— Reply to this email directly, view it on GitHub https://github.com/CH-Earth/summa/pull/569#issuecomment-2187511815, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIKARPS7L23GZ23Y7N4YQ3ZJCMALAVCNFSM6AAAAABJSZKWL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBXGUYTCOBRGU . You are receiving this because you were mentioned.Message ID: @.***>

wknoben commented 5 months ago

Hi Andy, thanks for letting me know. It seems to me that Kyle build in a bunch of features to help locating library paths etc. In my (admittedly somewhat limited) experience it's these kind of things that are easy once you know what you're doing but can be hard to grasp if you're new to compiling code.

Given that both approaches can exist side-by-side, I think we should just give it a go and readjust if we get negative feedback for some reason.

andywood commented 5 months ago

Absolutely!

On Tue, Jun 25, 2024 at 11:15 AM Wouter Knoben @.***> wrote:

Hi Andy, thanks for letting me know. It seems to me that Kyle build in a bunch of features to help locating library paths etc. In my (admittedly somewhat limited) experience it's these kind of things that are easy once you know what you're doing but can be hard to grasp if you're new to compiling code.

Given that both approaches can exist side-by-side, I think we should just give it a go and readjust if we get negative feedback for some reason.

— Reply to this email directly, view it on GitHub https://github.com/CH-Earth/summa/pull/569#issuecomment-2189514310, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIKARLBDJBQ5EMF7BRS4ADZJGQTXAVCNFSM6AAAAABJSZKWL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBZGUYTIMZRGA . You are receiving this because you were mentioned.Message ID: @.***>