Re: newbie: array passing problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Mike Williams wrote:
"tom" <tadamsmar@xxxxxxxxx> wrote in message news:1184350761.343721.274120@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Can I pass a one dimension of an array as an array?
For instance:
DIM A(5,3) as Single
CALL FUBAR(A(1,2))
SUBROUTINE FUBAR(X() as Single)
Can X be treated as on dimensional array with 5 elements?

I'm not quite sure what you mean there, but if you want to perform some task on specific "column" (or "row" depending on how you look at things) of a two dimensional array then you can do so in the following manner. You can see immediately that it does not require any shifting about of actual array memory (because the array is passed by reference) by the fact that even though the entire array contains 25 million elements the 5000 elements in the specified "column" are deal with almost immediately you press the button. Unless of course I've misunderstood your question.

I think you have, Mike (misunderstood the question, that is :) )...

In your example code you're still always addressing the array w/ both subscripts.

In older FORTRAN, it was often the case that subroutines were passed the address (as they are in VB) of the starting array location and in the subroutine a multiply-dimension array would then be referenced by only a single index. OP wanted to implement that same construction in VB directly if possible as he was trying to translate code on a direct line-by-line basis. VB, however, won't allow the inconsistent array dimensions.

Parenthetically, newer Fortran introduces "array slices" which allow the same thing but are "safer" in that they contain the additional dope vector that allow the compiler to do bounds checking, etc., if requested that wasn't always possible w/ the earlier (pre-F77) versions.

--
.



Relevant Pages

  • Re: sort function
    ... I've got an array. ... Now I want to sort this ... Is there a funkionality like that available withinf fortran? ... subroutine sort_matrix ...
    (comp.lang.fortran)
  • Re: Double precision arrays and subroutines
    ... to be the start of an nx * nx array. ... What happens is that, in Fortran, these two program units are independent. ... The subroutine and the program that calls it are compiled separately, and normally the compiler doesn't know about one when it's compiling the other. ... Thus, the compiler doesn't know about the mismatch between the fact that the subroutine call is being given an integer and two scalar doubles, and the subroutine declaration is expecting an integer and two double arrays. ...
    (comp.lang.fortran)
  • Re: newbie: array passing problem
    ... In your example code you're still always addressing the array ... But does the fact that the subroutine needs to reference both the "column" and the "row" really matter? ... By the way, you can actually pass a reference to a single "column" of an array, but not "row" by setting up a suitable "single element" SafeArray structure and pointing it at the staring address of the block of array data you are interested in. ... It is the latter that is what OP was trying to avoid and I wouldn't say it was "worrying" me, only that you can't meet OP's actual question/want/desire in VB of being able to precisely mimic his existing Fortran code in VB. ...
    (microsoft.public.vb.general.discussion)
  • Re: How does this sintax means?
    ... However, the subroutine will work ... Here, the array y is an "automatic array", dynamically allocated when foo is ... Note that this is a Fortran 90/95 ...
    (comp.lang.fortran)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)