Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
23 Views

how can i use pointer like C pointer?

i have a think ,i hope use pointer like C ,following is c code: ......... char * data; int *iptr; float* fptr; double * dbptr; data = new char[100*4]; iptr = (int *)&data[0]; fptr = (float *)&data[0]; dbptr = (double *)&data[0]; i not't kown how can code this use fortran pointer? please tell me answer, thanks.
0 Kudos
2 Replies
Highlighted
New Contributor III
23 Views

Hi Qiu.

you might find integer pointers helpful (sometimes called Cray pointers), which are non-standard Fortran but supported also by Intel compilers and gfortran:

https://software.intel.com/en-us/node/679644

https://gcc.gnu.org/onlinedocs/gfortran/Cray-pointers.html

I don't know in which context you like to use it, but maybe the associate construct is what you like to have?

https://software.intel.com/en-us/node/679014

Best regards, Johannes

0 Kudos
Highlighted
Beginner
23 Views

Fortran tries to prevent you from aliasing the same data as integer, real, and double.  That's really really bad programming practice, hopefully you know this.  In Fortran you can also look at the TRANSFER intrinsic if you really want to treat the data as different intrinsic data types for different purposes.

0 Kudos