インテル® Fortran コンパイラー 14.0 ユーザー・リファレンス・ガイド
Run-Time Subroutine: Creates an array descriptor in memory.
CALL FOR_DESCRIPTOR_ASSIGN (dp,base,size,reserved,rank,dims_info)
The FOR_DESCRIPTOR_ASSIGN routine is similar to a Fortran pointer assignment, but gives you more control over the assignment, allowing, for example, assignment to any location in memory.
You can also use this routine to create an array that can be used from both Fortran or C.
use IFCORE
common/c_array/ array
real(8) array(5,5)
external init_array
external c_print_array
real(8),pointer :: p_array(:,:)
type(FOR_DIMS_INFO) dims_info(2)
call init_array()
do i=1,5
do j=1,5
print *,i,j, array(i,j)
end do
end do
dims_info(1)%LOWERBOUND = 11
dims_info(1)%UPPERBOUND = 15
dims_info(1)%STRIDE = 1
dims_info(2)%LOWERBOUND = -5
dims_info(2)%UPPERBOUND = -1
dims_info(2)%STRIDE = 1
call FOR_DESCRIPTOR_ASSIGN(p_array, &
LOC(array), &
SIZEOF(array(1,1)), &
FOR_DESCRIPTOR_ARRAY_DEFINED .or. &
FOR_DESCRIPTOR_ARRAY_NODEALLOC .or. &
FOR_DESCRIPTOR_ARRAY_CONTIGUOUS, &
2, &
dims_info )
p_array = p_array + 1
call c_print_array()
end
The following shows the C program containing init_array and c_print_array:
#include <stdio.h>
#if !defined(_WIN32) && !defined(_WIN64)
#define C_ARRAY c_array_
#define INIT_ARRAY init_array_
#define C_PRINT_ARRAY c_print_array_
#endif
double C_ARRAY[5][5];
void INIT_ARRAY(void);
void C_PRINT_ARRAY(void);
void INIT_ARRAY(void)
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
C_ARRAY[i][j] = j + 10*i;
}
void C_PRINT_ARRAY(void)
{
int i,j;
for(i=0;i<5;i++){
for(j=0;j<5;j++)
printf("%f ", C_ARRAY[i][j]);
printf("\n");
}
}