I've never written a Fortran code.
But it seems like you have to declare your variables first, then assign values, which you violate in your code (you declare and assign g on the same line and you declare a after you have assigned value to g).
I suggest having a look on a Fortran tutorial, such as this: https://www.tutorialspoint.com/fortran/index.htm
I played around a bit with the help of some tutorials and this is what I came up with:
! Declare your variable
! Assign your values
g = 9.8
a = 3
print *, 'func = ', func(a, g)
function func(a, F)
func = a * F
end function func
F = g * 2
end function F
Feel free to modify it to suit your needs.