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

Pointer size?

drb
Beginner
2,209 Views
Hello!
I am currently looking at a new dataset that has been designed by a colleague. I am trying to determine the size of the data that will be stored, and know the size of integers and reals. I cannot seem to find the size of a F90 pointer.
For example, I have:
INTEGER(INT4), DIMENSION(:), POINTER :: MyArray
Can anyone tell me the size of the pointer?
Thanks
Ben
0 Kudos
8 Replies
ArturGuzik
Valued Contributor I
2,209 Views
I don't know what you mean exactly and whether I answer your question but (here fromdocumentation):
A pointer does not contain data, but points to a scalar or array variable where data is stored. ...memory storage is created for the pointer as a program runs. No storage space is created for a pointer until it is allocated with an ALLOCATE statement or until it is assigned to a allocated target.
All you know is that it will be a vector of integers. Once the memmory is allocated you can get the size (no. of elements) by: size(MyArray).
A.
0 Kudos
Steven_L_Intel1
Employee
2,209 Views
A Fortran 9x pointer can be either the size of an address, or can be a data structure with many elements, depending on whether the thing being pointed to is a scalar or an array. This is discussed in the User Manual/Programmer's Guide chapter on mixed-language programming.
Intel Fortran 8.0 and CVF offers the INT_PTR_KIND intrinsic to return the "kind" of an integer pointer, the kind used in the so-called "Cray POINTER" extension.
Steve
0 Kudos
drb
Beginner
2,209 Views
Thankyou for the very quick replies! I tried to reply once but my net connection went down :(
I have re-read my original query, and it wasnt as clear on the screen as it is in my head. If I have an INTEGER of type INT4, then I know that the variables that I state after this will have size 4 bytes, that is that they will take 4 bytes to store the variable value.
So, what I meant to ask was, what is the size of the pointer? I think that the question has been answered now, so I'll do some more reading of the manuals.
Many thanks!
Ben
0 Kudos
Steven_L_Intel1
Employee
2,209 Views
In the example you give, the size of the pointer is some 28 or 32 bytes, I forget which, and it depends on the compiler version. This is because it is an array and the pointer needs to describe the bounds and strides of the array.
0 Kudos
drb
Beginner
2,209 Views

Thanks once again.

I have found the page now for the manual, I had a suspicion that there was more than just the address being stored in the pointer. So I guess that we can save some memory overhead by using just the cray pointer (c-type) pointers (if this is possible).

Thankyou for the speedy responses!

Ben

0 Kudos
durisinm
Novice
2,209 Views

I don't understand why the F95 pointer to an array or structure needs to contain all that information. Why don't all the pointers contain just the starting address of the data like the pointer to a scalar variable does?

Mike D.

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,209 Views

Because F90 pointer 1) may be non-contiguous (pointing to an array section) 2) has a well-definedsize and shapewhich can be queried using SIZE, SHAPE or other intrinsics.

Jugoslav

0 Kudos
drb
Beginner
2,209 Views

We have noticed a time penalty when pointing temporary pointers to defined ones, ie:

TT => TT(n)%AA

I am going to do some tests to see if I can use the cray pointer style to save both memory and time, considering that we do not use the intrinsic functions (SIZE etc) as mentioned above.

Ben

0 Kudos
Reply