Hi,
I', kind of new to Fortran, so I've probably missed something completely obvious...
This is my lib code:
which I have compiled into a lib:
Have made this program to use the lib:
which I have compiled:
Using SunStudio12.1 on a Ubuntu 9.04 Linux system
The program returns
In other words, the subroutine works fine, but the function does not return anything. I have tried to move the function into the main program - in which case it returns 1.44 as expected. I have also tried to debug the program, and the values are passed correctly, but somehow the result is not returned to the caller - why? help! Thx in advance!
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
I', kind of new to Fortran, so I've probably missed something completely obvious...
This is my lib code:
Code:
real function jMultiply(a,b)
implicit none
real a,b
jMultiply = a*b
end function jMultiply
subroutine sMultiply (a,b,res)
real res,a,b
res = a*b
end
which I have compiled into a lib:
Code:
f95 -c -g -w1 -o JFTools.o JFTools.f90
ar rv libjflib.a JFTools.o
Have made this program to use the lib:
Code:
real :: r
r = jMultiply(1.2,1.2)
PRINT*,r
call sMultiply(1.2,1.2,r)
PRINT*,r
END
which I have compiled:
Code:
f95 -o testJFLib.o -L../JFLib/ ../JFLib/libjflib.a
Using SunStudio12.1 on a Ubuntu 9.04 Linux system
The program returns
Code:
0.0E+0
1.44
In other words, the subroutine works fine, but the function does not return anything. I have tried to move the function into the main program - in which case it returns 1.44 as expected. I have also tried to debug the program, and the values are passed correctly, but somehow the result is not returned to the caller - why? help! Thx in advance!
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'