FORTRAN / VBA EXCEL

FORTRAN / VBA EXCEL

What is the difference between:

subroutine Test1(Double1,Double1_N,Integer1,Integer1_N,Charater1,Charater1_LEN,Charater1_DIM,Results1,Results1_N)
!dec$ attributes dllexport,stdcall,reference,alias:'Test1' :: Test1

And

subroutine Test1(Double1,Double1_N,Integer1,Integer1_N,Charater1,Charater1_LEN,Charater1_DIM,Results1,Results1_N) Bind(C)
!DEC$ ATTRIBUTES DLLEXPORT:: Test1

This works just fine and VBA Excel can call the subroutine

subroutine Test1(Double1,Double1_N,Integer1,Integer1_N,Charater1,Charater1_LEN,Charater1_DIM,Results1,Results1_N)
!dec$ attributes dllexport,stdcall,reference,alias:'Test1' :: Test1
use iso_c_binding
implicit none
integer(c_int), value :: Double1_N,Integer1_N,Results1_N,Charater1_LEN,Charater1_DIM
real(8), dimension(Double1_N), intent(in):: Double1
real(8), dimension(Results1_N), intent(out)::Results1
integer(4), dimension(Integer1_N),intent(inout):: Integer1
character(len=Charater1_LEN), dimension(Charater1_DIM),intent(inout) :: Charater1
Results1 =Double1*Integer1
Charater1(1) = 'abcde'
Charater1(2) = 'fghij'
Charater1(3) = 'klmno'
Charater1(4) = 'pqrst'
Charater1(5) = 'uvwxyz'
end subroutine Test1

The follwoing does not work I get a "Bad DLL calling convection" when VBA Excel tries to call the subroutine

subroutine Test1(Double1,Double1_N,Integer1,Integer1_N,Charater1,Charater1_LEN,Charater1_DIM,Results1,Results1_N) Bind(C)
!DEC$ ATTRIBUTES DLLEXPORT:: Test1
use iso_c_binding
implicit none
integer(c_int), value :: Double1_N,Integer1_N,Results1_N,Charater1_LEN,Charater1_DIM
real(8), dimension(Double1_N), intent(in):: Double1
real(8), dimension(Results1_N), intent(out)::Results1
integer(4), dimension(Integer1_N),intent(inout):: Integer1
character(len=Charater1_LEN), dimension(Charater1_DIM),intent(inout) :: Charater1
Results1 =Double1*Integer1
Charater1(1) = 'abcde'
Charater1(2) = 'fghij'
Charater1(3) = 'klmno'
Charater1(4) = 'pqrst'
Charater1(5) = 'uvwxyz'
end subroutine Test1

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

The second uses the C calling convention rather than STDCALL.  VBA/Excel requires STDCALL. Intel Fortran doesn't let you mix STDCALL with BIND(C) at present.

Steve

Thanks Steve I found out that if I use /iface:stdcall the latter does work too.Thanks for you reply.

Melden Sie sich an, um einen Kommentar zu hinterlassen.