In Fortran I have a an array specified as:
dimension insv(*)
Now I would like to edit this array from C. I managed to read the array from C by using the iso_c_binding:
SUBROUTINE userroutine(insv)
IMPLICIT NONE
INTERFACE
SUBROUTINE MODIFYARRAY(insv) BIND(C)
USE, INTRINSIC::ISO_C_BINDING
REAL(C_DOUBLE),DIMENSION(*), INTENT(INOUT) :: insv
END SUBROUTINE MODIFYARRAY
END INTERFACE
dimension insv(*)
WRITE(insv(0))
call modifyarray(insv)
WRITE(insv(0))
END
My C function:
__declspec(dllexport) void modifyarray(double * insv)
But modifying a value in this array in C either crashes or simply doesnt get changed at all.
__declspec(dllexport) void modifyarray(double * insv)
{
insv[0] = 1234.00;
}
Im not sure as to what i should change to the iso_c_binding or the C function to make this work.
Some more context: The fortran array type cannot be changed since the dimension variable is a parameter of a userroutine, not in my control, so to say. The array is already filled when entering the fortran function, but needs to be modified in C.
insvis an integer array. The subroutine is expecting a real argument.implicit noneand including all variable declarations.