Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

VB.net over Fortran 102

WesJD
Novice
926 Views

Is there any systematic documentation of how to develop a VB.net program with Fortran subroutines? I have the "VB calls Fortran" example code but I'm looking for more detailed guidance and explanation of what is required to make the two languages work with each other. When I try to adapt the example with my code I'm getting errors I don't understand. (I should say, I'm reasonably competent in Fortran and VB.Net separately.) Thanks in advance.

0 Kudos
3 Replies
FortranFan
Honored Contributor III
910 Views

@WesJD ,

I'm unaware of any systematic documentation but can't say I have looked for any in a long time - so things may have changed.

However do note what you will find a lot of information online is how to consume C code in VB .NET, especially as part of Microsoft's Platform Invoke technology:

https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke

Please know "under the hood" Microsoft does indeed recognize its own C/C++ compiler as part of its managed (.NET) domain.

Thus a strategy then can be for you to have your Fortran code be interoperable with a C companion processor and here, try to follow as much as possible the standard facilities toward interoperability introduced starting Fortran 2003 and enhanced in 2018.  That will get you a long way in what you are trying to do.  You can then get your Fortran code processed using Intel Fortran to work with Microsoft C/C++ compiler and that would indicate a very, very strong chance of being usable from VB .NET.

I will strongly advise staying away from the earlier COM-era "SAFEARRAYS" and other nonsense you will notice in Intel documentation and pursue the newer marshaling options developed by Microsoft as part of the above-mentioned P/Invoke layer.

0 Kudos
WesJD
Novice
877 Views

@FortranFan , thank you for those pointers. 

0 Kudos
FortranFan
Honored Contributor III
831 Views

@WesJD wrote:

.. When I try to adapt the example with my code I'm getting errors I don't understand. ..


@WesJD ,

Hope you will agree a way to figure out how to do something is by actually doing and looking at ways of how to solve specific hurdles you face along the way, or considering different or better ways of accomplishing the needed tasks.

If you can post somewhere online, either at this forum or perhaps at Fortran Discourse site https://fortran-lang.discourse.group/ also since your inquiries will be more a general how to interoperate Fortran with a C companion processor in order to work with Visual Basic .NET question than Intel Fortran specific issues, other Fortran-minded readers may have a lot of pointers for you on how to get it to work.

I too will be more than happy to offer whatever inputs I can come up with: if you search this site for my handle and .NET you will find a lot of fully worked out examples toward various aspects of getting interoperating Fortran with .NET, both C# and Visual Basic.

0 Kudos
Reply