That's a horrid piece of code ...
The cause of your problem is that the name g
in the program is related only by name to the function called g
. You haven't told the compiler that they are the same things, and it is left to the runtime to connect them. Because you have used implicit typing something in the program scope called g
is given type real
. But your function called g
returns a real*8
value, leading directly to the error message you see.
To fix this:
- Use explicit typing in all scopes. Add the line
implicit none
at the start of each program unit. Then clear up the errors that arise. - Get the compiler to generate an explicit interface to the function
g
. The easy way to do this is to move theend program
statement to the end of your source file and in its place write the wordcontains
. This will enable the compiler to know that the nameg
refers to that function and not to some variable you haven't declared. Drop the use of the non-standard
real*8
(etc). One option for this would be to use-associate the standard moduleiso_fortran_env
with a line such asuse, intrinsic :: iso_fortran_env
between the
program
statement andimplicit none
and then you can use pre-defined kinds for your declarations like this;real(real64) :: g0
- Indent your program consistently.
There's probably more, but that's enough for now.