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

How to create Fortran array referencing SafeArrayAccessData

MWind2
新分销商 III
10,446 次查看

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 项奖励
1 解答
Steve_Lionel
名誉分销商 III
10,384 次查看

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.

在原帖中查看解决方案

23 回复数
MWind2
新分销商 III
1,337 次查看

New dll for adding more dimensions with 2d working

0 项奖励
Steve_Lionel
名誉分销商 III
1,332 次查看

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

0 项奖励
MWind2
新分销商 III
1,313 次查看

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

0 项奖励
回复