Confusing double precision real in Fortran

Personally I now write use, intrinsic :: iso_fortran_env which includes parameters such as int32,real64 which have the obvious meanings, and can be used like this: real(real64) :: a_64_bit_real_scalar Note that kind=8 is not guaranteed, by the standard, to deliver an 8-byte kind. The values that kind parameters take are not standardised and do vary from … Read more

Fortran SAVE statement

In principal when a module goes out-of-scope, the variables of that module become undefined — unless they are declared with the SAVE attribute, or a SAVE statement is used. “Undefined” means that you are not allowed to rely on the variable having the previous value if you again use the module — it might have … Read more

Size of array after a deallocate

This is a question crying out for a canonical one, really. In the interest of answering your specific question in the absence (as far as I can tell, but I may write one eventually), I’ll answer. The argument to size must not be an unallocated allocatable variable. For your code fred is an allocatable variable. … Read more

Are Fortran control characters (carriage control) still implemented in compilers?

In years past, ignoring this use of the first column could cause bad things on a line printer, like page ejects — but when was the last time that you saw a line printer? Otherwise it was output device, compiler and OS dependent. The advice of “Fortran 95/2003 for Scientists and Engineers” was excellent for … Read more