Closed Patol75 closed 2 years ago
I wholeheartedly agree with this. When we updated to Ubuntu 20 I had to go through a similar process and check all the compiler warnings in case GCC 10 had raised any problematic warnings and it was definitely cumbersome. It would be substantially easier if only "relevant" warnings were displayed.
-Wno-unused-function
ieee_arithmetic_dummy
can be removed completely, which should remove some compiler warnings, and instead we
can use and ieee_is_normal
, ieee_is_nan
, etc. from ieee_arithmetic
see here for quick info-Wc-binding-type
warnings in Integer_set.F90
and Integer_hash_table.F90
can be removed by changing from the default kind
to a C kind
s from iso_c_binding
/iso_fortran_env
-Wunused-dummy-argument
are really case dependant and IMO a fair ammount of rewrite would need to be done for them to go away, so for now maybe just turn them off (-Wno-unused-dummy-argument
)??-Wconversion
warnings e.g. Linked_Lists.F90:663:11 might need us to specify the kinds of integers explicitly, which might be an issue.-Wtabs
I think can be ignored unless if we don't mind that a couple of files will have big, whitespace git diffs (of course we can always ignore whitespaces in git diffs)-Wmaybe-uninitialized
as far as I could tell when we migrated to Ubuntu 20 were all false positives so we can ignore them.-Wimplicit-interface
. The solution for this is relatively simple, let us create a couple of modules for BLAS/LAPACK, PETSc, Zoltan and MPI that would contain just the interfaces (MPI already has that).
However, when I encountered the same issue with our Radiation Transport code (FETCH) and replaced the barebone BLAS/LAPACK calls with calls from explicitly defined interfaces I noticed a small, but measurable ~3-5% increase in runtime, for medium to large problem sizes.
Given that nothing else changed and the results were identical to a relative tolerance of 1e-14 this lead me to believe that explicitly defining an interface in some cases might lead to unnecessary creations of temporary arrays, which in turn degrades performance.
Fluidity might not run into this since for every call to BLAS/LAPACK in Fluidity roughly 100-200 could me made in FETCH.
I am attaching the BLAS/LAPACK Fortran interfaces if anyone wants to give this a try in Fluidity LAPACK_Interfaces.F90.txtAgreed with most of that. There's a balance here - warnings are not always 100% accurate, and sometimes we ignore them for good practical reasons; switching off all categories that give cases we choose to ignore, may hide valid warnings; but I fully agree that there are way too many at the moment, which means in practice that all warning messages are now being ignored.
Specifically:
Thanks to both of you for the help here.
I have pushed an additional commit that should drastically reduce the number of warnings, that is if it passes CI. Mentioning CI, I have removed Groovy from the YAML, as it is not supported anymore.
Regarding your comments, I have done the following:
-Wno-unused-function
and -Wno-unused-dummy-argument
-Wimplicit-interface
-Wconversion
using the transfer
functionCan I ask one of you to deal with ieee_arithmetic_dummy
and -Wc-binding-type
? I am not fully sure how to proceed for both of them. For the latter, perhaps this is relevant.
Additionally, there is a -Wintrinsic-shadow
in C_Interfaces_Fortran.F90:70:37:
, if any of you know what it is about.
Indeed, I did break things. transfer
was not the appropriate thing to do; instead, int is probably the way to go. Also, I tried to play clever with Fortran 77, but I failed miserably, so reverted the changes in libmba2d/makM.f
.
I forgot to mention there are also a few -Wunknown-pragmas
in fldtriangle.cpp
and fldgmsh.cpp
@gnikit @stephankramer CI is green again, happy for you to commit some further changes according to the above. Also, does any of you know how to remove Groovy from the list of expected checks?
Awesome work @Patol75, I will have a go at ieee_arithmetic_dummy
and -Wc-binding-type
.
I will also check -Wintrinsic-shadow
. Having had a quick look at C_Interfaces_Fortran.F90
I think the module can be removed all together. get_environment_variable
is now in the standard, memcpy
is not used and compare_pointers
can be written in pure fortran.
Let me know if you want me to know if there is anything I can do.
As for the Groovy Actions workflow, I think we run into our branch protection rules see https://github.com/actions/runner/issues/1539 . @stephankramer do you by any chance have access to the Settings of Fluidity or know the name of the new devops person that does (now that Tim is on leave)?
@stephankramer FYI I had to write a new is_nan
that is optimisation-safe because NaNs are optimised with -ffast-math
. The previous is_nan
worked because it was effectively isnan
from C compiled without any optimisations. None of this really matters since all of the is_nan
calls in Fluidity are surrounded by assert
s, but I thought I should justify this specific change in the codebase.
@gnikit Thanks a lot for your commits here!
I am glad I let you handle ieee_arithmetic_dummy
, really great work there (I see you encountered Vladimir F on StackOverflow, the guy knows everything about Fortran!).
For -Wc-binding-type
, you made me realise my attempt was not successful because I was writing type(c_int)
instead of integer(c_int)
! So bad haha.
After pulling the new commits (and adding my latest one), make -j
now prints about 1500 lines, among which the following types of warnings are still present:
-Wunused-label
-> 3-Wconversion
-> 97Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label
-> 2-Wcatch-value=
-> 7-Wreturn-type
-> 6-Wmaybe-uninitialized
-> 32-Wcharacter-truncation
-> 3-Winteger-division
-> 1-Wunused-value
-> 2Additionally, make -j fltools
, executed after make -j
, now prints about 260 lines, among which the following types of warnings are still present:
-Wunknown-pragmas
-> 4-Wconversion
-> 38-Wunused-value
-> 2Finally, sudo make install
and make unittest
executed thereafter are warning-free. However, for the latter, there are some problems with tools/gmsh2triangle.py
. It seems to me that this script has not been updated to reflect the changes to Gmsh v4. Would you mind having a look @angus-g? Executing make
in assemble/tests
should yield the error.
Note the maybe_unused
attribute that works great for C++ code.
There are a few GMSH 4 formats, and it's hard to hand-roll scripts that are compatible with all of them. Maybe it would be worth rewriting the tools on top of something like https://github.com/nschloe/meshio, but in the meantime it's probably easier to pass the -format msh2
flag to gmsh in the Makefiles?
CI is all green, I guess now is a good time to review the changes. Looking back at what I have done, the main wonder I have is if I should have commented out some lines of code instead of deleting them, but I lack experience with Fluidity source code to answer that one.
I've taken the liberty of rebasing onto latest main, and stripping out the trivial whitespace changes (i.e. EOL removals) while leaving the tab-conversions that alleviate the -Wtabs
warnings. It's available at https://github.com/angus-g/fluidity/tree/deal_with_warnings. I agree that it's annoying to have trailing whitespace, but I'm not yet sure if it's worth having giant whitespace diffs just to fix it (yes, there are ways around it, but it's still noisy). I'll defer to @stephankramer for an opinion on that. Otherwise, once this branch is rebased onto main, I'll have a few review suggestions and then we should be good to go!
Thanks, @angus-g. Regarding whitespaces, I think that the easiest approach is to use pre-commit as mentioned somewhere else by @gnikit. Someone runs it locally, commits all the changes, opens a PR, makes sure CI stays green, and then basically merges. Indeed, pre-commit can then be added to the CI so that all new committed files/changes would be checked. And then we never hear ever again about whitespaces.
That makes sense, I think that's a reasonable solution. In that case, it would probably be better to do it all at once in its own PR to have a single conflict point (e.g. if there's a merge/rebase spanning that commit), and then add the CI at that point, and have it ready for everything that comes afterwards?
Indeed, sounds like a good plan. I have rebased as requested. :)
Thanks, @angus-g.
@stephankramer Can you confirm that this change is fine? Thank you.
CI returned all green after a re-trigger, let me know if this is good to go.
Yes, I'm happy with the changes. It is of course now failing the pre-commit because it doesn't have a pre-commit configuration, meaning that PRs can't be merged without admin override before we merge the pre-commit stuff - which I could do of course, but actually would you mind just merging this branch into the pre-commit PR branch (which I think is ready to go as well once the flake8 stuff is fixed)? Both PRs touch quite a large number of lines in the code, so there's going to be some conflicts, but it's better to resolve these only once, instead of everyone else having to resolve these same conflicts when merging their own life branches.
All good, closing this PR accordingly.
There is a large number of warnings generated throughout the building and testing phases in Fluidity. It would be nice to try to limit their occurrence. I have currently removed a lot of unused variables, with still more to go. Indeed, there are other kinds of warnings, such as implicit procedures or unused dummy arguments. Any help is appreciated.