Assessing code quality with the NAG Fortran compiler

Assessing code quality with the NAG Fortran compiler
by Iain Barrass
May 20, 2022 · 23 mins read

The NAG Fortran compiler, like other compilers, has diagnostic capabilities which can help us write correct and portable Fortran programs. In this post we’ll look at these, comparing with those of the GCC and Intel compilers, and see how the compiler can be a valuable tool when developing or maintaining Fortran code.

Conclusion

In this post we’ve looked at using the NAG Fortran compiler to help us develop standard-compliant and portable Fortran code which is free of bugs. Aiming to write portable code means that we have greater freedom to compile and test our programs using multiple tools, as well as being able to more widely share our work.

The NAG Fortran compiler detects many of those problems in our code that may be found by other commonly used compilers. It also has sensitivity to other types of errors and at times clearer diagnostic messages.

Even if we intend to use one compiler on one machine for the “production” version of our program, it’s good practice to test with as many tools and machines as possible during its development. We’ve seen here that the NAG Fortran compiler can help us detect subtle errors which may exist in code. These errors may not be detected with our target compiler but may lead to inaccurate results, or different behaviours when the same code is compiled by another user on a different system.

The author wrote a good article on parameterized derived types.

3 Likes