Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

FORTRAN / VBA EXCEL

$
0
0

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


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>