Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design of library_interface.F90 #455

Open
LecrisUT opened this issue Aug 29, 2023 · 2 comments
Open

Design of library_interface.F90 #455

LecrisUT opened this issue Aug 29, 2023 · 2 comments
Assignees
Milestone

Comments

@LecrisUT
Copy link
Contributor

I would like to suggest that module/submodule interface should be used for the api library. Having functions like get_fortran_stderr is not helpful for the user, and it otherwise complicates the navigation of the interface to find the relevant interface the user would need. Splitting these and making them private to the submodule would simplify the interface.

To properly test if the import works, #444 would be helpful, since that would give a clean environment as if the package was installed on the system. I have implemented something similar in spglib and that could be adapted here as well.

Also, is there a reason for keeping the functions like set_u_matrix as global functions instead of class methods?

@JeromeCCP9
Copy link
Collaborator

Hi Cristian!

These are design questions, yes.

The rationale behind get_fortran_stderr is for use by python, where it is necessary to have a public function (of course this function is not needed from fortran).

Concerning the encapsulation, this design choice was part of our remit when we were given the library task: that the interface should consist of simple global functions. Whether this is best is a tricky discussion, but we feel that the simple function interface also makes calling the library from other languages much easier.

We touched on this with the other developers and our design was essentially accepted, but ultimately it is a community decision & others may wish to comment.

Does this more or less answer your question?

Jerome, Barry

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Oct 2, 2023

The rationale behind get_fortran_stderr is for use by python, where it is necessary to have a public function (of course this function is not needed from fortran).

I am not sure I am getting this. Python also has access to stderr, and since this is just an integer, it doesn't make a difference if it is specified by python or fortran. If it was lib_common_type%err_log that would make more sense, because that would indicate where all error logs would need to go.

Whether this is best is a tricky discussion, but we feel that the simple function interface also makes calling the library from other languages much easier.

You can have both of course. A cleaner object oriented interface for use across fortran projects, and global function interface for linking to other languages. This is a common C++/C design. Also in order to make calling the language across languages, it should also have bind(C) and equivalents.

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

No branches or pull requests

3 participants