If I have a Fortran subroutine which takes a Fortran IO Unit as one of its parameters (for printing debug information to), and this function is compiled into a shared library, how do I correctly call this function from C?
! An example subroutine that I want to call from C:
subroutine hi(unit)
integer :: unit
write(unit,*) "hello"
end subroutine
! example call site in Fortran
program main
call hi(6)
end
I am interested in how these unit numbers relate to file descriptors.
This is completely compiler dependent, there is no portable correspondence. See the manual of your compiler if they support some sort of interoperability as an extension.