Hi Tek-tips,
I am having a very wierd problem that I can't seem to figure out!
I need to call a fortran 77 function from IDL. To do this, I must export these functions in a DLL and also add a wrapper function (IDL uses argc,argv convention).
So first I am testing my dll in fortran (Visual Studio 2008). I have my main program which imports the dll and calls f2c_w (the wrapper function). This function then calls the actual working function that converts fahrenheit to celsius, however it does not return the value to the wrapper function, and hence to my main program!
At first my functions were not even passing arguments into the function, but I found that by making all scalar arguments an array of dimension(1), it works. --- why is this!?
Now my problem is that the function f2c is not passing arguments back.
Does anyone know what is going on?
---------------------------------------------
! Main program
program testf2c
!DEC$ ATTRIBUTES DLLIMPORT :: f2c_w
implicit none
integer :: a , f2c_w
integer,parameter :: argc=2
real(4), dimension(argc) :: argv
argv(1) = 98.6
argv(2) = 0.0
a = f2c_w(argc,argv)
print*, argv(1), argv(2)
end program testf2c
---------------------------------------------
! DLL PROGRAM
integer function f2c_w(argc, argv)
implicit none
!DEC$ ATTRIBUTES DLLEXPORT::f2c_w
integer :: argc
real(4), dimension(argc) :: argv
call f2c((argv(1)), (argv(2)))
f2c_w = 5
return
end
!This subroutine is called by f2c_w and has no IDL-specific code.
subroutine f2c(f, c)
implicit none
real(4), dimension(1) :: f, c
c = (f - 32.0) * (5.0/9.0)
return
end
Thanks for your help!
I am having a very wierd problem that I can't seem to figure out!
I need to call a fortran 77 function from IDL. To do this, I must export these functions in a DLL and also add a wrapper function (IDL uses argc,argv convention).
So first I am testing my dll in fortran (Visual Studio 2008). I have my main program which imports the dll and calls f2c_w (the wrapper function). This function then calls the actual working function that converts fahrenheit to celsius, however it does not return the value to the wrapper function, and hence to my main program!
At first my functions were not even passing arguments into the function, but I found that by making all scalar arguments an array of dimension(1), it works. --- why is this!?
Now my problem is that the function f2c is not passing arguments back.
Does anyone know what is going on?
---------------------------------------------
! Main program
program testf2c
!DEC$ ATTRIBUTES DLLIMPORT :: f2c_w
implicit none
integer :: a , f2c_w
integer,parameter :: argc=2
real(4), dimension(argc) :: argv
argv(1) = 98.6
argv(2) = 0.0
a = f2c_w(argc,argv)
print*, argv(1), argv(2)
end program testf2c
---------------------------------------------
! DLL PROGRAM
integer function f2c_w(argc, argv)
implicit none
!DEC$ ATTRIBUTES DLLEXPORT::f2c_w
integer :: argc
real(4), dimension(argc) :: argv
call f2c((argv(1)), (argv(2)))
f2c_w = 5
return
end
!This subroutine is called by f2c_w and has no IDL-specific code.
subroutine f2c(f, c)
implicit none
real(4), dimension(1) :: f, c
c = (f - 32.0) * (5.0/9.0)
return
end
Thanks for your help!