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

Array base address in array descriptor

marcellocattaneo
Beginner
922 Views
I am using the routines provided in the DESCRIPT.F90 example to extract from the array descriptor the address of the first element of a pointer array.
I then pass this address to a C routine, together with array dimensions; the array will be further manipulated in the C part of the code.
As described in the CVF documentation (Programmers Guide, 18.3.4) the address of the start of the array should be
d%base + d%offset. However, my C program did not recognize the start of the array when using this location, and it worked perfectly well when using d%base (w/o adding the offset value).
Is there something wrong in the way I am interpreting the code in the Descript module?
I am worried that the workaround was pure chance and that it wont work in the future, when deployed in an actual application.
See the attached workspace files and source code in the ANN_Workspace.ZIP file.

Marcello Cattaneo
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
922 Views
No, you're actually perfectly fine with D.base (without seeing your code).

Actually, as far as I know, D.offset only compensates for the fact that Fortran arrays are 1-based, so that further computation is slightly simpler.

So, X(i) = *(D.base + D.offset + i*D.sizeof)

(I'm not sure what's the value of D.offset for Fortran arrays with starting index other than 1 though.)

Jugoslav
0 Kudos
marcellocattaneo
Beginner
922 Views
Thanks ... I was under the impression that offset referred to a memory offset!
Marcello
0 Kudos
Reply