Skip to content

fpm assumes .mod has the same name as the source file #57

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

Closed
milancurcic opened this issue Apr 26, 2020 · 7 comments
Closed

fpm assumes .mod has the same name as the source file #57

milancurcic opened this issue Apr 26, 2020 · 7 comments

Comments

@milancurcic
Copy link
Member

If I have a source file datetime.f90 that contains a module called datetime_module, then gfortran (and all other compilers I believe) output datetime_module.mod. However, fpm expects datetime.mod and can't find it.

I believe the assumption about .mod filename comes from somewhere around here, however I don't have a solution right now.

I think the safe assumption is that the .mod file will have the module name, for fpm will need to scan the source file to get this info.

Further, a source file can have multiple modules defined, and for each the compiler will emit one .mod file.

@everythingfunctional
Copy link
Member

That assumption actually comes from here.

The reasoning is that we want the file name to match the module name, and the module name to include the path components of the file name. This was a basic structure to help with organizing modules that @certik and I came up with.

There are ways to just inspect the source files and figure out the module names and dependencies more flexibly, but for our initial implementation we wanted to keep things as simple as possible and try and encourage a common organizational convention.

Obviously this is something that should be added to the README. @certik , do you think you'll have time to write up our standard conventions in the README any time soon?

@milancurcic
Copy link
Member Author

Specifically for datetime-fortran, that's fine. I'm happy to rename the source file so it can build with fpm.

I also support encouraging the practice one module per source file, with file name matching the module.

However, I think this may be quite limiting if fpm is to build existing packages. I don't know, but it's possible that there are many that have multiple modules per source file.

This made me think now: why would there be an expectation for a specific .mod file to be present? AFAIK, the compiler cares only about the include path and that the modules are there. It knows how to find the file in the include directory. So, this requirement by fpm seems artificial to me. Could it be removed so that fpm only checks for .o files? I think it's safe to assume that if .o file is created, that the .mod files have been created as well.

@milancurcic
Copy link
Member Author

However, I think this may be quite limiting if fpm is to build existing packages. I don't know, but it's possible that there are many that have multiple modules per source file.

Related to this, I think more problematic is that this requirement would prevent fpm from building correct and modern Fortran code.

@everythingfunctional
Copy link
Member

It's more about rebuilds. If you change a module and rebuild, then if the .mod file changes, you need to rebuild everything that depends on it.

@certik
Copy link
Member

certik commented Apr 27, 2020 via email

@milancurcic
Copy link
Member Author

Okay, sounds good. We can revisit if it shows to be an issue, I don't think it is right now.

Yes, it'd be good to discuss and write out requirements for packages. I don't remember seeing this specific one anywhere.

@certik
Copy link
Member

certik commented Apr 27, 2020

@milancurcic see #39.

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

No branches or pull requests

3 participants