TommyCee
Civil/Environmental
- Nov 6, 2009
- 13
Here, the "main" program is function WinMain(), and it calls a simple function that "lives" in another *.f90 file (compiled w/ the project. That function is this:
integer*4 function fRun(Nint)
implicit none
integer :: Nint
fRun = Nint + 10
end
An Interface is presented in the declaration area of the calling program:
interface
function fRun(Hint)
integer Hint
end function
end interface
integer*4 :: iResult, Hint
Later, the function is called as follows:
Hint = 2
iResult = fRun(Hint)
The system compiles & links fine. On execution, Hint is set to 2, control goes to the function (in the other f90 file) and Nint takes on the value of 2. fRun becomes 12, as it should.
When control returns to the calling program, Hint still knows what it should be (2) but fRun has lost its mind. Instead of holding a value of 12, its a long, meaningless string (-2147348), which, oddly enough, is minus the value of WinMain (in case that's a clue).
BTW, I tried moving fRun to the bottom of the calling program and I got the same result.
Any ideas as to what I'm missing here?
{No, this is NOT a homework assignment; it's a rudiment of what will become a huge Fortran app.)
integer*4 function fRun(Nint)
implicit none
integer :: Nint
fRun = Nint + 10
end
An Interface is presented in the declaration area of the calling program:
interface
function fRun(Hint)
integer Hint
end function
end interface
integer*4 :: iResult, Hint
Later, the function is called as follows:
Hint = 2
iResult = fRun(Hint)
The system compiles & links fine. On execution, Hint is set to 2, control goes to the function (in the other f90 file) and Nint takes on the value of 2. fRun becomes 12, as it should.
When control returns to the calling program, Hint still knows what it should be (2) but fRun has lost its mind. Instead of holding a value of 12, its a long, meaningless string (-2147348), which, oddly enough, is minus the value of WinMain (in case that's a clue).
BTW, I tried moving fRun to the bottom of the calling program and I got the same result.
Any ideas as to what I'm missing here?
{No, this is NOT a homework assignment; it's a rudiment of what will become a huge Fortran app.)