What does “real*8” mean?

The 8 refers to the number of bytes that the data type uses. So a 32-bit integer is integer*4 along the same lines. A quick search found this guide to Fortran data types, which includes: The “real*4” statement specifies the variable names to be single precision 4-byte real numbers which has 7 digits of accuracy … Read more

How do I do big integers in Fortran?

There is no built-in “big number” support, but we can first check whether there is a larger integer kind available (as mentioned by Francescalus above and also many previous pages (e.g. this page). On my computer with gfortran-6.1, the compiler seems to support 128-bit integer kind, so I could calculate the result up to n=160 … Read more

how to write wrapper for ‘allocate’

This can be done via a generic interface block. You have to create procedures for each rank that you want to handle, e.g., memory_1d, memory_2d, … memory_4d. (Obviously a lot of cut & pasting.) Then you write a generic interface block that gives all of these procedures the alternative name memory as a generic procedure … Read more

What are the ways to pass a set of variable values through the subroutine to a function without common block?

What you care about here is association: you want to be able to associate entities in the function f with those in the subroutine condat. Storage association is one way to do this, which is what the common block is doing. There are other forms of association which can be useful. These are use association … Read more

Does Fortran have undefined behavior?

Yes, it has. It is just called differently. There are many things that you could do and will make your code not standard conforming, for which there is no requirement to for the processor (compiler) to diagnose such non-conformance (of course, many deviations must be diagnosed). Often the situations will be similar to C undefined-behaviour … Read more

Why is this a function declared inside the module and then used somewhere else in the same module not seen by the linker?

In the following, I’ll explain using the complete example below (which you can compile and link to try things): module mymodule contains integer function foo () foo = 1 end function integer function bar () integer :: foo bar = foo() end function end module program test use mymodule print *, bar() end In the … Read more