For reasons that are not relevant, I need to pass a C/C++ function name into a Fortran subroutine, which, in turn, calls that C function. What I have found is that I can succesf
I would change the interface definition to read
interface
subroutine calledfromFortran(status) bind (c)
use iso_c_binding
integer(kind = c_int), VALUE :: status
end subroutine calledfromFortran
end interface
I am not sure what intent(in)
was, but that bit of the code does not look right. Apart for that, the rest looks (at first pass) reasonable and right.
Note. The ISO C bindings were only added in the 2003 releae of the FORTRAN language, so if you are using an older version it might be worth checking the compiler documentation for details. Some compilers allow ISO C bindings, but maybe called slightly differently than that I have displayed above.
Edit. Having looked into the intent
keyword, you might try using intent(in)
in conjunction with the following type declaration, that follows the interface
definition
integer (c_int), parameter :: one = 2
I hope this helps.