Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

VB2005 - IVF passing data problems

paolo_becchi
Beginner
1,103 Views
Dear all,
I have an old version of a VB6 program where I exchange data matrix and array from VB6 to CVF using the SafeArrayAccessData calls and similar. Everything worked properly.
Now I have already started in converting the VB6 application to VB2005, but before converting the Fortran DLLs, I decided to debug the VB2005 code with the same CVF DLLs.
The problem concerns the back data exchange from CVF to VB2005, because the Fortran code seems to not allocate the pointer pointing to the local matrix data (pointing to the same Input matrix) and then I cannot pass the elaborated data back to VB.
Considering the following example
arrayINPUT dimension (:) [passed in input]
loc_ARRAY dimension (:) [local matrix variable]
ptrINP integer
ptrARRAY pointer

POINTER(arrayINPUT, ptrINP)
POINTER(ptrARRAY, loc_ARRAY )

status=SafeArrayAccessData(arrayINPUT, ptrARRAY)

the problem seems to be located where it is asked to connect the arrayINPUT to the pointer ptrARRAY.
Any suggestions?
Thanks
0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,103 Views

Is the title of this thread correct? It seems to me that the problem is VB2005-CVF, right? I think that VB2005 (indeed 2002 and later) and VB6 are incompatible in the way they pass things, but I don't recall the details.

The samples I attached here include a SafeArray sample. Perhaps that will give you a clue.

0 Kudos
paolo_becchi
Beginner
1,103 Views
Yes, the title is correct especially because the VB05-CVF is closesly a first debug step. My intention concerns the complete passage from the VB6-CVF configuration to VB05-IVF, but if VB05-CVF doesn't work the question is: Is it suggestible to finalize the upgrading to the last configuration? Will it work?
Why at the moment I cannot pass back the data matrix from CVF dll to VB05?
Why the pointer is not allocated?
Thanks

0 Kudos
Steven_L_Intel1
Employee
1,103 Views
If you encounter problems with VB05 and IVF, I can try to help. Perhaps others can help with VB6 and CVF. I can tell you that you'll probably have to make changes when switching from VB6 to VB05.
0 Kudos
paolo_becchi
Beginner
1,103 Views
Many thanks in advance, I'm already working with a combined VB05 program combined with a IVF dll, but I have some problems. Just in order to check the program configuration, I defined a very simple dll where the Pigreek function provide the value 3.1415.... but when I call the function, the program crashes.
So, just in order to give you a more detailed idea of the problem, I defined the following generic class:
Public Class clsMAT
Public Declare Function pigreek Lib "if_Mat.dll" () As Double
End class

and
then the call is:
Imports clsMAT

Dim value as double
value=pigreek()


So, any idea? I also tried to debug the IVF dll, but I think the problems concerns the call dll, not directly inside the F90 code.
Regards and thanks

0 Kudos
Steven_L_Intel1
Employee
1,103 Views
I don't know how VB expects function results to be returned. See if it works to make pigreek a subroutine with a variable passed as an argument.
0 Kudos
paolo_becchi
Beginner
1,103 Views
I tried with a different, but very simple function named "DEG" that is aimed to convert a Rad angle in Deg angle.
During the debug of the Fortran function, the variable AngRAD and DEG have the following values:
ANGRAD -1.0803502417083776e+057 double (and not 3.1415!)
DEG -6.1899507523317673e+058 double
(and not 180.0!)
that is very different from what was passed to the dll.
Any suggestions?


INTEL VISUAL FORTRAN
!DEC$ INTEGER : 4
!DEC$ REAL : 8

FUNCTION DEG(AngRAD)
!DEC$ ATTRIBUTES DLLEXPORT:: DEG
!DEC$ ATTRIBUTES ALIAS: 'DEG'::DEG
!DEC$ ATTRIBUTES STDCALL:: DEG
!DEC$ REFERENCE:: AngRAD

IMPLICIT NONE

REAL, INTENT(IN):: AngRAD
REAL:: DEG

!Execution section
DEG=AngRAD*180./3.1415

RETURN
END FUNCTION DEG


VISUAL BASIC 2005
(Function definition)
Class customMATH
Private Declare Function VBDEG Lib "ivfMATH.dll" _
Alias "DEG" (ByRef AngRAD As Double) As Double

Public Shared Function DEG(ByRef AngRAD As Double) As Double
changedir(PathDLL) 'change the directory to the directory where is located the ivfMATH.dll
DEG = VBDEG(AngRAD)
End Function
End Class

(call)
Dim value As Double
value =
customMATH.DEG(CDbl(3.1415))
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,103 Views
Shouldn't that be instead:

!DEC$ ATTRIBUTES REFERENCE:: AngRAD

In addition, may I suggest not using !DEC$ INTEGER and !DEC$ REAL directives? Those are ugly hacks that, in my opinion, should be used only for making dusty decks work. If you want the precision setting centralized, a better option would be:

MODULE MyKinds
INTEGER, PARAMETER:: wp = 8
END MODULE MyKinds
FUNCTION Deg(...)
Use MyKinds
REAL(wp), INTENT(IN):: AngRad
...

0 Kudos
g_f_thomas
Beginner
1,103 Views

I'm puzzled by your post but ..., in respect to vb6 and vb.net, the former, like fortran, stores arrays in column-major order and arrays are optionally 1-based, while the latter, like c/c++, stores arrays in row-major orderand they are always 0-based.

Ciao,

Gerry

0 Kudos
sabalan
New Contributor I
1,103 Views

Umm...! I dont know how VB.net is, but in VB6 arrays AREoptionally 0-based unless you declare them like MyArray (1 To n).

Sabalan.

0 Kudos
g_f_thomas
Beginner
1,103 Views

Let me see, the snippet

Option Explicit
Option Base 1 '0

Private Sub Form_Load()
Dim A(1) As Long

Debug.Print LBound(A); UBound(A)

End Sub

confirms the validity of the VB6 docs thatOption Base 0 is the defaultand Option Base 1 is optional. I believe that's what I said but in a more simpler way. With VB.NET all arrays are 0-basedno options about it.

0 Kudos
sabalan
New Contributor I
1,103 Views

Ah, sorry! I mssed up "optional" and "default"! Yes, arrays in VB6 are 0-based by DEFAULT.

Sabalan

0 Kudos
Reply