I'm experimenting with the iso_fortran_binding facilities. I have found something that may be a bug.
The compiler Version is:16.0.0.109 Build 20150815
I have written the following C routine:
#include <stdio.h>
#include "ISO_Fortran_binding.h"
void printarraydesc(const CFI_cdesc_t * vin) {
CFI_index_t i;
printf("Array\n");
printf("Rank: %d\n", vin-> rank);
for(i=0; i<vin->rank; i++) {
printf("Dimension: %d ", i);
printf("lbounds %d ", vin->dim[i].lower_bound);
printf("extent %d ", vin->dim[i].extent);
printf("stride %d\n", vin->dim[i].sm);
}
}And the following Fortran program:
program smalltest
implicit none
interface
subroutine printarraydesc(vin) bind(C,name="printarraydesc")
type(*),intent(in) :: vin(..)
endsubroutine
end interface
real :: a(3,4)
call printarraydesc(a)
call printarraydesc(a(3,:))
end program
While the first descriptor is correctly written, it seems that the second one is not. The rank is not passed correctly. It prints:
Array Rank: 2 Dimension: 0 lbounds 0 extent 3 stride 4 Dimension: 1 lbounds 0 extent 4 stride 12 Array Rank: 2 Dimension: 0 lbounds 0 extent 4 stride 12 Dimension: 1 lbounds 993324632 extent 2051380828 stride 993324632