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

Accessing fortran variables from c#

drbath
Beginner
1,436 Views
I've looked everywhere on the internet for accessing Fortran common block variables in C#, can't really find anything. Does anyone have any idea how to do this? I can get access to Fortran subroutines, functions, etc. but cant seem to get to common blocks. I've got over 500 Fortran variables I need to get access to and writing get or set subroutines in Fortran would be very time consuming.

Any ideas?
0 Kudos
6 Replies
bmchenry
New Contributor II
1,436 Views
Is there a need to continue to use common blocks? (do you require some form of linear arrangement of the data?)
You should simply move the common block data in tomodules which can be easily shared with c#.

0 Kudos
Steven_L_Intel1
Employee
1,436 Views
The problem is that C# is a .NET language and does not link into the same address space as non-managed code, so there is no sharing of vartiables. Writing access routines is perhaps the best way. You could reduce the work by getting the address of the first variable in each COMMON block and using that as a pointer to a struct of the appropriate layout.
0 Kudos
drbath
Beginner
1,436 Views
Quoting - bmchenry
Is there a need to continue to use common blocks? (do you require some form of linear arrangement of the data?)
You should simply move the common block data in tomodules which can be easily shared with c#.

How would access a module in c#? Would it be the same as a subprogram?
0 Kudos
Steven_L_Intel1
Employee
1,436 Views
Do you mean module variables? The same issue would arise as with a COMMON.
0 Kudos
bmchenry
New Contributor II
1,436 Views
My apologies. I use several Fortran compilers and was referrring to a .NET fortran compiler (Salford) for linking data. The process requires use of an Assembly Middle man for real time sharing of data.
I prefer to use the Intel fortran compiler for most of my problem solutions because i believe the .NET framework is primed for piracy. No security of code nor data!
So again, i apologize for responding as if you were using a different compiler.
0 Kudos
drbath
Beginner
1,436 Views
The problem is that C# is a .NET language and does not link into the same address space as non-managed code, so there is no sharing of vartiables. Writing access routines is perhaps the best way. You could reduce the work by getting the address of the first variable in each COMMON block and using that as a pointer to a struct of the appropriate layout.
Thanks for the help Steve - Access routines sounds like the best solutions right now.
0 Kudos
Reply