Handling Intel Fortran Pointers

Intel Fortran (integer) pointers are not the same as Fortran 90 pointers, but are instead like C pointers. On IA-32 systems, Intel Fortran pointers are 4-byte INTEGER quantities. On ItaniumŪ-based systems, Intel Fortran pointers are 8-byte INTEGER quantities.

When passing an Intel Fortran pointer to a routine written in another language:

When receiving a pointer from a routine written in another language:

For example, on IA-32 systems:

 ! Fortran subroutine.      SUBROUTINE Iptr_Sub (p)      !DEC$ ATTRIBUTES C, ALIAS:'_Iptr_Sub' :: Iptr_Sub         integer VAR(10)         POINTER (p, VAR)         OPEN (8, FILE='STAT.DAT')         READ (8, *) VAR(4) ! Read from file and store the                            ! fourth element of VAR      END SUBROUTINE Iptr_Sub ! //C main program extern void Iptr_Sub(int *p); main ( void ) {   int a[10];   Iptr_Sub (&a[0]);   printf("a[3] = %i\n", a[3]); }

On Itanium-based systems, the alias name for Iptr_Sub should not have a leading underscore:

   !DEC$ ATTRIBUTES C, ALIAS:'Iptr_Sub' :: Iptr_Sub

When the main C program and Fortran subroutine are built and executed, the following output appears if the STAT.DAT file contains 4:

   a[3] = 4