int main(void){
int a=2;
sb(&a);
return 0;
}
and
module myadd
use iso_c_binding
implicit none
contains
subroutine add1(a) bind(c)
implicit none
integer (c_int),intent (inout) :: a
a=a+1
end subroutine add1
end module myadd
!sb.f90
subroutine sq(a) bind(c, name="sb")
use iso_c_binding
use myadd
implicit none
integer (c_int), intent(inout) :: a
call add1(a)
a=a*a
end subroutine sq
with
gcc -c main.c
gfortran-debug fort_subs.f90 main.o
It is easier to link with the Fortran compiler because it brings in the Fortran libraries.