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

How to create Fortran array referencing SafeArrayAccessData

MWind2
New Contributor III
2,670 Views

VBArray INOUT length known
integer(C_INTPTR_T) :: dptr
...
iRes=SafeArrayAccessData(VBArray,dptr)
dptr address is starting point of one dimensional c array of real{8}

I want to put it in a Fortran array so I can see it in debugger for one reason, but I want the Fortran array to reference the underlying data and not be a copy. Intention would be changes to data in Fortran array would be preserved in dptr array.

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
2,608 Views

Two errors. First, you omitted the size argument I specified to C_F_POINTER. Second, you treated the array as if it were zero-origin, but the array you get from C_F_POINTER is one-origin. (This could be finessed with pointer assignment redeclaring the bounds, but that seems unnecessary.)

I attach my modified df.f90. I didn't change anything else.

View solution in original post

23 Replies
MWind2
New Contributor III
347 Views

New dll for adding more dimensions with 2d working

0 Kudos
Steve_Lionel
Honored Contributor III
342 Views

I'm glad to see that you sorted this out.

0 Kudos
MWind2
New Contributor III
323 Views

Here's general code tested in 2d and 3d. Thanks for help and previous example with strings.

0 Kudos
Reply