since we´re planned to re-design our software at our company (whole programm was programmed in F90 with Fortran Compiler 11) we´re planned to to the GUI and easy operations through VB.NET.
The GUI building, event Handling and so, is much easier to code and to implement specific features.
But well ... Fortran is incredibly fast at mathematic operations, which our software is mainly developed for.
So plans are, to call F90 dll´s which are to do the mathematical stuff and send back the results to the VB.NET GUI.
Easy things like multiplie 2 integers, or square rooting, and so ... work like a charm and also strings working good (which are quite the hell on earth in F90 imho :D) ... but i am absolutely not able to simply pass a 1-dimensional array to Fortran.
I tried it with a simple BubbleSort module, just to get the know-how and later be able to implement it to our software. Google does not helping me, and also the examples, which comes with the compiler does not help :(.
Here is the fortran module (sorry i have no idea how to set this in code tags ... the old forum had a function for that if i remeber correct ;) )
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS : "BubbleSortI4SingleArray" :: BubbleSortI4SingleArray
!DEC$ ATTRIBUTES REFERENCE : array
integer, intent(inOut) :: array(:)
integer :: temp
INTEGER :: i, j
LOGICAL :: swapped = .TRUE.
DO j = SIZE(array)-1, 1, -1
swapped = .FALSE.
DO i = 0, j
IF (array(i) > array(i+1)) THEN
temp = array(i)
array(i) = array(i+1)
array(i+1) = temp
swapped = .TRUE.
IF (.NOT. swapped) EXIT
END SUBROUTINE BubbleSortI4SingleArray
In VB.NET i tried 2 different Versions of implementing the Declare command ... at the 1st the array "redims" itself to only 1 number after running through the fortran dll.
At the 2nd, the array holds its size ... but not getting sorted. I also implemented a print *, size(array) in the fortran module, just to control, if the array is correctly "given" by VB.NET. Well ... a size of a few millions, only when it should have e.g. 10 shows me, that something between VB.NET to the Fortran module does not work correctly and fortran so cant sort the array.
Here are the 2 Declare methods i tried:
1) Declare Sub BubbleSortI4SingleArray Lib "C:\sortdemo\sorts.dll" Alias "BubbleSortI4SingleArray" (ByRef array() As Integer)
2) Declare Sub BubbleSortI4SingleArray Lib "C:\sortdemo\sorts.dll" Alias "BubbleSortI4SingleArray" (<MarshalAs(UnmanagedType.SafeArray)> ByRef array() As Integer)
Does anyone have an idea, what the hell i am doing wrong?
I also tried to give the size of the array by VB.net by using array.GetUpperBound(0) and "declare" it in fortran with array(0:upBound-1), since arrays in .NET are 0-based ... but that also won´t work :(
Best regards, Oliver