
Passing arrays from VB5 to MS FORTRAN PwrStn
Greetings:
I'm trying to build a Visual Basic 5.0 front-end for a MS fortran
PowerStation 4.0 program. My problem is that I need to pass an array from
VB to the FORTRAN DLL that varies in size; the user will specify the
matrix dimensions using the VB front-end, and the FORTRAN program will
return parameters in the array. I have it working for a matrix of fixed
dimensions - say, a 3x2 matrix, specified in both the VB and FORTRAN code
- but when I try to generalize it crashes and burns.
For example, I'd like to pass 3 arguments to the FORTRAN DLL - I, J and
X(I, J), where I and J are integers (e.g., 3 and 2) and X is a I x J
matrix (e.g., 3x2 matrix). I and J are specified by the user, however.
I dimensioned the variables in VB5 as follows:
Dim I As Integer
Dim J As Integer
Dim X() As Single
ReDim X(I,J) As Single
My subroutine declaration in VB looks like:
(ByRef I As Integer, ByRef J As Integer, ByRef X As Single)
Option Base 1 (by the way...)
And I call the FORTRAN DLL like this:
Call PleaseWork (I, J, X(1,1))
On the FORTRAN side, I would like to say something like this:
SUBROUTINE PLEASEWORK(I,J,X)
DIMENSION X(I,J) (or, REAL X(I,J) )
and, of course, be able to enter values in the X matrix to be returned to
VB. If I try this:
X(1,1) = 11
it's fine. But if I do this:
X(1,2) = 12
it crashes and burns horribly. So, I can make it work with an
"Explicit-Shape Array", but it won't work with an "Assumed-Shape Array"
(i.e., DIMENSION X(:,:) ), I can't use an "Assumed-Size Array", and when I
try to set it up in FORTRAN as a "Deferred-Shape Array" (i.e.:
REAL, ALLOCATABLE:: X(:,:)
ALLOCATE (X(I,J))
the compiler complains that "X is a dummy argument - cannot be
ALLOCATABLE."
I've run out of ideas. I hope this is enough information for somebody to
see what the problem might be ... assuming this is possible of course ...
Thanks much for any advice,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
David A. Robinson |
The Wharton School, Univ. of PA | '''
2314 SH-DH, 3620 Locust Walk | (o o)
Philadelphia, PA 19104 |-------------oOO--(_)--OOo--------------