sanyibacsi
Programmer
Hello There,
Well, I hope to get some help from here since the actual problem is happening on the C side... but it is quite Fortan related.
I call a C function from a Fortran somehow like:
The C code looks more or less like:
I try to print the values arriving from Fortran. I think that the problem with the code above is that it just converts one character to float so I tried to convert four consecutive characters making up a number but did not succeed. It is not even clear to me what would be the order of the incoming variables since those dimension allocations are not quite conventional I guess.
Would somebody be able to help me explaining what structure of data should I expect and how to convert that from the type as those are?
Thank you very much,
Sandor
Well, I hope to get some help from here since the actual problem is happening on the C side... but it is quite Fortan related.
I call a C function from a Fortran somehow like:
Code:
type fe_node_property
real, allocatable, dimension(:,:) :: xf
integer, allocatable, dimension(:,:) :: prop
integer, allocatable, dimension(:) :: mat
end type fe_node_property
type(fe_node_property) :: fe_node
integer :: size1, size2
! size1 == size of xf and mat, xf first dimension is 3
! size2 = second dimension of prop, first dimension is 3
call cppfunc(size1, size2, fe_node)
The C code looks more or less like:
Code:
extern "C" {
void cppfunc_(int *pSize1, int *pSize2, char *pNode)
}
void cppfunc(int *pSize1, int *pSize2, char *pNode) {
for (int i = 0; i < *pSize1; i++) {
printf("%d float1, 2, 3: %f, %f, %f\n", i, (float)*(pNodes + (i * 3), (float)*(pNodes + (i * 3) + 1), (float)*(pNodes + (i * 3) + 2));
}
}
I try to print the values arriving from Fortran. I think that the problem with the code above is that it just converts one character to float so I tried to convert four consecutive characters making up a number but did not succeed. It is not even clear to me what would be the order of the incoming variables since those dimension allocations are not quite conventional I guess.
Would somebody be able to help me explaining what structure of data should I expect and how to convert that from the type as those are?
Thank you very much,
Sandor