Hello Experts,
It might not be appropriate to address this question here.
I tried to create Fotran dll file and asked VBA to call it. A very
simple example:
Let's say we have a Fortran subroutine that multiplies all elements of
an array by 10.
Then, VBA Excel has an array as input and calls this (dll) fortran
subroutine and will get the array multiplied by 10.
I always fail to do so with array as input, however find no problem
with single-valued variable.
Look forwards to hearing from you.
Thanks,
Irfan
|
|
0
|
|
|
|
Reply
|
kisitanggang (72)
|
9/19/2008 3:28:18 PM |
|
On Sep 19, 11:28=A0am, kis <kisitangg...@gmail.com> wrote:
> Hello Experts,
>
> It might not be appropriate to address this question here.
>
> I tried to create Fotran dll file and asked VBA to call it. A very
> simple example:
> Let's say we have a Fortran subroutine that multiplies all elements of
> an array by 10.
> Then, VBA Excel has an array as input and calls this (dll) fortran
> subroutine and will get the array multiplied by 10.
>
> I always fail to do so with array as input, however find no problem
> with single-valued variable.
>
> Look forwards to hearing from you.
>
> Thanks,
> Irfan
Try passing the first element of the array as your actual argument:
call FOO(x(1)), etc.
In addition many other things depend on which compiler you are using.
DVF, CVF and IVF have good documentation concerning mixed language
programming.
- e
|
|
0
|
|
|
|
Reply
|
epc8 (1259)
|
9/19/2008 4:49:53 PM
|
|
Can you pls give me an example code that does this?
FYI, I use CVF 6.6
Thanks,
Irfan
On 19 Sep, 11:49, e p chandler <e...@juno.com> wrote:
> On Sep 19, 11:28=A0am, kis <kisitangg...@gmail.com> wrote:
>
>
>
> > Hello Experts,
>
> > It might not be appropriate to address this question here.
>
> > I tried to create Fotran dll file and asked VBA to call it. A very
> > simple example:
> > Let's say we have a Fortran subroutine that multiplies all elements of
> > an array by 10.
> > Then, VBA Excel has an array as input and calls this (dll) fortran
> > subroutine and will get the array multiplied by 10.
>
> > I always fail to do so with array as input, however find no problem
> > with single-valued variable.
>
> > Look forwards to hearing from you.
>
> > Thanks,
> > Irfan
>
> Try passing the first element of the array as your actual argument:
>
> call FOO(x(1)), etc.
>
> In addition many other things depend on which compiler you are using.
>
> DVF, CVF and IVF have good documentation concerning mixed language
> programming.
>
> - e
|
|
0
|
|
|
|
Reply
|
kisitanggang (72)
|
9/22/2008 1:43:36 PM
|
|
kis wrote:
> Can you pls give me an example code that does this?
> FYI, I use CVF 6.6
....
There is a section on arrays in mixed-language programming in the CVF
documentation in the mixed language programming section as well as
sample projects for each data type (strings, variables, arrays, UDTs, ...)
One small section contains the following snippet; reading the section
will enlighten greatly...
Handling Arrays and Visual Fortran Array Descriptors
....
To pass an array from Visual Basic to Fortran, pass the first element of
the array. By default, Visual Basic passes variables by reference, so
passing the first element of the array will give Fortran the starting
location of the array, just as Fortran expects. ...
' In Basic
Declare Sub FORTARRAY Lib "fortarr.dll" (Barray as Single)
DIM barray (1 to 3, 1 to 7) As Single
Call FORTARRAY(barray (1,1))
! In Fortran
Subroutine FORTARRAY(arr)
REAL arr(3,7)
--
|
|
0
|
|
|
|
Reply
|
none1568 (6639)
|
9/22/2008 2:25:32 PM
|
|
Thanks so much. I will try it.
Irfan
On Sep 22, 9:25=A0am, dpb <n...@non.net> wrote:
> kis wrote:
> > Can you pls give me an example code that does this?
> > FYI, I use CVF 6.6
>
> ...
> There is a section on arrays in mixed-language programming in the CVF
> documentation in the mixed language programming section as well as
> sample projects for each data type (strings, variables, arrays, UDTs, ...=
)
>
> One small section contains the following snippet; reading the section
> will enlighten greatly...
>
> Handling Arrays and Visual Fortran Array Descriptors
> ...
> To pass an array from Visual Basic to Fortran, pass the first element of
> the array. By default, Visual Basic passes variables by reference, so
> passing the first element of the array will give Fortran the starting
> location of the array, just as Fortran expects. ...
>
> =A0 ' In Basic
> =A0 Declare Sub FORTARRAY Lib "fortarr.dll" (Barray as Single)
> =A0 DIM barray (1 to 3, 1 to 7) As Single
> =A0 Call FORTARRAY(barray (1,1))
>
> =A0 ! In Fortran
> =A0 Subroutine FORTARRAY(arr)
> =A0 =A0 =A0REAL arr(3,7)
>
> --
|
|
0
|
|
|
|
Reply
|
kisitanggang (72)
|
9/22/2008 6:56:31 PM
|
|
|
4 Replies
110 Views
(page loaded in 0.089 seconds)
|