Re: strange arguments passing problem (from vba to fortran dll)
- From: formulae translator <liwei19742001@xxxxxxxxx>
- Date: 29 May 2007 14:57:01 -0700
On May 29, 1:06 pm, Louis Krupp <lkr...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
formulae translator wrote:
On May 29, 2:50 am, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:
On 29 mei, 00:01, formulae translator <liwei19742...@xxxxxxxxx> wrote:
Dear all,It looks as if only the scalar variables are passed correctly.
I encounter a strange problem when I am trying to pass arguments from
VBA (excel 2003) to fortran dll (compiled using CVF 6.6b).
debug in cvf environment shows some of the arguments are passed
correctly while some are not.
I attached part of the code here. The arguments passed correctly are
f_max, ppw, ma, para_H2. For other array arguments, only the first
elements are passed correctly.
any comments or suggestions are appreciated.
That does seem to make sense to me:
In VB you need to pass arrays like: ByRef array() As Double
In the code you posted the interfaces are missing the ().
Regards,
Arjen
Dear Arjen,
Thanks a lot for your prompt reply.
I tried the way you suggested, but got a compilor error (type
mismatch) from VBA.
The example in CVF document also has no "()" in "byref array as
double".
except for the two scalars (F_max and ppw), I have two arrays (ma and
para_H2) passed correctly.
I suspect the reason is that total size of arguments exceeds some
limit, but I am not sure because I cannot find any evidence to support
this.
Wei
You can test that hypothesis by stripping your code down to nothing but
variable initialization in VB and the Fortran subroutine call;
eliminate everything except for the subroutine arguments. If the values
look right when you do that, then the problem is elsewhere. Add
'implicit none' to the Fortran code -- it can save you some bugs later on.
Louis- Hide quoted text -
- Show quoted text -
Thanks for Louis' reply
I found the reason by playing with VBA part.
I can NOT define more than one array in one line.
It's so strange because I never heard anyone mentioned this.
The adjusted code should be following:
Dim f_max, ppw As Double
Dim i, j, nt_out, nlayer, n_ma As Long
Dim control(7) As Long
Dim ma(100) As Long
Dim acc(10000, 2) As Double
Dim profile(100, 4) As Double
Dim degradation(20, 200) As Double
Dim tabk(8, 3) As Double
Dim para_H2(10, 50) As Double
Dim node_depth(100) As Double
Dim layer_depth(100) As Double
Dim out_a(10000, 100) As Double
.
- Follow-Ups:
- References:
- strange arguments passing problem (from vba to fortran dll)
- From: formulae translator
- Re: strange arguments passing problem (from vba to fortran dll)
- From: Arjen Markus
- Re: strange arguments passing problem (from vba to fortran dll)
- From: formulae translator
- Re: strange arguments passing problem (from vba to fortran dll)
- From: Louis Krupp
- strange arguments passing problem (from vba to fortran dll)
- Prev by Date: Re: Salford Fortran - Double Precision product
- Next by Date: Re: user-defined alignment in gfortran
- Previous by thread: Re: strange arguments passing problem (from vba to fortran dll)
- Next by thread: Re: strange arguments passing problem (from vba to fortran dll)
- Index(es):
Relevant Pages
|