Hi,

Modern Fortran has a feature called ISO_C_BINDING. It essentially
allows to declare a binding of external function to be used from
Fortran program. You only need to provide a corresponding interface.
ISO_C_BINDING module contains C-like extensions in type system, but
you don't need them, as your function has no arguments :)

Example:

program fork_test

interface

function fork() bind(C)
use iso_c_binding
integer(c_int) :: fork
end function fork

end interface

print *, 'My PID = ', fork()

end program fork_test

$ make
gfortran fork.f90 -o fork
$ ./fork
 My PID =         4033
 My PID =            0

For further info, please refer to language standard
http://gcc.gnu.org/wiki/GFortranStandards#Fortran_2003
If you have any questions - consider asking the gfortran community,
they are very friendly.

Best,
- D.

2012/8/30 sudhirs@ <sudhirche...@gmail.com>:
> Dear users,
>  How to use fork(), vfork() type functions in Fortran programming ??
>
> Thanking you in advance
>
> --
> Sudhir Kumar Sahoo
> Ph.D Scholar
> Dept. Of Chemistry
> IIT Kanpur-208016
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users

Reply via email to