m3g / packmol

Packmol - Initial configurations for molecular dynamics simulations
http://m3g.github.io/packmol
MIT License
222 stars 51 forks source link

Fortran-Package-Manager compatiblity #41

Closed fedebenelli closed 1 year ago

fedebenelli commented 1 year ago

Hello!

I've restructured the structure (it's a minimal change) to add compatibility with the Fortran-Package-Manager (fpm: https://fpm.fortran-lang.org/en/index.html)

With the package manager installed in the system, an user can now install packmol with just

fpm install --profile release

And this will automatically check dependencies order, compile and move the executable into ~/.local/bin, to make it accessible everywhere.

Optionally one could run:

fpm build

Compilers flag can be set with:

fpm build --flags "--flags-here"

And this will do the same thing, but move the executable (and compiled objects) into a build folder.

I thought in adding this build instructions into the README but all the build instructions are on the website so I'm not sure if that would be correct.

All the metadata (authors, license, maintainer, etc) is set on the fpm.toml file, I've left those fields empty since I wasn't sure what to put there.

I've tested against the original executable with the water example in the repo and I got the same results :)

Only bad side-effect: I had to delete the "data_types.f90" file since it can be compiled, but I didn't saw anywhere that it's contents were used.

lmiq commented 1 year ago

Thanks, that is a nice contribution indeed.

I will probably take some time to merge it, because of the time of the year... and that changes a lot the directory structure so I have to check if nothing is breaking in the site, instructions, user guide, release scripts, etc. I won't be able to do that with the proper care before January.

One doubt: is it standard for fpm that one app directory contains a "special" source file with the main program? (seems strange that all other source files are in the src folder, except one).

fedebenelli commented 1 year ago

Yes, totally understandable for this time of the year. I'm glad you find the contribution useful!

With respect with the structure, yes, it's standard for fpm to have the main program on the app folder, because you could even have multiple main programs that you want to compile individually to single executables, but both share the same library modules (everything inside src).

If you look into the fpm.toml file you can see

[[executable]]
name = "packmol"
source-dir = "app"
main = "packmol.f90"

This could be repeated for each desired executable (I don't think that's packmol case)

fpm also provides the fpm test and fpm run --example commands, those will compile and run any main programs that are included in separate test and example folders.

Another nice feature of fpm (also not necessary for packmol I think) is the possibility of adding external dependencies that can be fetched and cached at compile time, by adding them into the fpm.toml file.

lmiq commented 1 year ago

I've merged to the "FPM" branch, where I will work on the scripts that I need to update, before merging to main.