(Adding the OP).
(2) I encountered a curious failure on compilation with the following statement using integer arithmetic: n= (m + 4)/5 with the message Error: Integer division truncated to constant ‘2’ at (1) [-Werror=integer-division] f951: all warnings being treated as errors
This error only occurs if both (a) the value of "m" would lead to a truncation (say 7 but not 6), and ALSO if (b) the value of "m" was set in a PARAMETER statement. I can work my way around this difficulty by rewriting the statement as: n= int ((1.0*m + 4)/5) but it does seem clumsy.
This warning was introduced because people all to often would write code like x = 3/7 and expect the same result as for x = 3./7.. As often, it is a delicate balance between warning too much and too little. Because this is an error, I assume you use -Werror. The error message gives you a hint, although an indirect one, of how to downgrade this particular error to a warning: Compile with $ gfortran -Wall -Werror -Wno-error=integer-division foo.f90 and you will get a warning again. If you want to still have an error for other unintended cases you may have missed, you can use n = (m+4-mod(m+4,5))/5 which, while also admittedly clumsy, will be evaluated at compile-time if m is a parameter. Hope this helps. Best regards Thomas