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

Fix "implicit none" usage #10

Open
certik opened this issue Jul 15, 2013 · 6 comments
Open

Fix "implicit none" usage #10

certik opened this issue Jul 15, 2013 · 6 comments

Comments

@certik
Copy link

certik commented Jul 15, 2013

There should be exactly one implicit none in each module at the top. No function in that module should have it, as it is redundant (the module one applies to all functions in the module). I'll send a PR once #9 is in, to avoid merge conflicts.

@mandli
Copy link
Member

mandli commented Jul 15, 2013

Yeah, I agree that this is unnecessary. This is done for the sake of older Fortran programmers so that they are reminded that each function does not have implicit typing. Since it does not actually affect the compilation of the code and may avoid problems I tend to put that statement in every subroutine.

Or perhaps there is a reason not to put that in everywhere?

@certik
Copy link
Author

certik commented Jul 15, 2013

It all depends on what culture you want to create in the project. I would assume that people will send PRs with additions, so it's easy to check that there is implicit none in each module at top. And in that case, any additional implicit none is just obstructing the code. The compiler will refuse to compile unless you specify types, so older Fortran programmers will get instantly reminded that they need to specify types. So the purpose of a reminder is served imho.

The reason not to put it everywhere is simply to keep the code short and consistent.

@mandli
Copy link
Member

mandli commented Jul 15, 2013

That is a good point, the compiler will inform people of their mistake before it gets too far along. Also, with the travis builds it will be easier to make sure someone does not accidentally do something and break everything.

Let's remove them.

@certik
Copy link
Author

certik commented Jul 15, 2013

Note that we can go even further and write a simple Python script that checks all .f90 module files to have "implicit none" at the module level. This will then naturally fail at Travis. This script might be reusable in other Fortran projects as well. There really should be a compiler option that does this particular check, but unfortunately I am not aware of any, except -Wimplicit-interface.

Update: gfortran also has -fimplicit-none, but I would discourage using it, as other compilers might not enforce this. We need to make sure that the code itself enforces "implicit none".

@mandli
Copy link
Member

mandli commented Jul 15, 2013

Looks like it's not supported very widely anyway. I would say remove the implicit nones and leave them in the module section.

@certik
Copy link
Author

certik commented Jul 15, 2013

Cool. I'll send a PR later.

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

2 participants